田源
2023-07-07 388daad59d20da84118067593fc88a89e3f8c9d8
Source/UBCS-WEB/src/components/Tree/attrCrud.vue
@@ -1,36 +1,38 @@
<template>
  <div>
    <div style="display: flex;flex-wrap: wrap;" v-if="this.crudArrayFlag">
      <el-button-group>
      <!--新增-->
      <el-button v-if="attrEditVisible == false && attrFlagChiledren==false" size="small" type="primary"
                 @click="busineHandle">+ 添加 {{ msg }}
      </el-button>
      <el-button v-if="attrEditVisible == false && attrFlagChiledren==false" size="small" type="primary" icon="el-icon-plus" @click="busineHandle">添加 {{ msg }}</el-button>
      <!--        全屏编辑-->
      <el-button v-if=" attrEditVisible == false && attrFlagChiledren==false" size="small" @click="fullscreenHandle">
        全屏编辑
      </el-button>
      <!--    组合规则-->
      <el-button size="small" @click="isShowHandler">组合规则</el-button>
      <el-button v-if=" attrEditVisible == false && attrFlagChiledren==false" size="small" @click="fullscreenHandle" icon="el-icon-full-screen">全屏编辑</el-button>
      <!--        验证规则-->
      <el-button icon="el-icon-info" size="small" @click="rulesVisible=true">验证规则</el-button>
      <!--        属性分组-->
      <el-button icon="el-icon-menu" size="small" @click="attrVisibleHandle">属性分组</el-button>
      </el-button-group>
      <el-button-group>
      <!--        分类注入-->
      <el-button icon="el-icon-magic-stick" size="small" @click="injectBtn">分类注入</el-button>
        <!--    组合规则-->
        <el-button size="small" @click="isShowHandler">组合规则</el-button>
      <!--        枚举注入-->
      <el-button size="small" @click="enmuVisHandle">枚举注入</el-button>
      <!--    级联属性-->
      <el-button size="small" @click="CascadeHandle">级联属性</el-button>
      <!--    预览排序-->
      <el-button size="small">预览排序</el-button>
        <el-button size="small" @click="orderHandle" icon="el-icon-arrow-down">预览排序</el-button>
      </el-button-group>
      <el-button-group>
      <!--    保存-->
      <el-button size="small" @click="addsHandler">保存</el-button>
      <el-button size="small" @click="addsHandler" icon="el-icon-check">保存</el-button>
      <!--    删除-->
      <el-button size="small" @click="CrudRemove">删除</el-button>
      <el-button size="small" @click="CrudRemove" icon="el-icon-delete">删除</el-button>
      <!--    重置-->
      <el-button size="small" @click="reset">重置</el-button>
      <el-button size="small" @click="reset" icon="el-icon-refresh-right">重置</el-button>
      <!--    同步到其他模板-->
      <el-button size="small"@click="syncHandle">同步到其他模板</el-button>
      <el-button size="small"@click="syncHandle" icon="el-icon-share">同步到其他模板</el-button>
      </el-button-group>
      <!--    编码申请预览-->
      <el-button size="small" @click="applicationHandle" style="">编码申请预览</el-button>
      <!--        验证规则-->
@@ -92,7 +94,7 @@
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="120">
              <template slot-scope="scope">
                <el-button size="small" type="text" @click.native.prevent="enumDeleteRow(scope.$index, tableData)">
                <el-button size="small" type="text" plain @click="enumDeleteRow">
                  移除
                </el-button>
              </template>
