import { BasicColumn, FormSchema } from '/@/components/Table';
import { dict, getTown, getHylb } from '/@/api/common/api'
import { useUserStore } from '/@/store/modules/user';
import { ref } from 'vue';

const userStore: any = useUserStore();
export const useSuspectsData = () => {
    const suspects = ref([]);
    // 获取行业分类
    const getIsSuspect = async () => {
        suspects.value = await dict({ key: 'dk_hyfl' });
    };
    getIsSuspect();
    return { data: suspects };
};

export const useCategoryData = () => {
    let allCategory = [];
    const treeData = ref([]);
    // 获取行业类别
    const getData = async () => {
        allCategory = await getHylb({});
        // allCategory = convertTreeData(allCategory); // 只显示前2级
        // allCategory.forEach((item: any) => {
        //     item.disabled = true; // 第1层级不能选中
        // });
        treeData.value = allCategory;
    };
    getData();
    // 改变行业分类
    function changeIsSuspect(v) {
        if (v == 1) {
            // 只显示42号类
            treeData.value = allCategory.filter((item) => item['is42']);
        } else {
            treeData.value = allCategory;
        }
    }
    return { data: treeData, changeIsSuspect };
};
// 获取等级
const userIdent = ref<any>([])
export const getUserLevel = () => {
    const getIsSuspect = async () => {
        if (userStore?.userInfo?.userIdentity == '1') {
            userIdent.value = [{
                text: '市级',
                value: '1'

            }, {
                text: '区县',
                value: '2'
            }
            ]
        }
    };
    getIsSuspect();

    return { data: userIdent };
}

