<!-- 
    TODO 数据权限设置
 -->
<template>
  <SysDialog
    class="data-permissionset"
    :visible="dialog.visible"
    v-bind="getBindValue"
    :title="dialog.title"
    @onClose="onclose"
  >
    <template #content>
      <el-form
        ref="dataPermissionsetSetFormRef"
        :model="dataPermissionsetSetForm"
        :rules="dataPermissionSetState.rulesSet"
        label-width="90px"
        inline
      >
        <el-row>
          <el-col :span="12">
            <el-form-item
              prop="permissionName"
              label="权限名称:"
              :style="setFormItemWidth"
            >
              <el-input
                v-model="dataPermissionsetSetForm.permissionName"
                clearable
                placeholder="权限名称"
              />
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item
              prop="menuId"
              label="菜单名称:"
              :style="setFormItemWidth"
            >
              <el-input
                type="hidden"
                v-model="dataPermissionsetSetForm.menuId"
              ></el-input>
              <el-input
                @click="selectParent"
                readonly
                placeholder="菜单名称"
                v-model="dataPermissionSetState.parentName"
              ></el-input>
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item
              prop="entityName"
              label="实体名称:"
              :style="setFormItemWidth"
            >
              <el-input
                v-model="dataPermissionsetSetForm.entityName"
                clearable
                placeholder="实体名称"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              prop="dataBaseType"
              label="库类型:"
              :style="setFormItemWidth"
            >
              <BaseSelect
                v-model:modelValue="dataPermissionsetSetForm.dataBaseType"
                :filterable="false"
                clearable
                class="w-100"
                :options="storeSystemType.getDataBaseTypeList"
                placeholder="库类型"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              prop="tableName"
              label="表名:"
              :style="setFormItemWidth"
            >
              <el-input
                v-model="dataPermissionsetSetForm.tableName"
                clearable
                placeholder="表名"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </template>
    <template #defineFooter>
      <span class="dialog-footer">
        <el-button
          type="success"
          :loading="dialog.confirmLoading"
          @click="confirm"
          >保存</el-button
        >
        <el-button type="danger" @click="onclose">取消</el-button>
      </span>
    </template>
  </SysDialog>
  <!-- 上级菜单弹框 -->
  <!-- <MenuParent ref="parentRef" @select="select"></MenuParent> -->
</template>
<script lang="ts" setup>
import SysDialog from "@/components/SysDialog.vue";
import useDialog from "@/hooks/useDialog";
import BaseSelect from "@/components/QuerySelect/BaseSelect.vue";
import { reactive } from "vue";
import { useDataPermissionAdd } from "@/composables/dataPermission/usedataPermissionSet";
import { DataPermissionDto } from "@/api/dataPermission/dataPermissionModel";
import MenuParent from "@/views/system/Menu/MenuParent.vue";
// import useSelectParent from "@/composables/department/useSelectParent";
import { ListIitem } from "@/api/base/BaseDataModel";

const props = defineProps<{
  menuList: ListIitem[]
}>()
const emit = defineEmits<{
  (e: "saveConfirm", params: DataPermissionDto, onclose: Fn, setLoading: Fn): void;
}>();
// 弹框一些配置
const getBindValue = reactive({
  title: "新增数据权限",
  width: 660,
  height: 0,
  isFooter: true,
  closeOnClickModal: false,
});
const { dialog, onClose, onShow, setLoading } = useDialog();

const {
  dataPermissionSetState,
  dataPermissionsetSetForm,
  dataPermissionsetSetFormRef,
  setFormItemWidth,
  select,
  show,
  onclose,
  confirm,
  storeSystemType
} = useDataPermissionAdd(dialog, onClose, onShow, setLoading, emit, props);

//上级菜单
// const { parentRef, selectParent } = useSelectParent();

//父组件调用子组件显示弹框
//暴露出去给外部使用
defineExpose({
  show,
});
</script>
