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) }} - + 编辑 删除 @@ -451,7 +434,7 @@ const canDeleteRow = (row) => { { - - - - - - - - - - @@ -565,40 +538,7 @@ const canDeleteRow = (row) => { - - - - - {{ currentDetail.id }} - {{ currentDetail.contract_name }} - {{ currentDetail.type === 'franchise' ? '加盟合同' : '采购合同' }} - {{ currentDetail.customer_name || currentDetail.customer_id }} - {{ currentDetail.supplier_name || currentDetail.supplier_id }} - {{ currentDetail.employee_name || currentDetail.employee_id }} - - ¥{{ currentDetail.amount?.toLocaleString() }} - - - {{ currentDetail.status }} - - {{ formatDate(currentDetail.effective_date) }} - {{ formatDate(currentDetail.expiry_date) }} - - {{ currentDetail.contract_content || '无' }} - - - {{ currentDetail.remark || '无' }} - - - {{ currentDetail.responsible_user_name || currentDetail.responsible_user_id || '无' }} - - - - - 关闭 - { const d = currentDetail; closeDetail(); editContract(d) })()">编辑 - - + @@ -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) - - - {{ row.responsible_user_name || '-' }} - - + 编辑 @@ -364,11 +346,6 @@ const canOperate = computed(() => canUpdate.value || canDelete.value) - - - - - @@ -393,7 +370,6 @@ const canOperate = computed(() => canUpdate.value || canDelete.value) {{ [currentDetail.province, currentDetail.city, currentDetail.district].filter(Boolean).join(' ') }} {{ currentDetail.address || '无' }} - {{ currentDetail.responsible_user_name || '-' }} {{ currentDetail.remark || '无' }} diff --git a/src/components/service.vue b/src/components/service.vue index 87ebf56..a92062a 100644 --- a/src/components/service.vue +++ b/src/components/service.vue @@ -11,8 +11,8 @@ import { } from '../api/service' import { getSimpleCustomerList } from '../api/customer' import { getSimpleEmployeeList } from '../api/employee' -import { hasPermission } from '../store/user' -import { formatDateTime, formatDate } from '../utils/date' +import { hasPermission, getUserInfo } from '../store/user' +import { formatDate } from '../utils/date' const form = reactive({ customer_id: '', @@ -33,8 +33,6 @@ const showAddForm = ref(false) const isEditMode = ref(false) const currentServiceId = ref(null) const loading = ref(false) -const showDetailDialog = ref(false) -const currentDetail = ref(null) const customerList = ref([]) const employeeList = ref([]) @@ -86,11 +84,18 @@ watch(searchResults, () => { currentPage.value = 1 }) +const filteredResults = computed(() => { + if (!isOperationsManager.value) return searchResults.value + return searchResults.value.filter(row => { + return row.responsible_user_id != null && Number(row.responsible_user_id) === Number(currentUserId.value) + }) +}) + // 分页后的数据 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) }) // 获取售后列表 @@ -163,6 +168,14 @@ const resetForm = () => { // 显示新增表单 const addService = () => { resetForm() + // 默认选中当前用户为业务员(如果其员工信息在列表中) + const currentUser = getUserInfo() + if (currentUser?.name && employeeList.value.length > 0) { + const matched = employeeList.value.find(e => e.name === currentUser.name) + if (matched) { + form.employee_id = matched.id + } + } showAddForm.value = true showSearchResults.value = false } @@ -193,7 +206,7 @@ const saveService = async () => { const formData = { customer_id: form.customer_id, feedback: form.feedback, - employee_id: form.handle_status === '待处理' ? null : form.employee_id, + employee_id: form.employee_id || null, handle_method: form.handle_method, handle_status: form.handle_status, service_date: form.service_date, @@ -240,18 +253,6 @@ const cancelAdd = () => { showSearchResults.value = true } -// 双击行查看详情 -const handleRowDblClick = (row) => { - currentDetail.value = { ...row } - showDetailDialog.value = true -} - -// 关闭详情弹窗 -const closeDetail = () => { - showDetailDialog.value = false - currentDetail.value = null -} - // 页码变化 const handleCurrentChange = (val) => { currentPage.value = val @@ -263,6 +264,18 @@ const canUpdate = computed(() => hasPermission('after_sale', 'update')) const canDelete = computed(() => hasPermission('after_sale', 'delete')) const canOperate = computed(() => canUpdate.value || canDelete.value) +const isOperationsManager = computed(() => getUserInfo()?.departmentName === 'operations_manager') +const currentUserId = computed(() => getUserInfo()?.id) + +const canEditRow = (row) => { + if (!canUpdate.value) return false + return true +} +const canDeleteRow = (row) => { + if (!canDelete.value) return false + return true +} + @@ -315,8 +328,7 @@ const canOperate = computed(() => canUpdate.value || canDelete.value) 共找到 {{ searchResults.length }} 条记录 - + @@ -342,10 +354,10 @@ const canOperate = computed(() => canUpdate.value || canDelete.value) - + - 编辑 - 删除 + 编辑 + 删除 @@ -355,7 +367,7 @@ const canOperate = computed(() => canUpdate.value || canDelete.value) canUpdate.value || canDelete.value) - + @@ -415,36 +426,6 @@ const canOperate = computed(() => canUpdate.value || canDelete.value) - - - - {{ currentDetail.id }} - {{ formatDate(currentDetail.service_date) }} - {{ currentDetail.customer_name || currentDetail.customer_id }} - {{ currentDetail.employee_name || currentDetail.employee_id || '未分配' }} - - - {{ currentDetail.handle_status }} - - - {{ formatDateTime(currentDetail.created_at) }} - - {{ currentDetail.feedback }} - - - {{ currentDetail.handle_method || '暂无' }} - - - {{ currentDetail.remark || '无' }} - - - - - 关闭 - { const d = currentDetail; closeDetail(); editService(d) })()">编辑 - - - @@ -502,10 +483,6 @@ const canOperate = computed(() => canUpdate.value || canDelete.value) padding: 40px 0; } -.clickable-row { - cursor: pointer; -} - .pagination-container { display: flex; justify-content: center; @@ -513,15 +490,4 @@ const canOperate = computed(() => canUpdate.value || canDelete.value) padding-top: 15px; border-top: 1px solid #eee; } - -.detail-content { - padding: 10px 0; -} - -.content-text { - white-space: pre-wrap; - line-height: 1.6; - max-height: 120px; - overflow-y: auto; -}