@@ -209,49 +211,72 @@
      ></formula-editor>
      <!--    新增  -->
      <el-dialog :visible.sync="addVisible" append-to-body title="从业务类型中选择属性">
        <avue-crud :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>
                <el-option>属性英文名称</el-option>
                <el-option>属性中文名称</el-option>
              <el-select v-model="SelectValue" placeholder="请选择" style="width: 150px !important;">
                <el-option
                  v-for="item in SelectOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                  style="width: 150px">
                </el-option>
              </el-select>
              <el-input style="width: 300px;margin-left: 20px"></el-input>
              <el-button size="small" style="margin-left: 10px">查询</el-button>
              <el-input style="width: 400px;margin-left: 20px" v-model="SelectFInd"></el-input>
              <el-button size="small" style="margin-left: 10px" @click="AddFindHandler">查询</el-button>
            </div>
          </template>
        </avue-crud>
        <div style="display: flex;justify-content: flex-end;margin-top: 15px">
          <el-button size="small" type="primary" @click="busineAddHandle">保存</el-button>
          <el-button size="small" type="primary">取消</el-button>
          <el-button size="small" type="primary" @click="addVisible=false">取消</el-button>
        </div>
      </el-dialog>
      <!--      参照配置-->
        <refer-config-form-dialog
          ref="referConfigFormDialog"
          @echoReferConfig="echoReferConfig"
        ></refer-config-form-dialog>
    </div>
    <el-table :data="ProData"
              style="width: 100%"
              height="280"
              @cell-click="handleCellClicks"
              @select="selectHandle"
              @selection-change="selectionChange"
              v-if="this.crudArrayFlag"
              ref="referAttrCrud"
    >
      <el-table-column
        type="selection"
        width="55">
        width="55" fixed>
      </el-table-column>
      <!--<el-table-column fixed label="序号" type="index" width="55"></el-table-column>-->
      <el-table-column v-for="item in this.option.column" :key="item.id"
      <el-table-column v-for="(item,index) in this.option.column" :key="item.id"
                       :label="item.label"
                       :prop="item.prop"
                       :formatter="formAttr"
                       :width="item.label.length >=4 ?'150':item.label.length==3 ?'120':'90'"
                       :width="item.width||(item.label.length >=4 ?'160':item.label.length==3 ?'130':'100')"
                       :show-overflow-tooltip="true"
                       :sortable="item.sortable"
                       :fixed="item.fixed"
                       align="center"
                       v-if="item.edit !='referName'"
      >
        <template slot-scope="{ row }">
          <el-input v-if="editingRows === row && editShows== item.prop && (item.edit == 'text' || item.edit == 'select' ||item.edit == 'refer')" v-model="row[item.prop]"
          <el-input v-if="editingRows === row && editShows== item.prop && item.prop != 'codeDateFormat' && (item.edit == 'text'  ||item.edit == 'refer' )" v-model="row[item.prop]"
                    @blur="saveRows"></el-input>
          <el-input-number controls-position="right" v-if="editingRows === row && editShows== item.prop && item.edit == 'number'" v-model="row[item.prop]"
                           @blur="saveRows"></el-input-number>
          <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' " @focus="DataChangeHandler(item.editConfig,index)">
            <el-option
              v-for="optionItem in item.data"
              :key="optionItem.key"
              :label="optionItem.value"
              :value="optionItem.key">
            </el-option>
          </el-select>
          <el-switch
            v-if="item.edit === 'switch'" v-model="row[item.prop]" active-value="true"
            inactive-value="false">
@@ -262,7 +287,7 @@
      <el-table-column
        fixed="right"
        label="操作"
        width="120">
        width="70">
        <template slot-scope="scope">
          <el-button
            size="small"
@@ -274,11 +299,10 @@
      </el-table-column>
    </el-table>
  </div>
  <!--  </avue-crud>-->
</template>
<script>
import {AttrByBtm, gridCodeClassifyTemplateAttr, batchAddSave, copyto} from '@/api/template/templateAttr'
import {AttrByBtm, gridCodeClassifyTemplateAttr, batchAddSave, copyto,listByFlag} from '@/api/template/templateAttr'
export default {
  name: "attrCrud .vue",
@@ -326,6 +350,24 @@
  },
  data() {
    return {
      screenWidth: document.documentElement.clientWidth, // 屏幕宽度
      //当前单元格
      CurrentCell:'',
      // 新增
      SelectValue:"",
      SelectFInd:"",
      SelectOption:[
        {
          value: 'name',
          label: '属性中文名称'
        },
        {
          value: 'id',
          label: '属性英文名称'
        }
      ],
      //参照
      referVisible:false,
      crudArrayFlag:false,
      editingRows: null,
      editShows:"",
@@ -435,6 +477,8 @@
      isShowformulaEdit: false,
      // 级联单选
      selectRow: '',
      //级联单选数组
      selectRowArr:[],
      // 级联data
      CascadeData: [],
      // 级联option
@@ -901,11 +945,27 @@
          },
          {
            label: "数据类型",
            prop: "attrDataType"
            prop: "attrDataType",
            formatter:function(row,column){
              let vciFieldTypeMap = {
                VTBoolean: "布尔型",
                VTClob: "长文本",
                VTDate: "日期",
                VTDateTime: "日期时间",
                VTTime: "时间",
                VTLong: "长整型",
                VTDouble: "金额/双精度",
                VTInteger: "整形",
                VTFilePath: "文件",
                VTString: "字符串"
              }
              return vciFieldTypeMap[row.attrDataType];
            }
          },
          {
            label: "可空",
            prop: "nullableFlag"
            prop: "nullableFlag",
            formatter:function(row,column){return row.nullableFlag=='true' || row.nullableFlag=='1'?'是':'否'}
          },
          {
            label: "默认值",
@@ -925,11 +985,25 @@
          },
          {
            label: "参照",
            prop: "referFlag"
            prop: "referFlag",
            formatter: function (d) {
              if (!d.referFlag) {
                return '';
              } else {
                return d.referBtmTypeId
              }
            }
          },
          {
            label: "枚举",
            prop: "enumFlag"
            prop: "enumFlag",
            formatter: function (d) {
              if (!d.enumFlag) {
                return '';
              } else {
                return d.enumId
              }
            }
          },
        ]
      },
@@ -959,7 +1033,7 @@
          label: '排序号',
          sortable: true,
          edit: 'number',
          width: 60,
          width: 90,
          fixed: true
        }, {
            label: "属性英文编号",
@@ -975,7 +1049,7 @@
            prop: "name",
            fixed: true,
            cell: false,
            width: 125,
            width: 145,
            edit: 'text',
            sortable: true
          },
@@ -1016,14 +1090,14 @@
          {
            label: "高级查询属性",
            prop: "seniorQueryAttrFlag",
            width: 95,
            width: 110,
            cell: false,
            edit: "switch"
          },
          {
            label: "相似查重属性",
            prop: "sameRepeatAttrFlag",
            width: 95,
            width: 110,
            cell: false,
            edit: "switch"
          },
@@ -1076,6 +1150,13 @@
            prop: "prefixValue",
            sortable: true,
            edit: 'select',
            width: 110,
            editConfig: {
              extraParams: {
                code: 'codeclstempattr',
                dictKey: 'prefix'
              }
            },
            cell: false,
          },
          {
@@ -1083,6 +1164,13 @@
            prop: "suffixValue",
            sortable: true,
            edit: 'select',
            width: 110,
            editConfig: {
              extraParams: {
                code: 'codeclstempattr',
                dictKey: 'suffix'
              }
            },
            cell: false,
          },
          {
@@ -1105,15 +1193,27 @@
            label: "时间格式",
            prop: "codeDateFormat",
            sortable: true,
            width: 105,
            width: 135,
            edit: 'select',
            editConfig: {
              extraParams: {
                code: 'codeclstempattr',
                dictKey: 'dateFormates'
              }
            },
            cell: false,
          },
          {
            label: "分类注入",
            prop: "classifyInvokeLevelName",
            cell: false,
            edit: 'refer'
          },
          {
            label: "分类注入",
            prop: "classifyInvokeLevel",
            cell: false,
            edit: 'refer'
            edit: 'referName',
          },
          {
            label: "枚举注入",
@@ -1220,7 +1320,9 @@
        VTInteger: "整形",
        VTFilePath: "文件",
        VTString: "字符串"
      }
      },
      //时间格式下拉框
      codeDataFlag:false,
    }
  },
  computed:{
@@ -1240,6 +1342,17 @@
    }
  },
  mounted() {
    window.addEventListener(
      'resize',
      () => {
        if(Math.abs(this.screenWidth - document.body.clientWidth) > 20) {
          this.$nextTick(() => {
            this.$refs.AddOriginPlace.refreshTable();
          })
        }
        this.screenWidth = document.body.clientWidth;
      }
    )
  },
  created() {
@@ -1248,22 +1361,51 @@
    formAttr(row, column) {
      console.log(row,column)
    },
    //新增搜索
    AddFindHandler(){
      if(this.SelectValue == 'id'){
        const masterParameter={
          'conditionMap[id]':this.SelectFInd
        }
        this.BuineAttrByBtm(masterParameter);
        this.SelectValue=""
        this.SelectFInd=""
      }else if(this.SelectValue == 'name'){
        const masterParameter={
          'conditionMap[name]':this.SelectFInd
        }
        this.BuineAttrByBtm(masterParameter)
        this.SelectValue=""
        this.SelectFInd=""
      }
    },
    //参照配置子组件
    echoReferConfig(val){
      console.log('val--',val)
      this.$set(this.CurrentCell,'referConfig',JSON.stringify(val))
    },
    //时间下拉格式
    DataChangeHandler(editConfig,index){
      listByFlag(editConfig.extraParams).then(res=>{
        console.log(res);
        this.option.column[index].data=res;
      })
    },
    //属性分组按钮
    attrVisibleHandle() {
      if (this.attrSelectList.length > 1) {
        this.$message.warning('只能选择一条模板属性')
      } else if (this.attrSelectList < 1) {
     if (this.attrSelectList < 1) {
        this.$message.warning('请选择一条模板属性')
      } else if (this.attrSelectList.length === 1) {
      } else  {
        this.attrVisible = true;
       console.log(this.attrSelectList)
      }
    },
    //属性分组提交
    attrHandle() {
      this.$set(this.attrRow, 'attributeGroup', this.attrModel)
      this.attrModel = ""
      this.attrVisible = false
      this.attrModel = "";
      this.attrVisible = false;
    },
    //属性分组清空
    attrRemove() {
@@ -1285,7 +1427,6 @@
        this.$message.warning('请选择属性集');
        return false;
      }
debugger;
      let ordernum = this.ProData.length;
      this.busineSelectList.forEach((citem) => {
        let isCopy = false;
@@ -1310,18 +1451,16 @@
            precisionLength: (citem.precisionLength ? citem.precisionLength : '') + (citem.scaleLength ? '(' + citem.scaleLength + ')' : ''),
            classifyTemplateOid: this.crudOid,
            classifytemplateoid: this.crudOid,
            formDisplayFlag: true,
            tableDisplayFlag: true,
            sortAttrFlag: false,
            queryAttrFlag: true,
            seniorQueryAttrFlag: true,
            formDisplayFlag: 'true',
            tableDisplayFlag: 'true',
            sortAttrFlag: 'false',
            queryAttrFlag: 'true',
            seniorQueryAttrFlag: 'true',
            attrTableWidth: 120
          })
          this.ProData.push(JSON.parse(JSON.stringify(this.busineAddList)))
        }
      })
      this.addVisible = false;
    },
