Commit 20f1a2f6 by Lin

feat(Employee, AddFiles, DetailFiles): 优化员工选择和信息显示逻辑

- 将 Employee 组件中的 open 方法改为异步,确保员工列表在需要时加载。
- 新增 ensureEmployeeList 方法以处理员工列表的获取逻辑。
- 在 AddFiles 页面中添加流量来源员工选择组件,并调整相关逻辑。
- 在 DetailFiles 页面中优化只读字段的显示逻辑,确保显示格式一致性。
1 parent 70bfe06a
...@@ -74,32 +74,34 @@ export default { ...@@ -74,32 +74,34 @@ export default {
mounted () { mounted () {
}, },
methods: { methods: {
open () { async open () {
if (Array.isArray(this.list)) {
this.$refs.employeeBoxVisible.open()
return
}
await this.ensureEmployeeList()
this.$refs.employeeBoxVisible.open() this.$refs.employeeBoxVisible.open()
if (Array.isArray(this.list)) return },
const userInfo = uni.$storage.get("userInfo") async ensureEmployeeList () {
const userInfo = uni.$storage.get('userInfo') || {}
if (this.employeeType === 'seller') { if (this.employeeType === 'seller') {
if (this.sellerEmployeeList.length) return
const { merchantId } = userInfo const { merchantId } = userInfo
uni.$api.popupApi const res = await uni.$api.popupApi.getEmployeeList({
.getEmployeeList({
merchantId, merchantId,
sceneList: '' sceneList: ''
}) })
.then((res) => {
this.sellerEmployeeList = res || [] this.sellerEmployeeList = res || []
})
return return
} }
const employeeList = this.$store.state.user.employeeList
if (employeeList && employeeList.length) return
const { shopMerchantId } = userInfo const { shopMerchantId } = userInfo
/**获取销售人员 */ const res = await uni.$api.commonApi.getEmployeeList({
uni.$api.commonApi merchantId: shopMerchantId
.getEmployeeList({
merchantId: shopMerchantId,
})
.then((res) => {
this.$store.dispatch("setEmployeeList", res);
uni.$storage.set("employeeList", res || []);
}) })
this.$store.dispatch('setEmployeeList', res)
uni.$storage.set('employeeList', res || [])
}, },
handleSelect (item) { handleSelect (item) {
this.close(); this.close();
......
...@@ -129,10 +129,17 @@ ...@@ -129,10 +129,17 @@
:customerInfo="customerInfo" :customerInfo="customerInfo"
></reception-sence> ></reception-sence>
<employee <employee
ref="trafficSourceVisible"
title="流量来源"
employeeType="default"
:salesPropsUuid="customerInfo.userId"
@select="handleSelect($event, 'trafficSourceVisible')"
/>
<employee
ref="residentSaleVisible" ref="residentSaleVisible"
:title="employeeSelectKey === 'sellerUserId' ? '驻店零售' : '流量来源'" title="驻店零售"
:employeeType="employeeSelectKey === 'sellerUserId' ? 'seller' : 'default'" employeeType="seller"
:salesPropsUuid="employeeSelectKey ? customerInfo[employeeSelectKey] : ''" :salesPropsUuid="customerInfo.sellerUserId"
@select="handleSelect($event, 'residentSaleVisible')" @select="handleSelect($event, 'residentSaleVisible')"
/> />
</view> </view>
...@@ -192,7 +199,7 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -192,7 +199,7 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
key: 'userId', key: 'userId',
type: 'select', type: 'select',
required: true, required: true,
popKey: 'residentSaleVisible', popKey: 'trafficSourceVisible',
merchantNameKey: 'merchantName' merchantNameKey: 'merchantName'
} }
// { // {
...@@ -256,7 +263,6 @@ export default { ...@@ -256,7 +263,6 @@ export default {
startDate: '', startDate: '',
endDate: '', endDate: '',
validateState: true, validateState: true,
employeeSelectKey: '',
inviteDateTouched: false inviteDateTouched: false
} }
}, },
...@@ -319,7 +325,6 @@ export default { ...@@ -319,7 +325,6 @@ export default {
}) })
}, },
showPopup (item) { showPopup (item) {
this.employeeSelectKey = item.key
this.$refs[item.popKey].open() this.$refs[item.popKey].open()
}, },
getFieldDisplayValue (field) { getFieldDisplayValue (field) {
...@@ -342,8 +347,8 @@ export default { ...@@ -342,8 +347,8 @@ export default {
oneCarBrand: item.carBrand, oneCarBrand: item.carBrand,
oneCarBrandId: item.carBrandId oneCarBrandId: item.carBrandId
}) })
} else if (popkey == 'residentSaleVisible') { } else if (popkey === 'residentSaleVisible' || popkey === 'trafficSourceVisible') {
const field = this.customerForm.concat(this.optionalForm).find(e => e.key === this.employeeSelectKey) const field = this.customerForm.concat(this.optionalForm).find(e => e.popKey === popkey)
if (field) { if (field) {
if (field.merchantNameKey) { if (field.merchantNameKey) {
const { shopMerchantName } = uni.$storage.get('userInfo') || {} const { shopMerchantName } = uni.$storage.get('userInfo') || {}
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<view class="required" v-if="i.required">*</view>{{ i.label }} <view class="required" v-if="i.required">*</view>{{ i.label }}
</view> </view>
<template v-if="i.type == 'readonly'"> <template v-if="i.type == 'readonly'">
<view class="input input--readonly text-hide">{{ customerInfo[i.valueKey] || '-' }}</view> <view class="input input--readonly text-hide">{{ getFieldDisplayValue(i) || '-' }}</view>
</template> </template>
<template v-else-if="i.type == 'input'"> <template v-else-if="i.type == 'input'">
<input <input
...@@ -137,10 +137,10 @@ ...@@ -137,10 +137,10 @@
</view> </view>
<template v-if="i.type == 'readonly'"> <template v-if="i.type == 'readonly'">
<view v-if="i.showSync" class="readonly-box flex"> <view v-if="i.showSync" class="readonly-box flex">
<view class="input input--readonly text-hide">{{ customerInfo[i.valueKey] || '-' }}</view> <view class="input input--readonly text-hide">{{ getFieldDisplayValue(i) || '-' }}</view>
<view class="sync-btn" @click.stop="syncCustomerGroupInfo">同步</view> <view class="sync-btn" @click.stop="syncCustomerGroupInfo">同步</view>
</view> </view>
<view v-else class="input input--readonly text-hide">{{ customerInfo[i.valueKey] || '-' }}</view> <view v-else class="input input--readonly text-hide">{{ getFieldDisplayValue(i) || '-' }}</view>
</template> </template>
<template v-else-if="i.type == 'input'"> <template v-else-if="i.type == 'input'">
<view class="input-box flex"> <view class="input-box flex">
...@@ -267,7 +267,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -267,7 +267,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
valueKey: 'employeeName', valueKey: 'employeeName',
key: 'userId', key: 'userId',
type: 'readonly', type: 'readonly',
required: true required: true,
merchantNameKey: 'merchantName'
}], }],
default_optionalForm = [{ default_optionalForm = [{
label: '车架号', label: '车架号',
...@@ -627,6 +628,7 @@ export default { ...@@ -627,6 +628,7 @@ export default {
createdDate: '', createdDate: '',
employeeName: '', employeeName: '',
userId: '', userId: '',
merchantName: '',
advanceUserName: '', advanceUserName: '',
advanceUserId: '', advanceUserId: '',
qwGroupName: '', qwGroupName: '',
...@@ -680,6 +682,12 @@ export default { ...@@ -680,6 +682,12 @@ export default {
showPopup (e) { showPopup (e) {
this.$refs[e].open() this.$refs[e].open()
}, },
getFieldDisplayValue (field) {
const value = this.customerInfo[field.valueKey]
if (!value) return ''
const merchantName = field.merchantNameKey && this.customerInfo[field.merchantNameKey]
return merchantName ? `${merchantName}-${value}` : value
},
handleSelect (item, popkey) { handleSelect (item, popkey) {
this.$refs[popkey].close() this.$refs[popkey].close()
if (popkey == 'carBrandVisible') { if (popkey == 'carBrandVisible') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!