<template>
    <!-- 往来单位管理页面 -->
    <div class="app-container">
        <!-- 列表 -->
        <TableModel
          :formLabel="formLabel"
          :columnsList="columnsList"
          :request-api="queryStorageListApi"
          ref="tableRef"
        >
            <template slot="btn" slot-scope="{ queryParams }">
                <el-button type="primary" @click="handleAddData()"
                    >新建</el-button
                >
                <el-button type="success"
                >配置</el-button
                >
                <el-button @click="handleExportData(queryParams, 'base/customer/export', '往来单位清单')"
                    >导出</el-button
                >
            </template>

            <template slot="handle" slot-scope="{ data }">
                <el-button
                  type="warning"
                  size="mini"
                >解绑</el-button
                >
                <el-button
                    type="primary"
                    size="mini"
                    @click="handleEditData(data)"
                    >编辑</el-button
                >
                <el-button
                    type="danger"
                    size="mini"
                    @click="handleDeleteData(data.id, delStorageListApi)"
                    >删除</el-button
                >
            </template>
<!--            <template slot="isActive" slot-scope="{ data }">
              {{ data.isActive == '1' ? '启用' : '不启用' }}
            </template>
            <template slot="phone" slot-scope="{ data }">
              {{ phoneCrypto(data.phone) }}
            </template>-->
        </TableModel>

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

<script>
import { columnsList, dialogConfig, formLabel } from './config'
import { commonMixin } from '../mixins/common'
import FormTrack from './components/form-track.vue'
import {
  queryStorageListApi,
  delStorageListApi
} from '@/api/material/storage'

export default {
    name: 'trackManage',
    mixins: [commonMixin], // 混入公共方法和数据
    components: { FormTrack },
    methods: {
      queryStorageListApi,
      delStorageListApi
    },
    data() {
        return {
            formLabel,
            columnsList,
            dialogConfig,
            addDialogTitle: '新建仓库', // 新建时弹框标题
            editDialogTitle: '修改仓库', // 修改时弹框标题
        }
    },
}
</script>
