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 <van-nav-bar
title="供应商时段电话" title="供应商时段电话"
left-arrow left-arrow
@click-left="goBack" @click-left="onNavBack"
fixed fixed
placeholder placeholder
class="nav-bar" class="nav-bar"
@@ -29,7 +29,7 @@
<div v-for="(item, index) in phoneList" :key="index" class="time-card" @click="goEdit(index)"> <div v-for="(item, index) in phoneList" :key="index" class="time-card" @click="goEdit(index)">
<div class="card-head"> <div class="card-head">
<span class="period">{{ item.startTime }} {{ item.endTime }}</span> <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-edit" @click="goEdit(index)">编辑</span>
<span class="op-del" @click="deleteItem(index)">删除</span> <span class="op-del" @click="deleteItem(index)">删除</span>
</div> </div>
@@ -107,17 +107,12 @@ export default {
} }
this.loadData() this.loadData()
}, },
activated() {
// 从编辑页返回时刷新本地草稿
if (this.supplierId) {
this.loadDraft()
}
},
methods: { methods: {
async loadData() { async loadData() {
Toast.loading({ message: '加载中...', forbidClick: true, duration: 0 }) Toast.loading({ message: '加载中...', forbidClick: true, duration: 0 })
try { try {
const res = await getSupplierPhoneList({ supplierId: this.supplierId }) const result = await getSupplierPhoneList({ supplierId: this.supplierId })
const res=result?.data || ''
this.supplierName = res?.supplierName || '' this.supplierName = res?.supplierName || ''
this.approvalId = res?.approvalId || null this.approvalId = res?.approvalId || null
this.approvalState = res?.approvalState || null this.approvalState = res?.approvalState || null
@@ -127,8 +122,8 @@ export default {
this.approvalRemark = res?.approvalRemark || '' this.approvalRemark = res?.approvalRemark || ''
const cached = this.getCachedDraft() const cached = this.getCachedDraft()
if (cached && cached.approvalId === this.approvalId && cached.approvalState === this.approvalState) { if (cached && Array.isArray(cached.phoneList)) {
this.phoneList = cached.phoneList || [] this.phoneList = cached.phoneList
} else { } else {
this.phoneList = res?.phoneList || [] this.phoneList = res?.phoneList || []
this.saveDraft() this.saveDraft()
@@ -139,12 +134,6 @@ export default {
Toast.clear() Toast.clear()
} }
}, },
loadDraft() {
const cached = this.getCachedDraft()
if (cached) {
this.phoneList = cached.phoneList || []
}
},
visiblePhones(item) { visiblePhones(item) {
const list = [] const list = []
for (let i = 1; i <= 3; i++) { for (let i = 1; i <= 3; i++) {
@@ -176,10 +165,16 @@ export default {
} }
localStorage.setItem(getDraftKey(this.supplierId), JSON.stringify(draft)) localStorage.setItem(getDraftKey(this.supplierId), JSON.stringify(draft))
}, },
onNavBack() {
localStorage.removeItem(getDraftKey(this.supplierId))
this.goBack()
},
goAdd() { goAdd() {
this.saveDraft()
this.goPage('supplierTimePhoneEdit', { supplierId: this.supplierId, index: -1 }) this.goPage('supplierTimePhoneEdit', { supplierId: this.supplierId, index: -1 })
}, },
goEdit(index) { goEdit(index) {
this.saveDraft()
this.goPage('supplierTimePhoneEdit', { supplierId: this.supplierId, index }) this.goPage('supplierTimePhoneEdit', { supplierId: this.supplierId, index })
}, },
deleteItem(index) { deleteItem(index) {
@@ -191,6 +186,40 @@ export default {
this.saveDraft() this.saveDraft()
}).catch(() => {}) }).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() { async onSubmitClick() {
if (this.inApproval) return if (this.inApproval) return
if (!this.phoneList.length) { if (!this.phoneList.length) {
@@ -201,6 +230,11 @@ export default {
Toast('每条时段电话1均必填') Toast('每条时段电话1均必填')
return return
} }
const timeError = this.validateTimePeriods(this.phoneList)
if (timeError) {
Toast(timeError)
return
}
Toast.loading({ message: '提交中...', forbidClick: true, duration: 0 }) Toast.loading({ message: '提交中...', forbidClick: true, duration: 0 })
try { try {
+42 -41
View File
@@ -3,7 +3,7 @@
<van-nav-bar <van-nav-bar
:title="isEdit ? '编辑时段电话' : '新增时段电话'" :title="isEdit ? '编辑时段电话' : '新增时段电话'"
left-arrow left-arrow
@click-left="goBack" @click-left="h5GoBack"
fixed fixed
placeholder placeholder
class="nav-bar" class="nav-bar"
@@ -46,8 +46,6 @@
</div> </div>
<div class="footer"> <div class="footer">
<button v-if="isEdit" class="btn btn-del" @click="deleteCurrent">删除本时段</button>
<button class="btn btn-cancel" @click="goBack">取消</button>
<button class="btn btn-save" @click="save">保存</button> <button class="btn btn-save" @click="save">保存</button>
</div> </div>
</div> </div>
@@ -56,18 +54,29 @@
<script> <script>
import { myMixins } from '@/utils/myMixins' import { myMixins } from '@/utils/myMixins'
import { isValidPhone, validateTimeRange } from '@/utils/validate' import { isValidPhone, validateTimeRange } from '@/utils/validate'
import { Dialog, Toast } from 'vant' import { Toast } from 'vant'
const DRAFT_KEY_PREFIX = 'supplierTimePhoneDraft_' const DRAFT_KEY_PREFIX = 'supplierTimePhoneDraft_'
function getSupplierIdFromToken() {
const token = localStorage.getItem('token')
if (!token) return null
try {
const payload = JSON.parse(atob(token.split('.')[1]))
return payload.supplierId || null
} catch (e) {
return null
}
}
function getDraftKey(supplierId) { function getDraftKey(supplierId) {
return `${DRAFT_KEY_PREFIX}${supplierId}` return `${DRAFT_KEY_PREFIX}${supplierId}`
} }
function emptyRecord() { function emptyRecord() {
return { return {
startTime: '00:00', startTime: '',
endTime: '23:59', endTime: '',
phone1: '', phone1: '',
phone1Desc: '', phone1Desc: '',
phone1WechatId: '', phone1WechatId: '',
@@ -98,7 +107,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.supplierId = this.$route.query.supplierId this.supplierId = this.$route.query.supplierId || getSupplierIdFromToken()
this.index = Number(this.$route.query.index) this.index = Number(this.$route.query.index)
if (Number.isNaN(this.index)) { if (Number.isNaN(this.index)) {
this.index = -1 this.index = -1
@@ -108,18 +117,6 @@ export default {
} }
}, },
methods: { methods: {
loadRecord() {
try {
const raw = localStorage.getItem(getDraftKey(this.supplierId))
const draft = raw ? JSON.parse(raw) : null
const list = draft?.phoneList || []
if (list[this.index]) {
this.form = { ...emptyRecord(), ...list[this.index] }
}
} catch (e) {
console.error(e)
}
},
validate() { validate() {
this.periodErr = '' this.periodErr = ''
this.phoneErr = ['', '', ''] this.phoneErr = ['', '', '']
@@ -163,13 +160,36 @@ export default {
return valid return valid
}, },
loadRecord() {
const key = getDraftKey(this.supplierId)
const raw = localStorage.getItem(key)
if (!raw) {
Toast('未找到时段数据')
this.h5GoBack()
return
}
try {
const draft = JSON.parse(raw)
const list = draft.phoneList || []
if (this.index >= 0 && this.index < list.length) {
this.form = { ...list[this.index] }
} else {
Toast('时段数据不存在')
this.h5GoBack()
}
} catch (e) {
console.error(e)
Toast('数据读取失败')
this.h5GoBack()
}
},
save() { save() {
if (!this.validate()) return if (!this.validate()) return
try { try {
const key = getDraftKey(this.supplierId) const key = getDraftKey(this.supplierId)
let draft = JSON.parse(localStorage.getItem(key) || '{}') const draft = JSON.parse(localStorage.getItem(key) || '{}')
let list = draft.phoneList || [] const list = draft.phoneList || []
const record = { const record = {
startTime: this.form.startTime, startTime: this.form.startTime,
endTime: this.form.endTime, endTime: this.form.endTime,
@@ -191,31 +211,12 @@ export default {
draft.phoneList = list draft.phoneList = list
localStorage.setItem(key, JSON.stringify(draft)) localStorage.setItem(key, JSON.stringify(draft))
Toast('已保存') Toast('已保存')
this.goBack() this.h5GoBack()
} catch (e) { } catch (e) {
Toast('保存失败') Toast('保存失败')
console.error(e) console.error(e)
} }
}, },
deleteCurrent() {
Dialog.confirm({
title: '提示',
message: '确定删除该时段电话?'
}).then(() => {
try {
const key = getDraftKey(this.supplierId)
let draft = JSON.parse(localStorage.getItem(key) || '{}')
let list = draft.phoneList || []
list.splice(this.index, 1)
draft.phoneList = list
localStorage.setItem(key, JSON.stringify(draft))
Toast('已删除')
this.goBack()
} catch (e) {
Toast('删除失败')
}
}).catch(() => {})
}
} }
} }
</script> </script>