xiejun
2023-08-12 a19d26e88360c9760b2286bac4dfb1710fd2fa21
Source/UBCS-WEB/src/components/Theme/ThemeAttrCrud.vue
@@ -1,54 +1,79 @@
<template>
  <div>
    <div style="display: flex;flex-wrap: wrap;" v-if="this.crudArrayFlag" class="app">
    <div v-if="this.crudArrayFlag" class="app" style="display: flex;flex-wrap: wrap; display: inline-block">
      <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-button
          v-if="attrEditVisible == false && attrFlagChiledren==false && editOpenFlag &&  (!checkStatus || crudLCStatus=='Editing' )"
          icon="el-icon-plus" plain size="small" type="primary" @click="busineHandle">添加 {{ msg }}
        </el-button>
      <!--        全屏编辑-->
      <el-button v-if=" attrEditVisible == false && attrFlagChiledren==false && editOpenFlag&&(!checkStatus || crudLCStatus=='Editing')" size="small" @click="fullscreenHandle" icon="el-icon-full-screen">全屏编辑</el-button>
        <el-button
          v-if=" attrEditVisible == false && attrFlagChiledren==false && editOpenFlag&&(!checkStatus || crudLCStatus=='Editing')"
          icon="el-icon-full-screen" size="small" @click="fullscreenHandle">全屏编辑
        </el-button>
      <!--        验证规则-->
      <el-button v-if="(!checkStatus || crudLCStatus=='Editing' )&& editOpenFlag" icon="el-icon-info" size="small" @click="ruleAddHandler">验证规则</el-button>
        <el-button v-if="(!checkStatus || crudLCStatus=='Editing' )&& editOpenFlag" icon="el-icon-info" size="small"
                   @click="ruleAddHandler">验证规则
        </el-button>
      <!--        属性分组-->
      <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-menu" size="small" @click="attrVisibleHandle">属性分组</el-button>
        <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-menu" size="small"
                   @click="attrVisibleHandle">属性分组
        </el-button>
      </el-button-group>
      <el-button-group>
        <!--    保存-->
        <el-button v-if="(!checkStatus|| crudLCStatus=='Editing') && editOpenFlag" size="small" type="success" plain @click.prevent="addsHandler" icon="el-icon-check">保存</el-button>
        <el-button v-if="(!checkStatus|| crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-check" plain size="small"
                   type="success" @click.prevent="addsHandler">保存
        </el-button>
        <!--    预览排序-->
        <el-button size="small" @click="orderHandle" icon="el-icon-arrow-down">预览排序</el-button>
        <el-button icon="el-icon-arrow-down" size="small" @click="orderHandle">预览排序</el-button>
        <!--    删除-->
        <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" size="small" @click="CrudRemove" icon="el-icon-delete">删除</el-button>
        <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-delete" size="small"
                   @click="CrudRemove">删除
        </el-button>
        <!--    重置-->
        <el-button size="small" @click="reset" icon="el-icon-refresh-right">重置</el-button>
        <el-button icon="el-icon-refresh-right" size="small" @click="reset">重置</el-button>
      </el-button-group>
      <el-button-group>
        <!--新增-->
      <!--        分类注入-->
      <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag"  icon="el-icon-magic-stick" size="small" @click="injectBtn">分类注入</el-button>
        <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-magic-stick"
                   size="small" @click="injectBtn">分类注入
        </el-button>
        <!--    组合规则-->
        <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-film" size="small" @click="isShowHandler">组合规则</el-button>
        <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-film" size="small"
                   @click="isShowHandler">组合规则
        </el-button>
      <!--        枚举注入-->
      <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-c-scale-to-original" size="small" @click="enmuVisHandle">枚举注入</el-button>
        <el-button v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-c-scale-to-original"
                   size="small" @click="enmuVisHandle">枚举注入
        </el-button>
      <!--    级联属性-->
      <el-button v-if="(!checkStatus|| crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-coin" size="small" @click="CascadeHandle">级联属性</el-button>
        <el-button v-if="(!checkStatus|| crudLCStatus=='Editing') && editOpenFlag" icon="el-icon-coin" size="small"
                   @click="CascadeHandle">级联属性
        </el-button>
      </el-button-group>
      <el-button-group>
      <!--    同步到其他模板-->
      <el-button size="small"@click="syncHandle" icon="el-icon-share">同步到其他模板</el-button>
        <el-button icon="el-icon-share" size="small" @click="syncHandle">同步到其他模板</el-button>
      </el-button-group>
      <el-button-group>
      <!--    编码申请预览-->
      <el-button size="small" icon="el-icon-view" @click="applicationHandle" style="">编码申请预览</el-button>
        <el-button icon="el-icon-view" size="small" style="" @click="applicationHandle">编码申请预览</el-button>
      </el-button-group>
      <!-- 是否开启编辑     -->
    <el-button-group>
      <el-button size="small" plain  icon="el-icon-view"  v-if="(!checkStatus|| crudLCStatus=='Editing') && !editOpenFlag && attrEditVisible == false && attrFlagChiledren==false" @click="editOpen" >开启编辑</el-button>
        <el-button v-if="(!checkStatus|| crudLCStatus=='Editing') && !editOpenFlag && attrEditVisible == false && attrFlagChiledren==false" icon="el-icon-view" plain
                   size="small"
                   @click="editOpen">开启编辑
        </el-button>
    </el-button-group>
      <el-select v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag"  size="small" v-model="selectvalue" placeholder="请选择">
      <el-select v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag" v-model="selectvalue" placeholder="请选择"
                 size="small">
        <el-option
          v-for="item in selectoptions"
          :key="item.value"
