sparkles: ✨ 先选类型再选物料
This commit is contained in:
parent
541fc2ff8a
commit
7ce15ddf0e
@ -3961,7 +3961,23 @@
|
|||||||
"enum": [],
|
"enum": [],
|
||||||
"typeProperties": []
|
"typeProperties": []
|
||||||
},
|
},
|
||||||
"parameters": []
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "类型",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"name": "type",
|
||||||
|
"dataType": {
|
||||||
|
"typeArgs": [],
|
||||||
|
"typeName": "string",
|
||||||
|
"isDefsType": false,
|
||||||
|
"templateIndex": -1,
|
||||||
|
"compileTemplateKeyword": "#/definitions/",
|
||||||
|
"enum": [],
|
||||||
|
"typeProperties": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "物料详情",
|
"description": "物料详情",
|
||||||
@ -4497,11 +4513,11 @@
|
|||||||
{
|
{
|
||||||
"dataType": {
|
"dataType": {
|
||||||
"typeArgs": [],
|
"typeArgs": [],
|
||||||
"typeName": "",
|
"typeName": "boolean",
|
||||||
"isDefsType": false,
|
"isDefsType": false,
|
||||||
"templateIndex": -1,
|
"templateIndex": -1,
|
||||||
"compileTemplateKeyword": "#/definitions/",
|
"compileTemplateKeyword": "#/definitions/",
|
||||||
"enum": ["'LOW_VALUE'", "'HIGH_VALUE'"],
|
"enum": [],
|
||||||
"typeProperties": []
|
"typeProperties": []
|
||||||
},
|
},
|
||||||
"name": "assignRule",
|
"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
|
applyId?: number
|
||||||
|
|
||||||
/** assignRule */
|
/** assignRule */
|
||||||
assignRule?: 'LOW_VALUE' | 'HIGH_VALUE'
|
assignRule?: boolean
|
||||||
|
|
||||||
/** 确认数量 */
|
/** 确认数量 */
|
||||||
confirmQuantity?: number
|
confirmQuantity?: number
|
||||||
|
@ -1,18 +1,26 @@
|
|||||||
/**
|
/**
|
||||||
* @desc 查询所有物料列表
|
* @desc 查询所有物料列表
|
||||||
*/
|
*/
|
||||||
import { defaultSuccess, defaultError, http } from '@/plugins/axios';
|
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
|
||||||
import type { AxiosResponse } from 'axios';
|
import type { AxiosResponse } from 'axios'
|
||||||
export default async function (
|
export interface Params {
|
||||||
success: (data: Array<material.Material>) => void = defaultSuccess,
|
/** 类型 */
|
||||||
fail: (error: { code: string; error?: string }) => void = defaultError,
|
type?: string
|
||||||
): Promise<void> {
|
}
|
||||||
return http({
|
|
||||||
method: 'get',
|
export default async function (
|
||||||
url: `/material/list`,
|
params: Params,
|
||||||
})
|
success: (data: Array<material.Material>) => void = defaultSuccess,
|
||||||
.then((data: AxiosResponse<Array<material.Material>, unknown>) => {
|
fail: (error: { code: string; error?: string }) => void = defaultError,
|
||||||
success(data.data);
|
): Promise<void> {
|
||||||
})
|
return http({
|
||||||
.catch((error: { code: string; error?: string }) => fail(error));
|
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']
|
AAvatar: typeof import('ant-design-vue/es')['Avatar']
|
||||||
AButton: typeof import('ant-design-vue/es')['Button']
|
AButton: typeof import('ant-design-vue/es')['Button']
|
||||||
ACard: typeof import('ant-design-vue/es')['Card']
|
ACard: typeof import('ant-design-vue/es')['Card']
|
||||||
|
ACascader: typeof import('ant-design-vue/es')['Cascader']
|
||||||
ACol: typeof import('ant-design-vue/es')['Col']
|
ACol: typeof import('ant-design-vue/es')['Col']
|
||||||
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
|
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
|
||||||
ADatePicker: typeof import('ant-design-vue/es')['DatePicker']
|
ADatePicker: typeof import('ant-design-vue/es')['DatePicker']
|
||||||
@ -56,6 +57,7 @@ declare module 'vue' {
|
|||||||
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
|
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
|
||||||
ATransfer: typeof import('ant-design-vue/es')['Transfer']
|
ATransfer: typeof import('ant-design-vue/es')['Transfer']
|
||||||
ATree: typeof import('ant-design-vue/es')['Tree']
|
ATree: typeof import('ant-design-vue/es')['Tree']
|
||||||
|
ATreeSelect: typeof import('ant-design-vue/es')['TreeSelect']
|
||||||
ATypographyLink: typeof import('ant-design-vue/es')['TypographyLink']
|
ATypographyLink: typeof import('ant-design-vue/es')['TypographyLink']
|
||||||
ATypographyParagraph: typeof import('ant-design-vue/es')['TypographyParagraph']
|
ATypographyParagraph: typeof import('ant-design-vue/es')['TypographyParagraph']
|
||||||
ATypographyTitle: typeof import('ant-design-vue/es')['TypographyTitle']
|
ATypographyTitle: typeof import('ant-design-vue/es')['TypographyTitle']
|
||||||
|
@ -17,18 +17,31 @@
|
|||||||
<a-date-picker v-model:value="formData.applyDate" />
|
<a-date-picker v-model:value="formData.applyDate" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="选择物料" name="selected">
|
<a-form-item label="选择物料" name="selected">
|
||||||
<a-select
|
<div style="display: flex; justify-content: space-between">
|
||||||
v-model:value="formData.slectedList"
|
<a-tree-select
|
||||||
mode="multiple"
|
v-model:value="typeVal"
|
||||||
bordered
|
show-search
|
||||||
placeholder="请选择物料"
|
style="width: 49%"
|
||||||
style="width: 40%"
|
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
||||||
show-search
|
placeholder="请选择物料类型"
|
||||||
:options="options"
|
allow-clear
|
||||||
:filter-option="filterOption"
|
tree-default-expand-all
|
||||||
@deselect="removeEvent($event)"
|
:tree-data="types"
|
||||||
@select="insertEvent($event)"
|
tree-node-filter-prop="label"
|
||||||
></a-select>
|
/>
|
||||||
|
<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-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
</div>
|
</div>
|
||||||
@ -84,6 +97,7 @@
|
|||||||
import dayjs, { Dayjs } from 'dayjs'
|
import dayjs, { Dayjs } from 'dayjs'
|
||||||
import { LabeledValue, DefaultOptionType } from 'ant-design-vue/es/select'
|
import { LabeledValue, DefaultOptionType } from 'ant-design-vue/es/select'
|
||||||
import { SelectHandler } from 'ant-design-vue/es/vc-select/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(
|
const props = defineProps(
|
||||||
@ -115,7 +129,6 @@
|
|||||||
applyType: string // 申请类型
|
applyType: string // 申请类型
|
||||||
slectedList: number[] // 入库物料
|
slectedList: number[] // 入库物料
|
||||||
}
|
}
|
||||||
|
|
||||||
const formData = ref<FormData>({
|
const formData = ref<FormData>({
|
||||||
applicant: '',
|
applicant: '',
|
||||||
applyDate: dayjs(),
|
applyDate: dayjs(),
|
||||||
@ -123,6 +136,20 @@
|
|||||||
slectedList: [],
|
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相关的设置
|
// vxe-table相关的设置
|
||||||
export interface RowVO {
|
export interface RowVO {
|
||||||
id: number
|
id: number
|
||||||
@ -139,18 +166,28 @@
|
|||||||
const tableRef = ref<VxeTableInstance<RowVO>>()
|
const tableRef = ref<VxeTableInstance<RowVO>>()
|
||||||
// vxe-table 数据结果
|
// vxe-table 数据结果
|
||||||
const tableData = ref<Array<RowVO>>([])
|
const tableData = ref<Array<RowVO>>([])
|
||||||
|
|
||||||
// 物料选择器
|
// 物料选择器
|
||||||
|
const typeVal = ref('')
|
||||||
const options = ref<{ label: string; value: number }[]>([])
|
const options = ref<{ label: string; value: number }[]>([])
|
||||||
const materialList = ref<material.Material[]>([])
|
const materialList = ref<material.Material[]>([])
|
||||||
const getMaterialList = async () => {
|
const getMaterialList = async () => {
|
||||||
await api.materialApi.material.all((data) => {
|
await api.materialApi.material.all({ type: typeVal.value }, (data) => {
|
||||||
materialList.value = data
|
materialList.value = data
|
||||||
})
|
})
|
||||||
options.value = materialList.value.map((item) => {
|
options.value = materialList.value.map((item) => {
|
||||||
return { label: item.name ? item.name : '未知', value: item.id ? item.id : -1 }
|
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 }
|
// value: number, option: { label: string, value: number }
|
||||||
|
@ -35,6 +35,7 @@ export const formItems = (types: TreeDataNode[]): FormItem[] => [
|
|||||||
},
|
},
|
||||||
rules: [],
|
rules: [],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: 'tree-select',
|
type: 'tree-select',
|
||||||
group: 'form',
|
group: 'form',
|
||||||
|
@ -24,6 +24,7 @@ export const formItems = (levels: Codebook[]): FormItem[] => [
|
|||||||
label: '类型编码',
|
label: '类型编码',
|
||||||
name: 'no',
|
name: 'no',
|
||||||
required: true,
|
required: true,
|
||||||
|
help: '格式:一级编码两位组成,00-99取值,只要保证唯一即可;二级编码,四位组成,父级的两位+00-99取值,只要保证唯一即可;',
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
size: 'default',
|
size: 'default',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user