@@ -1334,7 +1473,11 @@
      this.addVisible = true;
      this.busineSelectList = []
      this.busineAddList = [];
      AttrByBtm({'conditionMap[oid]': this.crudOid}).then(res => {
      this.BuineAttrByBtm()
    },
    //业务类型数据
    BuineAttrByBtm(masterParameter){
      AttrByBtm({'conditionMap[oid]': this.crudOid,...masterParameter}).then(res => {
        this.businessData = res.data.data;
      })
    },
@@ -1354,25 +1497,10 @@
        })
      }
    },
    //表格单选
    selectHandle(selection, row) {
      this.attrOid = row.oid;
      this.attrRow = row;
    },
    //表格选择
    selectionChange(list) {
      this.attrSelectList = list;
    },
    //保存
    addsHandler() {
      batchAddSave(JSON.parse(JSON.stringify(this.ProData))).then(res => {
        this.$message.success('保存成功')
      })
    },
    //级联保存
    CascadeAddHandle() {
      let CascadeString = "";
      CascadeString = this.attrRow.id + (this.attrRow.name);
      CascadeString = this.selectRowArr.id + (this.selectRowArr.name);
      this.$set(this.attrRow, 'parentCode', CascadeString)
      this.CascadeVisible = false;
    },
@@ -1382,16 +1510,54 @@
    },
    // 级联属性行单选
    CascaderowClick(row) {
      this.selectRow = row.$index
      this.selectRow = row.$index;
      this.selectRowArr=row
    },
    // 排序预览按钮
    orderHandle(){
      this.$refs.referAttrCrud.sort("orderNum");
    },
    //表格单选
    selectHandle(selection, row) {
      this.attrOid = row.oid;
      this.attrRow = row;
      console.log(row)
    },
    //表格选择
    selectionChange(list,) {
      this.attrSelectList = list;
      console.log(list)
    },
    //保存
    addsHandler() {
      batchAddSave(JSON.parse(JSON.stringify(this.ProData))).then(res => {
        this.$message.success('保存成功')
      })
    },
    //表格行编辑
    handleCellClicks(row, column) {
        this.editingRows = row;
        this.editShows = column.property;
        this.rowOid = row.oid;
      console.log(row,column)
      this.CurrentCell=row;
      if(column.property == 'referConfig' ){
        this.$refs.referConfigFormDialog.isShowReferConfigForm = true;
        this.$refs.referConfigFormDialog.onloadAttrData();
      }else if(column.property == 'classifyInvokeLevelName'){
        this.injectVisible=true;
      }else if(column.property == 'componentRule'){
        this.isShowformulaEdit = true;
      }else if(column.property == 'enumString'){
        this.enumVisible=true;
      }else if(column.property == 'parentCode'){
        this.CascadeVisible=true;
      }
    },
    saveRows() {
      this.editingRows = null;
      console.log('1321')
    },
    // 枚举注入添加一行空数据
    addRow() {
@@ -1407,7 +1573,7 @@
    },
    //枚举注入删除
    enumDeleteRow(row) {
      this.tableData.splice(row, 1)
      this.tableData.splice(row.$index, 1)
    },
    //枚举注入按钮
    enmuVisHandle() {
@@ -1428,11 +1594,16 @@
      if (this.enumRow.length < 1) {
        this.$message.warning('请至少选择一条数据')
      } else {
        this.$set(this.attrRow, 'enumString', this.enumRow);
        this.enumVisible = false;
        if(this.CurrentCell){
          this.$set(this.CurrentCell, 'enumString', JSON.stringify(this.enumRow));
          this.enumVisible = false;
        }else {
          this.$set(this.attrRow, 'enumString', JSON.stringify(this.enumRow));
          this.enumVisible = false;
        }
      }
    },
    // 将正在编辑的行的状态变为 null ,即退出编辑状态
    // 将正在编辑的行的状态变为 null,即退出编辑状态
    saveRow() {
      this.editingRow = null;
    },
