import { factorySelect, shopSelectByFactory } from "@/services/system";
import { doFetch } from "@/utils/doFetch";
import { Table } from "antd";


const one = {
  "materieInstoreNo": {
    "value": null,
    "type": "input",
    "title": "入库单号",
    "name": [
      "materieInstoreNo"
    ],
    "required": false
  },
  "storeId": {
    "value": null,
    "type": "select",
    "title": "仓库",
    "name": [
      "storeId"
    ],
    "required": true,
    "options": {
      database: () => doFetch({ url: "/ngic-auth/sysStore/selectionBox", params: { factoryIdList: [] } }),
      params: {}
    },
  },
  "supplierId": {
    "value": null,
    "type": "select",
    "title": "供应商",
    "name": [
      "supplierId"
    ],
    "required": true,
    "options": {
      database: () => doFetch({ url: "/ngic-auth/sysSupplier/query/selection", params: {} }),
      params: {}
    },
  },
  "businessNo": {
    "value": null,
    "type": "input",
    "title": "相关单号",
    "name": [
      "businessNo"
    ],
    "required": false
  },
  "remark": {
    "value": null,
    "type": "textarea",
    "title": "备注",
    "name": [
      "remark"
    ],
    "required": false,
    "col": {
      "span": 24
    }
  },
  "materialList": {
    value: [],
    title: "物料信息",
    type: "table",
    col: { span: 24 },
    name: ["materialList"],
    required: true,
    linkconfig: {
      urlchangeval: {//根据url接口 改变某个value
        database: (params) => doFetch({ url: "/ngic-workmanship/pmMaterie/queryUnitByMaterieId", params }),
        params: { "materieId": "linked" },
        effectresult: {
          "productionUnit": "productionUnit",//key 为列表更新值  value为response 返回值
          "productionUnitName": "productionUnitName"
        }

      }
    },
    columns: [
      {
        "title": <span>物料编码-名称 <b style={{ color: "red" }}>*</b></span>,
        "dataIndex": "materieId",
        "key": "materieId",
        "valueType": "select",
        "width": 300,
        "request": async () => {
          let res = await doFetch({ url: "/ngic-workmanship/pmMaterie/query/selectbox", params: {} })
          return res?.data?.dataList
        },
        "fieldProps": {
          allowClear: false,
          showSearch: true
        },
        "formItemProps": () => {
          return {
            rules: [{ required: true, message: '此项为必填项' }],
          };
        },
      },
      {
        "title": "批次号/SN号",
        "dataIndex": "materieControlNo",
        "key": "materieControlNo"
      },
      {
        "title": <span>入库数量 <b style={{ color: "red" }}>*</b></span>,
        "dataIndex": "instroeNum",
        "key": "instroeNum",
        "formItemProps": () => {
          return {
            rules: [{ required: true, message: '此项为必填项' }],
          };
        },
      },
      {
        "title": "单位",
        "dataIndex": "productionUnitName",
        "key": "productionUnitName",
        "readonly": 'productionUnitName',
        "width": 60
      },
      {
        title: "操作",
        valueType: "option",
        width: 70,
        render: (text, record, _, action) => [
          <a key="delete" onClick={() => { }}>
            删除
          </a>,
        ],
      },
    ],
    rowKey: "id",
  }
},
  two = {
    "materieInstoreNo": {
      "value": null,
      "type": "input",
      "title": "入库单号",
      "name": [
        "materieInstoreNo"
      ],
      "required": false
    },
    "storeId": {
      "value": null,
      "type": "select",
      "title": "仓库",
      "name": [
        "storeId"
      ],
      "required": true,
      "options": {
        database: () => doFetch({ url: "/ngic-auth/sysStore/selectionBox", params: { factoryIdList: [] } }),
        params: {}
      },
    },
    "supplierId": {
      "value": null,
      "type": "select",
      "title": "供应商",
      "name": [
        "supplierId"
      ],
      "required": true,
      "options": {
        database: () => doFetch({ url: "/ngic-auth/sysSupplier/query/selection", params: { factoryIdList: [] } }),
        params: {}
      },
    },
    "businessNo": {
      "value": null,
      "type": "input",
      "title": "相关单号",
      "name": [
        "businessNo"
      ],
      "required": false
    },
    "remark": {
      "value": null,
      "type": "textarea",
      "title": "备注",
      "name": [
        "remark"
      ],
      "required": false,
      "col": {
        "span": 24
      }
    },
    "materialList": {
      value: [],
      title: "物料信息",
      type: "table",
      col: { span: 24 },
      name: ["materialList"],
      required: true,
      columns: [
        {
          "title": "物料名称",
          "dataIndex": "materieName",
          "key": "materieName"
        },
        {
          "title": "物料编码",
          "dataIndex": "materieCode",
          "key": "materieCode"
        },
        {
          "title": "批次号/SN号",
          "dataIndex": "materieControlNo",
          "key": "materieControlNo"
        },
        {
          "title": "入库数量",
          "dataIndex": "instroeNum",
          "key": "instroeNum"
        },
        {
          "title": "单位",
          "dataIndex": "productionUnit",
          "key": "productionUnit"
        },
        {
          title: "操作",
          valueType: "option",
          width: 70,
          render: (text, record, _, action) => [
            <a key="delete" onClick={() => { }}>
              删除
            </a>,
          ],
        },
      ],
      rowKey: "id",
    }
  },
  three = {},
  four = {},
  detail = {
    totalCard: [
      //物料详情
      {
        cardTitle: "基本信息",
        itemData: [
          {
            title: "入库单号",
            key: "materieInstoreNo",
          },
          {
            title: "入库类型",
            key: "instoreTypeName",
          },
          {
            title: "入库仓库",
            key: "storeName",
          },
          {
            title: "相关单号",
            key: "businessNo",
          },
          {
            title: "备注",
            key: "remark",
          },
          {
            title: "创建人",
            key: "createUserName",
          },
          {
            title: "创建时间",
            key: "createTime",
          },
        ],
      },
      {
        cardTitle: "物料信息列表",
        itemData: [
          {
            key: "materialList",
            type: "table",
            col: { span: 24 },
            columns: [
              {
                title: "物料名称",
                dataIndex: "materieName",
                key: "materieName",
                search: false,
              },
              {
                title: "物料编码",
                dataIndex: "materieCode",
                key: "materieCode",
                search: false,
              },
              {
                title: "入库数量",
                dataIndex: "instroeNum",
                key: "instroeNum",
                search: false,
              },
              {
                title: "单位",
                dataIndex: "productionUnitName",
                key: "productionUnitName",
                search: false,
              },
            ],
            expandable: {
              expandedRowRender: record => <Table
                style={{marginLeft:48}}
                columns={[
                  {
                    title: "库位名称",
                    dataIndex: "storeName",
                    key: "storeName",
                    search: false,
                  },
                  {
                    title: "上架数量",
                    dataIndex: "instroeNum",
                    key: "instroeNum",
                    search: false,
                  }
                ]}
                dataSource={record.uploadList}
                pagination={false}
              />,
            }
          },
        ],
      },
    ]
  };




export default {
  one,
  two,
  three,
  four,
  detail
};
