From 41409ff44db50fc361bd08438789f8de85a7c9b4 Mon Sep 17 00:00:00 2001 From: duan Date: Wed, 10 Aug 2022 14:27:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(src/views/reagent/warehousing):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0index=E4=BD=9C=E4=B8=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=94=AF=E4=B8=80=E6=80=A7=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ReagentForm/index.vue | 12 ++++++++---- src/views/reagent/warehousing/index.vue | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/components/ReagentForm/index.vue b/src/components/ReagentForm/index.vue index bf99bf9..389154f 100644 --- a/src/components/ReagentForm/index.vue +++ b/src/components/ReagentForm/index.vue @@ -187,12 +187,16 @@ export default { tempDate = this.strToDate(this.formData.production_date) } let temDate = this.formData.expiration_date - if (typeof (this.formData.expiration_date) === 'string') { + if (temDate && typeof (this.formData.expiration_date) === 'string') { temDate = this.strToDate(this.formData.expiration_date) } - // 计算过期时间 - const diff = temDate.getTime() - tempDate.getTime() - this.formData.shelf_life = Math.trunc(diff / (60 * 60 * 24 * 1000)) + if (temDate && tempDate) { + // 计算过期时间 + const diff = temDate.getTime() - tempDate.getTime() + this.formData.shelf_life = Math.trunc(diff / (60 * 60 * 24 * 1000)) + } else { + this.formData.shelf_life = 0 + } this.$emit('handlefunc', this.formData) } if (!valid) return diff --git a/src/views/reagent/warehousing/index.vue b/src/views/reagent/warehousing/index.vue index fb5ee32..a3c4b0c 100644 --- a/src/views/reagent/warehousing/index.vue +++ b/src/views/reagent/warehousing/index.vue @@ -297,26 +297,21 @@ export default { return } const data = JSON.parse(JSON.stringify(this.currentRow)) + const id = data.index delete data.status + delete data.index bind_tmp_enter_warehouse(stringify({ 'tmplate_content': JSON.stringify(data), 'bar_code': newCode, 'client_id': this.client_id_input })).then(res => { if (res.status === 0) { - let cindex = 0 // 记录成功后的下一个index + this.bindToDBData[id].status = true this.$message.success('入库成功!') - this.bindToDBData = this.bindToDBData.map((item, index) => { - if (item.variety_id === this.currentRow.variety_id) { - item.status = true - cindex = index + 1 - } - return item - }) // 判断是否是最后一行,不是最后一行自动选择下一行 - if (cindex <= this.bindToDBData.length - 1) { + if (id < this.bindToDBData.length - 1) { // 将下一行自动选中 - this.$refs.singleTable.setCurrentRow(this.bindToDBData[cindex]) + this.$refs.singleTable.setCurrentRow(this.bindToDBData[id + 1]) } } else { this.$message.error('入库失败,请重试!') @@ -407,9 +402,13 @@ export default { this.formVisible = false this.bindToDBData = [] for (let i = 0; i < obj.num; i++) { - this.bindToDBData.push({ ...this.propsformdata, ...obj, 'status': false }) + this.bindToDBData.push({ ...this.propsformdata, ...obj, 'status': false, 'index': i }) } this.client_id_input = obj.client_id + // 自动选择第一行数据 + this.$nextTick(() => { + this.$refs.singleTable.setCurrentRow(this.bindToDBData[0]) + }) this.bindToDBVisible = true }, // 处理选择试剂入库弹框关闭后数据留存问题 @@ -535,8 +534,9 @@ export default { } this.bindToDBData = [] this.multipleSelection.forEach(item => { - this.bindToDBData.push(...JSON.parse(item.template_content).map(item => { + this.bindToDBData.push(...JSON.parse(item.template_content).map((item, index) => { item.status = false + item.index = index return item })) })