import moment from "moment";
import { upcloud_base_gsp, SERVICE_DATA_API_BASE } from "@/config/serviceSettings";

import {
  genItemSearchModal,
  genWarehouseSearchModal,
  genWarehouseAuthSearchModal,
  genBldgSearchModal,
  genCargoownerAuthSearchModal,
  genWarehouseLocatorSearchModal,
  genItemSearchModalcuring,
} from "@/views/kzyWMS/SearchModal";
import qs from "qs";
import store from "@/store";
import { changecargoOwnerfun } from "@/views/kzyWMS/utils/setCargoOwner";

const baseUrl = upcloud_base_gsp;
let dcId = null;
let warehouseId = store.state.user.warehouse.warehouseId || null;
let bldgId = null;
let warehouseRoomId = null;
let warehouseAreaId = null;
let warehouseLogicId = null;
let cargoOwnerId = null;
let itemId = null;
let itemCategoryCode = null;

import { api } from "@/views/kzyWMS/api/common/dictionaries-type";
import { sorter } from "../../../../utils/sort";
import { axios } from "@/utils/request";
import { upcloud_base_common } from '@/config/serviceSettings'

export function getList() {
  return axios.get(
    upcloud_base_common+'/dict/basic/type-list?typeCode=gsp_measure',
  )
}

export let itemHealthCategory = {
  type: "select",
  name: "itemHealthCategory",
  label: "商品大类",
  value: "",
  autoLoad: true,
  remoteUrl: { url: api.queryDictList + "?dicttypeCodes=item_health_category", method: "post" },
  replaceFields: {
    value: "dictCode",
    label: "dictName",
  },
};

