<template>
    <!-- 项目管理 -->
    <div class="app-container">
        <TableModel :formLabel="formLabel" :showOperation="true" :showRightTools="true" ref="proTableRef"
            :columnsList="columnsList" :request-api="getProListAPI">
            <template slot="contentsName" slot-scope="{ data }">
                <el-tag
                    size="mini"
                    :type="data.contentsName ? 'success' : 'danger'"
                >
                    {{ data.contentsName ? data.contentsName : '未配置' }}
                </el-tag>
            </template>
            <template slot="handle" slot-scope="{ data }">
                <el-button plain size="mini" type="primary" icon="el-icon-edit" v-hasPermi="['data:classify:update']"
                    @click="handleUpdate(data)" v-if="!data.contentsName">
                    配置档案类型
                </el-button>
            </template>
        </TableModel>
        <!-- 配置 -->
        <FileSetForm v-if="isflag" :isAdd="isAdd" :rowData="row" @handleQuery="handleQuery" :title="title"
            @closeDialog="closeDialog" @showColose="showColose" :dataForm="row" :disabled="loading" :width="600" />
    </div>
</template>

<script>
import TableModel from '@/components/TableModel'
import { columnsList, formLabel } from './config'
import {
    getProListAPI
} from '@/api/archivesManagement/project'
// import FileSetForm from './prop/fileSetForm'


export default {
    name: 'ProManager',
    dicts:['pro_type','voltage_level'],
    components: {
        TableModel,
        // FileSetForm
    },
    data() {
        return {
            formLabel,
            columnsList,
            getProListAPI,
            title: "",
            isflag: false,
            isAdd: '',
            row: {},
            loading: false,
        }
    },

    created() {
        // 将字典数据填充到表单配置的下拉选项中
        if (Array.isArray(this.formLabel)) {
            this.formLabel.forEach((item) => {
                if (item.f_dict && this.dict && this.dict.type && this.dict.type[item.f_dict]) {
                    this.$set(item, 'f_selList', this.dict.type[item.f_dict])
                }
            })
        }
    },

    methods: {
        closeDialog() {
            this.isflag = false;
        },
        showColose() {
            this.isflag = false;
        },
        /** 配置档案类型 */
        handleUpdate(row) {
            this.title = "配置档案类型";
            this.isAdd = 'edit';
            this.row = row;
            this.isflag = true;
        },
        /* 搜索操作 */
        handleQuery() {
            this.$refs.proTableRef.getTableList()
        },
    },
}
</script>
