提交
This commit is contained in:
1 parent
7b1d4c8729
commit
ffc89d9b57
75 files changed
+12263
-7950
No files matched your search
@@ -2,7 +2,7 @@
|
||||
<el-dialog
|
||||
title="选择客户"
|
||||
v-model="dialogVisible"
|
||||
width="1280px"
|
||||
width="1500px"
|
||||
align-center
|
||||
class="dialog-form-layout"
|
||||
modal-class="order-module-dialog-mask"
|
||||
@@ -39,6 +39,7 @@
|
||||
<div class="panel dialog-list-panel">
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
v-loading="loading"
|
||||
:data="customerList"
|
||||
class="list-table"
|
||||
@@ -48,7 +49,13 @@
|
||||
:max-height="400"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="60" align="center" header-align="center" />
|
||||
<el-table-column label="客户名称" prop="customerName" min-width="230" align="center" header-align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="客户名称" prop="customerName" min-width="200" align="center" header-align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="客户简称" prop="shortName" min-width="120" align="center" header-align="center" :show-overflow-tooltip="true">
|
||||
<template #default="scope">
|
||||
<span v-if="hasShortName(scope.row)">{{ scope.row.shortName }}</span>
|
||||
<el-tag v-else type="warning" size="small">未填写</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户类型" prop="customerType" min-width="150" align="center" header-align="center">
|
||||
<template #default="scope">
|
||||
<DictTag dict-type="crm_customer_type" :value="scope.row.customerType" />
|
||||
@@ -72,6 +79,13 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="负责人" prop="ownerUserName" min-width="100" align="center" header-align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="操作" fixed="right" min-width="120" align="center" header-align="center" class-name="col-actions">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click.stop="handleEditShortName(scope.row)">
|
||||
<el-icon><Edit /></el-icon>{{ hasShortName(scope.row) ? '编辑简称' : '填写简称' }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<ListPagination
|
||||
@@ -90,6 +104,7 @@
|
||||
<div class="selected-customer">
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="客户名称">{{ currentCustomer.customerName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客户简称">{{ currentCustomer.shortName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客户类型">
|
||||
<DictTag dict-type="crm_customer_type" :value="currentCustomer.customerType" />
|
||||
</el-descriptions-item>
|
||||
@@ -110,7 +125,55 @@
|
||||
<el-button class="btn-ghost" @click="handleClose">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleConfirm" :disabled="!currentCustomer">
|
||||
<el-button
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
@click="handleConfirm"
|
||||
:disabled="!currentCustomer || !hasShortName(currentCustomer)"
|
||||
>
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 填写/编辑客户简称 -->
|
||||
<el-dialog
|
||||
v-model="shortNameDialogVisible"
|
||||
:title="hasShortName(shortNameForm) ? '编辑客户简称' : '填写客户简称'"
|
||||
width="480px"
|
||||
align-center
|
||||
class="dialog-form-layout"
|
||||
modal-class="order-module-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
>
|
||||
<el-form
|
||||
ref="shortNameFormRef"
|
||||
:model="shortNameForm"
|
||||
:rules="shortNameRules"
|
||||
label-position="top"
|
||||
class="crm-dialog-form"
|
||||
>
|
||||
<el-form-item label="客户名称">
|
||||
<el-input :model-value="shortNameForm.customerName" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="客户简称" prop="shortName">
|
||||
<el-input
|
||||
v-model="shortNameForm.shortName"
|
||||
placeholder="请输入客户简称"
|
||||
maxlength="100"
|
||||
show-word-limit
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button class="btn-ghost" @click="shortNameDialogVisible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="shortNameSaving" @click="handleSaveShortName">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -122,10 +185,10 @@
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import DictTag from '@/components/DictTag/index.vue'
|
||||
import ListPagination from '@/components/ListPagination/index.vue'
|
||||
import { Check, Close, Refresh, Search } from '@element-plus/icons-vue'
|
||||
import { Check, Close, Edit, Refresh, Search } from '@element-plus/icons-vue'
|
||||
import { ref, watch } from 'vue'
|
||||
import type { ElFormInstance } from 'element-plus'
|
||||
import { fetchCustomerList } from '@/api/crm/customer'
|
||||
import type { ElFormInstance, FormItemRule } from 'element-plus'
|
||||
import { fetchCustomerList, fetchUpdateCustomer } from '@/api/crm/customer'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
|
||||
@@ -167,6 +230,21 @@ const loading = ref(false)
|
||||
const total = ref(0)
|
||||
const currentCustomer = ref<any | null>(null)
|
||||
const queryFormRef = ref<ElFormInstance>()
|
||||
const tableRef = ref<any>()
|
||||
|
||||
const shortNameDialogVisible = ref(false)
|
||||
const shortNameSaving = ref(false)
|
||||
const shortNameFormRef = ref<ElFormInstance>()
|
||||
const shortNameForm = ref({
|
||||
id: '' as string | number,
|
||||
customerName: '',
|
||||
shortName: ''
|
||||
})
|
||||
const shortNameRules: Record<string, FormItemRule[]> = {
|
||||
shortName: [{ required: true, message: '客户简称不能为空', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const hasShortName = (row?: { shortName?: string } | null) => Boolean(String(row?.shortName || '').trim())
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
@@ -213,10 +291,66 @@ watchDebounced(
|
||||
)
|
||||
|
||||
const handleCurrentChange = (row: any) => {
|
||||
if (!row) {
|
||||
currentCustomer.value = null
|
||||
return
|
||||
}
|
||||
if (!hasShortName(row)) {
|
||||
ElMessage.warning('该客户尚未填写简称,请先填写客户简称后再选择')
|
||||
tableRef.value?.setCurrentRow(undefined)
|
||||
currentCustomer.value = null
|
||||
return
|
||||
}
|
||||
currentCustomer.value = row
|
||||
}
|
||||
|
||||
const handleEditShortName = (row: any) => {
|
||||
shortNameForm.value = {
|
||||
id: row.id,
|
||||
customerName: row.customerName || '',
|
||||
shortName: row.shortName || ''
|
||||
}
|
||||
shortNameDialogVisible.value = true
|
||||
nextTick(() => shortNameFormRef.value?.clearValidate())
|
||||
}
|
||||
|
||||
const handleSaveShortName = async () => {
|
||||
const valid = await shortNameFormRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
|
||||
shortNameSaving.value = true
|
||||
try {
|
||||
const trimmedShortName = shortNameForm.value.shortName.trim()
|
||||
await fetchUpdateCustomer({
|
||||
id: shortNameForm.value.id,
|
||||
shortName: trimmedShortName
|
||||
})
|
||||
ElMessage.success('客户简称保存成功')
|
||||
|
||||
const targetId = shortNameForm.value.id
|
||||
const updatedRow = customerList.value.find((item) => item.id === targetId)
|
||||
if (updatedRow) {
|
||||
updatedRow.shortName = trimmedShortName
|
||||
}
|
||||
if (currentCustomer.value?.id === targetId) {
|
||||
currentCustomer.value = { ...currentCustomer.value, shortName: trimmedShortName }
|
||||
}
|
||||
|
||||
shortNameDialogVisible.value = false
|
||||
} catch (error) {
|
||||
console.error('保存客户简称失败:', error)
|
||||
ElMessage.error('保存客户简称失败')
|
||||
} finally {
|
||||
shortNameSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleConfirm = () => {
|
||||
if (!currentCustomer.value) return
|
||||
if (!hasShortName(currentCustomer.value)) {
|
||||
ElMessage.warning('该客户尚未填写简称,请先填写客户简称后再选择')
|
||||
return
|
||||
}
|
||||
emit('confirm', currentCustomer.value)
|
||||
handleClose()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user