田源
2023-09-15 80ef464bf93212805d6b36f12b7791edda04e23e
Source/UBCS-WEB/src/components/Theme/ThemeAttrCrud.vue
@@ -71,19 +71,19 @@
                   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>
@@ -326,10 +326,11 @@
      >
        <template slot-scope="{ row }">
          <el-input v-if="editingRows === row && editShows== item.prop && item.prop != 'codeDateFormat' && (item.edit == 'text'  ||item.edit == 'refer' )"
                    ref="inputRef"
                    :ref="'input' + row.oid"
                    v-show="!AddCellFlag"
                    v-model="row[item.prop]"
                    autofocus @blur="saveRows"></el-input>
                    @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"
@@ -372,6 +373,7 @@
import {AttrByBtm, gridCodeClassifyTemplateAttr, batchAddSave, copyto, listByFlag} from '@/api/template/templateAttr'
import {getList} from "@/api/refer/table";
import func from "@/util/func";
import {getCurrentInstance} from "vue";
export default {
  name: "attrCrud .vue",
@@ -428,7 +430,7 @@
      }
    },
    crudArrayFlag: {
      handler(newval, olaval) {
      handler(newval, oldval) {
        console.log('crudArrayFlag', newval)
      }
    },
@@ -453,6 +455,16 @@
        }
      }
    },
    // editingRows:{
    //   handler(newval,oldval){
    //     if(newval){
    //       const inputElement = document.querySelector(`#inputRef${newval.oid}`);
    //       if (inputElement) {
    //         inputElement.focus();
    //       };
    //     }
    //   }
    // },
    ProData: {
      handler(newval, oldval) {
        if (newval) {
@@ -1078,11 +1090,13 @@
        column: [
          {
            label: "属性英文名称",
            prop: "id"
            prop: "id",
            width:100,
          },
          {
            label: "属性中文名称",
            prop: "name"
            prop: "name",
            width:100,
          },
          {
            label: "长度",
@@ -1123,7 +1137,7 @@
            prop: "precisionLength"
          },
          {
            label: "小精刻度",
            label: "小数刻度",
            prop: "scaleLength"
          },
          {
@@ -1565,9 +1579,6 @@
    //可输可选下拉
    selectChangeHandler(editConfig, index) {
      let that = this;
      /*if(that.option.column[index].data && that.option.column[index].data.length>=0){
        return;
      }*/
      listByFlag(editConfig.extraParams).then(res => {
        that.option.column[index].data = res.data.data;
      })
@@ -1586,7 +1597,7 @@
        item.attributeGroup = this.attrModel
      })
      if (this.CurrentCell) {
        this.$set(this.CurrentCell, 'attributeGroup', this.attrModel)
        this.$set(this.CurrentCell, 'attributeGroup', this.attrModel);
      } else {
        this.$set(this.attrSelectList[0], 'attributeGroup', this.attrModel)
      }
@@ -1743,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;
        }
@@ -1755,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({
@@ -1814,63 +1817,82 @@
        this.editShows = column.property;
        this.rowOid = row.oid;
        this.CurrentCell = row;
        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();
      // }
    },
    // 枚举注入添加一行空数据
    addRow() {
@@ -1974,6 +1996,7 @@
    rulesHandle() {
      if (this.CurrentCell) {
        this.$set(this.CurrentCell, 'verifyRule', this.RulesForm.expressionText)
        this.AddCellFlag = !this.AddCellFlag;
      } else {
        this.attrSelectList.forEach((item) => {
          this.$set(item, 'verifyRule', this.RulesForm.expressionText)
@@ -2001,32 +2024,29 @@
    },
    //分类注入保存
    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() {
@@ -2092,6 +2112,7 @@
        this.editStyleFlag = true;
        this.attrEditVisible = true;
        this.attrFlag = true;
        this.AddCellFlag=true;
      }
    },
@@ -2120,7 +2141,7 @@
        this.$set(this.attrRow, 'referConfig', JSON.stringify(content))
      }
    },
    // 排序
    // 排序 this.AddCellFlag=false;
    sortChange(val) {
      console.log(val)
    },