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
+42 -41
View File
@@ -3,7 +3,7 @@
<van-nav-bar
:title="isEdit ? '编辑时段电话' : '新增时段电话'"
left-arrow
@click-left="goBack"
@click-left="h5GoBack"
fixed
placeholder
class="nav-bar"
@@ -46,8 +46,6 @@
</div>
<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>
</div>
</div>
@@ -56,18 +54,29 @@
<script>
import { myMixins } from '@/utils/myMixins'
import { isValidPhone, validateTimeRange } from '@/utils/validate'
import { Dialog, Toast } from 'vant'
import { Toast } from 'vant'
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) {
return `${DRAFT_KEY_PREFIX}${supplierId}`
}
function emptyRecord() {
return {
startTime: '00:00',
endTime: '23:59',
startTime: '',
endTime: '',
phone1: '',
phone1Desc: '',
phone1WechatId: '',
@@ -98,7 +107,7 @@ export default {
}
},
mounted() {
this.supplierId = this.$route.query.supplierId
this.supplierId = this.$route.query.supplierId || getSupplierIdFromToken()
this.index = Number(this.$route.query.index)
if (Number.isNaN(this.index)) {
this.index = -1
@@ -108,18 +117,6 @@ export default {
}
},
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() {
this.periodErr = ''
this.phoneErr = ['', '', '']
@@ -163,13 +160,36 @@ export default {
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() {
if (!this.validate()) return
try {
const key = getDraftKey(this.supplierId)
let draft = JSON.parse(localStorage.getItem(key) || '{}')
let list = draft.phoneList || []
const draft = JSON.parse(localStorage.getItem(key) || '{}')
const list = draft.phoneList || []
const record = {
startTime: this.form.startTime,
endTime: this.form.endTime,
@@ -191,31 +211,12 @@ export default {
draft.phoneList = list
localStorage.setItem(key, JSON.stringify(draft))
Toast('已保存')
this.goBack()
this.h5GoBack()
} catch (e) {
Toast('保存失败')
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>