|
@@ -3,25 +3,16 @@
|
|
|
<div class="page-side">
|
|
|
<el-scrollbar style="height:100%;padding:5px;box-sizing: border-box;">
|
|
|
<el-tree :data="treeNodes" :props="treeNodeProps" :highlight-current="true" class="tree" @node-click="nodeClickHandle">
|
|
|
- <template #default="{ node, data }">
|
|
|
- <span class="custom-tree-node">
|
|
|
- <template v-if="node.isLeaf">
|
|
|
- <el-icon><Tools/></el-icon><span style="margin-left:2px;">{{ node.label }}</span>
|
|
|
- </template>
|
|
|
-
|
|
|
- <span v-else>{{ node.label }}</span>
|
|
|
-
|
|
|
- </span>
|
|
|
- </template>
|
|
|
+
|
|
|
</el-tree>
|
|
|
</el-scrollbar>
|
|
|
</div>
|
|
|
<div class="page-split"></div>
|
|
|
<div class="page-main">
|
|
|
- <el-form :model="formModel" label-position="right" label-width="auto" :inline="false" :rules="rules" :inline-message="true">
|
|
|
+ <el-form :model="formModel" ref="formcomp" label-position="right" label-width="auto" :inline="false" :rules="rules" :inline-message="true">
|
|
|
<el-form-item label="上级编码名">
|
|
|
- <el-input v-model="formModel.fatherCodeName" autocomplete="off" class="edit-form-item" :readonly="true"/>
|
|
|
- <el-button type="primary" plain size="default">清除</el-button>
|
|
|
+ <el-tree-select v-model="formModel.fatherCodeId" :data="treeNodes" :props="treeNodeProps" :render-after-expand="false" check-strictly class="edit-form-item"/>
|
|
|
+ <el-button type="primary" plain size="default" @click="clearSuperHandle">清除</el-button>
|
|
|
<span class="footnote">(为空表示顶级)</span>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="编码">
|
|
@@ -36,7 +27,7 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="显示序号">
|
|
|
- <el-input v-model="formModel.displayNum" autocomplete="off" class="edit-form-item" clearable/>
|
|
|
+ <el-input-number v-model="formModel.displayNum" :min="1" :max="10000"/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
@@ -63,9 +54,9 @@
|
|
|
|
|
|
|
|
|
<el-form-item label=" ">
|
|
|
- <el-button type="primary">保存</el-button>
|
|
|
- <el-button type="success">新增</el-button>
|
|
|
- <el-button>删除</el-button>
|
|
|
+ <el-button type="primary" @click="saveSubmit">保存</el-button>
|
|
|
+ <el-button type="success" @click="addSubmit">新增</el-button>
|
|
|
+ <el-button @click="delSubmit">删除</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
@@ -73,22 +64,24 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
- import {ref,reactive} from 'vue'
|
|
|
- import sidetreeAPI from "../../api/sidetree.js"
|
|
|
+ import {ref,reactive,toRaw } from 'vue'
|
|
|
+ import sortCodeAPI from "../../api/sortCode.js"
|
|
|
+ import utils from "../../utils/utils.js"
|
|
|
+ import {ElMessageBox,ElMessage} from 'element-plus'
|
|
|
|
|
|
const treeNodes = ref([])
|
|
|
|
|
|
const treeNodeProps = {
|
|
|
children: 'children',
|
|
|
- label: 'label',
|
|
|
- isLeaf:'leaf'
|
|
|
+ label: 'codeName',
|
|
|
+ value:'codeId'
|
|
|
}
|
|
|
|
|
|
const formModel = reactive({
|
|
|
fatherCodeName:null,
|
|
|
codeId: '',
|
|
|
codeName:'',
|
|
|
- displayNum:'',
|
|
|
+ displayNum:1,
|
|
|
assistCode:'',
|
|
|
spare1:null,
|
|
|
spare2:null,
|
|
@@ -96,16 +89,9 @@
|
|
|
spare4:null
|
|
|
})
|
|
|
|
|
|
- const nodeClickHandle=()=>{
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- const getData = () => {
|
|
|
- sidetreeAPI.fetchData({}).then((res) => {
|
|
|
- treeNodes.value=res
|
|
|
- });
|
|
|
- };
|
|
|
- getData();
|
|
|
+ const formcomp = ref(null);
|
|
|
+
|
|
|
|
|
|
const rules =reactive({
|
|
|
codeName:[
|
|
@@ -113,6 +99,121 @@
|
|
|
{ min: 3, max: 20, message: '编码名长度应该为3-20', trigger: 'blur' }
|
|
|
]
|
|
|
})
|
|
|
+
|
|
|
+
|
|
|
+ const getData = () => {
|
|
|
+ let converDef={id:'codeId',name:'codeName',superId:'fatherCodeId',superName:'fatherCodeName',children:'children'}
|
|
|
+ sortCodeAPI.fetchData().then((resp) => {
|
|
|
+ console.log(resp)
|
|
|
+ if(resp.code===0){
|
|
|
+ let treeDatas=utils.list2Tree(resp.data||[],converDef)
|
|
|
+ console.log(treeDatas['topNodes'])
|
|
|
+ treeNodes.value=treeDatas['topNodes']
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ console.log(resp.msg)
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ };
|
|
|
+ getData();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const nodeClickHandle = (item) =>{
|
|
|
+ console.log(item)
|
|
|
+
|
|
|
+ let {fatherCodeName,fatherCodeId,codeId,codeName,displayNum,assistCode,spare1,spare2,spare3,spare4}=item
|
|
|
+ fatherCodeId=fatherCodeId=='0'?null:fatherCodeId
|
|
|
+ Object.assign(formModel,{fatherCodeName,fatherCodeId,codeId,codeName,displayNum,assistCode,spare1,spare2,spare3,spare4})
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const clearForm=()=>{
|
|
|
+ let [fatherCodeName,fatherCodeId,codeId,codeName,displayNum,assistCode,spare1,spare2,spare3,spare4]=[null,null,null,null,null,null,null,null,null,null]
|
|
|
+ Object.assign(formModel,{fatherCodeName,fatherCodeId,codeId,codeName,displayNum,assistCode,spare1,spare2,spare3,spare4})
|
|
|
+ }
|
|
|
+
|
|
|
+ const clearSuperHandle=()=>{
|
|
|
+ formModel.fatherCodeName=''
|
|
|
+ formModel.fatherCodeId=''
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const saveSubmit=()=>{
|
|
|
+ formcomp.value.validate((valid) => {
|
|
|
+ if(!valid){
|
|
|
+ ElMessage.error("请按要求填写数据");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sortCodeAPI.save(toRaw(formModel)).then(resp=>{
|
|
|
+ if(resp.code!=0){
|
|
|
+ ElMessage.error(resp.msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ElMessage.success('操作成功')
|
|
|
+ getData();
|
|
|
+
|
|
|
+ }).catch(err=>{
|
|
|
+ ElMessage.error(err||'操作失败')
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const addSubmit=()=>{
|
|
|
+ formcomp.value.validate((valid) => {
|
|
|
+ if(!valid){
|
|
|
+ ElMessage.error("请按要求填写数据");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sortCodeAPI.add(toRaw(formModel)).then(resp=>{
|
|
|
+ if(resp.code!=0){
|
|
|
+ ElMessage.error(resp.msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ElMessage.success('操作成功')
|
|
|
+ clearForm()
|
|
|
+ getData();
|
|
|
+
|
|
|
+ }).catch(err=>{
|
|
|
+ ElMessage.error(err||'操作失败')
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ const delSubmit=()=>{
|
|
|
+ if(!formModel.codeId){
|
|
|
+ ElMessage.error("请先选择一个编码,再继续");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ '确定要删除吗?',
|
|
|
+ '操作确认',
|
|
|
+ {
|
|
|
+ confirmButtonText:'确定',
|
|
|
+ cancelButtonText:'取消',
|
|
|
+ type: 'warning'
|
|
|
+ }
|
|
|
+ ).then(()=>{
|
|
|
+ sortCodeAPI.del({codeId:formModel.codeId}).then(resp=>{
|
|
|
+ if(resp.code!=0){
|
|
|
+ ElMessage.error(resp.msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ElMessage.success('操作成功')
|
|
|
+ clearForm()
|
|
|
+ getData();
|
|
|
+
|
|
|
+ }).catch(err=>{
|
|
|
+ ElMessage.error(err||'操作失败')
|
|
|
+ })
|
|
|
+
|
|
|
+ }).catch(()=>{
|
|
|
+ console.log('cancel del')
|
|
|
+ })
|
|
|
+ }
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
@@ -147,4 +248,6 @@
|
|
|
font-size:12px;
|
|
|
color:#999;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
</style>
|