ludc
2023-11-07 6a5d1fda15176a5866eaccb31f0e78ef65dd1461
Source/UBCS-WEB/src/views/modeling/Business.vue
@@ -1,111 +1,397 @@
<template>
  <div>
    <avue-form :model="form" :rules="rules">
      <avue-form-item label="姓名" prop="name">
        <el-input v-model="form.name"></el-input>
      </avue-form-item>
      <avue-form-item label="学历" prop="education">
        <el-select v-model="form.education" placeholder="请选择">
          <el-option label="博士" value="博士"></el-option>
          <el-option label="硕士" value="硕士"></el-option>
          <el-option label="本科" value="本科"></el-option>
          <el-option label="大专" value="大专"></el-option>
          <el-option label="中专" value="中专"></el-option>
        </el-select>
      </avue-form-item>
      <avue-form-item label="工作经历">
        <table class="table">
          <thead>
          <tr>
            <th>公司</th>
            <th>职位</th>
            <th>起止时间</th>
          </tr>
          </thead>
          <tbody>
          <tr v-for="(item, index) in form.workExperience" :key="index">
            <td>
              <el-input v-model="item.company"></el-input>
            </td>
            <td>
              <el-input v-model="item.position"></el-input>
            </td>
            <td>
              <el-date-picker
                v-model="item.dateRange"
                range-separator="至"
                type="daterange"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                format="yyyy-MM-dd"
              ></el-date-picker>
            </td>
          </tr>
          </tbody>
        </table>
      </avue-form-item>
    </avue-form>
  </div>
  <el-container>
    <el-header class="businessHeader" style="height: 40px;padding:0 8px">
      <div>
        <el-button v-if="permissionList.addBtn" icon="el-icon-plus" size="small" type="primary" @click="businessAdd" plain>
          新增
        </el-button>
        <el-button v-if="permissionList.editBtn" icon="el-icon-edit" size="small" type="primary" @click="businessEdit" plain>
          修改
        </el-button>
        <el-button v-if="permissionList.table" icon="el-icon-thumb" size="small" type="primary"
                   @click="selectFromTable" plain> 从已有中获取
        </el-button>
      </div>
    </el-header>
    <el-container>
      <el-aside width="240px">
        <basic-container class="businessTreeContainer">
          <p style="margin-top: 10px;font-weight: 570;font-size: 19px">{{ treeOption.title }}</p>
          <avue-tree id="basic" :data="treeData" :option="treeOption" class="businessTree" @node-click="nodeClick">
            <span slot-scope="{ node, data }" class="el-tree-node__label">
              <span>
                <i :class="(node || {}).level === 2 ? 'el-icon-star-off' : 'el-icon-folder-opened'"></i>
                {{ (node || {}).label }}
              </span>
            </span>
          </avue-tree>
        </basic-container>
      </el-aside>
      <el-container>
        <el-main>
          <!--基本信息-->
          <basic-container>
            <p style="margin-top: 10px;font-weight: 570;font-size: 19px">基本信息</p>
            <el-descriptions :column="3" :size="size" border class="margin-top">
              <el-descriptions-item :contentStyle="descriptionOption.contentStyle"
                                    :labelStyle="descriptionOption.labelStyle">
                <template slot="label">
                  <i :class="icons.key"></i>
                  英文名称
                </template>
                {{ obj.id }}
              </el-descriptions-item>
              <el-descriptions-item :contentStyle="descriptionOption.contentStyle"
                                    :labelStyle="descriptionOption.labelStyle">
                <template slot="label">
                  <i :class="icons.name"></i>
                  中文名称
                </template>
                {{ obj.name }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label" :contentStyle="descriptionOption.contentStyle"
                          :labelStyle="descriptionOption.labelStyle">
                  <i :class="icons.tableName"></i>
                  数据库表名
                </template>
                {{ obj.tableName }}
              </el-descriptions-item>
              <el-descriptions-item :contentStyle="descriptionOption.contentStyle"
                                    :labelStyle="descriptionOption.labelStyle">
                <template slot="label">
                  <i :class="icons.domain"></i>
                  所属领域
                </template>
                <el-tag v-if="obj.domainText" size="small">
                  {{ obj.domainText }}
                </el-tag>
                <span v-else></span>
              </el-descriptions-item>
              <el-descriptions-item :contentStyle="descriptionOption.contentStyle"
                                    :labelStyle="descriptionOption.labelStyle">
                <template slot="label">
                  <i :class="icons.revisionRule"></i>
                  版本规则
                </template>
                {{ obj.revisionRuleName ? obj.revisionRuleName + '(' + obj.revisionRuleId + ')' : '' }}
              </el-descriptions-item>
              <el-descriptions-item :contentStyle="descriptionOption.contentStyle"
                                    :labelStyle="descriptionOption.labelStyle">
                <template slot="label">
                  <i :class="icons.lifeCycle"></i>
                  生命周期
                </template>
                {{ obj.lifeCycleName ? obj.lifeCycleName + '(' + obj.lifeCycleId + ')' : '' }}
              </el-descriptions-item>
<!--              <el-descriptions-item :contentStyle="descriptionOption.contentStyle"-->
<!--                                    :labelStyle="descriptionOption.labelStyle">-->
<!--                <template slot="label">-->
<!--                  <i :class="icons.view"></i>-->
<!--                  视图-->
<!--                </template>-->
<!--                <el-tag v-if="obj.viewText" size="small">-->
<!--                  {{ obj.viewText }}-->
<!--                </el-tag>-->
<!--                <span v-else></span>-->
<!--              </el-descriptions-item>-->
              <!-- <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-arrow-down"></i>
              实现类
            </template>
            {{ obj.implClass }}
          </el-descriptions-item> -->
              <el-descriptions-item :contentStyle="descriptionOption.contentStyle"
                                    :labelStyle="descriptionOption.labelStyle">
                <template slot="label">
                  <i :class="icons.desc"></i>
                  描述
                </template>
                {{ obj.description }}
              </el-descriptions-item>
            </el-descriptions>
          </basic-container>
          <!-- 属性列表-->
          <basic-container>
            <p style="margin-top: 10px;font-weight: 570;font-size: 19px">属性列表</p>
            <avue-crud v-model="obj" :data="obj.attributes" :option="loadOption" class="attributeCrud">
              <template slot="attrDataTypeText" slot-scope="{row}">
                <el-tag>{{ row.attrDataTypeText }}</el-tag>
              </template>
            </avue-crud>
          </basic-container>
        </el-main>
        <el-dialog :visible="ref.visible" append-to-body title="从数据库中添加" width="700px" @close="dialoghandelfalse" top="9vh">
          选择领域:
          <el-select v-model="domain" placeholder="请选择" size="small" @change="refOnLoad">
            <el-option v-for="item in domainOptions" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
          <div class="sep" style="height:7px">
          </div>
          <avue-crud ref="businessCrud" v-model="ref.form" :data="ref.data" :option="ref.option" class="businessCrud"
                     @selection-change="selectionChange">
          </avue-crud>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialoghandelfalse">取 消</el-button>
            <el-button type="primary" @click="dialoghandeltrue">确 定</el-button>
          </span>
        </el-dialog>
      </el-container>
    </el-container>
    <business-add ref="btmAdd" :btmType="addOption.btmType" :domainOption="domainOptions" :icons="icons"
                  @refreshTable="initTreeOnLoad">
    </business-add>
  </el-container>
</template>
<script>
import {
  initTree,
  refOnLoad,
  getDomain,
  saveFromTable,
  getDetail
} from "@/api/omd/btmType"
import {mapGetters} from "vuex";
export default {
  name: "Business",
  data(){
  data() {
    return {
      form: {
        name: "",
        education: "",
        workExperience: [
          { company: "", position: "", dateRange: [] },
          { company: "", position: "", dateRange: [] },
        ],
      //生命周期对话框状态
      packageLifeBox: false,
      //版本规则状态
      rulesFalg: false,
      obj: {},
      selectionList: [],
      treeData: [],
      treeOption: {
        defaultExpandAll: true,
        title: '业务类型树',
        addBtn: false,
        menu: false,
        props: {
          labelText: '',
          label: 'label',
          value: 'oid',
          children: 'childList',
        }
      },
      rules: {
        name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
        education: [{ required: true, message: "请选择学历", trigger: "change" }],
        "workExperience.0.company": [
          { required: true, message: "请输入公司名称", trigger: "blur" },
        ],
        "workExperience.0.position": [
          { required: true, message: "请输入职位名称", trigger: "blur" },
        ],
        "workExperience.0.dateRange": [
          { required: true, message: "请选择起止时间", trigger: "change" },
        ],
        "workExperience.1.company": [
          { required: true, message: "请输入公司名称", trigger: "blur" },
        ],
        "workExperience.1.position": [
          { required: true, message: "请输入职位名称", trigger: "blur" },
        ],
        "workExperience.1.dateRange": [
          { required: true, message: "请选择起止时间", trigger: "change" },
        ],
      addOption: {
        btmType: {},
      },
      loadOption: {
        border: true,
        height: 478,
        editBtn: false,
        addBtn: false,
        menu: false,
        highlightCurrentRow: true,
        refreshBtn: false,
        columnBtn: false,
        column: [
          {
            label: '英文名称',
            prop: 'id',
            align: 'center'
          }, {
            label: '中文名称',
            prop: 'name',
            align: 'center'
          },
          {
            label: "类型",
            prop: "attrDataTypeText",
            align: 'center',
            slot: true
          },
          {
            label: "默认值",
            prop: "defaultValue",
            align: 'center'
          },
          {
            label: "说明",
            prop: "description",
            align: 'center'
          }
        ]
      },
      descriptionOption: {
        labelStyle: 'text-align:center;width:120px',
        contentStyle: 'width:240px;text-align:center;word-break;break-all;'
      },
      domain: null,
      domainOptions: [],
      icons: {
        key: 'el-icon-finished',
        name: 'el-icon-tickets',
        tableName: 'el-icon-date',
        domain: 'el-icon-folder-opened',
        revisionRule: 'el-icon-s-check',
        lifeCycle: 'el-icon-refresh-right',
        view: 'el-icon-view',
        desc: 'el-icon-chat-line-square',
        referType: 'el-icon-search'
      },
      ref: {
        // 从表中选择dialog状态
        visible: false,
        form: {},
        option: {
          height: "550px",
          selection: true,
          headerAlign: 'center',
          border: true,
          index: true,
          rowKey: 'id',
          tabs: true,
          addBtn: false,
          menu: false,
          highlightCurrentRow: true,
          column: [
            {
              label: '表名',
              prop: 'tableName',
              align: 'center',
              display: false
            },
            {
              label: '描述',
              prop: 'description',
              align: 'center',
              display: false
            }
          ]
        },
        data: [],
      }
    }
  }
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.modeling_Business.Business_add, false),
        table: this.vaildData(this.permission.modeling_Business.Business_table, false),
        editBtn: this.vaildData(this.permission.modeling_Business.Business_edit, false),
      }
    }
  },
  created() {
    this.initTreeOnLoad();
    this.initDomainOption();
  },
  methods: {
    nodeClick(data, node, leaf) {
      if (data.oid) {
        getDetail(data.oid).then(res => {
          this.obj = res.data.data;
        })
      } else {
        this.$message.warning('请点击子节点');
      }
    },
    //  基本信息添加
    basicSave(row, done, loading) {
      add(Object.assign({
        createUser: this.userInfo.name
      }, row)).then(() => {
        this.$message.success('新增成功')
        done();
        this.getList();
      }).catch(() => {
        loading()
      })
    },
    //属性添加
    loadSave(row, done, loading) {
      add(Object.assign({
        createUser: this.userInfo.name
      }, row)).then(() => {
        this.$message.success('新增成功')
        done();
        this.getList();
      }).catch(() => {
        loading()
      })
    },
    selectFromTable() {
      this.ref.visible = true;
    },
    refOnLoad(domain) {
      refOnLoad(domain).then(res => {
        this.ref.data = res.data.data;
      })
    },
    initTreeOnLoad() {
      initTree().then(res => {
        this.treeData = res.data.data;
      });
    },
    initDomainOption() {
      getDomain().then(res => {
        this.domainOptions = res.data.data;
      })
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    dialoghandelfalse() {
      this.ref.visible = false;
      this.$refs.businessCrud.toggleSelection()
      this.selectionList = [];
      this.domain = null;
    },
    dialoghandeltrue() {
      if (this.selectionList.length < 1) {
        this.$message.warning('请选择数据');
        return false;
      }
      saveFromTable(this.selectionList, this.domain).then(res => {
        this.$message.success('保存成功');
        this.dialoghandelfalse();
        this.initTreeOnLoad();
      })
    },
    businessAdd() {
      this.$refs.btmAdd.showSubmitDialog = true;
      this.$refs.btmAdd.btmType = {};
      this.ifRefreshBtmAddRefresh();
    },
    businessEdit() {
      if (!this.obj.oid) {
        this.$message.warning("请选择一条叶子节点的业务类型");
        return;
      }
      const json = JSON.stringify(this.obj);
      this.$refs.btmAdd.btmType = JSON.parse(json);
      this.$refs.btmAdd.showSubmitDialog = true;
      this.ifRefreshBtmAddRefresh();
    },
    ifRefreshBtmAddRefresh() {
      // this.$refs.btmAdd.refreshAttrTable();
    }
  },
}
</script>
<style scoped>
.table {
  width: 100%;
  border-collapse: collapse;
<style lang="scss">
#basic {
  height: 770px;
  border-radius: 10px;
}
.table th,
.table td {
  padding: 10px;
  border: 1px solid #ccc;
.businessCrud > .el-card:nth-of-type(2) > .el-card__body > .avue-crud__menu {
  display: none !important;
}
.table th {
  background-color: #f0f0f0;
  font-weight: bold;
.attributeCrud > .el-card:nth-of-type(2) > .el-card__body > .avue-crud__menu {
  display: none !important;
}
</style>
.businessTreeContainer > .el-card > .el-card__body {
  height: 775px;
}</style>