tab2.vue 15 KB

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