diff --git a/src/api/customer/customer.ts b/src/api/customer/customer.ts new file mode 100644 index 0000000..cb41f8c --- /dev/null +++ b/src/api/customer/customer.ts @@ -0,0 +1,60 @@ +/** + * 溯源供方请求接口 + */ +import request from '../index' +import type { ICustomerQuery } from '@/views/customer/customerInfo/customer_interface' +const prefix = '/meter' + +// 列表查询 +export function getCustomerList(data: ICustomerQuery) { + return request({ + url: `${prefix}/supplier/listPage?offset=${data.offset}&limit=${data.limit}`, + method: 'post', + data, + }) +} + +// 数据删除 +export function deleteCustomer(data: { id: string }) { + return request({ + url: `${prefix}/supplier/delete`, + method: 'post', + data, + }) +} + +// 查看详情 +export function getCustomerDetail(data: { id: string }) { + return request({ + url: `${prefix}/supplier/detail`, + method: 'post', + data, + }) +} + +// 提交数据 +export function addCustomer(data: object) { + return request({ + url: '/meter/supplier/submit', + method: 'post', + data, + }) +} +// 更新数据 +export function updateCustomer(data: object) { + return request({ + url: `${prefix}/supplier/update`, + method: 'post', + data, + }) +} + +// 导出列表 +export function exportCustomerList(data: Omit) { + return request({ + url: `${prefix}/supplier/listExport`, + method: 'post', + responseType: 'blob', + data, + }) +} diff --git a/src/api/customer/customer.ts b/src/api/customer/customer.ts new file mode 100644 index 0000000..cb41f8c --- /dev/null +++ b/src/api/customer/customer.ts @@ -0,0 +1,60 @@ +/** + * 溯源供方请求接口 + */ +import request from '../index' +import type { ICustomerQuery } from '@/views/customer/customerInfo/customer_interface' +const prefix = '/meter' + +// 列表查询 +export function getCustomerList(data: ICustomerQuery) { + return request({ + url: `${prefix}/supplier/listPage?offset=${data.offset}&limit=${data.limit}`, + method: 'post', + data, + }) +} + +// 数据删除 +export function deleteCustomer(data: { id: string }) { + return request({ + url: `${prefix}/supplier/delete`, + method: 'post', + data, + }) +} + +// 查看详情 +export function getCustomerDetail(data: { id: string }) { + return request({ + url: `${prefix}/supplier/detail`, + method: 'post', + data, + }) +} + +// 提交数据 +export function addCustomer(data: object) { + return request({ + url: '/meter/supplier/submit', + method: 'post', + data, + }) +} +// 更新数据 +export function updateCustomer(data: object) { + return request({ + url: `${prefix}/supplier/update`, + method: 'post', + data, + }) +} + +// 导出列表 +export function exportCustomerList(data: Omit) { + return request({ + url: `${prefix}/supplier/listExport`, + method: 'post', + responseType: 'blob', + data, + }) +} diff --git a/src/router/modules/customer.ts b/src/router/modules/customer.ts new file mode 100644 index 0000000..fe11b9d --- /dev/null +++ b/src/router/modules/customer.ts @@ -0,0 +1,123 @@ +import type { Route } from '@/global' + +const Layout = () => import('@/layouts/index.vue') + +const routes: Route.recordRaw[] = [ + { + path: '/customer', + component: Layout, + redirect: '/customer/bench', + name: 'CustomerBench', + meta: { + title: '工作台', + icon: 'ep:key', + auth: '/customer/bench', + }, + children: [ + { + path: 'bench', + name: 'CustomerBenchPage', + component: () => import('@/views/measure/bench/bench.vue'), + meta: { + title: '工作台', + auth: '/customer/bench', + sidebar: false, + breadcrumb: true, + activeMenu: '/customer', + }, + }, + ], + }, + { + path: '/sample', + component: Layout, + redirect: '/sample/list', + name: 'File', + meta: { + title: '样品库', + icon: 'ep:key', + auth: '/sample', + }, + children: [ + { + path: 'list', + name: 'SampleList', + component: () => import('@/views/measure/file/quality.vue'), + meta: { + title: '样品列表', + icon: 'ep:key', + auth: '/sample/list', + }, + }, + { + path: 'overtime', + name: 'OvertimeSample', + component: () => import('@/views/measure/file/rules.vue'), + meta: { + title: '到期样品', + icon: 'ep:key', + auth: '/sample/overtime', + }, + }, + ], + }, + { + path: '/customerManage', + component: Layout, + redirect: '/customerManage/list', + name: 'MeasureSource', + meta: { + title: '客户管理', + icon: 'ep:key', + auth: '/customer/manage', + }, + children: [ + { + path: 'list', + name: 'CustomerList', + component: () => import('@/views/customer/customerInfo/customerList.vue'), + meta: { + title: '客户列表', + icon: 'ep:key', + auth: '/customer/list', + }, + }, + { + path: ':type/:id?', + name: 'CustomerDetail', + component: () => import('@/views/measure/source/listAdd.vue'), + meta: { + title: '客户详情', + icon: 'ep:key', + sidebar: false, + breadcrumb: true, + activeMenu: '/source/list', + }, + }, + { + path: 'advice', + name: 'CustomerAdvice', + component: () => import('@/views/measure/source/approve.vue'), + meta: { + title: '客户关系', + icon: 'ep:key', + auth: '/customer/advice', + }, + }, + { + path: 'advice/:type/:id?', + name: 'CustomerAdviceDetail', + component: () => import('@/views/measure/source/components/sourceApprovalDetail.vue'), + meta: { + title: '客户关系详情', + icon: 'ep:key', + sidebar: false, + breadcrumb: true, + activeMenu: '/source/approve', + }, + }, + ], + }, +] + +export default routes diff --git a/src/api/customer/customer.ts b/src/api/customer/customer.ts new file mode 100644 index 0000000..cb41f8c --- /dev/null +++ b/src/api/customer/customer.ts @@ -0,0 +1,60 @@ +/** + * 溯源供方请求接口 + */ +import request from '../index' +import type { ICustomerQuery } from '@/views/customer/customerInfo/customer_interface' +const prefix = '/meter' + +// 列表查询 +export function getCustomerList(data: ICustomerQuery) { + return request({ + url: `${prefix}/supplier/listPage?offset=${data.offset}&limit=${data.limit}`, + method: 'post', + data, + }) +} + +// 数据删除 +export function deleteCustomer(data: { id: string }) { + return request({ + url: `${prefix}/supplier/delete`, + method: 'post', + data, + }) +} + +// 查看详情 +export function getCustomerDetail(data: { id: string }) { + return request({ + url: `${prefix}/supplier/detail`, + method: 'post', + data, + }) +} + +// 提交数据 +export function addCustomer(data: object) { + return request({ + url: '/meter/supplier/submit', + method: 'post', + data, + }) +} +// 更新数据 +export function updateCustomer(data: object) { + return request({ + url: `${prefix}/supplier/update`, + method: 'post', + data, + }) +} + +// 导出列表 +export function exportCustomerList(data: Omit) { + return request({ + url: `${prefix}/supplier/listExport`, + method: 'post', + responseType: 'blob', + data, + }) +} diff --git a/src/router/modules/customer.ts b/src/router/modules/customer.ts new file mode 100644 index 0000000..fe11b9d --- /dev/null +++ b/src/router/modules/customer.ts @@ -0,0 +1,123 @@ +import type { Route } from '@/global' + +const Layout = () => import('@/layouts/index.vue') + +const routes: Route.recordRaw[] = [ + { + path: '/customer', + component: Layout, + redirect: '/customer/bench', + name: 'CustomerBench', + meta: { + title: '工作台', + icon: 'ep:key', + auth: '/customer/bench', + }, + children: [ + { + path: 'bench', + name: 'CustomerBenchPage', + component: () => import('@/views/measure/bench/bench.vue'), + meta: { + title: '工作台', + auth: '/customer/bench', + sidebar: false, + breadcrumb: true, + activeMenu: '/customer', + }, + }, + ], + }, + { + path: '/sample', + component: Layout, + redirect: '/sample/list', + name: 'File', + meta: { + title: '样品库', + icon: 'ep:key', + auth: '/sample', + }, + children: [ + { + path: 'list', + name: 'SampleList', + component: () => import('@/views/measure/file/quality.vue'), + meta: { + title: '样品列表', + icon: 'ep:key', + auth: '/sample/list', + }, + }, + { + path: 'overtime', + name: 'OvertimeSample', + component: () => import('@/views/measure/file/rules.vue'), + meta: { + title: '到期样品', + icon: 'ep:key', + auth: '/sample/overtime', + }, + }, + ], + }, + { + path: '/customerManage', + component: Layout, + redirect: '/customerManage/list', + name: 'MeasureSource', + meta: { + title: '客户管理', + icon: 'ep:key', + auth: '/customer/manage', + }, + children: [ + { + path: 'list', + name: 'CustomerList', + component: () => import('@/views/customer/customerInfo/customerList.vue'), + meta: { + title: '客户列表', + icon: 'ep:key', + auth: '/customer/list', + }, + }, + { + path: ':type/:id?', + name: 'CustomerDetail', + component: () => import('@/views/measure/source/listAdd.vue'), + meta: { + title: '客户详情', + icon: 'ep:key', + sidebar: false, + breadcrumb: true, + activeMenu: '/source/list', + }, + }, + { + path: 'advice', + name: 'CustomerAdvice', + component: () => import('@/views/measure/source/approve.vue'), + meta: { + title: '客户关系', + icon: 'ep:key', + auth: '/customer/advice', + }, + }, + { + path: 'advice/:type/:id?', + name: 'CustomerAdviceDetail', + component: () => import('@/views/measure/source/components/sourceApprovalDetail.vue'), + meta: { + title: '客户关系详情', + icon: 'ep:key', + sidebar: false, + breadcrumb: true, + activeMenu: '/source/approve', + }, + }, + ], + }, +] + +export default routes diff --git a/src/router/modules/measure.ts b/src/router/modules/measure.ts index 73a7470..855c6fa 100644 --- a/src/router/modules/measure.ts +++ b/src/router/modules/measure.ts @@ -4,10 +4,10 @@ const routes: Route.recordRaw[] = [ { - path: '/bench', + path: '/measure', component: Layout, - redirect: '/bench/list', - name: 'Bench', + redirect: '/measure/bench', + name: 'MeasureBench', meta: { title: '工作台', icon: 'ep:key', @@ -15,15 +15,15 @@ }, children: [ { - path: 'list', - name: 'BenchList', + path: 'bench', + name: 'MeasureBenchPage', component: () => import('@/views/measure/bench/bench.vue'), meta: { title: '工作台', auth: '/measure/bench', sidebar: false, breadcrumb: true, - activeMenu: '/bench', + activeMenu: '/measure', }, }, ], diff --git a/src/api/customer/customer.ts b/src/api/customer/customer.ts new file mode 100644 index 0000000..cb41f8c --- /dev/null +++ b/src/api/customer/customer.ts @@ -0,0 +1,60 @@ +/** + * 溯源供方请求接口 + */ +import request from '../index' +import type { ICustomerQuery } from '@/views/customer/customerInfo/customer_interface' +const prefix = '/meter' + +// 列表查询 +export function getCustomerList(data: ICustomerQuery) { + return request({ + url: `${prefix}/supplier/listPage?offset=${data.offset}&limit=${data.limit}`, + method: 'post', + data, + }) +} + +// 数据删除 +export function deleteCustomer(data: { id: string }) { + return request({ + url: `${prefix}/supplier/delete`, + method: 'post', + data, + }) +} + +// 查看详情 +export function getCustomerDetail(data: { id: string }) { + return request({ + url: `${prefix}/supplier/detail`, + method: 'post', + data, + }) +} + +// 提交数据 +export function addCustomer(data: object) { + return request({ + url: '/meter/supplier/submit', + method: 'post', + data, + }) +} +// 更新数据 +export function updateCustomer(data: object) { + return request({ + url: `${prefix}/supplier/update`, + method: 'post', + data, + }) +} + +// 导出列表 +export function exportCustomerList(data: Omit) { + return request({ + url: `${prefix}/supplier/listExport`, + method: 'post', + responseType: 'blob', + data, + }) +} diff --git a/src/router/modules/customer.ts b/src/router/modules/customer.ts new file mode 100644 index 0000000..fe11b9d --- /dev/null +++ b/src/router/modules/customer.ts @@ -0,0 +1,123 @@ +import type { Route } from '@/global' + +const Layout = () => import('@/layouts/index.vue') + +const routes: Route.recordRaw[] = [ + { + path: '/customer', + component: Layout, + redirect: '/customer/bench', + name: 'CustomerBench', + meta: { + title: '工作台', + icon: 'ep:key', + auth: '/customer/bench', + }, + children: [ + { + path: 'bench', + name: 'CustomerBenchPage', + component: () => import('@/views/measure/bench/bench.vue'), + meta: { + title: '工作台', + auth: '/customer/bench', + sidebar: false, + breadcrumb: true, + activeMenu: '/customer', + }, + }, + ], + }, + { + path: '/sample', + component: Layout, + redirect: '/sample/list', + name: 'File', + meta: { + title: '样品库', + icon: 'ep:key', + auth: '/sample', + }, + children: [ + { + path: 'list', + name: 'SampleList', + component: () => import('@/views/measure/file/quality.vue'), + meta: { + title: '样品列表', + icon: 'ep:key', + auth: '/sample/list', + }, + }, + { + path: 'overtime', + name: 'OvertimeSample', + component: () => import('@/views/measure/file/rules.vue'), + meta: { + title: '到期样品', + icon: 'ep:key', + auth: '/sample/overtime', + }, + }, + ], + }, + { + path: '/customerManage', + component: Layout, + redirect: '/customerManage/list', + name: 'MeasureSource', + meta: { + title: '客户管理', + icon: 'ep:key', + auth: '/customer/manage', + }, + children: [ + { + path: 'list', + name: 'CustomerList', + component: () => import('@/views/customer/customerInfo/customerList.vue'), + meta: { + title: '客户列表', + icon: 'ep:key', + auth: '/customer/list', + }, + }, + { + path: ':type/:id?', + name: 'CustomerDetail', + component: () => import('@/views/measure/source/listAdd.vue'), + meta: { + title: '客户详情', + icon: 'ep:key', + sidebar: false, + breadcrumb: true, + activeMenu: '/source/list', + }, + }, + { + path: 'advice', + name: 'CustomerAdvice', + component: () => import('@/views/measure/source/approve.vue'), + meta: { + title: '客户关系', + icon: 'ep:key', + auth: '/customer/advice', + }, + }, + { + path: 'advice/:type/:id?', + name: 'CustomerAdviceDetail', + component: () => import('@/views/measure/source/components/sourceApprovalDetail.vue'), + meta: { + title: '客户关系详情', + icon: 'ep:key', + sidebar: false, + breadcrumb: true, + activeMenu: '/source/approve', + }, + }, + ], + }, +] + +export default routes diff --git a/src/router/modules/measure.ts b/src/router/modules/measure.ts index 73a7470..855c6fa 100644 --- a/src/router/modules/measure.ts +++ b/src/router/modules/measure.ts @@ -4,10 +4,10 @@ const routes: Route.recordRaw[] = [ { - path: '/bench', + path: '/measure', component: Layout, - redirect: '/bench/list', - name: 'Bench', + redirect: '/measure/bench', + name: 'MeasureBench', meta: { title: '工作台', icon: 'ep:key', @@ -15,15 +15,15 @@ }, children: [ { - path: 'list', - name: 'BenchList', + path: 'bench', + name: 'MeasureBenchPage', component: () => import('@/views/measure/bench/bench.vue'), meta: { title: '工作台', auth: '/measure/bench', sidebar: false, breadcrumb: true, - activeMenu: '/bench', + activeMenu: '/measure', }, }, ], diff --git a/src/views/customer/customerInfo/customerList.vue b/src/views/customer/customerInfo/customerList.vue index 5b84610..c5ff34e 100644 --- a/src/views/customer/customerInfo/customerList.vue +++ b/src/views/customer/customerInfo/customerList.vue @@ -4,9 +4,11 @@ import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import type { ICustomer, ICustomerQuery } from './customer_interface' import type { TableColumn } from '@/components/NormalTable/table_interface' -// import { exportSourceList, getSoucreList, getSoucreListDelete } from '@/api/measure/source' import { printJSON } from '@/utils/printUtils' import { exportFile } from '@/utils/exportUtils' +import { deleteCustomer, exportCustomerList, getCustomerList } from '@/api/customer/customer' +const { proxy } = getCurrentInstance() as any +const $router = useRouter() // 查询条件 const listQuery: Ref = ref({ bussinessSize: '', // 业务规模 @@ -16,109 +18,62 @@ offset: 1, limit: 20, }) -// 控制是否显示新增页面 -const show = ref(true) -// 表格数据 -const list = ref([]) -const { proxy } = getCurrentInstance() as any -// 总数 -const total = ref(0) // 表头 const columns = ref([ - { - text: '客户编号', - value: 'customerNo', - width: '160', - align: 'center', - }, - { - text: '客户名称', - value: 'customerName', - width: '120', - align: 'center', - }, - { - text: '公司规模', - value: 'businessContent', - align: 'center', - }, - { - text: '业务规模', - value: 'businessScope', - align: 'center', - }, - { - text: '履约评级', - value: 'director', - align: 'center', - }, - { - text: '整体评价', - value: 'mobile', - align: 'center', - }, - { - text: '公司地址', - value: 'briefName', - align: 'center', - }, - { - text: '创建时间', - value: 'createTime', - align: 'center', - width: '180px', - }, - { - text: '备注', - value: 'remark', - align: 'center', - }, + { text: '客户编号', value: 'customerNo', width: '160', align: 'center' }, + { text: '客户名称', value: 'customerName', width: '120', align: 'center' }, + { text: '公司规模', value: 'companySizeName', align: 'center' }, + { text: '业务规模', value: 'businessSizeName', align: 'center' }, + { text: '履约评级', value: 'gradeName', align: 'center' }, + { text: '整体评价', value: 'evaluationName', align: 'center' }, + { text: '公司地址', value: 'briefName', align: 'center' }, + { text: '创建时间', value: 'createTime', align: 'center', width: '180px' }, + { text: '备注', value: 'remark', align: 'center' }, ]) - +// 表格数据 +const list = ref([]) +// 总数 +const total = ref(0) +// 表格加载状态 +const loadingTable = ref(false) // 选中的内容 const checkoutList = ref([]) // 文件上传input const fileRef = ref() -// 点击按钮 -const buttonType = ref('') -const loadingTable = ref(false) -const fetchData = (isNowPage: boolean) => { +// 数据查询 +function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } - // getSoucreList(listQuery.value).then((response) => { - // list.value = response.data.rows.map((item: ICustomer) => { - // if (item.companyProvinceName && item.companyCityName) { - // item.briefName = `${item.companyProvinceName}/${item.companyCityName}` - // } - // else { - // item.briefName = item.companyProvinceName || item.companyCityName - // } - // return item - // }) - // total.value = parseInt(response.data.total) - loadingTable.value = false - // }) + getCustomerList(listQuery.value).then((response) => { + // 模拟数据 + response.data.rows = [{ bankAccount: '银行账户', bankAccountNumber: '银行账号', bankName: '工商银行', briefName: '京东', businessContent: '电商', businessScope: 'test1', grade: '1', gradeName: '优质', companySize: '1', companySizeName: '优质', businessSize: '1', businessSizeName: '小微企业', evaluation: '1', evaluationName: '优质', companyAddress: '五棵松', companyAreaName: '海淀区', companyCityName: '北京市', companyCountryName: '中国', companyProvinceName: '北京', companyArea: '110007', companyCity: '110000', companyCountry: 'CN', companyProvince: '100000', createTime: '2022-11-29 21:14:50', director: '刘强东', fax: 'test1', id: '1597579843411234817', invoiceAddress: '五棵松', invoiceAreaName: '海淀区', invoiceCityName: '北京市', invoiceCountryName: '中国', invoiceProvinceName: '北京', invoiceyArea: '110007', invoiceCity: '110000', invoiceCountry: 'CN', invoiceProvince: '100000', mailbox: 'test1', minioFileName: 'test', mobile: 'test', phone: '950618', postalCode: 'test', remark: 'test', customerName: '京东集团', customerNo: 'sygf202211290001', taxNumber: 'test', updateTime: '2023-01-10 09:56:57', website: 'test' }] + list.value = response.data.rows.map((item: ICustomer) => { + if (item.companyProvinceName && item.companyCityName) { + item.briefName = `${item.companyProvinceName}/${item.companyCityName}` + } + else { + item.briefName = item.companyProvinceName || item.companyCityName + } + return item + }) + total.value = parseInt(response.data.total) + loadingTable.value = false + }) } -fetchData(true) // 多选发生改变时 -const handleSelectionChange = (e: any) => { +function handleSelectionChange(e: any) { checkoutList.value = e.map((item: { id: string }) => item.id) } -// 点击编辑id和删除row类型 -interface rowReturn { - id: string - customerName: string -} -const $router = useRouter() + // 点击编辑/详情 -const handleEdit = (row: rowReturn, pageType: 'edit' | 'detail') => { - $router.push(`/source/${pageType}/${row.id}`) +const handleEdit = (row: ICustomer, pageType: 'edit' | 'detail') => { + $router.push(`/customer/${pageType}/${row.id}`) } // 点击删除 -const handleDelete = (index: string, row: rowReturn) => { +const handleDelete = (index: string, row: ICustomer) => { ElMessageBox.confirm( `确认删除${row.customerName}吗?`, '提示', @@ -129,15 +84,15 @@ }, ) .then(() => { - // getSoucreListDelete({ id: row.id as string }).then((res) => { - // if (res.code === 200) { - // ElMessage({ - // type: 'success', - // message: '删除成功', - // }) - // fetchData(true) - // } - // }) + deleteCustomer({ id: row.id }).then((res) => { + if (res.code === 200) { + ElMessage({ + type: 'success', + message: '删除成功', + }) + fetchData(true) + } + }) }) } // 点击搜索 @@ -158,6 +113,7 @@ // 上传文件/批量导入 const onFileChange = (event: any) => { + // todo: 校验文件类型,调用上传接口 if (event.target.files[0].type === 'application/pdf') { if (event.target.files?.length !== 0) { // 创建formdata对象 @@ -188,15 +144,15 @@ fetchData(true) } -// 批量导入 +// 点击批量导入 const uploadAll = () => { - // todo: 批量导入 fileRef.value.click() } // 添加客户 const add = () => { $router.push('/customer/add') } +// 导出 const exportAll = () => { const loading = ElLoading.service({ lock: true, @@ -205,15 +161,16 @@ }) if (list.value.length > 0) { const params = { - customerNo: '', // 业务内容 - customerName: '', // 客户名称 - businessContent: '', // 客户编号 + bussinessSize: listQuery.value.bussinessSize, // 业务规模 + customerName: listQuery.value.customerName, // 公司名称 + customerNo: listQuery.value.customerNo, // 客户编号 + grade: listQuery.value.grade, // 履约评级 ids: checkoutList.value, } - // exportSourceList(params).then((res) => { - // const blob = new Blob([res.data]) - // exportFile(blob, '客户列表.xlsx') - // }) + exportCustomerList(params).then((res) => { + const blob = new Blob([res.data]) + exportFile(blob, '客户列表.xlsx') + }) } else { ElMessage.warning('无数据可导出数据') @@ -241,84 +198,81 @@ ElMessage.warning('无可打印内容') } } + +fetchData(true)