export const excedColumns: BasicColumn[] = [

    {
        title: '行政区划',
        dataIndex: 'name',
        resizable: true,
    },
    {
        title: '地块总数',
        dataIndex: 'total',
        // sorter: true,
        resizable: true,
    },
    {
        title: '未评审地块数量',
        dataIndex: 'wpsTotal',
        // sorter: true,
        resizable: true,
    },
    {
        title: '未超标地块数量',
        dataIndex: 'wcbTotal',
        // sorter: true,
        resizable: true,
    },
    {
        title: '超标地块数量',
        dataIndex: 'cbTotal',
        // sorter: true,
        resizable: true,
    },
]
export const searchExcedFormSchema: FormSchema[] = [
    {
        label: '等级',
        field: 'level',
        component: 'ApiSelect',
        show: () => {
            return userStore?.userInfo?.userIdentity == '1' ? true : false
        },
        slot: 'userLevle'
    },
    {
        label: '市',
        field: 'cityCode',
        component: 'ApiSelect',
        show: ({ values }) => {
            return values.level == '2' ? true : false
        },
        componentProps: () => {
            return {
                api: getTown,
                params: 440000, // 市编码
                labelField: 'name',
                valueField: 'id',

            };
        },
    },
    // {
    //     label: '政策依据',
    //     field: 'faliyiju',
    //     component: 'JSearchSelect',
    //     componentProps: {
    //         dict: 'dk_zcyj',
    //     },
    // },
    // {
    //     label: '政策依据二级',
    //     field: 'faliErji',
    //     component: 'ApiSelect',
    //     show: ({ values }) => {
    //         return values?.faliyiju == 1
    //     },
    //     componentProps: {
    //         api: dict,
    //         params: { key: 'dk_zcyjej' },
    //         labelField: 'text',
    //         valueField: 'value'
    //     },
    // },
]
// 行业超标
export const HyColumns: BasicColumn[] = [

    {
        title: '行业类别',
        dataIndex: 'name',
        resizable: true,
    },
    {
        title: '地块总数',
        dataIndex: 'total',
        // sorter: true,
        resizable: true,
    },
    {
        title: '未评审地块数量',
        dataIndex: 'wpsTotal',
        // sorter: true,
        resizable: true,
    },
    {
        title: '未超标地块数量',
        dataIndex: 'wcbTotal',
        // sorter: true,
        resizable: true,
    },
    {
        title: '超标地块数量',
        dataIndex: 'cbTotal',
        // sorter: true,
        resizable: true,
    },
]
export const HyseachFormSchema: FormSchema[] = [

    {
        label: '市',
        field: 'cityCode',
        component: 'ApiSelect',
        ifShow: () => {
            return userStore?.userInfo?.userIdentity == '1' ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            return {
                api: getTown,
                params: 440000, // 市编码
                labelField: 'name',
                valueField: 'id',
                onChange: (val: any) => {
                    const { updateSchema } = formActionType;
                    formModel.countryCode = undefined;
                    if (val) {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: getTown,
                                params: val,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    } else {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: undefined,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    }
                },
            };
        },
    },
    {
        label: '县',
        field: 'countryCode',
        component: 'ApiSelect',
        ifShow: () => {
            return (userStore?.userInfo?.userIdentity == '2' || userStore?.userInfo?.userIdentity == '1') ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            if (userStore?.userInfo?.userIdentity == '2') {
                const { updateSchema } = formActionType;
                updateSchema({
                    label: '县',
                    field: 'countryCode',
                    ifShow: true,
                    componentProps: {
                        api: getTown,
                        params: userStore?.userInfo?.codeRegion,
                        labelField: 'name',
                        valueField: 'id',
                    },
                });
            }
            return {
                labelField: 'name',
                valueField: 'id',
            }
        },
    },
    {
        label: '行业类别',
        field: 'hylb',
        component: 'TreeSelect',
        slot: 'category',
    },
    // {
    //     label: '政策依据',
    //     field: 'faliyiju',
    //     component: 'JSearchSelect',
    //     componentProps: {
    //         dict: 'dk_zcyj',
    //     },
    // },

]
// 逾期情况监测
export const YqColumns: BasicColumn[] = [
    {
        title: '行政区划',
        dataIndex: 'name',
        resizable: true,
    },
    {
        title: '用户账号',
        dataIndex: 'userId',
        resizable: true,
    },
    {
        title: '地块名称',
        dataIndex: 'wrdkmc',
        resizable: true,
    },
    {
        title: '行业类别',
        dataIndex: 'hylb',
        resizable: true,
    },

    {
        title: '地块类型',
        dataIndex: 'dklx',
        resizable: true,
    },

    {
        title: '地块创建时间',
        dataIndex: 'createTsamp',
        resizable: true,
    },

    {
        title: '确认收到账户日期',
        dataIndex: 'qrsdzhrq',
        resizable: true,
    },
    {
        title: '逾期时长(天)',
        dataIndex: 'yqsc',
        resizable: true,
    },

]
export const YqseachFormSchema: FormSchema[] = [

    {
        label: '市',
        field: 'cityCode',
        component: 'ApiSelect',
        ifShow: () => {
            return userStore?.userInfo?.userIdentity == '1' ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            return {
                api: getTown,
                params: 440000, // 市编码
                labelField: 'name',
                valueField: 'id',
                onChange: (val: any) => {
                    const { updateSchema } = formActionType;
                    formModel.countryCode = undefined;
                    if (val) {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: getTown,
                                params: val,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    } else {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: undefined,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    }
                },
            };
        },
    },
    {
        label: '县',
        field: 'countryCode',
        component: 'ApiSelect',
        ifShow: () => {
            return (userStore?.userInfo?.userIdentity == '2' || userStore?.userInfo?.userIdentity == '1') ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            if (userStore?.userInfo?.userIdentity == '2') {
                const { updateSchema } = formActionType;
                updateSchema({
                    label: '县',
                    field: 'countryCode',
                    ifShow: true,
                    componentProps: {
                        api: getTown,
                        params: userStore?.userInfo?.codeRegion,
                        labelField: 'name',
                        valueField: 'id',
                    },
                });
            }
            return {
                labelField: 'name',
                valueField: 'id',
            }
        },
    },
    {
        label: '行业类别',
        field: 'hylb',
        component: 'TreeSelect',
        slot: 'category',
    },
    {
        label: '逾期状态',
        field: 'yqzt',
        component: 'Select',
        componentProps: {
            options: [
                { label: '未逾期', value: '1' },
                { label: '已逾期', value: '2' },
                { label: '用户尚未登录', value: '3' },

            ],
        }
    },
    {
        label: '地块名称',
        field: 'wrdkbm',
        component: 'Input',
        componentProps: {
            placeholder: '地块名称或者账户名称'
        }
    },
    // {
    //     label: '政策依据',
    //     field: 'faliyiju',
    //     component: 'JSearchSelect',
    //     componentProps: {
    //         dict: 'dk_zcyj',
    //     },
    // },

]
// 全部地块报表
export const QbdkColumns: BasicColumn[] = [
    {
        title: '行政区划',
        dataIndex: 'name',
        resizable: true,
    },
    {
        title: '地块名称',
        dataIndex: 'wrdkmc',
        resizable: true,
    },
    {
        title: '用户编码',
        dataIndex: 'wrdkbm',
        resizable: true,
    },

    {
        title: '行业类别',
        dataIndex: 'hylb',
        resizable: true,
    },

    {
        title: '是否超标',
        dataIndex: 'pollueted',
        resizable: true,

    },

    {
        title: '所处阶段',
        dataIndex: 'scjd',
        resizable: true,
    },

]