@@ -1467,7 +1638,19 @@
    },
    //分类注入保存
    injectAddHandle() {
      this.$set(this.attrRow, 'classifyInvokeLevel', this.injectOption);
      let data = {
        "注入类型": this.injectOption.type,
        "注入类型名称": this.injectOption.set,
        "层级设置": this.injectOption.injectNum,
        "是否可修改": this.injectOption.change
      }
      if(this.CurrentCell){
        this.$set(this.CurrentCell, "classifyInvokeLevelName", data);
        this.$set(this.CurrentCell, "classifyInvokeLevel", JSON.stringify(this.injectOption));
      }else {
        this.$set(this.attrRow, 'classifyInvokeLevelName', data);
        this.$set(this.attrRow, 'classifyInvokeLevel', JSON.stringify(this.injectOption));
      }
      this.injectVisible = false
    },
    //分类注入清空
@@ -1482,32 +1665,15 @@
      this.injectVisible = false
    },
    //属性模板表格单元格点击事件
    handleRowClick(row, column, cell, event) {
      //判断点击不是操作栏才可执行
      if (column.property != "menu") {
        // 当前行变为可编辑状态
        this.rowList = row
        row.$cellEdit = true
        // 每一个单元格加上cell为true才是编辑状态
        //拿到每个columnKey,点击时设置为true,就实现单元格编辑状态了
        this.rowCellList = this.findObject(this.option.column, column.columnKey)
        this.rowCellList.cell = true
        if (this.List.indexOf(column.columnKey) == -1) {
          this.List.push(column.columnKey)
        }
        // if(this.List.length >= 2){
        //   const cellName=this.List[0]
        //
        // }
      }
    },
    //表格操作栏删除
    CrudRowDel(row) {
      this.ProData.splice(row.$index, 1)
    },
    //表格删除
    CrudRemove() {
      this.ProData.splice(this.attrRow.$index, 1)
      this.attrSelectList.forEach((item)=>{
        this.ProData.splice(item.$index, 1)
      })
    },
    //表格重置
    reset() {
@@ -1536,7 +1702,7 @@
      } else if (this.attrSelectList.length < 1) {
        this.$message.warning('请选择一条模板属性数据')
      } else if (this.attrSelectList.length === 1) {
        this.isShowformulaEdit = true;
        this.isShowformulaEdit=true
      }
    },
    //全屏编辑
@@ -1554,8 +1720,14 @@
      this.attrFlagChiledren = false;
      this.attrEditVisible = false;
    },
    //组合规则确定
    updataFormlaContent(val) {
      this.$set(this.attrRow, 'componentRule', val)
      if(this.CurrentCell){
        this.$set(this.CurrentCell, 'componentRule', JSON.stringify(val))
      }else {
        this.$set(this.attrRow, 'componentRule', JSON.stringify(val))
      }
    },
    // 排序
    sortChange(val) {
@@ -1575,7 +1747,7 @@
}
</script>
<style scoped lang="scss">
<style scoped lang="scss" >
/deep/ .el-button {
  margin: 0 10px 10px 0;
}