tab3.vue 15 KB

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