From ec2f257a8790f1bd31fc258dd0b137a125a3be27 Mon Sep 17 00:00:00 2001 From: mocheng <3057647414@qq.com> Date: Wed, 25 Jun 2025 09:27:33 +0800 Subject: [PATCH] asset --- apps/web-antd/.env.production | 2 +- apps/web-antd/.env.test | 2 +- .../src/api/property/assetType/index.ts | 4 + .../application/application-modal.vue | 106 +++++++++++++++++- .../property/assetManage/application/data.ts | 64 +++++------ .../assetManage/asset/asset-modal.vue | 56 ++++++++- .../views/property/assetManage/asset/data.ts | 30 +++-- .../src/views/property/floor/index.vue | 15 +-- apps/web-antd/vite.config.mts | 3 +- .../base/shared/src/constants/dict-enum.ts | 1 + 10 files changed, 224 insertions(+), 59 deletions(-) diff --git a/apps/web-antd/.env.production b/apps/web-antd/.env.production index 5fa61183..2b43bb72 100644 --- a/apps/web-antd/.env.production +++ b/apps/web-antd/.env.production @@ -7,7 +7,7 @@ VITE_COMPRESS=gzip VITE_PWA=false # vue-router 的模式 -VITE_ROUTER_HISTORY=history +VITE_ROUTER_HISTORY=hash # 是否注入全局loading VITE_INJECT_APP_LOADING=true diff --git a/apps/web-antd/.env.test b/apps/web-antd/.env.test index f66a206f..41548e98 100644 --- a/apps/web-antd/.env.test +++ b/apps/web-antd/.env.test @@ -10,7 +10,7 @@ VITE_COMPRESS=gzip VITE_PWA=false # vue-router 的模式 -VITE_ROUTER_HISTORY=history +VITE_ROUTER_HISTORY=hash # 是否注入全局loading VITE_INJECT_APP_LOADING=true diff --git a/apps/web-antd/src/api/property/assetType/index.ts b/apps/web-antd/src/api/property/assetType/index.ts index a2d96625..ec5852ba 100644 --- a/apps/web-antd/src/api/property/assetType/index.ts +++ b/apps/web-antd/src/api/property/assetType/index.ts @@ -15,6 +15,10 @@ export function assetTypeList(params?: AssetTypeQuery) { return requestClient.get>('/property/assetType/list', { params }); } +export function assetTypeselect() { + return requestClient.get('/property/assetType/list'); +} + /** * 导出资产类型列表 * @param params diff --git a/apps/web-antd/src/views/property/assetManage/application/application-modal.vue b/apps/web-antd/src/views/property/assetManage/application/application-modal.vue index 304b9fe3..9c9dac78 100644 --- a/apps/web-antd/src/views/property/assetManage/application/application-modal.vue +++ b/apps/web-antd/src/views/property/assetManage/application/application-modal.vue @@ -5,11 +5,16 @@ import { useVbenModal } from '@vben/common-ui'; import { $t } from '@vben/locales'; import { cloneDeep } from '@vben/utils'; -import { useVbenForm } from '#/adapter/form'; +import { type FormSchemaGetter, useVbenForm } from "#/adapter/form"; import { applicationAdd, applicationInfo, applicationUpdate } from '#/api/property/assetManage/application'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { modalSchema } from './data'; +import { assetTypeselect } from "#/api/property/assetType"; +import { depotList } from "#/api/property/assetManage/depot"; +import { suppliersList } from "#/api/property/assetManage/suppliers"; +import { assetList } from "#/api/property/assetManage/asset"; +import { userList } from "#/api/system/user"; const emit = defineEmits<{ reload: [] }>(); @@ -41,6 +46,103 @@ const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff( }, ); +formApi.getValues().then(setupPackageSelect); + +async function upSelectUser(nickName: string){ + const list=await userList({ + nickName:nickName, + pageNum: 1, + pageSize: 10, + }); + const options=list.map(item=>{ + item.label=item.userName; + item.value=item.id; + }) + fromApi.updateSchema([ + { + componentProps: { + optionFilterProp: 'label', + optionLabelProp: 'label', + options, + showSearch: true, + }, + fieldName: 'userId', + }, + ]); +} + +async function upSelectAssets(assetsName: string){ + const list=await assetList({ + assetsName:assetsName, + pageNum: 1, + pageSize: 10, + }); + const options=list.map(item=>{ + item.label=item.assetsName; + item.value=item.id; + }) + fromApi.updateSchema([ + { + componentProps: { + optionFilterProp: 'label', + optionLabelProp: 'label', + options, + showSearch: true, + }, + fieldName: 'assetsId', + }, + ]); +} + +async function setupPackageSelect() { + const users = await userList({ + pageNum: 1, + pageSize: 10, + }); + const assets = await assetList({ + pageNum: 1, + pageSize: 10, + }); + const options = users.rows.map((item) => ({ + label: item.nickName, + value: item.userId, + })); + const assetOptions = assets.rows.map((item) => ({ + label: item.name, + value: item.id, + })); + formApi.updateSchema([ + { + componentProps: { + optionFilterProp: 'label', + optionLabelProp: 'label', + options, + showSearch: true, + }, + async select(userId) { + await upSelectUser(userId); + userId="" + }, + fieldName: 'userId', + }, + { + componentProps: { + optionFilterProp: 'label', + optionLabelProp: 'label', + options: assetOptions, + showSearch: true, + }, + async select(assetsId) { + await upSelectAssets(assetsId); + assetsId="" + }, + fieldName: 'assetId', + }, + + ]); + +} + const [BasicModal, modalApi] = useVbenModal({ // 在这里更改宽度 class: 'w-[550px]', @@ -62,7 +164,7 @@ const [BasicModal, modalApi] = useVbenModal({ await formApi.setValues(record); } await markInitialized(); - + await setupPackageSelect(); modalApi.modalLoading(false); }, }); diff --git a/apps/web-antd/src/views/property/assetManage/application/data.ts b/apps/web-antd/src/views/property/assetManage/application/data.ts index 0ee40ab9..8b14dd49 100644 --- a/apps/web-antd/src/views/property/assetManage/application/data.ts +++ b/apps/web-antd/src/views/property/assetManage/application/data.ts @@ -112,46 +112,46 @@ export const modalSchema: FormSchemaGetter = () => [ { label: '资产id', fieldName: 'assetId', - component: 'Input', + component: 'Select', }, { label: '领用人id', fieldName: 'userId', - component: 'Input', + component: 'Select', }, { label: '数量', fieldName: 'number', component: 'Input', }, - { - label: '状态', - fieldName: 'state', - component: 'Input', - }, - { - label: '审批人id', - fieldName: 'acceptanceUserId', - component: 'Input', - }, - { - label: '审批时间', - fieldName: 'acceptanceTime', - component: 'DatePicker', - componentProps: { - showTime: true, - format: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'YYYY-MM-DD HH:mm:ss', - }, - }, - { - label: '申请时间', - fieldName: 'applicationTime', - component: 'DatePicker', - componentProps: { - showTime: true, - format: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'YYYY-MM-DD HH:mm:ss', - }, - }, + // { + // label: '状态', + // fieldName: 'state', + // component: 'Input', + // }, + // { + // label: '审批人id', + // fieldName: 'acceptanceUserId', + // component: 'Input', + // }, + // { + // label: '审批时间', + // fieldName: 'acceptanceTime', + // component: 'DatePicker', + // componentProps: { + // showTime: true, + // format: 'YYYY-MM-DD HH:mm:ss', + // valueFormat: 'YYYY-MM-DD HH:mm:ss', + // }, + // }, + // { + // label: '申请时间', + // fieldName: 'applicationTime', + // component: 'DatePicker', + // componentProps: { + // showTime: true, + // format: 'YYYY-MM-DD HH:mm:ss', + // valueFormat: 'YYYY-MM-DD HH:mm:ss', + // }, + // }, ]; diff --git a/apps/web-antd/src/views/property/assetManage/asset/asset-modal.vue b/apps/web-antd/src/views/property/assetManage/asset/asset-modal.vue index 4afd063a..c3c13dea 100644 --- a/apps/web-antd/src/views/property/assetManage/asset/asset-modal.vue +++ b/apps/web-antd/src/views/property/assetManage/asset/asset-modal.vue @@ -10,6 +10,10 @@ import { assetAdd, assetInfo, assetUpdate } from '#/api/property/assetManage/ass import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { modalSchema } from './data'; +import { packageSelectList } from "#/api/system/tenant-package"; +import { assetTypeselect } from "#/api/property/assetType"; +import { depotList } from "#/api/property/assetManage/depot"; +import { suppliersList } from "#/api/property/assetManage/suppliers"; const emit = defineEmits<{ reload: [] }>(); @@ -41,6 +45,55 @@ const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff( }, ); +async function setupPackageSelect() { + const tenantPackageList = await assetTypeselect(); + const depot = await depotList(); + const suppliers =await suppliersList(); + const options = tenantPackageList.rows.map((item) => ({ + label: item.assetTypeName, + value: item.id, + })); + const depotoptions = depot.rows.map((item) => ({ + label: item.depotName, + value: item.id, + })); + const supplieroptions = suppliers.rows.map((item) => ({ + label: item.suppliersName, + value: item.id, + })); + + formApi.updateSchema([ + { + componentProps: { + optionFilterProp: 'label', + optionLabelProp: 'label', + options, + showSearch: true, + }, + fieldName: 'model', + }, + { + componentProps: { + optionFilterProp: 'label', + optionLabelProp: 'label', + options: depotoptions, + showSearch: true, + }, + fieldName: 'depotId', + }, + { + componentProps: { + optionFilterProp: 'label', + optionLabelProp: 'label', + options: supplieroptions, + showSearch: true, + }, + fieldName: 'suppliersId', + }, + ]); + +} + const [BasicModal, modalApi] = useVbenModal({ // 在这里更改宽度 class: 'w-[550px]', @@ -52,6 +105,7 @@ const [BasicModal, modalApi] = useVbenModal({ if (!isOpen) { return null; } + modalApi.modalLoading(true); const { id } = modalApi.getData() as { id?: number | string }; @@ -62,7 +116,7 @@ const [BasicModal, modalApi] = useVbenModal({ await formApi.setValues(record); } await markInitialized(); - + await setupPackageSelect(); modalApi.modalLoading(false); }, }); diff --git a/apps/web-antd/src/views/property/assetManage/asset/data.ts b/apps/web-antd/src/views/property/assetManage/asset/data.ts index bd513f29..2b381f74 100644 --- a/apps/web-antd/src/views/property/assetManage/asset/data.ts +++ b/apps/web-antd/src/views/property/assetManage/asset/data.ts @@ -1,6 +1,9 @@ import type {FormSchemaGetter} from '#/adapter/form'; import type {VxeGridProps} from '#/adapter/vxe-table'; import {getDictOptions} from "#/utils/dict"; +import { renderDict } from "#/utils/render"; +import { DictEnum } from '@vben/constants'; + export const querySchema: FormSchemaGetter = () => [ @@ -44,7 +47,7 @@ export const columns: VxeGridProps['columns'] = [ }, { title: '资产类型', - field: 'model', + field: 'modelName', }, { title: '规格', @@ -63,16 +66,16 @@ export const columns: VxeGridProps['columns'] = [ field: 'unit', }, { - title: '仓库id', - field: 'depotId', + title: '仓库', + field: 'depotName', }, { title: '描述信息', field: 'msg', }, { - title: '供应商id', - field: 'suppliersId', + title: '供应商', + field: 'suppliersName', }, { title: '入库时间', @@ -81,6 +84,11 @@ export const columns: VxeGridProps['columns'] = [ { title: '固定资产', field: 'type', + slots: { + default: ({ row }) => { + return renderDict(row.type, DictEnum.WY_SF); + }, + }, }, { title: '创建时间', @@ -113,7 +121,7 @@ export const modalSchema: FormSchemaGetter = () => [ { label: '类型', fieldName: 'model', - component: 'Textarea', + component: 'Select', }, { label: '规格', @@ -136,9 +144,9 @@ export const modalSchema: FormSchemaGetter = () => [ component: 'Input', }, { - label: '仓库id', + label: '仓库', fieldName: 'depotId', - component: 'Input', + component: 'Select', }, { label: '描述信息', @@ -148,7 +156,7 @@ export const modalSchema: FormSchemaGetter = () => [ { label: '供应商id', fieldName: 'suppliersId', - component: 'Input', + component: 'Select', }, { label: '入库时间', @@ -164,6 +172,8 @@ export const modalSchema: FormSchemaGetter = () => [ label: '固定资产类型', fieldName: 'type', component: 'Select', - componentProps: {}, + componentProps: { + options: getDictOptions('wy_sf'), + }, }, ]; diff --git a/apps/web-antd/src/views/property/floor/index.vue b/apps/web-antd/src/views/property/floor/index.vue index 27953212..ed2d40ad 100644 --- a/apps/web-antd/src/views/property/floor/index.vue +++ b/apps/web-antd/src/views/property/floor/index.vue @@ -1,18 +1,11 @@