sparkles: ✨ 先选类型再选物料
This commit is contained in:
parent
541fc2ff8a
commit
7ce15ddf0e
@ -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",
|
||||
|
2
src/api/material/api.d.ts
vendored
2
src/api/material/api.d.ts
vendored
@ -42,7 +42,7 @@ declare namespace material {
|
||||
applyId?: number
|
||||
|
||||
/** assignRule */
|
||||
assignRule?: 'LOW_VALUE' | 'HIGH_VALUE'
|
||||
assignRule?: boolean
|
||||
|
||||
/** 确认数量 */
|
||||
confirmQuantity?: number
|
||||
|
@ -1,18 +1,26 @@
|
||||
/**
|
||||
* @desc 查询所有物料列表
|
||||
*/
|
||||
import { defaultSuccess, defaultError, http } from '@/plugins/axios';
|
||||
import type { AxiosResponse } from 'axios';
|
||||
export default async function (
|
||||
success: (data: Array<material.Material>) => void = defaultSuccess,
|
||||
fail: (error: { code: string; error?: string }) => void = defaultError,
|
||||
): Promise<void> {
|
||||
return http({
|
||||
method: 'get',
|
||||
url: `/material/list`,
|
||||
})
|
||||
.then((data: AxiosResponse<Array<material.Material>, 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<material.Material>) => void = defaultSuccess,
|
||||
fail: (error: { code: string; error?: string }) => void = defaultError,
|
||||
): Promise<void> {
|
||||
return http({
|
||||
method: 'get',
|
||||
url: `/material/list`,
|
||||
|
||||
params,
|
||||
})
|
||||
.then((data: AxiosResponse<Array<material.Material>, unknown>) => {
|
||||
success(data.data)
|
||||
})
|
||||
.catch((error: { code: string; error?: string }) => fail(error))
|
||||
}
|
||||
|
2
src/components.d.ts
vendored
2
src/components.d.ts
vendored
@ -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']
|
||||
|
@ -17,18 +17,31 @@
|
||||
<a-date-picker v-model:value="formData.applyDate" />
|
||||
</a-form-item>
|
||||
<a-form-item label="选择物料" name="selected">
|
||||
<a-select
|
||||
v-model:value="formData.slectedList"
|
||||
mode="multiple"
|
||||
bordered
|
||||
placeholder="请选择物料"
|
||||
style="width: 40%"
|
||||
show-search
|
||||
:options="options"
|
||||
:filter-option="filterOption"
|
||||
@deselect="removeEvent($event)"
|
||||
@select="insertEvent($event)"
|
||||
></a-select>
|
||||
<div style="display: flex; justify-content: space-between">
|
||||
<a-tree-select
|
||||
v-model:value="typeVal"
|
||||
show-search
|
||||
style="width: 49%"
|
||||
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
||||
placeholder="请选择物料类型"
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
:tree-data="types"
|
||||
tree-node-filter-prop="label"
|
||||
/>
|
||||
<a-select
|
||||
v-model:value="formData.slectedList"
|
||||
mode="multiple"
|
||||
bordered
|
||||
placeholder="请选择物料"
|
||||
style="width: 49%"
|
||||
show-search
|
||||
:options="options"
|
||||
:filter-option="filterOption"
|
||||
@deselect="removeEvent($event)"
|
||||
@select="insertEvent($event)"
|
||||
></a-select>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
@ -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<FormData>({
|
||||
applicant: '',
|
||||
applyDate: dayjs(),
|
||||
@ -123,6 +136,20 @@
|
||||
slectedList: [],
|
||||
})
|
||||
|
||||
// 物料类型树
|
||||
const types = ref<Array<TreeDataNode>>([])
|
||||
api.materialApi.type.trees((data) => {
|
||||
types.value = children(data)
|
||||
})
|
||||
const children = (res: Array<material.TypeTree>): Array<TreeDataNode> => {
|
||||
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<VxeTableInstance<RowVO>>()
|
||||
// vxe-table 数据结果
|
||||
const tableData = ref<Array<RowVO>>([])
|
||||
|
||||
// 物料选择器
|
||||
const typeVal = ref('')
|
||||
const options = ref<{ label: string; value: number }[]>([])
|
||||
const materialList = ref<material.Material[]>([])
|
||||
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 }
|
||||
|
@ -35,6 +35,7 @@ export const formItems = (types: TreeDataNode[]): FormItem[] => [
|
||||
},
|
||||
rules: [],
|
||||
},
|
||||
|
||||
{
|
||||
type: 'tree-select',
|
||||
group: 'form',
|
||||
|
@ -24,6 +24,7 @@ export const formItems = (levels: Codebook[]): FormItem[] => [
|
||||
label: '类型编码',
|
||||
name: 'no',
|
||||
required: true,
|
||||
help: '格式:一级编码两位组成,00-99取值,只要保证唯一即可;二级编码,四位组成,父级的两位+00-99取值,只要保证唯一即可;',
|
||||
},
|
||||
properties: {
|
||||
size: 'default',
|
||||
|
Loading…
x
Reference in New Issue
Block a user