Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/formDefine/components/formDialog.vue
@@ -30,12 +30,15 @@
              <div style="display: flex;justify-content: center">
                <span style="display: flex;align-items: center; margin-right: 5px;">
                 <p class="tableTopLabel">名称:</p>
                 <el-input v-model="topForm.viName" placeholder="请输入内容" size="mini"></el-input>
                 <el-input v-model="topForm.viName" placeholder="请输入名称" size="mini"></el-input>
                </span>
                <span style="display: flex;align-items: center; margin-right: 5px;">
                 <p class="tableTopLabel">查询模板名称:</p>
                 <el-input v-model="form.itemQtName" placeholder="请输入查询模板名称" size="mini"></el-input>
                  <el-select v-model="form.itemQtName" placeholder="请选择查询模板" size="mini">
                    <el-option v-for="(item,index) in searchQtNameList" :key="index" :label="item.qtName"
                               :value="item.qtName"></el-option>
                  </el-select>
                </span>
                <span style="display: flex;align-items: center; margin-right: 5px;">
@@ -129,7 +132,8 @@
              </el-button>
              <el-button icon="el-icon-plus" plain size="small" type="primary" @click="addCustomClickHandler">添加自定义组件
              </el-button>
              <el-button icon="el-icon-zoom-in" plain size="small" type="primary" @click="checkViewHandler" >预览</el-button>
              <el-button icon="el-icon-zoom-in" plain size="small" type="primary" @click="checkViewHandler">预览
              </el-button>
            </div>
          </basic-container>
        </el-main>
@@ -240,7 +244,9 @@
                    <el-form-item label="权限控制">
                      <div style="display: flex;align-items: center">
                        <el-input v-model="form.itemRight" placeholder="请输入内容" size="mini"></el-input>
                        <el-button plain size="mini" style="margin-left: 3px" type="success">选择</el-button>
                        <el-button plain size="mini" style="margin-left: 3px" type="success" @click="authClickHandler">
                          选择
                        </el-button>
                      </div>
                    </el-form-item>
                  </el-col>
@@ -513,10 +519,12 @@
          </el-col>
          <el-col :span="24">
            <el-form-item label="权限控制">
            <el-form-item label="属性权限">
              <div style="display: flex;align-items: center">
                <el-input v-model="customForm.itemRight" placeholder="请输入内容" size="mini"></el-input>
                <el-button plain size="mini" style="margin-left: 3px" type="success">选择</el-button>
                <el-button plain size="mini" style="margin-left: 3px" type="success" @click="customAuthClickHandler">
                  选择
                </el-button>
              </div>
            </el-form-item>
          </el-col>
@@ -668,6 +676,29 @@
         <el-button type="primary" @click="customSaveHandler">确 定</el-button>
    </span>
    </el-dialog>
    <!-- 添加自定义组件选择属性池属性对话框  -->
    <el-dialog
      v-dialogDrag
      :visible.sync="customAttrVisible"
      append-to-body="true"
      class="avue-dialog"
      title="选择属性"
      width="50%">
      <avue-crud
        ref="userCrud"
        :data="customAttrData"
        :option="customAttrOption"
        :page.sync="page"
        :table-loading="customAttrLoading"
        @row-click="customAttrRowClickHandler"
      >
      </avue-crud>
      <span slot="footer" class="dialog-footer">
         <el-button @click="customAttrVisible = false">取 消</el-button>
         <el-button type="primary" @click="customAttrSaveHandler">确 定</el-button>
    </span>
    </el-dialog>
    <!-- 预览  -->
    <el-dialog
      v-dialogDrag
      :visible.sync="checkViewVisible"
@@ -744,12 +775,42 @@
        </el-row>
      </el-form>
    </el-dialog>
    <el-dialog
      v-dialogDrag
      :visible.sync="authVisible"
      append-to-body="true"
      class="avue-dialog"
      title="权限控制-人员列表"
      width="60%"
      @close="authDialogClose">
      <div style="height: 650px">
        <div style="height: 600px;">
          <avue-tree :key="refresh" ref="authTree" v-model="treeAuthForm" :data="treeAuthData" :option="treeAuthOption"
                     @check-change="treeAuthCheckChange">
              <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>
      </div>
      <span slot="footer" class="dialog-footer">
         <el-button @click="authDialogClose">取 消</el-button>
         <el-button type="primary" @click="authDialogSaveHandler">确 定</el-button>
    </span>
    </el-dialog>
  </el-dialog>