@@ -56,7 +81,8 @@
          :value="item.value">
        </el-option>
      </el-select>
      <el-switch v-if="(!checkStatus || crudLCStatus=='Editing') && editOpenFlag"  v-model="switchvalue" @change="batchSetFlag" active-value="true" style="margin:6px 0 0 10px">
      <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>
<!--    弹窗-->
@@ -86,9 +112,15 @@
        </div>
      </el-dialog>
      <!--        枚举注入-->
      <el-dialog :visible.sync="enumVisible" append-to-body title="枚举注入" :before-close="this.enumBeforeClose">
      <el-dialog :before-close="this.enumBeforeClose" :visible.sync="enumVisible" append-to-body title="枚举注入">
        <!-- 渲染表格及按钮 -->
        <!-- 渲染表格及按钮 -->
        <el-alert
          :closable="false"
          style="margin-bottom: 10px;display: inline-block"
          title="请新增后点击单元格输入枚举数据"
          type="success">
        </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"
@@ -111,7 +143,7 @@
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="120">
              <template slot-scope="scope">
                <el-button size="small" type="text" plain @click="enumDeleteRow">
                <el-button plain size="small" type="text" @click="enumDeleteRow">
                  移除
                </el-button>
              </template>
@@ -146,7 +178,8 @@
                <el-radio-group v-model="injectOption.classifyInvokeLevel">
                  <el-radio label="min">最小层</el-radio>
                  <el-radio label="max">指定层</el-radio>
                  <el-input-number v-if="this.injectOption.classifyInvokeLevel == 'max'" v-model="injectOption.classifyNumber" :max="10" :min="0"
                  <el-input-number v-if="this.injectOption.classifyInvokeLevel == 'max'"
                                   v-model="injectOption.classifyNumber" :max="10" :min="0"
                                   controls-position="right"></el-input-number>
                </el-radio-group>
              </el-form-item>
@@ -166,7 +199,8 @@
        </div>
      </el-dialog>
      <!--        属性分组-->
      <el-dialog :visible.sync="attrVisible" append-to-body :before-close="attrClose" style="width: 800px; left:30vw;top: 10vh ;"
      <el-dialog :before-close="attrClose" :visible.sync="attrVisible" append-to-body
                 style="width: 800px; left:30vw;top: 10vh ;"
                 title="输入分组的名称">
        <el-form ref="form" label-width="70px">
          <el-form-item label="属性分组">
@@ -217,19 +251,22 @@
        </el-container>
      </el-dialog>
      <!--        全屏编辑-->
      <el-dialog :visible.sync="attrEditVisible" append-to-body fullscreen="true" :before-close="escEdit" >
        <attrCrud :ProData="this.ProData" :attrFlagChiledren="this.attrFlag" @editCloseChildren="editClose" :editStyleFlag="editStyleFlag" :editOpenFlag="editOpenFlag" :crudArrayFlag="this.crudArrayFlag"></attrCrud>
      <el-dialog :before-close="escEdit" :visible.sync="attrEditVisible" append-to-body fullscreen="true">
        <attrCrud :ProData="this.ProData" :attrFlagChiledren="this.attrFlag" :crudArrayFlag="this.crudArrayFlag"
                  :editOpenFlag="editOpenFlag" :editStyleFlag="editStyleFlag"
                  @editCloseChildren="editClose"></attrCrud>
      </el-dialog>
      <!--      组合规则-->
      <formula-editor :systemVariableTableData="systemVariableTableData"
      <formula-editor :componentRuleText="componentRuleText"
                      :systemVariableTableData="systemVariableTableData"
                      :thisSceneTableData="thisSceneTableData"
                      :visible.sync="isShowformulaEdit"
                      @updateFormulaContent="updataFormlaContent"
                      :componentRuleText="componentRuleText"
      ></formula-editor>
      <!--    新增  -->
      <el-dialog :visible.sync="addVisible" append-to-body title="从业务类型中选择属性">
        <avue-crud ref="AddOriginPlace" :data="businessData" :option="businessOption" @selection-change="businessSelect">
        <avue-crud ref="AddOriginPlace" :data="businessData" :option="businessOption"
                   @selection-change="businessSelect">
          <template slot="menuLeft">
            <div style="display: flex;">
              <el-select v-model="SelectValue" placeholder="请选择" style="width: 150px !important;">
