CRM_26-07-21#story#9039,服务商在调度端App与系统中能变更基础信息及对应区域经理审核功能增加

This commit is contained in:
zxl
2026-07-22 13:17:26 +08:00
parent b95f325b3e
commit a5b07e3f40
2 changed files with 93 additions and 58 deletions
+51 -17
View File
@@ -3,7 +3,7 @@
<van-nav-bar
title="供应商时段电话"
left-arrow
@click-left="goBack"
@click-left="onNavBack"
fixed
placeholder
class="nav-bar"
@@ -29,7 +29,7 @@
<div v-for="(item, index) in phoneList" :key="index" class="time-card" @click="goEdit(index)">
<div class="card-head">
<span class="period">{{ item.startTime }} {{ item.endTime }}</span>
<div class="ops" @click.stop>
<div class="ops" @click.stop v-if="!inApproval">
<span class="op-edit" @click="goEdit(index)">编辑</span>
<span class="op-del" @click="deleteItem(index)">删除</span>
</div>
@@ -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 {