48c2130ed5aab953bf5bac8cd815b7a0bf4ece07.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <div class="app-content">
  3. <div class="search">
  4. <el-select v-model="table.getdataListParm.parammaps.pastureid" placeholder="牧场" class="filter-item" style="width: 120px;">
  5. <el-option v-for="item in pastureList" :key="item.pastureid" :label="item.pasturename" :value="item.pastureid" />
  6. </el-select>
  7. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" :clearable="false" style="width: 250px;" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" />
  8. <el-button style="float: left;" :disabled="Beforedisabled" class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  9. <el-button style="float: left;" :disabled="Nextdisabled" class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  10. <el-input v-model="table.getdataListParm.parammaps.tmrtname" style="width: 110px;" placeholder="TMR名称" class="filter-item" clearable />
  11. <el-input v-model="table.getdataListParm.parammaps.projname" style="width: 110px;" placeholder="车次" class="filter-item" clearable />
  12. <el-select v-model="table.getdataListParm.parammaps.times" style="width: 100px;" filterable placeholder="班次" class="filter-item" clearable>
  13. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  14. </el-select>
  15. <el-input v-model="table.getdataListParm.parammaps.templetname" style="width: 110px;" placeholder="配方名称" class="filter-item" clearable />
  16. <el-input v-model="table.getdataListParm.parammaps.fname" style="width: 110px;" placeholder="栏舍名称" class="filter-item" clearable />
  17. <el-select v-model="table.getdataListParm.parammaps.buttontype" style="width: 110px;" filterable placeholder="跳转方式" class="filter-item" clearable>
  18. <el-option v-for="item in jumpModeList" :key="item.id" :label="item.name" :value="item.id" />
  19. </el-select>
  20. <el-select v-model="table.getdataListParm.parammaps.isuse" style="width: 130px;" filterable placeholder="上传状态" class="filter-item" clearable>
  21. <el-option v-for="item in isuseList" :key="item.id" :label="item.name" :value="item.id" />
  22. </el-select>
  23. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  24. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  25. <el-button class="export" style="float: right;margin-right: 10px;margin-bottom:10px;" @click="handleExport">导出</el-button>
  26. </div>
  27. <div class="table">
  28. <el-table
  29. :key="table.tableKey"
  30. v-loading="table.listLoading"
  31. element-loading-text="给我一点时间"
  32. :data="table.list"
  33. border
  34. fit
  35. highlight-current-row
  36. style="width: 100%;"
  37. :row-style="rowStyle"
  38. :cell-style="cellStyle"
  39. class="elTable table-fixed"
  40. >
  41. <el-table-column label="牧场" min-width="110px" align="center" prop="牧场" />
  42. <el-table-column label="日期" min-width="110px" align="center" prop="日期" />
  43. <el-table-column label="TMR名称" min-width="110px" align="center" prop="TMR名称" />
  44. <el-table-column label="车次" min-width="110px" align="center" prop="车次" />
  45. <el-table-column label="班次" min-width="110px" align="center" prop="班次" />
  46. <el-table-column label="配方名称" min-width="110px" align="center" prop="配方名称" />
  47. <el-table-column label="栏舍" min-width="110px" align="center" prop="栏舍" />
  48. <el-table-column label="理论重量" min-width="110px" align="center" prop="理论重量" />
  49. <el-table-column label="实际重量" min-width="110px" align="center" prop="实际重量" />
  50. <el-table-column label="误差值" min-width="110px" align="center" prop="误差值" />
  51. <el-table-column label="准确率" min-width="110px" align="center" prop="准确率" />
  52. <el-table-column label="开始时间" min-width="110px" align="center" prop="开始时间" />
  53. <el-table-column label="结束时间" min-width="110px" align="center" prop="结束时间" />
  54. <!-- <el-table-column label="搅拌时间" min-width="70px" align="center" prop="搅拌时间" /> -->
  55. <el-table-column label="跳转方式" min-width="110px" align="center" prop="跳转方式" />
  56. <el-table-column label="开始重量" min-width="110px" align="center" prop="开始重量" />
  57. <el-table-column label="结束重量" min-width="110px" align="center" prop="结束重量" />
  58. </el-table>
  59. <!-- <pagination v-show="tab3.table.total>=0" :total="tab3.table.total" :page.sync="tab3.table.getdataListParm.offset" :limit.sync="tab3.table.getdataListParm.pagecount" @pagination="getTab3List" /> -->
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import echarts from 'echarts'
  65. require('echarts/theme/macarons')
  66. import { GetDataByName, GetReportform, GetDataByNames } from '@/api/common'
  67. import Cookies from 'js-cookie'
  68. import { parseTime } from '@/utils/index.js'
  69. import Pagination from '@/components/Pagination'
  70. import { json2excel } from '@/utils/index.js'
  71. import { MessageBox } from 'element-ui'
  72. export default {
  73. name: 'Tab2',
  74. components: { Pagination },
  75. data() {
  76. return {
  77. Beforedisabled: false,
  78. Nextdisabled: false,
  79. pickerMinDate: '',
  80. pickerOptions: {
  81. onPick: ({ maxDate, minDate }) => {
  82. this.pickerMinDate = minDate.getTime()
  83. if (maxDate) {
  84. this.pickerMinDate = ''
  85. }
  86. },
  87. // 限制不能选择今天之后的日期
  88. disabledDate: (time) => {
  89. if (this.pickerMinDate !== '') {
  90. const one = 31 * 24 * 3600 * 1000
  91. const minTime = this.pickerMinDate - one
  92. let maxTime = this.pickerMinDate + one
  93. if (maxTime > new Date()) {
  94. maxTime = new Date()
  95. }
  96. return time.getTime() < minTime || time.getTime() > maxTime
  97. }
  98. return time.getTime() > Date.now()
  99. }
  100. },
  101. requestParams: [
  102. { name: 'getPastureListJT', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid'), pasturename: '' }}
  103. ],
  104. pastureList: [], // 牧场
  105. // 班次
  106. maxTime: {
  107. getMaxTimesParm: {
  108. name: 'getSysoptEnable',
  109. page: 1,
  110. offset: 1,
  111. pagecount: 1,
  112. returntype: 'Map',
  113. parammaps: {
  114. pastureid: Cookies.get('pastureid'),
  115. inforname: 'times'
  116. }
  117. }
  118. },
  119. jumpModeList: [{ id: '0', name: '手动跳转' }, { id: '1', name: '自动跳转' }],
  120. frequencyList: [],
  121. isuseList: [{ id: '0', name: '未完成' }, { id: '2', name: '部分完成' }, { id: '1', name: '全部完成' }],
  122. table: {
  123. getdataListParm: {
  124. name: 'getStatisticsSL',
  125. page: 1,
  126. offset: 1,
  127. pagecount: '',
  128. returntype: 'Map',
  129. parammaps: {
  130. pastureid: Cookies.get('pastureid'),
  131. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  132. stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
  133. inputDatetime: [new Date(), new Date()],
  134. tmrtname: '',
  135. projname: '',
  136. times: '',
  137. templetname: '',
  138. fname: '',
  139. buttontype: '',
  140. isuse: ''
  141. }
  142. },
  143. tableKey: 1,
  144. list: [],
  145. total: 0,
  146. listLoading: true,
  147. temp: {}
  148. },
  149. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  150. cellStyle: { padding: 0 + 'px' }
  151. }
  152. },
  153. create() {
  154. this.getDownList()
  155. this.getIsDisplay()
  156. },
  157. activated() {
  158. this.getTimeFn()
  159. this.getDownList()
  160. this.getIsDisplay()
  161. },
  162. methods: {
  163. getTimeFn() {
  164. const that = this
  165. const start = new Date()
  166. const end = new Date()
  167. const start2 = new Date()
  168. const end2 = new Date()
  169. start2.setTime(start2.getTime() - 3600 * 1000 * 24 * 1)
  170. end2.setTime(end2.getTime() - 3600 * 1000 * 24 * 1)
  171. that.table.getdataListParm.parammaps.inputDatetime = [start2, end2]
  172. that.table.getdataListParm.parammaps.startTime = parseTime(start2, '{y}-{m}-{d}')
  173. that.table.getdataListParm.parammaps.stopTime = parseTime(end2, '{y}-{m}-{d}')
  174. },
  175. getIsDisplay() {
  176. GetDataByName(this.maxTime.getMaxTimesParm).then(response => {
  177. if (response.data.list[0].inforvalue == 1) {
  178. this.frequencyList = [{ id: '1', name: '第一班' }]
  179. } else if (response.data.list[0].inforvalue == 2) {
  180. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }]
  181. } else if (response.data.list[0].inforvalue == 3) {
  182. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  183. } else if (response.data.list[0].inforvalue == 4) {
  184. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
  185. }
  186. })
  187. },
  188. getDownList() {
  189. GetDataByNames(this.requestParams).then(response => {
  190. this.pastureList = response.data.getPastureListJT.list
  191. this.table.getdataListParm.parammaps.pastureid = response.data.getPastureListJT.list[0].pastureid
  192. this.getList()
  193. })
  194. },
  195. getList() {
  196. this.table.listLoading = true
  197. GetDataByName(this.table.getdataListParm).then(response => {
  198. console.log('撒料统计table数据', response.data.list)
  199. if (response.data.list !== null) {
  200. this.table.list = response.data.list
  201. this.table.total = response.data.total
  202. } else {
  203. this.table.list = []
  204. }
  205. setTimeout(() => {
  206. this.table.listLoading = false
  207. }, 100)
  208. })
  209. },
  210. handleSearch() {
  211. this.table.getdataListParm.name = 'getStatisticsSL'
  212. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  213. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  214. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  215. } else {
  216. this.table.getdataListParm.parammaps.inputDatetime = ''
  217. this.table.getdataListParm.parammaps.startTime = ''
  218. this.table.getdataListParm.parammaps.stopTime = ''
  219. }
  220. this.table.getdataListParm.offset = 1
  221. this.getList()
  222. },
  223. handleRefresh() {
  224. this.table.getdataListParm.parammaps.tmrtname = ''
  225. this.table.getdataListParm.parammaps.projname = ''
  226. this.table.getdataListParm.parammaps.times = ''
  227. this.table.getdataListParm.parammaps.templetname = ''
  228. this.table.getdataListParm.parammaps.buttontype = ''
  229. this.table.getdataListParm.parammaps.fname = ''
  230. this.getList()
  231. },
  232. handleExport() {
  233. var excelDatasTab3 = [
  234. {
  235. tHeader: ['日期', 'TMR名称', '车次', '班次', '配方名称', '栏舍', '理论重量', '实际重量', '误差值', '准确率', '开始时间', '结束时间', '跳转方式', '开始重量', '结束重量', '搅拌时间'],
  236. filterVal: ['日期', 'TMR名称', '车次', '班次', '配方名称', '栏舍', '理论重量', '实际重量', '误差值', '准确率', '开始时间', '结束时间', '跳转方式', '开始重量', '结束重量', '搅拌时间'],
  237. tableDatas: this.tab3.table.list,
  238. sheetName: '撒料统计'
  239. }
  240. ]
  241. json2excel(excelDatasTab3, '撒料统计', true, 'xlsx')
  242. },
  243. handleBefore() {
  244. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  245. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  246. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  247. if (stop > Date.now() - 8.64e7) {
  248. this.Nextdisabled = true
  249. this.Beforedisabled = false
  250. } else {
  251. this.Nextdisabled = false
  252. this.Beforedisabled = false
  253. }
  254. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  255. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  256. this.$forceUpdate()
  257. }
  258. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  259. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  260. this.getList()
  261. },
  262. handleNext() {
  263. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  264. var start2 = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  265. var stop2 = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  266. if (stop2 > Date.now() - 8.64e7) {
  267. this.Nextdisabled = true
  268. this.Beforedisabled = false
  269. } else {
  270. this.Nextdisabled = false
  271. this.Beforedisabled = false
  272. }
  273. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  274. this.table.getdataListParm.parammaps.inputDatetime.push(start2, stop2)
  275. this.$forceUpdate()
  276. }
  277. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  278. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  279. this.getList()
  280. }
  281. }
  282. }
  283. </script>
  284. <style>
  285. </style>