diff --git a/src/api/mes/customer/index.ts b/src/api/mes/customer/index.ts
index ae8a2977..95b7e62e 100644
--- a/src/api/mes/customer/index.ts
+++ b/src/api/mes/customer/index.ts
@@ -3,6 +3,9 @@ import request from '@/config/axios'
export interface CustomerVO {
id: number // 编号
name: string // 客户名称
+ customerCode?: string // 客户编码
+ isCode?: boolean // 是否自动生成客户编码
+ contactName?: string // 联系人
followUpStatus: boolean // 跟进状态
contactLastTime: Date // 最后跟进时间
contactLastContent: string // 最后跟进内容
diff --git a/src/views/mes/customer/CustomerForm.vue b/src/views/mes/customer/CustomerForm.vue
index 589bb99d..c156b4c5 100644
--- a/src/views/mes/customer/CustomerForm.vue
+++ b/src/views/mes/customer/CustomerForm.vue
@@ -28,8 +28,31 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -51,13 +74,13 @@
-
-
+
+
-
-
+
+
@@ -164,6 +187,9 @@ const userOptions = ref([]) // 用户列表
const formData = ref({
id: undefined,
name: undefined,
+ customerCode: undefined,
+ isCode: true,
+ contactName: undefined,
contactNextTime: undefined,
ownerUserId: 0,
mobile: undefined,
@@ -178,8 +204,21 @@ const formData = ref({
source: undefined,
remark: undefined
})
+const validateCustomerCode = (_rule, value, callback) => {
+ if (Boolean(formData.value.isCode)) {
+ callback()
+ return
+ }
+ if (value === undefined || value === null || String(value).trim() === '') {
+ callback(new Error('客户编码不能为空'))
+ return
+ }
+ callback()
+}
+
const formRules = reactive({
name: [{ required: true, message: '客户名称不能为空', trigger: 'blur' }],
+ customerCode: [{ validator: validateCustomerCode, trigger: ['blur', 'change'] }],
ownerUserId: [{ required: true, message: '负责人不能为空', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
@@ -194,7 +233,11 @@ const open = async (type: string, id?: number) => {
if (id) {
formLoading.value = true
try {
- formData.value = await CustomerApi.getCustomer(id)
+ const data = await CustomerApi.getCustomer(id)
+ formData.value = {
+ ...data,
+ isCode: (data as any)?.isCode ?? false
+ } as any
} finally {
formLoading.value = false
}
@@ -208,6 +251,13 @@ const open = async (type: string, id?: number) => {
formData.value.ownerUserId = useUserStore().getUser.id
}
}
+const handleCodeAutoChange = (value: boolean) => {
+ if (value) {
+ formData.value.customerCode = undefined
+ }
+ formRef.value?.clearValidate('customerCode')
+}
+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
@@ -241,6 +291,9 @@ const resetForm = () => {
formData.value = {
id: undefined,
name: undefined,
+ customerCode: undefined,
+ isCode: true,
+ contactName: undefined,
contactNextTime: undefined,
ownerUserId: 0,
mobile: undefined,
@@ -258,3 +311,20 @@ const resetForm = () => {
formRef.value?.resetFields()
}
+
+
diff --git a/src/views/mes/customer/index.vue b/src/views/mes/customer/index.vue
index 5db53645..e34488b4 100644
--- a/src/views/mes/customer/index.vue
+++ b/src/views/mes/customer/index.vue
@@ -9,7 +9,7 @@
:inline="true"
:model="queryParams"
class="-mb-15px"
- label-width="68px"
+ min-label-width="68px"
>
-
+
@@ -87,10 +87,10 @@
新增
-
+
-
+
-
- {{ scope.row.name }}
-
+ {{ scope.row.name }}
+
+
-
-
-
+
+
+
@@ -227,7 +227,7 @@ import download from '@/utils/download'
import * as CustomerApi from '@/api/mes/customer'
import CustomerForm from './CustomerForm.vue'
import CustomerImportForm from './CustomerImportForm.vue'
-import { TabsPaneContext } from 'element-plus'
+// import { TabsPaneContext } from 'element-plus'
defineOptions({ name: 'MesCustomer' })
@@ -250,13 +250,13 @@ const queryParams = reactive({
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
-const activeName = ref('1') // 列表 tab
+// const activeName = ref('1') // 列表 tab
/** tab 切换 */
-const handleTabClick = (tab: TabsPaneContext) => {
- queryParams.sceneType = tab.paneName as string
- handleQuery()
-}
+// const handleTabClick = (tab: TabsPaneContext) => {
+// queryParams.sceneType = tab.paneName as string
+// handleQuery()
+// }
/** 查询列表 */
const getList = async () => {
@@ -283,10 +283,10 @@ const resetQuery = () => {
}
/** 打开客户详情 */
-const { currentRoute, push } = useRouter()
-const openDetail = (id: number) => {
- push({ name: 'MesCustomerDetail', params: { id } })
-}
+const { currentRoute } = useRouter()
+// const openDetail = (id: number) => {
+// push({ name: 'MesCustomerDetail', params: { id } })
+// }
/** 添加/修改操作 */
const formRef = ref()
@@ -309,9 +309,9 @@ const handleDelete = async (id: number) => {
/** 导入按钮操作 */
const importFormRef = ref>()
-const handleImport = () => {
- importFormRef.value?.open()
-}
+// const handleImport = () => {
+// importFormRef.value?.open()
+// }
/** 导出按钮操作 */
const handleExport = async () => {