e01c498f37743344714a09c254959df3141e2a7d.svn-base 14 KB

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