| | |
| | | <template> |
| | | <el-container> |
| | | |
| | | <el-aside> |
| | | <basic-container> |
| | | <div ref="TreeBox" style="height: calc(100vh - 144px);!important;"> |
| | | <div ref="TreeBox" style="height: calc(100vh - 154px);!important;"> |
| | | <div class="headerCon"> |
| | | <el-button icon="el-icon-plus" plain size="small" type="primary" @click="addClickHandler">å建 |
| | | </el-button> |
| | | <el-button icon="el-icon-edit" plain size="small" type="primary" @click="editClickHandler">ä¿®æ¹ |
| | | </el-button> |
| | | <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delClickHandler">å é¤ |
| | | </el-button> |
| | | <el-button icon="el-icon-download" plain size="small" type="primary" @click="exportClickHandler">å¯¼åº |
| | | </el-button> |
| | | <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="uploadClickHandler">导å
¥ |
| | | </el-button> |
| | | <el-button class="smallBtn" plain size="small" type="primary" |
| | | @click="checkViewClickHandler">æ¥ç使ç¨èå´ |
| | | </el-button> |
| | | <avue-radio v-model="radioForm" :dic="radioDic" style="margin: 10px 0 5px"></avue-radio> |
| | | </div> |
| | | <!-- 左侧æ --> |
| | | <div style="height: calc(100vh - 280px);"> |
| | | <div style="height: calc(100vh - 230px);"> |
| | | <avue-tree :data="treeData" :option="treeOption" @node-click="nodeClick"> |
| | | <span slot-scope="{ node, data }" class="el-tree-node__label"> |
| | | <span style="font-size: 15px"> |
| | |
| | | |
| | | <el-main> |
| | | <basic-container> |
| | | 模æ¿å表ï¼<avue-select v-model="templateForm" placeholder="è¯·éæ©æ¨¡æ¿" type="tree" :dic="templateData" @change="changeTemp"></avue-select> |
| | | <avue-crud ref="queryCrud" |
| | | :data="attrData" :option="attrOption" :table-loading="tableLoading" style="margin-top: 10px"> |
| | | <template slot="menuLeft" slot-scope="scope"> |
| | | <el-button icon="el-icon-plus" size="small" type="primary" @click="addHandler">å建</el-button> |
| | | <el-button icon="el-icon-edit" plain size="small" type="primary" @click="editHandler">ä¿®æ¹</el-button> |
| | | <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delHandler">å é¤</el-button> |
| | | </template> |
| | | </avue-crud> |
| | | </basic-container> |
| | | </el-main> |
| | | |
| | | <!-- æ°å¢ && ç¼è¾ --> |
| | | <el-dialog |
| | | v-dialogDrag |
| | | :title="title === 'add' ? 'å建' : 'ä¿®æ¹'" |
| | | :visible.sync="visible" |
| | | append-to-body="true" |
| | | class="avue-dialog" |
| | | width="75%" |
| | | @close="addDialogClose"> |
| | | <el-form ref="form" :model="form" :rules="rules" label-width="95px"> |
| | | <el-form-item label="模æ¿åç§°ï¼" prop="name"> |
| | | <el-input v-model="form.name"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <avue-crud |
| | | ref="dialogCrud" |
| | | :data="attrData" |
| | | :option="dialogAttrOption" |
| | | @select="selectHandler"> |
| | | </avue-crud> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="addDialogClose">å æ¶</el-button> |
| | | <el-button type="primary" @click="addDialogSavaHandler">ç¡® å®</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </el-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import {getBizTypes, getAllAttributesByBtmId} from "@/api/modeling/businessType/api"; |
| | | import {gridLink,getAllAttributeByLink} from "@/api/modeling/linkType/api"; |
| | | import {gridTemplate,saveTemplate,updateTemplate,deleteTemplate} from "@/api/queryTemplate/queryDefine"; |
| | | import basicOption from "@/util/basic-option"; |
| | | import func from "@/util/func"; |
| | | |
| | | export default { |
| | | name: "index" |
| | | name: "index", |
| | | data() { |
| | | return{ |
| | | treeOption: { |
| | | height: 'auto', |
| | | defaultExpandAll: false, |
| | | menu: false, |
| | | addBtn: false, |
| | | props: { |
| | | label: 'label', |
| | | value: 'oid', |
| | | children: 'children' |
| | | } |
| | | }, |
| | | nodeRow:{}, |
| | | treeData: [], |
| | | radioForm:0, |
| | | radioDic:[{ |
| | | label:'ä¸å¡ç±»å', |
| | | value:0 |
| | | },{ |
| | | label:'龿¥ç±»å', |
| | | value:1 |
| | | }], |
| | | templateForm:'', |
| | | templateData:[], |
| | | form :{ |
| | | abNames:[], |
| | | linkTypeName: "",//左侧éç龿¥ç±»ååç§° |
| | | btmName:'',//左侧鿩çä¸å¡ç±»ååç§° |
| | | name:'' |
| | | }, |
| | | rules: { |
| | | name: [ |
| | | {required: true, message: '请è¾å
¥æ¨¡æ¿åç§°', trigger: 'blur'} |
| | | ] |
| | | }, |
| | | attrData: [], |
| | | title: '', |
| | | visible: false, |
| | | tableLoading: false, |
| | | attrOption: { |
| | | ...basicOption, |
| | | addBtn: false, |
| | | editBtn: false, |
| | | delBtn: false, |
| | | selection: true, |
| | | selectable:function (){ |
| | | return false; |
| | | }, |
| | | menu:false, |
| | | height: "auto", |
| | | calcHeight: -40, |
| | | title:'æ¥è¯¢å±æ§', |
| | | tip:false, |
| | | column: [{ |
| | | label: 'åæ®µç¼ç ', |
| | | prop: 'id' |
| | | }, |
| | | { |
| | | label: 'åæ®µåç§°', |
| | | prop: 'name' |
| | | }] |
| | | }, |
| | | selectionRow:[], |
| | | dialogAttrOption: { |
| | | ...basicOption, |
| | | addBtn: false, |
| | | editBtn: false, |
| | | delBtn: false, |
| | | selection: true, |
| | | menu:false, |
| | | height: "auto", |
| | | calcHeight: 140, |
| | | title:'æ¥è¯¢å±æ§', |
| | | tip:false, |
| | | header:false, |
| | | column: [{ |
| | | label: 'åæ®µç¼ç ', |
| | | prop: 'id' |
| | | }, |
| | | { |
| | | label: 'åæ®µåç§°', |
| | | prop: 'name' |
| | | }] |
| | | }, |
| | | dialogSelectionRow:[] |
| | | } |
| | | }, |
| | | created() { |
| | | this.getTreeList(); |
| | | }, |
| | | watch: { |
| | | radioForm: { |
| | | handler(newval) { |
| | | const loading = this.$loading({}); |
| | | if (newval ==0) { |
| | | getBizTypes().then(res => { |
| | | const data = res.data.data.map(item => { |
| | | item.label=item.attributes.id; |
| | | return item; |
| | | }); |
| | | this.treeData = data; |
| | | loading.close(); |
| | | }) |
| | | }else { |
| | | gridLink().then(res => { |
| | | const data = res.data.data.map(item => { |
| | | item.label=item.name; |
| | | return item; |
| | | }); |
| | | this.treeData = data; |
| | | loading.close(); |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | methods: { |
| | | //æ 表æ¥è¯¢ |
| | | getTreeList() { |
| | | const loading = this.$loading({}); |
| | | getBizTypes().then(res => { |
| | | const data = res.data.data.map(item => { |
| | | item.label=item.attributes.id; |
| | | return item; |
| | | }); |
| | | this.treeData = data; |
| | | loading.close(); |
| | | }) |
| | | }, |
| | | |
| | | // æ ç¹å» |
| | | nodeClick(row) { |
| | | this.nodeRow = row; |
| | | this.tableLoading = true; |
| | | if(this.radioForm==1){ |
| | | //龿¥ç±»å |
| | | getAllAttributeByLink({name:row.label,linkFlag:true}).then(res => { |
| | | this.attrData = res.data.data; |
| | | this.getTemp(); |
| | | }) |
| | | }else { |
| | | //ä¸å¡ç±»å |
| | | getAllAttributesByBtmId({btmId:row.label,linkFlag:false}).then(res => { |
| | | this.attrData = res.data.data; |
| | | this.getTemp(); |
| | | }) |
| | | } |
| | | }, |
| | | getTemp() { |
| | | gridTemplate({btmName: this.nodeRow.label, linkFlag: this.radioForm == 1}).then(res => { |
| | | const data = res.data.data.map(item => { |
| | | item.label = item.name; |
| | | item.value = item.name; |
| | | return item; |
| | | }); |
| | | this.templateData = data; |
| | | if (res.data.data.length > 0) { |
| | | this.templateForm = this.templateData[0].value; |
| | | } else { |
| | | this.templateForm = ''; |
| | | this.$refs.queryCrud.clearSelection(); |
| | | } |
| | | this.tableLoading = false; |
| | | }) |
| | | }, |
| | | selectHandler(selection, row){debugger; |
| | | this.dialogSelectionRow=selection |
| | | }, |
| | | changeTemp(data) { |
| | | this.$refs.queryCrud.clearSelection(); |
| | | if (data.value != '') { |
| | | let abNames = data.item.abNames.join(',').toLowerCase().split(',') |
| | | this.selectionRow = this.attrData.filter(item => { |
| | | return abNames.includes(item.id.toLowerCase()) |
| | | }) |
| | | this.$refs.queryCrud.toggleSelection(this.selectionRow); |
| | | } |
| | | }, |
| | | //å建 |
| | | addHandler(){ |
| | | if (func.isEmptyObject(this.nodeRow)) { |
| | | this.$message.error('è¯·éæ©è¦æ·»å çèç¹'); |
| | | return; |
| | | } |
| | | this.title = 'add'; |
| | | this.visible = true; |
| | | this.$nextTick(()=>{ |
| | | this.$refs.dialogCrud.clearSelection(); |
| | | }); |
| | | }, |
| | | //ä¿®æ¹ |
| | | editHandler(){ |
| | | if (func.isEmptyObject(this.nodeRow)) { |
| | | this.$message.error('请è³å°éæ©ä¸æ¡æ°æ®'); |
| | | return; |
| | | } |
| | | this.form.name = this.templateForm; |
| | | this.title = 'edit'; |
| | | this.visible = true; |
| | | this.$nextTick(()=>{ |
| | | this.dialogSelectionRow=this.selectionRow; |
| | | this.$refs.dialogCrud.clearSelection(); |
| | | this.$refs.dialogCrud.toggleSelection(this.dialogSelectionRow ); |
| | | }); |
| | | }, |
| | | // æ°å¢ç¼è¾ä¿å |
| | | addDialogSavaHandler() { |
| | | this.$refs.form.validate((valid) => { |
| | | const saveFunction = this.title === 'add' ? saveTemplate : updateTemplate; |
| | | if (valid) { |
| | | if(this.radioForm == 0){ |
| | | this.form.btmName=this.nodeRow.label; |
| | | delete this.form.linkTypeName |
| | | }else { |
| | | this.form.linkTypeName=this.nodeRow.label; |
| | | delete this.form.btmName |
| | | } |
| | | let abNames=this.dialogSelectionRow.map(item => { |
| | | return item.id |
| | | }) |
| | | if(abNames.length==0){ |
| | | this.$message.error('è¯·éæ©æ¥è¯¢å±æ§'); |
| | | return false; |
| | | } |
| | | this.form.abNames=abNames; |
| | | saveFunction(this.form).then(res => { |
| | | if (res.data.code === 200) { |
| | | this.$message.success(res.data.obj); |
| | | if(this.title === 'edit'){ |
| | | this.templateForm=''; |
| | | } |
| | | this.getTemp(); |
| | | this.addDialogClose(); |
| | | } |
| | | }) |
| | | } else { |
| | | return false; |
| | | } |
| | | }); |
| | | }, |
| | | // æ°å¢ç¼è¾å¯¹è¯æ¡åæ¶ |
| | | addDialogClose() { |
| | | this.form = { |
| | | abNames:[], |
| | | linkTypeName: "",//左侧éç龿¥ç±»ååç§° |
| | | btmName:'',//左侧鿩çä¸å¡ç±»ååç§° |
| | | name:'' |
| | | }; |
| | | this.$refs.form.clearValidate(); |
| | | this.visible = false; |
| | | }, |
| | | //å é¤ |
| | | delHandler(){ |
| | | if (func.isEmptyObject(this.nodeRow)) { |
| | | this.$message.error('è¯·éæ©æ°æ®'); |
| | | return; |
| | | } |
| | | this.$confirm('æ¨ç¡®å®è¦å é¤æéæ©çæ°æ®åï¼', 'æç¤º', { |
| | | confirmButtonText: 'ç¡®å®', |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | deleteTemplate({name:this.templateForm,btmName: this.nodeRow.label, linkFlag: this.radioForm == 1}).then(res => { |
| | | if (res.data.code === 200) { |
| | | this.$message.success(res.data.obj); |
| | | this.getTemp(); |
| | | } |
| | | }) |
| | | }).catch(() => { |
| | | this.$message({ |
| | | type: 'info', |
| | | message: '已忶å é¤' |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |