From 7ce15ddf0e02994a4aae93acb90ab2225288d585 Mon Sep 17 00:00:00 2001 From: my_ong <429426262@qq.com> Date: Tue, 4 Mar 2025 12:09:58 +0800 Subject: [PATCH] =?UTF-8?q?sparkles:=20:sparkles:=20=E5=85=88=E9=80=89?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=86=8D=E9=80=89=E7=89=A9=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/api-lock.json | 22 ++++++-- src/api/material/api.d.ts | 2 +- src/api/material/mods/material/all.ts | 36 ++++++++----- src/components.d.ts | 2 + src/views/stock/component/apply-form.vue | 67 ++++++++++++++++++------ src/views/stock/material/form.ts | 1 + src/views/stock/type/form.ts | 1 + 7 files changed, 98 insertions(+), 33 deletions(-) diff --git a/src/api/api-lock.json b/src/api/api-lock.json index 78f5b53..14e23b5 100644 --- a/src/api/api-lock.json +++ b/src/api/api-lock.json @@ -3961,7 +3961,23 @@ "enum": [], "typeProperties": [] }, - "parameters": [] + "parameters": [ + { + "description": "类型", + "required": false, + "in": "query", + "name": "type", + "dataType": { + "typeArgs": [], + "typeName": "string", + "isDefsType": false, + "templateIndex": -1, + "compileTemplateKeyword": "#/definitions/", + "enum": [], + "typeProperties": [] + } + } + ] }, { "description": "物料详情", @@ -4497,11 +4513,11 @@ { "dataType": { "typeArgs": [], - "typeName": "", + "typeName": "boolean", "isDefsType": false, "templateIndex": -1, "compileTemplateKeyword": "#/definitions/", - "enum": ["'LOW_VALUE'", "'HIGH_VALUE'"], + "enum": [], "typeProperties": [] }, "name": "assignRule", diff --git a/src/api/material/api.d.ts b/src/api/material/api.d.ts index 796eeb0..a8656fe 100644 --- a/src/api/material/api.d.ts +++ b/src/api/material/api.d.ts @@ -42,7 +42,7 @@ declare namespace material { applyId?: number /** assignRule */ - assignRule?: 'LOW_VALUE' | 'HIGH_VALUE' + assignRule?: boolean /** 确认数量 */ confirmQuantity?: number diff --git a/src/api/material/mods/material/all.ts b/src/api/material/mods/material/all.ts index 84f7c1d..ee6c864 100644 --- a/src/api/material/mods/material/all.ts +++ b/src/api/material/mods/material/all.ts @@ -1,18 +1,26 @@ /** * @desc 查询所有物料列表 */ -import { defaultSuccess, defaultError, http } from '@/plugins/axios'; -import type { AxiosResponse } from 'axios'; -export default async function ( - success: (data: Array) => void = defaultSuccess, - fail: (error: { code: string; error?: string }) => void = defaultError, -): Promise { - return http({ - method: 'get', - url: `/material/list`, - }) - .then((data: AxiosResponse, unknown>) => { - success(data.data); - }) - .catch((error: { code: string; error?: string }) => fail(error)); +import { defaultSuccess, defaultError, http } from '@/plugins/axios' +import type { AxiosResponse } from 'axios' +export interface Params { + /** 类型 */ + type?: string +} + +export default async function ( + params: Params, + success: (data: Array) => void = defaultSuccess, + fail: (error: { code: string; error?: string }) => void = defaultError, +): Promise { + return http({ + method: 'get', + url: `/material/list`, + + params, + }) + .then((data: AxiosResponse, unknown>) => { + success(data.data) + }) + .catch((error: { code: string; error?: string }) => fail(error)) } diff --git a/src/components.d.ts b/src/components.d.ts index 2135f8b..86b50d0 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -11,6 +11,7 @@ declare module 'vue' { AAvatar: typeof import('ant-design-vue/es')['Avatar'] AButton: typeof import('ant-design-vue/es')['Button'] ACard: typeof import('ant-design-vue/es')['Card'] + ACascader: typeof import('ant-design-vue/es')['Cascader'] ACol: typeof import('ant-design-vue/es')['Col'] AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider'] ADatePicker: typeof import('ant-design-vue/es')['DatePicker'] @@ -56,6 +57,7 @@ declare module 'vue' { ATooltip: typeof import('ant-design-vue/es')['Tooltip'] ATransfer: typeof import('ant-design-vue/es')['Transfer'] ATree: typeof import('ant-design-vue/es')['Tree'] + ATreeSelect: typeof import('ant-design-vue/es')['TreeSelect'] ATypographyLink: typeof import('ant-design-vue/es')['TypographyLink'] ATypographyParagraph: typeof import('ant-design-vue/es')['TypographyParagraph'] ATypographyTitle: typeof import('ant-design-vue/es')['TypographyTitle'] diff --git a/src/views/stock/component/apply-form.vue b/src/views/stock/component/apply-form.vue index 7eb6684..99b9073 100644 --- a/src/views/stock/component/apply-form.vue +++ b/src/views/stock/component/apply-form.vue @@ -17,18 +17,31 @@ - +
+ + +
@@ -84,6 +97,7 @@ import dayjs, { Dayjs } from 'dayjs' import { LabeledValue, DefaultOptionType } from 'ant-design-vue/es/select' import { SelectHandler } from 'ant-design-vue/es/vc-select/Select' + import { TreeDataNode } from 'ant-design-vue/es/vc-tree-select/interface' // 和外层界面的数据交互 const props = defineProps( @@ -115,7 +129,6 @@ applyType: string // 申请类型 slectedList: number[] // 入库物料 } - const formData = ref({ applicant: '', applyDate: dayjs(), @@ -123,6 +136,20 @@ slectedList: [], }) + // 物料类型树 + const types = ref>([]) + api.materialApi.type.trees((data) => { + types.value = children(data) + }) + const children = (res: Array): Array => { + return res.map((areaTree) => ({ + label: areaTree.label, + value: areaTree.value, + children: areaTree.children ? children(areaTree.children) : [], + key: areaTree.value, + })) + } + // vxe-table相关的设置 export interface RowVO { id: number @@ -139,18 +166,28 @@ const tableRef = ref>() // vxe-table 数据结果 const tableData = ref>([]) + // 物料选择器 + const typeVal = ref('') const options = ref<{ label: string; value: number }[]>([]) const materialList = ref([]) const getMaterialList = async () => { - await api.materialApi.material.all((data) => { + await api.materialApi.material.all({ type: typeVal.value }, (data) => { materialList.value = data }) options.value = materialList.value.map((item) => { return { label: item.name ? item.name : '未知', value: item.id ? item.id : -1 } }) } - getMaterialList() + watch( + typeVal, + (newVal) => { + if (newVal !== '') { + getMaterialList() + } + }, + { immediate: true, deep: true }, + ) // 选中时在末尾新增一行 // value: number, option: { label: string, value: number } diff --git a/src/views/stock/material/form.ts b/src/views/stock/material/form.ts index 080c775..2d79e2e 100644 --- a/src/views/stock/material/form.ts +++ b/src/views/stock/material/form.ts @@ -35,6 +35,7 @@ export const formItems = (types: TreeDataNode[]): FormItem[] => [ }, rules: [], }, + { type: 'tree-select', group: 'form', diff --git a/src/views/stock/type/form.ts b/src/views/stock/type/form.ts index 1e416c0..73c6793 100644 --- a/src/views/stock/type/form.ts +++ b/src/views/stock/type/form.ts @@ -24,6 +24,7 @@ export const formItems = (levels: Codebook[]): FormItem[] => [ label: '类型编码', name: 'no', required: true, + help: '格式:一级编码两位组成,00-99取值,只要保证唯一即可;二级编码,四位组成,父级的两位+00-99取值,只要保证唯一即可;', }, properties: { size: 'default',