export const tableColumns = function (that) {
  let optionsList = {
    options: [
      { label: "待处理", value: "0" },
      { label: "合格", value: "1" },
      //   { label: "不合格", value: "2" },
    ],
  };
  return {
    gridform: {
      ref: "form",
      items: [
        // 仓库
        ...genWarehouseAuthSearchModal(
          1,
          true,
          false,
          null,
          function (rowData, form) {
            form.setFieldsValue({
              cargoOwnerCode: null,
              cargoOwnerId: null,
              cargoOwnerName: null,
            });
            console.log(rowData);
            if (!rowData) {
              warehouseId = null;
            } else {
              warehouseId = rowData[0].companyId;
            }
          },
          {
            span: 6,
            labelCol: { span: 6 },
            wrapperCol: { span: 14 },
          }
        ),
        //货主
        ...genCargoownerAuthSearchModal(
          1,
          false,
          false,
          null,
          function (rowData, form) {
            console.log(rowData);
            if (!rowData) {
              cargoOwnerId = null;
            } else {
              cargoOwnerId = rowData[0].companyId;
            }
          },
          {
            span: 6,
            labelCol: { span: 6 },
            wrapperCol: { span: 14 },
          }
        ),
        //商品大类
        { ...itemHealthCategory, span: 6 },

        ...genWarehouseLocatorSearchModal(
          1,
          false,
          false,
          function (res, p) {
            console.log(warehouseId);
            p.params.warehouseId = warehouseId;
            p.params.cargoOwnerId = cargoOwnerId;
            return p;
          },
          null,
          {
            span: 6,
            labelCol: { span: 6 },
            wrapperCol: { span: 14 },
          }
        ),

        {
          type: "date",
          name: "startTime",
          label: "开始日期",
          format: "YYYY-MM-DD",
          span: 6,
          value: moment().startOf("month").format("YYYY-MM-DD"),
        },
        {
          type: "date",
          name: "endTime",
          format: "YYYY-MM-DD",
          label: "结束日期",
          span: 6,
          value: moment().locale("zh-cn").format("YYYY-MM-DD"),
        },
        ...genBldgSearchModal(
          1,
          false,
          false,
          function (res, p) {
            console.log(warehouseId);
            p.params.warehouseId = warehouseId;
            return p;
          },
          function (value, form) {
            if (!value) {
              bldgId = null;
            } else {
              bldgId = value[0].bldgId;
            }
          },
          {
            span: 6,
            labelCol: { span: 6 },
            wrapperCol: { span: 14 },
          },
          {
            search(p1, p2, p3, p4, p5) {
              warehouseId = p5.warehouseId;
              cargoOwnerId = p5.mtlOwnerId;
              itemId = p5.itemId;
              itemCategoryCode = p5.categoryId;
            },
          }
        ),
        //商品
        ...genItemSearchModalcuring(
          1,
          false,
          false,
          function (res, p) {
            p.data.cargoOwnerId = cargoOwnerId;
            p.data.warehouseId = warehouseId;
            console.log(p, "====");
            return p;
          },
          null,
          { span: 6, labelCol: { span: 6 }, wrapperCol: { span: 14 } }
        ),
        {
          span: 6,
          type: "buttonGroup",
          style: { textAlign: "left" },
          options: [
            {
              value: "查询",
              icon: "search",
              btnType: "primary",
              style: "margin-right:10px;margin-left:30px;",
              on: {
                click(event, form) {
                  that.showModal();
                },
              },
            },
            {
              value: "重置",
              name: "ccz",
              icon: "redo",
              on: {
                click(event, form) {
                  form.resetFields();
                },
              },
            },
          ],
        },
      ],
    },
    search: {
      columns: [
        {
          title: "单据编号",
          dataIndex: "code",
        },
        {
          title: "日期",
          dataIndex: "gmtCreate",
        },
        {
          title: "类别",
          dataIndex: "source",
        },
        {
          title: "单据ID",
          dataIndex: "id",
          hidden: true,
        },
      ],
    },
    //主表
    MainTable: {
      scroll: { x: 2500 },
      edit: true,
      title: "不合格品单",
      remoteUrl: {
        url: baseUrl + "/gspUpkeepCheck/findByPlanId",
        method: "get",
      },
      doneBefore(res) {
        console.log(res);
        res.data.list.forEach((item) => {
          item.upkeepConclusion = "1";
          if (item.upkeepQty) {
            item.upkeepQty1 = item.upkeepQty;
          }
        });
        return res;
      },
      ref: "MainTable",
      rowkey: "id",
      columns: sorter([
        {
          title: "养护计划日期",
          dataIndex: "planUpkeepDate",
          type: "txt",
          width: 150,
          format: "YYYY-MM-DD",
          customRender(text) {
            if (text) {
              return moment(text).format("YYYY-MM-DD");
            }
          },
          key: "planUpkeepDate",
          scopedSlots: { customRender: "planUpkeepDate" },
        },
        {
          ...genWarehouseAuthSearchModal(2, true, false, null, changecargoOwnerfun, {}),
          width: 150,
        },
        {
          ...genBldgSearchModal(
            2,
            true,
            false,
            function (res, p) {
              p.params.warehouseId = warehouseId;
              return p;
            },
            function (rowData, index) {
              bldgId = rowData[0].bldgId;
            },
            {}
          ),
          width: 150,
        },
        {
          ...genCargoownerAuthSearchModal(
            2,
            true,
            false,
            null,
            function (rowData, form) {
              console.log(rowData);
              if (!rowData) {
                cargoOwnerId = null;
              } else {
                cargoOwnerId = rowData[0].companyId;
              }
            },
            {
              span: 6,
              labelCol: { span: 6 },
              wrapperCol: { span: 14 },
            }
          ),
          width: 150,
        },
        {
          title: "库别",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "warehouseAreaCode",
          type: "txt",
        },
        {
          title: "托盘号",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "containerCode",
          type: "txt",
        },
        //实际货位
        {
          ...genWarehouseLocatorSearchModal(
            2,
            true,
            false,
            function (res, p) {
              p.params.warehouseId = warehouseId;
              p.params.cargoOwnerId = cargoOwnerId;
              p.params.itemId = itemId;
              p.params.itemCategoryCode = itemCategoryCode;
              console.log(p);
              return p;
            },
            function (value, index) {
              if (!value) {
                console.log(value, "value");
                warehouseId = null;
                cargoOwnerId = null;
                itemId = null;
                itemCategoryCode = null;
              }
            },
            {
              span: 6,
              labelCol: { span: 6 },
              wrapperCol: { span: 14 },
            }
          ),
          width: 100,
          title: "实际货位",
        },
        {
          title: "库别",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "warehouseAreaCategory",
          type: "txt",
        },

        {
          title: "计划养护数量",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "planStockQty",
          type: "txt",
        },
        {
          title: "库存数量",
          dataIndex: "stockQty",
          scopedSlots: { customRender: "stockQty" },
          align: "center",
          width: 100,
          type: "txt",
        },
        {
          title: "实际养护数量",
          ellipsis: true,
          align: "center",
          width: 100,
          scopedSlots: { customRender: "upkeepQty" },
          dataIndex: "upkeepQty",
          type: "number",
        },
        {
          title: "商品编码",
          dataIndex: "itemCode",
          width: 100,
          type: "txt",
        },
        {
          ...genItemSearchModalcuring(
            2,
            false,
            false,
            function (res, p) {
              p.data.cargoOwnerId = cargoOwnerId;
              p.data.warehouseId = warehouseId;
              console.log(p, "====");
              return p;
            },
            null,
            { span: 6, labelCol: { span: 6 }, wrapperCol: { span: 14 } }
          ),
          ellipsis: true,
          width: 100,
        },
        {
          title: "批号",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "lotNum",
          type: "edit",
        },
        // {
        //   title: "托盘",
        //   align: "center",
        //   dataIndex: "containerCode",
        //   width: 100,
        //   ellipsis: true,
        // },
        {
          title: "生产日期",
          width: 100,
          dataIndex: "pdateFrom",
          type: "date",
          format: "YYYY-MM-DD",
        },
        {
          title: "有效期至",
          width: 100,
          dataIndex: "validUntil",
          type: "date",
          format: "YYYY-MM-DD",
        },
        {
          title: "养护结论",
          dataIndex: "upkeepConclusion",
          width: 100,
          required: true,
          type: "select",
          ...optionsList,
        },
        {
          title: "养护待处理数量",
          dataIndex: "pendingQty",
          width: 100,
          type: "number",
        },
        {
          title: "养护待处理原因",
          dataIndex: "pendingReason",
          width: 100,
          type: "edit",
        },
        {
          title: "外观",
          dataIndex: "checkWaiGuan",
          type: "edit",
          width: 50,
          align: "center",
          slots: { title: "checkWaiGuanTitle" },
          scopedSlots: { customRender: "checkWaiGuan" },
        },
        {
          title: "包装",
          dataIndex: "checkBaoZhuang",
          type: "edit",
          width: 50,
          align: "center",
          slots: { title: "checkBaoZhuangTitle" },
          scopedSlots: { customRender: "checkBaoZhuang" },
        },
        {
          title: "存储条件",
          dataIndex: "checkChenChuTiaoJian",
          type: "edit",
          width: 80,
          align: "center",
          slots: { title: "checkChenChuTiaoJianTitle" },
          scopedSlots: { customRender: "checkcheckChenChuTiaoJianFanDuo" },
        },
        {
          title: "翻跺",
          dataIndex: "checkFanDuo",
          width: 50,
          align: "center",
          slots: { title: "checkFanDuoTitle" },
          scopedSlots: { customRender: "checkFanDuo" },
        },
        {
          title: "除湿",
          dataIndex: "checkChuShi",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChuShiTitle" },
          scopedSlots: { customRender: "checkChuShi" },
        },
        {
          title: "加湿",
          dataIndex: "checkJiaShi",
          width: 50,
          align: "center",
          type: "switch",
          slots: { title: "checkJiaShiTitle" },
          scopedSlots: { customRender: "checkJiaShi" },
        },
        {
          title: "升温",
          dataIndex: "checkShenWen",
          width: 50,
          align: "center",
          type: "switch",
          slots: { title: "checkShenWenTitle" },
          scopedSlots: { customRender: "checkShenWen" },
        },
        {
          title: "降温",
          dataIndex: "checkJiangWen",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkJiangWenTitle" },
          scopedSlots: { customRender: "checkJiangWen" },
        },
        {
          title: "通风",
          dataIndex: "checkTongFeng",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkTongFengTitle" },
          scopedSlots: { customRender: "checkTongFeng" },
        },
        {
          title: "除尘",
          dataIndex: "checkChuChen",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChuChenTitle" },
          scopedSlots: { customRender: "checkChuChen" },
        },
        {
          title: "虫蛀",
          dataIndex: "checkChongZhu",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChongZhuTitle" },
          scopedSlots: { customRender: "checkChongZhu" },
        },
        {
          title: "发霉",
          dataIndex: "checkFaMei",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkFaMeiTitle" },
          scopedSlots: { customRender: "checkFaMei" },
        },
        // {
        //   title: "泛油",
        //   dataIndex: "checkFanYou",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkFanYouTitle" },
        //   scopedSlots: { customRender: "checkFanYou" },
        // },
        {
          title: "防潮",
          dataIndex: "checkChaoJie",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChaoJieTitle" },
          scopedSlots: { customRender: "checkChaoJie" },
        },
        {
          title: "避光",
          dataIndex: "checkBiGuang",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkBiGuangTitle" },
          scopedSlots: { customRender: "checkBiGuang" },
        },
        {
          title: "遮光",
          dataIndex: "checkZheGuang",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkZheGuangTitle" },
          scopedSlots: { customRender: "checkZheGuang" },
        },
        // {
        //   title: "变色",
        //   dataIndex: "checkBianSe",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkBianSeTitle" },
        //   scopedSlots: { customRender: "checkBianSe" },
        // },
        // {
        //   title: "上斗",
        //   dataIndex: "checkShangDou",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkShangDouTitle" },
        //   scopedSlots: { customRender: "checkShangDou" },
        // },
        // {
        //   title: "破损",
        //   dataIndex: "checkPoSun",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkPoSunTitle" },
        //   scopedSlots: { customRender: "checkPoSun" },
        // },
        {
          title: "库区",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "warehouseAreaName",
          type: "txt",
        },
        {
          title: "存储条件",
          dataIndex: "storeTemperature",
          width: 100,
          type: "txt",
        },
        {
          title: "备注",
          dataIndex: "remark",
          width: 100,
          type: "edit",
          key: "remark",
        },
        {
          title: "质量状况",
          dataIndex: "qualityStatus",
          width: 100,
          type: "edit",
          key: "qualityStatus",
          customRender(text) {
            if (text == "1") return "合格";
            if (text == "2") return "不合格";
            if (text == "3") return "待检";
            if (text == "4") return "退货";
            return text;
          },
        },
        {
          title: "商品大类",
          width: 100,
          dataIndex: "itemHealthCategoryName",
          type: "txt",
        },
        {
          title: "商品规格",
          ellipsis: true,
          width: 100,
          dataIndex: "specification",
        },
        {
          title: "生产厂家",
          dataIndex: "manufacturerName",
          width: 100,
          ellipsis: true,
          type: "edit",
        },
        {
          title: "产地",
          width: 150,
          ellipsis: true,
          dataIndex: "countryOriginName",
        },
        {
          title: "包装数量",
          width: 150,
          ellipsis: true,
          dataIndex: "caseConversionRate",
        },
        {
          title: "包装单位",
          width: 150,
          ellipsis: true,
          dataIndex: "caseUom",
        },
        {
          title: "批准文号",
          dataIndex: "itemHealthApprovalNbr",
          width: 100,
          type: "txt",
        },
        {
          title: "上市许可持有人",
          ellipsis: true,
          width: 150,
          dataIndex: "itemHealthListedLicensor",
        },
        {
          title: "注册证号",
          ellipsis: true,
          width: 150,
          dataIndex: "itemHealthRegisterNbr",
        },
      ]),
      columns1: [
        {
          title: "养护计划日期",
          dataIndex: "planUpkeepDate",
          type: "txt",
          width: 150,
          format: "YYYY-MM-DD",
          scopedSlots: { customRender: "planUpkeepDate" },
          align: "center",
        },
        {
          ...genWarehouseAuthSearchModal(
            2,
            true,
            false,
            null,
            function (modalRowData, index, value, record) {
              //   record.warehouseName = modalRowData[0].companyName
              console.log(modalRowData);
              if (modalRowData.length > 0) {
                record.warehouseId = modalRowData[0].companyId;
                record.warehouseCode = modalRowData[0].companyCode;
                record.dcId = modalRowData[0].dcId;
              } else {
                record.warehouseId = null;
                record.warehouseCode = null;
                record.dcId = null;
              }
            },
            {}
          ),
          targetValueKey: "companyName",
          width: 150,
        },
        {
          ...genBldgSearchModal(
            2,
            true,
            false,
            function (res, p) {
              console.log(warehouseId);
              p.params.warehouseId = warehouseId;
              return p;
            },
            function (rowData, form) {
              bldgId = rowData[0].bldgId;
            },
            {
              span: 6,
              labelCol: { span: 6 },
              wrapperCol: { span: 14 },
            }
          ),
          width: 150,
        },
        {
          ...genCargoownerAuthSearchModal(
            2,
            true,
            false,
            null,
            function (rowData, form) {
              console.log(rowData);
              if (!rowData) {
                cargoOwnerId = null;
              } else {
                cargoOwnerId = rowData[0].companyId;
              }
            },
            {
              span: 6,
              labelCol: { span: 6 },
              wrapperCol: { span: 14 },
            }
          ),
          targetValueKey: "companyName",
          width: 150,
        },
        //实际货位
        {
          ...genWarehouseLocatorSearchModal(
            2,
            true,
            false,
            function (res, p) {
              p.params.warehouseId = warehouseId;
              p.params.cargoOwnerId = cargoOwnerId;
              p.params.itemId = itemId;
              p.params.itemCategoryCode = itemCategoryCode;
              console.log(p);
              return p;
            },
            function (value, index) {
              console.log(value, "value");
              if (!value) {
                warehouseId = null;
                cargoOwnerId = null;
                itemId = null;
                itemCategoryCode = null;
              }
            },
            {
              span: 6,
              labelCol: { span: 6 },
              wrapperCol: { span: 14 },
            }
          ),
          width: 100,
          title: "实际货位",
        },
        {
          title: "库别",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "warehouseAreaCategory",
          type: "txt",
        },

        {
          title: "计划养护数量",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "planStockQty",
          type: "txt",
          key: "planStockQty",
          on: {
            change(data) {},
          },
        },
        {
          title: "库存数量",
          dataIndex: "stockQty",
          scopedSlots: { customRender: "stockQty" },
          align: "center",
          width: 80,
          type: "txt",
          key: "stockQty",
        },
        {
          title: "实际养护数量",
          ellipsis: true,
          dataIndex: "upkeepQty",
          align: "center",
          width: 100,
          type: "number",
          scopedSlots: { customRender: "upkeepQty1" },
          key: "upkeepQty",
        },
        {
          title: "商品编号",
          dataIndex: "itemCode",
          width: 100,
          type: "txt",
          ellipsis: true,
        },
        {
          ...genItemSearchModalcuring(
            2,
            false,
            false,
            function (res, p) {
              p.data.cargoOwnerId = cargoOwnerId;
              p.data.warehouseId = warehouseId;
              console.log(p, "====");
              return p;
            },
            function (value, index) {
              console.log(value, "value", arguments);
              arguments[3].itemCode = value[0].itemCode;
            },
            { span: 6, labelCol: { span: 6 }, wrapperCol: { span: 14 } }
          ),
          ellipsis: true,
          width: 100,
        },
        {
          title: "批号",
          ellipsis: true,
          dataIndex: "lotNum",
          align: "center",
          width: 100,
          type: "edit",
          key: "lotNum",
        },
        {
          title: "托盘",
          align: "center",
          dataIndex: "containerCode",
          width: 100,
          ellipsis: true,
        },
        {
          title: "生产日期",
          dataIndex: "pdateFrom",
          type: "date",
          width: 100,
          format: "YYYY-MM-DD",
        },
        {
          title: "有效期至",
          dataIndex: "validUntil",
          width: 100,
          type: "date",
          format: "YYYY-MM-DD",
        },
        {
          title: "养护结论",
          dataIndex: "upkeepConclusion",
          width: 100,
          required: true,
          type: "select",
          ...optionsList,
        },
        {
          title: "养护待处理数量",
          dataIndex: "pendingQty",
          width: 100,
          type: "number",
        },
        {
          title: "养护待处理原因",
          dataIndex: "pendingReason",
          width: 100,
          type: "edit",
        },
        {
          title: "外观",
          dataIndex: "checkWaiGuan",
          type: "edit",
          width: 50,
          align: "center",
          slots: { title: "checkWaiGuanTitle" },
          scopedSlots: { customRender: "checkWaiGuan" },
        },
        {
          title: "包装",
          dataIndex: "checkBaoZhuang",
          type: "edit",
          width: 50,
          align: "center",
          slots: { title: "checkBaoZhuangTitle" },
          scopedSlots: { customRender: "checkBaoZhuang" },
        },
        {
          title: "存储条件",
          dataIndex: "checkChenChuTiaoJian",
          type: "edit",
          width: 80,
          align: "center",
          slots: { title: "checkChenChuTiaoJianTitle" },
          scopedSlots: { customRender: "checkcheckChenChuTiaoJianFanDuo" },
        },
        {
          title: "翻跺",
          dataIndex: "checkFanDuo",
          width: 50,
          align: "center",
          slots: { title: "checkFanDuoTitle" },
          scopedSlots: { customRender: "checkFanDuo" },
        },
        {
          title: "除湿",
          dataIndex: "checkChuShi",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChuShiTitle" },
          scopedSlots: { customRender: "checkChuShi" },
        },
        {
          title: "加湿",
          dataIndex: "checkJiaShi",
          width: 50,
          align: "center",
          type: "switch",
          slots: { title: "checkJiaShiTitle" },
          scopedSlots: { customRender: "checkJiaShi" },
        },
        {
          title: "升温",
          dataIndex: "checkShenWen",
          width: 50,
          align: "center",
          type: "switch",
          slots: { title: "checkShenWenTitle" },
          scopedSlots: { customRender: "checkShenWen" },
        },
        {
          title: "降温",
          dataIndex: "checkJiangWen",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkJiangWenTitle" },
          scopedSlots: { customRender: "checkJiangWen" },
        },
        {
          title: "通风",
          dataIndex: "checkTongFeng",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkTongFengTitle" },
          scopedSlots: { customRender: "checkTongFeng" },
        },
        {
          title: "除尘",
          dataIndex: "checkChuChen",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChuChenTitle" },
          scopedSlots: { customRender: "checkChuChen" },
        },
        {
          title: "虫蛀",
          dataIndex: "checkChongZhu",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChongZhuTitle" },
          scopedSlots: { customRender: "checkChongZhu" },
        },
        {
          title: "发霉",
          dataIndex: "checkFaMei",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkFaMeiTitle" },
          scopedSlots: { customRender: "checkFaMei" },
        },
        // {
        //   title: "泛油",
        //   dataIndex: "checkFanYou",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkFanYouTitle" },
        //   scopedSlots: { customRender: "checkFanYou" },
        // },
        {
          title: "防潮",
          dataIndex: "checkChaoJie",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChaoJieTitle" },
          scopedSlots: { customRender: "checkChaoJie" },
        },
        {
          title: "避光",
          dataIndex: "checkBiGuang",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkBiGuangTitle" },
          scopedSlots: { customRender: "checkBiGuang" },
        },
        {
          title: "遮光",
          dataIndex: "checkZheGuang",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkZheGuangTitle" },
          scopedSlots: { customRender: "checkZheGuang" },
        },
        // {
        //   title: "变色",
        //   dataIndex: "checkBianSe",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkBianSeTitle" },
        //   scopedSlots: { customRender: "checkBianSe" },
        // },
        // {
        //   title: "上斗",
        //   dataIndex: "checkShangDou",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkShangDouTitle" },
        //   scopedSlots: { customRender: "checkShangDou" },
        // },
        // {
        //   title: "破损",
        //   dataIndex: "checkPoSun",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkPoSunTitle" },
        //   scopedSlots: { customRender: "checkPoSun" },
        // },
        {
          title: "库区",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "warehouseAreaName",
          type: "txt",
        },
        {
          title: "存储条件",
          dataIndex: "storeTemperature",
          width: 100,
          type: "txt",
        },
        {
          title: "备注",
          dataIndex: "remark",
          width: 100,
          type: "edit",
        },
        {
          title: "质量状况",
          dataIndex: "qualityStatus",
          width: 100,
          type: "edit",
          customRender(text) {
            if (text == "1") return "合格";
            if (text == "2") return "不合格";
            if (text == "3") return "待检";
            if (text == "4") return "退货";
            return text;
          },
        },

        {
          title: "商品大类",
          dataIndex: "itemHealthCategoryName",
          width: 100,
          type: "txt",
        },
        {
          title: "商品规格",
          ellipsis: true,
          width: 100,
          type: "txt",
          dataIndex: "specification",
        },
        {
          title: "生产厂家",
          dataIndex: "manufacturerName",
          ellipsis: true,
          type: "txt",
        },
        {
          title: "产地",
          width: 150,
          type: "txt",
          ellipsis: true,
          dataIndex: "countryOriginName",
        },
        {
          title: "包装数量",
          width: 150,
          type: "txt",
          ellipsis: true,
          dataIndex: "caseConversionRate",
        },
        {
          title: "包装单位",
          width: 150,
          type: "txt",
          ellipsis: true,
          dataIndex: "caseUom",
        },
        {
          title: "批准文号",
          dataIndex: "itemHealthApprovalNbr",
          width: 100,
          type: "txt",
        },
        {
          title: "上市许可持有人",
          ellipsis: true,
          type: "txt",
          width: 150,
          dataIndex: "itemHealthListedLicensor",
        },
        {
          title: "注册证号",
          ellipsis: true,
          type: "txt",
          width: 150,
          dataIndex: "itemHealthRegisterNbr",
        },
      ],
      columns2: [
        {
          title: "养护计划日期",
          dataIndex: "planUpkeepDate",
          type: "txt",
          width: 150,
          customRender(text) {
            if (text) {
              return moment(text).format("YYYY-MM-DD");
            } else return;
          },
          format: "YYYY-MM-DD",
          scopedSlots: { customRender: "planUpkeepDate" },
        },
        {
          dataIndex: "warehouseName",
          title: "仓库名称",
          width: 100,
          type: "txt",
        },
        {
          dataIndex: "bldgName",
          title: "建筑物",
          width: 100,
          type: "txt",
        },
        {
          title: "货主名称",
          type: "txt",
          name: "cargoOwnerName",
          width: 100,
          ellipsis: true,
          dataIndex: "cargoOwnerName",
        },
        {
          title: "实际货位",
          type: "txt",
          width: 100,
          name: "locatorName",
          dataIndex: "locatorName",
        },
        {
          title: "库别",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "warehouseAreaCategory",
          type: "txt",
        },

        {
          title: "计划养护数量",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "planStockQty",
          type: "txt",
        },

        {
          title: "库存数量",
          dataIndex: "stockQty",
          scopedSlots: { customRender: "stockQty" },
          align: "center",
          width: 80,
          type: "txt",
        },
        {
          title: "实际养护数量",
          ellipsis: true,
          dataIndex: "upkeepQty",
          scopedSlots: { customRender: "upkeepQty" },
          align: "center",
          width: 100,
          type: "number",
        },

        {
          title: "商品编号",
          width: 100,
          dataIndex: "itemCode",
          type: "txt",
        },
        {
          width: 100,
          title: "商品名称",
          dataIndex: "itemName",
          ellipsis: true,
          type: "txt",
        },
        {
          title: "批号",
          ellipsis: true,
          width: 100,
          dataIndex: "lotNum",
          align: "center",
          type: "txt",
        },
        {
          title: "托盘",
          align: "center",
          dataIndex: "containerCode",
          width: 100,
          ellipsis: true,
        },
        {
          title: "生产日期",
          dataIndex: "pdateFrom",
          width: 100,
          type: "txt",
          format: "YYYY-MM-DD",
          customRender(text) {
            if (text) {
              return moment(text).format("YYYY-MM-DD");
            }
          },
        },
        {
          title: "有效期至",
          dataIndex: "validUntil",
          width: 100,
          type: "txt",
          format: "YYYY-MM-DD",
          customRender(text) {
            if (text) {
              return moment(text).format("YYYY-MM-DD");
            }
          },
        },
        {
          title: "养护结论",
          dataIndex: "upkeepConclusion",
          width: 100,
          required: true,
          type: "select",
          ...optionsList,
        },
        {
          title: "养护待处理数量",
          dataIndex: "pendingQty",
          width: 100,
          type: "number",
          scopedSlots: { customRender: "pendingQty" },
          //   on: {
          //     change(e) {
          //       console.log(e);
          //   e.value
          //       let value = +e.record.planStockQty - +e.record.upkeepQty;
          //       console.log(value);
          //       if (value - e.value) {
          //         e.record.pendingQty = 0;
          //         e.value = 0;
          //         that.$message.error("养护待处理数量与实际养护数量");
          //       }

          //       //   upkeepQty  实际养护数量
          //       // planStockQty  计划养护
          //     },
          //     blur(e) {
          //       console.log(arguments);
          //     },
          //   },
        },
        {
          title: "养护待处理原因",
          dataIndex: "pendingReason",
          width: 100,
          type: "edit",
        },
        {
          title: "外观",
          dataIndex: "checkWaiGuan",
          type: "edit",
          width: 50,
          slots: { title: "checkWaiGuanTitle" },
          scopedSlots: { customRender: "checkWaiGuan" },
        },
        {
          title: "包装",
          dataIndex: "checkBaoZhuang",
          type: "edit",
          width: 50,
          align: "center",
          slots: { title: "checkBaoZhuangTitle" },
          scopedSlots: { customRender: "checkBaoZhuang" },
        },
        {
          title: "存储条件",
          dataIndex: "checkChenChuTiaoJian",
          type: "edit",
          width: 80,
          align: "center",
          slots: { title: "checkChenChuTiaoJianTitle" },
          scopedSlots: { customRender: "checkcheckChenChuTiaoJianFanDuo" },
        },
        {
          title: "翻跺",
          dataIndex: "checkFanDuo",
          width: 50,
          align: "center",
          slots: { title: "checkFanDuoTitle" },
          scopedSlots: { customRender: "checkFanDuo" },
        },
        {
          title: "除湿",
          dataIndex: "checkChuShi",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChuShiTitle" },
          scopedSlots: { customRender: "checkChuShi" },
        },
        {
          title: "加湿",
          dataIndex: "checkJiaShi",
          width: 50,
          align: "center",
          type: "switch",
          slots: { title: "checkJiaShiTitle" },
          scopedSlots: { customRender: "checkJiaShi" },
        },
        {
          title: "升温",
          dataIndex: "checkShenWen",
          width: 50,
          align: "center",
          type: "switch",
          slots: { title: "checkShenWenTitle" },
          scopedSlots: { customRender: "checkShenWen" },
        },
        {
          title: "降温",
          dataIndex: "checkJiangWen",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkJiangWenTitle" },
          scopedSlots: { customRender: "checkJiangWen" },
        },
        {
          title: "通风",
          dataIndex: "checkTongFeng",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkTongFengTitle" },
          scopedSlots: { customRender: "checkTongFeng" },
        },
        {
          title: "除尘",
          dataIndex: "checkChuChen",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChuChenTitle" },
          scopedSlots: { customRender: "checkChuChen" },
        },
        {
          title: "虫蛀",
          dataIndex: "checkChongZhu",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChongZhuTitle" },
          scopedSlots: { customRender: "checkChongZhu" },
        },
        {
          title: "发霉",
          dataIndex: "checkFaMei",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkFaMeiTitle" },
          scopedSlots: { customRender: "checkFaMei" },
        },
        // {
        //   title: "泛油",
        //   dataIndex: "checkFanYou",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkFanYouTitle" },
        //   scopedSlots: { customRender: "checkFanYou" },
        // },
        {
          title: "防潮",
          dataIndex: "checkChaoJie",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkChaoJieTitle" },
          scopedSlots: { customRender: "checkChaoJie" },
        },
        {
          title: "避光",
          dataIndex: "checkBiGuang",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkBiGuangTitle" },
          scopedSlots: { customRender: "checkBiGuang" },
        },
        {
          title: "遮光",
          dataIndex: "checkZheGuang",
          type: "switch",
          width: 50,
          align: "center",
          slots: { title: "checkZheGuangTitle" },
          scopedSlots: { customRender: "checkZheGuang" },
        },
        // {
        //   title: "变色",
        //   dataIndex: "checkBianSe",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkBianSeTitle" },
        //   scopedSlots: { customRender: "checkBianSe" },
        // },
        // {
        //   title: "上斗",
        //   dataIndex: "checkShangDou",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkShangDouTitle" },
        //   scopedSlots: { customRender: "checkShangDou" },
        // },
        // {
        //   title: "破损",
        //   dataIndex: "checkPoSun",
        //   type: "switch",
        //   width: 50,
        //   align: "center",
        //   slots: { title: "checkPoSunTitle" },
        //   scopedSlots: { customRender: "checkPoSun" },
        // },
        {
          title: "库区",
          ellipsis: true,
          align: "center",
          width: 100,
          dataIndex: "warehouseAreaName",
          type: "txt",
        },
        {
          title: "存储条件",
          dataIndex: "storeTemperature",
          width: 100,
          type: "txt",
        },
        {
          title: "备注",
          dataIndex: "remark",
          width: 100,
          type: "edit",
        },
        {
          title: "质量状况",
          dataIndex: "qualityStatus",
          width: 100,
          type: "txt",
          customRender(text) {
            if (text == "1") return "合格";
            if (text == "2") return "不合格";
            if (text == "3") return "待检";
            if (text == "4") return "退货";
            return text;
          },
        },

        {
          title: "商品大类",
          dataIndex: "itemHealthCategoryName",
          width: 100,
          type: "txt",
        },
        {
          title: "商品规格",
          ellipsis: true,
          type: "txt",
          width: 100,
          dataIndex: "specification",
        },
        {
          title: "生产厂家",
          width: 100,
          dataIndex: "manufacturerName",
          ellipsis: true,
          type: "txt",
        },
        {
          title: "产地",
          width: 150,
          ellipsis: true,
          type: "txt",
          dataIndex: "countryOriginName",
        },
        {
          title: "包装数量",
          width: 150,
          ellipsis: true,
          type: "txt",
          dataIndex: "caseConversionRate",
        },
        {
          title: "包装单位",
          width: 150,
          type: "txt",
          ellipsis: true,
          dataIndex: "caseUom",
        },
        {
          title: "批准文号",
          dataIndex: "itemHealthApprovalNbr",
          width: 100,
          type: "txt",
        },
        {
          title: "上市许可持有人",
          dataIndex: "itemHealthListedLicensor",
          width: 100,
          ellipsis: true,
          type: "txt",
        },
        {
          title: "注册证号",
          ellipsis: true,
          width: 150,
          type: "txt",
          dataIndex: "itemHealthRegisterNbr",
        },
      ],
    },
    //弹窗
    modalItems: {
      rowkey: "locatorId",
      remoteUrl: {
        url: SERVICE_DATA_API_BASE + "/search/page",
        method: "post",
      },
      remoteBefore(vn, params) {
        let p = { ...params };
        p.data = {
          num: "589130005049643008",
          pageNum: params.data.pageNum,
          pageSize: params.data.pageSize,
          params: params.data,
        };
        return p;
      },
      title: "提取商品",
      gridformref: "gridformModelFormType",
      ref: "modelFormType",
      items: [
        ...genWarehouseAuthSearchModal(1, true, false, null, changecargoOwnerfun, {
          span: 6,
          labelCol: { span: 6 },
          wrapperCol: { span: 14 },
        }),
        ...genCargoownerAuthSearchModal(1, true, false, null, null, {
          span: 6,
          labelCol: { span: 6 },
          wrapperCol: { span: 14 },
        }),
        {
          type: "select",
          span: 6,
          name: "refBillType",
          label: "不合格品来源",
          value: "", //初始化值
          options: [
            { label: "所有", value: "" },
            { label: "入库", value: "1" },
            { label: "移库", value: "2" },
          ],
        },
        {
          type: "input",
          span: 6,
          name: "itemId",
          label: "商品",
          placeholder: "请输入产品名称或助记码或产品编",
          value: "",
        },
        {
          span: 24,
          type: "buttonGroup",
          style: { textAlign: "right" },
          options: [
            {
              value: "查询",
              icon: "search",
              btnType: "primary",
              style: "margin-right:10px;margin-left:10px;",
              htmlType: "submit",
            },
            {
              value: "重置",
              name: "ccz",
              icon: "redo",
              on: {
                click(event, form) {
                  form.resetFields();
                },
              },
            },
          ],
        },
      ],
      columns: [
        {
          title: "日期",
          dataIndex: "refBillDate",
          ellipsis: true,
        },
        {
          title: "原单据编号",
          dataIndex: "refBillId",
          ellipsis: true,
        },
        {
          title: "不合格品来源",
          dataIndex: "refBillType",
          ellipsis: true,
          width: 100,
        },
        {
          title: "不合格原因",
          dataIndex: "unqualifiedReason",
          ellipsis: true,
        },
        {
          title: "不合格数量",
          dataIndex: "unqualifiedQty",
          hidden: true,
        },

        {
          title: "数量",
          dataIndex: "lossQty",
          width: 100,
          scopedSlots: { customRender: "number" },
        },
        {
          title: "商品编码",
          ellipsis: true,
          dataIndex: "itemCode",
        },
        {
          ...genItemSearchModalcuring(
            2,
            false,
            false,
            function (res, p) {
              p.data.cargoOwnerId = cargoOwnerId;
              p.data.warehouseId = warehouseId;
              console.log(p, "====");
              return p;
            },
            null,
            { span: 6, labelCol: { span: 6 }, wrapperCol: { span: 14 } }
          ),
          ellipsis: true,
        },
        {
          title: "助记码",
          ellipsis: true,
          dataIndex: "itemAssistantCode",
        },
        {
          title: "生产厂家",
          ellipsis: true,
          dataIndex: "manufacturerName",
        },
        {
          title: "货位",
          ellipsis: true,
          dataIndex: "locatorCode",
        },
        {
          title: "货位ID",
          ellipsis: true,
          dataIndex: "locatorId",
        },
        {
          title: "批号",
          ellipsis: true,
          align: "center",
          dataIndex: "lotNum",
        },
        {
          title: "托盘",
          align: "center",
          dataIndex: "containerCode",
          width: 100,
          ellipsis: true,
        },
        {
          title: "是否监管",
          ellipsis: true,
          dataIndex: "itemHealthSuperviseflag",
        },
        {
          title: "商品规格",
          ellipsis: true,
          dataIndex: "specification",
        },
        {
          title: "产地",
          ellipsis: true,
          dataIndex: "countryOriginName",
        },
        {
          title: "上市许可持有人",
          ellipsis: true,
          width: 150,
          dataIndex: "itemHealthListedLicensor",
        },
        {
          title: "包装量",
          ellipsis: true,
          dataIndex: "caseConversionRate",
        },
        {
          title: "包装单位",
          ellipsis: true,
          dataIndex: "caseUom",
        },
      ],
      ModalItemsOpinion: {
        ref: "Opinion",
        items: [
          {
            type: "input",
            span: 12,
            name: "opinions",
            label: "所在部门意见",
            value: "", //初始化值
          },
        ],
      },
    },
  };
};
