0be188cbacd3a3f0eae76131b8a3e1bc5a7c638c.svn-base 11 KB

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