wangting
2024-11-07 db78e86024c5cc3928bdd837e148204d59bd4fbb
Source/plt-web/plt-web-ui/src/views/modelingMenu/modeling/businessType/index.vue
@@ -215,31 +215,32 @@
                           :props="{label: 'id', value: 'id'}"
                           :dic="lifeData"></avue-select>
            </el-form-item>
            <el-form-item label="备选生命周期列表:" label-width="138px">
              <avue-select multiple
                           :filterable="true"
                           v-model="form.subLifeCycleId"
                           v-model="form.subLifeCycleIdList"
                           placeholder="请选择生命周期"
                           :props="{label: 'id', value: 'id'}"
                           type="tree"
                           :dic="lifeData"></avue-select>
                           :dic="subLifeData"
                           @change="subLifeChange"></avue-select>
            </el-form-item>
          </div>
        </div>
      </el-form>
      <div class="bottomForm">
        <h3 style="margin-bottom: 10px;">属性池列表</h3>
        <avue-crud
          size="mini"
          :data="dialogAttrData"
          :option="dialogAttrOption"
          @row-del="dialogBottomAttrDel">
          <template slot="menuLeft">
            <el-button icon="el-icon-plus" size="small" type="primary" @click="addDialogClickHandler">创建</el-button>
            <h3 style="display: inline-block;margin-right: 20px;margin-bottom: 10px;">属性池列表</h3>
            <el-button icon="el-icon-plus" size="mini" type="primary" @click="addDialogClickHandler">创建</el-button>
          </template>
        </avue-crud>
      </div>
      <span slot="footer" class="dialog-footer avue-dialog__footer">
      <span slot="footer" class="dialog-footer">
         <el-button type="primary" @click="addDialogSavaHandler">确 定</el-button>
         <el-button @click="addDialogClose">取 消</el-button>
        </span>
@@ -271,8 +272,8 @@
      >
      </avue-crud>
      <span slot="footer" class="dialog-footer">
         <el-button @click="dialogAttrClose">取 消</el-button>
         <el-button type="primary" @click="dialogAttrAddClickHandler">确 定</el-button>
         <el-button @click="dialogAttrClose">取 消</el-button>
        </span>
    </el-dialog>
