index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" :range-separator="$t('common.to')" :start-placeholder="$t('common.startTime')" :end-placeholder="$t('common.endTime')" style="width: 250px;" />
  5. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  6. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  7. <el-select v-model="table.getdataListParm.parammaps.cowclassid" :placeholder="$t('feedingEfficiency.cxlb')" class="filter-item" style="width: 150px;" clearable>
  8. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  9. </el-select>
  10. <el-select v-model="table.getdataListParm.parammaps.feedid":placeholder="$t('InventoryManagement.silc')" class="filter-item" style="width: 150px;" filterable clearable>
  11. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  12. </el-select>
  13. <el-select v-model="table.getdataListParm.parammaps.ischarge" placeholder="是否审核" class="filter-item" style="width: 150px;" clearable>
  14. <el-option v-for="item in isAuditList" :key="item.id" :label="item.name" :value="item.id" />
  15. </el-select>
  16. <el-button class="successBorder" @click="form_search">{{$t('common.query')}}</el-button>
  17. <el-button class="successBorder" @click="handleRefresh">{{$t('common.reset')}}</el-button>
  18. </div>
  19. <div class="operation">
  20. <el-button v-if="isRoleEdit" class="success" icon="el-icon-document-checked" @click="handleExamine">审核</el-button>
  21. <el-button class="export" icon="el-icon-upload2" style="float: right;margin-right: 10px;" @click="handleExport">{{$t('formulationEvaluation.out')}}</el-button>
  22. </div>
  23. <div class="table">
  24. <el-table
  25. :key="table.tableKey"
  26. v-loading="table.listLoading"
  27. :element-loading-text="$t('common.tableMsg')"
  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. @selection-change="handleSelectionChange"
  37. >
  38. <el-table-column type="selection" align="center" width="50" />
  39. <el-table-column :label="$t('formulationEvaluation.xh')" align="center" type="index" width="50px">
  40. <template slot-scope="scope">
  41. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="业务日期" min-width="100px" align="center">
  45. <template slot-scope="scope">
  46. <span>{{ scope.row.usedate }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column :label="$t('errorAnalysis.sxlb')" min-width="100px" align="center">
  50. <template slot-scope="scope">
  51. <span>{{ scope.row.cowclass }}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column :label="$t('InventoryManagement.silc')" min-width="100px" align="center">
  55. <template slot-scope="scope">
  56. <span>{{ scope.row.feedname }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="是否预混料" min-width="100px" align="center">
  60. <template slot-scope="scope">
  61. <span>{{ scope.row.feedname }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="库存重量(kg)" min-width="100px" align="center">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.repertoryweight }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="计划重量(kg)" min-width="100px" align="center">
  70. <template slot-scope="scope">
  71. <span>{{ scope.row.planweight }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="设备实测重量(kg)" min-width="150px" align="center">
  75. <template slot-scope="scope">
  76. <span>{{ scope.row.actweight }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="出库重量(kg)" min-width="130px" align="center">
  80. <template slot-scope="scope">
  81. <span v-if="scope.row.NoEdit">{{ scope.row.operateweight }}</span>
  82. <el-input v-if="scope.row.Edit" v-model="scope.row.operateweight" placeholder="最多保留两位小数" type="number" :step="0.01" style="width:95%;padding:10px 0;" />
  83. </template>
  84. </el-table-column>
  85. <el-table-column :label="$t('formulationEvaluation.remark')" min-width="100px" align="center">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  88. <el-input v-if="scope.row.Edit" v-model="scope.row.remark"
  89. :placeholder="$t('supplier.zf1')" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="是否审核" min-width="100px" align="center">
  93. <template slot-scope="scope">
  94. <span v-if="scope.row.ischarge == 1">{{$t('feedChart.yes')}}</span>
  95. <span v-else>{{$t('feedChart.no')}}</span>
  96. </template>
  97. </el-table-column>
  98. <el-table-column :label="$t('errorAnalysis.cz')" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  99. <template slot-scope="{row}">
  100. <el-button v-if="row.isUpdate && row.ischarge !== 1 && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  101. <el-button v-if="row.isUpdateSave" :disabled="isokDisable" class="miniSuccess" icon="el-icon-folder-checked" @click="updateData(row)" />
  102. <el-button v-if="row.isUpdateSave" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  107. </div>
  108. </div>
  109. </template>
  110. <script>
  111. import { GetDataByName, GetDataByNames, checkButtons, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  112. import Pagination from '@/components/Pagination'
  113. import { MessageBox } from 'element-ui'
  114. import Cookies from 'js-cookie'
  115. import { parseTime, json2excel } from '@/utils/index.js'
  116. export default {
  117. name: 'SystemConsumption',
  118. components: { Pagination },
  119. data() {
  120. return {
  121. livestockTypeList: [], // 牲畜类别
  122. feedNameList: [{ id: 0, name: '羊草' }, { id: 1, name: '小苏打' }], // 饲料名称
  123. isAuditList: [{ id: '1',
  124. name:this.$t('supplier.yes')}, { id: '0',
  125. name:this.$t('supplier.no') }], // 是否审核
  126. requestParams: [
  127. { name: 'getFeedListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  128. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] }
  129. ],
  130. table: {
  131. getdataListParm: {
  132. name: 'getFeeduseList',
  133. page: 1,
  134. offset: 1,
  135. pagecount: parseInt(Cookies.get('pageCount')),
  136. returntype: 'Map',
  137. parammaps: {
  138. inputDatetime: '',
  139. pastureid: Cookies.get('pastureid'),
  140. startTime: '',
  141. stopTime: '',
  142. usetype: '系统用量',
  143. feedid: '',
  144. cowclassid: '',
  145. ischarge: ''
  146. }
  147. },
  148. tableKey: 0,
  149. list: [],
  150. total: 0,
  151. listLoading: true
  152. },
  153. selectList: [],
  154. requestParam: {},
  155. download: {
  156. getdataListParm: {
  157. name: 'getFeeduseList',
  158. page: 1,
  159. offset: 1,
  160. pagecount: 0,
  161. returntype: 'Map',
  162. parammaps: {
  163. inputDatetime: '',
  164. pastureid: Cookies.get('pastureid'),
  165. startTime: '',
  166. stopTime: '',
  167. usetype: '系统用量',
  168. feedid: '',
  169. cowclassid: '',
  170. ischarge: ''
  171. }
  172. },
  173. list: []
  174. },
  175. isokDisable: false,
  176. isRoleEdit: [],
  177. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  178. cellStyle: { padding: 0 + 'px' }
  179. }
  180. },
  181. created() {
  182. this.getButtons()
  183. this.getDownList()
  184. this.getList()
  185. },
  186. methods: {
  187. getButtons() {
  188. const Edit = 'SystemConsumption'
  189. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  190. this.isRoleEdit = isRoleEdit
  191. },
  192. getDownList() {
  193. GetDataByNames(this.requestParams).then(response => {
  194. this.feedNameList = response.data.getFeedListEnable.list
  195. this.livestockTypeList = response.data.getDictByName.list
  196. })
  197. },
  198. handleBefore() {
  199. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  200. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  201. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  202. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  203. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  204. this.$forceUpdate()
  205. }
  206. },
  207. handleNext() {
  208. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  209. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  210. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  211. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  212. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  213. this.$forceUpdate()
  214. }
  215. },
  216. getList() {
  217. this.table.listLoading = true
  218. GetDataByName(this.table.getdataListParm).then(response => {
  219. console.log('table数据', response.data.list)
  220. if (response.data.list !== null) {
  221. for (let i = 0; i < response.data.list.length; i++) {
  222. this.$set(response.data.list[i], 'Edit', false) // 编辑
  223. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  224. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  225. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  226. }
  227. this.table.list = response.data.list
  228. this.table.pageNum = response.data.pageNum
  229. this.table.pageSize = response.data.pageSize
  230. } else {
  231. this.table.list = []
  232. }
  233. this.table.total = response.data.total
  234. setTimeout(() => {
  235. this.table.listLoading = false
  236. }, 100)
  237. })
  238. },
  239. form_search() {
  240. console.log('点击了查询')
  241. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  242. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  243. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  244. } else {
  245. this.table.getdataListParm.parammaps.inputDatetime = ''
  246. this.table.getdataListParm.parammaps.startTime = ''
  247. this.table.getdataListParm.parammaps.stopTime = ''
  248. }
  249. this.table.getdataListParm.offset = 1
  250. this.getList()
  251. },
  252. handleRefresh() {
  253. console.log('点击了重置')
  254. this.table.getdataListParm.parammaps.inputDatetime = ''
  255. this.table.getdataListParm.parammaps.startTime = ''
  256. this.table.getdataListParm.parammaps.stopTime = ''
  257. this.table.getdataListParm.parammaps.feedid = ''
  258. this.table.getdataListParm.parammaps.cowclassid = ''
  259. this.table.getdataListParm.parammaps.ischarge = ''
  260. this.table.getdataListParm.offset = 1
  261. this.getList()
  262. },
  263. handleUpdate(row) {
  264. for (let i = 0; i < this.table.list.length; i++) {
  265. if (this.table.list[i].Edit == true) {
  266. this.$message({ type: 'error', message: this.$t('driver.messageNote'), duration: 2000 })
  267. return false
  268. }
  269. }
  270. // 编辑true,不可编辑false
  271. row.Edit = true
  272. row.NoEdit = false
  273. // 编辑false,编辑保存true
  274. row.isUpdate = false
  275. row.isUpdateSave = true
  276. },
  277. updateData(row) {
  278. console.log('点击了编辑保存', row)
  279. this.isokDisable = true
  280. setTimeout(() => {
  281. this.isokDisable = false
  282. }, 1000)
  283. this.requestParam.name = 'updateFeeduse'
  284. this.requestParam.parammaps = {}
  285. this.requestParam.parammaps.pastureid = row.pastureid
  286. this.requestParam.parammaps.id = row.id
  287. this.requestParam.parammaps.remark = row.remark
  288. this.requestParam.parammaps.operateweight = row.operateweight
  289. PostDataByName(this.requestParam).then(response => {
  290. console.log('新增保存发送参数', this.requestParam)
  291. if (response.msg !== 'fail') {
  292. this.$notify({ title: this.$t('common.succes'), message: this.$t('driver.saveSuccess'), type: 'success', duration: 2000 })
  293. this.getList()
  294. } else {
  295. this.$notify({ title: this.$t('driver.saveFail'), message: response.data, type: 'warning', duration: 2000 })
  296. }
  297. })
  298. },
  299. updateCancel(row) {
  300. console.log('点击了编辑取消')
  301. // 编辑false,不可编辑true
  302. row.Edit = false
  303. row.NoEdit = true
  304. // 编辑true,编辑保存false
  305. row.isUpdate = true
  306. row.isUpdateSave = false
  307. this.getList()
  308. },
  309. handleSelectionChange(val) {
  310. console.log('勾选数据', val)
  311. this.selectList = val
  312. },
  313. handleExamine() {
  314. if (this.selectList.length == 0) {
  315. this.$message({ type: 'error', message: '请选择需要审核的单据', duration: 2000 })
  316. } else {
  317. for (let i = 0; i < this.selectList.length; i++) {
  318. if (this.selectList[i].ischarge == 1) {
  319. this.$message({ type: 'error', message: '单据不可重复审核,请重新选择', duration: 2000 })
  320. return
  321. }
  322. }
  323. MessageBox.confirm('是否确认审核系统用量?', this.$t('message.msg111'), {
  324. confirmButtonText: this.$t('common.confirm'), confirmButtonText: this.$t('common.cancel'), type: 'warning'
  325. }).then(() => {
  326. this.requestParam.common = { 'returnmap': '0' }
  327. this.requestParam.data = []
  328. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  329. this.requestParam.data[0].children = []
  330. this.requestParam.data[0].children[0] = { 'name': 'insertFeedstorageUse', 'type': 'e', 'parammaps': {
  331. snowid: '@insertSpotList.snowid',
  332. pastureid: '@insertSpotList.pastureid',
  333. feedid: '@insertSpotList.feedid',
  334. fname: '@insertSpotList.fname',
  335. pcpde: '@insertSpotList.pcpde',
  336. operateweight: '@insertSpotList.operateweight',
  337. price: '@insertSpotList.price'
  338. }}
  339. this.requestParam.data[0].children[1] = { 'name': 'chargeFeedstorageuse', 'type': 'e', 'parammaps': {
  340. id: '@insertSpotList.id',
  341. pastureid: '@insertSpotList.pastureid',
  342. operateweight: '@insertSpotList.operateweight'
  343. }}
  344. ExecDataByConfig(this.requestParam).then(response => {
  345. console.log('审核保存发送参数', this.requestParam)
  346. if (response.msg === 'fail') {
  347. this.$notify({ title:this.$t('message.msg37'), message: response.data, type: 'warning', duration: 2000 })
  348. } else {
  349. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  350. this.getList()
  351. }
  352. })
  353. })
  354. }
  355. },
  356. handleExport() {
  357. console.log('点击了导出')
  358. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  359. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  360. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  361. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  362. } else {
  363. this.download.getdataListParm.parammaps.inputDatetime = ''
  364. this.download.getdataListParm.parammaps.startTime = ''
  365. this.download.getdataListParm.parammaps.stopTime = ''
  366. }
  367. GetDataByName(this.download.getdataListParm).then(response => {
  368. if (response.data.list !== null) {
  369. for (let i = 0; i < response.data.list.length; i++) {
  370. if (response.data.list[i].ischarge == 1) {
  371. response.data.list[i].ischarge = '是'
  372. } else {
  373. response.data.list[i].ischarge = '否'
  374. }
  375. }
  376. this.download.list = response.data.list
  377. } else {
  378. this.download.list = []
  379. }
  380. var excelDatas = [
  381. {
  382. tHeader: ['业务日期', '牲畜类别', '饲料名称', '库存重量(kg)', '计划重量(kg)', '设备实测重量(kg)', '出库重量(kg)', '备注', '是否审核'],
  383. filterVal: ['usedate', 'cowclass', 'feedname', 'repertoryweight', 'planweight', 'actweight', 'operateweight', 'remark', 'ischarge'],
  384. tableDatas: this.download.list,
  385. sheetName: 'Sheet1'
  386. }
  387. ]
  388. json2excel(excelDatas, '系统用量', true, 'xlsx')
  389. })
  390. }
  391. }
  392. }
  393. </script>
  394. <style lang="scss" scoped>
  395. // .operation{margin-top:10px;}
  396. .search{margin-top:10px;}
  397. </style>