完善单位物料功能

main
ljh 2024-07-03 17:32:43 +08:00
parent fa659428de
commit 3a62efa264
2 changed files with 528 additions and 505 deletions

View File

@ -2,7 +2,7 @@
<template> <template>
<div class="sys-open-access-container"> <div class="sys-open-access-container">
<el-dialog v-model="state.isShowDialog" :title="props.title" width="1000"> <el-dialog v-model="state.isShowDialog" :title="props.title" width="1000">
<el-form :inline="true" :model="ruleForm" class="demo-form-inline" label-width="90px"> <el-form ref="ruleFormRef" :inline="true" :model="ruleForm" class="demo-form-inline" label-width="90px">
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="物料类型" :rules="[{ required: true, message: '物料类型不能为空', trigger: 'blur' }]"> <el-form-item label="物料类型" :rules="[{ required: true, message: '物料类型不能为空', trigger: 'blur' }]">
@ -11,10 +11,13 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<el-row style="display: flex; justify-content: space-around;"> <template #footer>
<span class="dialog-footer">
<el-button style="width: 100px;" type="primary" @click="matterSubmit"></el-button> <el-button style="width: 100px;" type="primary" @click="matterSubmit"></el-button>
<el-button style="width: 100px;" @click="closeDialog"></el-button> <el-button style="width: 100px;" @click="closeDialog"></el-button>
</el-row> </span>
</template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@ -22,11 +25,15 @@
<script setup lang="ts"> <script setup lang="ts">
import {onMounted, reactive, ref} from 'vue'; import {onMounted, reactive, ref} from 'vue';
import {getAPI} from '/@/utils/axios-utils'; import {getAPI} from '/@/utils/axios-utils';
import { BrandApi, MaterialClassifyApi, PackageInfoApi, SysUnitGroupApi,SysUnitApi } from '/@/api-services/api'; import {
import { AddMaterialsInput, BrandOutput, MaterialsOutput, PackageInfoOutput, SysUnitGroupOutput, SysUnitOutput} from '/@/api-services/models'; MaterialClassifyApi,
} from '/@/api-services/api';
import {
MaterialsOutput,
SysUnitGroupOutput,
SysUnitOutput, UpdateMaterialClassifyInput
} from '/@/api-services/models';
import {ElMessageBox, ElMessage, TabsPaneContext} from 'element-plus'; import {ElMessageBox, ElMessage, TabsPaneContext} from 'element-plus';
import { addMaterials, updateMaterials,detailMaterials } from '/@/api/main/materials';
import { listUnitGroup } from '/@/api/main/unit';
import {addMaterialsClassify, detailMaterialsClassify, updateMaterialsClassify} from "/@/api/main/materialClassify"; import {addMaterialsClassify, detailMaterialsClassify, updateMaterialsClassify} from "/@/api/main/materialClassify";
const props = defineProps({ const props = defineProps({
@ -45,8 +52,7 @@ const fyListGet = async () => {
fyListData.value = res.data.result; fyListData.value = res.data.result;
} }
} }
const ruleFormRef = ref();
const ruleForm = ref<any>({});
const state = reactive({ const state = reactive({
loading: false, loading: false,
@ -66,18 +72,18 @@ const state = reactive({
editPrintTitle: '', editPrintTitle: '',
unitGroupData: [] as Array<SysUnitGroupOutput>, unitGroupData: [] as Array<SysUnitGroupOutput>,
unitData: [] as Array<SysUnitOutput>, unitData: [] as Array<SysUnitOutput>,
ruleForm: {} as UpdateMaterialClassifyInput,
}); });
// //
const openDialog = async (row: any) => { const openDialog = async (row: any) => {
//ruleFormRef.value?.resetFields(); ruleFormRef.value?.resetFields();
//state.selectedTabName = '0'; // tab //state.selectedTabName = '0'; // tab
let rowData = JSON.parse(JSON.stringify(row)); let rowData = JSON.parse(JSON.stringify(row));
if (rowData.id) if (rowData.id)
ruleForm.value = (await detailMaterialsClassify(rowData.id)).data.result; state.ruleForm = (await detailMaterialsClassify(rowData.id)).data.result;
else { else {
ruleForm.value = rowData; state.ruleForm = rowData;
ruleForm.value.isEnable=true;
} }
state.isShowDialog = true; state.isShowDialog = true;
}; };
@ -92,13 +98,14 @@ onMounted(() => {
}); });
// //
const matterSubmit = async () => { const matterSubmit = () => {
ruleFormRef.value.validate(async (valid: boolean) => {
if (!valid) return;
let res; let res;
if (props.title == '添加物料类型') { if (props.title == '添加物料类型') {
res = await addMaterialsClassify(ruleForm.value); res = await addMaterialsClassify(state.ruleForm);
} } else {
else { res = await updateMaterialsClassify(state.ruleForm);
res = await updateMaterialsClassify(ruleForm.value);
} }
//console.log(res) //console.log(res)
@ -109,13 +116,13 @@ const matterSubmit = async () => {
type: 'success', type: 'success',
}) })
//state.tableData.handleList(); //state.tableData.handleList();
} } else
else
ElMessage.error(res.message!) ElMessage.error(res.message!)
emit("reloadTable"); emit("reloadTable");
closeDialog(); closeDialog();
} });
}
// //

