From ccc9cb717a71eda7b42415e681a482f831570179 Mon Sep 17 00:00:00 2001 From: ChoChoX Date: Fri, 26 Jun 2026 09:44:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=A4=A7=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=9A=84=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=E5=92=8C?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/contract.vue | 121 ++++++------------------------------ src/components/customer.vue | 32 ++-------- src/components/service.vue | 108 +++++++++++--------------------- 3 files changed, 61 insertions(+), 200 deletions(-) diff --git a/src/components/contract.vue b/src/components/contract.vue index 228dbb6..c128344 100644 --- a/src/components/contract.vue +++ b/src/components/contract.vue @@ -11,7 +11,6 @@ import { import { getSimpleCustomerList } from '../api/customer' import { getEmployeeList } from '../api/employee' import { getSimpleSupplierList } from '../api/suppliers' -import { getSimpleUserList } from '../api/user' import { formatDateTime, formatDate } from "../utils/date" import { hasPermission, getUserInfo } from '../store/user' @@ -24,19 +23,15 @@ const showSearchResults = ref(false) const showAddForm = ref(false) const isEditMode = ref(false) const currentContractId = ref(null) -const showDetailDialog = ref(false) -const currentDetail = ref(null) const customerList = ref([]) const employeeList = ref([]) const supplierList = ref([]) -const userList = ref([]) // 分页相关 const currentPage = ref(1) const pageSize = ref(10) // 采购经理只能操作采购合同,招商经理只能操作加盟合同(提前定义,供 form 初始化使用) -const isAdmin = computed(() => getUserInfo()?.departmentName === 'admin') const isProcurementManager = computed(() => getUserInfo()?.departmentName === 'procurement_manager') const isFranchiseManager = computed(() => getUserInfo()?.departmentName === 'franchise_manager') const getDefaultType = () => { @@ -56,8 +51,7 @@ const form = reactive({ expiry_date: '', amount: 0, status: '生效中', - remark: '', - responsible_user_id: '' + remark: '' }) onMounted(() => { @@ -71,10 +65,19 @@ watch(searchResults, () => { }) // 分页后的数据 +const filteredResults = computed(() => { + if (!isFranchiseManager.value && !isProcurementManager.value) return searchResults.value + return searchResults.value.filter(row => { + if (row.type === 'supply' && isProcurementManager.value) return true + if (row.type === 'franchise' && isFranchiseManager.value) return true + return false + }) +}) + const paginatedData = computed(() => { const start = (currentPage.value - 1) * pageSize.value const end = start + pageSize.value - return searchResults.value.slice(start, end) + return filteredResults.value.slice(start, end) }) // 页码变化 @@ -87,8 +90,7 @@ const fetchOptions = async () => { const results = await Promise.allSettled([ getSimpleCustomerList(null, { quiet: true }), getEmployeeList(null, { quiet: true }), - getSimpleSupplierList(null, { quiet: true }), - getSimpleUserList({ quiet: true }) + getSimpleSupplierList(null, { quiet: true }) ]) if (results[0].status === 'fulfilled') { const cRes = results[0].value @@ -102,10 +104,6 @@ const fetchOptions = async () => { const sRes = results[2].value supplierList.value = sRes?.data || [] } - if (results[3].status === 'fulfilled') { - const uRes = results[3].value - userList.value = uRes?.data || [] - } } // 获取合同列表 @@ -163,6 +161,7 @@ const resetSearch = () => { // 新增合同 const addContract = () => { resetForm() + form.employee_id = getUserInfo()?.id || '' showAddForm.value = true showSearchResults.value = false } @@ -182,8 +181,7 @@ const editContract = (row) => { expiry_date: row.expiry_date, amount: row.amount, status: row.status, - remark: row.remark, - responsible_user_id: row.responsible_user_id || '' + remark: row.remark }) showAddForm.value = true showSearchResults.value = false @@ -206,8 +204,7 @@ const saveContract = async () => { ...form, customer_id: form.customer_id || null, supplier_id: form.supplier_id || null, - employee_id: form.employee_id || null, - responsible_user_id: form.responsible_user_id || null + employee_id: form.employee_id || null } try { if (isEditMode.value) { @@ -261,25 +258,12 @@ const resetForm = () => { expiry_date: '', amount: 0, status: '生效中', - remark: '', - responsible_user_id: '' + remark: '' }) isEditMode.value = false currentContractId.value = null } -// 双击查看详情 -const showDetail = (row) => { - currentDetail.value = row - showDetailDialog.value = true -} - -// 关闭详情弹窗 -const closeDetail = () => { - showDetailDialog.value = false - currentDetail.value = null -} - // 状态样式 const getStatusType = (status) => { const map = { @@ -394,8 +378,7 @@ const canDeleteRow = (row) => { 共找到 {{ searchResults.length }} 条合同 - + @@ -438,7 +421,7 @@ const canDeleteRow = (row) => { {{ formatDate(row.expiry_date) }} - + @@ -656,27 +596,6 @@ const canDeleteRow = (row) => { padding: 40px 0; } -.clickable-row { - cursor: pointer; -} - -.detail-content { - padding: 10px 0; -} - -.amount-text { - font-weight: 600; - color: #e6a23c; - font-size: 16px; -} - -.content-text { - white-space: pre-wrap; - line-height: 1.6; - max-height: 120px; - overflow-y: auto; -} - .pagination-container { display: flex; justify-content: center; diff --git a/src/components/customer.vue b/src/components/customer.vue index 2fbdce6..be86cd4 100644 --- a/src/components/customer.vue +++ b/src/components/customer.vue @@ -10,10 +10,7 @@ import { updateCustomer, deleteCustomerAPI } from '../api/customer' -import { getSimpleUserList } from '../api/user' -import { hasPermission, getUserInfo } from '../store/user' - -const isAdmin = computed(() => getUserInfo()?.departmentName === 'admin') +import { hasPermission } from '../store/user' const form = reactive({ id: '', @@ -22,8 +19,7 @@ const form = reactive({ region: [], address: '', email: '', - remark: '', - responsible_user_id: '' + remark: '' }) const search = ref('') @@ -38,7 +34,6 @@ let searchSeq = 0 const showDetailDialog = ref(false) const currentDetail = ref(null) const filterRegion = ref([]) -const userList = ref([]) // 分页相关 const currentPage = ref(1) @@ -64,12 +59,6 @@ const paginatedData = computed(() => { onMounted(() => { fetchData() - // 仅管理员可加载用户列表用于选择负责人 - if (isAdmin.value) { - getSimpleUserList({ quiet: true }).then(res => { - userList.value = res.data || [] - }).catch(() => {}) - } }) // 监听搜索结果变化,重置页码 @@ -124,7 +113,6 @@ const resetForm = () => { form.address = '' form.email = '' form.remark = '' - form.responsible_user_id = '' isEditMode.value = false currentCustomerId.value = null } @@ -150,7 +138,6 @@ const editCustomer = (row) => { form.address = row.address form.email = row.email form.remark = row.remark - form.responsible_user_id = row.responsible_user_id || '' showAddForm.value = true showSearchResults.value = false } @@ -164,8 +151,7 @@ const saveCustomer = async () => { district: CodeToText[form.region[2]] || '', address: form.address, email: form.email, - remark: form.remark, - responsible_user_id: form.responsible_user_id !== '' ? form.responsible_user_id : null + remark: form.remark } try { if (isEditMode.value) { @@ -306,11 +292,7 @@ const canOperate = computed(() => canUpdate.value || canDelete.value) - - - +