ludc
2024-09-27 0f4bac6483639a3be54d8fa311e005a2a3c99885
Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/uiDefine/rightRegion/bottomTable/components/action.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,433 @@
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="btnActionVisible"
    append-to-body="true"
    class="avue-dialog"
    title="选择Action"
    width="70%"
    @close="dialogClose">
    <el-container>
      <el-aside>
        <basic-container>
          <!-- å·¦ä¾§æ ‘ -->
          <div>
            <avue-tree
              ref="tree"
              v-model="treeForm"
              :data="treeData"
              :option="treeOption"
              node-key="value"
              @node-click="nodeClick">
          <span slot-scope="{ node, data }" class="el-tree-node__label">
           <span style="font-size: 15px">
              <i class="el-icon-s-promotion"></i>
                {{ (node || {}).label }}
            </span>
          </span>
            </avue-tree>
          </div>
        </basic-container>
      </el-aside>
      <el-main>
        <basic-container>
          <div>
            <avue-crud
              ref="crud"
              v-model="form"
              :data="data"
              :option="option"
              :page.sync="page"
              :table-loading="tableLoading"
              @search-change="handleSearch"
              @search-reset="handleReset"
              @refresh-change="handleRefresh"
              @selection-change="selectChangeHandler"
              @row-click="rowClickHandler">
              <template slot="plTypeType" slot-scope="{row}">
                <el-tag :type="row.plTypeType === 'business' ? '' : 'success'">
                  {{ row.plTypeType === 'business' ? '业务类型' : '链接类型' }}
                </el-tag>
              </template>
            </avue-crud>
          </div>
        </basic-container>
      </el-main>
    </el-container>
    <span slot="footer" class="dialog-footer">
        <el-button @click="btnActionVisible = false">取 æ¶ˆ</el-button>
        <el-button type="primary" @click="actionSaveHandler">ç¡® å®š</el-button>
      </span>
  </el-dialog>
