import AutoTable from '@/components/AutoTable/mtable';

function getcolumns(setdrawer) {
  const columns = [
    {
      title: '备件料号/名称',
      dataIndex: 'sparePartId',
      key: 'sparePartId',
      editable: false,
      hideInSearch: true,
      colProps: {
        span: 6,
      },
      valueType: 'select',
      formItemProps: {
        rules: [
          {
            required: true,
            message: '此项为必填项',
          },
        ],
      },
      options: {
        path: '/sparepart/sparePart/queryAllSelect',
        params: {},
      },
    },
    {
      title: '供应商编号/名称',
      dataIndex: 'supplierId',
      key: 'supplierId',
      editable: false,
      hideInSearch: true,
      colProps: {
        span: 6,
      },
      formItemProps: {
        rules: [
          {
            required: true,
            message: '此项为必填项',
          },
        ],
      },
      valueType: 'select',
      options: {
        path: '/sparepart/sparePartSupplier/queryOnSelect',
        params: {},
      },
    },
    {
      title: '入库数量',
      dataIndex: 'operateNum',
      valueType: 'digit',
      fieldProps: {
        precision: 0,
      },
      formItemProps: {
        rules: [
          {
            required: true,
            message: '此项为必填项',
          },
        ],
      },
      hideInSearch: true,
      colProps: {
        span: 6,
      },
    },
    {
      title: '库存单位',
      dataIndex: 'unit',
      key: 'unit',
      formItemProps: {
        rules: [
          {
            required: true,
            message: '此项为必填项',
          },
        ],
      },
      fieldProps: {
        disabled: true,
      },
      hideInSearch: true,
      editable: false,
      colProps: {
        span: 6,
      },
    },
  ];

  return [
    {
      tab: '未完成',
      key: '1',
      columns: [
        {
          title: '入库单号',
          dataIndex: 'taskNo',
          key: 'taskNo',
        },
        {
          title: '入库类型',
          dataIndex: 'inTypeName',
          key: 'inType',
          valueType: 'select',
          options: [
            {
              label: '采购入库',
              value: '1',
            },
            {
              label: '生产入库',
              value: '2',
            },
            {
              label: '其他入库',
              value: '3',
            },
          ],
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
        },
        {
          title: '入库仓库',
          dataIndex: 'inWarehouseName',
          key: 'inWarehouseName',
          hideInForm: true,
        },
        {
          title: '出库仓库',
          dataIndex: 'outWarehouseName',
          key: 'outWarehouseName',
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
        },
        {
          title: '备件种类',
          dataIndex: 'spareTypeNum',
          key: 'spareTypeNum',
          hideInForm: true,
          hideInSearch: true,
        },
        {
          title: '相关单号',
          dataIndex: 'relationNo',
          key: 'relationNo',
        },
        {
          title: '备注',
          dataIndex: 'remark',
          key: 'remark',
          valueType: 'textarea',
          hideInSearch: true,
        },
        {
          title: '创建人',
          dataIndex: 'createUserName',
          key: 'createUserId',
          hideInForm: true,
          valueType: 'select',
          fieldProps: {
            showSearch: true,
          },
          options: {
            path: '/auth/sysUser/selection',
            params: {},
          },
        },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          key: 'createTimeList',
          hideInForm: true,
          valueType: 'dateRange',
          render: (text, row) => {
            return <span>{row?.createTime}</span>;
          },
        },
        {
          title: '备件信息',
          dataIndex: 'details',
          key: 'details',
          valueType: 'split',
        },
        {
          title: '备件',
          dataIndex: 'detailsList',
          key: 'detailsList',
          valueType: 'formList',
          colProps: {
            span: 24,
          },
          columns,
          span: 12,
          path: '/sparepart/sparePart/queryList',
          hideInSearch: true,
          hideInTable: true,
          render: (text, row) => {
            return (
              <AutoTable
                columns={columns?.map((it) => ({
                  ...it,
                  hideInSearch: true,
                }))}
                dataSource={row?.detailsList}
              />
            );
          },
        },
      ],
      pathconfig: {
        enableadd: true,
        enableedit: true,
        enabledelete: true,
        enabledetail: true,
        add: '/sparepart/inWarehouseTask/save',
        edit: '/sparepart/inWarehouseTask/save',
        list: '/sparepart/inWarehouseTask/queryNoComplete',
        delete: '',
        detail: '/sparepart/inWarehouseTask/queryDetails',
      },
    },
    {
      tab: '已完成',
      key: '2',
      columns: [
        {
          title: '入库单号',
          dataIndex: 'taskNo',
          key: 'taskNo',
        },
        {
          title: '入库类型',
          dataIndex: 'inTypeName',
          key: 'inType',
          valueType: 'select',
          options: [
            {
              label: '采购入库',
              value: '1',
            },
            {
              label: '生产入库',
              value: '2',
            },
            {
              label: '其他入库',
              value: '3',
            },
          ],
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
        },
        {
          title: '入库仓库',
          dataIndex: 'inWarehouseName',
          key: 'inWarehouseName',
          hideInForm: true,
        },
        {
          title: '出库仓库',
          dataIndex: 'outWarehouseName',
          key: 'outWarehouseName',
          formItemProps: {
            rules: [
              {
                required: true,
                message: '此项为必填项',
              },
            ],
          },
        },
        {
          title: '备件种类',
          dataIndex: 'spareTypeNum',
          key: 'spareTypeNum',
          hideInForm: true,
          hideInSearch: true,
        },
        {
          title: '相关单号',
          dataIndex: 'relationNo',
          key: 'relationNo',
        },
        {
          title: '备注',
          dataIndex: 'remark',
          key: 'remark',
          valueType: 'textarea',
          hideInSearch: true,
        },
        {
          title: '创建人',
          dataIndex: 'createUserName',
          key: 'createUserId',
          hideInForm: true,
          valueType: 'select',
          fieldProps: {
            showSearch: true,
          },
          options: {
            path: '/auth/sysUser/selection',
            params: {},
          },
        },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          key: 'createTimeList',
          hideInForm: true,
          valueType: 'dateRange',
          render: (text, row) => {
            return <span>{row?.createTime}</span>;
          },
        },
        {
          title: '完成时间',
          dataIndex: 'completeTime',
          key: 'completeTimeList',
          hideInForm: true,
          valueType: 'dateRange',
          render: (text, row) => {
            return <span>{row?.completeTime}</span>;
          },
        },
        {
          title: '备件信息',
          dataIndex: 'details',
          key: 'details',
          valueType: 'split',
        },
        {
          title: '备件',
          dataIndex: 'detailsList',
          key: 'detailsList',
          valueType: 'formList',
          colProps: {
            span: 24,
          },
          columns,
          span: 12,
          path: '/sparepart/sparePart/queryList',
          hideInSearch: true,
          hideInTable: true,
          render: (text, row) => {
            return (
              <AutoTable
                columns={columns?.map((it) => ({
                  ...it,
                  hideInSearch: true,
                }))}
                dataSource={row?.detailsList}
              />
            );
          },
        },
        {
          dataIndex: 'splias',
          valueType: 'split',
          title: '入库/关单信息',
          key: 'splisa',
        },
        {
          title: '状态',
          dataIndex: 'statusName',
          key: 'status',
          hideInForm: true,
          valueType: 'select',
          width: 120,
          options: [
            { label: '已入库', value: 2 },
            { label: '已关单', value: 3 },
          ],
        },
        {
          title: '操作人',
          dataIndex: 'operateUserName',
          key: 'operateUserName',
          hideInSearch: true,
          hideInTable: true,
          hideInForm: true,
        },
        {
          title: '操作时间',
          dataIndex: 'operateTime',
          key: 'operateTime',
          hideInSearch: true,
          hideInTable: true,
          hideInForm: true,
        },
      ],
      pathconfig: {
        enableadd: true,
        enableedit: false,
        enabledelete: false,
        enabledetail: true,
        add: '/sparepart/inWarehouseTask/save',
        edit: '/sparepart/inWarehouseTask/save',
        list: '/sparepart/inWarehouseTask/queryYesComplete',
        delete: '',
        detail: '/sparepart/inWarehouseTask/queryDetails',
      },
    },
  ];
}
export default getcolumns;
