xiejun
2023-07-13 2871cb99e018f6bf9e2ef76a424a1429a7c818f0
Source/UBCS-WEB/src/views/modeling/BusinessAdd.vue
@@ -7,7 +7,8 @@
    width="70%"
    style="height: 115vh;"
    >
        <el-form ref="form" :model="btmType" show-message="true" inline size="medium" label-suffix=":" class="btmTypeForm" :rules="rules" @resetFields="resetForm" status-icon="true">
    <el-form ref="form" :model="btmType" show-message="true" inline size="medium" label-suffix=":" class="btmTypeForm"
             :rules="rules" @resetFields="resetForm" status-icon="true">
            <el-form-item label="英文名称" label-width="100px" required="true" prop="id">
                <el-input v-model="btmType.id" :prefix-icon="icons.key"></el-input>
            </el-form-item>
@@ -17,10 +18,11 @@
            <el-form-item label="数据库表名" label-width="100px">
                <el-input v-model="btmType.tableName" :prefix-icon="icons.tableName"></el-input>
            </el-form-item>
            <el-form-item label="所属领域" label-width="100px" prop="domain">
                <el-select v-model="btmType.domain" :prefix-icon="icons.domain">
      <el-form-item label="所属领域" label-width="100px" prop="domain" class="domainSelect">
        <el-select v-model="btmType.bizDomain" :prefix-icon="icons.domain">
                    <el-option v-for="item in domainOption"
                    :label="item.label" :value="item.value" :key="item.value"></el-option>
                     :label="item.label" :value="item.value" :key="item.value">
          </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="版本规则" label-width="100px">
@@ -30,7 +32,7 @@
                </el-input>
            </el-form-item>
            <el-form-item label="生命周期" label-width="100px">
                <el-input v-model="btmType.lifeCycleId" :prefix-icon="icons.lifeCycle">
        <el-input v-model="btmType.lifeCycleName" :prefix-icon="icons.lifeCycle" class="lifeCycle" @focus="openLifeCycle" clearable @clear="clearLifeCycle">
                    <i slot="suffix" class="el-input__icon el-icon-search"></i>
                </el-input>
            </el-form-item>
@@ -38,7 +40,7 @@
            <el-form-item label="开启视图" label-width="100px" class="viewFlag">
                <el-switch v-model="btmType.viewFlag" active-color="#13ce66" @change="viewChange"></el-switch>
            </el-form-item>
            <el-form-item label="视图语句" label-width="100px">
        <el-form-item label="视图语句" label-width="100px" class="viewInput">
                <el-input v-model="btmType.view" :prefix-icon="icons.view" :disabled="!btmType.viewFlag"></el-input>
            </el-form-item>
        </div>
@@ -58,12 +60,21 @@
                <el-button type="danger"
                icon="el-icon-plus"
                size="small"
                @click="rowAdd()">属性选择</el-button>
                   @click="rowAdd()">属性选择
        </el-button>
      </template>
      <template slot="attrDataTypeText" slot-scope="{row}">
        <el-tag>{{ row.attrDataTypeText }}</el-tag>
            </template>
          <template slot="menu" slot-scope="{row,index}">
            <el-button icon="el-icon-edit" size="small" type="text" v-if="!row.$cellEdit" @click="cellEditClick(row)">编辑</el-button>
            <el-button icon="el-icon-delete" size="small" type="text" v-if="!row.$cellEdit" @click="removeFormAttrTable(row,index)">移除</el-button>
            <el-button icon="el-icon-check" size="small" type="text" v-if="row.$cellEdit" @click="cellEditSave(row,index)">保存</el-button>
        <el-button icon="el-icon-edit" size="small" type="text" v-if="!row.$cellEdit" @click="cellEditClick(row)">编辑
        </el-button>
        <el-button icon="el-icon-delete" size="small" type="text" v-if="!row.$cellEdit"
                   @click="removeFormAttrTable(row,index)">移除
        </el-button>
        <el-button icon="el-icon-check" size="small" type="text" v-if="row.$cellEdit" @click="cellEditSave(row,index)">
          保存
        </el-button>
          </template>
        </avue-crud>
        <div slot="footer" class="dialog-footer">
