提交
This commit is contained in:
1 parent
2df2ef0808
commit
683f14828f
388 files changed
+2738488
-81306
No files matched your search
@@ -9,34 +9,28 @@
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
>
|
||||
<!-- 查询表单 -->
|
||||
<el-form :model="queryParams" ref="queryFormRef" :inline="true" class="mb-3 search-form-inline">
|
||||
<el-form-item label="客户名称" prop="customerName">
|
||||
<el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable @keyup.enter="handleQuery" style="width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="客户编号" prop="customerNo">
|
||||
<el-input v-model="queryParams.customerNo" placeholder="请输入客户编号" clearable @keyup.enter="handleQuery" style="width: 150px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="客户类型" prop="customerType">
|
||||
<el-select v-model="queryParams.customerType" placeholder="请选择客户类型" clearable style="width: 150px">
|
||||
<el-option v-for="dict in dictStore.getOptions('crm_customer_type')" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop="mobile">
|
||||
<el-input v-model="queryParams.mobile" placeholder="请输入手机号码" clearable @keyup.enter="handleQuery" style="width: 150px" />
|
||||
</el-form-item>
|
||||
<el-form-item class="form-buttons-right">
|
||||
<el-button type="primary" :loading="loading" @click="handleQuery">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
<el-button :loading="loading" @click="resetQuery">
|
||||
<el-icon><Refresh /></el-icon>重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 客户列表 -->
|
||||
<div class="panel dialog-list-panel">
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row customer-selector-toolbar-row">
|
||||
<ListQuickSearchInput
|
||||
v-model="quickSearchKeyword"
|
||||
placeholder="客户名称/拼音首字母"
|
||||
@search="handleQuickSearch"
|
||||
@clear="handleQuickSearchClear"
|
||||
/>
|
||||
<el-button class="btn-main" type="primary" @click="handleAddCustomer">
|
||||
<el-icon><Plus /></el-icon>新增客户
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :disabled="!selectedRow" @click="handleEditCustomer">
|
||||
<el-icon><Edit /></el-icon>编辑客户
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :disabled="!selectedRow" @click="handleMaintainInvoice">
|
||||
<el-icon><Stamp /></el-icon>维护开票信息
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
@@ -179,14 +173,41 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<CustomerFormDialog ref="customerFormRef" @success="handleCustomerFormSuccess" />
|
||||
|
||||
<!-- 维护开票信息(一客户多条 + 默认;关闭后不自动回填外层,需重新「确定」选用客户) -->
|
||||
<el-dialog
|
||||
v-model="invoiceDialogVisible"
|
||||
:title="invoiceDialogTitle"
|
||||
width="1200px"
|
||||
align-center
|
||||
class="dialog-form-layout"
|
||||
modal-class="order-module-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
>
|
||||
<InvoiceInfo v-if="invoiceCustomerId" :customer-id="invoiceCustomerId" />
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button class="btn-ghost" @click="invoiceDialogVisible = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="CustomerSelector">
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import DictTag from '@/components/DictTag/index.vue'
|
||||
import ListPagination from '@/components/ListPagination/index.vue'
|
||||
import { Check, Close, Edit, Refresh, Search } from '@element-plus/icons-vue'
|
||||
import { ref, watch } from 'vue'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import CustomerFormDialog from '@/views/crm/customer/CustomerFormDialog.vue'
|
||||
import InvoiceInfo from '@/views/crm/customer/components/InvoiceInfo.vue'
|
||||
import { Check, Close, Edit, Plus, Stamp } from '@element-plus/icons-vue'
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import type { ElFormInstance, FormItemRule } from 'element-plus'
|
||||
import { fetchCustomerList, fetchUpdateCustomer } from '@/api/crm/customer'
|
||||
|
||||
@@ -207,6 +228,11 @@ watch(
|
||||
dialogVisible.value = val
|
||||
if (val) {
|
||||
await dictStore.loadAllDict()
|
||||
quickSearchKeyword.value = ''
|
||||
queryParams.value.pageNum = 1
|
||||
queryParams.value.keyword = undefined
|
||||
selectedRow.value = null
|
||||
currentCustomer.value = null
|
||||
getList()
|
||||
}
|
||||
}
|
||||
@@ -219,18 +245,19 @@ watch(dialogVisible, (val) => {
|
||||
const queryParams = ref<Record<string, any>>({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
customerName: undefined,
|
||||
customerNo: undefined,
|
||||
customerType: undefined,
|
||||
mobile: undefined
|
||||
keyword: undefined as string | undefined
|
||||
})
|
||||
|
||||
const quickSearchKeyword = ref('')
|
||||
const customerList = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const total = ref(0)
|
||||
/** 表格当前高亮行(可无简称,用于编辑) */
|
||||
const selectedRow = ref<any | null>(null)
|
||||
/** 可确认选用的客户(须已填简称) */
|
||||
const currentCustomer = ref<any | null>(null)
|
||||
const queryFormRef = ref<ElFormInstance>()
|
||||
const tableRef = ref<any>()
|
||||
const customerFormRef = ref<InstanceType<typeof CustomerFormDialog>>()
|
||||
|
||||
const shortNameDialogVisible = ref(false)
|
||||
const shortNameSaving = ref(false)
|
||||
@@ -252,10 +279,7 @@ const getList = async () => {
|
||||
const res = await fetchCustomerList({
|
||||
page: queryParams.value.pageNum,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
customerName: queryParams.value.customerName,
|
||||
customerNo: queryParams.value.customerNo,
|
||||
customerType: queryParams.value.customerType,
|
||||
mobile: queryParams.value.mobile
|
||||
keyword: queryParams.value.keyword || undefined
|
||||
})
|
||||
customerList.value = res.list || res.rows || []
|
||||
total.value = res.total ?? 0
|
||||
@@ -266,38 +290,61 @@ const getList = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleQuery = () => {
|
||||
const handleQuickSearch = () => {
|
||||
queryParams.value.pageNum = 1
|
||||
queryParams.value.keyword = quickSearchKeyword.value?.trim() || undefined
|
||||
getList()
|
||||
}
|
||||
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields()
|
||||
handleQuery()
|
||||
const handleQuickSearchClear = () => {
|
||||
quickSearchKeyword.value = ''
|
||||
queryParams.value.pageNum = 1
|
||||
queryParams.value.keyword = undefined
|
||||
getList()
|
||||
}
|
||||
|
||||
watchDebounced(
|
||||
() => ({
|
||||
customerName: queryParams.value.customerName,
|
||||
customerNo: queryParams.value.customerNo,
|
||||
customerType: queryParams.value.customerType,
|
||||
mobile: queryParams.value.mobile
|
||||
}),
|
||||
() => {
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
},
|
||||
{ debounce: 300, deep: true }
|
||||
const handleAddCustomer = () => {
|
||||
customerFormRef.value?.open()
|
||||
}
|
||||
|
||||
const handleEditCustomer = () => {
|
||||
if (!selectedRow.value?.id) {
|
||||
ElMessage.warning('请先选择一条客户记录')
|
||||
return
|
||||
}
|
||||
customerFormRef.value?.open(selectedRow.value.id)
|
||||
}
|
||||
|
||||
const invoiceDialogVisible = ref(false)
|
||||
const invoiceCustomerId = ref<string | number>('')
|
||||
const invoiceCustomerName = ref('')
|
||||
const invoiceDialogTitle = computed(() =>
|
||||
invoiceCustomerName.value
|
||||
? `维护开票信息 — ${invoiceCustomerName.value}`
|
||||
: '维护开票信息'
|
||||
)
|
||||
|
||||
const handleMaintainInvoice = () => {
|
||||
if (!selectedRow.value?.id) {
|
||||
ElMessage.warning('请先选择一条客户记录')
|
||||
return
|
||||
}
|
||||
invoiceCustomerId.value = selectedRow.value.id
|
||||
invoiceCustomerName.value = selectedRow.value.customerName || ''
|
||||
invoiceDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleCustomerFormSuccess = () => {
|
||||
getList()
|
||||
}
|
||||
|
||||
const handleCurrentChange = (row: any) => {
|
||||
selectedRow.value = row || null
|
||||
if (!row) {
|
||||
currentCustomer.value = null
|
||||
return
|
||||
}
|
||||
if (!hasShortName(row)) {
|
||||
ElMessage.warning('该客户尚未填写简称,请先填写客户简称后再选择')
|
||||
tableRef.value?.setCurrentRow(undefined)
|
||||
currentCustomer.value = null
|
||||
return
|
||||
}
|
||||
@@ -332,8 +379,11 @@ const handleSaveShortName = async () => {
|
||||
if (updatedRow) {
|
||||
updatedRow.shortName = trimmedShortName
|
||||
}
|
||||
if (currentCustomer.value?.id === targetId) {
|
||||
currentCustomer.value = { ...currentCustomer.value, shortName: trimmedShortName }
|
||||
if (selectedRow.value?.id === targetId) {
|
||||
selectedRow.value = { ...selectedRow.value, shortName: trimmedShortName }
|
||||
}
|
||||
if (currentCustomer.value?.id === targetId || (selectedRow.value?.id === targetId && hasShortName(selectedRow.value))) {
|
||||
currentCustomer.value = { ...(selectedRow.value || currentCustomer.value), shortName: trimmedShortName }
|
||||
}
|
||||
|
||||
shortNameDialogVisible.value = false
|
||||
@@ -346,7 +396,12 @@ const handleSaveShortName = async () => {
|
||||
}
|
||||
|
||||
const handleConfirm = () => {
|
||||
if (!currentCustomer.value) return
|
||||
if (!currentCustomer.value) {
|
||||
if (selectedRow.value && !hasShortName(selectedRow.value)) {
|
||||
ElMessage.warning('该客户尚未填写简称,请先填写客户简称后再选择')
|
||||
}
|
||||
return
|
||||
}
|
||||
if (!hasShortName(currentCustomer.value)) {
|
||||
ElMessage.warning('该客户尚未填写简称,请先填写客户简称后再选择')
|
||||
return
|
||||
@@ -356,6 +411,7 @@ const handleConfirm = () => {
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
selectedRow.value = null
|
||||
currentCustomer.value = null
|
||||
dialogVisible.value = false
|
||||
}
|
||||
@@ -368,20 +424,14 @@ const handleClose = () => {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.mb-3 {
|
||||
margin-bottom: 16px;
|
||||
/* 弹窗 append-to-body 后不在 .page-container 内,需自行限制检索框宽度,避免独占一行 */
|
||||
.customer-selector-toolbar-row {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.mt-3 {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.search-form-inline {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.form-buttons-right {
|
||||
margin-left: auto !important;
|
||||
.customer-selector-toolbar-row :deep(.quick-search-input) {
|
||||
width: 280px;
|
||||
max-width: 280px;
|
||||
flex: 0 0 280px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user