import { message } from "ant-design-vue";

export function fullScreen(isFullScreen) {
  if (!isFullScreen) {
    // 退出全屏
    if (document.exitFullScreen) {
      document.exitFullScreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
      document.webkitExitFullscreen();
    } else if (document.msExitFullscreen) {
      document.msExitFullscreen();
    }
  } else {
    // 全屏
    var el = document.documentElement;
    var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen;
    if (typeof rfs != "undefined" && rfs) {
      rfs.call(el);
    }
  }
}

/**
 * @description: 全屏函数
 * @param {object} that - 当前实例
 * @param { String } fullScreenNode - 节点
 * @param { Boolean } isFullScreen - 当前状态
 */
export function eleFullScreen(videoDom, isFullScreen) {
  videoDom = videoDom || document.documentElement;
  if (!videoDom) {
    throw new Error(`请配置 fullScreenNode 属性`);
  }
  // debugger
  if (isFullScreen) {
    if (videoDom.requestFullscreen) {
      console.log(videoDom);
      videoDom.requestFullscreen();
    } else if (videoDom.webkitRequestFullScreen) {
      videoDom.webkitRequestFullScreen();
    } else if (videoDom.mozRequestFullScreen) {
      videoDom.mozRequestFullScreen();
    } else {
      videoDom.msRequestFullscreen();
    }
    message.destroy();
    message.config({
      getContainer() {
        return videoDom;
      },
    });
  } else {
    if (document.exitFullscreen) {
      document.exitFullscreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.msExitFullscreen) {
      document.msExiFullscreen();
    } else if (document.webkitCancelFullScreen) {
      document.webkitCancelFullScreen();
    }
    message.destroy();
    message.config({
      getContainer() {
        return document.body;
      },
    });
  }
}