@@ -241,7 +278,7 @@
                  style="width: 150px">
                </el-option>
              </el-select>
              <el-input style="width: 400px;margin-left: 20px" v-model="SelectFInd"></el-input>
              <el-input v-model="SelectFInd" style="width: 400px;margin-left: 20px"></el-input>
              <el-button size="small" style="margin-left: 10px" @click="AddFindHandler">查询</el-button>
            </div>
          </template>
@@ -255,44 +292,50 @@
      <!--      参照配置-->
        <refer-config-dialog
          :display="referConfigVisble"
          @setReferConfigValue="setReferConfigValue"
          :referConfigOption="referConfigOption"
        @setReferConfigValue="setReferConfigValue"
        ></refer-config-dialog>
    </div>
    <el-table :data="ProData"
              style="width: 100%"
              :height="this.editStyleFlag? 800 : 343"
              @cell-click="handleCellClicks"
              @select="selectHandle"
              @selection-change="selectionChange"
              @row-click="rowClick"
              v-if="this.crudArrayFlag"
    <el-table v-if="this.crudArrayFlag"
              ref="referAttrCrud"
              v-loading="loading"
              :data="ProData"
              :height="this.editStyleFlag? 800 : 343"
              style="width: 100%"
              @select="selectHandle"
              @cell-click="handleCellClicks"
              @selection-change="selectionChange"
              @row-click="rowClick"
    >
      <el-table-column
        type="selection"
        width="55" fixed>
        fixed
        type="selection" width="55">
      </el-table-column>
      <!--<el-table-column fixed label="序号" type="index" width="55"></el-table-column>-->
      <el-table-column v-for="(item,index) in this.option.column" :key="item.id"
      <el-table-column v-for="(item,index) in this.option.column" v-if="item.edit !='referName'"
                       :key="item.id"
                       :fixed="item.fixed"
                       :formatter="formAttr"
                       :label="item.label"
                       :prop="item.prop"
                       :formatter="formAttr"
                       :width="item.width||(item.label.length >=4 ?'160':item.label.length==3 ?'130':'100')"
                       :show-overflow-tooltip="true"
                       :sortable="item.sortable"
                       :fixed="item.fixed"
                       :width="item.width||(item.label.length >=4 ?'160':item.label.length==3 ?'130':'100')"
                       align="center"
                       v-if="item.edit !='referName'"
      >
        <template slot-scope="{ row }">
          <el-input ref="inputRef" v-if="editingRows === row && editShows== item.prop && item.prop != 'codeDateFormat' && (item.edit == 'text'  ||item.edit == 'refer' )" v-model="row[item.prop]"
                    @blur="saveRows" autofocus ></el-input>
          <el-input-number size="small" controls-position="right" v-if="editingRows === row && editShows== item.prop && item.edit == 'number'" v-model="row[item.prop]"
                           @blur="saveRows" :style="{width:(item.width-10)+'px'}"></el-input-number>
          <el-select v-model="row[item.prop]" filterable  allow-create  default-first-option slot="prepend" v-if="editingRows === row && editShows== item.prop && item.edit == 'select' " @blur="selectChangeHandler(item.editConfig,index)">
          <el-input v-if="editingRows === row && editShows== item.prop && item.prop != 'codeDateFormat' && (item.edit == 'text'  ||item.edit == 'refer' )"
                    ref="inputRef"
                    v-model="row[item.prop]"
                    autofocus @blur="saveRows"></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
                     filterable
                     @blur="selectChangeHandler(item.editConfig,index)">
            <el-option
              v-for="optionItem in item.data"
              :key="optionItem.dictValue"
@@ -301,7 +344,7 @@
            </el-option>
          </el-select>
          <el-switch
            v-if="item.edit === 'switch'" v-model="row[item.prop]" active-value="true" :disabled="!editOpenFlag"
            v-if="item.edit === 'switch'" v-model="row[item.prop]" :disabled="!editOpenFlag" active-value="true"
            inactive-value="false">
          </el-switch>
          <span v-else>{{ row[item.prop] }}</span>