@@ -496,6 +497,7 @@
        index: false,
        selection: false,
        refreshBtn: false,
        header:false,
        column: [
          {
            label: '类型名',
@@ -554,6 +556,8 @@
      versionAddFlag: false,
      inheritTreeData: [],
      lifeData: [],//生命周期下拉数据
      subLifeData:[],//备选生命周期下拉数据
      allLifeData:[],
      versionData: [],//版本规则数据
      dialogAttrSelectList: [],
      searchAttrParams: {},
@@ -575,12 +579,16 @@
        height: 450,
        searchMenuSpan: 8,
        header: false,
        selectable:function(row){
          return row.selectable;
        },
        column: [
          {
            label: '属性名',
            prop: 'id',
            sortable: true,
            search: true,
            width:260
          },
          {
            label: '属性类型',
@@ -592,6 +600,7 @@
            label: '初始值',
            prop: 'defaultValue',
            sortable: true,
            width: 200
          },
          {
            label: '说明',
@@ -621,8 +630,10 @@
        editBtn: false,
        refreshBtn: false,
        selection: false,
        height: 210,
        height: 220,
        addBtn: false,
        gridBtn:false,
        columnBtn:false,
        menuWidth:100,
        // index:false,
        column: [
@@ -630,12 +641,14 @@
            label: '属性名',
            prop: 'id',
            sortable: true,
            width:260,
          },
          {
            prop: 'btmTypeId',
            label: '业务类型',
            sortable: true
            sortable: true,
            width: 200
          },
          {
            label: '属性类型',
@@ -647,7 +660,7 @@
            label: '初始值',
            prop: 'defaultValue',
            sortable: true,
            width:150,
            width:200,
          },
          {
            label: '说明',
@@ -671,22 +684,26 @@
          {
            prop: 'id',
            label: '属性名',
            sortable: true
            sortable: true,
            width:260
          },
          {
            prop: 'btmTypeId',
            label: '业务类型',
            sortable: true
            sortable: true,
            width:200
          },
          {
            prop: 'attributeDataType',
            label: '属性类型',
            sortable: true
            sortable: true,
            width:150
          },
          {
            prop: 'defaultValue',
            label: '默认值',
            sortable: true
            sortable: true,
            width: 200
          },
          {
            prop: 'description',
@@ -707,7 +724,8 @@
        delimiter: '', // 分隔符
        versionRule: '0', // 版次号规则
        lifeCycleId: '', // 生命周期
        subLifeCycleId: [], // 生命周期备选列表,
        subLifeCycleId: '', // 生命周期备选列表,
        subLifeCycleIdList:[],
        apNameArray: "", // 属性池列表’,‘分隔
      },
      nodeRow: {},
@@ -748,6 +766,19 @@
    this.getLifeCycle();
  },
  mounted() {
  },
  watch:{
    'form.lifeCycleId':{
      handler(newval) {
        if(this.form.lifeCycleId){
          this.subLifeData = this.allLifeData.filter(item=>{
            return item.id!=this.form.lifeCycleId
          });
        }else {
          this.subLifeData = this.allLifeData
        }
      },
    }
  },
  methods: {
    //树表查询
@@ -790,7 +821,7 @@
    //获取生命周期数据
    getLifeCycle(){
      gridLifeCycle().then(res => {
        this.lifeData = res.data.data;
        this.allLifeData=res.data.data;
      });
    },
    // 创建按钮
@@ -801,173 +832,10 @@
      }
      this.title = 'add';
      this.form.fName = this.nodeRow.id === 'topNode' ? "" : this.nodeRow.id;
      this.lifeData = this.allLifeData;
      this.subLifeData = this.allLifeData;
      this.form.inputRevisionFlag = JSON.parse(this.form.inputRevisionFlag); // 字符串false转换为布尔值
      this.visible = true;
    },
    // 对话框 属性池列表增加按钮
    addDialogClickHandler() {
      this.dialogAttrLoading = true;
      this.attrPollDialogVisible = true;
      this.dialogAttrReload = Math.random(); // 强制刷新表格 解决表格错行
      this.getAttrDialogDta();
    },
    // 查询属性池列表数据
    getAttrDialogDta() {
      gridAttribute(this.attrPage.currentPage, this.attrPage.pageSize, this.searchAttrParams).then(res => {
        const data = res.data.data;
        this.dialogAttrSaveData = data;
        this.attrPage.total = res.data.total;
        this.dialogAttrLoading = false;
      }).catch(err => {
        this.$message.error(err);
      });
    },
    // 新增属性池列表关闭对话框
    dialogAttrClose() {
      this.attrPollDialogVisible = false;
      this.searchAttrParams = {};
    },
    // 添加属性池表格选择框
    dialogAttrSelectChange(row) {
      this.dialogAttrSelectList = row;
    },
    // 添加属性池 行点击
    dialogAttrRowClickHandler(row) {
      func.rowClickHandler(
        row,
        this.$refs.dialogAttrCrud,
        this.attrLastIndex,
        (newIndex) => {
          this.attrLastIndex = newIndex;
        },
        () => {
          this.selectList = [];
        }
      );
    },
    //添加属性池 条数
    attrSizeChange(val) {
      this.attrPage.pageSize = val;
      this.getAttrDialogDta()
    },
    //添加属性池 页码
    attrCurrentChange(val) {
      this.attrPage.currentPage = val;
      this.getAttrDialogDta();
    },
    //添加属性池 搜索
    attrHandleSearch(params, done) {
      if (func.isEmptyObject(params)) {
        this.searchAttrParams = {};
      } else {
        this.searchAttrParams = {
          "conditionMap[id]": "*" + params.id + "*"
        };
      }
      this.getAttrDialogDta();
      done();
    },
    //添加属性池 清空搜索
    attrHandleReset() {
      this.searchAttrParams = {};
      this.getAttrDialogDta();
    },
    // 添加属性池 保存
    dialogAttrAddClickHandler() {
      let hasDuplicate = false;
      // 先创建一个临时数组来存储不重复的项
      const newItems = [];
      this.dialogAttrSelectList.forEach(item => {
        const exists = this.dialogAttrData.some(existingItem => existingItem.id === item.id);
        if (exists) {
          hasDuplicate = true;
          return;
        }
        // 如果没有重复项,则将该项添加到临时数组中
        newItems.push({
          id: item.id,
          attributeDataType: item.attributeDataType,
          defaultValue: item.defaultValue,
          description: item.description
        });
      });
      if (hasDuplicate) {
        this.$message.error('请检查是否有添加重复项!');
      } else {
        // 如果没有重复项,将新项添加到 dialogAttrData
        this.dialogAttrData.push(...newItems);
        this.attrPollDialogVisible = false;
      }
    },
    // 属性池删除
    dialogBottomAttrDel(form, index) {
      this.dialogAttrData.splice(index, 1);
    },
    // 只能输入英文正则校验
    validateEnglishOnly(rule, value, callback) {
      if (!value) {
        return callback(new Error('请输入类型名称'));
      }
      if (!/^[A-Za-z]+$/.test(value)) {
        return callback(new Error('只能输入英文字母'));
      }
      callback(); // 验证通过
    },
    // 清空表单
    resetForm() {
      const form = {
        id: '', // 类型名称
        name: '', // 标签
        fName: '', // 继承自
        implClass: '', // 实现类
        description: '', // 描述
        revLevel: '2', // 版本规则
        revisionRuleId: '',// 版本号规则
        inputRevisionFlag: 'false', // 手工输入
        delimiter: '', // 分隔符
        versionRule: '0', // 版次号规则
        lifeCycleId: '', // 生命周期
        subLifeCycleId: [], // 生命周期备选列表,
        lifeCycleIds:'',
        apNameArray: "", // 属性池列表’,‘分隔
      };
      this.dialogAttrData = []; // 将属性池表格置空
      this.form = {...form};
      this.$refs.form.clearValidate();
    },
    // 新增编辑对话框取消
    addDialogClose() {
      this.resetForm();
      this.visible = false;
    },
    // 版本规则切换 置空其他条件
    revLevelChange() {
      this.form.inputRevisionFlag = false;
      this.form.delimiter = "";
      this.form.versionRule = "0";
      this.form.revisionRuleId = "";
    },
    // 新增编辑保存
@@ -976,7 +844,8 @@
        this.$message.error('请检查版本号规则不能为空');
        return;
      }
      this.form.lifeCycleIds=this.form.subLifeCycleId.join(',');
      this.form.lifeCycleIds=this.form.subLifeCycleIdList.join(',');
      this.form.subLifeCycleId=this.form.subLifeCycleIdList.join(',');
      this.form.apNameArray = this.dialogAttrData ? this.dialogAttrData.map(item => item.id).join(',') : "";
      this.$refs.form.validate((valid) => {
        const saveFunction = this.title === 'add' ? addLifeCycle : updateLifeCycle;
@@ -1026,9 +895,7 @@
      this.form = {...this.nodeRow};
      this.form.inputRevisionFlag = JSON.parse(this.form.inputRevisionFlag); // 字符串false转换为布尔值
      // this.form.fName = this.nodeRow.id === 'topNode' ? "" : this.nodeRow.id;
      this.form.subLifeCycleId = (this.nodeRow.lifeCycleIds && this.nodeRow.lifeCycleIds.trim())
        ? this.nodeRow.lifeCycleIds.split(',').map(item => ({id: item.trim()}))
        : [];
      this.form.subLifeCycleIdList = this.nodeRow.lifeCycleIds.split(',');
      this.dialogAttrData = this.nodeRow.attributes ? JSON.parse(this.nodeRow.attributes) : [];
      function  processChildren(item,fName) {
        if (item.children && item.children.length > 0) {
@@ -1057,6 +924,166 @@
      this.visible = true;
    },
    subLifeChange(data){
      if (data.value.length == 0) {
        this.lifeData = this.allLifeData
      } else {
        this.lifeData = this.allLifeData.filter(item => {
          return !data.value.includes(item.id)
        });
      }
    },
    // 对话框 属性池列表增加按钮
    addDialogClickHandler() {
      this.dialogAttrLoading = true;
      this.attrPollDialogVisible = true;
      this.dialogAttrReload = Math.random(); // 强制刷新表格 解决表格错行
      this.getAttrDialogDta();
    },
    // 查询属性池列表数据
    getAttrDialogDta() {
      gridAttribute(this.attrPage.currentPage, this.attrPage.pageSize, this.searchAttrParams).then(res => {
        const data = res.data.data.map(item=>{
          item.selectable=!this.dialogAttrData.some(existingItem => existingItem.id === item.id);
          return item;
        });
        this.dialogAttrSaveData=data;
        this.attrPage.total = res.data.total;
        this.dialogAttrLoading = false;
      }).catch(err => {
        this.$message.error(err);
      });
    },
    // 新增属性池列表关闭对话框
    dialogAttrClose() {
      this.attrPollDialogVisible = false;
      this.searchAttrParams = {};
    },
    // 添加属性池表格选择框
    dialogAttrSelectChange(row) {
      this.dialogAttrSelectList = row;
    },
    // 添加属性池 行点击
    dialogAttrRowClickHandler(row) {
      if(!row.selectable){
        return;
      }
      func.rowClickHandler(
        row,
        this.$refs.dialogAttrCrud,
        this.attrLastIndex,
        (newIndex) => {
          this.attrLastIndex = newIndex;
        },
        () => {
          this.selectList = [];
        }
      );
    },
    //添加属性池 条数
    attrSizeChange(val) {
      this.attrPage.pageSize = val;
      this.getAttrDialogDta()
    },
    //添加属性池 页码
    attrCurrentChange(val) {
      this.attrPage.currentPage = val;
      this.getAttrDialogDta();
    },
    //添加属性池 搜索
    attrHandleSearch(params, done) {
      if (func.isEmptyObject(params)) {
        this.searchAttrParams = {};
      } else {
        this.searchAttrParams = {
          "conditionMap[id]": "*" + params.id + "*"
        };
      }
      this.getAttrDialogDta();
      done();
    },
    //添加属性池 清空搜索
    attrHandleReset() {
      this.searchAttrParams = {};
      this.getAttrDialogDta();
    },
    // 添加属性池 保存
    dialogAttrAddClickHandler() {
      this.dialogAttrSelectList.forEach(item => {
        this.dialogAttrData.push({
          id: item.id,
          attributeDataType: item.attributeDataType,
          defaultValue: item.defaultValue,
          description: item.description
        });
      });
      this.attrPollDialogVisible = false;
    },
    // 属性池删除
    dialogBottomAttrDel(form, index) {
      this.dialogAttrData.splice(index, 1);
    },
    // 只能输入英文正则校验
    validateEnglishOnly(rule, value, callback) {
      if (!value) {
        return callback(new Error('请输入类型名称'));
      }
      if (!/^[A-Za-z]+$/.test(value)) {
        return callback(new Error('只能输入英文字母'));
      }
      callback(); // 验证通过
    },
    // 清空表单
    resetForm() {
      const form = {
        id: '', // 类型名称
        name: '', // 标签
        fName: '', // 继承自
        implClass: '', // 实现类
        description: '', // 描述
        revLevel: '2', // 版本规则
        revisionRuleId: '',// 版本号规则
        inputRevisionFlag: 'false', // 手工输入
        delimiter: '', // 分隔符
        versionRule: '0', // 版次号规则
        lifeCycleId: '', // 生命周期
        subLifeCycleId: '', // 生命周期备选列表,
        subLifeCycleIdList:[],
        lifeCycleIds:'',
        apNameArray: "", // 属性池列表’,‘分隔
      };
      this.dialogAttrData = []; // 将属性池表格置空
      this.form = {...form};
      this.$refs.form.clearValidate();
    },
    // 新增编辑对话框取消
    addDialogClose() {
      this.resetForm();
      this.visible = false;
    },
    // 版本规则切换 置空其他条件
    revLevelChange() {
      this.form.inputRevisionFlag = false;
      this.form.delimiter = "";
      this.form.versionRule = "0";
      this.form.revisionRuleId = "";
    },
    // 删除按钮
    deleteClickHandler() {
      if (func.isEmptyObject(this.nodeRow)) {