添加跟进人
This commit is contained in:
parent
285c7ae0f7
commit
f4fd1f39a3
12
api/user.js
12
api/user.js
|
|
@ -60,3 +60,15 @@ export const logout = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有用户列表
|
||||||
|
* @returns {Promise<Array>} 返回用户列表
|
||||||
|
*/
|
||||||
|
export const getUserListAll = () => {
|
||||||
|
return uni.$uv.http.get('system/user/listAll', {
|
||||||
|
custom: {
|
||||||
|
auth: true // 启用 token 认证
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,13 @@
|
||||||
<text v-else class="form-placeholder">选择微信好友</text>
|
<text v-else class="form-placeholder">选择微信好友</text>
|
||||||
<text class="arrow">›</text>
|
<text class="arrow">›</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 跟进人 -->
|
||||||
|
<view class="form-item clickable-item" @click="$emit('open-picker', 'followUser')">
|
||||||
|
<text v-if="formData.followName" class="form-value">{{ formData.followName }}</text>
|
||||||
|
<text v-else class="form-placeholder">选择跟进人</text>
|
||||||
|
<text class="arrow">›</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,29 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 跟进人选择弹窗 -->
|
||||||
|
<view v-if="showFollowUserPicker" class="modal-mask" @click="closePicker('followUser')">
|
||||||
|
<view class="modal-content" @click.stop>
|
||||||
|
<view class="modal-title">选择跟进人</view>
|
||||||
|
<view class="picker-options">
|
||||||
|
<view
|
||||||
|
v-for="item in followUserOptions"
|
||||||
|
:key="item.userId"
|
||||||
|
class="picker-option"
|
||||||
|
:class="{ active: String(tempFollowUserId) === String(item.userId) }"
|
||||||
|
@click="selectFollowUser(item.userId)"
|
||||||
|
>
|
||||||
|
<text>{{ item.nickName }}</text>
|
||||||
|
<text v-if="String(tempFollowUserId) === String(item.userId)" class="check">✓</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="modal-buttons">
|
||||||
|
<button class="modal-btn" @click="closePicker('followUser')">取消</button>
|
||||||
|
<button class="modal-btn primary" @click="confirmFollowUser">确定</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|
@ -187,12 +210,14 @@ const props = defineProps({
|
||||||
showCustomerStatusPicker: Boolean,
|
showCustomerStatusPicker: Boolean,
|
||||||
showWorkWechatPicker: Boolean,
|
showWorkWechatPicker: Boolean,
|
||||||
showNextFollowTimePicker: Boolean,
|
showNextFollowTimePicker: Boolean,
|
||||||
|
showFollowUserPicker: Boolean,
|
||||||
customerTypeOptions: Array,
|
customerTypeOptions: Array,
|
||||||
sourceOptions: Array,
|
sourceOptions: Array,
|
||||||
intentOptions: Array,
|
intentOptions: Array,
|
||||||
intentLevelOptions: Array,
|
intentLevelOptions: Array,
|
||||||
customerStatusOptions: Array,
|
customerStatusOptions: Array,
|
||||||
workWechatOptions: Array,
|
workWechatOptions: Array,
|
||||||
|
followUserOptions: Array,
|
||||||
addressList: Array,
|
addressList: Array,
|
||||||
regionLoading: Boolean,
|
regionLoading: Boolean,
|
||||||
formData: Object
|
formData: Object
|
||||||
|
|
@ -209,6 +234,7 @@ const tempCustomerStatus = ref('');
|
||||||
const tempWorkWechat = ref('');
|
const tempWorkWechat = ref('');
|
||||||
const tempNextFollowDate = ref('');
|
const tempNextFollowDate = ref('');
|
||||||
const tempNextFollowTime = ref('');
|
const tempNextFollowTime = ref('');
|
||||||
|
const tempFollowUserId = ref('');
|
||||||
|
|
||||||
const regionPicker = ref(null);
|
const regionPicker = ref(null);
|
||||||
|
|
||||||
|
|
@ -221,6 +247,7 @@ watch(() => props.formData, (newData) => {
|
||||||
tempIntentLevel.value = newData.intentLevel || '';
|
tempIntentLevel.value = newData.intentLevel || '';
|
||||||
tempCustomerStatus.value = newData.customerStatus || '';
|
tempCustomerStatus.value = newData.customerStatus || '';
|
||||||
tempWorkWechat.value = newData.workWechatId || '';
|
tempWorkWechat.value = newData.workWechatId || '';
|
||||||
|
tempFollowUserId.value = newData.followId || '';
|
||||||
if (newData.nextFollowTime) {
|
if (newData.nextFollowTime) {
|
||||||
const [date, time] = newData.nextFollowTime.split(' ');
|
const [date, time] = newData.nextFollowTime.split(' ');
|
||||||
tempNextFollowDate.value = date || '';
|
tempNextFollowDate.value = date || '';
|
||||||
|
|
@ -356,6 +383,23 @@ const confirmNextFollowTime = () => {
|
||||||
closePicker('nextFollowTime');
|
closePicker('nextFollowTime');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 跟进人
|
||||||
|
const selectFollowUser = (userId) => {
|
||||||
|
tempFollowUserId.value = String(userId);
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmFollowUser = () => {
|
||||||
|
const selectedUser = props.followUserOptions.find(u => String(u.userId) === String(tempFollowUserId.value));
|
||||||
|
if (selectedUser) {
|
||||||
|
emit('update:formData', {
|
||||||
|
...props.formData,
|
||||||
|
followId: String(selectedUser.userId),
|
||||||
|
followName: selectedUser.nickName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
closePicker('followUser');
|
||||||
|
};
|
||||||
|
|
||||||
// 地区选择器
|
// 地区选择器
|
||||||
const onRegionChange = (e) => {
|
const onRegionChange = (e) => {
|
||||||
emit('region-change', e);
|
emit('region-change', e);
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,14 @@
|
||||||
:show-customer-status-picker="showCustomerStatusPicker"
|
:show-customer-status-picker="showCustomerStatusPicker"
|
||||||
:show-work-wechat-picker="showWorkWechatPicker"
|
:show-work-wechat-picker="showWorkWechatPicker"
|
||||||
:show-next-follow-time-picker="showNextFollowTimePicker"
|
:show-next-follow-time-picker="showNextFollowTimePicker"
|
||||||
|
:show-follow-user-picker="showFollowUserPicker"
|
||||||
:customer-type-options="customerTypeOptions"
|
:customer-type-options="customerTypeOptions"
|
||||||
:source-options="sourceOptions"
|
:source-options="sourceOptions"
|
||||||
:intent-options="intentOptions"
|
:intent-options="intentOptions"
|
||||||
:intent-level-options="intentLevelOptions"
|
:intent-level-options="intentLevelOptions"
|
||||||
:customer-status-options="customerStatusOptions"
|
:customer-status-options="customerStatusOptions"
|
||||||
:work-wechat-options="workWechatOptions"
|
:work-wechat-options="workWechatOptions"
|
||||||
|
:follow-user-options="followUserOptions"
|
||||||
:address-list="addressList"
|
:address-list="addressList"
|
||||||
:region-loading="regionLoading"
|
:region-loading="regionLoading"
|
||||||
:form-data="formData"
|
:form-data="formData"
|
||||||
|
|
@ -60,7 +62,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { createCustomer } from '@/api';
|
import { createCustomer, getUserListAll } from '@/api';
|
||||||
import { useUserStore } from '@/store/user';
|
import { useUserStore } from '@/store/user';
|
||||||
import { useCustomerForm } from '@/composables/useCustomerForm';
|
import { useCustomerForm } from '@/composables/useCustomerForm';
|
||||||
import CustomerFormNavbar from '@/components/customer/customer-form/CustomerFormNavbar.vue';
|
import CustomerFormNavbar from '@/components/customer/customer-form/CustomerFormNavbar.vue';
|
||||||
|
|
@ -105,7 +107,9 @@ const formData = ref({
|
||||||
pain: '',
|
pain: '',
|
||||||
attention: '',
|
attention: '',
|
||||||
demand: '',
|
demand: '',
|
||||||
nextFollowTime: ''
|
nextFollowTime: '',
|
||||||
|
followId: null,
|
||||||
|
followName: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
// 显示状态
|
// 显示状态
|
||||||
|
|
@ -117,6 +121,10 @@ const showIntentLevelPicker = ref(false);
|
||||||
const showCustomerStatusPicker = ref(false);
|
const showCustomerStatusPicker = ref(false);
|
||||||
const showWorkWechatPicker = ref(false);
|
const showWorkWechatPicker = ref(false);
|
||||||
const showNextFollowTimePicker = ref(false);
|
const showNextFollowTimePicker = ref(false);
|
||||||
|
const showFollowUserPicker = ref(false);
|
||||||
|
|
||||||
|
// 用户列表
|
||||||
|
const followUserOptions = ref([]);
|
||||||
|
|
||||||
const pickersRef = ref(null);
|
const pickersRef = ref(null);
|
||||||
|
|
||||||
|
|
@ -147,6 +155,9 @@ const handleOpenPicker = (pickerType) => {
|
||||||
case 'nextFollowTime':
|
case 'nextFollowTime':
|
||||||
showNextFollowTimePicker.value = true;
|
showNextFollowTimePicker.value = true;
|
||||||
break;
|
break;
|
||||||
|
case 'followUser':
|
||||||
|
showFollowUserPicker.value = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -174,6 +185,9 @@ const handleClosePicker = (pickerType) => {
|
||||||
case 'nextFollowTime':
|
case 'nextFollowTime':
|
||||||
showNextFollowTimePicker.value = false;
|
showNextFollowTimePicker.value = false;
|
||||||
break;
|
break;
|
||||||
|
case 'followUser':
|
||||||
|
showFollowUserPicker.value = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -192,12 +206,30 @@ const handleCancel = () => {
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 加载用户列表
|
||||||
|
const loadUserList = async () => {
|
||||||
|
try {
|
||||||
|
const res = await getUserListAll();
|
||||||
|
if (res && res.data && Array.isArray(res.data)) {
|
||||||
|
followUserOptions.value = res.data;
|
||||||
|
} else if (res && Array.isArray(res)) {
|
||||||
|
followUserOptions.value = res;
|
||||||
|
} else {
|
||||||
|
followUserOptions.value = [];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载用户列表失败:', error);
|
||||||
|
followUserOptions.value = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 组件挂载时加载数据并设置默认值
|
// 组件挂载时加载数据并设置默认值
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
loadRegionTree(),
|
loadRegionTree(),
|
||||||
loadDictData(),
|
loadDictData(),
|
||||||
loadWechatList()
|
loadWechatList(),
|
||||||
|
loadUserList()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 设置默认值:意向=电动车(按label),强度=中(按value),来源=抖音(按label),状态=意向(按value)
|
// 设置默认值:意向=电动车(按label),强度=中(按value),来源=抖音(按label),状态=意向(按value)
|
||||||
|
|
@ -262,9 +294,6 @@ const handleSave = async () => {
|
||||||
|
|
||||||
saving.value = true;
|
saving.value = true;
|
||||||
try {
|
try {
|
||||||
const userStore = useUserStore();
|
|
||||||
const userId = userStore.userInfo?.id || userStore.userInfo?.userId || '1';
|
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const formatDateTime = (date) => {
|
const formatDateTime = (date) => {
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
|
|
@ -279,6 +308,11 @@ const handleSave = async () => {
|
||||||
const intentsArray = Array.isArray(formData.value.intents) ? formData.value.intents : [];
|
const intentsArray = Array.isArray(formData.value.intents) ? formData.value.intents : [];
|
||||||
const regionIdsArray = formData.value.regionIds || [];
|
const regionIdsArray = formData.value.regionIds || [];
|
||||||
|
|
||||||
|
// 使用选中的跟进人ID,如果没有选择则使用当前用户ID
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const defaultUserId = userStore.userInfo?.id || userStore.userInfo?.userId || '1';
|
||||||
|
const followId = formData.value.followId || defaultUserId;
|
||||||
|
|
||||||
const submitData = {
|
const submitData = {
|
||||||
id: null,
|
id: null,
|
||||||
code: null,
|
code: null,
|
||||||
|
|
@ -289,7 +323,7 @@ const handleSave = async () => {
|
||||||
wechat: formData.value.wechat.trim() || null,
|
wechat: formData.value.wechat.trim() || null,
|
||||||
source: formData.value.source || null,
|
source: formData.value.source || null,
|
||||||
intents: intentsArray,
|
intents: intentsArray,
|
||||||
followId: userId,
|
followId: followId,
|
||||||
remark: formData.value.remark.trim() || null,
|
remark: formData.value.remark.trim() || null,
|
||||||
type: '2',
|
type: '2',
|
||||||
workWechatId: formData.value.workWechatId || null,
|
workWechatId: formData.value.workWechatId || null,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user