IceTracingManagement.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <template>
  2. <!-- 冰排追溯管理 -->
  3. <div>
  4. <actionBar :operateList="operateList" :formList="formList" :ruleForm="searchRuleForm" @openModel="openModel"
  5. @searchProtocol="searchProtocol" @handleScroll="handleScroll"></actionBar>
  6. <div class="card_content">
  7. <!-- 表单 -->
  8. <tables :tableList="tableList" :tableData="tableData" @buttonData="buttonData"></tables>
  9. <!-- 分页 -->
  10. <div v-if="Total">
  11. <pagination :total="Total" :currentPage="Pagination.PageIndex" @changeSize="changeSize"
  12. @changeCurrent="changeCurrent">
  13. </pagination>
  14. </div>
  15. </div>
  16. <!-- 历史记录 -->
  17. <div class="card_history">
  18. <el-dialog top="5vh" title="历史记录" :visible.sync="historyVisible" width="90%" :close-on-click-modal="false"
  19. @close="closeHistory">
  20. <tables :historyFlag="true" :tableList="historyList" :tableData="historyData" @buttonData="historyButton">
  21. </tables>
  22. <!-- 分页 -->
  23. <div v-if="historyTotal">
  24. <pagination :total="historyTotal" :currentPage="historyPagination.PageIndex" @changeSize="historySize"
  25. @changeCurrent="historyCurrent">
  26. </pagination>
  27. </div>
  28. <el-dialog width="500px" title="编辑" :visible.sync="innerVisible" append-to-body :close-on-click-modal="false"
  29. @close="closeNested">
  30. <forms ref="editRules" :formNewList="editRuleList" :ruleForm="editRuleForm" :iceBank="true" labelWidth="100px"
  31. @handleScroll="handleScroll" @remoteMethod="remoteMethod" :key="Math.random()"></forms>
  32. <div slot="footer" class="dialog-footer">
  33. <el-button @click="innerVisible = false">取消</el-button>
  34. <el-button type="primary" @click="submit">提交</el-button>
  35. </div>
  36. </el-dialog>
  37. </el-dialog>
  38. </div>
  39. <!-- 出入库 -->
  40. <el-dialog :title="staffTitle" :visible.sync="staffDialogVisible" width="600px" :close-on-click-modal="false"
  41. @close="closeDialog">
  42. <forms ref="childRules" :formNewList="formRuleList" :ruleForm="ruleForm" :iceTracing="true" :iceBank="true"
  43. labelWidth="100px" @handleScroll="handleScroll" @remoteMethod="remoteMethod">
  44. </forms>
  45. <span slot="footer" class="dialog-footer" v-if="operationType != 'logs'">
  46. <el-button plain @click="staffDialogVisible = false">取 消</el-button>
  47. <el-button type="primary" :loading="confirmLoading" @click="handleAdd">确 定</el-button>
  48. </span>
  49. </el-dialog>
  50. </div>
  51. </template>
  52. <script>
  53. import {
  54. getIceRaftNewest,
  55. iceraftIn,
  56. iceraftOut,
  57. getIceRaftRecord,
  58. putIceRaftRecord,
  59. delIceRaftRecord
  60. } from '@/api/iceRaft'
  61. import {
  62. getIcelocker,
  63. } from '@/api/refrigerator'
  64. import {
  65. getCoolerBox
  66. } from '@/api/incubator.js'
  67. import actionBar from '@/components/actionBar'
  68. import tables from '@/components/tables'
  69. import pagination from '@/components/pagination'
  70. import forms from '@/components/forms'
  71. import {
  72. employee,
  73. historyRecord,
  74. iceRaftRules,
  75. freezerRules,
  76. editRules
  77. } from "./iceRaft.js";
  78. export default {
  79. name: 'IceManagement',
  80. components: {
  81. actionBar,
  82. tables,
  83. pagination,
  84. forms
  85. },
  86. data() {
  87. return {
  88. operateList: [{
  89. type: 'come',
  90. title: '入库',
  91. }, {
  92. type: 'goOut',
  93. title: '出库',
  94. }],
  95. formList: [{
  96. type: 'input',
  97. label: '编号',
  98. field: 'code',
  99. placeholder: '请输入编号',
  100. }, {
  101. type: 'select',
  102. label: '状态',
  103. field: 'status',
  104. placeholder: '请选择状态',
  105. options: [{
  106. bgcolor: '#606266',
  107. label: '未入库',
  108. value: '0',
  109. }, {
  110. bgcolor: '#409EFF',
  111. label: '冷冻中',
  112. value: '1',
  113. }, {
  114. bgcolor: '#67C23A',
  115. label: '待使用',
  116. value: '2',
  117. }, {
  118. bgcolor: '#E6A23C',
  119. label: '使用中',
  120. value: '3',
  121. }, {
  122. bgcolor: '#909399',
  123. label: '已结束',
  124. value: '4',
  125. }]
  126. }, {
  127. type: 'select',
  128. label: '冷冻柜',
  129. field: 'iceLockerId',
  130. placeholder: '请选择冷冻柜',
  131. options: []
  132. }, {
  133. type: 'select',
  134. label: '保温箱',
  135. field: 'coolerBoxId',
  136. placeholder: '请选择保温箱',
  137. options: []
  138. }, ],
  139. searchRuleForm: {
  140. code: '',
  141. status: '',
  142. iceLockerId: null,
  143. coolerBoxId: null,
  144. },
  145. searchValue: {},
  146. tableList: employee(),
  147. tableData: [],
  148. Total: 0,
  149. Pagination: {
  150. PageIndex: 1,
  151. PageSize: 10,
  152. },
  153. // 历史记录
  154. historyList: historyRecord(),
  155. historyData: [],
  156. historyTotal: 0,
  157. historyPagination: {
  158. PageIndex: 1,
  159. PageSize: 10,
  160. },
  161. operationType: '',
  162. staffTitle: '添加',
  163. staffDialogVisible: false,
  164. formRuleList: {},
  165. ruleForm: {
  166. iceLockerId: '',
  167. freezeClaim: '',
  168. coolerBoxId: '',
  169. code: [],
  170. },
  171. confirmLoading: false,
  172. historyVisible: false,
  173. page: 1,
  174. staffName: '',
  175. limitNo: true,
  176. limitNoil: true,
  177. eventSource: null,
  178. timer: null, //定时器名称
  179. iceRaftId: null,
  180. innerVisible: false,
  181. editRuleList: {},
  182. editRuleForm: {
  183. code: '',
  184. status: '',
  185. inStorageTime: '',
  186. outStorageTime: '',
  187. freezeClaim: '',
  188. iceLockerId: '',
  189. coolerBoxId: '',
  190. },
  191. iceRaftCode: '',
  192. coldCupboard: {
  193. field: 'iceLockerId',
  194. label: '冷冻柜',
  195. placeholder: '请选择冷冻柜',
  196. type: 'searchSelect',
  197. colWidth: 24,
  198. multiple: false,
  199. rules: [{
  200. required: true,
  201. message: '请选择冷冻柜',
  202. trigger: 'blur'
  203. }],
  204. options: [],
  205. },
  206. thermostat: {
  207. field: 'coolerBoxId',
  208. label: '保温箱',
  209. placeholder: '请选择保温箱',
  210. type: 'searchSelect',
  211. colWidth: 24,
  212. rules: [{
  213. required: true,
  214. message: '请选择保温箱',
  215. trigger: 'blur'
  216. }],
  217. options: [],
  218. }
  219. }
  220. },
  221. beforeDestroy() {
  222. clearInterval(this.timer); // 清除定时器
  223. this.timer = null;
  224. },
  225. mounted() {
  226. this.getList()
  227. this.getFreezer()
  228. this.getIncubator()
  229. },
  230. methods: {
  231. // 搜索
  232. searchProtocol(value) {
  233. this.Pagination.PageIndex = 1
  234. this.searchValue = value
  235. this.getList()
  236. },
  237. // 获取冰排列表
  238. getList() {
  239. var params = {
  240. page: this.Pagination.PageIndex,
  241. pageSize: this.Pagination.PageSize,
  242. ...this.searchValue
  243. }
  244. getIceRaftNewest(params).then(res => {
  245. if (res.code == 200) {
  246. this.tableData = res.data.list
  247. this.Total = res.data.count
  248. this.timer = setTimeout(() => {
  249. this.getList();
  250. }, 60000)
  251. }
  252. })
  253. },
  254. // 弹窗表单添加
  255. handleAdd() {
  256. let flag = this.$refs['childRules'].validateForm();
  257. if (flag) {
  258. const params = {
  259. ...this.ruleForm,
  260. }
  261. if (this.operationType == 'come') {
  262. delete params.coolerBoxId
  263. params.iceLockerId = Number(params.iceLockerId)
  264. params.freezeClaim = Number(params.freezeClaim)
  265. iceraftIn(params).then(res => {
  266. if (res.code == 200) {
  267. this.$message({
  268. message: res.msg,
  269. type: 'success'
  270. });
  271. this.staffDialogVisible = false
  272. this.getList()
  273. }
  274. })
  275. } else if (this.operationType == 'goOut') {
  276. delete params.iceLockerId
  277. delete params.freezeClaim
  278. params.coolerBoxId = Number(params.coolerBoxId)
  279. iceraftOut(params).then(res => {
  280. if (res.code == 200) {
  281. this.$message({
  282. message: res.msg,
  283. type: 'success'
  284. });
  285. this.staffDialogVisible = false
  286. this.getList()
  287. }
  288. })
  289. }
  290. } else {
  291. this.$message.error('表单信息不完整,请继续填写完整');
  292. }
  293. },
  294. openModel(type) {
  295. this.operationType = type
  296. this.staffDialogVisible = true
  297. this.page = 1
  298. if (type == 'come') {
  299. this.staffTitle = '入库'
  300. this.formRuleList = iceRaftRules()
  301. this.coldCupboard.options = []
  302. this.formRuleList.unshift(this.coldCupboard)
  303. this.limitNo = true
  304. this.getFreezer()
  305. } else if (type == 'goOut') {
  306. this.staffTitle = '出库'
  307. this.formRuleList = freezerRules()
  308. this.thermostat.options = []
  309. this.formRuleList.unshift(this.thermostat)
  310. this.limitNoil = true
  311. this.getIncubator()
  312. }
  313. this.$forceUpdate()
  314. },
  315. // 重置冷冻柜、保温箱
  316. resetSelect() {
  317. this.page = 1
  318. this.limitNo = true
  319. this.limitNoil = true
  320. this.staffName = ''
  321. },
  322. // 触底事件
  323. handleScroll(type) {
  324. if (this.operationType == 'come') {
  325. if (this.limitNo) {
  326. this.getFreezer()
  327. }
  328. } else if (this.operationType == 'goOut') {
  329. if (this.limitNoil) {
  330. this.getIncubator()
  331. }
  332. } else if (this.operationType == 'edit') {
  333. if (this.deposit) {
  334. if (this.limitNo) {
  335. this.getFreezer()
  336. }
  337. } else {
  338. if (this.limitNoil) {
  339. this.getIncubator()
  340. }
  341. }
  342. } else {
  343. if (type == 'iceLockerId' && this.limitNo) {
  344. this.getFreezer()
  345. } else if (type == 'coolerBoxId' && this.limitNoil) {
  346. this.getIncubator()
  347. }
  348. }
  349. },
  350. // 搜索
  351. remoteMethod(value) {
  352. this.resetSelect()
  353. this.staffName = value
  354. if (this.operationType == 'edit') {
  355. this.editRuleList.forEach(item => {
  356. if (item.type == 'searchSelect') {
  357. item.options = []
  358. }
  359. })
  360. if (this.deposit) {
  361. this.getFreezer()
  362. } else {
  363. this.getIncubator()
  364. }
  365. } else {
  366. if (this.operationType == 'come') {
  367. this.formRuleList.forEach(item => {
  368. if (item.type == 'searchSelect') {
  369. item.options = []
  370. }
  371. })
  372. this.getFreezer()
  373. } else if (this.operationType == 'goOut') {
  374. this.getIncubator()
  375. }
  376. }
  377. },
  378. // 获取冷冻柜列表
  379. getFreezer() {
  380. let arrList = []
  381. let params = {
  382. page: this.page,
  383. pageSize: 10,
  384. status: '2',
  385. name: this.staffName,
  386. }
  387. getIcelocker(params).then(res => {
  388. if (res.code == 200) {
  389. let arr = res.data.list
  390. let arrList = []
  391. arr.forEach(item1 => {
  392. var arrData = {
  393. label: null,
  394. value: null,
  395. }
  396. arrData.label = item1.name
  397. arrData.value = item1.id
  398. arrList.push(arrData)
  399. })
  400. if (this.limitNo == true) {
  401. if (this.operationType != '') {
  402. if (this.operationType == 'come' || this.operationType == 'goOut') {
  403. this.formRuleList.forEach(item => {
  404. if (item.type == 'searchSelect') {
  405. item.options = item.options.concat(arrList)
  406. }
  407. })
  408. } else if (this.operationType == 'edit') {
  409. this.editRuleList.forEach(item => {
  410. if (item.type == 'searchSelect') {
  411. item.options = item.options.concat(arrList)
  412. }
  413. })
  414. }
  415. } else {
  416. this.formList.forEach(item => {
  417. if (item.field == 'iceLockerId') {
  418. item.options = item.options.concat(arrList)
  419. }
  420. })
  421. }
  422. }
  423. if (arrList.length >= 10) {
  424. this.page = ++this.page;
  425. } else {
  426. // 已经没数据了 不需要增加数据
  427. this.limitNo = false;
  428. }
  429. }
  430. })
  431. },
  432. // 获取保温箱列表
  433. getIncubator() {
  434. let arrList = []
  435. let params = {
  436. page: this.page,
  437. pageSize: 10,
  438. status: '2',
  439. name: this.staffName,
  440. }
  441. getCoolerBox(params).then(res => {
  442. if (res.code == 200) {
  443. let arr = res.data.list
  444. let arrList = []
  445. arr.forEach(item1 => {
  446. var arrData = {
  447. label: null,
  448. value: null,
  449. }
  450. arrData.label = item1.name
  451. arrData.value = item1.id
  452. arrList.push(arrData)
  453. })
  454. if (this.limitNoil == true) {
  455. if (this.operationType != '') {
  456. if (this.operationType == 'come' || this.operationType == 'goOut') {
  457. this.formRuleList.forEach(item => {
  458. if (item.type == 'searchSelect') {
  459. item.options = item.options.concat(arrList)
  460. }
  461. })
  462. } else if (this.operationType == 'edit') {
  463. this.editRuleList.forEach(item => {
  464. if (item.type == 'searchSelect') {
  465. item.options = item.options.concat(arrList)
  466. }
  467. })
  468. }
  469. } else {
  470. this.formList.forEach(item => {
  471. if (item.field == 'coolerBoxId') {
  472. item.options = item.options.concat(arrList)
  473. }
  474. })
  475. }
  476. // this.thermostat.options = this.thermostat.options.concat(arrList)
  477. }
  478. if (arrList.length >= 10) {
  479. this.page = ++this.page;
  480. } else {
  481. // 已经没数据了 不需要增加数据
  482. this.limitNoil = false;
  483. }
  484. }
  485. })
  486. },
  487. // 冰排列表
  488. buttonData(row, type) {
  489. this.operationType = type
  490. this.iceRaftId = row.id
  491. this.iceRaftCode = row.code
  492. if (type == 'logs') {
  493. this.historyVisible = true
  494. this.getHistory()
  495. }
  496. },
  497. // 获取历史记录列表
  498. getHistory(iceRaftId) {
  499. var params = {
  500. page: this.historyPagination.PageIndex,
  501. pageSize: this.historyPagination.PageSize,
  502. iceRaftId: this.iceRaftId,
  503. // ...this.searchValue
  504. }
  505. getIceRaftRecord(params).then(res => {
  506. if (res.code == 200) {
  507. this.historyData = res.data.list
  508. this.historyTotal = res.data.count
  509. }
  510. })
  511. },
  512. // 历史记录操作
  513. historyButton(row, type) {
  514. this.operationType = type
  515. this.limitNo = true
  516. if (type == 'edit') {
  517. this.innerVisible = true
  518. this.page = 1
  519. this.editRuleList = editRules()
  520. if (row.outStorageTime == '') {
  521. this.deposit = true
  522. this.getFreezer()
  523. this.editRuleList.push(this.coldCupboard)
  524. // 冷冻柜
  525. this.editRuleForm.iceLockerId = String(row.iceLockerId)
  526. } else {
  527. this.deposit = false
  528. this.getIncubator()
  529. this.editRuleList.push(this.thermostat)
  530. // 保温箱
  531. this.editRuleForm.coolerBoxId = String(row.coolerBoxId)
  532. }
  533. this.editRuleForm.id = row.id
  534. this.editRuleForm.code = this.iceRaftCode
  535. this.editRuleForm.status = row.status
  536. this.editRuleForm.inStorageTime = row.inStorageTime
  537. this.editRuleForm.outStorageTime = row.outStorageTime
  538. this.editRuleForm.freezeClaim = row.freezeClaim
  539. if (row.status == '3') {
  540. this.editRuleList.forEach(item => {
  541. if (item.field == 'freezeClaim') {
  542. item.disabled = true
  543. }
  544. })
  545. }
  546. } else if (type == 'del') {
  547. this.delHistory(row.id)
  548. }
  549. },
  550. // 编辑历史记录提交
  551. submit() {
  552. let flag = this.$refs['editRules'].validateForm();
  553. if (flag) {
  554. this.$confirm('确定修改该冰排信息吗, 是否继续?', '提示', {
  555. confirmButtonText: '确定',
  556. cancelButtonText: '取消',
  557. type: 'warning'
  558. }).then(() => {
  559. let param = {
  560. id: '',
  561. iceLockerId: '',
  562. coolerBoxId: '',
  563. freezeClaim: '',
  564. }
  565. param.id = this.editRuleForm.id
  566. param.iceLockerId = Number(this.editRuleForm.iceLockerId)
  567. param.coolerBoxId = Number(this.editRuleForm.coolerBoxId)
  568. param.freezeClaim = Number(this.editRuleForm.freezeClaim)
  569. if (this.editRuleForm.outStorageTime == '') {
  570. delete param.coolerBoxId
  571. } else {
  572. delete param.iceLockerId
  573. }
  574. putIceRaftRecord(param).then(res => {
  575. if (res.code == 200) {
  576. this.innerVisible = false
  577. this.$message({
  578. type: 'success',
  579. message: res.msg
  580. });
  581. this.getHistory()
  582. }
  583. })
  584. }).catch(() => {
  585. // console.log('取消修改')
  586. });
  587. } else {
  588. this.$message.error('表单信息不完整,请继续填写完整');
  589. }
  590. },
  591. // 删除历史记录
  592. delHistory(id) {
  593. this.$confirm('确定删除该冰排信息吗, 是否继续?', '提示', {
  594. confirmButtonText: '确定',
  595. cancelButtonText: '取消',
  596. type: 'warning'
  597. }).then(() => {
  598. delIceRaftRecord({
  599. id: id
  600. }).then(res => {
  601. if (res.code == 200) {
  602. this.$message({
  603. message: '删除成功,请重新入库该冰排!',
  604. type: 'warning'
  605. });
  606. const precisePage = Math.ceil((this.historyTotal - 1) / this.historyPagination.PageSize)
  607. this.historyPagination.PageIndex = this.historyPagination.PageIndex > precisePage ? precisePage : this
  608. .historyPagination.PageIndex
  609. this.historyPagination.PageIndex = this.historyPagination.PageIndex < 1 ? 1 : this.historyPagination.PageIndex
  610. this.getHistory()
  611. this.getList()
  612. }
  613. })
  614. }).catch(() => {
  615. // console.log('已取消删除')
  616. });
  617. },
  618. changeSize(val) {
  619. this.Pagination.PageSize = val
  620. this.getList()
  621. },
  622. changeCurrent(val) {
  623. this.Pagination.PageIndex = val
  624. this.getList()
  625. },
  626. // 历史记录分页
  627. historySize(val) {
  628. this.historyPagination.PageSize = val
  629. this.getHistory()
  630. },
  631. historyCurrent(val) {
  632. this.historyPagination.PageIndex = val
  633. this.getHistory()
  634. },
  635. // 关闭历史记录
  636. closeHistory() {
  637. this.historyPagination.PageIndex = 1
  638. this.historyVisible = false
  639. this.getList()
  640. },
  641. // 嵌套弹窗
  642. closeNested() {
  643. this.staffName = ''
  644. this.editRuleList.forEach(item => {
  645. if (item.type == 'searchSelect') {
  646. item.options = []
  647. }
  648. })
  649. },
  650. // 清空表单
  651. closeDialog() {
  652. this.resetSelect()
  653. this.ruleForm.code = []
  654. this.$refs.childRules.resetCheck();
  655. this.coldCupboard.options = []
  656. this.thermostat.options = []
  657. },
  658. }
  659. }
  660. </script>
  661. <style lang="scss" scoped>
  662. </style>