From c77086ad2d7949ab36dd0c4e0b59907e672dd64f Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 18 九月 2026 15:04:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev_pro2.0' into dev_宁夏_九泓化工
---
src/views/crm/invoice/data.ts | 315 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 315 insertions(+), 0 deletions(-)
diff --git a/src/views/crm/invoice/data.ts b/src/views/crm/invoice/data.ts
new file mode 100644
index 0000000..c58ff5c
--- /dev/null
+++ b/src/views/crm/invoice/data.ts
@@ -0,0 +1,315 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+
+import { DICT_TYPE } from '@vben/constants';
+import { getDictOptions } from '@vben/hooks';
+import { useUserStore } from '@vben/stores';
+
+import { getContractSimpleList } from '#/api/crm/contract';
+import { getSimpleUserList } from '#/api/system/user';
+import CrmCustomerSelect from '#/components/crm-customer-select.vue';
+
+import { markRaw } from 'vue';
+
+/** 鏂板/淇敼鐨勮〃鍗� */
+export function useFormSchema(): VbenFormSchema[] {
+ const userStore = useUserStore();
+ return [
+ {
+ fieldName: 'id',
+ component: 'Input',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
+ },
+ {
+ fieldName: 'no',
+ label: '寮�绁ㄧ紪鍙�',
+ component: 'Input',
+ componentProps: {
+ placeholder: '淇濆瓨鏃惰嚜鍔ㄧ敓鎴�',
+ disabled: true,
+ },
+ },
+ {
+ fieldName: 'ownerUserId',
+ label: '璐熻矗浜�',
+ component: 'ApiSelect',
+ rules: 'required',
+ dependencies: {
+ triggerFields: ['id'],
+ disabled: (values) => !!values.id,
+ },
+ componentProps: {
+ api: getSimpleUserList,
+ labelField: 'nickname',
+ valueField: 'id',
+ placeholder: '璇烽�夋嫨璐熻矗浜�',
+ allowClear: true,
+ },
+ defaultValue: userStore.userInfo?.id,
+ },
+ {
+ fieldName: 'customerId',
+ label: '瀹㈡埛鍚嶇О',
+ component: markRaw(CrmCustomerSelect),
+ rules: 'required',
+ componentProps: (_values, form) => ({
+ placeholder: '璇烽�夋嫨瀹㈡埛',
+ onChange: () => {
+ form.setFieldValue('contractId', undefined);
+ form.setFieldValue('price', undefined);
+ },
+ }),
+ dependencies: {
+ triggerFields: ['id'],
+ disabled: (values) => !!values.id,
+ },
+ },
+ {
+ fieldName: 'contractId',
+ label: '鍚堝悓鍚嶇О',
+ component: 'Select',
+ rules: 'required',
+ dependencies: {
+ triggerFields: ['customerId'],
+ disabled: (values) => !values.customerId || !!values.id,
+ async componentProps(values, form) {
+ if (!values.customerId) {
+ return {
+ options: [],
+ placeholder: '璇峰厛閫夋嫨瀹㈡埛',
+ };
+ }
+ const contracts = await getContractSimpleList(values.customerId);
+ const approvedContracts = contracts.filter(
+ (item) => item.auditStatus === 20,
+ );
+ return {
+ options: approvedContracts.map((item) => {
+ const remain =
+ (item.totalPrice ?? 0) - (item.totalInvoicePrice ?? 0);
+ return {
+ label: `${item.name}锛埪�${item.totalPrice ?? 0}锛屽彲寮�绁� 楼${remain.toFixed(2)}锛塦,
+ value: item.id,
+ };
+ }),
+ placeholder: '璇烽�夋嫨鍚堝悓',
+ onChange: () => {
+ form.setFieldValue('price', undefined);
+ },
+ } as any;
+ },
+ },
+ },
+ {
+ fieldName: 'invoiceType',
+ label: '鍙戠エ绫诲瀷',
+ component: 'Select',
+ rules: 'required',
+ componentProps: {
+ options: getDictOptions(DICT_TYPE.CRM_INVOICE_TYPE, 'number'),
+ placeholder: '璇烽�夋嫨鍙戠エ绫诲瀷',
+ },
+ },
+ {
+ fieldName: 'invoiceNo',
+ label: '鍙戠エ鍙风爜',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ彂绁ㄥ彿鐮�',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'invoiceTitle',
+ label: '鍙戠エ鎶ご',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ彂绁ㄦ姮澶�',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'price',
+ label: '寮�绁ㄩ噾棰濓紙鍏冿級',
+ component: 'InputNumber',
+ rules: 'required',
+ componentProps: {
+ class: '!w-full',
+ placeholder: '璇疯緭鍏ュ紑绁ㄩ噾棰�',
+ min: 0,
+ precision: 2,
+ },
+ },
+ {
+ fieldName: 'invoiceTime',
+ label: '寮�绁ㄦ棩鏈�',
+ component: 'DatePicker',
+ rules: 'required',
+ componentProps: {
+ placeholder: '璇烽�夋嫨寮�绁ㄦ棩鏈�',
+ showTime: false,
+ valueFormat: 'YYYY-MM-DD',
+ format: 'YYYY-MM-DD',
+ },
+ },
+ {
+ fieldName: 'blobIds',
+ label: '鍙戠エ闄勪欢',
+ component: 'FileUpload',
+ componentProps: {
+ valueKey: 'id',
+ maxNumber: 10,
+ multiple: true,
+ accept: ['jpg', 'jpeg', 'png', 'pdf'],
+ helpText: '鏀寔jpg銆乯peg銆乸ng銆乸df鏍煎紡锛屽崟涓枃浠朵笉瓒呰繃50MB',
+ },
+ formItemClass: 'md:col-span-2',
+ },
+ {
+ fieldName: 'remark',
+ label: '澶囨敞',
+ component: 'Textarea',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ娉�',
+ rows: 4,
+ },
+ formItemClass: 'md:col-span-2',
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'no',
+ label: '寮�绁ㄧ紪鍙�',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ紑绁ㄧ紪鍙�',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'customerId',
+ label: '瀹㈡埛',
+ component: markRaw(CrmCustomerSelect),
+ componentProps: {
+ placeholder: '璇烽�夋嫨瀹㈡埛',
+ allowClear: true,
+ },
+ },
+ ];
+}
+
+export function useGridColumns(): VxeTableGridOptions['columns'] {
+ return [
+ {
+ title: '寮�绁ㄧ紪鍙�',
+ field: 'no',
+ minWidth: 160,
+ fixed: 'left',
+ slots: { default: 'no' },
+ },
+ {
+ title: '瀹㈡埛鍚嶇О',
+ field: 'customerName',
+ minWidth: 150,
+ slots: { default: 'customerName' },
+ },
+ {
+ title: '鍚堝悓缂栧彿',
+ field: 'contract',
+ minWidth: 160,
+ slots: { default: 'contractNo' },
+ },
+ {
+ title: '鍙戠エ绫诲瀷',
+ field: 'invoiceType',
+ minWidth: 120,
+ cellRender: {
+ name: 'CellDict',
+ props: { type: DICT_TYPE.CRM_INVOICE_TYPE },
+ },
+ },
+ {
+ title: '鍙戠エ鍙风爜',
+ field: 'invoiceNo',
+ minWidth: 150,
+ },
+ {
+ title: '寮�绁ㄩ噾棰濓紙鍏冿級',
+ field: 'price',
+ minWidth: 150,
+ formatter: 'formatAmount2',
+ },
+ {
+ title: '鍓╀綑鍙洖娆鹃噾棰濓紙鍚鎵逛腑锛�',
+ field: 'remainingInvoicePrice',
+ minWidth: 180,
+ formatter: 'formatAmount2',
+ },
+ {
+ title: '寮�绁ㄦ棩鏈�',
+ field: 'invoiceTime',
+ minWidth: 150,
+ formatter: 'formatDateTime',
+ },
+ {
+ title: '澶囨敞',
+ field: 'remark',
+ minWidth: 150,
+ },
+ {
+ title: '璐熻矗浜�',
+ field: 'ownerUserName',
+ minWidth: 150,
+ },
+ {
+ title: '鎵�灞為儴闂�',
+ field: 'ownerUserDeptName',
+ minWidth: 150,
+ },
+ {
+ title: '鏇存柊鏃堕棿',
+ field: 'updateTime',
+ minWidth: 150,
+ formatter: 'formatDateTime',
+ },
+ {
+ title: '鍒涘缓鏃堕棿',
+ field: 'createTime',
+ minWidth: 150,
+ formatter: 'formatDateTime',
+ },
+ {
+ title: '鍒涘缓浜�',
+ field: 'creatorName',
+ minWidth: 150,
+ },
+ {
+ title: '闄勪欢',
+ field: 'attachmentList',
+ minWidth: 100,
+ fixed: 'right',
+ slots: { default: 'attachment' },
+ },
+ {
+ title: '瀹℃壒鐘舵��',
+ field: 'auditStatus',
+ minWidth: 100,
+ fixed: 'right',
+ slots: { default: 'auditStatus' },
+ },
+ {
+ title: '鎿嶄綔',
+ field: 'actions',
+ minWidth: 200,
+ fixed: 'right',
+ slots: { default: 'actions' },
+ },
+ ];
+}
--
Gitblit v1.9.3