import {SERVICE_CTRL_TOWER, upcloud_base_item} from "@/config/serviceSettings";

// 货主
export const getConsignorItems = changeFun => {
  return [
    {
      "hidden": true,
      "type": "input",
      "name": "consignorid",
      "label": "货主ID",
      "value": ""
    },
    {
      "hidden": true,
      "type": "input",
      "name": "consignorcode",
      "label": "货主编码",
      "value": ""
    },
    {
      "type": "searchModal",
      "name": "consignorname",
      "label": "货主名称",
      "title": "货主名称",
      "value": "",
      "rowKey": "companyId",
      "destroyOnClose": true,
      "targetClick": true,
      "targetValueKey": "companyName",
      "labelCol": {
        "span": 8
      },
      "wrapperCol": {
        "span": 16
      },
      "span": 6,
      "remoteUrl": {
        "url": SERVICE_CTRL_TOWER + "/userDataAuth/allDataAuthByUser/?companyType=H",
        "method": "get"
      },
      "required": true,
      "toolBar": {
        "items": []
      },
      "tableConfig": {
        "columns": [
          {
            "dataIndex": "companyId",
            "title": "货主ID",
            "hidden": true
          },
          {
            "dataIndex": "companyName",
            "title": "货主名称"
          },
          {
            "dataIndex": "companyCode",
            "title": "货主编码"
          }
        ],
        "hasRowSelectCheck": true,
        "rowSelectType": 1
      },
      "on": {
        change: changeFun
      }
    },
  ]
}

// 仓库
export const getBranchItems = changeFun => {
  return [
    {
      "hidden": true,
      "type": "input",
      "name": "dcId",
      "label": "仓配中心Id",
      "value": ""
    },
    {
      "hidden": true,
      "type": "input",
      "name": "branchid",
      "label": "仓库ID",
      "value": ""
    },
    {
      "hidden": true,
      "type": "input",
      "name": "branchcode",
      "label": "仓库编码",
      "value": ""
    },
    {
      "type": "searchModal",
      "name": "branchname",
      "label": "仓库名称",
      "title": "仓库名称",
      "value": "",
      "rowKey": "companyId",
      "destroyOnClose": true,
      "targetClick": true,
      "targetValueKey": "companyName",
      "labelCol": {
        "span": 8
      },
      "wrapperCol": {
        "span": 16
      },
      "span": 6,
      "remoteUrl": {
        "url": SERVICE_CTRL_TOWER + "/userDataAuth/allDataAuthByUser/?companyType=S",
        "method": "get"
      },
      "required": true,
      "toolBar": {
        "items": []
      },
      "tableConfig": {
        "columns": [
          {
            "dataIndex": "companyId",
            "title": "仓库ID",
            "hidden": true
          },
          {
            "dataIndex": "dcId",
            "title": "仓配中心ID",
            "hidden": true
          },
          {
            "dataIndex": "companyName",
            "title": "仓库名称"
          },
          {
            "dataIndex": "companyCode",
            "title": "仓库编码"
          }
        ],
        "hasRowSelectCheck": true,
        "rowSelectType": 1
      },
      "on": {
        change: changeFun
      }
    },
  ]
}

// 商品
export const getItemItems = (changeFun, remoteBeforeFun, modalOpenChange) => {
  return [
    {
      "hidden": true,
      "type": "input",
      "name": "itemId",
      "label": "商品ID",
      "value": ""
    },
    {
      "hidden": true,
      "type": "input",
      "name": "itemCode",
      "label": "编码",
      "value": ""
    },
    {
      "type": "searchModal",
      "name": "itemName",
      "label": "商品名称",
      "title": "商品名称",
      "value": "",
      "rowKey": "itemId",
      "destroyOnClose": true,
      "targetClick": true,
      "targetValueKey": "itemName",
      "labelCol": {
        "span": 8
      },
      "wrapperCol": {
        "span": 16
      },
      "span": 6,
      "remoteUrl": {
        "url": upcloud_base_item + "/item/pagebyRelated",
        "method": "post"
      },
      "required": false,
      "toolBar": {
        "items": [
          {
            "span": 16,
            "type": "input",
            "name": "condition",
            "label": "商品名称/编码/助记码",
            "value": ""
          }
        ]
      },
      "tableConfig": {
        remoteBefore: remoteBeforeFun,
        "columns": [
          {
            "dataIndex": "itemId",
            "title": "ID",
            "hidden": true
          },
          {
            "dataIndex": "itemName",
            "title": "商品名称"
          },
          {
            "dataIndex": "itemCode",
            "title": "商品编码"
          }
        ],
        "hasRowSelectCheck": true,
        "rowSelectType": 1
      },
      "on": {
        change: changeFun
      },
      modalOpenChange
    },
  ]
}