From 534533425b15b183cea60fa162d9884e5d3c6243 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 13 十月 2026 17:55:50 +0800
Subject: [PATCH] Merge branch 'dev_海西州_北京同仁堂' into dev_海西州_惠牧
---
src/views/erp/finance/fixed-asset/data.ts | 389 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 389 insertions(+), 0 deletions(-)
diff --git a/src/views/erp/finance/fixed-asset/data.ts b/src/views/erp/finance/fixed-asset/data.ts
new file mode 100644
index 0000000..5de9461
--- /dev/null
+++ b/src/views/erp/finance/fixed-asset/data.ts
@@ -0,0 +1,389 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { FinFixedAssetApi } from '#/api/erp/finance/fixed-asset';
+
+import { DICT_TYPE } from '@vben/constants';
+import { getDictOptions } from '@vben/hooks';
+import { handleTree } from '@vben/utils';
+
+import { z } from '#/adapter/form';
+import { getSimpleDeptList } from '#/api/system/dept';
+import { getSimpleUserList } from '#/api/system/user';
+import { getRangePickerDefaultProps } from '#/utils';
+
+import dayjs from 'dayjs';
+
+/**
+ * 浣跨敤閮ㄩ棬涓嬫媺锛氱郴缁熼儴闂ㄦ爲锛坴alue = 閮ㄩ棬缂栧彿锛�
+ * 涓� CRM 缁熻椤电殑銆屽綊灞為儴闂ㄣ�嶅啓娉曚繚鎸佷竴鑷�
+ */
+function departmentSelectProps() {
+ return {
+ allowClear: true,
+ class: 'w-full',
+ api: async () => handleTree(await getSimpleDeptList()),
+ labelField: 'name',
+ valueField: 'id',
+ childrenField: 'children',
+ placeholder: '璇烽�夋嫨浣跨敤閮ㄩ棬',
+ treeDefaultExpandAll: true,
+ };
+}
+
+/**
+ * 淇濈浜轰笅鎷夛細绯荤粺鐢ㄦ埛鍒楄〃锛坴alue = 鐢ㄦ埛缂栧彿锛宭abel = 鏄电О锛�
+ * 涓� WMS 鍗曟嵁閲岄�夌敤鎴风殑鍐欐硶淇濇寔涓�鑷�
+ */
+function keeperSelectProps() {
+ return {
+ allowClear: true,
+ class: 'w-full',
+ api: getSimpleUserList,
+ labelField: 'nickname',
+ valueField: 'id',
+ placeholder: '璇烽�夋嫨淇濈浜�',
+ showSearch: true,
+ };
+}
+
+/** 璧勪骇鐘舵�侊細1鍦ㄧ敤 2闂茬疆 3缁翠慨涓� 4宸叉姤搴� */
+export const FIXED_ASSET_STATUS_IN_USE = 1;
+export const FIXED_ASSET_STATUS_IDLE = 2;
+export const FIXED_ASSET_STATUS_REPAIRING = 3;
+export const FIXED_ASSET_STATUS_SCRAPPED = 4;
+
+/** 鍙鎻愭姌鏃х殑鐘舵�侊紙宸叉姤搴熺殑璧勪骇涓嶅啀璁℃彁锛� */
+export const DEPRECIABLE_FIXED_ASSET_STATUS = [
+ FIXED_ASSET_STATUS_IN_USE,
+ FIXED_ASSET_STATUS_IDLE,
+ FIXED_ASSET_STATUS_REPAIRING,
+];
+
+/** 鏂板/淇敼鐨勮〃鍗� */
+export function useFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ component: 'Input',
+ fieldName: 'id',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
+ },
+ {
+ fieldName: 'assetCode',
+ label: '璧勪骇缂栫爜',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ヨ祫浜х紪鐮侊紝濡� GD2026100001',
+ allowClear: true,
+ },
+ rules: 'required',
+ },
+ {
+ fieldName: 'assetName',
+ label: '璧勪骇鍚嶇О',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ヨ祫浜у悕绉�',
+ allowClear: true,
+ },
+ rules: 'required',
+ },
+ {
+ fieldName: 'category',
+ label: '璧勪骇绫诲埆',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ヨ祫浜х被鍒紝濡� 鐢熶骇璁惧',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'specification',
+ label: '瑙勬牸鍨嬪彿',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ヨ鏍煎瀷鍙�',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'purchaseDate',
+ label: '璐疆鏃ユ湡',
+ component: 'DatePicker',
+ componentProps: {
+ placeholder: '璇烽�夋嫨璐疆鏃ユ湡',
+ showTime: false,
+ valueFormat: 'YYYY-MM-DD',
+ format: 'YYYY-MM-DD',
+ class: 'w-full',
+ },
+ rules: 'required',
+ defaultValue: dayjs().format('YYYY-MM-DD'),
+ },
+ {
+ fieldName: 'originalValue',
+ label: '璧勪骇鍘熷��',
+ component: 'InputNumber',
+ componentProps: {
+ class: 'w-full',
+ placeholder: '璇疯緭鍏ヨ祫浜у師鍊�',
+ min: 0,
+ precision: 2,
+ },
+ rules: z.number().min(0).default(0),
+ },
+ {
+ fieldName: 'usefulLife',
+ label: '浣跨敤骞撮檺锛堝勾锛�',
+ component: 'InputNumber',
+ componentProps: {
+ class: 'w-full',
+ placeholder: '璇疯緭鍏ヤ娇鐢ㄥ勾闄�',
+ min: 1,
+ precision: 0,
+ },
+ defaultValue: 10,
+ rules: z.number().min(1).default(10),
+ },
+ {
+ fieldName: 'residualRate',
+ label: '娈嬪�肩巼锛�%锛�',
+ component: 'InputNumber',
+ componentProps: {
+ class: 'w-full',
+ placeholder: '璇疯緭鍏ユ畫鍊肩巼',
+ min: 0,
+ max: 100,
+ precision: 2,
+ },
+ defaultValue: 5,
+ rules: z.number().min(0).max(100).default(5),
+ help: '鏈堟姌鏃ч =锛堝師鍊� 脳锛�1 - 娈嬪�肩巼锛夛級梅锛堜娇鐢ㄥ勾闄� 脳 12锛�',
+ },
+ {
+ fieldName: 'location',
+ label: '瀛樻斁鍦扮偣',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ瓨鏀惧湴鐐�',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'departmentId',
+ label: '浣跨敤閮ㄩ棬',
+ component: 'ApiTreeSelect',
+ componentProps: departmentSelectProps(),
+ },
+ {
+ fieldName: 'keeperId',
+ label: '淇濈浜�',
+ component: 'ApiSelect',
+ componentProps: keeperSelectProps(),
+ },
+ {
+ fieldName: 'status',
+ label: '璧勪骇鐘舵��',
+ component: 'RadioGroup',
+ componentProps: {
+ options: getDictOptions(
+ DICT_TYPE.FINANCE_FIXED_ASSET_STATUS,
+ 'number',
+ ),
+ buttonStyle: 'solid',
+ optionType: 'button',
+ },
+ defaultValue: FIXED_ASSET_STATUS_IN_USE,
+ rules: 'selectRequired',
+ },
+ {
+ fieldName: 'remark',
+ label: '澶囨敞',
+ component: 'Textarea',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ娉�',
+ rows: 3,
+ },
+ formItemClass: 'md:col-span-2',
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'assetCode',
+ label: '璧勪骇缂栫爜',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ヨ祫浜х紪鐮�',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'assetName',
+ label: '璧勪骇鍚嶇О',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ヨ祫浜у悕绉�',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'category',
+ label: '璧勪骇绫诲埆',
+ component: 'Input',
+ componentProps: {
+ placeholder: '璇疯緭鍏ヨ祫浜х被鍒�',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'purchaseDate',
+ label: '璐疆鏃ユ湡',
+ component: 'RangePicker',
+ componentProps: {
+ ...getRangePickerDefaultProps(),
+ showTime: false,
+ format: 'YYYY-MM-DD',
+ valueFormat: 'YYYY-MM-DD',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'departmentId',
+ label: '浣跨敤閮ㄩ棬',
+ component: 'ApiTreeSelect',
+ componentProps: departmentSelectProps(),
+ },
+ {
+ fieldName: 'keeperId',
+ label: '淇濈浜�',
+ component: 'ApiSelect',
+ componentProps: keeperSelectProps(),
+ },
+ {
+ fieldName: 'status',
+ label: '璧勪骇鐘舵��',
+ component: 'Select',
+ componentProps: {
+ options: getDictOptions(
+ DICT_TYPE.FINANCE_FIXED_ASSET_STATUS,
+ 'number',
+ ),
+ placeholder: '璇烽�夋嫨璧勪骇鐘舵��',
+ allowClear: true,
+ },
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勫瓧娈� */
+export function useGridColumns(): VxeTableGridOptions<FinFixedAssetApi.FixedAsset>['columns'] {
+ return [
+ { type: 'checkbox', width: 40 },
+ {
+ field: 'assetCode',
+ title: '璧勪骇缂栫爜',
+ minWidth: 150,
+ fixed: 'left',
+ },
+ {
+ field: 'assetName',
+ title: '璧勪骇鍚嶇О',
+ minWidth: 160,
+ },
+ {
+ field: 'category',
+ title: '璧勪骇绫诲埆',
+ minWidth: 120,
+ },
+ {
+ field: 'specification',
+ title: '瑙勬牸鍨嬪彿',
+ minWidth: 140,
+ showOverflow: 'tooltip',
+ },
+ {
+ field: 'purchaseDate',
+ title: '璐疆鏃ユ湡',
+ minWidth: 120,
+ formatter: 'formatDate',
+ },
+ {
+ field: 'originalValue',
+ title: '璧勪骇鍘熷��',
+ minWidth: 130,
+ align: 'right',
+ formatter: 'formatAmount2',
+ },
+ {
+ field: 'usefulLife',
+ title: '浣跨敤骞撮檺',
+ minWidth: 100,
+ align: 'right',
+ },
+ {
+ field: 'residualRate',
+ title: '娈嬪�肩巼(%)',
+ minWidth: 110,
+ align: 'right',
+ },
+ {
+ field: 'monthlyDepreciation',
+ title: '鏈堟姌鏃ч',
+ minWidth: 130,
+ align: 'right',
+ formatter: 'formatAmount2',
+ },
+ {
+ field: 'accumulatedDepreciation',
+ title: '绱鎶樻棫',
+ minWidth: 130,
+ align: 'right',
+ formatter: 'formatAmount2',
+ },
+ {
+ field: 'netValue',
+ title: '鍑�鍊�',
+ minWidth: 130,
+ align: 'right',
+ formatter: 'formatAmount2',
+ },
+ {
+ // 鍚庣 departmentId 瀛樼殑鏄儴闂ㄧ紪鍙凤紝鍒楄〃灞曠ず鐢ㄥ悗绔В鏋愬ソ鐨� departmentName
+ field: 'departmentName',
+ title: '浣跨敤閮ㄩ棬',
+ minWidth: 120,
+ },
+ {
+ field: 'keeperName',
+ title: '淇濈浜�',
+ minWidth: 100,
+ },
+ {
+ field: 'status',
+ title: '璧勪骇鐘舵��',
+ minWidth: 110,
+ cellRender: {
+ name: 'CellDict',
+ props: { type: DICT_TYPE.FINANCE_FIXED_ASSET_STATUS },
+ },
+ },
+ {
+ field: 'createTime',
+ title: '鍒涘缓鏃堕棿',
+ minWidth: 180,
+ formatter: 'formatDateTime',
+ },
+ {
+ title: '鎿嶄綔',
+ width: 200,
+ fixed: 'right',
+ slots: { default: 'actions' },
+ },
+ ];
+}
--
Gitblit v1.9.3