100e7fa67bc8dc8092a5f7a1c09e06a09af6666a.svn-base 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. :height="myHeight2"
  40. >
  41. <el-table-column label="牧场" min-width="90px" align="center" prop="牧场" />
  42. <el-table-column label="日期" min-width="70px" align="center" prop="日期" />
  43. <el-table-column label="TMR名称" min-width="70px" align="center" prop="TMR名称" />
  44. <el-table-column label="车次" min-width="50px" align="center" prop="车次" />
  45. <el-table-column label="班次" min-width="50px" align="center" prop="班次" />
  46. <el-table-column label="配方名称" min-width="90px" align="center" prop="配方名称" />
  47. <el-table-column label="饲料" min-width="70px" align="center" prop="饲料" />
  48. <el-table-column label="理论重量" min-width="55px" align="center" prop="理论重量" />
  49. <el-table-column label="实际重量" min-width="55px" align="center" prop="实际重量" />
  50. <el-table-column label="误差值" min-width="45px" align="center" prop="误差值" />
  51. <el-table-column label="准确率" min-width="45px" align="center" prop="准确率" />
  52. <el-table-column label="计划时间" min-width="55px" align="center" prop="计划时间" />
  53. <el-table-column label="开始时间" min-width="55px" align="center" prop="开始时间" />
  54. <el-table-column label="结束时间" min-width="55px" align="center" prop="结束时间" />
  55. <el-table-column label="搅拌时间" min-width="55px" 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>
  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. frequencyList: [],
  120. jumpModeList: [{ id: '0', name: '手动跳转' }, { id: '1', name: '自动跳转' }],
  121. isuseList: [{ id: '0', name: '未完成' }, { id: '2', name: '部分完成' }, { id: '1', name: '全部完成' }],
  122. table: {
  123. getdataListParm: {
  124. name: 'getStatisticsHL',
  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. buttontype: '',
  138. templetname: ''
  139. }
  140. },
  141. tableKey: 1,
  142. list: [],
  143. total: 0,
  144. listLoading: true,
  145. temp: {}
  146. },
  147. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  148. cellStyle: { padding: 0 + 'px' },
  149. myHeight2:document.documentElement.clientHeight - 85-210
  150. }
  151. },
  152. created() {
  153. this.getTimeFn()
  154. this.getDownList()
  155. this.getIsDisplay()
  156. },
  157. activated() {
  158. this.getDownList()
  159. this.getIsDisplay()
  160. },
  161. methods: {
  162. getTimeFn() {
  163. const that = this
  164. const start = new Date()
  165. const end = new Date()
  166. const start2 = new Date()
  167. const end2 = new Date()
  168. start2.setTime(start2.getTime() - 3600 * 1000 * 24 * 1)
  169. end2.setTime(end2.getTime() - 3600 * 1000 * 24 * 1)
  170. that.table.getdataListParm.parammaps.inputDatetime = [start2, end2]
  171. that.table.getdataListParm.parammaps.startTime = parseTime(start2, '{y}-{m}-{d}')
  172. that.table.getdataListParm.parammaps.stopTime = parseTime(end2, '{y}-{m}-{d}')
  173. },
  174. getIsDisplay() {
  175. GetDataByName(this.maxTime.getMaxTimesParm).then(response => {
  176. if (response.data.list[0].inforvalue == 1) {
  177. this.frequencyList = [{ id: '1', name: '第一班' }]
  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. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }]
  182. } else if (response.data.list[0].inforvalue == 3) {
  183. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  184. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  185. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }]
  186. } else if (response.data.list[0].inforvalue == 4) {
  187. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
  188. this.frequencyList = [{ id: '1', name: '第一班' }, { id: '2', name: '第二班' }, { id: '3', name: '第三班' }, { id: '4', name: '第四班' }]
  189. }
  190. })
  191. },
  192. getDownList() {
  193. GetDataByNames(this.requestParams).then(response => {
  194. this.pastureList = response.data.getPastureListJT.list
  195. this.table.getdataListParm.parammaps.pastureid = response.data.getPastureListJT.list[0].pastureid
  196. this.getList()
  197. })
  198. },
  199. getList() {
  200. this.table.listLoading = true
  201. GetDataByName(this.table.getdataListParm).then(response => {
  202. console.log('混料统计table数据', response.data.list)
  203. if (response.data.list !== null) {
  204. this.table.list = response.data.list
  205. this.table.total = response.data.total
  206. } else {
  207. this.table.list = []
  208. }
  209. setTimeout(() => {
  210. this.table.listLoading = false
  211. }, 100)
  212. })
  213. },
  214. handleSearch() {
  215. this.table.getdataListParm.name = 'getStatisticsHL'
  216. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  217. console.log(this.table.getdataListParm.parammaps.inputDatetime)
  218. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  219. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  220. } else {
  221. this.table.getdataListParm.parammaps.inputDatetime = ''
  222. this.table.getdataListParm.parammaps.startTime = ''
  223. this.table.getdataListParm.parammaps.stopTime = ''
  224. }
  225. this.table.getdataListParm.offset = 1
  226. this.getList()
  227. },
  228. handleRefresh() {
  229. this.table.getdataListParm.parammaps.tmrtname = ''
  230. this.table.getdataListParm.parammaps.projname = ''
  231. this.table.getdataListParm.parammaps.times = ''
  232. this.table.getdataListParm.parammaps.templetname = ''
  233. this.table.getdataListParm.parammaps.buttontype = ''
  234. this.getList()
  235. },
  236. handleBefore() {
  237. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  238. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  239. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  240. if (stop > Date.now() - 8.64e7) {
  241. this.Nextdisabled = true
  242. this.Beforedisabled = false
  243. } else {
  244. this.Nextdisabled = false
  245. this.Beforedisabled = false
  246. }
  247. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  248. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  249. this.$forceUpdate()
  250. }
  251. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  252. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  253. this.getList()
  254. },
  255. handleNext() {
  256. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  257. var start2 = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  258. var stop2 = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  259. if (stop2 > Date.now() - 8.64e7) {
  260. this.Nextdisabled = true
  261. this.Beforedisabled = false
  262. } else {
  263. this.Nextdisabled = false
  264. this.Beforedisabled = false
  265. }
  266. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  267. this.table.getdataListParm.parammaps.inputDatetime.push(start2, stop2)
  268. this.$forceUpdate()
  269. }
  270. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  271. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  272. this.getList()
  273. },
  274. handleExport() {
  275. var excelDatasTab2 = [
  276. {
  277. tHeader: ['日期', 'TMR名称', '车次', '班次', '配方名称', '饲料', '理论重量', '实际重量', '误差值', '准确率', '计划时间', '开始时间', '结束时间', ' 跳转方式', '开始重量', '结束重量', '搅拌时间'],
  278. filterVal: ['日期', 'TMR名称', '车次', '班次', '配方名称', '饲料', '理论重量', '实际重量', '误差值', '准确率', '计划时间', '开始时间', '结束时间', '跳转方式', '开始重量', '结束重量', '搅拌时间'],
  279. tableDatas: this.table.list,
  280. sheetName: '混料统计'
  281. }
  282. ]
  283. json2excel(excelDatasTab2, '混料统计', true, 'xlsx')
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang="scss" scoped>
  289. /deep/ .el-table th>.cell{
  290. padding-left: 0 !important;;
  291. padding-right: 0 !important;;
  292. }
  293. /deep/ .el-table td>.cell{
  294. padding-left: 0 !important;;
  295. padding-right: 0 !important;;
  296. }
  297. </style>