<template>
  <el-container class="fullheight" style="border: 1px solid #eee">
    <ht-aside-tree
      cat-id="9"
      @node-click="handleNodeClick"
      @check="checkNode"
    />
    <el-main>
      <ht-table
        @load="loadTableData"
        :data="tableData"
        :pageResult="pageResult"
        :selection="true"
        quick-search-props="alias,description"
        :default-sorter="[{direction: 'DESC', property: 'createTime'}]"
        ref="htTable"
        @select-all="tableSelect"
        @select="tableSelect"
        @selection-change="handleSelectionChange"
        @row-click="rowClick"
        :show-export="false"
        :show-custom-column="false"
        :header-cell-class-name="headerCellClassName"
      >
        <!-- class="dddd" -->
        <template v-slot:toolbar>
          <el-button
            icon="el-icon-plus"
            size="small"
            @click="openBusinessObjDialog()"
            type="primary"
            >添加</el-button
          >
          <el-button
            @click="showDialog('entsType')"
            :disabled="isDisabled"
            icon="icon-shezhifenlei"
            >设置分类</el-button
          >
          <el-button
            @click="handleDeleteForm"
            icon="icon-application-delete"
            :disabled="isDisabled"
            >删除</el-button
          >
          <ht-delete-button
            v-show="false"
            class="del_btn"
            style="margin: 0px"
            :url="formDeleteUrl"
            :htTable="$refs.htTable"
            :disabled="isDisabled"
            >删除</ht-delete-button
          >
        </template>
        <template>
          <ht-table-column
            type="index"
            width="50"
            align="center"
            label="序号"
          />
          <ht-table-column
            label="描述"
            :sortable="true"
            prop="description"
            :show-overflow-tooltip="true"
          >
            <template v-slot="scope">
              <el-link
                type="primary"
                v-if="$checkRight(scope.row,'3')"
                @click="openBusinessObjDialog('edit', scope.row.id)"
                >{{ scope.row.description }}
              </el-link>
              <template v-else>{{ scope.row.description }}</template>
            </template>
          </ht-table-column>
          <ht-table-column width="150" prop="categoryName" label="所属分类" />
          <ht-table-column prop="alias" label="别名" />
          <ht-table-column
            prop="status"
            width="100"
            label="状态"
            :render-header="renderHeaderMethod"
            :filters="[
              {text: '禁用', value: 'forbidden'},
              {text: '启用', value: 'normal'}
            ]"
          >
            <template slot-scope="scope">
              <el-switch
                :width="38"
                v-model="scope.row.status"
                active-value="normal"
                inactive-value="forbidden"
                v-if="$checkRight(scope.row,'3')"
                @change="status => handleSwitch(scope.row, status)"
              >
              </el-switch>
              <span
                class="status_text"
                :class="{primary: scope.row.status == 'normal'}"
                >{{ scope.row.status == 'normal' ? '启用' : '禁用' }}
              </span>
            </template>
          </ht-table-column>
          <ht-table-column
            prop="deployed"
            width="130"
            label="是否已发布"
            :render-header="renderHeaderMethod"
            :filters="[
              {text: '未发布', value: 0},
              {text: '已发布', value: 1}
            ]"
          >
            <template v-slot="{row}">
              <span :class="{'green-color': row.deployed}">{{
                row.deployed ? '已发布' : '未发布'
              }}</span>
            </template>
          </ht-table-column>
          <ht-table-column width="240" label="操作" align="left">
            <template v-slot="{row}">
              <el-button
                type="text"
                @click="showFormDialog({row: row, command: 'bind'})"
                >绑定关系</el-button
              >
              <el-button
                type="text"
                v-if="$checkRight(row, '4')"
                @click="showFormDialog({row: row, command: 'delete'})"
                >删除</el-button
              >
              <!-- <el-button
                type="text"
                class="copy-btn"
                v-if="row.deployed == 0"
                @click="showFormDialog({row: row, command: 'deployed'})"
                >发布</el-button
              > -->
              <el-dropdown
                size="mini"
                class="more-operate-btn__dropdown"
                @command="showFormDialog"
              >
                <span class="more-operate-btn"
                  >更多操作<i class="el-icon-caret-bottom"></i>
                </span>

                <el-dropdown-menu
                  slot="dropdown"
                  class="operate-dropdown__button"
                >
                  <el-dropdown-item
                    v-if="row.deployed == 0"
                    :command="{row: row, command: 'deployed'}"
                    size="mini"
                    >发布</el-dropdown-item
                  >
                  <el-dropdown-item
                    :command="{row: row, command: 'copy'}"
                    >复制
                  </el-dropdown-item>
                  <el-dropdown-item
                    :command="{row: row, command: 'formation'}"
                    size="mini"
                    >数据结构</el-dropdown-item
                  >
                  <el-dropdown-item
                    :command="{row: row, command: 'tableDetail'}"
                    size="mini"
                    >物理表</el-dropdown-item
                  >
                  <el-dropdown-item
                    :command="{row: row, command: 'fetchApi'}"
                    size="mini"
                    >获取接口</el-dropdown-item
                  >
                  <!-- <el-dropdown-item
                    :command="{row: row, command: 'delete'}"
                    size="mini"
                    >删除</el-dropdown-item
                  > -->
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </ht-table-column>
        </template>
      </ht-table>
    </el-main>
    <!--数据结构-->
    <ht-sidebar-dialog
      width="20%"
      title="数据结构"
      :visible.sync="dialogVisible"
      :before-close="handleClose"
    >
      <pre
        style="border: 1px solid #ccc;background-color: #f5f5f5; border-radius: 4px"
        >{{ this.dataformation }}</pre
      >
    </ht-sidebar-dialog>
    <!-- 获取接口 -->
    <el-dialog
      title="获取接口"
      :visible.sync="apiDialogVisible"
      append-to-body
      :close-on-click-modal="false"
      class="urgent-text"
    >
      <el-form v-form class="copy-form">
        <ht-form-item label="更新" label-width="80px">
          <el-input v-model="updateApi" :disabled="true" />
          <el-tooltip
            class="item"
            effect="light"
            placement="bottom-end"
            popper-class="testtooltip"
          >
            <div slot="content" class="tooltip">
              <p>提示信息</p>
              <p>
                接口类型为POST类型，接口参数示例为:{{
                  apiDataformation
                }}{主键值不能为空}
              </p>
            </div>
            <el-button
              class="copy-btn"
              type="text"
              v-clipboard:copy="updateApi"
              v-clipboard:success="onCopy"
              v-clipboard:error="onError"
              >复制接口</el-button
            ></el-tooltip
          >
        </ht-form-item>
        <ht-form-item label="删除" label-width="80px">
          <el-input v-model="deleteApi" :disabled="true" />
          <el-tooltip
            class="item"
            effect="light"
            placement="bottom-end"
            popper-class="testtooltip"
          >
            <div slot="content" class="tooltip">
              <p>提示信息</p>
              <p>
                接口类型为POST类型，接口参数示例为:ids:XXXXXX,删除多条数据为ids的集合通过逗号“,”拼接
              </p>
            </div>
            <el-button
              class="copy-btn"
              type="text"
              v-clipboard:copy="deleteApi"
              v-clipboard:success="onCopy"
              v-clipboard:error="onError"
              >复制接口</el-button
            ></el-tooltip
          >
        </ht-form-item>
        <ht-form-item label="插入" label-width="80px">
          <el-input v-model="insertApi" :disabled="true" />
          <el-tooltip
            class="item"
            effect="light"
            placement="bottom-end"
            popper-class="testtooltip"
          >
            <div slot="content" class="tooltip">
              <p>提示信息</p>
              <p>接口类型为POST类型，接口参数示例为:{{ apiDataformation }}</p>
            </div>
            <el-button
              class="copy-btn"
              type="text"
              v-clipboard:copy="insertApi"
              v-clipboard:success="onCopy"
              v-clipboard:error="onError"
              >复制接口</el-button
            ></el-tooltip
          >
        </ht-form-item>
        <ht-form-item label="查询" label-width="80px">
          <el-input v-model="searchApi" :disabled="true" />
          <el-tooltip
            class="item"
            effect="light"
            placement="bottom-end"
            popper-class="testtooltip"
          >
            <div slot="content" class="tooltip">
              <p>提示信息</p>
              <p>
                接口类型为POST类型，接口参数示例为:queryFilter:{pageBean: {page:
                "1",pageSize: 30, showTotal: "true" },querys: [{property:
                "表名.字段名".,value:"参数内容",group: "main", operation:
                "LIKE", relation:"OR"}]},boEntName: "实体名称"
              </p>
            </div>
            <el-button
              class="copy-btn"
              type="text"
              v-clipboard:copy="searchApi"
              v-clipboard:success="onCopy"
              v-clipboard:error="onError"
              >复制接口</el-button
            ></el-tooltip
          >
        </ht-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="close()">关闭</el-button>
      </div>
    </el-dialog>
    <!--建模表单-->
    <business-obj-dialog
      @opretaId="opretaId"
      :clickTree="clickTree"
      :dataView="dataView"
      ref="objDialog"
      @loadTableData="handleNodeClick"
      :data="formData"
    ></business-obj-dialog>
    <business-table-detail ref="businessTableDetailDialog" />
    <ht-sidebar-dialog
      width="28%"
      title="绑定关系"
      :visible.sync="dialogVisible2"
      :before-close="handleClose"
    >
      <el-row>
        <el-col>
          实体对象：
          <span v-for="(item, index) in bindData.entData" :key="index">
            <el-tag
              style="margin-right: 5px;cursor: pointer;"
              @click="
                closeBindDialog
                openBusinessObjDialog('edit', item.defId, item.id_)
              "
              >{{ item.name_ }}</el-tag
            >
          </span>
        </el-col>
      </el-row>
      <br />
      <el-row>
        <el-col>
          PC表单：
          <span v-for="(item, index) in bindData.formData" :key="index">
            <el-tag
              style="margin-right: 5px;"
              v-if="item.form_type_ != 'mobile'"
            >
              <router-link
                replace
                :to="{
                  path: 'formManager',
                  query: {formId: item.id_, defId: item.def_id_}
                }"
              >
                {{ item.name_ }}</router-link
              >
            </el-tag>
          </span>
        </el-col>
      </el-row>
      <br />
      <el-row>
        <el-col>
          手机表单：
          <span v-for="(item, index) in bindData.formData" :key="index">
            <el-tag style="margin-right: 5px;" v-if="item.form_type_ != 'pc'">
              <router-link
                replace
                :to="{
                  path: 'mobileFormManager',
                  query: {formId: item.id_, defId: item.def_id_}
                }"
              >
                {{ item.name_ }}</router-link
              >
            </el-tag>
          </span>
        </el-col>
      </el-row>
      <br />
      <el-row>
        <el-col>
          流程定义：
          <template v-if="bindData && bindData.bpmData">
            <div
              v-for="(item, index) in bindData.bpmData"
              :key="index"
              style="margin: 10px"
            >
              <span>{{ item.flowName }}</span>
              <span v-for="ship in item.ships" :key="ship.flowId">
                <el-tag type="danger" v-if="ship.main" class="m-l-5">
                  <router-link
                    :to="{path: 'defManager', query: {bpmId: ship.flowId}}"
                    >版本:{{ ship.version }}(主版本)
                  </router-link>
                </el-tag>
                <el-tag v-else class="m-l-5">
                  <router-link
                    :to="{path: 'defManager', query: {bpmId: ship.flowId}}"
                    >版本:{{ ship.version }}
                  </router-link>
                </el-tag>
              </span>
            </div>
          </template>
          <span
            v-if="bindData && bindData.bpmData && bindData.bpmData.length == 0"
            >未绑定</span
          >
        </el-col>
      </el-row>
    </ht-sidebar-dialog>
    <eip-sys-type-dialog
      ref="entsType"
      name="entsType"
      :cat-id="'9'"
      @onConfirm="sysTypeDialogOnConfirm"
    >
    </eip-sys-type-dialog>
    <form-template-dialog
      @onConfirm="confirmTemplate"
      formType="pc"
      ref="formTemplateDialog"
    />
    <business-obj-copy-dialog
      ref="businessObjCopyDialog"
      @onConfirm="businessObjCopyDialogConfirm"
    />
  </el-container>