View File

@ -33,7 +33,9 @@
<div> <div>
<el-button type="success" link <el-button type="success" link
@click.prevent="addUnitGroup" @click.prevent="addUnitGroup"
style="border-right: 1px #515a6e solid; border-radius: 0px; margin-right: 3px; padding: 0 3px;">新增</el-button> style="border-right: 1px #515a6e solid; border-radius: 0px; margin-right: 3px; padding: 0 3px;">
新增
</el-button>
</div> </div>
</div> </div>
<div style="height: 100%;"> <div style="height: 100%;">
@ -53,7 +55,9 @@
<vxe-column title="操作" width="150" fixed="right" show-overflow> <vxe-column title="操作" width="150" fixed="right" show-overflow>
<template #default="{ row }"> <template #default="{ row }">
<vxe-button type="text" @click="editUnitGroup(row)" icon="vxe-icon-edit">修改</vxe-button> <vxe-button type="text" @click="editUnitGroup(row)" icon="vxe-icon-edit">修改</vxe-button>
<vxe-button type="text" @click="deleteUnitGroup(row)" icon="vxe-icon-delete" style="color: rgb(223, 65, 65)">删除</vxe-button> <vxe-button type="text" @click="deleteUnitGroup(row)" icon="vxe-icon-delete"
style="color: rgb(223, 65, 65)">删除
</vxe-button>
<!-- <vxe-button type="text" icon="vxe-icon-delete"></vxe-button> --> <!-- <vxe-button type="text" icon="vxe-icon-delete"></vxe-button> -->
</template> </template>
</vxe-column> </vxe-column>
@ -88,10 +92,13 @@
</el-table-column> </el-table-column>
<el-table-column prop="updateUserName" label="修改人" show-overflow-tooltip=""/> <el-table-column prop="updateUserName" label="修改人" show-overflow-tooltip=""/>
<el-table-column prop="updateTime" label="修改时间" show-overflow-tooltip=""/> <el-table-column prop="updateTime" label="修改时间" show-overflow-tooltip=""/>
<el-table-column width="200" label="操作"align="center" fixed="right" show-overflow-tooltip="" v-if="auth('materials:update') || auth('materials:delete')"> <el-table-column width="200" label="操作" align="center" fixed="right" show-overflow-tooltip=""
v-if="auth('materials:update') || auth('materials:delete')">
<template #default="scope"> <template #default="scope">
<vxe-button type="text" @click="editUnit(scope.row)" icon="vxe-icon-edit">修改</vxe-button> <vxe-button type="text" @click="editUnit(scope.row)" icon="vxe-icon-edit">修改</vxe-button>
<vxe-button type="text" @click="deleteUnit(scope.row)" icon="vxe-icon-delete" style="color: rgb(223, 65, 65)">删除</vxe-button> <vxe-button type="text" @click="deleteUnit(scope.row)" icon="vxe-icon-delete"
style="color: rgb(223, 65, 65)">删除
</vxe-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -226,7 +233,7 @@
<el-button style="width: 100px;" @click="dialogTableVisible = false">取消</el-button> <el-button style="width: 100px;" @click="dialogTableVisible = false">取消</el-button>
</el-row> </el-row>
</el-dialog> </el-dialog>
<div v-if="isShowDialog">
<el-dialog v-model="isShowDialog" :title="mGroupTitle" ref="ruleFormRef" :width="800"> <el-dialog v-model="isShowDialog" :title="mGroupTitle" ref="ruleFormRef" :width="800">
<template #header> <template #header>
<div style="color: #fff"> <div style="color: #fff">
@ -236,7 +243,8 @@
<el-form :model="unitGroupModel" label-width="auto" :rules="rules"> <el-form :model="unitGroupModel" label-width="auto" :rules="rules">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input v-model="unitGroupModel.name" placeholder="请输入名称" maxlength="32" show-word-limit clearable /> <el-input v-model="unitGroupModel.name" placeholder="请输入名称" maxlength="32" show-word-limit
clearable/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
@ -252,7 +260,7 @@
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</div>
</div> </div>
</template> </template>
@ -261,7 +269,12 @@
import {onMounted, reactive, ref} from 'vue' import {onMounted, reactive, ref} from 'vue'
import {getAPI} from '/@/utils/axios-utils'; import {getAPI} from '/@/utils/axios-utils';
import {SysUnitApi, SysUnitGroupApi} from '/@/api-services/api'; import {SysUnitApi, SysUnitGroupApi} from '/@/api-services/api';
import { AddSysUnitInput, SqlSugarPagedListSysUnitOutput, SysUnitGroupOutput, SysUnitInput} from '/@/api-services/models'; import {
AddSysUnitInput,
SqlSugarPagedListSysUnitOutput,
SysUnitGroupOutput,
SysUnitInput
} from '/@/api-services/models';
import type {FormRules} from "element-plus"; import type {FormRules} from "element-plus";
import {ElMessageBox, ElMessage} from 'element-plus'; import {ElMessageBox, ElMessage} from 'element-plus';
import {auth} from "/@/utils/authFunction"; import {auth} from "/@/utils/authFunction";
@ -290,7 +303,6 @@ let mGroupTitle = ref('新增');
let dialogTableVisible = ref(false); let dialogTableVisible = ref(false);
const unitFrom = ref<any>({isEnable: true, isDelete: false, name: '', codeNum: ''}) const unitFrom = ref<any>({isEnable: true, isDelete: false, name: '', codeNum: ''})
const cancel = () => { const cancel = () => {
@ -331,7 +343,10 @@ const formInline = reactive({} as SysUnitInput)
// //
const unitPage = async (parameter = formInline) => { const unitPage = async (parameter = formInline) => {
let res = await getAPI(SysUnitApi).apiSysUnitPagePost({pageSize:tableParams.value.pageSize,page:tableParams.value.page, ...parameter,...formInline }); let res = await getAPI(SysUnitApi).apiSysUnitPagePost({
pageSize: tableParams.value.pageSize,
page: tableParams.value.page, ...parameter, ...formInline
});
data.unit = res.data.result?.items as any; data.unit = res.data.result?.items as any;
tableParams.value.total = res.data.result?.total; tableParams.value.total = res.data.result?.total;
} }
@ -373,8 +388,7 @@ const unitSubmit = async () => {
unitPage({groupUnitId: data.selectUnitGroupId}); unitPage({groupUnitId: data.selectUnitGroupId});
} }
} else { } else {
if(unitFrom.value.isBaseUnit && item!=null && item.id!=unitFrom.value.id) if (unitFrom.value.isBaseUnit && item != null && item.id != unitFrom.value.id) {
{
ElMessage({message: '基本单位必须唯一', type: 'error',}); ElMessage({message: '基本单位必须唯一', type: 'error',});
unitFrom.value.isBaseUnit = false; unitFrom.value.isBaseUnit = false;
return; return;
@ -400,7 +414,7 @@ const getCurrentDate = () => {
} }
const editUnit = async (row: any) => { const editUnit = async (row: any) => {
unitFrom.value=row; unitFrom.value = reactive({ ...row });
mTitle.value = '编辑' mTitle.value = '编辑'
dialogTableVisible.value = true; dialogTableVisible.value = true;
} }
@ -420,7 +434,8 @@ const deleteUnit=async(row:any)=>{
} else } else
ElMessage.error(res.data.message!) ElMessage.error(res.data.message!)
}) })
.catch(() => {}); .catch(() => {
});
} }
const addUnitGroup = () => { const addUnitGroup = () => {
@ -429,10 +444,10 @@ const addUnitGroup=()=>{
} }
const editUnitGroup=async(row:any)=>{ const editUnitGroup = (row: any) => {
unitGroupModel=row;
mGroupTitle.value = '编辑' mGroupTitle.value = '编辑'
isShowDialog.value = true; isShowDialog.value = true;
unitGroupModel = reactive({ ...row });
} }
const deleteUnitGroup = async (row: any) => { const deleteUnitGroup = async (row: any) => {
@ -458,7 +473,8 @@ const deleteUnitGroup=async(row:any)=>{
} else } else
ElMessage.error(res.data.message!) ElMessage.error(res.data.message!)
}) })
.catch(() => {}); .catch(() => {
});
} }
} }