Merge remote-tracking branch 'origin/main'

# Conflicts:
#	Web/src/views/basics-date/matter/component/editClassifyOpenAccess.vue
#	Web/src/views/basics-date/unit/index.vue
main
ljh 2024-07-03 23:47:35 +08:00
commit 755dba17cf
3 changed files with 563 additions and 625 deletions

View File

@ -259,3 +259,34 @@ public class QueryByIdMaterialsInput : DeleteMaterialsInput
{
}
/// <summary>
///
/// </summary>
public class MaterialsUnitInput : MaterialsBaseInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}
/// <summary>
///
/// </summary>
public class MaterialsUnitGetInput
{
/// <summary>
/// 单位组ID
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public virtual long UnitGroupId { get; set; }
/// <summary>
/// 基本单位
/// </summary>
public virtual string Unit { get; set; }
}

View File

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

View File

@ -18,8 +18,8 @@
<el-form-item>
<el-button type="primary" @click="unitPage({groupUnitId:data.selectUnitGroupId})"></el-button>
<el-button type="primary" @click="addUnit"></el-button>
<el-button @click="unitUpdateEnable(true)"></el-button>
<el-button @click="unitUpdateEnable(false)"></el-button>
<el-button @click="''"></el-button>
<el-button @click="''"></el-button>
</el-form-item>
</el-form>
</div>
@ -33,9 +33,7 @@
<div>
<el-button type="success" link
@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 style="height: 100%;">
@ -55,9 +53,7 @@
<vxe-column title="操作" width="150" fixed="right" show-overflow>
<template #default="{ row }">
<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> -->
</template>
</vxe-column>
@ -73,7 +69,6 @@
v-loading="loading"
tooltip-effect="light"
row-key="id"
@selection-change="handleSelectionChange"
border="">
<el-table-column type="selection" width="60" />
<el-table-column prop="codeNum" label="编码" show-overflow-tooltip="" />
@ -93,13 +88,10 @@
</el-table-column>
<el-table-column prop="updateUserName" 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">
<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>
</el-table-column>
</el-table>
@ -158,21 +150,21 @@
</div>
<el-dialog v-model="dialogTableVisible" :title="mTitle" width="860">
<el-form :inline="true" ref="ruleFormRef" :model="unitFrom" class="demo-form-inline" label-width="80px">
<el-form :inline="true" :model="unitFrom" class="demo-form-inline" label-width="80px">
<el-row>
<el-col :span="8">
<el-form-item label="名称" :rules="[{ required: true, message: '名称不能为空', trigger: 'blur' }]" prop="name">
<el-form-item label="名称" :rules="[{ required: true, message: '名称不能为空', trigger: 'blur' }]">
<el-input v-model="unitFrom.name" placeholder="请输入名称" clearable />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="编码" :rules="[{ required: true, message: '编码不能为空', trigger: 'blur' }]" prop="codeNum">
<el-form-item label="编码" :rules="[{ required: true, message: '编码不能为空', trigger: 'blur' }]">
<el-input v-model="unitFrom.codeNum" placeholder="请输入编码" clearable />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="单位组" :rules="[{ required: true, message: '单位组不能为空', trigger: 'blur' }]" prop="groupUnitId">
<el-form-item label="单位组" :rules="[{ required: true, message: '单位组不能为空', trigger: 'blur' }]">
<el-select v-model="unitFrom.groupUnitId" placeholder="请选择" clearable>
<el-option :label="item.name" :value="item.id" v-for="item, index in data.unitGroup"
:key="index" />
@ -187,13 +179,13 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="子单位数" :rules="[{ required: true, message: '不能为空', trigger: 'blur' }]" prop="childUnitCount">
<el-form-item label="子单位数" :rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
<el-input v-model="unitFrom.childUnitCount" placeholder="下级单位数量" clearable />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="换算率" :rules="[{ required: true, message: '不能为空', trigger: 'blur' }]" prop="rate">
<el-form-item label="换算率" :rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
<el-input v-model="unitFrom.rate" placeholder="基本单位数量" clearable />
</el-form-item>
</el-col>
@ -227,40 +219,24 @@
</el-form-item>
</el-col>
</el-row>
<el-tabs v-model="activeName" class="demo-tabs" >
<el-tab-pane label="操作信息" name="操作信息">
<el-row>
<el-col :span="8">
<el-form-item label="创建人" >
<el-input v-model="unitFrom.createUserName" disabled clearable />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="修改人" >
<el-input v-model="unitFrom.updateUserName" disabled clearable />
</el-form-item>
</el-col>
</el-row>
</el-tab-pane>
</el-tabs>
</el-form>
<el-row style="display: flex; justify-content: space-around;">
<el-button style="width: 100px;" type="primary" @click="unitSubmit"></el-button>
<el-button style="width: 100px;" @click="dialogTableVisible = false">取消</el-button>
</el-row>
</el-dialog>
<div v-if="isShowDialog">
<el-dialog v-model="isShowDialog" :title="mGroupTitle" :width="800">
<el-dialog v-model="isShowDialog" :title="mGroupTitle" ref="ruleFormRef" :width="800" >
<template #header>
<div style="color: #fff">
<span>单位组</span>
</div>
</template>
<el-form ref="unitGroupRuleFormRef" :model="unitGroupModel" label-width="auto" >
<el-form :model="unitGroupModel" label-width="auto" :rules="rules">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="名称" prop="name" :rules="[{ required: true, message: '名称不能为空', trigger: 'blur' }]">
<el-input v-model="unitGroupModel.name" placeholder="请输入名称" maxlength="32" show-word-limit
clearable/>
<el-form-item label="名称" prop="name">
<el-input v-model="unitGroupModel.name" placeholder="请输入名称" maxlength="32" show-word-limit clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
@ -276,7 +252,7 @@
</span>
</template>
</el-dialog>
</div>
</div>
</template>
@ -285,78 +261,59 @@
import { onMounted, reactive, ref } from 'vue'
import { getAPI } from '/@/utils/axios-utils';
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 { ElMessageBox, ElMessage } from 'element-plus';
import {auth} from "/@/utils/authFunction";
import {listMaterialByUnit} from "/@/api/main/materials";
let data = reactive({
unit: [] as SqlSugarPagedListSysUnitOutput[],//
unitGroup: [] as SysUnitGroupOutput[],//
selectUnitGroupId:0,
});
const activeName = ref('操作信息')
const loading = ref(false);
const ruleFormRef = ref();
const isShowDialog=ref(false);
const multipleSelection = ref([])
const tableParams = ref({
page: 1,
pageSize: 10,
total: 0,
});
const unitGroupRuleFormRef = ref();
let unitGroupModel=reactive<any>({isEnable:true,isDelete:false});
//
const rules = ref<FormRules>({
name: [{required: true, message: '请输入名称', trigger: 'blur',},],
});
let mTitle = ref('新增');
let mGroupTitle = ref('新增');
let dialogTableVisible = ref(false);
const unitFrom = ref<any>({isEnable:true,isDelete:false,name:'',codeNum:''})
const cancel=()=>{
isShowDialog.value=false
}
const handleSelectionChange = (val: []) => {
multipleSelection.value = val
}
//submit
const submit = async () => {
unitGroupRuleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
if (isValid) {
if (unitGroupModel.id>0){
if(!unitGroupModel.isEnable){
let wlRes = await listMaterialByUnit(unitGroupModel.id,"");
if(wlRes.data.code == 200) {
if (wlRes.data.result.length > 0) return ElMessage.error("单位已被物料使用,无法停用")
}
}
let res = await getAPI(SysUnitGroupApi).apiSysUnitGroupUpdatePost(unitGroupModel);
if (res.data.code === 200) {
isShowDialog.value = false;
await unitGroup();
}
}
else{
if(mGroupTitle.value=='新增'){
let res = await getAPI(SysUnitGroupApi).apiSysUnitGroupAddPost(unitGroupModel);
console.log(res)
if (res.data.code===200) {
isShowDialog.value = false;
await unitGroup();
unitGroup();
}
}else{
let res = await getAPI(SysUnitGroupApi).apiSysUnitGroupUpdatePost(unitGroupModel);
if (res.data.code===200) {
isShowDialog.value = false;
unitGroup();
}
}
}
});
};
//
@ -374,10 +331,7 @@ const formInline = reactive({} as SysUnitInput)
//
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;
tableParams.value.total = res.data.result?.total;
}
@ -396,8 +350,6 @@ const handleCurrentChange = (val: number) => {
const addUnit= ()=>{
ruleFormRef.value?.resetFields();
unitFrom.value = reactive({ });
unitFrom.value.codeNum = 'DW'+ getCurrentDate();
dialogTableVisible.value=true;
mTitle.value='新增'
@ -405,8 +357,6 @@ const addUnit = () => {
//
const unitSubmit = async () => {
ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
if (isValid) {
//
let checkRes = await getAPI(SysUnitApi).apiSysUnitCheckPost(unitFrom.value);
if(checkRes.data.code === 200){
@ -420,47 +370,23 @@ const unitSubmit = async () => {
let res = await getAPI(SysUnitApi).apiSysUnitAddPost(unitFrom.value);
if (res.data.code===200) {
dialogTableVisible.value = false;
await unitPage({groupUnitId: data.selectUnitGroupId});
unitPage({groupUnitId:data.selectUnitGroupId});
}
}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', });
unitFrom.value.isBaseUnit = false;
return;
}
if(!unitFrom.value.isEnable){
let wlRes = await listMaterialByUnit(unitFrom.value.unitGroupId,unitFrom.value.name);
if(wlRes.data.code == 200) {
if (wlRes.data.result.length > 0) return ElMessage.error("单位已被物料使用,无法停用")
}
}
let res = await getAPI(SysUnitApi).apiSysUnitUpdatePost(unitFrom.value);
if (res.data.code===200) {
dialogTableVisible.value = false;
await unitPage({groupUnitId: data.selectUnitGroupId});
unitPage({groupUnitId:data.selectUnitGroupId});
}
}
}
}
})
}
//
const unitUpdateEnable = async (enable:boolean) => {
if(multipleSelection.value.length === 0){ return ElMessage.error("至少选择一条单位数据")}
let ids = [] as any;
multipleSelection.value.forEach(item => {
ids.push(item.id);
})
let result = await getAPI(SysUnitApi).apiSysUnitUpdateEnablePost({ids:ids.join(","),isEnable:enable});
if (result.data.code === 200) {
ElMessage({message: '成功', type: 'success',})
await unitPage({groupUnitId: data.selectUnitGroupId});
}
else{
ElMessage.error(res.data.message!)
}
}
const getCurrentDate = () => {
const now = new Date();
@ -474,16 +400,12 @@ const getCurrentDate = () => {
}
const editUnit=async(row:any)=>{
ruleFormRef.value?.resetFields();
unitFrom.value = reactive({ ...row });
unitFrom.value=row;
mTitle.value='编辑'
dialogTableVisible.value=true;
}
const deleteUnit=async(row:any)=>{
let wlRes = await listMaterialByUnit(row.unitGroupId,row.name);
if(wlRes.data.code == 200) {
if (wlRes.data.result.length > 0) return ElMessage.error("单位已被物料使用")
ElMessageBox.confirm(`确定删除?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -498,23 +420,19 @@ const deleteUnit = async (row: any) => {
} else
ElMessage.error(res.data.message!)
})
.catch(() => {
});
}
.catch(() => {});
}
const addUnitGroup=()=>{
unitGroupRuleFormRef.value?.resetFields();
unitGroupModel = reactive({ });
isShowDialog.value=true
}
const editUnitGroup = (row: any) => {
unitGroupRuleFormRef.value?.resetFields();
const editUnitGroup=async(row:any)=>{
unitGroupModel=row;
mGroupTitle.value='编辑'
isShowDialog.value=true;
unitGroupModel = reactive({ ...row });
}
const deleteUnitGroup=async(row:any)=>{
@ -524,9 +442,6 @@ const deleteUnitGroup = async (row: any) => {
if(result){
return ElMessage.error("存在单位数据,不允许删除")
}
let wlRes = await listMaterialByUnit(row.id,"");
if(wlRes.data.code == 200) {
if(wlRes.data.result.length>0) return ElMessage.error("单位组已被物料使用")
ElMessageBox.confirm(`确定删除?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -543,10 +458,9 @@ const deleteUnitGroup = async (row: any) => {
} else
ElMessage.error(res.data.message!)
})
.catch(() => {
});
}
.catch(() => {});
}
}
const pageVO1 = reactive({