</template>

<script>
import form from '@/api/form.js'
import businessObjDialog from '@/views/form/BusinessObjDialog.vue'
const htAsideTree = () => import('@/components/common/HtAsideTree.vue')
import FormTemplateDialog from '@/components/dialog/FormTemplateDialog.vue'
import BusinessObjCopyDialog from '@/views/form/BusinessObjCopyDialog.vue'
import tableHeaderFilter from '@/mixins/tableHeaderFilter.js'
const eipSysTypeDialog = () =>
  import('@/components/dialog/EipSysTypeDialog.vue')
const BusinessTableDetail = () => import('@/views/form/BusinessTableDetail.vue')

export default {
  components: {
    businessObjDialog,
    htAsideTree,
    eipSysTypeDialog,
    FormTemplateDialog,
    BusinessObjCopyDialog,
    BusinessTableDetail
  },
  mixins: [tableHeaderFilter],
  data() {
    return {
      selectTypeIds: '',
      selectTypeName: '',
      selectTypeId: '',
      currentRow: null, // 当前选中的数据行
      dataView: {id: '', type: ''},
      dialogVisible: false,
      dialogVisible2: false,
      tableData: [], //表格
      updateTableData: [], //修改分类数据
      deployedId: '',
      dataformation: '', //数据视图

      pageResult: {
        page: 1,
        pageSize: 20,
        total: 0
      },
      bindData: '',
      clickTree: {id: '', name: ''},
      formData: {
        //表单
        alias: '',
        categoryId: '',
        categoryName: '',
        deployed: 0,
        description: '',
        dsName: '',
        isCreateTable: '',
        isExternal: '',
        status: 'normal',
        supportDb: true,
        verifyJson: null,
        ents: []
      },
      isDisabled: true,
      apiDialogVisible: false,
      updateApi: '',
      deleteApi: '',
      insertApi: '',
      searchApi: '',
      apiDataformation: '',
      selectedList: []
    }
  },
  computed: {
    formDeleteUrl: function() {
      return `${window.context.form}/bo/def/v1/removes`
    }
  },
  watch: {
    /*  updateTableData: {
      handler(val) {
        console.log(val)
        this.isDisabled = val.length < 1 ? true : false
      },
      deep: true
    }, */
    selectedList: {
      handler(val) {
        this.isDisabled = val.length < 1 ? true : false
      },
      deep: true
    }
  },
  methods: {
    // 删除表单
    handleDeleteForm() {
      const idsArr = []
      let notRightNames = []
      this.updateTableData.forEach(item => {
        if (this.$checkRight(item, '4')) {
          idsArr.push(item.id)
        } else {
          notRightNames.push(item.description)
        }
      })
      const ids = idsArr.join(',')
      this.$confirm('此操作会删除已生成物理表,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'error',
        dangerouslyUseHTMLString: true
      }).then(() => {
        if (notRightNames.length > 0) {
          this.$message.error(
            '以下数据无权限删除,已跳过：[' + notRightNames.join(',') + ']'
          )
          if (notRightNames.length == this.updateTableData.length) {
            return
          }
        }
        form.removeBusinessObj(ids).then(res => {
          if (res.data.state) {
            this.$message({message: res.data.message, type: 'success'})
            this.loadTableData()
          }
        })
      })
    },
    deleteData(param) {
      this.$confirm('此操作会删除已生成物理表,是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'error',
        dangerouslyUseHTMLString: true
      })
        .then(() => {
          form.removeBusinessObj([param.row.id]).then(() => {
            this.loadTableData()
          })
        })
        .catch(() => {})
    },
    //鼠标选中行改变复选框
    rowClick(row, column, event) {
      this.$refs.htTable.$refs.htTable.toggleRowSelection(row)
    },
    handleSelectionChange(selection) {
      this.selectedList = selection
    },
    //获取建模id
    opretaId(id) {
      this.openBusinessObjDialog('edit', id)
    },
    //关闭绑定关系
    closeBindDialog() {
      this.dialogVisible2 = false
    },
    //表格选中数据
    tableSelect(selection) {
      this.updateTableData = selection
    },
    //表格操作
    showFormDialog(param) {
      switch (param.command) {
        case 'edit':
          this.openBusinessObjDialog('edit', param.row.id)
          break
        case 'deployed':
          this.deployedId = param.row.id
          this.deploy(param.row)
          break
        case 'formation':
          this.getFormation(param)
          break
        case 'bind':
          this.openBind(param)
          break
        case 'tableDetail':
          this.openTableDetail(param)
          break
        case 'copy':
          this.openCopyDialog(param)
          break
        case 'fetchApi':
          this.getApi(param)
          break
        case 'delete':
          this.deleteData(param)
          break
      }
    },
    openBind(param) {
      this.dialogVisible2 = true
      this.getBingData(param)
    },
    openTableDetail(param) {
      this.getEntData(param.row.id).then(data => {
        this.$refs.businessTableDetailDialog.showDialog(data)
      })
    },
    openCopyDialog(param) {
      this.$refs.businessObjCopyDialog.showDialog(param.row.id)
    },
    businessObjCopyDialogConfirm() {
      this.loadTableData()
    },
    //获取绑定数据
    getBingData(param) {
      return form.getBindData(param.row.id, param.row.alias).then(resp => {
        this.bindData = resp.data
      })
    },
    //表单对话框
    openBusinessObjDialog(status, id, entId) {
      this.dataView.type = status
      this.dataView.id = id
      if (entId) {
        for (let i = 0; i < this.bindData.entData.length; i++) {
          if (entId == this.bindData.entData[i].id_) {
            this.dataView.entIndex = i
            this.dialogVisible2 = false
          }
        }
      }
      this.getFormData()
    },
    //数据视图对话框
    getFormation(param) {
      this.dialogVisible = true
      form.getDataformation(param.row.alias, data => {
        this.dataformation = data.data
      })
    },
    //关闭数据视图
    handleClose() {
      this.dialogVisible = false
      this.dialogVisible2 = false
      this.$refs.htTable.load()
      this.bindData = ''
    },
    handleSwitch(row, status) {
      this.updateStatus(row, status)
    },
    //设置状态
    updateStatus(row, status) {
      form.updateBusinessObjStatus(row.id, status).then(resp => {
        if (resp.data.state == true) {
          this.$message({message: resp.data.message, type: 'success'})
          this.loadTableData()
          return
        }
        this.$message(resp.message)
      })
    },
    //通过分类树筛选数据
    handleNodeClick: function(data) {
      if (data && data.id == '9') {
        this.selectTypeIds = null
      } else {
        if (data) {
          this.clickTree.id = data.id
          this.clickTree.name = data.name
          this.selectTypeName = data.name
          this.selectTypeId = data.id
          this.selectTypeIds = {
            property: 'categoryId',
            value: data.id,
            group: 'main',
            operation: 'IN',
            relation: 'AND'
          }
        }
      }
       this.$refs.htTable.load()
    },
    //加载列表
    loadTableData: function(param, cb) {
      let pageInfo = {
        pageBean: {
          page: 1,
          pageSize: 20,
          showTotal: true
        },
        sorter: [{direction: 'DESC', property: 'createTime'}]
      }
      if (this.selectTypeName && this.selectTypeName != '建模分类') {
        if (param && !param.querys) {
          param.querys = []
        }
        if (param && param.querys) {
          // 标记是否有选择分类
          let hasCategoryName = false
          let hasCategoryId = false
          if (this.selectTypeIds) {
            param.querys.push(this.selectTypeIds)
          }
          /*  param.querys.forEach(query => {
            if (query.property == 'categoryName') {
              hasCategoryName = true
              query.value = this.selectTypeName
            }
            if (query.property == 'categoryId') {
              hasCategoryId = true
              query.value = this.selectTypeId
            }
          }) */
          /* if (!hasCategoryName && !hasCategoryId) {
            param.querys.push({
              property: 'categoryId',
              value: this.selectTypeId,
              group: 'main',
              operation: 'EQUAL',
              relation: 'AND'
            })
          } */
        }
      } else if (param && param.querys) {
        param.querys = param.querys.filter(
          item => item.property !== 'categoryId'
        )
      }
      if (param == undefined) {
        this.$addRightMarkIntoFilter(pageInfo)
        form
          .getBusinessObjData(pageInfo)
          .then(resp => {
            this.tableData = resp.rows
            this.pageResult = {
              page: resp.page,
              pageSize: resp.pageSize,
              total: resp.total
            }
          })
          .finally(() => cb && cb())
      } else {
        param.pageBean = param.pageBean || this.pageResult
        this.$addRightMarkIntoFilter(param)
        form
          .getBusinessObjData(param)
          .then(resp => {
            this.tableData = resp.rows
            this.pageResult = {
              page: resp.page,
              pageSize: resp.pageSize,
              total: resp.total
            }
          })
          .finally(() => cb && cb())
      }
    },

    //表单对话框
    handleOpen() {
      this.$refs.objDialog.handleOpen()
    },
    //表单数据加载
    getFormData() {
      if (this.dataView.id) {
        this.getEntData(this.dataView.id).then(data => {
          this.formData = data
          this.handleOpen()
        })
      } else {
        this.handleOpen()
      }
    },
    // 通过表单ID获取实体信息
    getEntData(formId) {
      return new Promise(resolve => {
        form.getEntData(formId, resp => {
          resp.data.ents.forEach((entData, index) => {
            if (entData.isExternal == '1' && index == 0) {
              entData.show = '主实体-外'
            } else if (entData.isExternal == '1') {
              entData.show = '子实体-外'
            }
            if (index === 0) {
              entData.isCheck = true
            }
            if (entData.children) {
              entData.children.forEach(v => {
                if (v.isExternal == '1') {
                  v.show = '孙实体-外'
                }
              })
            }
            for (let q = 0; q < entData.attributeList.length; q++) {
              if (entData.attributeList[q]) {
                if (entData.attributeList[q].isRequired == 0) {
                  entData.attributeList[q].isRequired = '0'
                } else {
                  entData.attributeList[q].isRequired = '1'
                }
              }
              for (let i = 0; i < entData.attributeList.length - 1 - q; i++) {
                if (
                  entData.attributeList[i].index >
                  entData.attributeList[i + 1].index
                ) {
                  let temp = entData.attributeList[i]
                  entData.attributeList[i] = entData.attributeList[i + 1]
                  entData.attributeList[i + 1] = temp
                }
              }
            }
          })
          resolve(resp.data)
        })
      })
    },
    //发布
    deploy(row) {
      form.deploy(this.deployedId).then(resp => {
        this.$confirm(resp.data.message + '，是否创建表单？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.currentRow = row
            this.$refs.formTemplateDialog.showDialog(row.id)
            this.loadTableData()
          })
          .catch(() => {
            this.loadTableData()
          })
      })
    },
    checkNode(data, checkObj) {
      if (checkObj.checkedKeys.length == 0) {
        this.selectTypeIds = null
      } else {
        this.selectTypeIds = {
          property: 'categoryId',
          value: checkObj.checkedKeys.join(','),
          group: 'main',
          operation: 'IN',
          relation: 'AND'
        }
      }
      this.$refs.htTable.load()
    },
    sysTypeDialogOnConfirm(data) {
      var id = this.getHasRightIds()
      let this_ = this
      form.updateCategory(id, data.id, encodeURI(data.name)).then(resp => {
        if (resp.data.state) {
          this.$message({message: resp.data.message, type: 'success'})
          this.updateTableData = []
          this.$refs.htTable.selection = []
          setTimeout(function() {
            this_.dialogVisible = false
            this_.loadTableData({})
          }, 2000)
          return
        }
        this.$message.error(resp.data.message)
      })
    },
    getHasRightIds(alertMessage = true) {
      let selection = this.$refs.htTable.$refs.htTable.selection
      if (selection.length == 0) {
        this.$message.warning('请选择至少一项记录')
        return
      }
      let ids = []
      let notRightNames = []
      for (let item of selection) {
        if (this.$checkRight(item, '3')) {
          ids.push(item['id'])
        } else {
          notRightNames.push(item.description)
        }
      }
      if (notRightNames.length > 0) {
        if (alertMessage || notRightNames.length == selection.length) {
          this.$message.error(
            '以下数据无权限更新,已跳过：[' + notRightNames.join(',') + ']'
          )
        }

        if (notRightNames.length == selection.length) {
          return null
        }
      }
      return ids
    },
    showDialog(ref) {
      if (this.$refs.htTable.selection.length == 0) {
        this.$message({
          message: '请先选择需要设置分类的数据',
          type: 'warning'
        })
        return
      }
      if (ref == 'entsType') {
        var ids = this.getHasRightIds(false)
        if (!ids || ids.length == 0) {
          return
        }
      }
      this.updateTableData = [...this.$refs.htTable.selection]
      this.$refs[ref].showDialog({})
    },
    // 选择生成表单的模板
    confirmTemplate(templateModel) {
      const row = {...this.currentRow}
      this.currentRow = null
      let query = {bos: [row]}

      if (templateModel) {
        query.templateConf = templateModel
      }

      this.$router.push({
        path: '/formManager',
        query: query
      })
    },
    //获取接口对话框
    getApi(param) {
      this.apiDialogVisible = true
      this.updateApi = `/bo/def/v1/editBo/${param.row.alias}`
      this.deleteApi = `/bo/def/v1/deleteBo/${param.row.alias}`
      this.insertApi = `/bo/def/v1/saveBo/${param.row.alias}`
      this.searchApi = `/bo/def/v1/list/${param.row.alias}`
      form.getDataformation(param.row.alias, data => {
        this.apiDataformation = data.data
      })
    },
    close() {
      this.apiDialogVisible = false
    },
    // 复制成功时的回调函数
    onCopy(e) {
      this.$message.success('内容已复制到剪切板！')
    },
    // 复制失败时的回调函数
    onError(e) {
      this.$message.error('抱歉，复制失败！')
    }
  },

  mounted() {
    //业务表单-》查看绑定关系
    if (this.$route.query.id) {
      this.openBusinessObjDialog('edit', this.$route.query.id)
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/.el-dropdown-menu__item {
  text-align: left;
  width: 100px;
}

.m-l-5 {
  margin-left: 5px;
}

@media (max-width: 1152px) {
  /deep/ .search-container__col {
    flex-wrap: wrap;
    .el-button-group {
      margin-top: 10px;
    }
  }
}
::v-deep {
  .cell > .el-table__column-filter-trigger {
    display: none;
  }
}
.status_text {
  margin-left: 4px;
}
.primary {
  color: #409eff;
}
.del_btn {
  margin-left: 10px !important;
}
>>> .el-dialog {
  // width: 750px;
  // height: 400px;
}
>>> .el-dialog__body {
  padding: 32px 48px;
}
>>> .el-dialog__footer {
  // position: absolute;
  // text-align: center;
  // bottom: 0;
  // left: 0;
  // right: 0;
  // padding: 40px !important;
}
>>> .copy-form {
  margin: 8px 15px;
}
>>> .copy-btn {
  margin-left: 15px;
  padding: 3px 8px;
}

>>> .el-form-item__content > .el-input--small {
  width: 530px;
}
.operate-dropdown__button >>> .el-dropdown-menu__item {
  text-align: center;
}
.operate-dropdown__button >>> .el-dropdown-menu__item:nth-child(3) {
  color: #e55555;
}
.tooltip {
  min-height: 100px;
  max-height: 500px;
  overflow-y: auto;
  p:nth-child(1) {
    font-size: 12px;
    color: #333;
    font-weight: bold;
    margin-bottom: 8px;
  }
}
/* 设置滚动条的样式 */
::-webkit-scrollbar {
  width: 6px;
}
/* 滚动槽 */
::-webkit-scrollbar-track {
  -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.3);
  border-radius: 4px;
}
/* 滚动条滑块 */
::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.1);
  -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
  background: rgba(255, 0, 0, 0.4);
}
.el-tooltip__popper >>> .is-light {
  border: 0 !important;
  box-shadow: 0px 2px 8px 1px rgba(0, 0, 0, 0.15);
  border-radius: 4px 4px 4px 4px;
}
</style>
<style lang="scss">
.el-tooltip__popper[x-placement^='bottom'].testtooltip .popper__arrow {
  border-bottom-color: white !important;
}
.el-tooltip__popper[x-placement^='bottom'].testtooltip .popper__arrow:after {
  border-bottom-color: white !important;
}
.el-tooltip__popper[x-placement^='bottom'].is-light {
  border: 0;
}
.testtooltip {
  background: white !important;
  box-shadow: 1px 1px 10px 3px #d3d3d6;
}
</style>