@@ -107,7 +118,10 @@
             :data="revisionRef.data"
             :page.sync="revisionRef.page"
             ref="revisionRef"
             @row-click="revisionClick">
                 @row-click="revisionClick"
                 v-loading="revisionRef.loading"
                @search-change="searchRevisionRule"
                 @search-reset="clearSearchRevisionRule">
                <template slot="radio"
                slot-scope="{row}">
                    <el-radio v-model="revisionRef.selectRow"
@@ -120,7 +134,37 @@
                <el-button @click="cancelRevision">取消</el-button>
            </div>
        </el-dialog>
    <!-- 生命周期的参照 -->
    <el-dialog title="请选择生命周期"
               :visible.sync="lifeCycleRef.visible"
               append-to-body
               width="80%">
      <avue-crud class="lifeCycleRef"
                 :option="lifeCycleRef.option"
                 :data="lifeCycleRef.data"
                 :page.sync="lifeCycleRef.page"
                 ref="lifeCycleRef"
                 @row-click="lifeCycleClick"
                 v-loading="lifeCycleRef.loading"
                @search-change="searchLifeCycle"
                 @search-reset="clearSearchLifeCycle">
        <template slot="radio"
                  slot-scope="{row}">
          <el-radio v-model="lifeCycleRef.selectRow"
                    :label="row.$index">&nbsp;
          </el-radio>
        </template>
      </avue-crud>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirmLifeCycle">确定</el-button>
        <el-button @click="cancelLifeCycle">取消</el-button>
      </div>
    </el-dialog>
  </el-dialog>
</template>
@@ -129,6 +173,8 @@
import { add,update } from '@/api/omd/btmType';
import { queryPage } from '@/api/omd/OmdAttribute';
import { getPage } from '@/api/omd/revisionRule';
import {getList} from '@/api/modeling/cycle';
export default {
    name: 'BusinessAdd',
    props: {
@@ -140,6 +186,15 @@
        },
        icons: {
            type: Array
    }
  },
  watch: {
    btmType: {
      handler(newval, oldval) {
        console.log('监听', newval, oldval)
      },
      deep: true,
      immediate: true
        }
    },
    data() {
@@ -157,6 +212,7 @@
                menu: true,
                editBtn: false,
                delBtn: false,
        columnBtn: false,
                menuWidth: 150,
                addBtn:false,
                highlightCurrentRow: true,
@@ -170,10 +226,9 @@
                        prop: 'name',
                        align: 'center',
                        cell: true
                    },
                    {
          },{
                        label: "类型",
                        prop: "attrDataType",
            prop: "attrDataTypeText",
                        align: 'center',
                        slot: true
                    },
