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,46 +2,39 @@
<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 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-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item prop="name" label="物料类型" :rules="[{ required: true, message: '物料类型不能为空', trigger: 'blur' }]"> <el-form-item label="物料类型" :rules="[{ required: true, message: '物料类型不能为空', trigger: 'blur' }]">
<el-input v-model="state.ruleForm.name" placeholder="请输入名称" clearable maxlength="32"/> <el-input v-model="ruleForm.name" placeholder="请输入名称" clearable maxlength="32" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<template #footer> <el-row style="display: flex; justify-content: space-around;">
<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>
</span> </el-row>
</template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<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 { import { BrandApi, MaterialClassifyApi, PackageInfoApi, SysUnitGroupApi,SysUnitApi } from '/@/api-services/api';
MaterialClassifyApi, import { AddMaterialsInput, BrandOutput, MaterialsOutput, PackageInfoOutput, SysUnitGroupOutput, SysUnitOutput} from '/@/api-services/models';
} from '/@/api-services/api'; import { ElMessageBox, ElMessage, TabsPaneContext } from 'element-plus';
import { import { addMaterials, updateMaterials,detailMaterials } from '/@/api/main/materials';
MaterialsOutput, import { listUnitGroup } from '/@/api/main/unit';
SysUnitGroupOutput,
SysUnitOutput, UpdateMaterialClassifyInput
} from '/@/api-services/models';
import {ElMessageBox, ElMessage, TabsPaneContext} from 'element-plus';
import {addMaterialsClassify, detailMaterialsClassify, updateMaterialsClassify} from "/@/api/main/materialClassify"; import {addMaterialsClassify, detailMaterialsClassify, updateMaterialsClassify} from "/@/api/main/materialClassify";
const props = defineProps({ const props = defineProps({
title: String, title: String,
orgData: Array<MaterialsOutput>, orgData: Array<MaterialsOutput>,
}); });
// //
const emit = defineEmits(["reloadTable"]); const emit = defineEmits(["reloadTable"]);
// //
let fyListData = ref(); let fyListData = ref();
@ -52,14 +45,15 @@ 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,
isShowDialog: false, isShowDialog:false,
editClassifyOpenAccessTitle: '新增', editClassifyOpenAccessTitle:'新增',
tableData: [],//as Array<MaterialsOutput> tableData: [] ,//as Array<MaterialsOutput>
orgTreeData: [],//as Array<MaterialsOutput> orgTreeData: [] ,//as Array<MaterialsOutput>
//matterFrom: {} ,//as AddMaterialsInput //matterFrom: {} ,//as AddMaterialsInput
queryParams: { queryParams: {
name: undefined, name: undefined,
@ -70,42 +64,41 @@ const state = reactive({
total: 0 as any, total: 0 as any,
}, },
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)
state.ruleForm = (await detailMaterialsClassify(rowData.id)).data.result; ruleForm.value = (await detailMaterialsClassify(rowData.id)).data.result;
else { else{
state.ruleForm = rowData; ruleForm.value = rowData;
ruleForm.value.isEnable=true;
} }
state.isShowDialog = true; state.isShowDialog = true;
}; };
// //
const closeDialog = () => { const closeDialog = () => {
state.isShowDialog = false; state.isShowDialog = false;
}; };
onMounted(() => { onMounted(() => {
fyListGet(); fyListGet();
}); });
// //
const matterSubmit = () => { const matterSubmit = async () => {
ruleFormRef.value.validate(async (valid: boolean) => {
if (!valid) return;
let res; let res;
if (props.title == '添加物料类型') { if (props.title=='添加物料类型'){
res = await addMaterialsClassify(state.ruleForm); res = await addMaterialsClassify(ruleForm.value);
} else { }
res = await updateMaterialsClassify(state.ruleForm); else {
res = await updateMaterialsClassify(ruleForm.value);
} }
//console.log(res) //console.log(res)
@ -116,17 +109,17 @@ const matterSubmit = () => {
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();
});
} }
// //
defineExpose({openDialog}); defineExpose({ openDialog });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -5,12 +5,12 @@
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="名称"> <el-form-item label="名称">
<el-input v-model="formInline.name" placeholder="请输入名称" clearable/> <el-input v-model="formInline.name" placeholder="请输入名称" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="编码"> <el-form-item label="编码">
<el-input v-model="formInline.codeNum" placeholder="请输入编码" clearable/> <el-input v-model="formInline.codeNum" placeholder="请输入编码" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -18,8 +18,8 @@
<el-form-item> <el-form-item>
<el-button type="primary" @click="unitPage({groupUnitId:data.selectUnitGroupId})"></el-button> <el-button type="primary" @click="unitPage({groupUnitId:data.selectUnitGroupId})"></el-button>
<el-button type="primary" @click="addUnit"></el-button> <el-button type="primary" @click="addUnit"></el-button>
<el-button @click="unitUpdateEnable(true)"></el-button> <el-button @click="''"></el-button>
<el-button @click="unitUpdateEnable(false)"></el-button> <el-button @click="''"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@ -33,9 +33,7 @@
<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;"> style="border-right: 1px #515a6e solid; border-radius: 0px; margin-right: 3px; padding: 0 3px;">新增</el-button>
新增
</el-button>
</div> </div>
</div> </div>
<div style="height: 100%;"> <div style="height: 100%;">
@ -55,9 +53,7 @@
<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" <vxe-button type="text" @click="deleteUnitGroup(row)" icon="vxe-icon-delete" style="color: rgb(223, 65, 65)">删除</vxe-button>
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>
@ -73,68 +69,64 @@
v-loading="loading" v-loading="loading"
tooltip-effect="light" tooltip-effect="light"
row-key="id" row-key="id"
@selection-change="handleSelectionChange"
border=""> border="">
<el-table-column type="selection" width="60"/> <el-table-column type="selection" width="60" />
<el-table-column prop="codeNum" label="编码" show-overflow-tooltip=""/> <el-table-column prop="codeNum" label="编码" show-overflow-tooltip="" />
<el-table-column prop="name" label="名称" show-overflow-tooltip=""/> <el-table-column prop="name" label="名称" show-overflow-tooltip="" />
<el-table-column prop="code" label="代码" show-overflow-tooltip=""/> <el-table-column prop="code" label="代码" show-overflow-tooltip="" />
<el-table-column prop="isEnable" label="可用状态" show-overflow-tooltip=""> <el-table-column prop="isEnable" label="可用状态" show-overflow-tooltip="">
<template #default="scope"> <template #default="scope">
{{ scope.row.isEnable ? '启用' : '关闭' }} {{ scope.row.isEnable ? '启用' : '关闭' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="childUnitCount" label="子单位数" show-overflow-tooltip=""/> <el-table-column prop="childUnitCount" label="子单位数" show-overflow-tooltip="" />
<el-table-column prop="rate" label="换算率" show-overflow-tooltip=""/> <el-table-column prop="rate" label="换算率" show-overflow-tooltip="" />
<el-table-column prop="isEnable" label="作为基本单位" show-overflow-tooltip=""> <el-table-column prop="isEnable" label="作为基本单位" show-overflow-tooltip="">
<template #default="scope"> <template #default="scope">
{{ scope.row.isBaseUnit ? '是' : '否' }} {{ scope.row.isBaseUnit ? '是' : '否' }}
</template> </template>
</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="" <el-table-column width="200" label="操作"align="center" fixed="right" show-overflow-tooltip="" v-if="auth('materials:update') || auth('materials:delete')">
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" <vxe-button type="text" @click="deleteUnit(scope.row)" icon="vxe-icon-delete" style="color: rgb(223, 65, 65)">删除</vxe-button>
style="color: rgb(223, 65, 65)">删除
</vxe-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- <vxe-table show-overflow height="100%" :data="data.unit" :border=true--> <!-- <vxe-table show-overflow height="100%" :data="data.unit" :border=true-->
<!-- :tree-config="{ transform: true }" :scroll-y="{ gt: 20 }">--> <!-- :tree-config="{ transform: true }" :scroll-y="{ gt: 20 }">-->
<!-- <vxe-column type="checkbox" width="60" fixed="left"></vxe-column>--> <!-- <vxe-column type="checkbox" width="60" fixed="left"></vxe-column>-->
<!-- <vxe-column field="codeNum" sortable title="编码" width=""></vxe-column>--> <!-- <vxe-column field="codeNum" sortable title="编码" width=""></vxe-column>-->
<!-- <vxe-column field="name" sortable title="名称" width=""></vxe-column>--> <!-- <vxe-column field="name" sortable title="名称" width=""></vxe-column>-->
<!-- <vxe-column field="code" sortable title="代码" width=""></vxe-column>--> <!-- <vxe-column field="code" sortable title="代码" width=""></vxe-column>-->
<!-- <vxe-column sortable title="可用状态" width="">--> <!-- <vxe-column sortable title="可用状态" width="">-->
<!-- <template #default="{ row }">--> <!-- <template #default="{ row }">-->
<!-- {{ row.isEnable ? '启用' : '关闭' }}--> <!-- {{ row.isEnable ? '启用' : '关闭' }}-->
<!-- &lt;!&ndash; <vxe-button type="text" icon="vxe-icon-delete"></vxe-button> &ndash;&gt;--> <!-- &lt;!&ndash; <vxe-button type="text" icon="vxe-icon-delete"></vxe-button> &ndash;&gt;-->
<!-- </template>--> <!-- </template>-->
<!-- </vxe-column>--> <!-- </vxe-column>-->
<!-- <vxe-column field="childUnitCount" sortable title="子单位数" width=""></vxe-column>--> <!-- <vxe-column field="childUnitCount" sortable title="子单位数" width=""></vxe-column>-->
<!-- <vxe-column field="rate" sortable title="换算率" width=""></vxe-column>--> <!-- <vxe-column field="rate" sortable title="换算率" width=""></vxe-column>-->
<!-- <vxe-column field="isBaseUnit" sortable title="作为基本单位" width="">--> <!-- <vxe-column field="isBaseUnit" sortable title="作为基本单位" width="">-->
<!-- <template #default="{ row }">--> <!-- <template #default="{ row }">-->
<!-- {{ row.isBaseUnit ? '是' : '否' }}--> <!-- {{ row.isBaseUnit ? '是' : '否' }}-->
<!-- &lt;!&ndash; <vxe-button type="text" icon="vxe-icon-delete"></vxe-button> &ndash;&gt;--> <!-- &lt;!&ndash; <vxe-button type="text" icon="vxe-icon-delete"></vxe-button> &ndash;&gt;-->
<!-- </template>--> <!-- </template>-->
<!-- </vxe-column>--> <!-- </vxe-column>-->
<!-- <vxe-column title="操作" width="200" fixed="right" show-overflow>--> <!-- <vxe-column title="操作" width="200" fixed="right" show-overflow>-->
<!-- <template #default="{ row }">--> <!-- <template #default="{ row }">-->
<!-- <vxe-button type="text" @click="editUnit(row)" icon="vxe-icon-edit">修改</vxe-button>--> <!-- <vxe-button type="text" @click="editUnit(row)" icon="vxe-icon-edit">修改</vxe-button>-->
<!-- <vxe-button type="text" @click="deleteUnit(row)" icon="vxe-icon-delete" style="color: rgb(223, 65, 65)">删除</vxe-button>--> <!-- <vxe-button type="text" @click="deleteUnit(row)" icon="vxe-icon-delete" style="color: rgb(223, 65, 65)">删除</vxe-button>-->
<!-- &lt;!&ndash; <vxe-button type="text" icon="vxe-icon-delete"></vxe-button> &ndash;&gt;--> <!-- &lt;!&ndash; <vxe-button type="text" icon="vxe-icon-delete"></vxe-button> &ndash;&gt;-->
<!-- </template>--> <!-- </template>-->
<!-- </vxe-column>--> <!-- </vxe-column>-->
<!-- </vxe-table>--> <!-- </vxe-table>-->
</div> </div>
<div style="line-height: 35px"> <div style="line-height: 35px">
<el-pagination <el-pagination
@ -150,32 +142,32 @@
/> />
</div> </div>
<!-- <div>--> <!-- <div>-->
<!-- <vxe-pager v-model:current-page="pageVO1.currentPage" v-model:page-size="pageVO1.pageSize"--> <!-- <vxe-pager v-model:current-page="pageVO1.currentPage" v-model:page-size="pageVO1.pageSize"-->
<!-- :total="pageVO1.total" />--> <!-- :total="pageVO1.total" />-->
<!-- </div>--> <!-- </div>-->
</div> </div>
</div> </div>
<el-dialog v-model="dialogTableVisible" :title="mTitle" width="860"> <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-row>
<el-col :span="8"> <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-input v-model="unitFrom.name" placeholder="请输入名称" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <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-input v-model="unitFrom.codeNum" placeholder="请输入编码" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <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-select v-model="unitFrom.groupUnitId" placeholder="请选择" clearable>
<el-option :label="item.name" :value="item.id" v-for="item, index in data.unitGroup" <el-option :label="item.name" :value="item.id" v-for="item, index in data.unitGroup"
:key="index"/> :key="index" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -183,89 +175,73 @@
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="精度"> <el-form-item label="精度">
<el-input v-model="unitFrom.accuracy" placeholder="请输入" clearable/> <el-input v-model="unitFrom.accuracy" placeholder="请输入" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <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-input v-model="unitFrom.childUnitCount" placeholder="下级单位数量" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <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-input v-model="unitFrom.rate" placeholder="基本单位数量" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="代码"> <el-form-item label="代码">
<el-input v-model="unitFrom.code" placeholder="请输入" clearable/> <el-input v-model="unitFrom.code" placeholder="请输入" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="外部编码"> <el-form-item label="外部编码">
<el-input v-model="unitFrom.externalNumber" placeholder="请输入" clearable/> <el-input v-model="unitFrom.externalNumber" placeholder="请输入" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="备注"> <el-form-item label="备注">
<el-input v-model="unitFrom.remarks" placeholder="请输入" clearable/> <el-input v-model="unitFrom.remarks" placeholder="请输入" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="基本单位"> <el-form-item label="基本单位">
<el-switch v-model="unitFrom.isBaseUnit" inline-prompt active-text="" inactive-text=""/> <el-switch v-model="unitFrom.isBaseUnit" inline-prompt active-text="" inactive-text="" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="是否启用"> <el-form-item label="是否启用">
<el-switch v-model="unitFrom.isEnable" inline-prompt active-text="" inactive-text=""/> <el-switch v-model="unitFrom.isEnable" inline-prompt active-text="" inactive-text="" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </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-form>
<el-row style="display: flex; justify-content: space-around;"> <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;" type="primary" @click="unitSubmit"></el-button>
<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" :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">
<span>单位组</span> <span>单位组</span>
</div> </div>
</template> </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-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-form-item label="名称" prop="name">
<el-input v-model="unitGroupModel.name" placeholder="请输入名称" maxlength="32" show-word-limit <el-input v-model="unitGroupModel.name" placeholder="请输入名称" maxlength="32" show-word-limit clearable />
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">
<el-form-item label="是否启用" prop="isEnable"> <el-form-item label="是否启用" prop="isEnable">
<el-switch v-model="unitGroupModel.isEnable" active-text="" inactive-text=""/> <el-switch v-model="unitGroupModel.isEnable" active-text="" inactive-text="" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-form> </el-form>
@ -276,88 +252,69 @@
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</div>
</div> </div>
</template> </template>
<script setup lang="ts" name="sysUnit"> <script setup lang="ts" name="sysUnit">
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 { import { AddSysUnitInput, SqlSugarPagedListSysUnitOutput, SysUnitGroupOutput, SysUnitInput} from '/@/api-services/models';
AddSysUnitInput, import type { FormRules } from "element-plus";
SqlSugarPagedListSysUnitOutput, import { ElMessageBox, ElMessage } from 'element-plus';
SysUnitGroupOutput,
SysUnitInput
} from '/@/api-services/models';
import type {FormRules} from "element-plus";
import {ElMessageBox, ElMessage} from 'element-plus';
import {auth} from "/@/utils/authFunction"; import {auth} from "/@/utils/authFunction";
import {listMaterialByUnit} from "/@/api/main/materials";
let data = reactive({ let data = reactive({
unit: [] as SqlSugarPagedListSysUnitOutput[],// unit: [] as SqlSugarPagedListSysUnitOutput[],//
unitGroup: [] as SysUnitGroupOutput[],// unitGroup: [] as SysUnitGroupOutput[],//
selectUnitGroupId: 0, selectUnitGroupId:0,
}); });
const activeName = ref('操作信息')
const loading = ref(false); const loading = ref(false);
const ruleFormRef = ref(); const ruleFormRef = ref();
const isShowDialog = ref(false); const isShowDialog=ref(false);
const multipleSelection = ref([])
const tableParams = ref({ const tableParams = ref({
page: 1, page: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
}); });
const unitGroupRuleFormRef = ref(); let unitGroupModel=reactive<any>({isEnable:true,isDelete:false});
let unitGroupModel = reactive<any>({isEnable: true, isDelete: false}); //
const rules = ref<FormRules>({
name: [{required: true, message: '请输入名称', trigger: 'blur',},],
});
let mTitle = ref('新增');
let mTitle = ref('新增');
let mGroupTitle = ref('新增'); let mGroupTitle = ref('新增');
let dialogTableVisible = ref(false); let dialogTableVisible = ref(false);
const unitFrom = ref<any>({isEnable: true, isDelete: false, name: '', codeNum: ''})
const cancel = () => { const unitFrom = ref<any>({isEnable:true,isDelete:false,name:'',codeNum:''})
isShowDialog.value = false
}
const handleSelectionChange = (val: []) => { const cancel=()=>{
multipleSelection.value = val isShowDialog.value=false
} }
//submit //submit
const submit = async () => { const submit = async () => {
unitGroupRuleFormRef.value.validate(async (isValid: boolean, fields?: any) => { if(mGroupTitle.value=='新增'){
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{
let res = await getAPI(SysUnitGroupApi).apiSysUnitGroupAddPost(unitGroupModel); let res = await getAPI(SysUnitGroupApi).apiSysUnitGroupAddPost(unitGroupModel);
console.log(res) console.log(res)
if (res.data.code === 200) { if (res.data.code===200) {
isShowDialog.value = false; isShowDialog.value = false;
await unitGroup(); unitGroup();
}
}else{
let res = await getAPI(SysUnitGroupApi).apiSysUnitGroupUpdatePost(unitGroupModel);
if (res.data.code===200) {
isShowDialog.value = false;
unitGroup();
} }
} }
}
}); };
};
// //
const unitGroup = async () => { const unitGroup = async () => {
@ -366,18 +323,15 @@ const unitGroup = async () => {
} }
// //
const radioChangeEvent = ({row}) => { const radioChangeEvent = ({ row }) => {
data.selectUnitGroupId = row.id; data.selectUnitGroupId = row.id;
unitPage({groupUnitId: row.id}) unitPage({groupUnitId:row.id})
} }
const formInline = reactive({} as SysUnitInput) const formInline = reactive({} as SysUnitInput)
// //
const unitPage = async (parameter = formInline) => { const unitPage = async (parameter = formInline) => {
let res = await getAPI(SysUnitApi).apiSysUnitPagePost({ let res = await getAPI(SysUnitApi).apiSysUnitPagePost({pageSize:tableParams.value.pageSize,page:tableParams.value.page, ...parameter,...formInline });
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;
} }
@ -385,81 +339,53 @@ const unitPage = async (parameter = formInline) => {
// //
const handleSizeChange = (val: number) => { const handleSizeChange = (val: number) => {
tableParams.value.pageSize = val; tableParams.value.pageSize = val;
unitPage({groupUnitId: data.selectUnitGroupId}); unitPage({groupUnitId:data.selectUnitGroupId});
}; };
// //
const handleCurrentChange = (val: number) => { const handleCurrentChange = (val: number) => {
tableParams.value.page = val; tableParams.value.page = val;
unitPage({groupUnitId: data.selectUnitGroupId}); unitPage({groupUnitId:data.selectUnitGroupId});
}; };
const addUnit = () => { const addUnit= ()=>{
ruleFormRef.value?.resetFields(); unitFrom.value.codeNum = 'DW'+ getCurrentDate();
unitFrom.value = reactive({ }); dialogTableVisible.value=true;
unitFrom.value.codeNum = 'DW' + getCurrentDate(); mTitle.value='新增'
dialogTableVisible.value = true;
mTitle.value = '新增'
} }
// //
const unitSubmit = async () => { const unitSubmit = async () => {
ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
if (isValid) {
// //
let checkRes = await getAPI(SysUnitApi).apiSysUnitCheckPost(unitFrom.value); let checkRes = await getAPI(SysUnitApi).apiSysUnitCheckPost(unitFrom.value);
if (checkRes.data.code === 200) { if(checkRes.data.code === 200){
const item = checkRes.data.result; const item = checkRes.data.result;
if (mTitle.value == '新增') { if(mTitle.value=='新增'){
if (unitFrom.value.isBaseUnit && item != null) { if(unitFrom.value.isBaseUnit && item!=null){
ElMessage({message: '基本单位必须唯一', type: 'error',}); ElMessage({ message: '基本单位必须唯一', type: 'error', });
unitFrom.value.isBaseUnit = false; unitFrom.value.isBaseUnit = false;
return; return;
} }
let res = await getAPI(SysUnitApi).apiSysUnitAddPost(unitFrom.value); let res = await getAPI(SysUnitApi).apiSysUnitAddPost(unitFrom.value);
if (res.data.code === 200) { if (res.data.code===200) {
dialogTableVisible.value = false; dialogTableVisible.value = false;
await 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;
} }
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); let res = await getAPI(SysUnitApi).apiSysUnitUpdatePost(unitFrom.value);
if (res.data.code === 200) { if (res.data.code===200) {
dialogTableVisible.value = false; 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 getCurrentDate = () => {
@ -473,17 +399,13 @@ const getCurrentDate = () => {
return `${year}${month}${day}${hours}${minutes}${seconds}`; return `${year}${month}${day}${hours}${minutes}${seconds}`;
} }
const editUnit = async (row: any) => { const editUnit=async(row:any)=>{
ruleFormRef.value?.resetFields(); unitFrom.value=row;
unitFrom.value = reactive({ ...row }); mTitle.value='编辑'
mTitle.value = '编辑' dialogTableVisible.value=true;
dialogTableVisible.value = true;
} }
const deleteUnit = async (row: any) => { 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(`确定删除?`, '提示', { ElMessageBox.confirm(`确定删除?`, '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
@ -492,41 +414,34 @@ const deleteUnit = async (row: any) => {
.then(async () => { .then(async () => {
let res = await getAPI(SysUnitApi).apiSysUnitDeletePost(row); let res = await getAPI(SysUnitApi).apiSysUnitDeletePost(row);
if (res.data.code == 200) { if (res.data.code == 200) {
ElMessage({message: '成功', type: 'success',}) ElMessage({ message: '成功', type: 'success', })
unitPage({groupUnitId: data.selectUnitGroupId}); unitPage({groupUnitId:data.selectUnitGroupId});
//state.tableData.handleList(); //state.tableData.handleList();
} else } else
ElMessage.error(res.data.message!) ElMessage.error(res.data.message!)
}) })
.catch(() => { .catch(() => {});
});
}
} }
const addUnitGroup = () => { const addUnitGroup=()=>{
unitGroupRuleFormRef.value?.resetFields();
unitGroupModel = reactive({ }); isShowDialog.value=true
isShowDialog.value = true
} }
const editUnitGroup = (row: any) => { const editUnitGroup=async(row:any)=>{
unitGroupRuleFormRef.value?.resetFields(); 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)=>{
let checkRes = await getAPI(SysUnitGroupApi).apiSysUnitGroupCheckPost({Id: row.id}); let checkRes = await getAPI(SysUnitGroupApi).apiSysUnitGroupCheckPost({Id:row.id});
if (checkRes.data.code == 200) { if(checkRes.data.code == 200){
const result = checkRes.data.result; const result = checkRes.data.result;
if (result) { if(result){
return ElMessage.error("存在单位数据,不允许删除") 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(`确定删除?`, '提示', { ElMessageBox.confirm(`确定删除?`, '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
@ -536,17 +451,16 @@ const deleteUnitGroup = async (row: any) => {
console.log(row) console.log(row)
let res = await getAPI(SysUnitGroupApi).apiSysUnitGroupDeletePost(row); let res = await getAPI(SysUnitGroupApi).apiSysUnitGroupDeletePost(row);
if (res.data.code == 200) { if (res.data.code == 200) {
ElMessage({message: '成功', type: 'success',}) ElMessage({ message: '成功', type: 'success', })
unitGroup() unitGroup()
unitPage({groupUnitId: data.selectUnitGroupId}) unitPage({groupUnitId:data.selectUnitGroupId})
//state.tableData.handleList(); //state.tableData.handleList();
} else } else
ElMessage.error(res.data.message!) ElMessage.error(res.data.message!)
}) })
.catch(() => { .catch(() => {});
});
}
} }
} }
const pageVO1 = reactive({ const pageVO1 = reactive({
@ -557,7 +471,7 @@ const pageVO1 = reactive({
onMounted(() => { onMounted(() => {
unitGroup() unitGroup()
unitPage({groupUnitId: data.selectUnitGroupId}) unitPage({groupUnitId:data.selectUnitGroupId})
}) })
</script> </script>