From c7b4b9a2f4c0f05aeb60a9e3f5fba5d9a3676f3f Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期一, 18 八月 2025 16:22:42 +0800 Subject: [PATCH] 中强恒兴设备管理页面添加 --- src/views/salesManagement/customerManagement/index.vue | 423 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 423 insertions(+), 0 deletions(-) diff --git a/src/views/salesManagement/customerManagement/index.vue b/src/views/salesManagement/customerManagement/index.vue new file mode 100644 index 0000000..131124b --- /dev/null +++ b/src/views/salesManagement/customerManagement/index.vue @@ -0,0 +1,423 @@ +<template> + <div class="app-container"> + <el-card class="box-card"> + <!-- 鎼滅储鍖哄煙 --> + <el-row :gutter="20" class="search-row"> + <el-col :span="6"> + <el-input + v-model="searchForm.name" + placeholder="璇疯緭鍏ュ鎴峰悕绉�" + clearable + @keyup.enter="handleSearch" + > + <template #prefix> + <el-icon><Search /></el-icon> + </template> + </el-input> + </el-col> + <el-col :span="6"> + <el-select v-model="searchForm.region" placeholder="璇烽�夋嫨鍖哄煙" clearable> + <el-option label="鍗庝笢鍖�" value="鍗庝笢鍖�"></el-option> + <el-option label="鍗庡崡鍖�" value="鍗庡崡鍖�"></el-option> + <el-option label="鍗庡寳鍖�" value="鍗庡寳鍖�"></el-option> + <el-option label="瑗垮崡鍖�" value="瑗垮崡鍖�"></el-option> + </el-select> + </el-col> + <el-col :span="6"> + <el-select v-model="searchForm.level" placeholder="璇烽�夋嫨瀹㈡埛绛夌骇" clearable> + <el-option label="VIP瀹㈡埛" value="VIP瀹㈡埛"></el-option> + <el-option label="閲嶈瀹㈡埛" value="閲嶈瀹㈡埛"></el-option> + <el-option label="鏅�氬鎴�" value="鏅�氬鎴�"></el-option> + </el-select> + </el-col> + <el-col :span="6"> + <el-button type="primary" @click="handleSearch">鎼滅储</el-button> + <el-button @click="resetSearch">閲嶇疆</el-button> + <el-button style="float: right;" type="primary" @click="handleAdd"> + 鏂板瀹㈡埛 + </el-button> + </el-col> + </el-row> + + <!-- 瀹㈡埛鍒楄〃 --> + <el-table + :data="filteredList" + style="width: 100%" + v-loading="loading" + border + stripe + height="calc(100vh - 22em)" + > + <el-table-column prop="id" label="ID" width="80" align="center"/> + <el-table-column prop="name" label="瀹㈡埛鍚嶇О" width="150" /> + <el-table-column prop="contactPerson" label="鑱旂郴浜�" width="100" /> + <el-table-column prop="phone" label="鑱旂郴鐢佃瘽" width="140" /> + <el-table-column prop="email" label="閭" /> + <el-table-column prop="region" label="鍖哄煙" width="100" /> + <el-table-column prop="level" label="瀹㈡埛绛夌骇" width="100"> + <template #default="scope"> + <el-tag :type="getLevelType(scope.row.level)"> + {{ scope.row.level }} + </el-tag> + </template> + </el-table-column> + <el-table-column prop="salesperson" label="璐熻矗涓氬姟鍛�" width="120" /> + <el-table-column prop="status" label="鐘舵��" width="80"> + <template #default="scope"> + <el-tag :type="getStatusType(scope.row.status)"> + {{ scope.row.status }} + </el-tag> + </template> + </el-table-column> + <el-table-column label="鎿嶄綔" width="200" fixed="right" align="center"> + <template #default="scope"> + <el-button link type="primary" @click="handleEdit(scope.row)">缂栬緫</el-button> + <el-button link type="primary" @click="handleAllocation(scope.row)">鍒嗛厤</el-button> + <el-button link type="danger" @click="handleDelete(scope.row)">鍒犻櫎</el-button> + </template> + </el-table-column> + </el-table> + + <!-- 鍒嗛〉 --> + <pagination + :total="pagination.total" + layout="total, sizes, prev, pager, next, jumper" + :page="pagination.currentPage" + :limit="pagination.pageSize" + @pagination="handleCurrentChange" + /> + </el-card> + + <!-- 鏂板/缂栬緫瀵硅瘽妗� --> + <el-dialog v-model="dialogVisible" :title="dialogTitle" width="600px"> + <el-form :model="form" :rules="rules" ref="formRef" label-width="100px"> + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="瀹㈡埛鍚嶇О" prop="name"> + <el-input v-model="form.name" placeholder="璇疯緭鍏ュ鎴峰悕绉�"></el-input> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鑱旂郴浜�" prop="contactPerson"> + <el-input v-model="form.contactPerson" placeholder="璇疯緭鍏ヨ仈绯讳汉"></el-input> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="鑱旂郴鐢佃瘽" prop="phone"> + <el-input v-model="form.phone" placeholder="璇疯緭鍏ヨ仈绯荤數璇�"></el-input> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="閭" prop="email"> + <el-input v-model="form.email" placeholder="璇疯緭鍏ラ偖绠�"></el-input> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="鍖哄煙" prop="region"> + <el-select v-model="form.region" placeholder="璇烽�夋嫨鍖哄煙" style="width: 100%"> + <el-option label="鍗庝笢鍖�" value="鍗庝笢鍖�"></el-option> + <el-option label="鍗庡崡鍖�" value="鍗庡崡鍖�"></el-option> + <el-option label="鍗庡寳鍖�" value="鍗庡寳鍖�"></el-option> + <el-option label="瑗垮崡鍖�" value="瑗垮崡鍖�"></el-option> + </el-select> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="瀹㈡埛绛夌骇" prop="level"> + <el-select v-model="form.level" placeholder="璇烽�夋嫨瀹㈡埛绛夌骇" style="width: 100%"> + <el-option label="VIP瀹㈡埛" value="VIP瀹㈡埛"></el-option> + <el-option label="閲嶈瀹㈡埛" value="閲嶈瀹㈡埛"></el-option> + <el-option label="鏅�氬鎴�" value="鏅�氬鎴�"></el-option> + </el-select> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="璐熻矗涓氬姟鍛�" prop="salesperson"> + <el-select v-model="form.salesperson" placeholder="璇烽�夋嫨涓氬姟鍛�" style="width: 100%"> + <el-option label="寮犱笁" value="寮犱笁"></el-option> + <el-option label="鏉庡洓" value="鏉庡洓"></el-option> + <el-option label="鐜嬩簲" value="鐜嬩簲"></el-option> + </el-select> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鐘舵��" prop="status"> + <el-select v-model="form.status" placeholder="璇烽�夋嫨鐘舵��" style="width: 100%"> + <el-option label="娲昏穬" value="娲昏穬"></el-option> + <el-option label="娼滃湪" value="娼滃湪"></el-option> + <el-option label="娴佸け" value="娴佸け"></el-option> + </el-select> + </el-form-item> + </el-col> + </el-row> + </el-form> + <template #footer> + <div class="dialog-footer"> + <el-button @click="dialogVisible = false">鍙� 娑�</el-button> + <el-button type="primary" @click="handleSubmit">纭� 瀹�</el-button> + </div> + </template> + </el-dialog> + + <!-- 瀹㈡埛鍒嗛厤瀵硅瘽妗� --> + <el-dialog v-model="allocationDialogVisible" title="瀹㈡埛鍒嗛厤" width="500px"> + <el-form label-width="100px"> + <el-form-item label="瀹㈡埛鍚嶇О"> + <span>{{ currentCustomer.name }}</span> + </el-form-item> + <el-form-item label="褰撳墠涓氬姟鍛�"> + <span>{{ currentCustomer.salesperson }}</span> + </el-form-item> + <el-form-item label="閲嶆柊鍒嗛厤"> + <el-select v-model="newSalesperson" placeholder="璇烽�夋嫨鏂颁笟鍔″憳" style="width: 100%"> + <el-option label="寮犱笁" value="寮犱笁"></el-option> + <el-option label="鏉庡洓" value="鏉庡洓"></el-option> + <el-option label="鐜嬩簲" value="鐜嬩簲"></el-option> + </el-select> + </el-form-item> + <el-form-item label="鍒嗛厤鍘熷洜"> + <el-input v-model="allocationReason" type="textarea" rows="3" placeholder="璇疯緭鍏ュ垎閰嶅師鍥�"></el-input> + </el-form-item> + </el-form> + <template #footer> + <div class="dialog-footer"> + <el-button @click="allocationDialogVisible = false">鍙� 娑�</el-button> + <el-button type="primary" @click="saveAllocation">纭� 瀹�</el-button> + </div> + </template> + </el-dialog> + </div> +</template> + +<script setup> +import { ref, reactive, computed } from 'vue' +import { ElMessage, ElMessageBox } from 'element-plus' +import { Plus, Search } from '@element-plus/icons-vue' +import Pagination from '@/components/PIMTable/Pagination.vue' + +// 鍝嶅簲寮忔暟鎹� +const loading = ref(false) +const searchForm = reactive({ + name: '', + region: '', + level: '' +}) + +const customerList = ref([ + { + id: 1, + name: '涓婃捣绉戞妧鏈夐檺鍏徃', + contactPerson: '寮犵粡鐞�', + phone: '021-12345678', + email: 'zhang@shanghai-tech.com', + region: '鍗庝笢鍖�', + level: 'VIP瀹㈡埛', + salesperson: '寮犱笁', + status: '娲昏穬' + }, + { + id: 2, + name: '娣卞湷鐢靛瓙鏈夐檺鍏徃', + contactPerson: '鏉庢��', + phone: '0755-87654321', + email: 'li@shenzhen-elec.com', + region: '鍗庡崡鍖�', + level: '閲嶈瀹㈡埛', + salesperson: '鏉庡洓', + status: '娲昏穬' + }, + { + id: 3, + name: '鍖椾含璐告槗鍏徃', + contactPerson: '鐜嬬粡鐞�', + phone: '010-11223344', + email: 'wang@beijing-trade.com', + region: '鍗庡寳鍖�', + level: '鏅�氬鎴�', + salesperson: '鐜嬩簲', + status: '娼滃湪' + } +]) + +const pagination = reactive({ + total: 3, + currentPage: 1, + pageSize: 10 +}) + +const dialogVisible = ref(false) +const dialogTitle = ref('鏂板瀹㈡埛') +const form = reactive({ + name: '', + contactPerson: '', + phone: '', + email: '', + region: '', + level: '', + salesperson: '', + status: '娲昏穬' +}) + +const rules = { + name: [{ required: true, message: '璇疯緭鍏ュ鎴峰悕绉�', trigger: 'blur' }], + contactPerson: [{ required: true, message: '璇疯緭鍏ヨ仈绯讳汉', trigger: 'blur' }], + phone: [{ required: true, message: '璇疯緭鍏ヨ仈绯荤數璇�', trigger: 'blur' }], + email: [{ required: true, message: '璇疯緭鍏ラ偖绠�', trigger: 'blur' }], + region: [{ required: true, message: '璇烽�夋嫨鍖哄煙', trigger: 'change' }], + level: [{ required: true, message: '璇烽�夋嫨瀹㈡埛绛夌骇', trigger: 'change' }], + salesperson: [{ required: true, message: '璇烽�夋嫨涓氬姟鍛�', trigger: 'change' }], + status: [{ required: true, message: '璇烽�夋嫨鐘舵��', trigger: 'change' }] +} + +const isEdit = ref(false) +const editId = ref(null) +const allocationDialogVisible = ref(false) +const currentCustomer = ref({}) +const newSalesperson = ref('') +const allocationReason = ref('') +const formRef = ref() + +// 璁$畻灞炴�� +const filteredList = computed(() => { + let list = customerList.value + if (searchForm.name) { + list = list.filter(item => item.name.includes(searchForm.name)) + } + if (searchForm.region) { + list = list.filter(item => item.region === searchForm.region) + } + if (searchForm.level) { + list = list.filter(item => item.level === searchForm.level) + } + return list +}) + +// 鏂规硶 +const getLevelType = (level) => { + const levelMap = { + 'VIP瀹㈡埛': 'danger', + '閲嶈瀹㈡埛': 'warning', + '鏅�氬鎴�': 'info' + } + return levelMap[level] || 'info' +} + +const getStatusType = (status) => { + const statusMap = { + '娲昏穬': 'success', + '娼滃湪': 'warning', + '娴佸け': 'danger' + } + return statusMap[status] || 'info' +} + +const handleSearch = () => { + // 鎼滅储閫昏緫宸插湪computed涓鐞� +} + +const resetSearch = () => { + searchForm.name = '' + searchForm.region = '' + searchForm.level = '' +} + +const handleAdd = () => { + dialogTitle.value = '鏂板瀹㈡埛' + isEdit.value = false + form.name = '' + form.contactPerson = '' + form.phone = '' + form.email = '' + form.region = '' + form.level = '' + form.salesperson = '' + form.status = '娲昏穬' + dialogVisible.value = true +} + +const handleEdit = (row) => { + dialogTitle.value = '缂栬緫瀹㈡埛' + isEdit.value = true + editId.value = row.id + Object.assign(form, row) + dialogVisible.value = true +} + +const handleDelete = (row) => { + ElMessageBox.confirm('纭鍒犻櫎璇ュ鎴峰悧锛�', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).then(() => { + const index = customerList.value.findIndex(item => item.id === row.id) + if (index > -1) { + customerList.value.splice(index, 1) + pagination.total-- + ElMessage.success('鍒犻櫎鎴愬姛') + } + }) +} + +const handleAllocation = (row) => { + currentCustomer.value = row + newSalesperson.value = '' + allocationReason.value = '' + allocationDialogVisible.value = true +} + +const saveAllocation = () => { + if (!newSalesperson.value) { + ElMessage.warning('璇烽�夋嫨鏂颁笟鍔″憳') + return + } + + const index = customerList.value.findIndex(item => item.id === currentCustomer.value.id) + if (index > -1) { + customerList.value[index].salesperson = newSalesperson.value + ElMessage.success('瀹㈡埛鍒嗛厤鎴愬姛') + allocationDialogVisible.value = false + } +} + +const handleSubmit = () => { + formRef.value.validate((valid) => { + if (valid) { + if (isEdit.value) { + // 缂栬緫 + const index = customerList.value.findIndex(item => item.id === editId.value) + if (index > -1) { + customerList.value[index] = { ...form, id: editId.value } + ElMessage.success('缂栬緫鎴愬姛') + } + } else { + // 鏂板 + const newId = Math.max(...customerList.value.map(item => item.id)) + 1 + customerList.value.push({ + ...form, + id: newId + }) + pagination.total++ + ElMessage.success('鏂板鎴愬姛') + } + dialogVisible.value = false + } + }) +} + +const handleCurrentChange = (val) => { + pagination.currentPage = val.page + pagination.pageSize = val.limit +} +</script> + +<style scoped> +.search-row { + margin-bottom: 20px; +} +</style> -- Gitblit v1.9.3