@@ -266,6 +321,71 @@
                    currentPage:1,
                    pageSize: 10
                },
        loading: false,
        selectRow: '',
        searchKey: null,
        option: {
          height: 360,
          addBtn: false,
          refreshBtn: false,
          columnBtn: false,
          menu: false,
          border: true,
          reserveSelection: true,
          searchMenuSpan: 8,
          searchShowBtn: false,
          highlightCurrentRow: true,
          column: [{
            label: '选择',
            prop: 'radio',
            width: 60,
            hide: false
          },
            {
              label: '英文名称',
              prop: 'id',
              search: true
            },
            {
              label: "中文名称",
              prop: "name",
              search: true,
            },
            {
              label: "跳跃字符",
              prop: "skipCode"
            },
            {
              label: "初始值",
              prop: "startCode"
            },
            {
              label: "步长",
              prop: "serialStep"
            },
            {
              label: "前缀",
              prop: "prefixCode"
            },
            {
              label: "后缀",
              prop: "suffixCode"
            },
            {
              label: "描述",
              prop: "description",
              type: "textarea"
            }
          ]
        },
      },
      lifeCycleRef: {
        visible: false,
        page: {
          currentPage: 1,
          pageSize: 10
        },
        loading: false,
                selectRow:'',
                searchKey: null,
                option:{
@@ -329,6 +449,9 @@
                    { pattern: /^[A-Za-z]+$/, message: '业务类型编号只能为英文', trigger: 'blur' },
                    { min: 2, max: 20, message: '长度在2到20个字符', trigger: 'blur' }
                ],
        name: [
          {required: true, message: '请输入业务类型中文名称', trigger: 'blur'}
        ],
                domain: [
                    { required: true, message: '请选择所属领域', trigger: 'blur' }
                ]
@@ -359,7 +482,7 @@
        },
        // 属性池加载
        attrRefOnLoad(){
            if (!this.attrRef.queryNotIn || (this.attrRef.queryNotIn === '' && this.btmType.attributes !== [])){
      if (this.attrRef.queryNotIn != '' && this.btmType.attributes !== undefined && this.btmType.attributes.length > 0) {
              this.attrRef.queryNotIn = '';
               this.btmType.attributes.forEach(item => {
                  this.attrRef.queryNotIn += (item.id + ",")
@@ -402,20 +525,19 @@
            if(!this.btmType.attributes) {
              this.btmType.attributes = [];
            }
      console.log(this.attrRef.selectData);
            this.attrRef.selectData.forEach(item => {
                this.btmType.attributes.push({
                    id: item.id,
                    name: item.name,
                    typeValue: item.typeValue,
                    typeKey: item.typeValue,
                    attrDataType : item.typeKey,
          attrDataTypeText: item.typeValue,
                    defaultValue: item.defaultValue,
                    description: item.description,
                    attributeLength: item.maxLength,
                    referBtmTypeId: item.referTypeCode,
                    referBtmTypeName: item.referToName,
                    enumId: item.dictCode,
                    // enumName: item,
                });
                this.attrRef.queryNotIn += (item.id + ",")
            });
@@ -430,6 +552,23 @@
        // 添加业务类型
        submitBtmType(){
            console.log(this.btmType);
      if (!this.btmType.attributes){
         this.$message.warning("还没有为业务类型选择属性");
         return;
      }else{
        let nullFlag = false;
         this.btmType.attributes.forEach(item => {
            if (!item.name){
               this.$message.warning("第" + (item.$index+1) + "行的中文名称不能为空");
               nullFlag = true;
               return;
            }
         })
        if (nullFlag){
          return;
        }
      }
            add(this.btmType,true).then(res => {
                // 添加完成,回调父组件的刷新
                this.$message.success('保存成功');
@@ -466,22 +605,49 @@
            row.$cellEdit = false;
        },
        // 打开版本规则参照
        async openRevision(){
            await getPage().then(res => {
     openRevision() {
      this.revisionRef.visible = true;
      this.revisionRuleOnLoad();
    },
    // 版本参照列表的默认查询方法
    revisionRuleOnLoad(){
      this.revisionRef.loading = true;
      getPage().then(res => {
                this.revisionRef.data = res.data.data.records;
            });
            this.revisionRef.visible = true;
      setTimeout(() => {
        this.revisionRef.loading = false;
      }, 600)
      this.$nextTick(() => {
        this.$refs.revisionRef.refreshTable();
      });
    },
    // 打开版本规则参照
    openLifeCycle() {
      this.lifeCycleRef.visible = true;
      this.lifeCycleOnLoad();
    },
    // 生命周期列表的默认查询方法
    lifeCycleOnLoad(){
      this.lifeCycleRef.loading = true;
      getList().then(res => {
        this.lifeCycleRef.data = res.data.data.records;
      });
      setTimeout(() => {
        this.lifeCycleRef.loading = false;
      }, 600)
      this.$nextTick(() => {
        this.$refs.lifeCycleRef.refreshTable();
      });
        },
       // 关闭版本规则参照弹窗
       closeRevisionDialog(){
            this.revisionRef.visible = false;
       },
       // 版本规则参照列表检索
       revisionRefSearch(){
    // 关闭生命周期参照弹窗
    closeLifeCycleDialog() {
      this.lifeCycleRef.visible = false;
       },
       // 版本规则选中事件
       revisionChange(){},
       // 确认选中版本规则
       confirmRevision(){
            this.btmType.revisionFlag = true;
@@ -490,11 +656,24 @@
            this.btmType.inputRevisionFlag = false;
            this.cancelRevision();
       },
    // 确认选中生命周期
    confirmLifeCycle() {
      this.btmType.lifeCycleFlag = true;
      this.btmType.lifeCycleId = this.lifeCycleRef.selectData.id;
      this.btmType.lifeCycleName = this.lifeCycleRef.selectData.name;
      this.cancelLifeCycle();
    },
       // 取消选中版本规则
       cancelRevision(){
            this.revisionRef.selectRow  = '';
            this.revisionRef.selectData = {};
            this.closeRevisionDialog();
    },
    // 取消选中生命周期
    cancelLifeCycle() {
      this.lifeCycleRef.selectRow = '';
      this.lifeCycleRef.selectData = {};
      this.closeLifeCycleDialog();
       },
       // 版本规则单选
       revisionClick(row){
@@ -504,15 +683,90 @@
                name: row.name,
            };
       },
    // 生命周期单选
    lifeCycleClick(row) {
      this.lifeCycleRef.selectRow = row.$index;
      this.lifeCycleRef.selectData = {
        id: row.id,
        name: row.name,
      };
    },
    // 取消版本规则
       clearRevision(){
            this.$delete(this.btmType,'revisionFlag');
            this.$delete(this.btmType,'revisionRuleId');
            this.$delete(this.btmType,'revisionRuleName');
            this.$delete(this.btmType,'inputRevisionFlag');
       },
    // 取消生命周期
    clearLifeCycle() {
      this.$delete(this.btmType, 'lifeCycleFlag');
      this.$delete(this.btmType, 'lifeCycleId');
      this.$delete(this.btmType, 'lifeCycleName');
    },
    // 表单重置
       resetForm(){
        this.btmType = {};
        this.$refs.form.resetFields();
    },
    /**
     * 搜索版本规则
     * @param params 搜索框输入值  {id: '',name: ''} 直接获取就行
     * @param done 执行完成后的回调
     */
    searchRevisionRule(params,done){
      let condition = {};
      if (params.id){
          condition['id_like'] = params.id;
      }
      if (params.name){
          condition['name_like'] = params.name;
      }
      this.revisionRef.loading = true;
      getPage(this.revisionRef.page.currentPage,this.revisionRef.page.pageSize,condition).then(res => {
        this.revisionRef.data = res.data.data.records;
      });
      setTimeout(() => {
        done();
        this.revisionRef.loading = false;
      }, 600);
      this.$nextTick(() => {
        this.$refs.revisionRef.refreshTable();
      });
    },
    /**
     * 搜索生命周期
     * @param params 搜索框输入值
     * @param done 执行完成后的回调
     */
    searchLifeCycle(params,done){
      let condition = {};
      if (params.id){
        condition['id_like'] = params.id;
      }
      if (params.name){
        condition['name_like'] = params.name;
      }
      this.lifeCycleRef.loading = true;
      getList(this.lifeCycleRef.page.currentPage,this.lifeCycleRef.page.pageSize,condition).then(res => {
        this.lifeCycleRef.data = res.data.data.records;
      });
      setTimeout(() => {
        done();
        this.lifeCycleRef.loading = false;
      }, 600);
      this.$nextTick(() => {
        this.$refs.lifeCycleRef.refreshTable();
      });
    },
    // 取消版本规则搜索
    clearSearchRevisionRule(item){
      this.revisionRuleOnLoad();
    },
    // 取消生命周期搜索
    clearSearchLifeCycle(item){
      this.lifeCycleOnLoad();
      console.log(item);
       }
    }
}
@@ -528,7 +782,15 @@
    display: none !important;
}
.lifeCycleRef > .el-card:nth-of-type(2) > .el-card__body > .avue-crud__menu {
  display: none !important;
}
.btmTypeForm > .el-form-item > .el-form-item__content > .el-input > .el-input__inner {
  width: 200px;
}
.domainSelect > .el-form-item__content > .el-select > .el-input > .el-input__inner {
    width: 200px;
}
@@ -536,6 +798,10 @@
    width: 305px;
}
.viewInput > .el-form-item__content > .el-input > .el-input__inner {
  width: 200px;
}
.descClass > .el-input__inner {
    width: 57vw
}