91cc4aea1020c2cd822e4dd8c7c92c5edea45fdc.svn-base 17 KB

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