| | |
| | | <template> |
| | | <div> |
| | | <div style="display: flex;flex-wrap: wrap;" v-if="this.crudArrayFlag" class="app"> |
| | | |
| | | <div style="display: flex;flex-wrap: wrap; display: inline-block" v-if="this.crudArrayFlag" class="app" > |
| | | <el-button-group> |
| | | <!--新增--> |
| | | <el-button v-if="attrEditVisible == false && attrFlagChiledren==false && editOpenFlag && (!checkStatus || crudLCStatus=='Editing' )" size="small" type="primary" icon="el-icon-plus" plain @click="busineHandle">添加 {{ msg }}</el-button> |
| | |
| | | <el-dialog :visible.sync="enumVisible" append-to-body title="枚举注入" :before-close="this.enumBeforeClose"> |
| | | <!-- 渲染表格及按钮 --> |
| | | <!-- 渲染表格及按钮 --> |
| | | <el-alert |
| | | title="请新增后点击单元格输入枚举数据" |
| | | type="success" |
| | | style="margin-bottom: 10px;display: inline-block" |
| | | :closable="false"> |
| | | </el-alert> |
| | | <div> |
| | | <el-button icon="el-icon-plus" type="primary" @click="addRow">新增</el-button> |
| | | <el-table :data="tableData" style="width: 100%" @cell-click="handleCellClick" |
| | |
| | | </div> |
| | | </el-dialog> |
| | | <!-- 属性分组--> |
| | | <el-dialog :visible.sync="attrVisible" append-to-body style="width: 800px; left:30vw;top: 10vh ;" |
| | | <el-dialog :visible.sync="attrVisible" append-to-body :before-close="attrClose" style="width: 800px; left:30vw;top: 10vh ;" |
| | | title="输入分组的名称"> |
| | | <el-form ref="form" label-width="70px"> |
| | | <el-form-item label="属性分组"> |
| | |
| | | <script> |
| | | import {AttrByBtm, gridCodeClassifyTemplateAttr, batchAddSave, copyto,listByFlag} from '@/api/template/templateAttr' |
| | | import {getList} from "@/api/refer/table"; |
| | | import func from "@/util/func"; |
| | | |
| | | export default { |
| | | name: "attrCrud .vue", |
| | |
| | | } |
| | | } |
| | | }, |
| | | crudArrayFlag:{ |
| | | handler(newval,olaval){ |
| | | console.log('crudArrayFlag',newval) |
| | | } |
| | | }, |
| | | crudArray:{ |
| | | handler(newval,oldval){ |
| | | console.log('crudArray',newval) |
| | | if(newval != undefined){ |
| | | if(newval.length>=1){ |
| | | this.crudArrayFlag=true |
| | |
| | | }else { |
| | | this.$set(this.attrSelectList[0], 'attributeGroup', this.attrModel) |
| | | } |
| | | this.attrModel = ""; |
| | | this.attrVisible = false; |
| | | this.attrClose() |
| | | }, |
| | | //属性分组清空 |
| | | attrRemove() { |
| | | this.attrModel = "" |
| | | }, |
| | | attrClose(){ |
| | | this.attrModel = ""; |
| | | this.attrVisible=false |
| | | }, |
| | | //表格数据 |
| | | CrudRend() { |
| | |
| | | }, |
| | | //保存 |
| | | addsHandler(event) { |
| | | batchAddSave(JSON.parse(JSON.stringify(this.ProData))).then(res => { |
| | | this.$message.success('保存成功') |
| | | this.editOpenFlag=false; |
| | | this.$emit('editCloseChildren') |
| | | }).catch(()=>{ |
| | | this.$message.warning('保存失败,请查看控制台输出!') |
| | | this.$refs.referAttrCrud.sort("orderNum"); |
| | | var ischeck = true; |
| | | console.log(this.ProData) |
| | | this.ProData.forEach((item,index)=>{ |
| | | if((item.requireFlag && item.requireFlag.toString()=='true') && (item.readOnlyFlag && item.readOnlyFlag.toString()=='true')){ |
| | | this.$message.warning(item.name+"("+item.id+")必输的属性不能是只读"); |
| | | console.log(item) |
| | | ischeck=false; |
| | | return; |
| | | } |
| | | var num=0; |
| | | if(item.componentRule){ |
| | | //组合规则 |
| | | num++ |
| | | } |
| | | if(item.enumString || item.enumId){ |
| | | //枚举 |
| | | num++ |
| | | } |
| | | if(item.referConfig || item.referBtmId){ |
| | | //参照 |
| | | num++ |
| | | } |
| | | if(item.codeDateFormat){ |
| | | //时间格式 |
| | | num++ |
| | | } |
| | | if(item.classifyInvokeLevel){ |
| | | //分类注入 |
| | | num++ |
| | | } |
| | | if(num>1 && ischeck){ |
| | | this.$message({ |
| | | showClose: true, |
| | | message: item.name+"("+item.id+") 属性只能是组合规则,枚举,参照,时间格式,分类注入中的一种", |
| | | type: 'warning' |
| | | }); |
| | | ischeck=false; |
| | | return; |
| | | } |
| | | }) |
| | | if(!ischeck){ |
| | | return ; |
| | | } |
| | | // 新函数用于执行batchAddSave方法 |
| | | const executeBatchAddSave = () => { |
| | | batchAddSave(JSON.parse(JSON.stringify(this.ProData))).then(res => { |
| | | this.$message.success('保存成功') |
| | | this.editOpenFlag=false; |
| | | // 调用父组件修改按钮状态 |
| | | this.$emit('editCloseChildren') |
| | | }).catch(()=>{ |
| | | this.$message.warning('保存失败,请查看控制台输出!') |
| | | }); |
| | | } |
| | | // 所有if条件和逻辑通过后调用executeBatchAddSave函数 |
| | | executeBatchAddSave(); |
| | | }, |
| | | //表格行编辑 |
| | | handleCellClicks(row, column) { |
| | |
| | | this.rulesVisible=true; |
| | | }else if(column.property == 'attributeGroup'){ |
| | | this.attrVisible = true; |
| | | if(this.CurrentCell.attributeGroup !== ''){ |
| | | this.attrModel=this.CurrentCell.attributeGroup |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | //枚举注入保存 |
| | | enumAddHandle() { |
| | | let hasError = false; // 添加一个变量 |
| | | this.tableData.forEach((item, index) => { |
| | | if (item.key === '') { |
| | | this.$message.warning(`第${index + 1}行的选项值不能为空`); |
| | | hasError = true; |
| | | return; |
| | | } else if (item.value === '') { |
| | | this.$message.warning(`第${index + 1}行的选项中文标签不能为空`); |
| | | hasError = true; |
| | | return; |
| | | } |
| | | }); |
| | | // 保存执行逻辑 |
| | | if (!hasError) { |
| | | if (this.CurrentCell) { |
| | | this.$set(this.CurrentCell, 'enumString', JSON.stringify(this.tableData)); |
| | | this.enumVisible = false; |
| | | } else { |
| | | this.$set(this.attrSelectList[0], 'enumString', JSON.stringify(this.tableData)); |
| | | this.tableData=[]; |
| | | this.enumVisible = false; |
| | | } |
| | | } |
| | | if(this.tableData.length>=1){ |
| | | let hasError = false; // 添加一个变量 |
| | | this.tableData.forEach((item, index) => { |
| | | if (item.key === '') { |
| | | this.$message.warning(`第${index + 1}行的选项值不能为空`); |
| | | hasError = true; |
| | | return; |
| | | } else if (item.value === '') { |
| | | this.$message.warning(`第${index + 1}行的选项中文标签不能为空`); |
| | | hasError = true; |
| | | return; |
| | | } |
| | | }); |
| | | // 保存执行逻辑 |
| | | if (!hasError) { |
| | | if (this.CurrentCell) { |
| | | this.$set(this.CurrentCell, 'enumString', JSON.stringify(this.tableData)); |
| | | this.enumVisible = false; |
| | | } else { |
| | | this.$set(this.attrSelectList[0], 'enumString', JSON.stringify(this.tableData)); |
| | | this.tableData=[]; |
| | | this.enumVisible = false; |
| | | } |
| | | } |
| | | }else { |
| | | this.$message.warning('请添加枚举注入数据!') |
| | | } |
| | | }, |
| | | // 将正在编辑的行的状态变为 null,即退出编辑状态 |
| | | saveRow() { |