田源
2023-10-12 b4c7c6a738f44afadbc388bb774ac044e7fafe38
Source/UBCS-WEB/src/components/Theme/ThemeAttrCrud.vue
@@ -23,7 +23,8 @@
      </el-button-group>
      <el-button-group>
        <!--    保存-->
        <el-button v-if="(!checkStatus|| crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-check" plain size="small"
        <el-button v-if="(!checkStatus|| crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-check" plain
                   size="small"
                   type="success" @click.prevent="addsHandler">保存
        </el-button>
        <!--    预览排序-->
@@ -67,23 +68,26 @@
      </el-button-group>
      <!-- 是否开启编辑     -->
      <el-button-group>
        <el-button v-if="(!checkStatus|| crudLCStatus=='Editing') && !editOpenFlag && attrEditVisible == false && attrFlagChiledren==false" icon="el-icon-view" plain
                   size="small"
                   @click="editOpen">开启编辑
        <el-button
          v-if="(!checkStatus|| crudLCStatus=='Editing') && !editOpenFlag && attrEditVisible == false && attrFlagChiledren==false"
          icon="el-icon-view" plain
          size="small"
          @click="editOpen">开启编辑
        </el-button>
        <el-select v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" v-model="selectvalue"
                   placeholder="请选择"
                   size="small">
          <el-option
            v-for="item in selectoptions"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
        <el-switch v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" v-model="switchvalue"
                   active-value="true" style="margin:6px 0 0 10px" @change="batchSetFlag">
        </el-switch>
      </el-button-group>
      <el-select v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" v-model="selectvalue" placeholder="请选择"
                 size="small">
        <el-option
          v-for="item in selectoptions"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
      <el-switch v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" v-model="switchvalue"
                 active-value="true" style="margin:6px 0 0 10px" @change="batchSetFlag">
      </el-switch>
    </div>
    <!--    弹窗-->
    <div>
@@ -325,18 +329,20 @@
                       align="center"
      >
        <template slot-scope="{ row }">
          <el-input v-if="editingRows === row && editShows== item.prop && item.prop != 'codeDateFormat' && (item.edit == 'text'  ||item.edit == 'refer' )"
                    ref="inputRef"
                    :id="'inputRef' + row.oid"
                    v-show="!AddCellFlag"
                    v-model="row[item.prop]"
                    @blur="saveRows"
                    autofocus></el-input>
          <el-input-number v-if="editingRows === row && editShows== item.prop && item.edit == 'number'" v-model="row[item.prop]"
          <el-input
            v-if="editingRows === row && editShows== item.prop && item.prop != 'codeDateFormat' && (item.edit == 'text'  ||item.edit == 'refer' )"
            v-show="!AddCellFlag"
            :ref="'input' + row.oid"
            v-model="row[item.prop]"
            @blur="saveRows(row)"
          ></el-input>
          <el-input-number v-if="editingRows === row && editShows== item.prop && item.edit == 'number'"
                           v-model="row[item.prop]"
                           :style="{width:(item.width-10)+'px'}"
                           controls-position="right"
                           size="small" @blur="saveRows"></el-input-number>
          <el-select v-if="editingRows === row && editShows== item.prop && item.edit == 'select' " slot="prepend" v-model="row[item.prop]" allow-create default-first-option
          <el-select v-if="editingRows === row && editShows== item.prop && item.edit == 'select' " slot="prepend"
                     v-model="row[item.prop]" allow-create default-first-option
                     filterable
                     @blur="selectChangeHandler(item.editConfig,index)">
            <el-option
