174e6991459e6373f1f0134b6d07a520548e75f1.svn-base 14 KB

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