批量新建

main
HUOJIN\霍先森 2025-03-16 19:24:03 +08:00
parent 85778d433a
commit 9480a8f874
7 changed files with 279 additions and 15 deletions

View File

@ -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);
},
}; };

View File

@ -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 {

View File

@ -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";
// ------------------------ ------------------------ // ------------------------ ------------------------

View File

@ -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 {

View File

@ -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>

View File

@ -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('参数验证错误,请仔细填写表单数据!');
} }

View File

@ -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>