<template>
    <!-- 单位类型管理页面 -->
    <div class="app-container">
        <!-- 表格 -->
        <TableModel
            :formLabel="formLabel"
            :columnsList="columnsList"
            :requestApi="queryUnitTypeListApi"
            ref="tableRef"

        >
            <template slot="btn" slot-scope="{ queryParams }">
                <el-button type="primary" @click="handleAddData()"
                    >新建</el-button
                >
                <el-button @click="handleExportData(queryParams, 'base/unittype/export', '单位类型清单')"
                    >导出</el-button
                >
            </template>
            <template slot="handle" slot-scope="{ data }">
                <el-button
                    type="primary"
                    size="mini"
                    @click="handleEditData(data)"
                    >编辑</el-button
                >
                <el-button
                    type="danger"
                    size="mini"
                    @click="handleDeleteData(data.id, deleteUnitTypeApi)"
                    >删除</el-button
                >
            </template>
            <template slot="isActive" slot-scope="{ data }">
<!--              {{ data }}-->
              {{ data.isActive == '1' ? '启用' : '不启用' }}
            </template>
        </TableModel>

        <!-- 新增以及修改时的弹框 -->
        <DialogModel
            :dialogConfig="dialogConfig"
            @closeDialogOuter="closeDialogOuter"
        >
            <template slot="outerContent">
                <!-- 新增以及修改数据的表单组件 -->
                <FormUnitsType
                    @closeDialog="closeDialog"
                    :editParams="editParams"
                />
            </template>
        </DialogModel>
    </div>
</template>

<script>
import { formLabel, columnsList, dialogConfig } from './config'
import { commonMixin } from '../mixins/common'
import FormUnitsType from './components/form-units-type'
import { queryUnitTypeListApi, deleteUnitTypeApi } from '@/api/base/unitType.js'
export default {
    name: 'UnitType',
    mixins: [commonMixin], // 混入公共方法和数据
    components: {
        FormUnitsType,
    },
    methods: { queryUnitTypeListApi, deleteUnitTypeApi },
    data() {
        return {
            formLabel,
            columnsList,
            dialogConfig,
            // 新建时弹框标题
            addDialogTitle: '新建单位类型',
            // 修改时弹框标题
            editDialogTitle: '修改单位类型',
        }
    },
}
</script>
