import { FormProps, FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
import { uploadApi } from '/@/api/sys/upload';

export const searchFormSchema: FormSchema[] = [
  {
    field: 'bhgid',
    label: '不合格品',
    defaultValue: undefined,
    component: 'XjrSelect',
    componentProps: {
      datasourceType: 'api',
      apiConfig: {
        path: '/zlgl//bhgp/getBhgp',
        method: 'GET',
        apiId: '716761046a754a3ba90b8911eb7c9e2c',
        apiParams: [
          { key: '1', title: 'Query Params', tableInfo: [] },
          { key: '2', title: 'Header', tableInfo: [] },
          { key: '3', title: 'Body' },
        ],
        script:
          "if(keyword!=null && keyword!=''){\r\n    var sql = \"select id as value,djbh as label from mes_quality_unqualified where delete_mark=0 and djbh like '%${keyword}%' \";\r\n    return db.select(sql)\r\n}\r\nvar sql = 'select id as value,djbh as label from mes_quality_unqualified where delete_mark=0 ';\r\nreturn db.select(sql)",
        outputParams: [
          {
            name: 'label',
            tableTitle: '不合格品编号',
            bindField: 'dan_xing_wen_ben7442',
            show: true,
            width: 150,
            component: '09f63149f2464349b1a85ac7d1956d19',
          },
        ],
      },
      labelField: 'label',
      valueField: 'value',
      mode: 'multiple',
      showSearch: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'jyrq',
    label: '检验日期',
    defaultValue: undefined,
    component: 'RangePicker',
    componentProps: {
      format: 'YYYY-MM-DD HH:mm:ss',
      style: { width: '100%' },
      getPopupContainer: () => document.body,
    },
  },

  {
    field: 'hjph',
    label: '合金牌号',
    defaultValue: undefined,
    component: 'Input',
  },
  {
    field: 'lch',
    label: '炉次号',
    defaultValue: undefined,
    component: 'Input',
  },
  {
    field: 'jyy',
    label: '检验员',
    defaultValue: undefined,
    component: 'User',
    componentProps: {
      suffix: 'ant-design:setting-outlined',
      placeholder: '请选择',
    },
  },

  {
    field: 'gkmc',
    label: '顾客名称',
    defaultValue: undefined,
    component: 'Input',
  },
  {
    field: 'qxmc',
    label: '缺陷名称',
    defaultValue: undefined,
    component: 'Input',
  },
  {
    field: 'qxms',
    label: '缺陷描述',
    defaultValue: undefined,
    component: 'Input',
  },
  {
    field: 'qxmssfss',
    label: '缺陷描述是否属实',
    defaultValue: undefined,
    component: 'XjrSelect',
    componentProps: {
      datasourceType: 'staticData',
      staticOptions: [
        { key: 2, label: '是', value: '1' },
        { key: 3, label: '否', value: '2' },
      ],
      labelField: 'label',
      valueField: 'value',
      mode: 'multiple',
      showSearch: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'jzyfcsyz1',
    label: '纠正预防措施验证1',
    defaultValue: undefined,
    component: 'XjrSelect',
    componentProps: {
      datasourceType: 'staticData',
      staticOptions: [
        { key: 1, label: '是', value: '1' },
        { key: 3, label: '否', value: '2' },
      ],
      labelField: 'label',
      valueField: 'value',
      mode: 'multiple',
      showSearch: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'jzcsyz2',
    label: '纠正措施验证2',
    defaultValue: undefined,
    component: 'XjrSelect',
    componentProps: {
      datasourceType: 'staticData',
      staticOptions: [
        { key: 1, label: '是', value: '1' },
        { key: 2, label: '否', value: '2' },
      ],
      labelField: 'label',
      valueField: 'value',
      mode: 'multiple',
      showSearch: true,
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'jzcsssyxxyz',
    label: '纠正措施实施有效性验证',
    defaultValue: undefined,
    component: 'Input',
  },
  {
    field: 'jzyfcs',
    label: '纠正预防措施',
    defaultValue: undefined,
    component: 'Input',
  },
  {
    field: 'gbyyfx',
    label: '根本原因分析',
    defaultValue: undefined,
    component: 'Input',
  },
];

export const columns: BasicColumn[] = [
  {
    resizable: true,
    dataIndex: 'bhgid',
    title: '不合格品',
    componentType: 'associate-popup',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: undefined,
  },

  {
    resizable: true,
    dataIndex: 'jyrq',
    title: '检验日期',
    componentType: 'date',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: undefined,
  },

  {
    resizable: true,
    dataIndex: 'hjph',
    title: '合金牌号',
    componentType: 'input',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: '',
  },

  {
    resizable: true,
    dataIndex: 'lch',
    title: '炉次号',
    componentType: 'input',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: '',
  },

  {
    resizable: true,
    dataIndex: 'jyy',
    title: '检验员',
    componentType: 'user',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: undefined,
  },

  {
    resizable: true,
    dataIndex: 'gkmc',
    title: '顾客名称',
    componentType: 'input',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: '',
  },

  {
    resizable: true,
    dataIndex: 'qxmc',
    title: '缺陷名称',
    componentType: 'input',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: '',
  },

  {
    resizable: true,
    dataIndex: 'qxms',
    title: '缺陷描述',
    componentType: 'input',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: '',
  },

  {
    resizable: true,
    dataIndex: 'qxmssfss',
    title: '缺陷描述是否属实',
    componentType: 'select',

    customRender: ({ record }) => {
      const staticOptions = [
        { key: 2, label: '是', value: '1' },
        { key: 3, label: '否', value: '2' },
      ];

      return staticOptions.filter((x) => x.value == record.qxmssfss)[0]?.label;
    },

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: undefined,
  },

  {
    resizable: true,
    dataIndex: 'jzyfcsyz1',
    title: '纠正预防措施验证1',
    componentType: 'select',

    customRender: ({ record }) => {
      const staticOptions = [
        { key: 1, label: '是', value: '1' },
        { key: 3, label: '否', value: '2' },
      ];

      return staticOptions.filter((x) => x.value == record.jzyfcsyz1)[0]?.label;
    },

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: undefined,
  },

  {
    resizable: true,
    dataIndex: 'jzcsyz2',
    title: '纠正措施验证2',
    componentType: 'select',

    customRender: ({ record }) => {
      const staticOptions = [
        { key: 1, label: '是', value: '1' },
        { key: 2, label: '否', value: '2' },
      ];

      return staticOptions.filter((x) => x.value == record.jzcsyz2)[0]?.label;
    },

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: undefined,
  },

  {
    resizable: true,
    dataIndex: 'jzcsssyxxyz',
    title: '纠正措施实施有效性验证',
    componentType: 'input',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: '',
  },

  {
    resizable: true,
    dataIndex: 'jzyfcs',
    title: '纠正预防措施',
    componentType: 'input',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: '',
  },

  {
    resizable: true,
    dataIndex: 'gbyyfx',
    title: '根本原因分析',
    componentType: 'input',

    fixed: false,
    sorter: true,

    styleConfig: undefined,
    listStyle: '',
  },
];
//表头合并配置
export const headerMergingData = [];
//表单事件
export const formEventConfigs = {
  0: [
    {
      type: 'circle',
      color: '#2774ff',
      text: '开始节点',
      icon: '#icon-kaishi',
      bgcColor: '#D8E5FF',
      isUserDefined: false,
    },
    {
      color: '#F6AB01',
      icon: '#icon-chushihua',
      text: '初始化表单',
      bgcColor: '#f9f5ea',
      isUserDefined: false,
      nodeInfo: { processEvent: [] },
    },
  ],
  1: [
    {
      color: '#B36EDB',
      icon: '#icon-shujufenxi',
      text: '获取表单数据',
      detail: '(新增无此操作)',
      bgcColor: '#F8F2FC',
      isUserDefined: false,
      nodeInfo: { processEvent: [] },
    },
  ],
  2: [
    {
      color: '#F8625C',
      icon: '#icon-jiazai',
      text: '加载表单',
      bgcColor: '#FFF1F1',
      isUserDefined: false,
      nodeInfo: { processEvent: [] },
    },
  ],
  3: [
    {
      color: '#6C6AE0',
      icon: '#icon-jsontijiao',
      text: '提交表单',
      bgcColor: '#F5F4FF',
      isUserDefined: false,
      nodeInfo: { processEvent: [] },
    },
  ],
  4: [
    {
      type: 'circle',
      color: '#F8625C',
      text: '结束节点',
      icon: '#icon-jieshuzhiliao',
      bgcColor: '#FFD6D6',
      isLast: true,
      isUserDefined: false,
    },
  ],
};
export const formProps: FormProps = {
  labelCol: { span: 3, offset: 0 },
  labelAlign: 'right',
  layout: 'horizontal',
  size: 'default',
  schemas: [
    {
      key: '7d97909d98d54826843087e98bd145fd',
      field: 'bhgid',
      label: '不合格品',
      type: 'associate-popup',
      component: 'MultiplePopup',
      colProps: { span: 24 },
      componentProps: {
        popupType: 'associate',
        width: '100%',
        span: '',
        placeholder: '请选择不合格品',
        showLabel: true,
        disabled: false,
        datasourceType: 'api',
        labelField: 'label',
        valueField: 'value',
        pageSize: 10,
        assoTitle: '不合格品',
        apiConfig: {
          path: '/zlgl//bhgp/getBhgp',
          method: 'GET',
          apiId: '716761046a754a3ba90b8911eb7c9e2c',
          apiParams: [
            { key: '1', title: 'Query Params', tableInfo: [] },
            { key: '2', title: 'Header', tableInfo: [] },
            { key: '3', title: 'Body' },
          ],
          script:
            "if(keyword!=null && keyword!=''){\r\n    var sql = \"select id as value,djbh as label from mes_quality_unqualified where delete_mark=0 and djbh like '%${keyword}%' \";\r\n    return db.select(sql)\r\n}\r\nvar sql = 'select id as value,djbh as label from mes_quality_unqualified where delete_mark=0 ';\r\nreturn db.select(sql)",
          outputParams: [
            {
              name: 'label',
              tableTitle: '不合格品编号',
              bindField: 'danXingWenBen7442',
              show: true,
              width: 150,
              component: '09f63149f2464349b1a85ac7d1956d19',
            },
          ],
        },
        dicOptions: [],
        required: false,
        rules: [],
        events: {},
        isShow: true,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: 'e3ddb10b34544215939acd3c8e5ac645',
      field: 'jyrq',
      label: '检验日期',
      type: 'date',
      component: 'DatePicker',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        span: '',
        defaultValue: '',
        width: '100%',
        placeholder: '请选择检验日期',
        format: 'YYYY-MM-DD HH:mm:ss',
        showLabel: true,
        allowClear: false,
        disabled: false,
        required: true,
        isShow: true,
        rules: [],
        events: {},
        isGetCurrent: false,
        tooltipConfig: { visible: false, title: '提示文本' },
        searchType: 'time',
        style: { width: '100%' },
      },
    },
    {
      key: '928a3689145b40068812ae200ef4192e',
      field: 'hjph',
      label: '合金牌号',
      type: 'input',
      component: 'Input',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        width: '100%',
        span: '',
        defaultValue: '',
        placeholder: '请输入合金牌号',
        maxlength: null,
        prefix: '',
        suffix: '',
        addonBefore: '',
        addonAfter: '',
        disabled: false,
        allowClear: false,
        showLabel: true,
        required: true,
        rules: [],
        events: {},
        listStyle: '',
        isSave: false,
        isShow: true,
        scan: false,
        bordered: true,
        isShowAi: false,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: 'f27565fe96154a06b5e68bd5e738f22e',
      field: 'lch',
      label: '炉次号',
      type: 'input',
      component: 'Input',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        width: '100%',
        span: '',
        defaultValue: '',
        placeholder: '请输入炉次号',
        maxlength: null,
        prefix: '',
        suffix: '',
        addonBefore: '',
        addonAfter: '',
        disabled: false,
        allowClear: false,
        showLabel: true,
        required: true,
        rules: [],
        events: {},
        listStyle: '',
        isSave: false,
        isShow: true,
        scan: false,
        bordered: true,
        isShowAi: false,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: '086ea409b1834b86a61bf38537d80ce4',
      field: 'jyy',
      label: '检验员',
      type: 'user',
      component: 'User',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        span: '',
        width: '100%',
        defaultValue: '',
        placeholder: '请选择人员',
        userType: 0,
        prefix: '',
        suffix: 'ant-design:setting-outlined',
        showLabel: true,
        disabled: false,
        required: true,
        multiple: true,
        isShow: true,
        events: {},
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: 'e689f5cfe2804ebc9582de1743bb493e',
      field: 'gkmc',
      label: '顾客名称',
      type: 'input',
      component: 'Input',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        width: '100%',
        span: '',
        defaultValue: '',
        placeholder: '请输入顾客名称',
        maxlength: null,
        prefix: '',
        suffix: '',
        addonBefore: '',
        addonAfter: '',
        disabled: false,
        allowClear: false,
        showLabel: true,
        required: true,
        rules: [],
        events: {},
        listStyle: '',
        isSave: false,
        isShow: true,
        scan: false,
        bordered: true,
        isShowAi: false,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: '5945de2c060e43d99d44bac3c8a9e30c',
      field: 'images',
      label: '附件',
      type: 'upload',
      component: 'Upload',
      colProps: { span: 24 },
      componentProps: {
        api: uploadApi,
        span: '',
        defaultValue: '',
        accept: '',
        maxNumber: 5,
        maxSize: 5,
        showLabel: true,
        multiple: false,
        disabled: false,
        required: false,
        isShow: true,
        events: {},
        listType: 'text',
        sourceType: 'album,camera',
        tooltipConfig: { visible: false, title: '提示文本' },
      },
    },
    {
      key: '9f2b5aa4478e4dc38f97f2aecc70f5e7',
      field: 'qxmc',
      label: '缺陷名称',
      type: 'input',
      component: 'Input',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        width: '100%',
        span: '',
        defaultValue: '',
        placeholder: '请输入缺陷名称',
        maxlength: null,
        prefix: '',
        suffix: '',
        addonBefore: '',
        addonAfter: '',
        disabled: false,
        allowClear: false,
        showLabel: true,
        required: true,
        rules: [],
        events: {},
        listStyle: '',
        isSave: false,
        isShow: true,
        scan: false,
        bordered: true,
        isShowAi: false,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: '8e00995380d0400b8873d5f598f12616',
      field: 'qxms',
      label: '缺陷描述',
      type: 'input',
      component: 'Input',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        width: '100%',
        span: '',
        defaultValue: '',
        placeholder: '请输入缺陷描述',
        maxlength: null,
        prefix: '',
        suffix: '',
        addonBefore: '',
        addonAfter: '',
        disabled: false,
        allowClear: false,
        showLabel: true,
        required: false,
        rules: [],
        events: {},
        listStyle: '',
        isSave: false,
        isShow: true,
        scan: false,
        bordered: true,
        isShowAi: false,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: '5dcfba711ff141f6864404a433f7fe48',
      field: 'qxmssfss',
      label: '缺陷描述是否属实',
      type: 'select',
      component: 'XjrSelect',
      colProps: { span: 24 },
      componentProps: {
        width: '100%',
        span: '',
        placeholder: '缺陷描述是否属实',
        showLabel: true,
        showSearch: false,
        isMultiple: false,
        clearable: false,
        disabled: false,
        staticOptions: [
          { key: 2, label: '是', value: '1' },
          { key: 3, label: '否', value: '2' },
        ],
        defaultSelect: '',
        datasourceType: 'staticData',
        params: null,
        labelField: 'label',
        valueField: 'value',
        apiConfig: {
          path: 'CodeGeneration/selection',
          method: 'GET',
          apiId: '93d735dcb7364a0f8102188ec4d77ac7',
        },
        dicOptions: [],
        required: true,
        rules: [],
        events: {},
        isShow: true,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: 'bbde2fe52b9443a1a1c77667efb60f25',
      field: 'jzyfcsyz1',
      label: '纠正预防措施验证1',
      type: 'select',
      component: 'XjrSelect',
      colProps: { span: 24 },
      componentProps: {
        width: '100%',
        span: '',
        placeholder: '纠正预防措施验证1',
        showLabel: true,
        showSearch: false,
        isMultiple: false,
        clearable: false,
        disabled: false,
        staticOptions: [
          { key: 1, label: '是', value: '1' },
          { key: 3, label: '否', value: '2' },
        ],
        defaultSelect: '',
        datasourceType: 'staticData',
        params: null,
        labelField: 'label',
        valueField: 'value',
        apiConfig: {
          path: 'CodeGeneration/selection',
          method: 'GET',
          apiId: '93d735dcb7364a0f8102188ec4d77ac7',
        },
        dicOptions: [],
        required: true,
        rules: [],
        events: {},
        isShow: true,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: '43f1169f500747f98ab91bf73a0b282d',
      field: 'jzcsyz2',
      label: '纠正措施验证2',
      type: 'select',
      component: 'XjrSelect',
      colProps: { span: 24 },
      componentProps: {
        width: '100%',
        span: '',
        placeholder: '纠正措施验证2',
        showLabel: true,
        showSearch: false,
        isMultiple: false,
        clearable: false,
        disabled: false,
        staticOptions: [
          { key: 1, label: '是', value: '1' },
          { key: 2, label: '否', value: '2' },
        ],
        defaultSelect: '',
        datasourceType: 'staticData',
        params: null,
        labelField: 'label',
        valueField: 'value',
        apiConfig: {
          path: 'CodeGeneration/selection',
          method: 'GET',
          apiId: '93d735dcb7364a0f8102188ec4d77ac7',
        },
        dicOptions: [],
        required: true,
        rules: [],
        events: {},
        isShow: true,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: '9bf3e230c5d948ca81ad5ef6d5571de3',
      field: 'jzcsssyxxyz',
      label: '纠正措施实施有效性验证',
      type: 'input',
      component: 'Input',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        width: '100%',
        span: '',
        defaultValue: '',
        placeholder: '请输入纠正措施实施有效性验证',
        maxlength: null,
        prefix: '',
        suffix: '',
        addonBefore: '',
        addonAfter: '',
        disabled: false,
        allowClear: false,
        showLabel: true,
        required: true,
        rules: [],
        events: {},
        listStyle: '',
        isSave: false,
        isShow: true,
        scan: false,
        bordered: true,
        isShowAi: false,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: '2f7507003f0b4814a8ea1ebeb56cb4d0',
      field: 'jzyfcs',
      label: '纠正预防措施',
      type: 'input',
      component: 'Input',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        width: '100%',
        span: '',
        defaultValue: '',
        placeholder: '请输入纠正预防措施',
        maxlength: null,
        prefix: '',
        suffix: '',
        addonBefore: '',
        addonAfter: '',
        disabled: false,
        allowClear: false,
        showLabel: true,
        required: true,
        rules: [],
        events: {},
        listStyle: '',
        isSave: false,
        isShow: true,
        scan: false,
        bordered: true,
        isShowAi: false,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
    {
      key: '58c19e3a0f704c9b8ccd8daa42430f9c',
      field: 'gbyyfx',
      label: '根本原因分析',
      type: 'input',
      component: 'Input',
      colProps: { span: 24 },
      defaultValue: '',
      componentProps: {
        width: '100%',
        span: '',
        defaultValue: '',
        placeholder: '请输入根本原因分析',
        maxlength: null,
        prefix: '',
        suffix: '',
        addonBefore: '',
        addonAfter: '',
        disabled: false,
        allowClear: false,
        showLabel: true,
        required: true,
        rules: [],
        events: {},
        listStyle: '',
        isSave: false,
        isShow: true,
        scan: false,
        bordered: true,
        isShowAi: false,
        tooltipConfig: { visible: false, title: '提示文本' },
        style: { width: '100%' },
      },
    },
  ],
  showActionButtonGroup: false,
  buttonLocation: 'center',
  actionColOptions: { span: 24 },
  showResetButton: false,
  showSubmitButton: false,
  hiddenComponent: [],
};
