import { reactive } from 'vue'
import CryptoUtil from "../../../api/crypto.js";

// 根据下拉数据构建搜索表单配置
// 注意：这里不直接发请求，只依赖调用方传入的 options，避免在模块顶层使用组合式 API
export const buildFormColumns = (
    positionOptions = [],
    natureOptions = [],
    categoryOptions = [],
) => [
    {
        type: 'input',
        prop: 'name',
        placeholder: '请输入姓名',
    },
    {
        type: 'select',
        prop: 'sex',
        placeholder: '请选择性别',
        options: [
            {
                label: '男',
                value: 1,
            },
            {
                label: '女',
                value: 0,
            },
        ],
    },
    {
        type: 'select',
        prop: 'positionId',
        placeholder: '请选择部门',
        options: positionOptions.map((item) => ({
            label: item.value,
            value: item.id,
        })),
    },
]

export const tableColumns = [
    {
        prop: 'inspectionStationName',
        label: '人员所属部门',
    },
    {
        prop: 'name',
        label: '姓名',
    },
    {
        prop: 'sex',
        label: '性别',
        formatter: (row) => (row.sex == 1 ? '男' : '女'),
    },
    {
        prop: 'phone',
        label: '电话',
        formatter: (row) => (CryptoUtil.decrypt(row.phone)),
    },
   
]

export const dialogConfig = reactive({
    outerVisible: false,
    outerTitle: '新增人员',
    outerWidth: '640px', // 根据图片缩小宽度更美观
    minHeight: '400px',
    maxHeight: '80vh',
})

export default {
    tableColumns,
    dialogConfig,
    buildFormColumns,
}