</template>
<script>
import {
  getActionTree,
  getActionTableData,
} from '@/api/UI/Action/api'
import func from "@/util/func";
import basicOption from "@/util/basic-option";
export default {
  name: "index",
  data() {
    return {
      btnActionVisible: false,
      currenRow: {}, // action当前行信息
      topMethodsObj: {
        select: true,
        all: true,
        page: false
      },
      transferTitle: ['未选择', '已选择'],
      leftRoleData: [],
      rightRoleData: [],
      form: {},
      bottomTableLoading: false,
      bottomData: [],
      bottomOption: {
        ...basicOption,
        addBtn: false,
        calcHeight: -30,
        selection: false,
        refreshBtn: false,
        // height:'auto',
        column: [
          {
            label: '参数名称',
            prop: 'name',
            rules: [
              {
                required: true,
                message: '请输入参数名称',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '默认值',
            prop: 'defaultValue',
          },
          {
            label: '提示信息',
            prop: 'description',
            span: 24,
            type: 'textarea',
            rows: 4
          },
        ],
      },
      tableLoading: false,
      lastIndex: null,
      selectList: [],
      data: [],
      option: {
        ...basicOption,
        addBtn: false,
        height: 500,
        highlightCurrentRow: true,
        menu:false,
        column: [
          {
            label: '编号',
            prop: 'plCode',
            search: true,
            rules: [
              {
                required: true,
                message: '请输入编号',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '名称',
            prop: 'plName',
            search: true,
            rules: [
              {
                required: true,
                message: '请输入名称',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '类路径',
            prop: 'plCSClass',
            search: true,
            overHidden: true,
          },
          {
            label: '分类',
            prop: 'plActionCls',
            type: 'tree',
            hide: true,
            props: {
              label: 'name',
              value: 'id',
              children: 'childs'
            },
            rules: [
              {
                required: true,
                message: '请选择分类',
                trigger: 'blur'
              }
            ],
            dicData: []
          },
          {
            label: '链接地址',
            prop: 'plBSUrl',
            search: true,
          },
          {
            label: '类型',
            prop: 'plTypeType',
            search: true,
            type: 'select',
            dicData: [{
              label: '业务类型',
              value: 'business'
            }, {
              label: '链接类型',
              value: 'link'
            }],
            rules: [
              {
                required: true,
                message: '请选择类型',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '描述',
            prop: 'plDesc',
            search: true,
            overHidden: true,
          },
        ]
      },
      treeNodeRow: {},
      treeForm: {},
      treeOption: {
        addBtn: false,
        defaultExpandedKeys: ['root'],
        props: {
          label: 'name',
          value: 'id',
          children: 'childs'
        },
        formOption: {
          column: [
            {
              label: '分类名称',
              prop: 'name',
              rules: [
                {
                  required: true,
                  message: '请输入分类名称',
                  trigger: 'blur'
                }
              ]
            },
            {
              label: '分类序号',
              prop: 'serialno',
              rules: [
                {
                  required: true,
                  message: '请输入分类序号',
                  trigger: 'blur'
                }
              ]
            },
            {
              label: '创建者',
              prop: 'creator',
              readonly: true,
            },
            {
              label: '创建时间',
              prop: 'createTime',
              readonly: true,
            },
            {
              label: '父主类',
              prop: 'pidName',
              readonly: true,
            },
            {
              label: '备注',
              prop: 'description'
            },
          ],
        }
      },
      treeData: [],
    }
  },
  created() {
    this.getTreeList();
  },
  methods: {
    // å·¦ä¾§æ ‘请求
    getTreeList(status) {
      const params = {
        isExp: status ? true : false
      }
      getActionTree(params).then(res => {
        const data = res.data.obj;
        this.treeData = [data];
        const selectTreeData = this.option.column.find(item => item.prop === 'plActionCls'); // æ‰¾åˆ°action添加分类树
        selectTreeData.dicData = [data];
      })
    },
    // å·¦ä¾§æ ‘行点击
    nodeClick(row) {
      this.treeNodeRow = row;
      this.getRightTableList(row);
      this.bottomData = [];
    },
    // å¤´éƒ¨åˆ·æ–°æŒ‰é’®
    handleRefresh() {
      if (func.isEmptyObject(this.treeNodeRow)) {
        return;
      }
      this.getRightTableList(this.treeNodeRow);
    },
    // å³ä¾§è¡¨æ ¼ä¿¡æ¯
    getRightTableList(row) {
      this.tableLoading = true;
      const params = {
        plactioncls: row.id
      }
      getActionTableData(params).then(res => {
        const data = res.data.data;
        this.data = data;
        this.tableLoading = false;
      })
    },
    // è¡¨æ ¼å¤šé€‰
    selectChangeHandler(row) {
      this.selectList = row;
    },
    // è¡Œç‚¹å‡»
    rowClickHandler(row) {
      this.currenRow = row;
      func.rowClickHandler(
        row,
        this.$refs.crud,
        this.lastIndex,
        (newIndex) => {
          this.lastIndex = newIndex;
        },
        () => {
          this.selectList = [];
        }
      );
    },
    // æœç´¢
    handleSearch(params, done) {
      if (func.isEmptyObject(this.treeNodeRow)) {
        this.$message.error('请先在左侧选择节点后操作');
        return done();
      }
      this.tableLoading = true;
      const apiParams = {
        plactioncls: this.treeNodeRow.id === 'root' ? '' : this.treeNodeRow.id,
        ...params
      }
      getActionTableData(apiParams).then(res => {
        const data = res.data.data;
        this.data = data;
        this.tableLoading = false;
      })
      done();
    },
    // é‡ç½®æœç´¢æ¡ä»¶
    handleReset() {
      if (func.isEmptyObject(this.treeNodeRow)) {
        this.$message.error('请先在左侧选择节点后操作');
        return;
      }
      this.getRightTableList(this.treeNodeRow);
    },
    // ä¿å­˜action
    actionSaveHandler() {
      if (this.selectList.length != 1) {
        this.$message.error('只能选择一条数据');
        return;
      }
      this.$emit('updataAction', this.selectList[0]);
      this.dialogClose();
    },
    dialogClose(){
      this.btnActionVisible = false;
      this.data = [];
      this.$refs.tree.setCurrentKey(null);
    }
  }
}
</script>
<style lang="scss" scoped>
::v-deep {
  .el-scrollbar__wrap {
    overflow: auto !important;
  }
  .headerCon {
    .el-button {
      width: 82px;
    }
  }
}
.headerCon {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 5px;
  .el-button + .el-button {
    margin-left: 5px;
  }
  .el-button {
    margin-top: 5px;
  }
}
.headerCon > .el-button:nth-child(4) {
  margin-left: 0;
}
.headerCon > .el-button:nth-child(7) {
  margin-left: 0;
}
.smallBtn {
  width: 82px;
  text-align: center;
  padding-left: 4.5px;
}
</style>