@@ -432,7 +438,7 @@
    },
    crudArrayFlag: {
      handler(newval, oldval) {
        console.log('crudArrayFlag', newval)
        // console.log('crudArrayFlag', newval)
      }
    },
    crudArray: {
@@ -476,7 +482,7 @@
    },
    editOpenFlag: {
      handler(newval, oldval) {
        console.log('editOpenFlag', newval)
        // console.log('editOpenFlag', newval)
      },
      deep: true,
      immediate: true
@@ -486,7 +492,7 @@
  data() {
    return {
      // 保存单元格状态
      AddCellFlag:false,
      AddCellFlag: false,
      //全屏编辑高度状态
      editStyleFlag: false,
      loading: false,
@@ -633,6 +639,7 @@
        addBtn: false,
        header: false,
        align: 'center',
        columnBtn:false,
        menuAlign: 'center',
        column: [{
          label: '',
@@ -847,6 +854,7 @@
          {
            label: "参照配置",
            prop: "referConfig",
            width: 105
          },
          {
            label: "级联查询属性",
@@ -891,7 +899,7 @@
          {
            label: "取值范围",
            prop: "valueArea",
          },
          }
        ]
      },
      // 存储表格数据
@@ -1082,12 +1090,12 @@
          {
            label: "属性英文名称",
            prop: "id",
            width:100,
            width: 100,
          },
          {
            label: "属性中文名称",
            prop: "name",
            width:100,
            width: 100,
          },
          {
            label: "长度",
@@ -1168,6 +1176,7 @@
      List: [],
      option: {
        index: false,
        columnBtn:false,
        border: true,
        editBtn: false,
        selection: true,
@@ -1745,11 +1754,9 @@
    addsHandler(event) {
      this.$refs.referAttrCrud.sort("orderNum");
      var ischeck = true;
      console.log('ProData',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;
        }
@@ -1757,29 +1764,23 @@
        if (item.componentRule) {
          //组合规则
          num++
          console.log('componentRule', num)
        }
        if (item.enumString || item.enumId) {
          //枚举
          num++
          console.log('enumString', num)
        }
        if (item.referConfig || item.referBtmId) {
          //参照
          num++
          console.log('referConfig', num)
        }
        if (item.codeDateFormat) {
          //时间格式
          num++
          console.log('codeDateFormat', num)
        }
        //如果空后台返回none
        if (item.classifyInvokeLevel && item.classifyInvokeLevel != 'none') {
          //分类注入
          num++
          console.log('classifyInvokeLevel', num)
          console.log(item.classifyInvokeLevel)
        }
        if (num > 1 && ischeck) {
          this.$message({
@@ -1801,7 +1802,7 @@
          this.editOpenFlag = false;
          // 调用父组件修改按钮状态
          this.$emit('editCloseChildren')
          this.AddCellFlag=true;
          this.AddCellFlag = true;
        }).catch(() => {
          this.$message.warning('保存失败,请查看控制台输出!')
        });
@@ -1816,74 +1817,82 @@
        this.editShows = column.property;
        this.rowOid = row.oid;
        this.CurrentCell = row;
        if(this.editingRows){
          const inputElement = document.querySelector(`#inputRef${row.oid}`);
          if (inputElement) {
            inputElement.focus();
          };
        }
        if (column.property == 'referConfig') {
          this.referConfigVisble = true;
          this.referConfigOption = {
            referConfig: this.CurrentCell.referConfig || '',
        this.$nextTick(() => {
          const inputs = this.$refs['input' + row.oid];
          const input = inputs && inputs.length > 0 ? inputs[0].$el : null;
          if (input) {
            input.focus();
          }
          if (this.CurrentCell.referConfig == '') {
        });
        const columnActions = {
          referConfig: () => {
            this.referConfigVisble = true;
            this.referConfigOption = {
              referConfig: '',
              referConfig: this.CurrentCell.referConfig || '',
            }
            if (this.CurrentCell.referConfig == '') {
              this.referConfigOption = {
                referConfig: '',
              }
            }
          },
          classifyInvokeText: () => {
            this.injectVisible = true;
            if (this.CurrentCell.classifyInvokeAttr != '') {
              this.injectOption = {
                classifyInvokeAttr: this.CurrentCell.classifyInvokeAttr,
                classifyInvokeAttrName: this.CurrentCell.classifyInvokeAttrName,
                classifyInvokeEditFlag: this.CurrentCell.classifyInvokeEditFlag,
                classifyInvokeLevel: this.CurrentCell.classifyInvokeLevel == 'min' ? 'min' : 'max',
                classifyNumber: this.CurrentCell.classifyInvokeLevel == 'min' ? '' : this.CurrentCell.classifyInvokeLevel
              };
            }
          },
          componentRule: () => {
            this.isShowformulaEdit = true;
          },
          enumString: () => {
            this.enumVisible = true;
            this.tableData = [];
            if (this.CurrentCell.enumString != "") {
              this.tableData = JSON.parse(this.CurrentCell.enumString)
              return;
            }
          },
          parentCode: () => {
            gridCodeClassifyTemplateAttr({
              'conditionMap[classifyTemplateOid]': this.Formlist[0].oid,
              'conditionMap[oid_notequal]': this.CurrentCell.oid,
              limit: -1
            }).then(res => {
              this.CascadeData = res.data.data;
            })
            this.CascadeVisible = true;
          },
          verifyRule: () => {
            this.RulesForm.expressionTextt = this.CurrentCell.verifyRule;
            this.rulesVisible = true;
          },
          attributeGroup: () => {
            this.attrVisible = true;
            if (this.CurrentCell.attributeGroup !== '') {
              this.attrModel = this.CurrentCell.attributeGroup
            }
          }
          // this.$refs.referConfigFormDialog.onloadAttrData();
        } else if (column.property == 'classifyInvokeText') {
          this.injectVisible = true;
          if (this.CurrentCell.classifyInvokeAttr != '') {
            this.injectOption = {
              classifyInvokeAttr: this.CurrentCell.classifyInvokeAttr,
              classifyInvokeAttrName: this.CurrentCell.classifyInvokeAttrName,
              classifyInvokeEditFlag: this.CurrentCell.classifyInvokeEditFlag,
              classifyInvokeLevel: this.CurrentCell.classifyInvokeLevel == 'min' ? 'min' : 'max',
              classifyNumber: this.CurrentCell.classifyInvokeLevel == 'min' ? '' : this.CurrentCell.classifyInvokeLevel
            };
          } else {
            // this.injectHandleReset();
          }
        } else if (column.property == 'componentRule') {
          if (this.CurrentCell) {
            // this.CurrentCell.componentRule = this.componentRuleText;
          }
          this.isShowformulaEdit = true;
        } else if (column.property == 'enumString') {
          this.enumVisible = true;
          if (this.attrSelectList[0].enumString != "") {
            this.tableData = JSON.parse(this.attrSelectList[0].enumString)
            return
          }
        } else if (column.property == 'parentCode') {
          gridCodeClassifyTemplateAttr({
            'conditionMap[classifyTemplateOid]': this.Formlist[0].oid,
            'conditionMap[oid_notequal]': this.CurrentCell.oid,
            limit: -1
          }).then(res => {
            this.CascadeData = res.data.data;
          })
          this.CascadeVisible = true;
        } else if (column.property == 'verifyRule') {
          this.RulesForm.expressionTextt = this.CurrentCell.verifyRule;
          this.rulesVisible = true;
        } else if (column.property == 'attributeGroup') {
          this.attrVisible = true;
          if (this.CurrentCell.attributeGroup !== '') {
            this.attrModel = this.CurrentCell.attributeGroup
          }
        };
        if (column.property in columnActions) {
          columnActions[column.property]();
        }
      }
    },
    saveRows() {
      this.editingRows = null;
      this.editShows = null;
      const inputElement = document.querySelector(`#inputRef${this.CurrentCell.oid}`);
      if (inputElement) {
        inputElement.blur();
      }
      // const inputElement = document.querySelector(`#inputRef${this.CurrentCell.oid}`);
      // if (inputElement) {
      //   inputElement.blur();
      // }
    },
    // 枚举注入添加一行空数据
    addRow() {
@@ -2015,32 +2024,35 @@
    },
    //分类注入保存
    injectAddHandle() {
      // 定义展示类型
      let data = {
        "注入类型": this.injectOption.classifyInvokeAttr,
        "注入类型名称": this.injectOption.classifyInvokeAttrName,
        "层级设置": this.injectOption.classifyInvokeLevel == 'max' ? this.injectOption.classifyNumber : 'min',
        "是否可修改": this.injectOption.classifyInvokeEditFlag
      }
      //勾选操作
      const {
        classifyInvokeAttr,
        classifyInvokeAttrName,
        classifyInvokeLevel,
        classifyInvokeEditFlag,
        classifyNumber
      } = this.injectOption;
      const data = {
        "注入类型": classifyInvokeAttr,
        "注入类型名称": classifyInvokeAttrName,
        "层级设置": classifyInvokeLevel === 'max' ? classifyNumber : 'min',
        "是否可修改": classifyInvokeEditFlag
      };
      for (const key in this.injectOption) {
        this.attrSelectList[0][key] = this.injectOption[key];
        //如果是指定层赋值为数字
        if (this.injectOption.classifyInvokeLevel !== 'min') {
          this.attrSelectList[0].classifyInvokeLevel = this.injectOption.classifyNumber
        if (classifyInvokeLevel !== 'min') {
          this.attrSelectList[0].classifyInvokeLevel = classifyNumber;
        } else {
          this.attrSelectList[0].classifyInvokeLevel = 'min'
          this.attrSelectList[0].classifyInvokeLevel = 'min';
        }
        this.$set(this.attrSelectList[0], 'classifyInvokeText', data)
        this.$set(this.attrSelectList[0], 'classifyInvokeText', data);
      }
      // this.injectHandleReset()
      if (this.injectOption.classifyInvokeLevel !== 'min') {
        this.injectOption.classifyInvokeLevel = this.injectOption.classifyNumber;
      if (classifyInvokeLevel !== 'min') {
        this.injectOption.classifyInvokeLevel = classifyNumber;
      } else {
        this.injectOption.classifyNumber = 0;
      }
      this.injectVisible = false;
    },
    //分类注入清空
    injectHandleReset() {
@@ -2106,7 +2118,7 @@
        this.editStyleFlag = true;
        this.attrEditVisible = true;
        this.attrFlag = true;
        this.AddCellFlag=true;
        this.AddCellFlag = true;
      }
    },
@@ -2120,7 +2132,7 @@
    updataFormlaContent(val) {
      if (this.CurrentCell) {
        this.$set(this.CurrentCell, 'componentRule', val.replace(/"/g, ''))
        this.componentRuleText= this.CurrentCell.componentRule
        this.componentRuleText = this.CurrentCell.componentRule
      } else {
        this.$set(this.attrRow, 'componentRule', val.replace(/"/g, ''))
      }
@@ -2137,12 +2149,12 @@
    },
    // 排序 this.AddCellFlag=false;
    sortChange(val) {
      console.log(val)
      // console.log(val)
    },
    //开启编辑
    editOpen() {
      this.editOpenFlag = true;
      this.AddCellFlag=false;
      this.AddCellFlag = false;
    },
    //定义一个关闭编辑的方法供子组件使用
    editClose() {