// 检查全屏状态
export function checkFull() {
  var isFull =
    document.mozFullScreen ||
    document.fullScreen ||
    document.webkitIsFullScreen ||
    document.webkitRequestFullScreen ||
    document.mozRequestFullScreen ||
    document.msFullscreenEnabled;
  if (isFull === undefined) {
    isFull = false;
  }
  return isFull;
}
export function queryFormItems(self) {
  let _this = self;
  return [
    {
      type: "input",
      name: "customercode",
      label: "",
      value: "",
      span: 24,
    },
    {
      type: "input",
      name: "customername",
      label: "",
      value: "",
      span: 24,
    },
    {
      type: "input",
      name: "lineCode",
      label: "",
      value: "",
      span: 24,
    },
  ];
}
export function items(self) {
  return [
    {
      type: "input",
      name: "redQty",
      label: "冲红数量",
      rules: [{ required: true, message: "数据不能为空" }],
      value: "",
      // span: 24
    },
    {
      type: "input",
      name: "redReason",
      label: "冲红原因",
      rules: [{ required: true, message: "数据不能为空" }],
      value: "",
      // span: 24
    },
    {
      type: "select",
      name: "redDoMethod",
      label: "红冲处理方式",
      value: "1",
      options: [
        { title: "转移到盘点库", value: "1" },
        // { title: '还原原货位', value: '2' }
      ],
    },
  ];
}
export const columns = [
  // {title: '序号',dataIndex: 'index',key: 'index',scopedSlots: { customRender: 'index' },},
  {
    title: "双人复核",
    dataIndex: "itemHealthIsDouble",
    ellipsis: true,
    width: 60,
    customRender: (text) => (text == "1" ? "是" : "否"),
  },
  { title: "拼箱数量", type: "txt", dataIndex: "lclQty", ellipsis: true, width: 100 },
  { title: "拼箱号", dataIndex: "lclNo", disabled: false, ellipsis: true, width: 100 },
  {
    title: "是否监管",
    dataIndex: "isSupervise",
    ellipsis: true,
    width: 60,
    customRender(text) {
      text == 0 && (text = "无");
      text == 1 && (text = "监管码");
      text == 2 && (text = "序列号");
      return text;
    },
  },
  { title: "商品编号", type: "txt", dataIndex: "itemCode", ellipsis: true, width: 150 },
  { title: "商品名称", type: "txt", dataIndex: "itemName", ellipsis: true, width: 200 },
  { title: "货位", type: "txt", dataIndex: "locatorCode", ellipsis: true, width: 100 },
  { title: "批号", type: "txt", dataIndex: "lotNo", ellipsis: true, width: 100 },
  { title: "计划数量", type: "txt", dataIndex: "qty", ellipsis: true, width: 60 },
  { title: "已拣数量", type: "txt", dataIndex: "pickQty", ellipsis: true, width: 60 },
  { title: "复核数量", type: "txt", dataIndex: "checkQty", ellipsis: true, width: 60 },
  { title: "复核数量(双人)", type: "txt", dataIndex: "check2Qty", ellipsis: true, width: 60 },
  { title: "冲红数量", type: "txt", dataIndex: "redQty", ellipsis: true, width: 60 },
  { title: "冲红原因", type: "txt", dataIndex: "redReason", ellipsis: true, width: 100 },
  { title: "拣货人", type: "txt", dataIndex: "pickerName", ellipsis: true, width: 100 },
  { title: "货位编码", type: "txt", dataIndex: "locatorCode", ellipsis: true, width: 100 },
  { title: "件数", type: "txt", dataIndex: "uomQty", ellipsis: true, width: 100 },
  { title: "包装数量", type: "txt", dataIndex: "caseConversionRate", ellipsis: true, width: 100 },
  { title: "单位", type: "txt", dataIndex: "uom", ellipsis: true, width: 100 },
  { title: "商品规格", type: "txt", dataIndex: "specification", ellipsis: true, width: 150 },
  { title: "生产厂家", type: "txt", dataIndex: "manufacturerId", ellipsis: true, width: 200 },
  { title: "产地", type: "txt", dataIndex: "countryOriginId", ellipsis: true, width: 200 },
  // {title: '状态',type:'txt', dataIndex: 'status',  ellipsis: true, width: 100},
  {
    title: "整散标志",
    type: "txt",
    dataIndex: "isCaseOrPiece",
    ellipsis: true,
    width: 100,
    customRender: (text, record) => {
      if (text == "0") {
        return "整散合一";
      } else if (text == "1") {
        return "整散分离";
      }
    },
  },
  { title: "批准文号", type: "txt", dataIndex: "itemHealthApprovalNbr", ellipsis: true, width: 150 },
  {
    title: "是否贵重商品",
    type: "txt",
    dataIndex: "itemIsValuable",
    ellipsis: true,
    width: 150,
    customRender: (text, record) => {
      if (text == "0") {
        return "否";
      } else if (text == "1") {
        return "是";
      }
    },
  },
  {
    title: "是否易碎",
    type: "txt",
    dataIndex: "itemIsFragile",
    ellipsis: true,
    width: 150,
    customRender: (text, record) => {
      if (text == "0") {
        return "否";
      } else if (text == "1") {
        return "是";
      }
    },
  },
  {
    title: "是否无菌",
    type: "txt",
    dataIndex: "isBacteria",
    ellipsis: true,
    width: 100,
    customRender: (text, record) => {
      if (text == "0") {
        return "否";
      } else if (text == "1") {
        return "是";
      }
    },
  },
  {
    title: "是否委托生产",
    type: "txt",
    dataIndex: "isDelegate",
    ellipsis: true,
    width: 100,
    customRender: (text, record) => {
      if (text == "0") {
        return "否";
      } else if (text == "1") {
        return "是";
      }
    },
  },
  {
    title: "商品是否代管",
    type: "txt",
    dataIndex: "isHosted",
    ellipsis: true,
    width: 100,
    customRender: (text, record) => {
      if (text == "0") {
        return "否";
      } else if (text == "1") {
        return "是";
      }
    },
  },
  { title: "助记码", type: "txt", dataIndex: "itemAssistantCode", ellipsis: true, width: 100 },
  { title: "货主编码", type: "txt", dataIndex: "cargoOwnerCode", ellipsis: true, width: 100 },
  { title: "货主名称", type: "txt", dataIndex: "cargoOwnerName", ellipsis: true, width: 150 },
  { title: "商品大类", type: "txt", dataIndex: "itemHealthCategory", ellipsis: true, width: 150 },
  { title: "上市许可持有人", type: "txt", dataIndex: "itemHealthListedLicensor", ellipsis: true, width: 150 },
  { title: "生产企业许可证号", type: "txt", dataIndex: "itemHealthProduceLicense", ellipsis: true, width: 150 },
  { title: "注册证号", type: "txt", dataIndex: "itemHealthRegisterNbr", ellipsis: true, width: 150 },
  { title: "备案号", type: "txt", dataIndex: "itemHealthRecordNbr", ellipsis: true, width: 150 },
  { title: "箱体积", type: "txt", dataIndex: "volume", ellipsis: true, width: 100 },
  { title: "箱重量", type: "txt", dataIndex: "weight", ellipsis: true, width: 100 },
  { title: "生产日期", type: "txt", dataIndex: "productionDate", ellipsis: true, width: 150 },
  // {title: '生产日期',type:'txt', dataIndex: 'productionDateShow', ellipsis: true, width: 150},
  { title: "有效期至", type: "txt", dataIndex: "expiredDate", ellipsis: true, width: 150 },
  // {title: '有效期至',dataIndex: 'expiredDateShow', ellipsis: true, width: 150},
  {
    title: "操作",
    key: "operate",
    align: "center",
    fixed: "right",
    ellipsis: true,
    width: 130,
    scopedSlots: { customRender: "action" },
  },
];
export const setColumns = (_self) => {
  return [
    {
      title: "双人复核",
      dataIndex: "itemHealthIsDouble",
      width: 100,
      customRender: (text) => (text == "1" ? "是" : "否"),
    },
    { title: "拼箱数量", type: "txt", dataIndex: "lclQty", width: 100 },
    {
      title: "拼箱号",
      dataIndex: "lclNo",
      get disabled() {
        return !_self.saveBtnStatus;
      },
      type: "edit",
      width: 100,
    },
    {
      title: "是否监管",
      dataIndex: "isSupervise",
      width: 60,
      customRender(text) {
        text == 0 && (text = "无");
        text == 1 && (text = "监管码");
        text == 2 && (text = "序列号");
        return text;
      },
    },
    {
      title: "是否监管",
      dataIndex: "itemIsSeque",
      hidden: true,
      width: 60,
      customRender(text) {
        text == 0 && (text = "无");
        text == 1 && (text = "监管码");
        text == 2 && (text = "序列号");
        return text;
      },
    },
    { title: "商品编号", type: "txt", dataIndex: "itemCode", width: 150 },
    { title: "商品名称", type: "txt", dataIndex: "itemName", width: 200 },
    { title: "货位", type: "txt", dataIndex: "locatorCode", ellipsis: true, width: 100 },
    { title: "批号", type: "txt", dataIndex: "lotNo", width: 100 },
    { title: "计划数量", type: "txt", dataIndex: "qty", width: 60 },
    { title: "已拣数量", type: "txt", dataIndex: "pickQty" },
    { title: "复核数量", type: "txt", dataIndex: "checkQty" },
    { title: "复核数量(双人)", type: "txt", dataIndex: "check2Qty" },
    { title: "冲红数量", type: "txt", dataIndex: "redQty" },
    { title: "冲红原因", type: "txt", dataIndex: "redReason", width: 100 },
    { title: "拣货人", type: "txt", dataIndex: "pickerName", width: 100 },
    { title: "货位编码", type: "txt", dataIndex: "locatorCode", width: 100 },
    {
      title: "件数",
      type: "txt",
      dataIndex: "uomQty",
      width: 100,
      customRender: (text, record) => {
        return text;
      },
    },
    { title: "包装数量", type: "txt", dataIndex: "caseConversionRate", width: 100 },
    { title: "单位", type: "txt", dataIndex: "uom", width: 100 },
    { title: "商品规格", type: "txt", dataIndex: "specification", width: 150 },
    { title: "生产厂家", type: "txt", dataIndex: "manufacturerId", width: 200 },
    { title: "产地", type: "txt", dataIndex: "countryOriginId", width: 200 },
    {
      title: "整散标志",
      type: "txt",
      dataIndex: "isCaseOrPiece",
      width: 100,
      customRender: (text, record) => {
        if (text == "0") {
          return "整散合一";
        } else if (text == "1") {
          return "整散分离";
        }
      },
    },
    { title: "批准文号", type: "txt", dataIndex: "itemHealthApprovalNbr", width: 150 },
    {
      title: "是否贵重商品",
      type: "txt",
      dataIndex: "itemIsValuable",
      width: 150,
      customRender: (text, record) => {
        if (text == "0") {
          return "否";
        } else if (text == "1") {
          return "是";
        }
      },
    },
    {
      title: "是否易碎",
      type: "txt",
      dataIndex: "itemIsFragile",
      width: 150,
      customRender: (text, record) => {
        if (text == "0") {
          return "否";
        } else if (text == "1") {
          return "是";
        }
      },
    },
    {
      title: "是否无菌",
      type: "txt",
      dataIndex: "isBacteria",
      width: 100,
      customRender: (text, record) => {
        if (text == "0") {
          return "否";
        } else if (text == "1") {
          return "是";
        }
      },
    },
    {
      title: "是否委托生产",
      type: "txt",
      dataIndex: "isDelegate",
      width: 100,
      customRender: (text, record) => {
        if (text == "0") {
          return "否";
        } else if (text == "1") {
          return "是";
        }
      },
    },
    {
      title: "商品是否代管",
      type: "txt",
      dataIndex: "isHosted",
      width: 100,
      customRender: (text, record) => {
        if (text == "0") {
          return "否";
        } else if (text == "1") {
          return "是";
        }
      },
    },
    { title: "助记码", type: "txt", dataIndex: "itemAssistantCode", width: 100 },
    { title: "货主编码", type: "txt", dataIndex: "cargoOwnerCode", width: 100 },
    { title: "货主名称", type: "txt", dataIndex: "cargoOwnerName", width: 150 },
    { title: "商品大类", type: "txt", dataIndex: "itemHealthCategory", width: 150 },
    { title: "上市许可持有人", type: "txt", dataIndex: "itemHealthListedLicensor", width: 150 },
    { title: "生产企业许可证号", type: "txt", dataIndex: "itemHealthProduceLicense", width: 150 },
    { title: "注册证号", type: "txt", dataIndex: "itemHealthRegisterNbr", width: 150 },
    { title: "备案号", type: "txt", dataIndex: "itemHealthRecordNbr", width: 150 },
    { title: "箱体积", type: "txt", dataIndex: "volume", width: 100 },
    { title: "箱重量", type: "txt", dataIndex: "weight", width: 100 },
    { title: "生产日期", type: "txt", dataIndex: "productionDate", width: 150 },
    { title: "有效期至", type: "txt", dataIndex: "expiredDate", width: 150 },
    {
      title: "操作",
      key: "operate",
      align: "center",
      fixed: "right",
      width: 130,
      scopedSlots: { customRender: "action" },
    },
  ];
};
export const printcolumns = [
  {
    title: "序号",
    dataIndex: "index",
    key: "index",
    scopedSlots: { customRender: "index" },
  },
  {
    title: "商品编码",
    key: "name",
    width: "100px",
    dataIndex: "itemCode",
  },
  {
    title: "数量",
    dataIndex: "qty",
    width: "100px",
    key: "qty",
  },
];