export const QbdkseachFormSchema: FormSchema[] = [

    {
        label: '市',
        field: 'cityCode',
        component: 'ApiSelect',
        ifShow: () => {
            return userStore?.userInfo?.userIdentity == '1' ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            return {
                api: getTown,
                params: 440000, // 市编码
                labelField: 'name',
                valueField: 'id',
                onChange: (val: any) => {
                    const { updateSchema } = formActionType;
                    formModel.countryCode = undefined;
                    if (val) {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: getTown,
                                params: val,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    } else {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: undefined,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    }
                },
            };
        },
    },
    {
        label: '县',
        field: 'countryCode',
        component: 'ApiSelect',
        ifShow: () => {
            return (userStore?.userInfo?.userIdentity == '2' || userStore?.userInfo?.userIdentity == '1') ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            if (userStore?.userInfo?.userIdentity == '2') {
                const { updateSchema } = formActionType;
                updateSchema({
                    label: '县',
                    field: 'countryCode',
                    ifShow: true,
                    componentProps: {
                        api: getTown,
                        params: userStore?.userInfo?.codeRegion,
                        labelField: 'name',
                        valueField: 'id',
                    },
                });
            }
            return {
                labelField: 'name',
                valueField: 'id',
            }
        },
    },
    {
        label: '行业类别',
        field: 'hylb',
        component: 'TreeSelect',
        slot: 'category',
    },
    {
        label: '是否超标',
        field: 'sfcb',
        component: 'ApiSelect',
        componentProps: {
            api: dict,
            params: { key: 'qd_sfcb' },
            labelField: 'text',
            valueField: 'value',
        }
    },
    {
        label: '所处阶段',
        field: 'scjd',
        component: 'Select',
        componentProps: {
            options: [
                { label: '未开展调查', value: 'S0' },
                { label: '地块调查 ', value: 'S2' },
                { label: '风险评估', value: 'S3' },
                { label: '风险管控', value: 'S4' },
                { label: '修复', value: 'S5' },
                { label: '管控及修复', value: 'S10' },
                { label: '效果评估', value: 'S6' },


            ],
        }
    },
    {
        label: '地块名称',
        field: 'wrdkbm',
        component: 'Input',
        componentProps: {
            placeholder: '地块名称或地块编码'
        }
    },
]
// 截止时间统计分析
export const JzsjColumns: BasicColumn[] = [

    {
        title: '行政区划',
        dataIndex: 'name',
        resizable: true,
    },

    {
        title: '地块总数',
        dataIndex: 'total',
        sorter: true,
        resizable: true,
    },
    {
        title: '未展开调查地块数量',
        dataIndex: 'wpsTotal',
        sorter: true,
        resizable: true,
    },
    {
        title: '未超标地块数量',
        dataIndex: 'wcbTotal',
        sorter: true,
        resizable: true,
    },
    {
        title: '超标地块数量',
        dataIndex: 'cbTotal',
        sorter: true,
        resizable: true,
    },
]
export const JzsjseachFormSchema: FormSchema[] = [

    {
        label: '市',
        field: 'cityCode',
        component: 'ApiSelect',
        ifShow: () => {
            return userStore?.userInfo?.userIdentity == '1' ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            return {
                api: getTown,
                params: 440000, // 市编码
                labelField: 'name',
                valueField: 'id',
                onChange: (val: any) => {
                    const { updateSchema } = formActionType;
                    formModel.countryCode = undefined;
                    if (val) {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: getTown,
                                params: val,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    } else {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: undefined,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    }
                },
            };
        },
    },
    {
        label: '县',
        field: 'countryCode',
        component: 'ApiSelect',
        ifShow: () => {
            return (userStore?.userInfo?.userIdentity == '2' || userStore?.userInfo?.userIdentity == '1') ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            if (userStore?.userInfo?.userIdentity == '2') {
                const { updateSchema } = formActionType;
                updateSchema({
                    label: '县',
                    field: 'countryCode',
                    ifShow: true,
                    componentProps: {
                        api: getTown,
                        params: userStore?.userInfo?.codeRegion,
                        labelField: 'name',
                        valueField: 'id',
                    },
                });
            }
            return {
                labelField: 'name',
                valueField: 'id',
            }
        },
    },
    {
        label: '日期',
        field: 'data',
        component: 'RangeDate',
        componentProps: {
            format: 'YYYY-MM-DD',
            //范围文本描述用集合
            placeholder: ['请选择开始日期', '请选择结束日期']
        },
    },

]
// 覆盖率
export const FglColumns: BasicColumn[] = [
    {
        title: '行政区划',
        dataIndex: 'name',
        resizable: true,
    },
    {
        title: '用户名',
        dataIndex: 'realname',
        resizable: true,
    },

    {
        title: '登录次数',
        dataIndex: 'loginNum',

        resizable: true,
    },
    {
        title: '用户类型',
        dataIndex: 'userType',

        resizable: true,
    },
    {
        title: '用户类别',
        dataIndex: 'userIdentity',

        resizable: true,
    },
]
export const FglseachFormSchema: FormSchema[] = [

    {
        label: '行政区(市)',
        field: 'cityCode',
        component: 'ApiSelect',
        ifShow: () => {
            return userStore?.userInfo?.userIdentity == '1' ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            return {
                api: getTown,
                params: 440000, // 市编码
                labelField: 'name',
                valueField: 'id',
                onChange: (val: any) => {
                    const { updateSchema } = formActionType;
                    formModel.countryCode = undefined;
                    if (val) {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: getTown,
                                params: val,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    } else {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: undefined,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    }
                },
            };
        },
    },
    {
        label: '县',
        field: 'countryCode',
        component: 'ApiSelect',
        ifShow: () => {
            return (userStore?.userInfo?.userIdentity == '2' || userStore?.userInfo?.userIdentity == '1') ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            if (userStore?.userInfo?.userIdentity == '2') {
                const { updateSchema } = formActionType;
                updateSchema({
                    label: '县',
                    field: 'countryCode',
                    ifShow: true,
                    componentProps: {
                        api: getTown,
                        params: userStore?.userInfo?.codeRegion,
                        labelField: 'name',
                        valueField: 'id',
                    },
                });
            }
            return {
                labelField: 'name',
                valueField: 'id',
            }
        },
    },
    {
        label: '用户类型',
        field: 'userType',
        component: 'ApiSelect',
        componentProps: {
            api: dict,
            params: { key: 'dk_user_type' },
            labelField: 'text',
            valueField: 'value',
        }
    },
    {
        label: '用户类别',
        field: 'userIdentity',
        component: 'ApiSelect',
        componentProps: {
            api: dict,
            params: { key: 'user_levle' },
            labelField: 'text',
            valueField: 'value',
        }
    },
]
// 用户活跃度
export const YhhyColumns: BasicColumn[] = [
    {
        title: '行政区划',
        dataIndex: 'name',
        resizable: true,
    },
    {
        title: '用户名',
        dataIndex: 'realname',
        resizable: true,
    },



    {
        title: '登录次数',
        dataIndex: 'num',

        resizable: true,
    },
    {
        title: '用户类型',
        dataIndex: 'userType',

        resizable: true,
    },
    {
        title: '用户类别',
        dataIndex: 'userIdentity',

        resizable: true,
    },
]
export const YhhyseachFormSchema: FormSchema[] = [

    {
        label: '市',
        field: 'cityCode',
        component: 'ApiSelect',
        ifShow: () => {
            return userStore?.userInfo?.userIdentity == '1' ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            return {
                api: getTown,
                params: 440000, // 市编码
                labelField: 'name',
                valueField: 'id',
                onChange: (val: any) => {
                    const { updateSchema } = formActionType;
                    formModel.countryCode = undefined;
                    if (val) {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: getTown,
                                params: val,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    } else {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: undefined,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    }
                },
            };
        },
    },
    {
        label: '县',
        field: 'countryCode',
        component: 'ApiSelect',
        ifShow: () => {
            return (userStore?.userInfo?.userIdentity == '2' || userStore?.userInfo?.userIdentity == '1') ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            if (userStore?.userInfo?.userIdentity == '2') {
                const { updateSchema } = formActionType;
                updateSchema({
                    label: '县',
                    field: 'countryCode',
                    ifShow: true,
                    componentProps: {
                        api: getTown,
                        params: userStore?.userInfo?.codeRegion,
                        labelField: 'name',
                        valueField: 'id',
                    },
                });
            }
            return {
                labelField: 'name',
                valueField: 'id',
            }
        },
    },
    {
        label: '用户类型',
        field: 'userType',
        component: 'ApiSelect',
        componentProps: {
            api: dict,
            params: { key: 'dk_user_type' },
            labelField: 'text',
            valueField: 'value',
        }
    },
    {
        label: '用户类别',
        field: 'userIdentity',
        component: 'ApiSelect',
        componentProps: {
            api: dict,
            params: { key: 'user_levle' },
            labelField: 'text',
            valueField: 'value',
        }
    },
    {
        label: '日期',
        field: 'data',
        component: 'RangeDate',
        componentProps: {
            //日期格式化，页面上显示的值
            format: 'YYYY-MM-DD',
            //返回值格式化（绑定值的格式）
            valueFormat: 'YYYY-MM-DD',
            placeholder: ['请选择开始日期', '请选择结束日期']
        }
    },

]
// 导出地块
export const DcColumns: BasicColumn[] = [
    {
        title: '行政区划',
        dataIndex: 'name',
        resizable: true,
    },

    {
        title: '地块名称',
        dataIndex: 'wrdkmc',
        resizable: true,
    },
    {
        title: '地块编码',
        dataIndex: 'wrdkbm',
        resizable: true,
    },
    {
        title: '操作账户ID',
        dataIndex: 'userId',

        resizable: true,
    },
    {
        title: '操作账户名称',
        dataIndex: 'realname',

        resizable: true,
    },
    {
        title: '删除时间',
        dataIndex: 'deleteTsamp',

        resizable: true,
    },
    {
        title: '地块账户ID',
        dataIndex: 'dkUserId',

        resizable: true,
    },
    {
        title: '状态',
        dataIndex: 'status',

        resizable: true,
    },

]
// 风险评估专题
export const FxpgztColumns: BasicColumn[] = [
    {
        title: '行政区划',
        dataIndex: 'name',
        resizable: true,
        // ifShow: () => {
        //     return userStore?.userInfo?.userIdentity == '1' ? true : false
        // },
    },
    // {
    //     title: '区县',
    //     dataIndex: 'countryName',
    //     resizable: true,
    //     ifShow: () => {
    //         return (userStore?.userInfo?.userIdentity == '2') ? true : false
    //     },
    // },
    {
        title: '地块名称',
        dataIndex: 'wrdkmc',
        resizable: true,
    },
    {
        title: '地块编码',
        dataIndex: 'wrdkbm',
        resizable: true,
    },
    {
        title: '关注度',
        dataIndex: 'gzd',
        resizable: true,
    }
]
export const FxpgztseachFormSchema: FormSchema[] = [
    {
        label: '市',
        field: 'cityCode',
        component: 'ApiSelect',
        ifShow: () => {
            return userStore?.userInfo?.userIdentity == '1' ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            return {
                api: getTown,
                params: 440000, // 市编码
                labelField: 'name',
                valueField: 'id',
                onChange: (val: any) => {
                    const { updateSchema } = formActionType;
                    formModel.countryCode = undefined;
                    if (val) {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: getTown,
                                params: val,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    } else {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: undefined,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    }
                },
            };
        },
    },
    {
        label: '县',
        field: 'countryCode',
        component: 'ApiSelect',
        ifShow: () => {
            return (userStore?.userInfo?.userIdentity == '2' || userStore?.userInfo?.userIdentity == '1') ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            if (userStore?.userInfo?.userIdentity == '2') {
                const { updateSchema } = formActionType;
                updateSchema({
                    label: '县',
                    field: 'countryCode',
                    ifShow: true,
                    componentProps: {
                        api: getTown,
                        params: userStore?.userInfo?.codeRegion,
                        labelField: 'name',
                        valueField: 'id',
                    },
                });
            }
            return {
                labelField: 'name',
                valueField: 'id',
            }
        },
    },
    {
        label: '关注度',
        field: 'gzd',
        component: 'Select',
        componentProps: {
            options: [
                { label: '低度关注', value: '1' },
                { label: '中度关注 ', value: '2' },
                { label: '高度关注', value: '3' }
            ],
        }
    },
    {
        label: '地块名称',
        field: 'wrdkbm',
        component: 'Input',
        componentProps: {
            placeholder: '地块名称'
        }
    },

]
export const DcseachFormSchema: FormSchema[] = [

    {
        label: '市',
        field: 'cityCode',
        component: 'ApiSelect',
        ifShow: () => {
            return userStore?.userInfo?.userIdentity == '1' ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            return {
                api: getTown,
                params: 440000, // 市编码
                labelField: 'name',
                valueField: 'id',
                onChange: (val: any) => {
                    const { updateSchema } = formActionType;
                    formModel.countryCode = undefined;
                    if (val) {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: getTown,
                                params: val,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    } else {
                        updateSchema({
                            field: 'countryCode',
                            componentProps: {
                                api: undefined,
                                labelField: 'name',
                                valueField: 'id',
                            },
                        });
                    }
                },
            };
        },
    },
    {
        label: '县',
        field: 'countryCode',
        component: 'ApiSelect',
        ifShow: () => {
            return (userStore?.userInfo?.userIdentity == '2' || userStore?.userInfo?.userIdentity == '1') ? true : false
        },
        componentProps: ({ formModel, formActionType }) => {
            if (userStore?.userInfo?.userIdentity == '2') {
                const { updateSchema } = formActionType;
                updateSchema({
                    label: '县',
                    field: 'countryCode',
                    ifShow: true,
                    componentProps: {
                        api: getTown,
                        params: userStore?.userInfo?.codeRegion,
                        labelField: 'name',
                        valueField: 'id',
                    },
                });
            }
            return {
                labelField: 'name',
                valueField: 'id',
            }
        },
    },

    {
        label: '日期',
        field: 'data',
        component: 'RangeDate',
        componentProps: {
            //日期格式化，页面上显示的值
            format: 'YYYY-MM-DD',
            //返回值格式化（绑定值的格式）
            valueFormat: 'YYYY-MM-DD',
            placeholder: ['请选择开始日期', '请选择结束日期']
        }
    },
    {
        label: '地块名称',
        field: 'wrdkbm',
        component: 'Input',
        componentProps: {
            placeholder: '地块名称或地块编码'
        }
    },
]
