| | |
| | | <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" |
| | |
| | | }, |
| | | //枚举注入保存 |
| | | 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() { |