@@ -327,6 +370,7 @@
<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",
@@ -380,6 +424,11 @@
        if(newval){
          this.editOpenFlag=false
        }
      }
    },
    crudArrayFlag: {
      handler(newval, olaval) {
        console.log('crudArrayFlag', newval)
      }
    },
    crudArray:{
@@ -1058,7 +1107,9 @@
          {
            label: "可空",
            prop: "nullableFlag",
            formatter:function(row,column){return row.nullableFlag=='true' || row.nullableFlag=='1'?'是':'否'}
            formatter: function (row, column) {
              return row.nullableFlag == 'true' || row.nullableFlag == '1' ? '是' : '否'
            }
          },
          {
            label: "默认值",
@@ -1613,7 +1664,10 @@
      this.addVisible = true;
      this.busineSelectList = []
      this.busineAddList = [];
      this.BuineAttrByBtm()
      this.BuineAttrByBtm();
      this.$nextTick(() => {
        this.$refs.AddOriginPlace.doLayout();
      })
    },
    //业务类型数据
    BuineAttrByBtm(masterParameter){
@@ -1650,7 +1704,10 @@
    },
    //级联属性清除
    casRemove() {
      this.selectRow = ""
      this.selectRow = "";
      this.$set(this.CurrentCell, 'parentCode', this.selectRow);
      this.CascadeVisible = false;
    },
    // 级联属性行单选
    CascaderowClick(row) {
@@ -1681,6 +1738,59 @@
    },
    //保存
    addsHandler(event) {
      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++
          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({
            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;
@@ -1688,7 +1798,10 @@
        this.$emit('editCloseChildren')
      }).catch(()=>{
        this.$message.warning('保存失败,请查看控制台输出!')
      })
        });
      }
      // 所有if条件和逻辑通过后调用executeBatchAddSave函数
      executeBatchAddSave();
    },
    //表格行编辑
    handleCellClicks(row, column) {
@@ -1719,7 +1832,7 @@
               classifyNumber: this.CurrentCell.classifyInvokeLevel == 'min' ? '' : this.CurrentCell.classifyInvokeLevel
             };
           } else {
             this.injectHandleReset();
            // this.injectHandleReset();
           }
         }else if(column.property == 'componentRule'){
           if(this.CurrentCell){
@@ -1800,6 +1913,7 @@
    },
    //枚举注入保存
    enumAddHandle() {
      if (this.tableData.length >= 1) {
      let hasError = false; // 添加一个变量
      this.tableData.forEach((item, index) => {
        if (item.key === '') {
@@ -1822,6 +1936,9 @@
          this.tableData=[];
          this.enumVisible = false;
        }
        }
      } else {
        this.$message.warning('请添加枚举注入数据!')
      }
    },
    // 将正在编辑的行的状态变为 null,即退出编辑状态
@@ -1846,6 +1963,8 @@
    rulesremove() {
      this.RulesForm.expressionText = ""
      this.RulesForm.TestContent = ""
      this.$set(this.CurrentCell, 'verifyRule', '')
      this.rulesVisible = false
    },
    // 验证规则确定
    rulesHandle() {
@@ -1896,8 +2015,7 @@
          }
          this.$set(this.attrSelectList[0],'classifyInvokeText',data)
        }
        this.injectHandleReset()
      // this.injectHandleReset()
      if(this.injectOption.classifyInvokeLevel !== 'min'){
        this.injectOption.classifyInvokeLevel=this.injectOption.classifyNumber;
      }else  {
@@ -1908,11 +2026,13 @@
    },
    //分类注入清空
    injectHandleReset() {
      this.injectOption.classifyInvokeAttrName = "分类名称";
      this.injectOption.classifyInvokeAttr = "name";
      this.injectOption.classifyInvokeLevel = "min";
      this.injectOption.classifyInvokeEditFlag = "true";
      this.injectOption.classifyNumber = "0";
      // this.injectOption.classifyInvokeAttrName = "分类名称";
      // this.injectOption.classifyInvokeAttr = "name";
      // this.injectOption.classifyInvokeLevel = "min";
      // this.injectOption.classifyInvokeEditFlag = "true";
      // this.injectOption.classifyNumber = "0";
      this.$set(this.CurrentCell, 'classifyInvokeText', '')
      this.injectVisible = false;
    },
    // 分类注入取消
    injectRemove() {
@@ -2018,12 +2138,13 @@
}
</script>
<style scoped lang="scss" >
<style lang="scss" scoped>
.app {
   /deep/ .el-button {
   //margin: 0 10px 10px 0;
   }
}
.el-button-group {
  margin-right: 10px;
  margin-bottom: 10px;