import { reactive } from 'vue'

// 月计划列表搜索表单配置
export const buildFormColumns = () => [
    {
        type: 'date',
        dateType: 'daterange',
        paramsList: ['startDate', 'endDate'],
        prop: 'month',
        style: {
            width: '240px',
        },
        placeholder: '请选择日期',
    },

    {
        type: 'input',
        prop: 'keyword',
        placeholder: '请输入关键字',
    },
    {
        type: 'input',
        prop: 'projectName',
        placeholder: '请输入项目名称',
    },
    {
        type: 'input',
        prop: 'workContent',
        placeholder: '请输入工作任务',
    },
    {
        type: 'select',
        prop: 'planCompletionStatus',
        placeholder: '请选择计划状态',
        options: [
            { label: '未开始', value: '未开始' },
            { label: '进行中', value: '进行中' },
            { label: '完成', value: '完成' },
        ],
    },
]

// 月计划列表表格列
export const tableColumns = [
    { prop: 'dayPlan', label: '日期', fixed: true, width: '140' },
    { prop: 'inspectionStationName', label: '运检站', fixed: true, width: '140' },
    { prop: 'planMajorName', label: '专业', fixed: true, width: '80' },
    { prop: 'projectName', label: '项目名称', fixed: true, width: '140' },
    { prop: 'workContent', label: '工作任务', width: '140' },
    { prop: 'riskLevel', label: '风险等级', width: '80' },
    { prop: 'plannedWorkload', label: '计划工作量(基)', width: '80' },
]
export const tableColumns_1 = [
    {
        prop: 'stationName',
        label: '拟投入作业人员数量',
        fixed: false,
        width: '80',

        formatter: (row) => {
            return row.proposedPersonnelList?.filter((item) => item.dataSource == 0).length || ''
        },
    },
    {
        prop: 'majorName',
        label: '拟投入作业人员姓名',
        fixed: false,
        width: '200',
        formatter: (row) => {
            return (
                row.proposedPersonnelList
                    ?.filter((item) => item.dataSource == 0)
                    .map((item) => item.name)
                    .join(',') || ''
            )
        },
    },
    {
        prop: 'proposedLongTimeCar',
        label: '拟投入车辆',
        fixed: false,
        width: '200',
        slot: 'proposedLongTimeCar',
    },
    {
        prop: 'projectName',
        label: '实际投入作业人员数量',
        fixed: false,
        width: '80',
        formatter: (row) => {
            return row.proposedPersonnelList?.filter((item) => item.dataSource == 1).length || ''
        },
    },
    {
        prop: 'workTask',
        label: '实际投入作业人员姓名',
        fixed: false,
        width: '200',
        formatter: (row) => {
            return (
                row.proposedPersonnelList
                    ?.filter((item) => item.dataSource == 1)
                    .map((item) => item.name)
                    .join(',') || ''
            )
        },
    },
    {
        prop: 'actualLongTimeCar',
        label: '实际投入车辆',
        fixed: false,
        width: '200',
        slot: 'actualLongTimeCar',
        // formatter: (row) => {
        //     return `长租车${row.actualLongTimeCar}辆,临租车${row.actualTemporaryCar}辆` || ''
        // },
    },
    { prop: 'actualWorkContent', label: '实际完成工作内容', fixed: false, width: '200' },
    { prop: 'actualWorkload', label: '实际完成工作量(基)', fixed: false, width: '80' },
    {
        prop: 'completionPercentage',
        label: '完成比例',
        fixed: false,
        width: '80',
        formatter: (row) => {
            return row.completionPercentage || ''
        },
    },

    { prop: 'planCompletionStatus', label: '作业计划完成情况', fixed: false, width: '200' },
    { prop: 'planChanges', label: '计划变更及未完成情况说明', fixed: false, width: '200' },
]
export const tableColumns_2 = [
    {
        prop: 'stationName',
        label: '拟投入高处作业人员数量',
        fixed: false,
        width: '80',
        formatter: (row) => {
            return row.proposedPersonnelList?.filter((item) => item.dataSource == 2).length || ''
        },
    },
    {
        prop: 'proposedPersonnelListHigh',
        label: '高处作业人员姓名',
        fixed: false,
        width: '200',
        formatter: (row) => {
            return (
                row.proposedPersonnelList
                    ?.filter((item) => item.dataSource == 2)
                    .map((item) => item.name)
                    .join(',') || ''
            )
        },
    },
    {
        prop: 'proposedPersonnelListGroundNum',
        label: '拟投入地面作业人员数量',
        fixed: false,
        width: '80',
        formatter: (row) => {
            return row.proposedPersonnelList?.filter((item) => item.dataSource == 3).length || ''
        },
    },
    {
        prop: 'proposedPersonnelListGround',
        label: '地面作业人员姓名',
        width: '200',
        fixed: false,
        formatter: (row) => {
            return (
                row.proposedPersonnelList
                    ?.filter((item) => item.dataSource == 3)
                    .map((item) => item.name)
                    .join(',') || ''
            )
        },
    },
    {
        prop: 'proposedProficientPersonnel',
        label: '拟投入检修熟练工数量(分包高空作业人员)',
        fixed: false,
        width: '80',
    },
    {
        prop: 'proposedAssistancePersonnel',
        label: '拟投入检修辅助工数量(分包地面作业人员)',
        fixed: false,
        width: '80',
    },
    {
        prop: 'proposedLongTimeCar',
        label: '拟投入车辆',
        fixed: false,
        width: '200',
        slot: 'proposedLongTimeCar',
        // formatter: (row) => {
        //     return `长租车${row.proposedLongTimeCar}辆,临租车${row.proposedTemporaryCar}辆` || ''
        // },
    },
    {
        prop: 'proposedPersonnelListHighNum',
        label: '实际投入高处作业人员数量',
        fixed: false,
        width: '80',
        formatter: (row) => {
            return row.proposedPersonnelList?.filter((item) => item.dataSource == 4).length || ''
        },
    },
    {
        prop: 'proposedPersonnelListHighName',
        label: '高处作业人员姓名',
        width: '200',
        fixed: false,
        formatter: (row) => {
            return (
                row.proposedPersonnelList
                    ?.filter((item) => item.dataSource == 4)
                    .map((item) => item.name)
                    .join(',') || ''
            )
        },
    },
    {
        prop: 'proposedPersonnelListNum',
        label: '实际投入地面作业人员数量',
        width: '80',
        fixed: false,
        formatter: (row) => {
            return row.proposedPersonnelList?.filter((item) => item.dataSource == 5).length || ''
        },
    },
    {
        prop: 'proposedPersonnelList',
        label: '地面作业人员姓名',
        width: '200',
        fixed: false,
        formatter: (row) => {
            return (
                row.proposedPersonnelList
                    ?.filter((item) => item.dataSource == 5)
                    .map((item) => item.name)
                    .join(',') || ''
            )
        },
    },
    {
        prop: 'actualProficientPersonnel',
        label: '实际投入检修熟练工数量(分包高空作业人员)',
        fixed: false,
        width: '80',
    },
    {
        prop: 'actualAssistancePersonnel',
        label: '实际投入检修辅助工数量(分包高空作业人员)',
        fixed: false,
        width: '80',
    },
    {
        prop: 'actualLongTimeCar',
        label: '实际投入车辆',
        width: '200',
        fixed: false,
        slot: 'actualLongTimeCar',
        // formatter: (row) => {
        //     return `长租车${row.actualLongTimeCar}辆,临租车${row.actualTemporaryCar}辆` || ''
        // },
    },
    {
        prop: 'workloadCategoryName',
        label: '实际完成工作内容',
        width: '200',
        fixed: false,
        formatter: (row) => {
            return row.actualWorkloadList?.map((item) => item.workloadCategoryName).join(',') || ''
        },
    },
    {
        prop: 'completionPercentage',
        label: '完成比例',
        fixed: false,
        width: '80',
        formatter: (row) => {
            return row.completionPercentage || ''
        },
    },
    { prop: 'planCompletionStatus', label: '作业计划完成情况', fixed: false, width: '200' },
    { prop: 'planChanges', label: '计划变更及未完成情况说明', fixed: false, width: '200' },
]

export const dialogConfig = reactive({
    outerVisible: false,
    outerTitle: '添加计划任务',
    outerWidth: '70%', // 根据图片缩小宽度更美观
    minHeight: '70vh',
    maxHeight: '90vh',
})

export default {
    tableColumns,
    tableColumns_1,
    tableColumns_2,
    dialogConfig,
    buildFormColumns,
}
