<!--
 * @Author: Liugh
 * @Date: 2021-05-19 16:09:07
 * @LastEditTime: 2021-05-20 10:12:36
 * @LastEditors: Do not edit
 * @FilePath: \auth-web\src\pages\data-auth-module\auth-subject-manage\subject-prop-manage\add-dialog.vue
 * @Description: 
-->

<template>
    <main class="add-dialog">
        <dg-row class="property-wapper" :gutter="10">
            <!-- 机构列表 -->
            <dg-col :span="8" class="property-wapper__left">
                <dg-card class="box-card">
                    <org-tree
                        ref="tree"
                        class="u-pm__left"
                        treeHeight="470px"
                        :search="true"
                        paddingRight="15px"
                        @handleGetNode="handleGetNode"
                        @submitRootNode="handleGetNode"
                    ></org-tree>
                </dg-card>
            </dg-col>
            <!-- 权限设置 -->
            <dg-col :span="16">
                <el-form ref="form" :model="addForm" label-suffix=":" inline>
                    <div v-if="type == 'personnel'">
                        <el-form-item label="姓名">
                            <el-input clearable placeholder="请输入姓名" v-model="addForm.name"></el-input>
                        </el-form-item>
                        <el-form-item label="身份证号码">
                            <el-input clearable placeholder="请输入身份证号码" v-model="addForm.name"></el-input>
                        </el-form-item>
                    </div>
                    <div v-if="type == 'application'">
                        <el-form-item label="应用系统名称">
                            <el-input clearable placeholder="请输入应用系统名称" v-model="addForm.name"></el-input>
                        </el-form-item>
                    </div>

                    <el-form-item>
                        <dg-button type="primary" icon="el-icon-search" @click="doSearchPersion">查询</dg-button>
                    </el-form-item>
                </el-form>
                <Table
                    v-if="type !== 'agency'"
                    ref="table"
                    :url="tableUrl"
                    :headerData="type == 'personnel' ? cardAddPersonnelList : cardAgencylist"
                    :condition="reportForm"
                    :lazyLoad="true"
                >
                </Table>
            </dg-col>
        </dg-row>
    </main>
</template>

<script>
import * as dynamicManageApi from "@/api/dynamic-manage";
import { cardAddPersonnelList, cardAgencylist } from "../DataConfig";
import orgTree from "@/components/tree";
import Table from "@/components/table";
export default {
    name: "add-dialog", // 组件名称
    props: {
        // 接收父组件的数据
        type: {
            type: String,
            default: "personnel"
        }
    },
    data() {
        // 组件内部参数
        return {
            // 参数名称及默认值
            cardAddPersonnelList,
            cardAgencylist,
            addForm: {},
            tableUrl: dynamicManageApi.tableUrl,
            reportForm: {}
        };
    },
    computed: {}, // 计算属性
    watch: {}, // 侦听器（扩展的计算属性）
    components: { orgTree, Table }, // 注册局部组件
    methods: {
        /**
         * @description: 获取机构节点
         * @param {*} node
         */
        handleGetNode(node) {
            this.subId = node.code;
            this.key++;
        },
        /**
         * @description:查询
         */
        doSearchPersion() {
            this.$emit("success");
        }
    }, // 内部方法
    beforeCreate() {}, // 组件创建前
    created() {}, // 组件创建完成后
    beforeMount() {}, // 组件挂载前
    mounted() {
        console.log(this.type);
    }, // 组件挂载完成后
    beforeUpdate() {}, // 组件更新前
    updated() {}, // 组件挂载完成后
    beforeDestroy() {}, // 组件销毁前
    destroyed() {} // 组件销毁完成后
};
</script>
<style lang="scss" scoped></style>
