import VillageInfoApi, { CommonInfoModel } from "@/api/inhert/VillageInfoApi";
import { useAliOssUploadCo } from "@/common/components/upload/AliOssUploadCo";
import type { PickerIdFieldProps } from "@/components/dynamic/wrappers/PickerIdField";
import type { FieldProps } from "@/components/form/Field.vue";
import type { PickerFieldProps } from "@/components/form/PickerField.vue";
import type { UploaderFieldProps } from "@/components/form/UploaderField.vue";
import type { GroupForm, SingleForm } from "../forms";
import { villageCommonContent } from "./common";

export const villageInfoTravelGuideForm : SingleForm = [CommonInfoModel, () => ({
  formItems: [
    {
      label: '交通基本信息', 
      name: 'transportBasic', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        {
          label: '路线', 
          name: 'villageRoute', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输路线',
          },
          rules:  [{
            required: true,
            message: '请输路线',
          }] 
        },
        {
          label: '距离县城', 
          name: 'county', 
          type: 'number', 
          defaultValue: 0,
          additionalProps: { min: 0, addonAfter: 'KM' },
          rules:  [{
            required: true,
            message: '请输入距离县城',
          }] 
        },
        {
          label: '距离镇区中心', 
          name: 'town', 
          type: 'number', 
          defaultValue: 0,
          additionalProps: { min: 0, addonAfter: 'KM' },
          rules:  [{
            required: true,
            message: '请输入距离镇区中心',
          }] 
        }, 
        {
          label: '距离市中心', 
          name: 'city', 
          type: 'number', 
          defaultValue: 0,
          additionalProps: { min: 0, addonAfter: 'KM' },
          rules:  [{
            required: true,
            message: '请输入距离市中心',
          }] 
        }
      ]
    },
    {
      label: '交通设施信息', 
      name: 'transportFacilities', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        {
          label: '最近高速收费站名称', 
          name: 'tollStationName', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入最近高速收费站名称',
          },
          rules:  [{
            required: true,
            message: '请输入最近高速收费站名称',
          }] 
        },
        {
          label: '最近高速收费站名称', 
          name: 'tollStation', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入最近高速收费站名称',
          },
          rules:  [] 
        },
        {
          label: '距离最近火车站', 
          name: 'trainStation', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入距离最近火车站',
          },
          rules:  [] 
        },
        //有无公交车
        {
          label: '有无公交车', 
          name: 'isBus', 
          type: 'check-box-int', 
          defaultValue: 0,
          additionalProps: {
            text: '有',
          },
          rules:  [{
            required: true,
            message: '请选择有无公交车',
            type: 'number',
          }] 
        },
        {
          label: '公交车介绍', 
          name: 'busIntro', 
          type: 'text', 
          show: { callback: (_, rawModel) => (rawModel.isBus == 1) },
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入公交车介绍',
          },
          rules: [{
            required: true,
            message: '请输入公交车介绍',
          }] 
        },
        {
          label: '其他交通方式', 
          name: 'otherBus', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入其他交通方式',
          },
          rules:  [] 
        }
      ]
    },
    {
      label: '图片信息', 
      name: 'imageInfo', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        {
          label: '景区全景图', 
          name: 'panorama', 
          type: 'uploader', 
          defaultValue: '',
          additionalProps: {
            upload: useAliOssUploadCo('xiangyuan/travel/panorama'),
            maxFileSize: 1024 * 1024 * 20,
            single: true,
          } as UploaderFieldProps,
          rules:  [] 
        },
        {
          label: '其他图', 
          name: 'otherImage', 
          type: 'uploader', 
          defaultValue: '',
          additionalProps: {
            upload: useAliOssUploadCo('xiangyuan/travel/guide'),
            maxFileSize: 1024 * 1024 * 20,
            single: true,
          } as UploaderFieldProps,
          rules:  [] 
        }
      ]
    },
    {
      label: '标识牌信息', 
      name: 'signInfo', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        //解说牌
        {
          label: '有无解说牌', 
          name: 'introBoard', 
          type: 'check-box-int', 
          defaultValue: 0,
          additionalProps: {
            text: '有',
          },
          rules:  [{
            required: true,
            message: '请选择有无解说牌',
          }] 
        },
        {
          label: '其他解说牌', 
          name: 'otherIntroBoard', 
          type: 'text', 
          show: { callback: (_, rawModel) => (rawModel.introBoard == 1) },
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入其他解说牌',
          },
          rules:  [] 
        },
        {
          label: '有无解指示牌', 
          name: 'indicateBoard', 
          type: 'check-box-int', 
          defaultValue: 0,
          additionalProps: {
            text: '有',
          },
          rules:  [{
            required: true,
            message: '请选择有无指示牌',
          }] 
        },
        {
          label: '其他指示牌', 
          name: 'otherIndicateBoard', 
          type: 'text', 
          show: { callback: (_, rawModel) => (rawModel.indicateBoard == 1) },
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入其他指示牌',
          },
          rules: [{
            required: true,
            message: '请输入其他指示牌',
          }] 
        },
        {
          label: '有无安全告示牌', 
          name: 'safeBoard', 
          type: 'check-box-int', 
          defaultValue: 0,
          additionalProps: {
            text: '有',
          },
          rules:  [{
            required: true,
            message: '请选择有无安全告示牌',
          }] 
        },
        {
          label: '其他安全告示牌', 
          name: 'otherSafeBoard', 
          type: 'text', 
          show: { callback: (_, rawModel) => (rawModel.safeBoard == 1) },
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入其他安全告示牌',
          },
          rules: [{
            required: true,
            message: '请输入其他安全告示牌',
          }] 
        }
      ]
    },
    {
      label: '服务设施', 
      name: 'serviceFacilities', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        {
          label: '有无游客服务中心', 
          name: 'visitorCenter', 
          type: 'check-box-int', 
          defaultValue: 0,
          additionalProps: {
            text: '有',
          },
          rules:  [{
            required: true,
            message: '请选择有有无游客服务中心',
          }] 
        },
        {
          label: '游客服务中心面积', 
          name: 'visitorCenterArea', 
          type: 'text', 
          show: { callback: (_, rawModel) => (rawModel.visitorCenter == 1) },
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入游客服务中心面积',
          },
          rules: [{
            required: true,
            message: '请输入游客服务中心面积',
          }] 
        },
        {
          label: '商业设施', 
          name: 'business',
          type: 'select-id', 
          additionalProps: {
            loadData: async () => 
            (await VillageInfoApi.getCategoryChildList(282))
              .map((p) => ({
                value: p.id,
                text: p.title,
              }))
            ,
          } as PickerIdFieldProps,
          formProps: { showRightArrow: true } as FieldProps,
          rules: [{
            required: true,
            message: '请选择商业设施',
          }],
        },
        {
          label: '其他商业设施', 
          name: 'otherBusiness', 
          type: 'text', 
          defaultValue: '',
          show: { callback: (_, rawModel) => (rawModel.business == 288) },
          additionalProps: {
            placeholder: '请输入其他商业设施',
          },
          rules: [{
            required: true,
            message: '请输入其他商业设施',
          }] 
        }
      ]
    },
    {
      label: '医疗与游览服务', 
      name: 'medicalTourService', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        //医疗点
        {
          label: '有无医疗点', 
          name: 'medicalPoint', 
          type: 'select', 
          defaultValue: 0,
          additionalProps: {
            columns: [[
              { value: 0, text: '无' },
              { value: 1, text: '有' },
              { value: 2, text: '其他' }
            ]],
            singleValue: true,
          } as PickerFieldProps,
          formProps: {
            showRightArrow: true,
          },
          rules:  [{
            required: true,
            message: '请选择有无医疗点',
          }] 
        },
        {
          label: '其他医疗点', 
          name: 'otherMedicalPoint', 
          type: 'text', 
          show: { callback: (_, rawModel) => (rawModel.medicalPoint == 2) },
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入其他医疗点',
          },
          rules: [{
            required: true,
            message: '请输入其他医疗点',
          }] 
        },
        //游览车
        {
          label: '有无游览车', 
          name: 'tourBus', 
          type: 'select', 
          defaultValue: 0,
          additionalProps: {
            columns: [[
              { value: 0, text: '无' },
              { value: 1, text: '有' },
              { value: 2, text: '其他' }
            ]],
            singleValue: true,
          } as PickerFieldProps,
          formProps: {
            showRightArrow: true,
          },
          rules:  [{
            required: true,
            message: '请选择有无游览车',
          }] 
        },
        {
          label: '其他游览车', 
          name: 'otherTourBus', 
          type: 'text', 
          show: { callback: (_, rawModel) => (rawModel.tourBus == 2) },
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入其他游览车',
          },
          rules: [{
            required: true,
            message: '请输入其他游览车',
          }] 
        }
      ]
    },
    {
      label: '基础设施', 
      name: 'infrastructure', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        {
          label: '机动车停车场', 
          name: 'parkingLot', 
          type: 'number', 
          defaultValue: 0,
          additionalProps: { min: 0, addonAfter: '辆' },
          rules:  [] 
        },
        {
          label: '分类垃圾点', 
          name: 'garbagePoint', 
          type: 'number', 
          defaultValue: 0,
          additionalProps: { 
            min: 0,
            addonAfter: '处',
          },
          rules:  [] 
        },
        {
          label: '公共卫生间', 
          name: 'publicToilets', 
          type: 'number', 
          defaultValue: 0,
          additionalProps: { min: 0, addonAfter: '处' },
          rules:  [] 
        }
      ]
    }
  ] 
}), { title: '旅游导览', typeName: '', }]