export function differentColumns(self) {
  let that = self;
  return [
    { title: "商品编码", dataIndex: "itemCode", key: "itemCode", width: 50 },
    { title: "商品名称", dataIndex: "itemName", key: "itemName" },
    {
      title: "批号",
      type: "input",
      dataIndex: "lotNo",
      key: "lotNo",
      required: true,
      disabled: [
        {
          $value: true,
          $match: [{ key: "pickTaskDId", value: "${*}" }],
        },
        { $value: false },
      ],
    },
    {
      title: "货位",
      type: "input",
      dataIndex: "locatorCode",
      key: "locatorCode",
      required: true,
      disabled: [
        {
          $value: true,
          $match: [{ key: "pickTaskDId", value: "${*}" }],
        },
        { $value: false },
      ],
    },
    {
      title: "应检数量",
      type: "input",
      dataIndex: "pickQty",
      key: "pickQty",
      required: true,
      disabled: [
        {
          $value: true,
          $match: [{ key: "pickTaskDId", value: "${*}" }],
        },
        { $value: false },
      ],
    },
    { title: "差异数量", type: "input", dataIndex: "differenceQty", key: "differenceQty", required: true },
    {
      title: "差异类型",
      type: "select",
      dataIndex: "differenceType",
      allowClear: true,
      required: true,
      key: "differenceType",
      options: [
        { label: "多拣", value: 1 },
        { label: "少拣", value: 2 },
      ],
      // disabled: [
      //   {
      //     $value: false,
      //     $match: [{ key: 'refModelId', value: '${*}' }]
      //   },
      //   { $value: true }
      // ],
    },
    {
      title: "差异原因",
      type: "select",
      dataIndex: "differenceReason",
      allowClear: true,
      key: "differenceReason",
      required: true,
      options: [
        { label: "商品少拣", value: 1 },
        { label: "商品多拣", value: 2 },
        { label: "商品错拣", value: 3 },
        { label: "批号错拣", value: 4 },
      ],
    },
    // {
    //   title: '关联引用',
    //   type: 'a-tree-select',
    //   allowClear: true,
    //   dataIndex: 'refModelId',
    //   key: 'refModelId',
    //   replaceFields: { key: 'id', title: 'name', value: 'id' },
    //   treeData: that.sTreeData,
    //   on: {
    //     change() {}
    //   }
    // },
    // {
    //   type: 'select',
    //   key: 'targetConfId1',
    //   dataIndex: 'targetConfId1',
    //   title: '模型字段',
    //   allowClear: true,
    //   destroyOptions: true,
    //   // required: true,
    //   remoteUrl: { url: '/api/upcloud-lowcode/field/list?', method: 'get' },
    //   relatedQuery: [{ key: 'refModelId', target: 'params.modelId' }],
    //   doneBefore(vnode) {
    //     let option = []
    //     vnode.data.forEach(t => {
    //       option.push({
    //         title: t.fieldName,
    //         value: t.modelId
    //       })
    //     })
    //     vnode.data = option
    //   },
    //   disabled: [
    //     {
    //       $value: false,
    //       $match: [{ key: 'refModelId', value: '${*}' }]
    //     },
    //     { $value: true }
    //   ],
    //   on: {
    //     change() {}
    //   }
    // },
    // { title: '表达式', type: 'input', dataIndex: 'mathExpression', key: 'mathExpression' }
  ];
}
