From a5b07e3f40786d5af22fdfb8ef156f6e30b6d2f1 Mon Sep 17 00:00:00 2001 From: zhouxueli <2841188632@qq.com> Date: Wed, 22 Jul 2026 13:17:26 +0800 Subject: [PATCH] =?UTF-8?q?CRM=5F26-07-21#story#9039,=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=95=86=E5=9C=A8=E8=B0=83=E5=BA=A6=E7=AB=AFApp=E4=B8=8E?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=B8=AD=E8=83=BD=E5=8F=98=E6=9B=B4=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E4=BF=A1=E6=81=AF=E5=8F=8A=E5=AF=B9=E5=BA=94=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E7=BB=8F=E7=90=86=E5=AE=A1=E6=A0=B8=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/index/supplierTimePhone.vue | 68 ++++++++++++++----- src/views/index/supplierTimePhoneEdit.vue | 83 ++++++++++++----------- 2 files changed, 93 insertions(+), 58 deletions(-) diff --git a/src/views/index/supplierTimePhone.vue b/src/views/index/supplierTimePhone.vue index 72ac8fdc..8e4b1b42 100644 --- a/src/views/index/supplierTimePhone.vue +++ b/src/views/index/supplierTimePhone.vue @@ -3,7 +3,7 @@
{{ item.startTime }} — {{ item.endTime }} -
+
编辑 删除
@@ -107,17 +107,12 @@ export default { } this.loadData() }, - activated() { - // 从编辑页返回时刷新本地草稿 - if (this.supplierId) { - this.loadDraft() - } - }, methods: { async loadData() { Toast.loading({ message: '加载中...', forbidClick: true, duration: 0 }) try { - const res = await getSupplierPhoneList({ supplierId: this.supplierId }) + const result = await getSupplierPhoneList({ supplierId: this.supplierId }) + const res=result?.data || '' this.supplierName = res?.supplierName || '' this.approvalId = res?.approvalId || null this.approvalState = res?.approvalState || null @@ -127,8 +122,8 @@ export default { this.approvalRemark = res?.approvalRemark || '' const cached = this.getCachedDraft() - if (cached && cached.approvalId === this.approvalId && cached.approvalState === this.approvalState) { - this.phoneList = cached.phoneList || [] + if (cached && Array.isArray(cached.phoneList)) { + this.phoneList = cached.phoneList } else { this.phoneList = res?.phoneList || [] this.saveDraft() @@ -139,12 +134,6 @@ export default { Toast.clear() } }, - loadDraft() { - const cached = this.getCachedDraft() - if (cached) { - this.phoneList = cached.phoneList || [] - } - }, visiblePhones(item) { const list = [] for (let i = 1; i <= 3; i++) { @@ -176,10 +165,16 @@ export default { } localStorage.setItem(getDraftKey(this.supplierId), JSON.stringify(draft)) }, + onNavBack() { + localStorage.removeItem(getDraftKey(this.supplierId)) + this.goBack() + }, goAdd() { + this.saveDraft() this.goPage('supplierTimePhoneEdit', { supplierId: this.supplierId, index: -1 }) }, goEdit(index) { + this.saveDraft() this.goPage('supplierTimePhoneEdit', { supplierId: this.supplierId, index }) }, deleteItem(index) { @@ -191,6 +186,40 @@ export default { this.saveDraft() }).catch(() => {}) }, + // 将 HH:mm 转换为分钟数,兼容中英文冒号 + timeToMinutes(timeStr) { + if (!timeStr) return null + const normalized = String(timeStr).trim().replace(/:/g, ':') + const [h, m] = normalized.split(':').map(Number) + if (isNaN(h) || isNaN(m)) return null + return h * 60 + m + }, + // 校验时间段:重叠、00:00 开始、23:59 结束、遗漏(允许 1 分钟误差) + validateTimePeriods(list) { + const periods = list.map(item => ({ + start: this.timeToMinutes(item.startTime), + end: this.timeToMinutes(item.endTime) + })) + if (periods.some(p => p.start === null || p.end === null)) { + return '存在格式不正确的时间段' + } + periods.sort((a, b) => a.start - b.start) + if (periods[0].start !== 0) { + return '时间段未从 00:00 开始!' + } + if (periods[periods.length - 1].end !== 23 * 60 + 59) { + return '时间段未到 23:59 结束!' + } + for (let i = 1; i < periods.length; i++) { + if (periods[i].start < periods[i - 1].end) { + return '时间段重叠' + } + if (periods[i].start - periods[i - 1].end > 1) { + return '时间段有遗漏' + } + } + return null + }, async onSubmitClick() { if (this.inApproval) return if (!this.phoneList.length) { @@ -201,6 +230,11 @@ export default { Toast('每条时段电话1均必填') return } + const timeError = this.validateTimePeriods(this.phoneList) + if (timeError) { + Toast(timeError) + return + } Toast.loading({ message: '提交中...', forbidClick: true, duration: 0 }) try { diff --git a/src/views/index/supplierTimePhoneEdit.vue b/src/views/index/supplierTimePhoneEdit.vue index 78a20440..4ae4a971 100644 --- a/src/views/index/supplierTimePhoneEdit.vue +++ b/src/views/index/supplierTimePhoneEdit.vue @@ -3,7 +3,7 @@
@@ -56,18 +54,29 @@