export const villageInfoRouteForm : SingleForm = [CommonInfoModel, (r) => ({
  formItems: [
    {
      label: '游览路线', 
      name: 'serviceFacilities', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        {
          label: '游览路线', 
          name: 'route', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入游览路线',
          },
          rules:  [{
            required: true,
            message: '请输入游览路线',
          }] 
        },
        {
          label: '路线名称', 
          name: 'name', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入路线名称',
          },
          rules:  [{
            required: true,
            message: '请输入路线名称',
          }] 
        },
        {
          label: '描述', 
          name: 'desc', 
          type: 'richtext', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入描述',
            maxLength: 200,
            showWordLimit: true, 
          },
          rules:  [{
            required: true,
            message: '请输入描述',
          }] 
        },
        {
          label: '起始点', 
          name: 'startPoint', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入起始点',
          },
          rules:  [{
            required: true,
            message: '请输入起始点',
          }] 
        },
        {
          label: '终止点', 
          name: 'endPoint', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入终止点',
          },
          rules:  [{
            required: true,
            message: '请输入终止点',
          }] 
        },
        {
          label: '预计时长', 
          name: 'estimate', 
          type: 'number', 
          defaultValue: 1,
          additionalProps: {
            min: 1,
            addonAfter: '小时',
          },
          rules:  [{
            required: true,
            message: '请输入预计时长',
          }] 
        },
        ...villageCommonContent(r, {
          title: '游览路线',
          showContent: false,
          showTitle: false,
        }).formItems
      ]
    },
    
    {
      label: '活动时间', 
      name: 'serviceFacilities', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        {
          label: '活动标题', 
          name: 'activity', 
          type: 'text', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入活动标题',
          },
          rules:  [{
            required: true,
            message: '请输入活动标题',
          }] 
        },
        {
          label: '活动开始时间', 
          name: 'startTime',
          type: 'datetime', 
          defaultValue: '',
          additionalProps: {
            type: 'datetime',
          },
          rules: [{
            required: true,
            message: '请选择活动开始时间',
          }],
        },
        {
          label: '活动结束时间', 
          name: 'endTime',
          type: 'datetime', 
          defaultValue: '',
          additionalProps: {
            type: 'datetime',
          },
          rules: [{
            required: true,
            message: '请选择活动结束时间',
          }],
        },
        {
          label: '活动时长', 
          name: 'duration',
          type: 'number', 
          defaultValue: 0,
          additionalProps: {
            min: 0,
            addonAfter: '分钟',
          },
          rules: [{
            required: true,
            message: '请选择活动时长',
          }],
        },
        ...villageCommonContent(r, {
          title: '活动时间',
          showContent: false,
          showTitle: false,
        }).formItems
      ] 
    },
    {
      label: '路线特色', 
      name: 'serviceFacilities', 
      type: 'flat-group', 
      childrenColProps: {
        span: 24,
      },
      children: [
        {
          label: '特色', 
          name: 'advant', 
          type: 'richtext', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入特色',
            maxLength: 300,
            showWordLimit: true, 
          } as FieldProps,
          rules:  [{
            required: true,
            message: '请输入特色',
          }] 
        },
        {
          label: '文化背景', 
          name: 'intro', 
          type: 'richtext', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入文化背景',
            maxLength: 300,
            showWordLimit: true, 
          } as FieldProps,
          rules:  [{
            required: true,
            message: '请输入文化背景',
          }] 
        },
        {
          label: '精彩推荐', 
          name: 'recommend', 
          type: 'richtext', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入精彩推荐',
            maxLength: 300,
            showWordLimit: true, 
          } as FieldProps,
          rules:  [{
            required: true,
            message: '请输入精彩推荐',
          }] 
        },
        {
          label: '推荐描述', 
          name: 'reason', 
          type: 'richtext', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入推荐描述',
            maxLength: 300,
            showWordLimit: true, 
          } as FieldProps,
          rules:  [{
            required: true,
            message: '请输入推荐描述',
          }] 
        },
        {
          label: '活动亮点', 
          name: 'highlight', 
          type: 'richtext', 
          defaultValue: '',
          additionalProps: {
            placeholder: '请输入活动亮点',
            maxLength: 300,
            showWordLimit: true, 
          } as FieldProps,
          rules:  [{
            required: true,
            message: '请输入活动亮点',
          }] 
        },
        ...villageCommonContent(r, {
          title: '路线特色',
          showContent: false,
          showTitle: false,
        }).formItems
      ]
    },
  ] 
}), { title: '旅游路线', typeName: '', }];
