批量新建
parent
85778d433a
commit
9480a8f874
|
|
@ -48,7 +48,7 @@ export const locationApi = {
|
||||||
/**
|
/**
|
||||||
* 下拉查询 @author hj
|
* 下拉查询 @author hj
|
||||||
*/
|
*/
|
||||||
queryLocation: (param: number[]) => {
|
queryLocation: (param: object) => {
|
||||||
return postRequest('/location/queryLocation', param);
|
return postRequest('/location/queryLocation', param);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -58,4 +58,11 @@ export const locationApi = {
|
||||||
multipleAdjust: (param: object) => {
|
multipleAdjust: (param: object) => {
|
||||||
return postRequest('/location/multipleAdjust', param);
|
return postRequest('/location/multipleAdjust', param);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新建 @author hj
|
||||||
|
*/
|
||||||
|
multipleInsert: (param: object) => {
|
||||||
|
return postRequest('/location/multipleInsert', param);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ function onSearch() {
|
||||||
queryData();
|
queryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
//选择库位
|
//选择库区
|
||||||
function changeAreaSelect(selectValue: any) {
|
function changeAreaSelect(selectValue: any) {
|
||||||
if(selectValue){
|
if(selectValue){
|
||||||
queryForm.areaId = selectValue.areaId;
|
queryForm.areaId = selectValue.areaId;
|
||||||
|
|
@ -314,7 +314,7 @@ async function requestBatchDelete() {
|
||||||
if (success) {
|
if (success) {
|
||||||
message.success(success);
|
message.success(success);
|
||||||
}
|
}
|
||||||
queryData();
|
await queryData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
smartSentry.captureError(e);
|
smartSentry.captureError(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,6 @@ import {message} from 'ant-design-vue';
|
||||||
import {SmartLoading} from '/@/components/framework/smart-loading';
|
import {SmartLoading} from '/@/components/framework/smart-loading';
|
||||||
import {itemApi} from '/@/api/business/base/item/item-api.js';
|
import {itemApi} from '/@/api/business/base/item/item-api.js';
|
||||||
import {smartSentry} from '/@/lib/smart-sentry';
|
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";
|
import DictSelect from "/@/components/support/dict-select/index.vue";
|
||||||
|
|
||||||
// ------------------------ 事件 ------------------------
|
// ------------------------ 事件 ------------------------
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ async function requestDelete(data: any) {
|
||||||
try {
|
try {
|
||||||
await itemApi.delete(data.itemId);
|
await itemApi.delete(data.itemId);
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
queryData();
|
await queryData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
smartSentry.captureError(e);
|
smartSentry.captureError(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -317,7 +317,7 @@ async function requestBatchDelete() {
|
||||||
SmartLoading.show();
|
SmartLoading.show();
|
||||||
await itemApi.batchDelete(selectedRowKeyList.value);
|
await itemApi.batchDelete(selectedRowKeyList.value);
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
queryData();
|
await queryData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
smartSentry.captureError(e);
|
smartSentry.captureError(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,20 @@
|
||||||
</template>
|
</template>
|
||||||
批量删除
|
批量删除
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button @click="showmultipleAdjustForm" type="primary" v-privilege="'location:multipleAdjust'">
|
<a-button @click="showMultipleAdjustForm" type="primary" v-privilege="'location:multipleAdjust'">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<EditOutlined/>
|
<EditOutlined/>
|
||||||
</template>
|
</template>
|
||||||
批量调整
|
批量调整
|
||||||
</a-button>
|
</a-button>
|
||||||
|
|
||||||
|
<a-button @click="showMultipleInsertForm" type="primary" v-privilege="'location:multipleInsert'">
|
||||||
|
<template #icon>
|
||||||
|
<EditOutlined/>
|
||||||
|
</template>
|
||||||
|
批量新建
|
||||||
|
</a-button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="smart-table-setting-block">
|
<div class="smart-table-setting-block">
|
||||||
<TableOperator v-model="columns" :tableId="TABLE_ID_CONST.BUSINESS.BASE.LOCATION" :refresh="queryData"/>
|
<TableOperator v-model="columns" :tableId="TABLE_ID_CONST.BUSINESS.BASE.LOCATION" :refresh="queryData"/>
|
||||||
|
|
@ -145,13 +153,18 @@
|
||||||
:total="total"
|
:total="total"
|
||||||
@change="queryData"
|
@change="queryData"
|
||||||
@showSizeChange="queryData"
|
@showSizeChange="queryData"
|
||||||
:show-total="(total:any) => `共${total}条`"
|
:show-total="(total:number) => `共${total}条`"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 新建/编辑-->
|
||||||
<LocationForm ref="formRef" @reloadList="queryData"/>
|
<LocationForm ref="formRef" @reloadList="queryData"/>
|
||||||
|
|
||||||
<LocationAdjustForm ref="multipleAdjustFormRef" @reloadList="queryData"/>
|
<!-- 批量调整-->
|
||||||
|
<MultipleAdjust ref="multipleAdjustFormRef" @reloadList="queryData"/>
|
||||||
|
|
||||||
|
<!-- 批量新建-->
|
||||||
|
<MultipleInsert ref="multipleInsertFormRef" @reloadList="queryData"/>
|
||||||
|
|
||||||
</a-card>
|
</a-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -164,13 +177,15 @@ import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const';
|
||||||
import {smartSentry} from '/@/lib/smart-sentry';
|
import {smartSentry} from '/@/lib/smart-sentry';
|
||||||
import TableOperator from '/@/components/support/table-operator/index.vue';
|
import TableOperator from '/@/components/support/table-operator/index.vue';
|
||||||
import LocationForm from '/@/views/business/base/location/location-form.vue';
|
import LocationForm from '/@/views/business/base/location/location-form.vue';
|
||||||
import LocationAdjustForm from '/@/views/business/base/location/multiple-adjust.vue';
|
import MultipleAdjust from "/@/views/business/base/location/multiple-adjust.vue";
|
||||||
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const";
|
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const";
|
||||||
import LocationSelect from "/@/views/business/base/location/location-select.vue";
|
import LocationSelect from "/@/views/business/base/location/location-select.vue";
|
||||||
import AreaSelect from "/@/views/business/base/area/area-select.vue";
|
import AreaSelect from "/@/views/business/base/area/area-select.vue";
|
||||||
import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
|
import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
|
||||||
import DictPreview from '/@/components/dict-preview/index.vue';
|
import DictPreview from '/@/components/dict-preview/index.vue';
|
||||||
import {useDict} from '/@/utils/dict';
|
import {useDict} from '/@/utils/dict';
|
||||||
|
import MultipleInsert from "/@/views/business/base/location/multiple-insert.vue";
|
||||||
|
|
||||||
|
|
||||||
const locType = useDict('LOC_TYPE');
|
const locType = useDict('LOC_TYPE');
|
||||||
// ---------------------------- 表格列 ----------------------------
|
// ---------------------------- 表格列 ----------------------------
|
||||||
|
|
@ -332,7 +347,7 @@ async function requestDelete(data: any) {
|
||||||
try {
|
try {
|
||||||
await locationApi.delete(data.locationId);
|
await locationApi.delete(data.locationId);
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
queryData();
|
await queryData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
smartSentry.captureError(e);
|
smartSentry.captureError(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -371,7 +386,7 @@ async function requestBatchDelete() {
|
||||||
SmartLoading.show();
|
SmartLoading.show();
|
||||||
await locationApi.batchDelete(selectedRowKeyList.value);
|
await locationApi.batchDelete(selectedRowKeyList.value);
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
queryData();
|
await queryData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
smartSentry.captureError(e);
|
smartSentry.captureError(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -382,7 +397,14 @@ async function requestBatchDelete() {
|
||||||
// ---------------------------- 批量调整 ----------------------------
|
// ---------------------------- 批量调整 ----------------------------
|
||||||
const multipleAdjustFormRef = ref();
|
const multipleAdjustFormRef = ref();
|
||||||
|
|
||||||
function showmultipleAdjustForm() {
|
function showMultipleAdjustForm() {
|
||||||
multipleAdjustFormRef.value.showMultipleAdjust();
|
multipleAdjustFormRef.value.showMultipleAdjust();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------- 批量新建 ----------------------------
|
||||||
|
const multipleInsertFormRef = ref();
|
||||||
|
|
||||||
|
function showMultipleInsertForm() {
|
||||||
|
multipleInsertFormRef.value.showMultipleInsert();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ function changeLocationSelect(selectValue: []) {
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
try {
|
try {
|
||||||
await formRef.value.validateFields();
|
await formRef.value.validateFields();
|
||||||
save();
|
await save();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
message.error('参数验证错误,请仔细填写表单数据!');
|
message.error('参数验证错误,请仔细填写表单数据!');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,237 @@
|
||||||
|
<!--
|
||||||
|
* 批量调整
|
||||||
|
*
|
||||||
|
* @Author: 霍锦
|
||||||
|
* @Date: 2024-11-18 14:17:31
|
||||||
|
* @Copyright 友仓
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<a-modal
|
||||||
|
:title="title"
|
||||||
|
:width="600"
|
||||||
|
:open="visibleFlag"
|
||||||
|
@cancel="onClose"
|
||||||
|
:maskClosable="false"
|
||||||
|
:destroyOnClose="true"
|
||||||
|
>
|
||||||
|
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 6 }">
|
||||||
|
<a-divider orientation="left">基础信息</a-divider>
|
||||||
|
<a-row :gutter="24">
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="库区" name="areaId">
|
||||||
|
<AreaSelect width="100%" v-model:value="form.areaId" :disabledFlag="true" @change="changeAreaSelect"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="类型" name="locationType">
|
||||||
|
<DictSelect width="100%" key-code="LOC_TYPE" v-model:value="form.locationType"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
|
||||||
|
|
||||||
|
<a-divider orientation="left">编码规则</a-divider>
|
||||||
|
<a-row :gutter="24">
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="前缀" name="code">
|
||||||
|
<a-input style="width: 100%" v-model:value="form.code" placeholder="编码前缀"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="分隔符" name="separator">
|
||||||
|
<a-select
|
||||||
|
width="100%"
|
||||||
|
v-model:value="form.separator"
|
||||||
|
>
|
||||||
|
<a-select-option value="-">-</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
|
||||||
|
<a-divider orientation="left">规则配置</a-divider>
|
||||||
|
<a-row :gutter="24">
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="起始排" name="startRow">
|
||||||
|
<a-input-number style="width: 100%" v-model:value="form.startRow" :min="1" :max="10" placeholder="起始排"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="截止排" name="endRow">
|
||||||
|
<a-input-number style="width: 100%" v-model:value="form.endRow" :min="1" :max="10" placeholder="截止排"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
|
||||||
|
<a-row :gutter="24">
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="起始列" name="startCol">
|
||||||
|
<a-input-number style="width: 100%" v-model:value="form.startCol" :min="1" :max="10" placeholder="起始列"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="截止列" name="endCol">
|
||||||
|
<a-input-number style="width: 100%" v-model:value="form.endCol" :min="1" :max="10" placeholder="截止列"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
|
||||||
|
<a-row :gutter="24">
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="起始层" name="startLay">
|
||||||
|
<a-input-number style="width: 100%" v-model:value="form.startLay" :min="1" :max="10" placeholder="起始层"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item label="截止层" name="endLay">
|
||||||
|
<a-input-number style="width: 100%" v-model:value="form.endLay" :min="1" :max="10" placeholder="截止层"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<a-space>
|
||||||
|
<a-button @click="onClose">取消</a-button>
|
||||||
|
<a-button type="primary" @click="onSubmit">保存</a-button>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {nextTick, reactive, ref} from 'vue';
|
||||||
|
import {message} from 'ant-design-vue';
|
||||||
|
import {SmartLoading} from '/@/components/framework/smart-loading';
|
||||||
|
import {locationApi} from '/@/api/business/base/location/location-api';
|
||||||
|
import {smartSentry} from '/@/lib/smart-sentry';
|
||||||
|
import AreaSelect from "/@/views/business/base/area/area-select.vue";
|
||||||
|
import DictSelect from "/@/components/support/dict-select/index.vue";
|
||||||
|
|
||||||
|
|
||||||
|
const title = ref('批量新建');
|
||||||
|
|
||||||
|
// ------------------------ 事件 ------------------------
|
||||||
|
|
||||||
|
const emits = defineEmits(['reloadList']);
|
||||||
|
|
||||||
|
// ------------------------ 显示与隐藏 ------------------------
|
||||||
|
const visibleFlag = ref(false);
|
||||||
|
|
||||||
|
function showMultipleInsert() {
|
||||||
|
visibleFlag.value = true;
|
||||||
|
nextTick(() => {
|
||||||
|
formRef.value.clearValidate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//关闭
|
||||||
|
function onClose() {
|
||||||
|
Object.assign(form, formDefault);
|
||||||
|
visibleFlag.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------ 表单 ------------------------
|
||||||
|
|
||||||
|
// 组件ref
|
||||||
|
const formRef = ref();
|
||||||
|
|
||||||
|
const formDefault = {
|
||||||
|
areaId: undefined, //库区
|
||||||
|
locationType: undefined,//库位类型
|
||||||
|
code: undefined, //编码前缀
|
||||||
|
separator: '-',//分隔符
|
||||||
|
startRow: undefined,//起始排
|
||||||
|
endRow: undefined,//截止排
|
||||||
|
startCol: undefined,//起始列
|
||||||
|
endCol: undefined,//截止列
|
||||||
|
startLay: undefined,//起始层
|
||||||
|
endLay: undefined,//截止层
|
||||||
|
status: true, //状态
|
||||||
|
disabledFlag: true, //是否禁用
|
||||||
|
rowDigits: 2, //排编码位数
|
||||||
|
colDigits: 2, //列编码位数
|
||||||
|
layDigits: 2, //层编码位数
|
||||||
|
};
|
||||||
|
|
||||||
|
let form = reactive({...formDefault});
|
||||||
|
|
||||||
|
const rules = {
|
||||||
|
areaId: [{required: true, message: '库区 必填'}],
|
||||||
|
locationType: [{required: true, message: '类型 必填'}],
|
||||||
|
code: [
|
||||||
|
{required: true, message: '编码前缀 必填'},
|
||||||
|
{pattern: /^[a-zA-Z]{1,4}$/, message: '请输入字母且不超四个'}
|
||||||
|
],
|
||||||
|
separator: [{required: true, message: '分隔符 必填'}],
|
||||||
|
startRow: [{required: true, message: '起始排 必填'}],
|
||||||
|
endRow: [{required: true, message: '截止排 必填'}],
|
||||||
|
startCol: [{required: true, message: '起始列 必填'}],
|
||||||
|
endCol: [{required: true, message: '截止列 必填'}],
|
||||||
|
startLay: [{required: true, message: '起始层 必填'}],
|
||||||
|
endLay: [{required: true, message: '截止层 必填'}],
|
||||||
|
};
|
||||||
|
|
||||||
|
//选择库区
|
||||||
|
function changeAreaSelect(selectValue: any) {
|
||||||
|
if (selectValue) {
|
||||||
|
form.areaId = selectValue.areaId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 点击确定,验证表单
|
||||||
|
async function onSubmit() {
|
||||||
|
try {
|
||||||
|
await formRef.value.validateFields();
|
||||||
|
await save();
|
||||||
|
} catch (err) {
|
||||||
|
message.error('参数验证错误,请仔细填写表单数据!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存生成编码
|
||||||
|
async function save() {
|
||||||
|
SmartLoading.show();
|
||||||
|
try {
|
||||||
|
const locationCodes: string[] = [];
|
||||||
|
for (let row = form.startRow!; row <= form.endRow!; row++) {
|
||||||
|
const formattedRow = formatNumber(row, form.rowDigits);
|
||||||
|
for (let col = form.startCol!; col <= form.endCol!; col++) {
|
||||||
|
const formattedCol = formatNumber(col, form.colDigits);
|
||||||
|
for (let lay = form.startLay!; lay <= form.endLay!; lay++) {
|
||||||
|
const formattedLay = formatNumber(lay, form.layDigits);
|
||||||
|
const locationCode = `${form.code}${form.separator}${formattedRow}${form.separator}${formattedCol}${form.separator}${formattedLay}`;
|
||||||
|
locationCodes.push(locationCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const response = await locationApi.multipleInsert({
|
||||||
|
locationCodes: locationCodes,
|
||||||
|
areaId: form.areaId,
|
||||||
|
locationType: form.locationType
|
||||||
|
});
|
||||||
|
const {error, success} = JSON.parse(response.data);
|
||||||
|
if (error) {
|
||||||
|
message.error(error);
|
||||||
|
}
|
||||||
|
if (success) {
|
||||||
|
message.success(success);
|
||||||
|
}
|
||||||
|
emits('reloadList');
|
||||||
|
onClose();
|
||||||
|
} catch (err) {
|
||||||
|
smartSentry.captureError(err);
|
||||||
|
} finally {
|
||||||
|
SmartLoading.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 格式化数字,补零到指定位数
|
||||||
|
const formatNumber = (num: number, digits: number): string => {
|
||||||
|
return num.toString().padStart(digits, '0');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
showMultipleInsert,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue