let upcloud_base_common = "/api/upcloud-base-common";
let upcloud_base_chain = "/api/upcloud-base-chain";
let grid = {
  labelCol: { span: 5 },
  span: 6,
};
let grid1 = {
  labelCol: { span: 8 },
  span: 11,
};
export function setFormItems(self) {
  let _this = self;
  return [
    {
      type: "input",
      name: "consignorId",
      label: "货主ID",
      value: "",
      hidden: true,
      ...grid,
    },
    {
      type: "input",
      name: "consignorCode",
      label: "货主编码",
      value: "",
      hidden: true,
      ...grid,
    },
    // ...genWarehouseAuthSearchModal(1, false, false, null, null, grid),
    // ...genCargoownerAuthSearchModal(1, false, false, null, null, grid,{mapper:
    //   {
    //     cargoOwnerId: 'consignorId',
    //     consignorName: 'cargoOwnerName',
    //     consignorCode: 'cargoOwnerCode'
    // }}),
    {
      type: "input",
      name: "warehouseId",
      label: "warehouseId",
      value: "",
      hidden: true,
      ...grid1,
    },
    {
      type: "input",
      name: "warehouseCode",
      label: "warehouseCode",
      value: "",
      hidden: true,
      ...grid1,
    },
    {
      label: "仓库名称",
      type: "searchModal",
      targetClick: true,
      disabled: false,
      ...grid,
      name: "warehouseName",
      remoteUrl: { url: "/api/service-ctrl-tower-wms/userDataAuth/allDataAuthByUser/?companyType=S", method: "get" },
      rowKey: "companyId",
      targetValueKey: "companyName",
      toolBar: {
        items: [
          {
            type: "input",
            name: "companyName",
            label: "仓库名称",
            value: "",
          },
          {
            type: "input",
            name: "companyCode",
            label: "仓库编码",
            value: "",
          },
        ],
      },
      tableConfig: {
        columns: [
          {
            dataIndex: "companyName",
            title: "仓库名称",
          },
          {
            dataIndex: "companyCode",
            title: "仓库编码",
          },
        ],
      },
      on: {
        ok(event, value, rowData, form) {
          console.log(form);
          if (form) {
            form.setFieldsValue({
              warehouseId: rowData[0].companyId,
              warehouseCode: rowData[0].companyCode,
            });
          }
        },
        change(event, value, rowData, form) {
          if (!value) {
            form.setFieldsValue({
              warehouseId: "",
              warehouseCode: "",
            });
          }
        },
      },
    },
    {
      label: "货主名称",
      type: "searchModal",
      targetClick: true,
      disabled: false,
      ...grid,
      name: "consignorName",
      remoteUrl: { url: "/api/service-ctrl-tower-wms/userDataAuth/allDataAuthByUser/?companyType=H", method: "get" },
      rowKey: "companyId",
      targetValueKey: "companyName",
      toolBar: {
        items: [
          {
            type: "input",
            name: "companyCode",
            label: "货主编码",
            value: "",
          },
          {
            type: "input",
            name: "companyName",
            label: "货主名称",
            value: "",
          },
        ],
      },
      tableConfig: {
        columns: [
          {
            dataIndex: "companyCode",
            title: "货主编码",
          },
          {
            dataIndex: "companyName",
            title: "货主名称",
          },
        ],
      },
      on: {
        ok(event, value, rowData, form) {
          console.log(form);
          if (form) {
            form.setFieldsValue({
              consignorName: rowData[0].companyName,
              consignorCode: rowData[0].companyCode,
              consignorId: rowData[0].companyId,
            });
          }
        },
        change(event, value, rowData, form) {
          if (!value) {
            form.setFieldsValue({
              consignorId: "",
              consignorCode: "",
            });
          }
        },
      },
    },
    {
      type: "input",
      name: "printBillCode",
      label: "单据编号",
      value: "",
      ...grid,
    },
    {
      type: "input",
      name: "printBillName",
      label: "单据名称",
      value: "",
      ...grid,
    },
    {
      type: "select",
      name: "tempType",
      label: "模板类型:",
      placeholder: "请选择模板类型",
      remoteUrl: { url: upcloud_base_common + "/dict/listbytype?dicttypeCodes=report_template", method: "post" },
      replaceFields: {
        value: "dictCode",
        label: "dictName",
      },
      ...grid,
    },
    // {
    //   type: 'select',
    //   name: 'tempType',
    //   label: '模板类型:',
    //   placeholder: '请选择模板类型',
    //   remoteUrl: { url: upcloud_base_common+'/dict/listbytype?dicttypeCodes=report_template', method: 'post' },
    //   replaceFields: {
    //     value: 'dictCode',
    //     label: 'dictName'
    //   },
    //   ...grid
    // },
    {
      type: "buttonGroup",
      style: { textAlign: "left" },
      ...grid,
      options: [
        {
          value: "查询",
          icon: "search",
          btnType: "primary",
          // style: 'margin-left:10px',
          htmlType: "submit",
        },
        {
          value: "重置",
          icon: "redo",
          style: "margin-left:10px",
          on: {
            click: () => {
              self.$refs.formTarget.form.resetFields();
            },
          },
        },
      ],
    },
  ];
}

export function detailFormItems(self) {
  let _this = self;
  return [
    {
      type: "input",
      hidden: true,
      name: "tempid",
      label: "tempid",
      value: "",
      ...grid1,
    },
    {
      type: "input",
      hidden: true,
      name: "strategyId",
      label: "strategyId",
      value: "",
      ...grid1,
    },
    {
      type: "input",
      hidden: true,
      name: "temppathid",
      label: "temppathid",
      value: "",
      ...grid1,
    },
    {
      type: "input",
      name: "consignorId",
      label: "consignorId",
      value: "",
      hidden: true,
      ...grid1,
    },
    {
      type: "input",
      name: "consignorCode",
      label: "consignorCode",
      value: "",
      hidden: true,
      ...grid1,
    },
    {
      type: "input",
      name: "warehouseId",
      label: "warehouseId",
      value: "",
      hidden: true,
      ...grid1,
    },
    {
      type: "input",
      name: "warehouseCode",
      label: "warehouseCode",
      value: "",
      hidden: true,
      ...grid1,
    },
    {
      type: "input",
      hidden: false,
      name: "printBillCode",
      // disabled: true,
      required: true,
      label: "单据编号",
      value: "",
      ...grid1,
    },
    {
      type: "input",
      hidden: false,
      name: "printBillName",
      required: true,
      // disabled: true,
      label: "单据名称",
      value: "",
      ...grid1,
    },
    // ...genWarehouseAuthSearchModal(1, true, false, null, null, grid1),
    {
      label: "仓库名称",
      type: "searchModal",
      targetClick: true,
      disabled: false,
      ...grid1,
      name: "warehouseName",
      remoteUrl: { url: "/api/service-ctrl-tower-wms/userDataAuth/allDataAuthByUser/?companyType=S", method: "get" },
      rowKey: "companyId",
      targetValueKey: "companyName",
      toolBar: {
        items: [
          {
            type: "input",
            name: "companyName",
            label: "仓库名称",
            value: "",
          },
          {
            type: "input",
            name: "companyCode",
            label: "仓库编码",
            value: "",
          },
        ],
      },
      tableConfig: {
        columns: [
          {
            dataIndex: "companyName",
            title: "仓库名称",
          },
          {
            dataIndex: "companyCode",
            title: "仓库编码",
          },
        ],
      },
      on: {
        ok(event, value, rowData, form) {
          console.log(form);
          if (form) {
            form.setFieldsValue({
              warehouseId: rowData[0].companyId,
              warehouseCode: rowData[0].companyCode,
            });
          }
        },
        change(event, value, rowData, form) {
          if (!value) {
            form.setFieldsValue({
              warehouseId: "",
              warehouseCode: "",
            });
          }
        },
      },
    },
    {
      label: "货主名称",
      type: "searchModal",
      targetClick: true,
      disabled: false,
      ...grid1,
      name: "consignorName",
      remoteUrl: { url: "/api/service-ctrl-tower-wms/userDataAuth/allDataAuthByUser/?companyType=H", method: "get" },
      rowKey: "companyId",
      targetValueKey: "companyName",
      toolBar: {
        items: [
          {
            type: "input",
            name: "companyCode",
            label: "货主编码",
            value: "",
          },
          {
            type: "input",
            name: "companyName",
            label: "货主名称",
            value: "",
          },
        ],
      },
      tableConfig: {
        columns: [
          {
            dataIndex: "companyCode",
            title: "货主编码",
          },
          {
            dataIndex: "companyName",
            title: "货主名称",
          },
        ],
      },
      on: {
        ok(event, value, rowData, form) {
          console.log(form);
          if (form) {
            form.setFieldsValue({
              consignorName: rowData[0].companyName,
              consignorCode: rowData[0].companyCode,
              consignorId: rowData[0].companyId,
            });
          }
        },
        change(event, value, rowData, form) {
          if (!value) {
            form.setFieldsValue({
              cargoOwnerId: "",
              cargoOwnerCode: "",
            });
          }
        },
      },
    },
    {
      type: "input",
      hidden: false,
      name: "shipvendorCode",
      // required:true,
      label: "物流商编号",
      value: "",
      ...grid1,
    },

    {
      type: "input",
      hidden: false,
      name: "printAddress",
      required: true,
      label: "打印服务地址",
      value: "",
      ...grid1,
    },

    {
      type: "select",
      name: "tempType",
      label: "模板类型:",
      autoLoad: true,
      placeholder: "请选择模板类型",
      required: false,
      remoteUrl: { url: upcloud_base_common + "/dict/listbytype?dicttypeCodes=report_template", method: "post" },
      replaceFields: {
        value: "dictCode",
        label: "dictName",
      },
      ...grid1,
    },
    {
      type: "radio",
      hidden: false,
      name: "status",
      label: "是否启用",
      required: true,
      ...grid1,
      value: 1,
      options: [
        {
          label: "是",
          value: 1,
        },
        {
          label: "否",
          value: 0,
        },
      ],
    },
    {
      type: "input",
      name: "tempName",
      label: "模板文件名",
      // disabled: true,
      required: true,
      value: "",
      ...grid1,
    },
    {
      type: "input",
      name: "tempPath",
      label: "模板路径",
      disabled: true,
      value: "",
      required: true,
      ...grid1,
    },
    {
      type: "number",
      name: "tempVersion",
      label: "模板版本",
      value: "",
      required: true,
      ...grid1,
    },
    {
      type: "input",
      name: "dbKey",
      label: "模板版本",
      value: "",
      hidden: true,
      ...grid1,
    },
    {
      label: "数据源",
      type: "searchModal",
      targetClick: true,
      required: true,
      disabled: false,
      ...grid1,
      name: "dsName",
      remoteUrl: { url: upcloud_base_common + "/datasource/v1/page", method: "get" },
      rowKey: "id",
      targetValueKey: "dsName",
      toolBar: {
        items: [
          {
            type: "input",
            name: "dsName",
            label: "数据源",
            value: "",
          },
        ],
      },
      tableConfig: {
        columns: [
          {
            dataIndex: "dsName",
            title: "数据源名称",
          },
        ],
      },
      on: {
        // ok(event, value, rowData, form) {
        //   console.log(form)
        //   if (form) {
        //     form.setFieldsValue({
        //       dbKey: rowData[0].id,
        //     })
        //   }
        // },
        change(event, value, rowData, form) {
          if (!value) {
            form.setFieldsValue({
              dbKey: "",
            });
          } else {
            form.setFieldsValue({
              dbKey: rowData[0].id,
            });
          }
        },
      },
    },
    {
      type: "radio",
      name: "underlineToCamel",
      label: "是否驼峰",
      options: [
        { label: "是", value: "1" },
        { label: "否", value: "0" },
      ],
      disabled: false,
      value: "1",
      required: true,
      ...grid1,
    },
    {
      type: "textarea",
      hidden: false,
      name: "remark",
      label: "备注",
      value: "",
      ...grid1,
    },
  ];
}
export function detailFormItems2(self) {
  let _this = self;
  return [
    {
      type: "select",
      name: "printStrategy",
      label: "打印策略",
      options: [
        { label: "默认打印机", value: "0" },
        { label: "指定打印方案", value: "1" },
        { label: "指定打印机名称", value: "2" },
        { label: "根据人员指定方案", value: "3" },
        { label: "根据人员指定打印机", value: "4" },
      ],
      disabled: false,
      required: true,
      value: "",
      on: {
        change(value, label, rowData, form) {
          console.log(rowData);
          console.log(form.getFieldsValue());
          self.printStrategy = value;
          self.remoteParams1.printStrategy = value;
          if (value == "1") {
            form.visibleItem(["printSolution"]);
            form.invisibleItem(["printName"]);
          } else if (value == "2") {
            form.visibleItem(["printName"]);
            form.invisibleItem(["printSolution"]);
          } else if (value == "3" || value == "4" || value == "0") {
            form.invisibleItem(["printSolution", "printName"]);
          }
        },
      },
      ...grid1,
    },
    {
      type: "input",
      name: "printSolution",
      label: "指定方案",
      disabled: false,
      value: "",
      required: false,
      ...grid1,
    },
    {
      type: "input",
      name: "printName",
      label: "指定打印机",
      disabled: false,
      value: "",
      required: false,
      ...grid1,
    },
    {
      type: "select",
      name: "preview",
      label: "是否预览",
      options: [
        { label: "是", value: "1" },
        { label: "否", value: "0" },
      ],
      disabled: false,
      value: "",
      required: true,
      ...grid1,
    },
    {
      type: "number",
      name: "count",
      label: "打印次数",
      disabled: false,
      value: "",
      required: true,
      ...grid1,
    },
    {
      type: "select",
      name: "shipvendorName",
      label: "模板数据",
      disabled: false,
      value: "",
      options: [
        {
          label: "GRF模板",
          value: "GRF",
        },
        {
          label: "PDF模板",
          value: "PDF",
        },
        {
          label: "DATA模板",
          value: "DATA",
        },
      ],
      ...grid1,
    },
    {
      type: 'number',
      name: 'shipvendorId',
      label: '超时时间',
      value: '',
      min:0,
      precision:0,
      ...grid1
    },
  ];
}

export function detailFormItems3(self) {
  let _this = self;
  return [
    {
      type: "input",
      name: "username",
      label: "员工用户名",
      disabled: false,
      value: "",
      required: true,
      ...grid1,
    },
    {
      type: "input",
      name: "printSolution",
      label: "打印方案",
      disabled: false,
      value: "",
      required: true,
      ...grid1,
    },
    {
      type: "input",
      name: "consignorName",
      label: "打印服务地址",
      disabled: false,
      value: "",
      required: true,
      ...grid1,
    },
  ];
}

export const tableColumnsConfig = [
  {
    title: "tempid",
    hidden: true,
    dataIndex: "tempid",
  },
  {
    title: "单据编号",
    width: 100,
    hidden: false,
    dataIndex: "printBillCode",
    className: "v_top",
  },
  {
    title: "单据名称",
    width: 100,
    hidden: false,
    dataIndex: "printBillName",
    className: "v_top",
  },
  {
    title: "仓库编号",
    width: 100,
    hidden: false,
    dataIndex: "warehouseCode",
    className: "v_top",
  },
  {
    title: "物流商编号",
    dataIndex: "shipvendorCode",
    width: 100,
    className: "v_top",
  },
  {
    title: "模板",
    width: 180,
    hidden: true,
    dataIndex: "tempName",
    className: "v_top",
  },
  {
    title: "模板路径",
    width: 180,
    dataIndex: "tempPath",
    className: "v_top",
  },
  // {
  //   title: '模板类型',
  //   width: 180,
  //   hidden: false,
  //   dataIndex: 'temptype',
  //   remoteUrl: { url: upcloud_base_common+'/dict/listbytype?dicttypeCodes=report_template', method: 'post' },
  //   replaceFields: {
  //     value: 'dictCode',
  //     label: 'dictName'
  //   },
  //   className: 'v_top'
  // },
  // {
  //   title: '模板类型',
  //   width: 180,
  //   hidden: false,
  //   dataIndex: 'tempType',
  //   className: 'v_top'
  // },
  {
    title: "模板版本",
    width: 80,
    hidden: false,
    dataIndex: "tempVersion",
    className: "v_top",
  },
  {
    title: "数据源",
    // width: 100,
    dataIndex: "dbKey",
    className: "v_top",
  },
  {
    title: "打印服务",
    // width: 100,
    dataIndex: "printAddress",
    className: "v_top",
  },
  {
    title: "打印策略",
    dataIndex: "printStrategy",
    className: "v_top",
    customRender: (text) => {
      let obj = { 0: "默认打印机", 1: "指定打印方案", 2: "指定打印机名称", 3: "根据人员指定方案", 4: "根据人员指定打印机" };
      return obj[text];
    },
  },
  {
    dataIndex: "status",
    title: "是否启用",
    width: 100,
    scopedSlots: { customRender: "status" },
  },

  {
    title: "操作",
    key: "operate",
    align: "center",
    fixed: "right",
    width: 240,
    scopedSlots: { customRender: "action" },
  },
];

export const tableColumnsConfig1 = [
  {
    title: "员工用户名",
    width: 100,
    hidden: false,
    dataIndex: "username",
    className: "v_top",
  },

  {
    title: "打印方案",
    hidden: false,
    dataIndex: "printSolution",
    className: "v_top",
  },
  {
    title: "打印服务地址",
    hidden: false,
    dataIndex: "consignorName",
    className: "v_top",
  },
  {
    title: "操作",
    key: "operate",
    align: "center",
    fixed: "right",
    width: 150,
    scopedSlots: { customRender: "action" },
  },
];
export const tableColumnsConfig2 = [
  {
    title: "员工用户名",
    width: 100,
    hidden: false,
    dataIndex: "username",
    className: "v_top",
  },

  {
    title: "打印机名称",
    hidden: false,
    dataIndex: "printSolution",
    className: "v_top",
  },
  {
    title: "打印服务地址",
    hidden: false,
    dataIndex: "consignorName",
    className: "v_top",
  },
  {
    title: "操作",
    key: "operate",
    align: "center",
    fixed: "right",
    width: 150,
    scopedSlots: { customRender: "action" },
  },
];

export const logColumnsConfig = [
  {
    title: '请求时间',
    hidden: false,
    dataIndex: 'gmtCreate',
    ellipsis: true,
    className: 'v_top'
  },
  {
    title: '状态',
    width: 100,
    hidden: false,
    dataIndex: 'status',
    ellipsis: true,
    className: 'v_top',
    scopedSlots: { customRender: "CustomStatus" },
  },
  {
    title: '请求参数',
    hidden: false,
    dataIndex: 'param',
    ellipsis: true,
    className: 'v_top'
  },
  {
    title: '请求接口路径',
    hidden: false,
    dataIndex: 'path',
    ellipsis: true,
    className: 'v_top'
  },
  {
    title: '打印服务地址',
    hidden: false,
    dataIndex: 'printAdress',
    ellipsis: true,
    className: 'v_top'
  },
  {
    title: '打印服务参数',
    hidden: false,
    dataIndex: 'printParam',
    ellipsis: true,
    className: 'v_top'
  }
]
