// 运营周报抽屉配置数据
// @ts-ignore: 忽略
import type { FormSchemaGetter } from '#/adapter/form';

// @ts-ignore: 忽略
import { getMultipleImageUploadConfig } from '#/components/upload';

export const drawerFormSchema: any | FormSchemaGetter = () => [
  {
    component: 'SectionTitle',
    fieldName: '_section_title',
    hideLabel: true,
    componentProps: {
      title: '基本信息',
    },
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入本站价格策略',
      type: 'textarea',
      rows: 3,
      maxlength: 200,
    },
    fieldName: 'sitePriceStrategy',
    label: '本站价格策略',
    rules: 'required',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入本站策略变化',
      type: 'textarea',
      rows: 3,
      maxlength: 200,
    },
    fieldName: 'siteStrategyChange',
    label: '本站策略变化',
    rules: 'required',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入竞对油站策略',
      type: 'textarea',
      rows: 3,
      maxlength: 200,
    },
    fieldName: 'competitorStrategy',
    label: '竞对油站策略',
    rules: 'required',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入竞对策略变化',
      type: 'textarea',
      rows: 3,
      maxlength: 200,
    },
    fieldName: 'competitorStrategyChange',
    label: '竞对策略变化',
    rules: 'required',
  },
  {
    component: 'SectionTitle',
    fieldName: '_section_title',
    hideLabel: true,
    componentProps: {
      title: '本周工作',
    },
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入本周完成工作',
      type: 'textarea',
      rows: 3,
      maxlength: 200,
    },
    fieldName: 'weekCompletedWork',
    label: '本周完成工作',
    rules: 'required',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入本周工作总结',
      type: 'textarea',
      rows: 3,
      maxlength: 200,
    },
    fieldName: 'weekSummary',
    label: '本周工作总结',
    rules: 'required',
  },
  {
    component: 'SectionTitle',
    fieldName: '_section_title',
    hideLabel: true,
    componentProps: {
      title: '下周计划',
    },
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入下周工作计划',
      type: 'textarea',
      rows: 3,
      maxlength: 200,
    },
    fieldName: 'nextWeekPlan',
    label: '下周工作计划',
    rules: 'required',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入需协调与帮助',
      type: 'textarea',
      rows: 3,
      maxlength: 200,
    },
    fieldName: 'coordinationHelp',
    label: '需协调与帮助',
    rules: 'required',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入安全、内控、合规、其它事项',
      type: 'textarea',
      rows: 3,
      maxlength: 200,
    },
    fieldName: 'securityInternalComplianceOther',
    label: '安全、内控、合规、其它事项',
  },
  {
    component: 'SectionTitle',
    fieldName: '_section_title',
    hideLabel: true,
    componentProps: {
      title: '附件',
    },
  },
  {
    component: 'Input',
    fieldName: 'images',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    component: 'Upload',
    fieldName: 'imagePaths',
    label: '图片',
    componentProps: (row: any) => {
      return {
        ...getMultipleImageUploadConfig(6),
        multiple: true,
        onSuccess: (res: any, uploadFile: any, uploadFiles: any) => {
          if (res.code === 200) {
            const paths: string[] = [];
            uploadFiles.forEach((item: any) => {
              if (item.response?.code === 200) {
                paths.push(item.response.data.fileName);
              }
            });
            row.images = paths.join(',');
            return res.data;
          }
        },
      };
    },
    renderComponentContent: () => {
      return {
        default: () => '点击上传',
      };
    },
  },
];
