田源
2024-09-27 c07a9afa70e53ae54e3586d6cb982e215ad8cb29
Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/uiDefine/rightRegion/bottomTable/index.vue
@@ -1,5 +1,5 @@
<template>
  <basic-container>
  <div>
    <avue-crud
      ref="crud"
      v-model="form"
@@ -21,37 +21,24 @@
        </el-button>
      </template>
      <!-- eventKey操作按钮 -->
      <template slot="eventButtonForm" slot-scope="scope">
        <div style="width: 100%;display: flex;justify-content: center">
          <el-button plain size="mini" type="primary" @click="formDataAddClickHandler">创建</el-button>
          <el-button plain size="mini" type="danger" @click="formDataDelClickHandler">删除</el-button>
          <el-button plain size="mini" type="primary" @click="moveUp">上移</el-button>
          <el-button plain size="mini" type="primary" @click="moveDown">下移</el-button>
        </div>
      </template>
      <!-- eventKey以及eventValue显示区域 -->
      <template slot="bottomValueForm" slot-scope="scope">
        <div style="height: 200px; width: 95%; border: 1px solid #bdbbbb;overflow-y: auto">
          <!-- 内容 -->
          <el-table
            :data="FormData"
            :highlight-current-row="true"
            style="width: 100%"
            @row-click="formDataRowClick">
            <el-table-column
              align="center"
              label="EventKey"
              prop="eventKey">
            </el-table-column>
            <el-table-column
              align="center"
              label="EventValue"
              prop="eventValue">
            </el-table-column>
          </el-table>
        </div>
        <avue-crud
          :data="eventData"
          :option="eventOption"
          @row-click="formDataRowClick">
          <template slot="menuLeft" slot-scope="scope">
            <el-button plain size="mini" type="primary" @click="formDataAddClickHandler">创建</el-button>
          </template>
          <template slot="menu" slot-scope="scope">
            <el-button plain size="mini" type="danger" @click="formDataDelClickHandler(scope.row)">删除</el-button>
            <el-button plain size="mini" type="primary" @click="moveUp(scope.row)">上移</el-button>
            <el-button plain size="mini" type="primary" @click="moveDown(scope.row)">下移</el-button>
          </template>
        </avue-crud>
      </template>
      <!-- 切换搜索类型 源对象 目标对象显示label切换 -->
      <template slot="showTypeLabel" slot-scope="{}">
@@ -68,9 +55,9 @@
      append-to-body="true"
      class="avue-dialog"
      title="配置按钮"
      width="70%"
      width="75%"
      @close="dialogClose">
      <el-container>
      <el-container v-loading="dialogLoading">
        <el-header style="height: 40px !important;">
          <div style="display: flex">
            <el-button :disabled="!disabledBtn" plain size="mini" type="primary" @click="addClickBtnHandler">添加
@@ -129,7 +116,12 @@
                  <el-form-item label="Action:" prop="Action">
                    <el-col :span="14">
                      <el-input v-model="basicForm.actionOId" :readonly="disabledBtn"></el-input>
                      <div style="display: flex">
                        <el-input v-model="basicForm.actionName" :readonly="disabledBtn"></el-input>
                        <el-button :disabled="disabledBtn" size="mini" style="margin-left: 10px" type="success"
                                   @click="actionFoucus">选择
                        </el-button>
                      </div>
                    </el-col>
                  </el-form-item>
@@ -168,10 +160,12 @@
              <el-divider content-position="left">参数信息</el-divider>
              <avue-crud
                ref="paramsCrud"
                v-model="paramsForm"
                :data="paramsData"
                :option="paramsOption"
                style="margin-top: 20px"
                @row-save="paramsRowSave">
                @row-save="paramsRowSave"
                @row-update="paramsRowUpdate">
                <template slot="menuLeft" slot-scope="scope">
                  <el-button :disabled="disabledBtn" icon="el-icon-plus" plain size="small" type="primary"
                             @click="paramsRowAddClickHandler">创建
@@ -179,6 +173,9 @@
                </template>
                <template slot="menu" slot-scope="scope">
                  <el-button :disabled="disabledBtn" icon="el-icon-edit" size="small" type="text"
                             @click="paramsRowEditHandler(scope.row)">修改
                  </el-button>
                  <el-button :disabled="disabledBtn" icon="el-icon-delete" size="small" type="text"
                             @click="paramsRowDeleteHandler(scope.row)">删除
                  </el-button>
