0767e7937d461bae63779033693d5c2e07b22fd6.svn-base 14 KB

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