</template>
<script>
import {getTreeAttributes, savePortalVI} from "@/api/UI/formDefine/api";
import {getObjTypeQTs, getTreeAttributes, savePortalVI, refPersonOrgTree} from "@/api/UI/formDefine/api";
import func from "@/util/func";
import basicOption from "@/util/basic-option";
import {gridAttribute} from "@/api/modeling/attributePool/api";
import {getSysModelTreeMenuByPID} from "@/api/systemModel/mangeModel/api";
export default {
  name: "formDialog",
@@ -771,6 +832,87 @@
  },
  data() {
    return {
      authType: 'default',
      refresh: Math.random(),
      treeAuthOption: {
        multiple: true,
        height: 'auto',
        menu: false,
        addBtn: false,
        defaultExpandAll: true,
        lazy: true,
        props: {
          label: 'text',
          value: 'oid',
          children: 'childNodes',
        },
        treeLoad: (node, resolve) => {
          // console.log(node);
          const params = {
            'conditionMap[dataType]': node.data.data,
            'conditionMap[parentId]': node.data.data,
            'conditionMap[orgType]': 'all'
          }
          refPersonOrgTree(node.level === 0 ? {} : params).then(res => {
            resolve(res.data.treeData.map(item => {
              return {
                ...item,
                id: item.id,
                name: item.name,
                leaf: item.leaf
              }
            }))
          })
        }
      },
      treeAuthData: [],
      treeAuthForm: {},
      authVisible: false,
      searchQtNameList: [],
      customAttrRow: {},
      customAttrOption: {
        ...basicOption,
        calcHeight: -60,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        menu: false,
        refreshBtn: false,
        highlightCurrentRow: true,
        selection: false,
        column: [
          {
            label: '属性名',
            prop: 'id',
            sortable: true,
          },
          {
            label: '标签',
            prop: 'name',
            sortable: true,
          },
          {
            label: '类型',
            prop: 'attributeDataTypeText',
            sortable: true,
            width: 100
          },
          {
            label: '默认值',
            prop: 'defaultValue',
            sortable: true,
            width: 120
          },
          {
            label: '描述',
            prop: 'description',
            overHidden: true,
          },
        ]
      },
      customAttrData: [],
      customAttrLoading: false,
      customAttrVisible: false,
      checkViewVisible: false,
      optionObj: {
        optionName: '',
@@ -954,6 +1096,7 @@
          this.treeLoading = false;
        }
      })
      this.getSearchSelectList();
    },
    // 开始拖拽树节点事件
@@ -969,8 +1112,10 @@
      const params = {
        text: data.text,
        oid: data.oid,
        itemType: 'text'
        itemType: 'text',
        itemName: data.data.name
      }
      console.log(data);
      const isDuplicate = this.formList.some(item => item.text === data.text);
      if (isDuplicate) {
@@ -985,6 +1130,7 @@
      this.activeItem = item;
      this.activeItemIndex = index;
      this.form = {...item};
      console.log(item);
      // console.log(item,index);
      this.topForm.position = index += 1;
@@ -1139,11 +1285,11 @@
    // 保存按钮
    saveClickHandler() {
      if (!this.topForm.viName) {
        this.$message.error('名称不能为空');
        this.$message.error('表单名称不能为空');
        return;
      }
      if (this.formList.length <= 0) {
        this.$message.error('页面不能为空');
        this.$message.error('页面定义不能为空');
        return;
      }
      this.formList = this.formList.map(item => {
@@ -1207,7 +1353,7 @@
        return;
      }
      const status = this.formList.some(item => item.text === this.customForm.text);
      if(status){
      if (status) {
        this.$message.error('请检查是否添加相同项');
        return;
      }
@@ -1238,14 +1384,38 @@
      this.customForm.itemListTable = this.customForm.itemListTxt = this.customForm.itemListVal = this.customForm.itemStyle = "";
    },
    // 自定义表单使用字段表格行点击
    customAttrRowClickHandler(row) {
      this.customAttrRow = row;
    },
    // 自定义表单使用字段选择
    customTextHandler() {
      this.customAttrVisible = true;
      this.customAttrLoading = true
      gridAttribute().then(res => {
        const data = res.data.data;
        this.customAttrData = data;
        this.customAttrLoading = false;
      }).catch(err => {
        this.$message.error(err)
      });
    },
    // 自定义表单使用字段保存
    customAttrSaveHandler() {
      if (func.isEmptyObject(this.customAttrRow)) {
        this.$message.error('请选择一条数据进行保存');
        return;
      }
      // console.log(this.customAttrRow)
      this.customForm.text = this.customAttrRow.id;
      this.customAttrVisible = false;
    },
    // 右侧表单应用按钮
    asideFormHandler() {
      if(!this.form.text){
      if (!this.form.text) {
        this.$message.error('请添加一条数据进行保存!');
        return;
      }
@@ -1257,8 +1427,66 @@
    },
    // 预览按钮
    checkViewHandler(){
    checkViewHandler() {
      this.checkViewVisible = true;
    },
    // 查询模板下拉接口查询
    getSearchSelectList() {
      getObjTypeQTs({btName: this.treeRadio === '0' ? this.TreeNodeRow.id : this.TreeNodeRow.name}).then(res => {
        this.searchQtNameList = res.data.data;
      })
    },
    // 权限选择按钮
    authClickHandler() {
      this.authVisible = true;
    },
    // 自定义表单选择权限
    customAuthClickHandler() {
      this.authVisible = true;
      this.authType = 'attr';
    },
    // 权限树对话框关闭
    authDialogClose() {
      this.authVisible = false;
      this.refresh = Math.random(); // 刷新左侧树
    },
    // 权限控制保存
    authDialogSaveHandler() {
      const filterList = ['root', 'user', 'role', 'department']
      const data = this.$refs.authTree.getCheckedNodes().filter(item => !filterList.includes(item.oid));
      if (!data || data.length <= 0) {
        this.$message.error('请检查是否勾选子节点');
        return;
      }
      const resultMap = {};
      data.forEach(item => {
        const key = item.parentBtmName;
        if (!resultMap[key]) {
          resultMap[key] = []; // 初始化数组
        }
        resultMap[key].push(item.parentBtmName === 'user' ? item.data.userName : item.data.name);
      });
      // 组装字符串
      const resultString = Object.entries(resultMap).map(([key, oids]) => {
        return `${key}=${oids.join(',')}`; // 用 , 连接同一类型的 oid
      }).join('&&'); // 最后用 && 连接不同类型
      // console.log(resultString);
      if (this.authType === 'attr') {
        this.customForm.itemRight = resultString;
      } else {
        this.form.itemRight = resultString;
      }
      // this.form.itemRight = resultString;
      this.authDialogClose();
    }
  }