@@ -190,80 +187,90 @@
        </el-container>
      </el-container>
    </el-dialog>
  </basic-container>
    <action-dialog ref="actionDialog" @updataAction="actionSaveHandler"></action-dialog>
  </div>
</template>
<script>
import basicOption from "@/util/basic-option";
import func from "@/util/func";
import {
  getPLPageDefinations,
  getBtmDatasByPage,
  getPortalVIDatasByPage,
  getQTInfoDatasByPage,
  getTabButtons,
  addTapButton,
  updateTapButton
  updateTapButton, getTabByContextIdAndType
} from "@/api/UI/uiDefine";
import actionDialog from '@/views/modelingMenu/ui/uiDefine/rightRegion/bottomTable/components/action';
export default {
  props: {
    sourceData: {
      type: Array,
      default: () => [
        {
          "controlPath": "",
          "description": "",
          "eventKey": "",
          "eventMap": null,
          "eventValue": "",
          "expandCols": "",
          "expandMode": "",
          "extAttr": "",
          "id": "ABAE25CE-867E-9C73-AC1A-B316FD91C65B",
          "isShowImage": "",
          "linkType": "parttodocument",
          "name": "技术文件",
          "navigatorType": "",
          "orderField": "",
          "orderMode": "",
          "orientation": "",
          "qryType": null,
          "queryTemplateName": "QueryPartEngineeringTechnology",
          "refTreeSet": "",
          "returnRows": "",
          "rootContent": "",
          "searchTarger": "2",
          "separator": "",
          "seq": "1",
          "showAbs": "",
          "showContent": "",
          "showContentRelation": "",
          "showContentTable": "",
          "showContentType": "",
          "showExpression": "",
          "showExpressionRoot": "",
          "showLinkAbs": "",
          "showType": "document",
          "subUILayout": "",
          "subUIObjType": "",
          "tabPageOId": "98F9082F-BAF4-FB81-3230-32590B34A329",
          "templateId": "PartEngineeringTechnology_list",
          "templateType": "1",
          "type": 3,
          "uiLayout": null,
          "uiParser": "",
          "validity": ""
        }
      ]
      type: Object,
      default: () => {
      }
    },
    height: {
      type: String,
      default: () => "auto"
    }
  },
  components: {
    actionDialog
  },
  name: "index",
  data() {
    return {
      paramsForm:{},
      eventOption: {
        ...basicOption,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        refreshBtn: false,
        highlightCurrentRow: true,
        height: 200,
        column: [
          {
            label: 'EventKey',
            prop: 'eventKey',
            type: 'select',
            value: 'SelectionEvent',
            dicData: [
              {
                label: 'SelectionEvent',
                value: 'SelectionEvent'
              },
              {
                label: 'DBClickEvent',
                value: 'DBClickEvent'
              },
              {
                label: 'ClickEvent',
                value: 'ClickEvent'
              }
            ],
            cell: true
          },
          {
            label: 'EventValue',
            prop: 'eventValue',
            cell: true,
            rules: [
              {
                required: true,
                message: '请输入eventValue',
                trigger: 'blur'
              }
            ]
          }
        ]
      },
      eventData: [],
      btnActionVisible: false,
      dialogLoading: false,
      saveType: '',
      disabledBtn: true,
      paramsData: [],
@@ -279,11 +286,27 @@
        column: [
          {
            label: '名称',
            prop: 'name'
            prop: 'name',
            span: 24,
            rules: [
              {
                required: true,
                message: '请输入名称',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '值',
            prop: 'value'
            prop: 'value',
            span: 24,
            rules: [
              {
                required: true,
                message: '请输入值',
                trigger: 'blur'
              }
            ]
          }
        ]
      },
@@ -299,13 +322,7 @@
      basicForm: {
        seq: 1
      },
      treeData: [
        {
          label: this.sourceData[0].name,
          oId: 'parentNode',
          children: []
        }
      ],
      treeData: [],
      treeOption: {
        menu: false,
        addBtn: false,
@@ -320,7 +337,7 @@
      btnDesignVisible: false,
      FormData: [],
      form: {},
      data: this.sourceData,
      data: [],
      option: {
        ...basicOption,
        height: this.height,
@@ -473,7 +490,6 @@
        ],
        group: [
          {
            icon: 'el-icon-folder-opened',
            label: '',
            arrow: false,
            prop: 'group1',
@@ -766,45 +782,15 @@
            ]
          },
          {
            icon: 'el-icon-folder-opened',
            label: '',
            arrow: false,
            prop: 'group2',
            column: [
              {
                label: 'EventKey',
                prop: 'eventKey',
                type: 'select',
                value: 'SelectionEvent',
                dicData: [
                  {
                    label: 'SelectionEvent',
                    value: 'SelectionEvent'
                  },
                  {
                    label: 'DBClickEvent',
                    value: 'DBClickEvent'
                  },
                  {
                    label: 'ClickEvent',
                    value: 'ClickEvent'
                  }
                ],
              },
              {
                label: 'EventValue',
                prop: 'eventValue',
                labelWidth: 100
              },
              {
                label: '',
                prop: 'eventButton',
                span: 24
              },
              {
                label: '',
                prop: 'bottomValue',
                span: 24
                span: 24,
                labelWidth: 10
              },
            ]
          }
@@ -816,8 +802,33 @@
      formDataRow: {},
    }
  },
  watch: {
    sourceData: {
      handler(val) {
        if (val && val.plOId) {
          this.getTableList()
        } else {
          this.data = [];
        }
      },
      immediate: true,
      deep: true
    }
  },
  computed: {},
  methods: {
    //获取列表数据
    getTableList() {
      const params = {
        pageContextOId: this.sourceData.plOId
      }
      getPLPageDefinations(params).then(res => {
        this.data = res.data.data;
        this.selectList = [];
        this.$refs.crud.clearSelection();
        this.tableLoading = false;
      })
    },
    // 根据不同值区分类型
    templateTypeValueHandler(val) {
      const componentMap = {
@@ -854,6 +865,11 @@
    // 增加
    addClickHandler() {
      console.log(this.sourceData);
      if (!this.sourceData || !this.sourceData.plOId) {
        this.$message.error('请在上方选择一条数据后进行添加');
        return;
      }
      this.$refs.crud.rowAdd();
    },
@@ -864,41 +880,37 @@
    // 对话框表格添加
    formDataAddClickHandler() {
      if (!this.form.eventKey) {
        this.$message.error('请选择EventKey');
        return;
      }
      if (!this.form.eventValue) {
        this.$message.error('请输入EventValue');
        return;
      }
      if (this.FormData.length >= 1) {
        const eventValueStatus = this.FormData.some(item => item.eventValue === this.form.eventValue);
        if (eventValueStatus) {
          this.$message.error('已存在相同的 EventValue,不能重复添加');
          return;
        }
      }
      // if (!this.form.eventKey) {
      //   this.$message.error('请选择EventKey');
      //   return;
      // }
      //
      // if (!this.form.eventValue) {
      //   this.$message.error('请输入EventValue');
      //   return;
      // }
      //
      // if (this.eventData.length >= 1) {
      //   const eventValueStatus = this.eventData.some(item => item.eventValue === this.form.eventValue);
      //
      //   if (eventValueStatus) {
      //     this.$message.error('已存在相同的 EventValue,不能重复添加');
      //     return;
      //   }
      // }
      const obj = {
        index: this.FormData.length,
        eventKey: this.form.eventKey,
        eventValue: this.form.eventValue
        index: this.eventData.length,
        eventKey: this.form.eventKey || 'SelectionEvent',
        eventValue: this.form.eventValue,
        $cellEdit: true
      }
      this.FormData.push(obj);
      this.eventData.push(obj);
    },
    // 对话框表格删除
    formDataDelClickHandler() {
      if (func.isEmptyObject(this.formDataRow)) {
        this.$message.error('请选择一条数据');
        return;
      }
      this.FormData = this.FormData.filter(item => item.index !== this.formDataRow.index);
    formDataDelClickHandler(row) {
      this.eventData = this.eventData.filter(item => item.index !== row.index);
    },
    // 模板类型显示隐藏方法
@@ -957,22 +969,22 @@
    },
    // 上移
    moveUp() {
      const index = this.findIndexByEventValue(this.FormData, this.formDataRow.eventValue);
    moveUp(row) {
      const index = this.findIndexByEventValue(this.eventData, row.eventValue);
      if (index > 0) {
        // 使用 splice 方法来模拟交换
        const temp = this.FormData.splice(index - 1, 1, this.FormData[index])[0]; // 移除 index-1 的元素,并在相同位置插入 index 的元素,返回被移除的元素
        this.FormData.splice(index, 1, temp); // 在 index 位置插入之前被移除的元素
        // 使用 splice 来模拟交换
        const temp = this.eventData.splice(index - 1, 1, this.eventData[index])[0]; // 移除 index-1 的元素 并在相同位置插入 index 的元素 返回被移除的元素
        this.eventData.splice(index, 1, temp); // 在 index 位置插入之前被移除的元素
      }
    },
    // 下移
    moveDown() {
      const index = this.findIndexByEventValue(this.FormData, this.formDataRow.eventValue);
      const length = this.FormData.length;
    moveDown(row) {
      const index = this.findIndexByEventValue(this.eventData, row.eventValue);
      const length = this.eventData.length;
      if (index < length - 1) {
        const temp = this.FormData[index];
        this.FormData.splice(index, 1, this.FormData.splice(index + 1, 1, temp)[0]);
        const temp = this.eventData[index];
        this.eventData.splice(index, 1, this.eventData.splice(index + 1, 1, temp)[0]);
      }
    },
@@ -983,12 +995,8 @@
    // 按钮设计
    btnDesignClickHandler() {
      if (this.selectList.length <= 0) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      if (this.selectList.length > 1) {
        this.$message.error('最多选择一条数据');
      if (this.selectList.length != 1) {
        this.$message.error('请选择一条数据');
        return;
      }
      this.btnDesignVisible = true;
@@ -1004,7 +1012,11 @@
      getTabButtons(params).then(res => {
        if (res.data.code === 200) {
          const data = res.data.data;
          this.treeData[0].children = data;
          this.treeData = [{
            label: this.selectList[0].name,
            oId: 'parentNode',
            children: data
          }];
          this.treeLoading = false;
        } else {
          this.$message.error('请检查控制台错误');
@@ -1028,9 +1040,20 @@
      this.paramsData.splice(row.$index, 1)
    },
    // 按钮设计信息参数信息修改
    paramsRowEditHandler(row) {
      this.$refs.paramsCrud.rowEdit(row);
    },
    // 按钮设计参数信息添加按钮
    paramsRowAddClickHandler() {
      this.$refs.paramsCrud.rowAdd();
    },
    // 按钮设计参数信息修改保存
    paramsRowUpdate(row, index, done, loading) {
      this.paramsData.splice(index, 1, row);
      done();
    },
    // 按钮设计参数信息保存
@@ -1064,7 +1087,7 @@
    // 按钮设计修改
    editClickBtnHandler() {
      if (func.isEmptyObject(this.nodeTreeRow)) {
        this.$message.error('请选择节点进行添加');
        this.$message.error('请选择节点进行修改');
        return;
      }
@@ -1087,6 +1110,7 @@
    // 按钮设计保存
    saveClickBtnHandler() {
      this.dialogLoading = true;
      const saveFunction = this.saveType === 'add' ? addTapButton : updateTapButton;
      const bottomParams = {};
      if (this.paramsData.length > 0) {
@@ -1112,7 +1136,10 @@
          this.getTabBtnTree();
          this.basicForm = {};
          this.paramsData = [];
          this.dialogLoading = false;
        }
      }).catch(err => {
        this.dialogLoading = false;
      })
    },
@@ -1141,6 +1168,17 @@
        });
      });
    },
    // 选择action
    actionFoucus() {
      this.$refs.actionDialog.btnActionVisible = true;
    },
    // 保存action
    actionSaveHandler(val) {
      this.$set(this.basicForm, 'actionName', val.plName);
      this.$set(this.basicForm, 'actionOId', val.plOId);
    }
  }
}
</script>