<template>
    <!-- 项目管理 -->
    <div class="app-container">
        <TableModel :formLabel="formLabel" :showOperation="true" :showRightTools="true" ref="proTableRef"
            :columnsList="columnsList" :request-api="getProListAPI">
            <template slot="fileStatus" slot-scope="{ data }">
                <el-tag
                    size="mini"
                    :type="data.fileStatus === '1' ? 'success' : 'danger'"
                >
                    {{ data.fileStatus === '0' ? '未归档移交' : '已归档移交' }}
                </el-tag>
            </template>
            <template slot="handle" slot-scope="{ data }">
                <el-button plain size="mini" type="primary" icon="el-icon-document" v-hasPermi="['file:manage:set']"
                    @click="openFileManager(data)">
                    档案管理
                </el-button>
            </template>
        </TableModel>
    </div>
</template>

<script>
import TableModel from '@/components/TableModel'
import { columnsList, formLabel } from './config'
import {
    getProListAPI
} from '@/api/archivesManagement/fileManager/fileManager.js'


export default {
    name: 'ProManager',
    dicts:['pro_type','voltage_level'],
    components: {
        TableModel,
    },
    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()
        },
        /* 打开档案管理 */
        openFileManager(row) {
            this.$router.push({
                name: 'FileData',
                query: {
                    id: row.id
                }
            })
        }
    },
}
</script>
