添加物料管理界面、物料下拉查询等

main
HUOJIN\霍先森 2025-03-14 23:50:53 +08:00
parent c0667d5424
commit 85778d433a
11 changed files with 213 additions and 76 deletions

View File

@ -12,21 +12,21 @@ export const areaApi = {
/**
* @author hj
*/
queryPage: (param: any) => {
queryPage: (param: object) => {
return postRequest('/area/queryPage', param);
},
/**
* @author hj
*/
add: (param: any) => {
add: (param: object) => {
return postRequest('/area/add', param);
},
/**
* @author hj
*/
update: (param: any) => {
update: (param: object) => {
return postRequest('/area/update', param);
},
@ -41,15 +41,15 @@ export const areaApi = {
/**
* @author hj
*/
batchDelete: (idList: any) => {
batchDelete: (idList: number[]) => {
return postRequest('/area/batchDelete', idList);
},
/**
* @author hj
*/
queryArea: (param: any) => {
return postRequest('/area/queryArea', {param});
queryArea: (param: object) => {
return postRequest('/area/queryArea', param);
},
};

View File

@ -45,4 +45,11 @@ export const itemApi = {
return postRequest('/item/batchDelete', idList);
},
/**
* @author hj
*/
queryItem: (param: object) => {
return postRequest('/item/queryItem', param);
},
};

View File

@ -12,21 +12,21 @@ export const locationApi = {
/**
* @author
*/
queryPage: (param: any) => {
queryPage: (param: object) => {
return postRequest('/location/queryPage', param);
},
/**
* @author
*/
add: (param: any) => {
add: (param: object) => {
return postRequest('/location/add', param);
},
/**
* @author
*/
update: (param: any) => {
update: (param: object) => {
return postRequest('/location/update', param);
},
@ -41,21 +41,21 @@ export const locationApi = {
/**
* @author
*/
batchDelete: (idList: any) => {
batchDelete: (idList: number[]) => {
return postRequest('/location/batchDelete', idList);
},
/**
* @author hj
*/
queryLocation: (param: any) => {
queryLocation: (param: number[]) => {
return postRequest('/location/queryLocation', param);
},
/**
* @author hj
*/
multipleAdjust: (param: any) => {
multipleAdjust: (param: object) => {
return postRequest('/location/multipleAdjust', param);
},
};

View File

@ -10,7 +10,7 @@
<a-form class="smart-query-form">
<a-row class="smart-query-form-row">
<a-form-item label="库区" class="smart-query-form-item">
<AreaSelect v-model:value="queryForm.areaId" @change="changeAreaSelect"/>
<AreaSelect v-model:value="queryForm.areaId" :disabledFlag="true" @change="changeAreaSelect"/>
</a-form-item>
<a-form-item label="是否启用" class="smart-query-form-item">
<a-select style="width: 200px" v-model:value="queryForm.disabledFlag" allowClear placeholder="请选择">
@ -19,7 +19,7 @@
</a-select>
</a-form-item>
<a-form-item class="smart-query-form-item">
<a-button type="primary" @click="onSearch">
<a-button type="primary" @click="onSearch" class="smart-margin-left10">
<template #icon>
<SearchOutlined/>
</template>

View File

@ -48,20 +48,23 @@ const props = defineProps({
type: Boolean,
default: false,
},
// ENTERPRISE_TYPE_ENUM
type: {
type: Number,
},
areaNames: {
type: Array as () => any[],
default: () => []
},
disabledFlag: {
type: Boolean,
default: null,
}
});
const areas = ref([]);
async function queryData() {
let res = await areaApi.queryArea({areaNames: props.areaNames});
let res = await areaApi.queryArea({
areaNames: props.areaNames,
disabledFlag: props.disabledFlag
});
areas.value = res.data;
}
@ -88,7 +91,7 @@ function handleChange(value: any) {
selectedLocations = areas.value.find((item: any) => item.areaId === value);
}
emit('update:value', value);
emit('change', JSON.parse(JSON.stringify(selectedLocations)));
emit('change', selectedLocations);
}

View File

@ -7,43 +7,64 @@
-->
<template>
<a-modal
:title="form.itemId ? '编辑' : '添加'"
:width="600"
:title="form.itemId ? '编辑物料' : '添加物料'"
:width="800"
:open="visibleFlag"
@cancel="onClose"
:maskClosable="false"
:destroyOnClose="true"
>
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }">
<a-form-item label="物料id" name="itemId">
<a-input-number style="width: 100%" v-model:value="form.itemId" placeholder="物料id"/>
</a-form-item>
<a-form-item label="物料编码" name="itemCode">
<a-input style="width: 100%" v-model:value="form.itemCode" placeholder="物料编码"/>
</a-form-item>
<a-form ref="formRef" :model="form" :rules="rules">
<a-row>
<a-col :span="24">
<a-form-item label="物料名称" name="itemName">
<a-input style="width: 100%" v-model:value="form.itemName" placeholder="物料名称"/>
</a-form-item>
<a-form-item label="是否禁用" name="disabledFlag">
<BooleanSelect v-model:value="form.disabledFlag" style="width: 100%"/>
</a-col>
</a-row>
<a-row>
<a-col :span="12">
<a-form-item label="物料编码" name="itemCode">
<a-input style="width: 100%" v-model:value="form.itemCode" placeholder="物料编码"/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="包装系数" name="packFactor">
<a-input-number style="width: 100%" v-model:value="form.packFactor" min="1" max="99999"
placeholder="包装系数"/>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="12">
<a-form-item label="包装单位" name="unit">
<DictSelect width="100%" key-code="ITEM_UNIT" v-model:value="form.unit"/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="物料类型" name="itemType">
<SmartEnumSelect width="100%" v-model:value="form.itemType" enumName="" placeholder="物料类型"/>
<DictSelect width="100%" key-code=" ITEM_TYPE" v-model:value="form.itemType"/>
</a-form-item>
<a-form-item label="创建人ID" name="createUserId">
<a-input-number style="width: 100%" v-model:value="form.createUserId" placeholder="创建人ID"/>
</a-form-item>
<a-form-item label="创建人" name="createUserName">
<a-input style="width: 100%" v-model:value="form.createUserName" placeholder="创建人"/>
</a-form-item>
<a-form-item label="创建时间" name="createTime">
<a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" v-model:value="form.createTime" style="width: 100%"
placeholder="创建时间"/>
</a-form-item>
<a-form-item label="更新时间" name="updateTime">
<a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" v-model:value="form.updateTime" style="width: 100%"
placeholder="更新时间"/>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-item label="是否启用" name="disabledFlag">
<a-switch
style="width: 80px"
v-model:checked="form.disabledFlag"
checked-children="启用"
un-checked-children="禁用"
/>
</a-form-item>
</a-col>
</a-row>
</a-form>
<template #footer>
@ -63,6 +84,7 @@ import {itemApi} from '/@/api/business/base/item/item-api.js';
import {smartSentry} from '/@/lib/smart-sentry';
import BooleanSelect from '/@/components/framework/boolean-select/index.vue';
import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
import DictSelect from "/@/components/support/dict-select/index.vue";
// ------------------------ ------------------------
@ -97,12 +119,10 @@ const formDefault = {
itemId: undefined, //id
itemCode: undefined, //
itemName: undefined, //
disabledFlag: undefined, //
disabledFlag: true, //
itemType: undefined, //
createUserId: undefined, //ID
createUserName: undefined, //
createTime: undefined, //
updateTime: undefined, //
unit: undefined, //
packFactor: 1,//
};
let form = reactive({...formDefault});
@ -111,12 +131,10 @@ const rules = {
itemId: [{required: true, message: '物料id 必填'}],
itemCode: [{required: true, message: '物料编码 必填'}],
itemName: [{required: true, message: '物料名称 必填'}],
disabledFlag: [{required: true, message: '是否禁用 必填'}],
itemType: [{required: true, message: '物料类型 必填'}],
createUserId: [{required: true, message: '创建人ID 必填'}],
createUserName: [{required: true, message: '创建人 必填'}],
createTime: [{required: true, message: '创建时间 必填'}],
updateTime: [{required: true, message: '更新时间 必填'}],
unit: [{required: true, message: '包装单位 必填'}],
packFactor: [{required: true, message: '包装系数 必填'}],
disabledFlag: [{required: true, message: '是否启用 必填'}],
};
//

View File

@ -9,14 +9,17 @@
<!---------- 查询表单form begin ----------->
<a-form class="smart-query-form">
<a-row class="smart-query-form-row">
<a-form-item label="物料编码" class="smart-query-form-item">
<a-input style="width: 200px" v-model:value="queryForm.itemCode" placeholder="物料编码"/>
<a-form-item label="物料" class="smart-query-form-item">
<ItemSelect v-model:value="queryForm.itemId" :disabledFlag="true" @change="changeItemSelect"/>
</a-form-item>
<a-form-item label="物料名称" class="smart-query-form-item">
<a-input style="width: 200px" v-model:value="queryForm.itemName" placeholder="物料名称"/>
<a-form-item label="是否启用" class="smart-query-form-item">
<a-select style="width: 200px" v-model:value="queryForm.disabledFlag" allowClear placeholder="请选择">
<a-select-option :value="true">启用</a-select-option>
<a-select-option :value="false">禁用</a-select-option>
</a-select>
</a-form-item>
<a-form-item class="smart-query-form-item">
<a-button type="primary" @click="onSearch">
<a-button type="primary" @click="onSearch" class="smart-margin-left10">
<template #icon>
<SearchOutlined/>
</template>
@ -134,6 +137,7 @@ import ItemForm from '/@/views/business/base/item/item-form.vue';
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const";
import DictPreview from '/@/components/dict-preview/index.vue';
import {useDict} from '/@/utils/dict';
import ItemSelect from "/@/views/business/base/item/item-select.vue";
const itemUnit = useDict('ITEM_UNIT');
const itemType = useDict('ITEM_TYPE');
@ -146,7 +150,7 @@ const columns = ref([
ellipsis: true,
},
{
title: '物料',
title: '物料编码',
dataIndex: 'itemCode',
ellipsis: true,
},
@ -161,7 +165,7 @@ const columns = ref([
ellipsis: true,
},
{
title: '单位',
title: '包装单位',
dataIndex: 'unit',
ellipsis: true,
},
@ -192,8 +196,8 @@ const columns = ref([
// ---------------------------- ----------------------------
const queryFormState = {
itemCode: undefined, //
itemName: undefined, //
itemId: undefined, //
disabledFlag: undefined,//
pageNum: 1,
pageSize: 10,
};
@ -220,6 +224,13 @@ function onSearch() {
queryData();
}
//
function changeItemSelect(selectValue: any) {
if (selectValue) {
queryForm.itemId = selectValue.itemId;
}
}
//
async function queryData() {
tableLoading.value = true;

View File

@ -0,0 +1,98 @@
<!--
* 物料 下拉选择框
*
*
-->
<template>
<a-select
v-model:value="selectValue"
:style="`width: ${width}`"
:placeholder="props.placeholder"
:showSearch="true"
:allowClear="true"
:size="size"
@change="handleChange"
:disabled="disabled"
:mode="multiple ? 'multiple' : ''"
optionFilterProp="label"
>
<a-select-option v-for="item in items" :key="item.itemId" :label="item.itemCode">
{{ item.itemCode }}
<div style="float: right">
<template v-if="item.itemName"> {{ item.itemName }}</template>
</div>
</a-select-option>
</a-select>
</template>
<script setup lang="ts">
import {onMounted, ref, watch} from 'vue';
import {itemApi} from '/@/api/business/base/item/item-api';
const props = defineProps({
value: [Number, String, Object, Array],
width: {
type: String,
default: '200px',
},
placeholder: {
type: String,
default: '请选择',
},
size: {
type: String,
default: 'default',
},
disabled: {
type: Boolean,
default: false,
},
multiple: {
type: Boolean,
default: false,
},
disabledFlag: {
type: Boolean,
default: null,
}
});
const items = ref([]);
async function queryData() {
let res = await itemApi.queryItem({
disabledFlag: props.disabledFlag
});
items.value = res.data;
}
const emit = defineEmits(['update:value', 'change']);
const selectValue = ref(props.value);
// value
watch(
() => props.value,
(newValue) => {
selectValue.value = newValue;
}
);
function handleChange(value: any) {
let selectedLocations: any[] | any;
if (Array.isArray(value)) {
//
selectedLocations = value.map((id) => items.value.find((item: any) => item.itemId === id)).filter(Boolean);
} else {
//
selectedLocations = items.value.find((item: any) => item.itemId === value);
}
emit('update:value', value);
emit('change', selectedLocations);
}
onMounted(queryData);
</script>

View File

@ -16,7 +16,7 @@
>
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }">
<a-form-item label="库区" name="areaId">
<AreaSelect style="width: 100%" v-model:value="form.areaId" @change="changeAreaSelect"/>
<AreaSelect style="width: 100%" v-model:value="form.areaId" :disabledFlag="true" @change="changeAreaSelect"/>
</a-form-item>
<a-form-item label="库位" name="locationCode">
<a-input style="width: 100%" v-model:value="form.locationCode" placeholder="库位编码"/>

View File

@ -10,10 +10,10 @@
<a-form class="smart-query-form">
<a-row class="smart-query-form-row">
<a-form-item label="库区" class="smart-query-form-item">
<AreaSelect v-model:value="queryForm.areaId" @change="changeAreaSelect"/>
<AreaSelect v-model:value="queryForm.areaId" :disabledFlag="true" @change="changeAreaSelect"/>
</a-form-item>
<a-form-item label="库位" class="smart-query-form-item">
<LocationSelect v-model:value="queryForm.locationId" @change="changeLocationSelect"/>
<LocationSelect v-model:value="queryForm.locationId" :disabledFlag="true" @change="changeLocationSelect"/>
</a-form-item>
<a-form-item label="状态" class="smart-query-form-item">
<SmartEnumSelect style="width: 200px" enum-name="USAGE_STATUS_ENUM" v-model:value="queryForm.status"/>
@ -26,7 +26,7 @@
</a-form-item>
<a-form-item class="smart-query-form-item">
<a-button type="primary" @click="onSearch">
<a-button type="primary" @click="onSearch" class="smart-margin-left10">
<template #icon>
<SearchOutlined/>
</template>

View File

@ -98,7 +98,7 @@ function handleChange(value: any) {
selectedLocations = locations.value.find((item: any) => item.locationId === value);
}
emit('update:value', value);
emit('change', JSON.parse(JSON.stringify(selectedLocations)));
emit('change', selectedLocations);
}