import Dialog from '../../../../dist/dialog/dialog.js';
const util = require('../../../../utils/util.js')
const api = require('../../../../utils/api.js')
const Constants = require('../../../../utils/Constants.js')
const config = require('../../../../config/config.js')
const common = require('../../../../utils/common'); 
const chooseGoodsCommon = require('../../../../utils/chooseGoodsCommon.js');
const soundUtil = require('../../../../utils/util.js')
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active: "0",
    activeNames: [
      "1"
    ],
    annexPaths: [],
    barcodeList: [],
    checked: true,
    deliveryPhoneTemp: [],
    deleteList: [],
    fileList: [],
    form: {
      "ascpId": 29195,
      "cpId": 20760,
      "deliveryTime": "2024/01/30 08:00:00",
      "remarks": null,
      "sale1Id": 20760,
      "sale2Id": 29195,
      "sumAmount": null,
      "sumQuantity": null,
      "outId": 3403,
      "outNo": "WO-QZHJ-000-202401290SAO",
      "erpOutNo": null,
      "orderId": 11971,
      "orderNo": "SA-QZHJ-BFJ-202401290SAN",
      "sumOutGoingQuantity": 30,
      "sumOutGoingAmount": 44000,
      "sumOutQuantity": 0,
      "sumOutAmount": 0,
      "flgValid": true,
      "opCreateTime": "2024-01-29 09:57:36",
      "opCreateUserId": 1005,
      "opUpdateUserId": 1005,
      "opUpdateTime": "2024-01-29 09:57:48",
      "opAppId": "5096ef17-ee97-47bc-ab99-1d6be28f4b66",
      "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
      "opTimestamp": "2024-01-29 09:57:48",
      "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"124.71.26.125\"}",
      "customerId": 3900,
      "customerName": "附件客户",
      "customerPhone": "17652525325",
      "contactName": null,
      "deliveryPhone": "",
      "salesChannel": 1,
      "outStatus": 2,
      "orgId": 32402,
      "opCreateTimeStart": null,
      "opCreateTimeEnd": null,
      "outReasonName": null,
      "staffName": "王英杰",
      "ascpName": null,
      "supplierName": null,
      "outObjectName": null,
      "outObjectId": null,
      "outObjectType": null,
      "categoryQuantity": null,
      "outKind": "出库类型-销售",
      "supplierId": null,
      "outReason": null,
      "outServiceType": null,
      "hgcrmPushStatus": null,
      "hgcrmPushResult": null,
      "staffId": 643,
      "rejectId": null,
      "rejectNo": null,
      "outDate": null,
      "outStatusName": null,
      "deliveryDate": null,
      "deliveryType": null,
      "toiletCount": 11,
      "fitupType": 88,
      "houseType": 85,
      "fitupStyle": 90,
      "ageComposition": 27,
      "decisionMaker": 103,
      "remarksInside": null,
      "orderOutItemResponseList": [
        {
          "bomSkuId": null,
          "brandName": "恒洁卫浴",
          "canOutQuantity": 10,
          "cpId": 20760,
          "decimalPlaces": null,
          "erpOutItemId": null,
          "erpOutNo": null,
          "flgNonStandardType": null,
          "flgNonStdType": null,
          "flgScanCode": null,
          "flgValid": true,
          "iconPathType": null,
          "iconThumPath": "haip/2023-04-21/19ae78a2639547d9aa961b58d20dbdbd.png",
          "itemId": 6188,
          "ivtId": null,
          "ivtQty": 3,
          "ivtUsableQty": 0,
          "nonStandardArea": 1,
          "nonStandardCode": "-",
          "nonStdCode": "-",
          "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
          "opAppId": "5096ef17-ee97-47bc-ab99-1d6be28f4b66",
          "opCreateTime": "2024-01-29 09:57:36",
          "opCreateUserId": 1005,
          "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"124.71.26.125\"}",
          "opTimestamp": "2024-01-29 09:57:36",
          "opUpdateTime": "2024-01-29 09:57:36",
          "opUpdateUserId": 1005,
          "orderAmount": 4000,
          "orderId": 11971,
          "orderItemId": 36126,
          "orderNo": null,
          "orderPriceSale": 400,
          "orderQuantity": 10,
          "originalDocumentNo": null,
          "originalDocumentType": null,
          "originalOutGoingAmount": 4000,
          "originalOutGoingQuantity": 10,
          "outAmount": 0,
          "outDate": null,
          "outGoingAmount": 4000,
          "outGoingQty": null,
          "outGoingQuantity": 10,
          "outId": 3403,
          "outQuantity": 0,
          "outStatus": 2,
          "outStatusName": null,
          "refCostAmt": 30780,
          "refCostPrice": 3078,
          "rejectAmount": 0,
          "rejectId": null,
          "rejectItemId": null,
          "rejectQuantity": 0,
          "remarks": null,
          "skuCode": "EE920A00200B01",
          "skuId": 9537580,
          "skuModel": "HE920",
          "skuName": "【已淘汰】智能盖板HE920",
          "skuSpecs": null,
          "skuType": 0,
          "skuTypeName": "智能马桶\\智能盖板",
          "skuVolume": null,
          "skuWeight": null,
          "soutId": null,
          "soutItemId": null,
          "specsList": [],
          "specsName": "智能盖板",
          "specsValues": null,
          "spuId": null,
          "titleTag": "HEGII",
          "unitName": null,
          "usableQty": 10,
          "whId": 552,
          "whName": "钦州运营仓",
          "barcodeList": []
        },
        {
          "bomSkuId": 161052,
          "brandName": "恒洁卫浴",
          "canOutQuantity": 10,
          "cpId": 20760,
          "decimalPlaces": null,
          "erpOutItemId": null,
          "erpOutNo": null,
          "flgNonStandardType": null,
          "flgNonStdType": null,
          "flgScanCode": null,
          "flgValid": true,
          "iconPathType": null,
          "iconThumPath": null,
          "itemId": 6189,
          "ivtId": null,
          "ivtQty": null,
          "ivtUsableQty": null,
          "nonStandardArea": null,
          "nonStandardCode": "-",
          "nonStdCode": "-",
          "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
          "opAppId": "5096ef17-ee97-47bc-ab99-1d6be28f4b66",
          "opCreateTime": "2024-01-29 09:57:36",
          "opCreateUserId": 1005,
          "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"124.71.26.125\"}",
          "opTimestamp": "2024-01-29 09:57:36",
          "opUpdateTime": "2024-01-29 09:57:36",
          "opUpdateUserId": 1005,
          "orderAmount": 17041.1,
          "orderId": 11971,
          "orderItemId": 36127,
          "orderNo": null,
          "orderPriceSale": 1704.11,
          "orderQuantity": 10,
          "originalDocumentNo": null,
          "originalDocumentType": null,
          "originalOutGoingAmount": 17041.1,
          "originalOutGoingQuantity": 10,
          "outAmount": 0,
          "outDate": null,
          "outGoingAmount": 17041.1,
          "outGoingQty": null,
          "outGoingQuantity": 10,
          "outId": 3403,
          "outQuantity": 0,
          "outStatus": 2,
          "outStatusName": null,
          "refCostAmt": 33030,
          "refCostPrice": 3303,
          "rejectAmount": 0,
          "rejectId": null,
          "rejectItemId": null,
          "rejectQuantity": 0,
          "remarks": null,
          "skuCode": "CT901DT2200B01",
          "skuId": 9605810,
          "skuModel": "HC0901DT-0",
          "skuName": "落地式坐便器HC0901DT\\地排305\\无盖板",
          "skuSpecs": null,
          "skuType": 0,
          "skuTypeName": "陶瓷类\\坐便器",
          "skuVolume": null,
          "skuWeight": null,
          "soutId": null,
          "soutItemId": null,
          "specsList": [],
          "specsName": "坐便器",
          "specsValues": null,
          "spuId": null,
          "titleTag": "HEGII",
          "unitName": null,
          "usableQty": null,
          "whId": 552,
          "whName": "钦州运营仓",
          "barcodeList": []
        },
        {
          "bomSkuId": 161052,
          "brandName": "恒洁卫浴",
          "canOutQuantity": 10,
          "cpId": 20760,
          "decimalPlaces": null,
          "erpOutItemId": null,
          "erpOutNo": null,
          "flgNonStandardType": null,
          "flgNonStdType": null,
          "flgScanCode": null,
          "flgValid": true,
          "iconPathType": null,
          "iconThumPath": null,
          "itemId": 6190,
          "ivtId": null,
          "ivtQty": null,
          "ivtUsableQty": null,
          "nonStandardArea": null,
          "nonStandardCode": "-",
          "nonStdCode": "-",
          "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
          "opAppId": "5096ef17-ee97-47bc-ab99-1d6be28f4b66",
          "opCreateTime": "2024-01-29 09:57:36",
          "opCreateUserId": 1005,
          "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"124.71.26.125\"}",
          "opTimestamp": "2024-01-29 09:57:36",
          "opUpdateTime": "2024-01-29 09:57:36",
          "opUpdateUserId": 1005,
          "orderAmount": 22958.9,
          "orderId": 11971,
          "orderItemId": 36128,
          "orderNo": null,
          "orderPriceSale": 2295.89,
          "orderQuantity": 10,
          "originalDocumentNo": null,
          "originalDocumentType": null,
          "originalOutGoingAmount": 22958.9,
          "originalOutGoingQuantity": 10,
          "outAmount": 0,
          "outDate": null,
          "outGoingAmount": 22958.9,
          "outGoingQty": null,
          "outGoingQuantity": 10,
          "outId": 3403,
          "outQuantity": 0,
          "outStatus": 2,
          "outStatusName": null,
          "refCostAmt": 44500,
          "refCostPrice": 4450,
          "rejectAmount": 0,
          "rejectId": null,
          "rejectItemId": null,
          "rejectQuantity": 0,
          "remarks": null,
          "skuCode": "CQ501000000N01",
          "skuId": 9607630,
          "skuModel": null,
          "skuName": "电控盖板HQ501",
          "skuSpecs": null,
          "skuType": 0,
          "skuTypeName": null,
          "skuVolume": null,
          "skuWeight": null,
          "soutId": null,
          "soutItemId": null,
          "specsList": [],
          "specsName": null,
          "specsValues": null,
          "spuId": null,
          "titleTag": "HEGII",
          "unitName": null,
          "usableQty": null,
          "whId": 552,
          "whName": "钦州运营仓",
          "barcodeList": []
        }
      ],
      "addressFull": "广东省广州市越秀区越秀区广州市人民政府(府前路北)121",
      "returnAddressFull": null,
      "returnContactName": null,
      "returnContactPhone": null,
      "makingUser": 1005,
      "makingTime": "2024-01-29 09:57:36",
      "makingDate": null,
      "makingUserName": null,
      "orgName": "北海富安居店",
      "doneTime": "2024-01-29 09:57:31",
      "doneUser": 1005,
      "doneUserName": null,
      "hgcrmPushStatusName": null,
      "annexPaths": [],
      "flgAllowTodone": false,
      "flgAllowReverse": false,
      "salesChannelCode": null,
      "erpPushStatus": 1,
      "erpPushResult": "操作成功",
      "sumRejectQuantity": null,
      "sumRejectAmount": null,
      "deliveryUser": null,
      "deliveryUserName": null,
      "installUser": null,
      "installUserName": null,
      "outKindName": null,
      "toiletCountName": null,
      "houseTypeName": "出租房",
      "fitupTypeName": "精装升级",
      "fitupStyleName": "中式",
      "ageCompositionName": "80后",
      "decisionMakerName": "驻店设计师",
      "deliveryTypeName": null,
      "fromName": "自然进店",
      "addressArea": null,
      "addressName": "越秀区广州市人民政府(府前路北)",
      "addressNo": "121",
      "addressGcj02": null,
      "customerFrom": 28,
      "sale2OpeMode": "分销模式-代送",
      "docCode": null,
      "contractNo": null,
      "flgToErp": false,
      "erpPushStatusName": null,
      "sale2EntryWhId": null,
      "orderAnnexPaths": [],
      "soutId": null
    },
    goodsList: [
      {
        "bomSkuId": null,
        "brandName": "恒洁卫浴",
        "canOutQuantity": 10,
        "cpId": 20760,
        "decimalPlaces": null,
        "erpOutItemId": null,
        "erpOutNo": null,
        "flgNonStandardType": null,
        "flgNonStdType": null,
        "flgScanCode": null,
        "flgValid": true,
        "iconPathType": null,
        "iconThumPath": "haip/2023-04-21/19ae78a2639547d9aa961b58d20dbdbd.png",
        "itemId": 6188,
        "ivtId": null,
        "ivtQty": 3,
        "ivtUsableQty": 0,
        "nonStandardArea": 1,
        "nonStandardCode": "-",
        "nonStdCode": "-",
        "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
        "opAppId": "5096ef17-ee97-47bc-ab99-1d6be28f4b66",
        "opCreateTime": "2024-01-29 09:57:36",
        "opCreateUserId": 1005,
        "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"124.71.26.125\"}",
        "opTimestamp": "2024-01-29 09:57:36",
        "opUpdateTime": "2024-01-29 09:57:36",
        "opUpdateUserId": 1005,
        "orderAmount": 4000,
        "orderId": 11971,
        "orderItemId": 36126,
        "orderNo": null,
        "orderPriceSale": 400,
        "orderQuantity": 10,
        "originalDocumentNo": null,
        "originalDocumentType": null,
        "originalOutGoingAmount": 4000,
        "originalOutGoingQuantity": 10,
        "outAmount": 0,
        "outDate": null,
        "outGoingAmount": 4000,
        "outGoingQty": null,
        "outGoingQuantity": 10,
        "outId": 3403,
        "outQuantity": 0,
        "outStatus": 2,
        "outStatusName": null,
        "refCostAmt": 30780,
        "refCostPrice": 3078,
        "rejectAmount": 0,
        "rejectId": null,
        "rejectItemId": null,
        "rejectQuantity": 0,
        "remarks": null,
        "skuCode": "EE920A00200B01",
        "skuId": 9537580,
        "skuModel": "HE920",
        "skuName": "【已淘汰】智能盖板HE920",
        "skuSpecs": null,
        "skuType": 0,
        "skuTypeName": "智能马桶\\智能盖板",
        "skuVolume": null,
        "skuWeight": null,
        "soutId": null,
        "soutItemId": null,
        "specsList": [],
        "specsName": "智能盖板",
        "specsValues": null,
        "spuId": null,
        "titleTag": "HEGII",
        "unitName": null,
        "usableQty": 10,
        "whId": 552,
        "whName": "钦州运营仓",
        "barcodeList": []
      },
      {
        "bomSkuId": 161052,
        "brandName": "恒洁卫浴",
        "canOutQuantity": 10,
        "cpId": 20760,
        "decimalPlaces": null,
        "erpOutItemId": null,
        "erpOutNo": null,
        "flgNonStandardType": null,
        "flgNonStdType": null,
        "flgScanCode": null,
        "flgValid": true,
        "iconPathType": null,
        "iconThumPath": null,
        "itemId": 6189,
        "ivtId": null,
        "ivtQty": null,
        "ivtUsableQty": null,
        "nonStandardArea": null,
        "nonStandardCode": "-",
        "nonStdCode": "-",
        "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
        "opAppId": "5096ef17-ee97-47bc-ab99-1d6be28f4b66",
        "opCreateTime": "2024-01-29 09:57:36",
        "opCreateUserId": 1005,
        "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"124.71.26.125\"}",
        "opTimestamp": "2024-01-29 09:57:36",
        "opUpdateTime": "2024-01-29 09:57:36",
        "opUpdateUserId": 1005,
        "orderAmount": 17041.1,
        "orderId": 11971,
        "orderItemId": 36127,
        "orderNo": null,
        "orderPriceSale": 1704.11,
        "orderQuantity": 10,
        "originalDocumentNo": null,
        "originalDocumentType": null,
        "originalOutGoingAmount": 17041.1,
        "originalOutGoingQuantity": 10,
        "outAmount": 0,
        "outDate": null,
        "outGoingAmount": 17041.1,
        "outGoingQty": null,
        "outGoingQuantity": 10,
        "outId": 3403,
        "outQuantity": 0,
        "outStatus": 2,
        "outStatusName": null,
        "refCostAmt": 33030,
        "refCostPrice": 3303,
        "rejectAmount": 0,
        "rejectId": null,
        "rejectItemId": null,
        "rejectQuantity": 0,
        "remarks": null,
        "skuCode": "CT901DT2200B01",
        "skuId": 9605810,
        "skuModel": "HC0901DT-0",
        "skuName": "落地式坐便器HC0901DT\\地排305\\无盖板",
        "skuSpecs": null,
        "skuType": 0,
        "skuTypeName": "陶瓷类\\坐便器",
        "skuVolume": null,
        "skuWeight": null,
        "soutId": null,
        "soutItemId": null,
        "specsList": [],
        "specsName": "坐便器",
        "specsValues": null,
        "spuId": null,
        "titleTag": "HEGII",
        "unitName": null,
        "usableQty": null,
        "whId": 552,
        "whName": "钦州运营仓",
        "barcodeList": []
      },
      {
        "bomSkuId": 161052,
        "brandName": "恒洁卫浴",
        "canOutQuantity": 10,
        "cpId": 20760,
        "decimalPlaces": null,
        "erpOutItemId": null,
        "erpOutNo": null,
        "flgNonStandardType": null,
        "flgNonStdType": null,
        "flgScanCode": null,
        "flgValid": true,
        "iconPathType": null,
        "iconThumPath": null,
        "itemId": 6190,
        "ivtId": null,
        "ivtQty": null,
        "ivtUsableQty": null,
        "nonStandardArea": null,
        "nonStandardCode": "-",
        "nonStdCode": "-",
        "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
        "opAppId": "5096ef17-ee97-47bc-ab99-1d6be28f4b66",
        "opCreateTime": "2024-01-29 09:57:36",
        "opCreateUserId": 1005,
        "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"124.71.26.125\"}",
        "opTimestamp": "2024-01-29 09:57:36",
        "opUpdateTime": "2024-01-29 09:57:36",
        "opUpdateUserId": 1005,
        "orderAmount": 22958.9,
        "orderId": 11971,
        "orderItemId": 36128,
        "orderNo": null,
        "orderPriceSale": 2295.89,
        "orderQuantity": 10,
        "originalDocumentNo": null,
        "originalDocumentType": null,
        "originalOutGoingAmount": 22958.9,
        "originalOutGoingQuantity": 10,
        "outAmount": 0,
        "outDate": null,
        "outGoingAmount": 22958.9,
        "outGoingQty": null,
        "outGoingQuantity": 10,
        "outId": 3403,
        "outQuantity": 0,
        "outStatus": 2,
        "outStatusName": null,
        "refCostAmt": 44500,
        "refCostPrice": 4450,
        "rejectAmount": 0,
        "rejectId": null,
        "rejectItemId": null,
        "rejectQuantity": 0,
        "remarks": null,
        "skuCode": "CQ501000000N01",
        "skuId": 9607630,
        "skuModel": null,
        "skuName": "电控盖板HQ501",
        "skuSpecs": null,
        "skuType": 0,
        "skuTypeName": null,
        "skuVolume": null,
        "skuWeight": null,
        "soutId": null,
        "soutItemId": null,
        "specsList": [],
        "specsName": null,
        "specsValues": null,
        "spuId": null,
        "titleTag": "HEGII",
        "unitName": null,
        "usableQty": null,
        "whId": 552,
        "whName": "钦州运营仓",
        "barcodeList": []
      }
    ],
    height: 0,
    item: {
      "addressArea": null,
      "addressFull": "广东省广州市越秀区越秀区广州市人民政府(府前路北)121",
      "addressGcj02": null,
      "addressName": null,
      "addressNo": null,
      "ageComposition": null,
      "ageCompositionName": null,
      "annexPaths": [],
      "ascpId": 29195,
      "ascpName": "无库无ERP00001",
      "categoryQuantity": null,
      "contactName": "",
      "deliveryPhone": "",
      "contractNo": null,
      "cpId": 20760,
      "customerFrom": null,
      "customerId": null,
      "customerName": "附件客户",
      "customerPhone": "17652525325",
      "decisionMaker": null,
      "decisionMakerName": null,
      "deliveryDate": null,
      "deliveryTime": "2024/01/30 08:00:00",
      "deliveryType": null,
      "deliveryTypeName": null,
      "deliveryUser": null,
      "deliveryUserName": null,
      "docCode": "销售订单",
      "doneTime": "2024-01-29 09:57:31",
      "doneUser": 1005,
      "doneUserName": "无库无ERP00001",
      "erpOutNo": null,
      "erpPushResult": "操作成功",
      "erpPushStatus": 1,
      "erpPushStatusName": "推送成功",
      "fitupStyle": null,
      "fitupStyleName": null,
      "fitupType": null,
      "fitupTypeName": null,
      "flgAllowReverse": false,
      "flgAllowTodone": false,
      "flgToErp": false,
      "flgValid": true,
      "fromName": null,
      "hgcrmPushResult": null,
      "hgcrmPushStatus": null,
      "hgcrmPushStatusName": null,
      "houseType": null,
      "houseTypeName": null,
      "installUser": null,
      "installUserName": null,
      "makingDate": "2024-01-29",
      "makingTime": "2024/01/29 09:57:36",
      "makingUser": 1005,
      "makingUserName": "无库无ERP00001",
      "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
      "opAppId": "5096ef17-ee97-47bc-ab99-1d6be28f4b66",
      "opCreateTime": "2024-01-29 09:57:36",
      "opCreateTimeEnd": null,
      "opCreateTimeStart": null,
      "opCreateUserId": 1005,
      "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"124.71.26.125\"}",
      "opTimestamp": "2024-01-29 09:57:48",
      "opUpdateTime": "2024-01-29 09:57:48",
      "opUpdateUserId": 1005,
      "orderAnnexPaths": null,
      "orderId": 11971,
      "orderNo": "SA-QZHJ-BFJ-202401290SAN",
      "orderOutItemResponseList": null,
      "orgId": 32402,
      "orgName": "北海富安居店",
      "outDate": null,
      "outId": 3403,
      "outKind": "出库类型-销售",
      "outKindName": "销售出库",
      "outNo": "WO-QZHJ-000-202401290SAO",
      "outObjectId": 3900,
      "outObjectName": "附件客户",
      "outObjectType": 1,
      "outReason": null,
      "outReasonName": null,
      "outServiceType": null,
      "outStatus": 2,
      "outStatusName": "出库中",
      "rejectId": null,
      "rejectNo": null,
      "remarks": null,
      "remarksInside": null,
      "returnAddressFull": null,
      "returnContactName": null,
      "returnContactPhone": null,
      "sale1Id": 20760,
      "sale2EntryWhId": 616,
      "sale2Id": 29195,
      "sale2OpeMode": "分销模式-代送",
      "salesChannel": null,
      "salesChannelCode": null,
      "soutId": null,
      "staffId": 1005,
      "staffName": "无库无ERP00001",
      "sumAmount": null,
      "sumOutAmount": 0,
      "sumOutGoingAmount": 44000,
      "sumOutGoingQuantity": 30,
      "sumOutQuantity": 0,
      "sumQuantity": null,
      "sumRejectAmount": 0,
      "sumRejectQuantity": 0,
      "supplierId": null,
      "supplierName": null,
      "toiletCount": null,
      "toiletCountName": null
    },
    loading: false,
    locationFlag: true,
    loginType: false,
    objItem: {},
    orgGoodsListFlag: false,
    orgGoodsListFlagCopy: false,
    orgItem: {
    text: "",
    value: null
    },
    organizationItem: {},
    organizationList: [],
    sale2OpeMode: "分销模式-代送",
    salesChannelItem: {
    text: "零售",
    value: 1
    },
    scanBarcodeName: "扫描条码",
    scanFunctionIsUseAble: true,
    scanList: [
    {},
    {}
    ],
    select: false,
    showEditProduct: false,
    showMore: false,
    showPanel1: false,
    staffItem: {
    text: "选择业务员",
    value: null
    },
    staffList: [],
    tags: [],
    telephone: "",
    orderAnnexPaths: [],
    orderfileList: []
  },
    /**
   * @desc : 选择业务员
   * @author : 王英杰
   * @date : 2023年10月8日
   */
  openStaffDropdown() {
    this.setData({
      staffFlag: true
    })
  },
  /**
   * @desc : 选择业务部门
   * @author : 王英杰
   * @date : 2023年10月8日
   */
  openOrgDropdown() {
    this.setData({
      orgFlag: true
    })
  },
  /**
   * 日期：2023年10月13日
   * author：王英杰
   * 全选事件监听
   */
  onCheckedSelectAllChange(e) {
    let form = this.data.form
    if(form.outStatus == -1){  //冲正单据的时候 不让操作
      return
    } 
    let checkedSelectAll = !this.data.checkedSelectAll
    let _this = this 
    const goodsList = this.data.goodsList 
    if (checkedSelectAll) {
      goodsList.forEach(function (item, index) {
        goodsList[index].outQuantity = goodsList[index].outGoingQuantity
        goodsList[index].checked = true
      }) 
    } else { 
      wx.showModal({
        title: '提示',
        content: '是否确定取消商品',
        success(res) {
          if (res.confirm) {
            goodsList.forEach(function (item, index) {
              goodsList[index].checked = false
              goodsList[index].outQuantity = 0
              //删除扫码信息  从总list中删除
              for (let j = 0; j < goodsList[index].barcodeList.length; j++) {
                const goodbarcode = goodsList[index].barcodeList[j];
                // 获取行号
                let m = _this.data.barcodeList.findIndex(it => it.barcode == goodbarcode.barcode);
                _this.data.barcodeList.splice(m, 1)
              }
              goodsList[index].barcodeList = [] // 商品的条码         
  
              setTimeout(function () {
                _this.setData({
                  goodsList,
                  barcodeList: _this.data.barcodeList,
                });
              }, 100)
            })  
          }
        }
      })
    } 
    this.setData({
      checkedSelectAll,
      goodsList
    })
  },
  /**商品明细 前面的Checkbox值改变监听 */
  onCheckboxChange(event) {
    let _this = this
    console.log("onCheckboxChange", event)
    const goodsList = this.data.goodsList
    const index = event.currentTarget.dataset.index
   
    if (event.detail) {
      goodsList[index].outQuantity = goodsList[index].outGoingQuantity
      goodsList[index].checked = !goodsList[index].checked
    } else {
      wx.showModal({
        title: '提示',
        content: '是否确定取消商品',
        success(res) {
          if (res.confirm) {           
            goodsList[index].checked = event.detail
            goodsList[index].outQuantity = 0            
            //删除扫码信息  从总list中删除
            for (let j = 0; j < goodsList[index].barcodeList.length; j++) {
              const goodbarcode = goodsList[index].barcodeList[j]; 
              // 获取行号
              let m = _this.data.barcodeList.findIndex(it => it.barcode == goodbarcode.barcode);
              _this.data.barcodeList.splice(m,1)
            } 
            goodsList[index].barcodeList = [] // 商品的条码         
            
            setTimeout(function () {
              _this.setData({
                goodsList,
                barcodeList:_this.data.barcodeList,
              });    
            }, 1000)
           
          }         
        }
      }) 
    }
    _this.setData({
      goodsList
    });
  },
  /**切换 商品明细和扫码明细的tab页事件 */
  onChangeTabs(e) {
    let active = e.detail.name
    this.setData({
      active: active
    })

  },
  /**每个商品折叠展开事件 */
  togglePanel1(e) {
    if (e.target.dataset.index == undefined) {
      const index = e.currentTarget.dataset.index;
      const goodsList = this.data.goodsList;
      goodsList[index].showPanel = !goodsList[index].showPanel;
      this.setData({
        goodsList: goodsList
      });
    }
  },
  /**扫描出库按钮点击 */
  scanBarcode() {
    let that = this
    this.setData({
      scanBarcodeName: (that.data.scanBarcodeName == "扫描条码") ? "关闭扫描" : "扫描条码"
    })
  },

  /**
   * @desc : 打开编辑商品备注事件 todo
   * @author : 王英杰
   * @date : 2023年9月12日
   */
  openRemark(e) {
    this.setData({
      remarksIndex: e.currentTarget.dataset.index,
      remarkFlag: true
    })
  },
  /**
   * @desc : 备注弹窗编辑事件
   * @author : 于继渤
   * @date : 2022/6/01 12:16
   */
  changeRemarksField(e) {
    this.setData({
      remarks: e.detail
    })
  },

  /**
   * @desc : 编辑商品关闭确定编辑备注事件
   * @author : 王英杰
   * @date : 2023年9月12日
   */
  updateToChooseList_remark(e) {
    let goodsList = this.data.goodsList
    goodsList[this.data.remarksIndex].remarks = this.data.remarks
    this.setData({
      goodsList: goodsList,
      remarkFlag: false
    })
  },
  /**
   * @desc : 编辑商品关闭编辑备注事件
   * @author : 王英机
   * @date : 2023年9月12日
   */
  closeChoosedItemInfo_remark() {
    this.setData({
      remarkFlag: false
    })
  },


  /**
   * @desc : 设计制图
   * @author : 于继渤
   * @date : 2022/6/15 9:16
   */
  onDesignGraphicsChange(e) {
    let item = e.currentTarget.dataset.item
    let form = this.data.form
    form.designGraphics = !item
    if (!form.designGraphics) {
      form.designRemarks = null
      form.designUserName = null
      form.designUser = null
      form.designStatus = Constants.DESIGN_STATUS.DESIGN_STATUS_NOT_REQUIRED //不需要设计 

    } else {
      form.designStatus = Constants.DESIGN_STATUS.DESIGN_STATUS_REQUIRED //设计状态 需设计
    }
    this.setData({
      form: form
    })
  },



  /**
   * @desc : 跳转选择客户
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  onChooseCustomer() {
    wx.navigateTo({
      url: '../choose-customer/choose-customer',
    })
  },

  /**
   * @desc : 跳转选商品
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  toChooseGoods() {
    wx.navigateTo({
      url: '/package6/pages/choose-product/choose-product',
    })
  },



  /**
   * @desc : 关闭产品
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  closeChoosedItemInfo() {
    this.setData({
      showEditProduct: false,
      currentChoosedItem: []
    })
  },



  /**
   * @desc : 展开,收起更多功能事件
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  listToggle() {
    this.setData({
      showMore: !this.data.showMore
    })
  },

  /**
   * @desc : 手风琴展开事件
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  onChange(event) {
    this.setData({
      activeNames: event.detail,
    });
  },


  /**
   * @desc : checkbox相关事件
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  changeAllReadyCheckBox(e) {
    let key = e.currentTarget.dataset.key
    let currentChoosedItem = this.data.currentChoosedItem
    if (key === 'flgGift') {

      //赠品标识如果选中则把销售价格置为0
      if (currentChoosedItem.cpFlgGift) {
        currentChoosedItem.flgGift = e.detail
        if (e.detail) {
          currentChoosedItem.priceSale_Temp = currentChoosedItem.priceSale
          currentChoosedItem.itemAmount_Temp = currentChoosedItem.itemAmount
          currentChoosedItem.discountStandard_Temp = currentChoosedItem.discountStandard
          currentChoosedItem.discountPromotion_Temp = currentChoosedItem.discountPromotion
          currentChoosedItem.priceSale = 0
          currentChoosedItem.discountStandard = 0
          currentChoosedItem.discountPromotion = 0
          currentChoosedItem.itemAmount = 0
        } else {
          // 恢复到以前的金额
          currentChoosedItem.priceSale = currentChoosedItem.priceSale_Temp
          currentChoosedItem.itemAmount = currentChoosedItem.itemAmount_Temp
          currentChoosedItem.discountStandard = currentChoosedItem.discountStandard_Temp
          currentChoosedItem.discountPromotion = currentChoosedItem.discountPromotion_Temp
        }
      }
    }

    this.setData({
      currentChoosedItem: currentChoosedItem
    })
  },

  /**
   * @desc : 使用位置相关事件
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  changeUseLocation(e) {
    let currentChoosedItem = this.data.currentChoosedItem
    currentChoosedItem.usedLocation = e.detail
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
  },
  /**
   * @desc : 安装送货标识触发事件
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  changeCheckBox(e) {
    let key = e.currentTarget.dataset.key
    let item = e.currentTarget.dataset.item
    let form = this.data.form

    if (key === 'DeliveryFlag') {
      form.DeliveryFlag = !item
      if (!item) {
        form.deliveryTime = util.formatDataTime(new Date(new Date().getTime() + 100))
        this.setData({
          DeliveryFlag_time_flag: true,
          deliveryTimeDefaultSearch: new Date().getTime() + 100

        })
      } else {
        form.deliveryTime = ''
      }

      this.setData({
        form: form
      })
    }

  },
  /**
   * @desc : 标识日期打开事件
   * @author : 于继渤
   * @date : 2022/5/26 17:16
   */
  openData(e) {
    let key = e.currentTarget.dataset.key
    //送货标识
    if (key === 'DeliveryFlag') {
      this.setData({
        DeliveryFlag_time_flag: true
      })
    }
  },



  /**
   * @desc : 标识日期关闭事件
   * @author : 于继渤
   * @date : 2022/5/26 17:16
   */
  onCloseChooseDate(e) {
    let key = e.currentTarget.dataset.key
    //安装标识
    if (key === 'installation') {
      this.setData({
        InstallationFlag_time_flag: false
      })
    }
    //送货标识
    if (key === 'delivery') {
      this.setData({
        DeliveryFlag_time_flag: false
      })
    }
  },


  /**
   * @desc : 标识日期变化事件
   * @author : 于继渤
   * @date : 2022/5/26 17:16
   */
  changeDate(e) {
    let key = e.currentTarget.dataset.key
    //安装标识
    if (key === 'installTime') {
      this.setData({
        installTimeDefaultSearch: e.detail
      })
    }
    //送货标识
    if (key === 'deliveryTime') {
      this.setData({
        deliveryTimeDefaultSearch: e.detail
      })
    }
  },




  /**
   * @desc : 点击改变显示
   * @author : 周兴
   * @date : 2022/11/1 18:16
   */
  changeDisplayText(e) {
    let currentChoosedItem = this.data.currentChoosedItem
    currentChoosedItem.displayTextFlag = !currentChoosedItem.displayTextFlag
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
  },

  /**
   * @desc : 组件关闭事件
   * @author : 于继渤
   * @date : 2022/5/31 18:16
   */
  muticlose(e) { },
  /**
   * @desc : 组件单选确定
   * @author : 王英杰
   * @date : 2023年9月5日
   */
  mutiSearch(e) {
    let id = e.target.id
    let form = this.data.form
    if (id === 'staff') { //责任人
      form.staffName = e.detail.name
      form.staffId = e.detail.id
    }
    if (id === 'org') { //部门
      form.orgName = e.detail.name
      form.orgId = e.detail.id
    }

    this.setData({
      form,
      staffFlag: false,
      orgFlag: false,
    })
  },


  /**
   * @desc : 商品删除
   * @author : 王英杰
   * @date : 2023年9月12日
   */
  onCloseDel(event) { 
    let form = this.data.form 
    let indexdata = event.currentTarget.dataset.fatherindex 
    let indexscan = event.currentTarget.dataset.indexscan 
    let arr = this.data.goodsList
    let barcodeList = this.data.barcodeList

    Dialog.confirm({
      message: '确定删除吗？',
    }).then(() => {
      if (arr[indexdata].itemId) {
        let orderItemDeleteVOListIds = []
        //包含所有明细id
        orderItemDeleteVOListIds.push(arr[indexdata].itemId)
        if (arr[indexdata].goodsSkuList && arr[indexdata].goodsSkuList.length > 0) {
          arr[indexdata].goodsSkuList.forEach(it => {
            orderItemDeleteVOListIds.push(it.itemId)
          })
        }
        form.orderItemDeleteVOList = form.orderItemDeleteVOList.concat(orderItemDeleteVOListIds)
      }
      let deleteList = this.data.deleteList
      if (arr[indexdata].itemId) { //从商品里选没有itemId  只有通过编辑接口查询的会有
        deleteList.push(arr[indexdata])
      }

       //删除扫码信息  从总list中删除
      // 获取行号
      let m = this.data.barcodeList.findIndex(it => it.barcode == arr[indexdata].barcodeList[indexscan].barcode);
      barcodeList.splice(m, 1)
      arr[indexdata].barcodeList.splice(indexscan,1) 
      arr[indexdata].outQuantity = arr[indexdata].outQuantity - 1 

      this.setData({
        deleteList,
        goodsList: arr,
        barcodeList:barcodeList,
        form: form
      })

    })
  },




  /**
   * @desc : 输入事件监听
   * @author : 王英杰
   * @date : 2023年9月12日
   */
  changeField(e) {
    let key = e.currentTarget.dataset.key
    let form = this.data.form
    form[key] = e.detail
    this.setData({
      form,
    })
  },

  /**
   * @desc : 保存前校验
   * @author : 王英杰
   * @date : 2023年9月5日
   */
  beforeSaveCheck(type) {
    let outboundForm = this.data.form.outboundForm
    
    return true

  },


  /**
   * @desc : 确定修改
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  updateToChooseList(e) {
    var goodsList = this.data.goodsList

    var index = this.data.ProductIndex
    var currentChoosedItem = this.data.currentChoosedItem
    goodsList[index].nonGlassList = []
    goodsList[index].nonGlassListShow = ''

    //校验商品数量
    if (currentChoosedItem.outGoingQuantity <= 0) {
      wx.showToast({
        title: '待出库数量不能为0',
        icon: 'none'
      })
      return
    }
    if (currentChoosedItem.outQuantity > currentChoosedItem.outGoingQuantity) {
      wx.showToast({
        title: '本次出库量不能大于待出库量',
        icon: 'none'
      })
      return
    }
    
    if (this.data.form.sale2OpeMode != "分销模式-代送") {
      if (currentChoosedItem.usableQty < currentChoosedItem.outGoingQuantity) {
        wx.showToast({
          title: "当前商品库存可售量不足，无法出库",
          icon: 'none'
        })
        return
      }
    }
    //非标定制品标价参数赋值
    if (currentChoosedItem.nonStandardList && currentChoosedItem.nonStandardList.length > 0) {
      let nonStandardList = util.copyObj(currentChoosedItem.nonStandardList)
      let nonStandardObjList = []
      nonStandardList.forEach(res => {
        let nonStandardObj = {
          fieldId: null,
          fieldCode: null,
          fieldName: null,
          optionCode: null,
          optionName: null,
        }
        nonStandardObj.fieldId = res.fieldId
        nonStandardObj.fieldCode = res.fieldCode
        nonStandardObj.fieldName = res.fieldName
        nonStandardObj.isScope = res.isScope
        //判断是否是范围值
        if (res.isScope == 1) {
          nonStandardObj.optionCode = res.optionCode
          nonStandardObj.optionName = res.optionName
        }
        if (res.options && res.options.length > 0) {
          res.options.forEach(it => {
            if (it.infotype == 'info') {
              nonStandardObj.optionCode = it.code
              nonStandardObj.optionName = it.name
            }
          })
        }
        //没有选择的参数不会设置
        if (nonStandardObj.optionCode) {
          nonStandardObjList.push(nonStandardObj)
        }

      })

      currentChoosedItem.nonGlassList = nonStandardObjList //订单明细字段

      goodsList[index].nonGlassList = nonStandardObjList
      //设置显示非标参数 (展示非标text)
      if (nonStandardObjList && nonStandardObjList.length > 0) {
        let nonGlassListShowTemp = []
        nonStandardObjList.forEach(it => {
          nonGlassListShowTemp.push(it.fieldName + '：' + it.optionName)
        })
        //非标参数显示/匹配命中标价的数据
        // currentChoosedItem.nonGlassListShow =[]
        currentChoosedItem.nonGlassListShow = nonGlassListShowTemp.join('，')
        goodsList[index].nonGlassListShow = nonGlassListShowTemp.join('，')
      }



      goodsList[index].nonStandardList = currentChoosedItem.nonStandardList
      goodsList[index].priceStandard = currentChoosedItem.priceStandard
    }
    goodsList[index].outGoingQuantity = currentChoosedItem.itemQuantity
    goodsList[index].itemQuantity = currentChoosedItem.itemQuantity //商品数量
    goodsList[index].outQuantity = currentChoosedItem.outQuantity
    if (currentChoosedItem.flgNonStandardType == 1 || currentChoosedItem.flgNonStandardType == 2) {
      goodsList[index].nonStandardArea = currentChoosedItem.nonStandardArea //面积
    }

    goodsList[index].usedLocation = currentChoosedItem.usedLocation //使用位置
    goodsList[index].priceSale = currentChoosedItem.priceSale //销售价格
    goodsList[index].flgGift = currentChoosedItem.flgGift //赠品标识
    goodsList[index].nonstandardRemarks = currentChoosedItem.nonstandardRemarks //非标备注
    goodsList[index].remarks = currentChoosedItem.remarks //备注
    goodsList[index].itemAmount = currentChoosedItem.itemAmount //销售金额
    goodsList[index].discountPromotion = currentChoosedItem.discountPromotion //标准售价折扣
    goodsList[index].discountStandard = currentChoosedItem.discountStandard //标价折扣
    if (goodsList[index].goodsSkuList && goodsList[index].goodsSkuList.length > 0) {

      goodsList[index].goodsSkuList.forEach(res => {
        if (currentChoosedItem.flgGift) {
          res.priceSale = 0
        }
        res.warehouseId = currentChoosedItem.warehouseId ? currentChoosedItem.warehouseId : null
        res.warehouseName = currentChoosedItem.warehouseName ? currentChoosedItem.warehouseName : null
        res.whId = currentChoosedItem.whId ? currentChoosedItem.whId : null
        res.whId_Name = currentChoosedItem.warehouseName ? currentChoosedItem.warehouseName : null
        res.itemQuantity = currentChoosedItem.itemQuantity * res.orderItemQuantity
      })

    }

    //使用位置标签功能↓↓↓↓↓
    let tags = this.data.tags
    for (let i = 0; i < tags.length; i++) {
      if (tags[i].usedLocation === currentChoosedItem.usedLocation) {
        tags.splice(i, 1)
      }
    }
    if (currentChoosedItem.usedLocation) {
      currentChoosedItem.usedLocation.replace(/\s*/g, "");
    }
    if (goodsList[index].usedLocation == undefined || goodsList[index].usedLocation == '' || currentChoosedItem.usedLocation.trim() == '') {

    } else {
      tags.push({
        usedLocation: currentChoosedItem.usedLocation
      })
      for (let i = 0; i < goodsList.length; i++) {
        //列表后五个
        if (i >= index && goodsList[i].usedLocation == undefined) {
          goodsList[i].usedLocation = currentChoosedItem.usedLocation
        }
      }
    }
    //使用位置标签功能↑↑↑↑↑↑↑
    this.setData({
      tags: tags,
      goodsList: goodsList,
      showEditProduct: false
    })
    if (!currentChoosedItem.flgGift) {
      this.handleData(goodsList)
    }

    this.setData({
      EditProduct_priceSale_temp: null
    })
    setTimeout(() => {
      // 更新组合中的隐藏的bom信息
      this.updateBomCombined(goodsList[index].goodsSkuList, currentChoosedItem)
    }, 300)
  },
  /**
   * @desc : 更新组合中BOM数量等
   * @author : 周兴
   * @date : 2022/9/20 18:16
   */
  updateBomCombined(goodsSkuList, pRow) {
    if (goodsSkuList && goodsSkuList.length > 0) {
      let filterRows = goodsSkuList.filter(it => it.bomSkuCombined && it.bomSkuCombined.length > 0);
      if (filterRows && filterRows.length > 0) {
        filterRows.forEach(it => {
          // 数量
          it.itemQuantity = Number(pRow.itemQuantity) * Number(it.orderItemQuantity)
          let bomSkuCombined = it.bomSkuCombined;
          let itemAmount = 0;
          let sumVolume = 0;
          let sumWeight = 0;
          let skuVolume = 0;
          let skuWeight = 0;
          bomSkuCombined.forEach(t => {
            let rows = goodsSkuList.filter(row => row.id == t);
            if (rows && rows.length > 0) {
              skuVolume = Number(rows[0].skuVolume) * Number(rows[0].itemQuantity);
              sumVolume += skuVolume;
              skuWeight = Number(rows[0].skuWeight) * Number(rows[0].itemQuantity);
              sumWeight += skuWeight;
              if (rows[0].itemQuantity && rows[0].priceSale) {
                itemAmount += Number(rows[0].itemQuantity) * Number(rows[0].priceSale);
              }
            }
          })
          it.skuVolume = sumVolume;
          it.skuWeight = sumWeight;
          it.itemAmount = itemAmount;
          it.priceSale = it.itemQuantity == 0 ? 0 : (itemAmount / it.itemQuantity).toFixed(2)
          it.discountPromotion = it.pricePromotion == 0 ? 0 : Number((it.priceSale * 100 / it.pricePromotion).toFixed(2));
          it.discountStandard = it.priceStandard == 0 ? 0 : Number((it.priceSale * 100 / it.priceStandard).toFixed(2));
        })
      }
    }

  },
  /**
   * @desc : 处理数据
   * @author : 于继渤
   * @date : 2022/5/31 18:16
   */
  handleData(goodsList) {
    let followFlag = this.data.followFlag;
    if (goodsList != null && goodsList.length > 0) {
      goodsList.forEach(it => {
        // 跟单处理为实际量
        if (followFlag) {
          it.tItemQuantity = it.itemQuantity
          it.tItemAmount = it.itemAmount
        }
        // ***如果有子级，需要处理子级的数据
        if (it.bomItems != null && it.bomItems.length > 0) {

          it.bomItems.forEach(row => {
            row.warehouseId = it.warehouseId ? it.warehouseId : null
            row.warehouseName = it.warehouseName ? it.warehouseName : null
            row.whId_Name = it.warehouseName ? it.warehouseName : null
            row.whId = it.whId ? it.whId : null
            // 数量的处理
            if (followFlag) {
              row.tItemQuantity = it.itemQuantity * row.orderItemQuantity
            } else {
              row.itemQuantity = it.itemQuantity * row.orderItemQuantity
            }
            // 如果单品促销
            if (it.promotionType == Constants.PROMOTION_TYPE.PRMOTION ||
              it.promotionType == Constants.PROMOTION_TYPE.COMBINED) {
              it.pricePromotion = it.pricePromotion ? it.pricePromotion : 0;
              if (it.pricePromotion == 0) {
                row.priceSale = 0
              } else {
                // 销售价（子级）= 销售价（父级）/ 标售售价（父级）* 标售售价（子级）
                row.priceSale = Number(it.priceSale / it.pricePromotion * row.pricePromotion).toFixed(2)
              }
            } else {
              it.priceStandard = it.priceStandard ? it.priceStandard : 0;
              // 正常品
              if (it.priceStandard == 0) {
                row.priceSale = 0
              } else {
                // 销售价（子级）= 销售价（父级）/ 标售售价（父级）* 标售售价（子级）
                row.priceSale = Number(it.priceSale / it.priceStandard * row.priceStandard).toFixed(2)
              }
            }
            if (followFlag) {
              row.tItemAmount = Number(row.priceSale * row.tItemQuantity).toFixed(2)
            } else {
              row.itemAmount = Number(row.priceSale * row.itemQuantity).toFixed(2)
            }

          })
          it.goodsSkuList = it.bomItems
        }
        // **** 如果有组合促销，需要进行数据的处理
        if (it.combinedList != null && it.combinedList.length > 0) {
          it.hasChild = 1; // 说明有子级
          it.goodsSkuList = []
          it.combinedList.forEach(row => {
            row.warehouseId = it.warehouseId ? it.warehouseId : null
            row.warehouseName = it.warehouseName ? it.warehouseName : null
            row.whId_Name = it.warehouseName ? it.warehouseName : null
            row.whId = it.whId ? it.whId : null
            // 如果没有bom，直接加入到goodsSkuList
            if (row.bomItems == null || row.bomItems.length == 0) {
              if (!row.cpFlgGift) {
                // 重新计算价格
                row.priceSale = this.getCombinedSalePrice(it, row);
                // 重新计算折扣
                this.getCombinedDiscount(row);
                // 计算数量
                row.itemQuantity = Number(it.itemQuantity) * Number(row.orderItemQuantity)
                row.itemAmount = Number(row.itemQuantity) * Number(row.priceSale)
                // 跟单处理为实际量
                if (followFlag) {
                  row.tItemQuantity = row.itemQuantity
                  row.tItemAmount = row.itemAmount
                }
              }

              it.goodsSkuList.push(row);
            } else {
              row.bomItems.forEach(ott => {
                ott.warehouseId = it.warehouseId ? it.warehouseId : null
                ott.warehouseName = it.warehouseName ? it.warehouseName : null
                ott.whId_Name = it.warehouseName ? it.warehouseName : null
                ott.whId = it.whId ? it.whId : null
              })



              if (!row.cpFlgGift) {
                row.bomItems.forEach(bRow => {

                  // 重新计算价格
                  bRow.priceSale = this.getCombinedSalePrice(it, bRow);
                  // 重新计算折扣
                  this.getCombinedDiscount(bRow);
                  // 数量的处理
                  bRow.itemQuantity = Number(it.itemQuantity) * Number(bRow.orderItemQuantity)
                  bRow.itemAmount = Number(bRow.priceSale) * Number(bRow.itemQuantity).toFixed(2)
                  if (followFlag) {
                    bRow.tItemQuantity = bRow.itemQuantity
                    bRow.tItemAmount = bRow.itemAmount
                  }

                  it.goodsSkuList.push(bRow);
                })
              }

            }

          })
        }
      })
      // 重新计算最后一条数据的金额，用父级金额-其他条金额合计
      common.countLastAmount(goodsList, false);

    }
    this.setData({
      goodsList: goodsList
    })
  },

  /**
   * @desc : 重新计算组合子件的价格
   * @date : 2022/7/6 16:49
   * @author : 周兴
   */
  getCombinedSalePrice(pRow, row) {
    let priceSale = 0;
    // 销售价（子级）= 销售价（父级）/ 标售售价（父级）* 标售售价（子级）
    if (pRow.pricePromotion == 0) {
      priceSale = 0
    } else {
      // 销售价（子级）= 销售价（父级）/ 标售售价（父级）* 标售售价（子级）
      priceSale = Number(pRow.priceSale / pRow.pricePromotion * row.pricePromotion).toFixed(2)
    }
    return priceSale;
  },

  /**
   * @desc : 计算折扣
   * @date : 2022/7/6 16:49
   * @author : 周兴
   */
  getCombinedDiscount(row) {
    let discountStandard = 0;
    let discountPromotion = 0;
    // 标价折扣= 售价/标价
    if (!row.priceStandard || row.priceStandard == 0) {
      discountStandard = 0;
    } else {
      discountStandard = Number(row.priceSale * 100 / row.priceStandard).toFixed(2)
    }
    // 促销折扣= 售价/促销价
    if (!row.pricePromotion || row.pricePromotion == 0) {
      discountPromotion = 0;
    } else {
      discountPromotion = Number(row.priceSale * 100 / row.pricePromotion).toFixed(2)
    }
    row.discountPromotion = discountPromotion;
    row.discountStandard = discountStandard;
  },
  /**
   * @desc : 商品数量编辑
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  changeAllreadyChooseQuantityPop(e) {
    console.log("changeAllreadyChooseQuantityPop", e)
    let type = e.currentTarget.dataset.type
    let currentChoosedItem = this.data.currentChoosedItem
    if (type == "待出库量") {
      currentChoosedItem.itemQuantity = e.detail
      currentChoosedItem.outGoingQuantity = e.detail
    }
    if (type == "本次出库量") {
      currentChoosedItem.outQuantity = e.detail

    }

    this.setData({
      currentChoosedItem: currentChoosedItem
    })
  },

  /**
   * @desc : 商品编辑信息输入事件
   * @author : 于继渤
   * @date : 2022/5/31 12:16
   */
  changeCurrentChoosedItemField(e) {
    let currentChoosedItem = this.data.currentChoosedItem
    let key = e.currentTarget.dataset.key
    let value = e.detail
    //备注
    if (key === 'remarks') {
      currentChoosedItem.remarks = value
    }
    //非标备注
    if (key === 'nonstandardRemarks') {
      currentChoosedItem.nonstandardRemarks = value
    }
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
  },




  /**
   * @desc : 查询单据多业务归属
   * @author : 于继渤
   * @date : 2022/7/07 16:16
   */
  getOrderMultiOwner(id) {
    api.request(Constants.ORDER_MULTI_OWNER_API + 'select_order_multi_owner', 'POST', {
      orderId: id
    }).then(res => {
      if (res.data.code === 200) {
        let item = res.data.data
        //业务员归属格式化数据(方便选择)
        this.staffItemFormat(item.staffList)
        //业务部门归属格式化数据(方便选择)
        this.orgItemFormat(item.orgList)
        item.staffList.forEach(item => {
          item.ownerFlag = item.ownerType == 3 ? true : false
        })
        item.orgList.forEach(item => {
          item.ownerFlag = item.ownerType == 1 ? true : false
        })
        this.setData({
          staffList: item.staffList,
          organizationList: item.orgList
        })
      }

    })
  },




  /**
   * @desc : 商品展开
   * @author : 于继渤
   * @date : 2022/6/02 16:16
   */
  onChangeOpenGoodsList(e) {
    let goodsList = this.data.goodsList
    let index = e.currentTarget.dataset.index
    goodsList[index].packageDetailsFlag = !goodsList[index].packageDetailsFlag
    this.setData({
      goodsList
    })
  },

  /**
   * @desc : 地图选点
   * @author : 于继渤
   * @date : 2022/5/31 18:16
   */
  onClickAddress(e) {
    let _this = this;
    //弹出腾讯地图选择地址      
    wx.chooseLocation({
      success: res => {
        let location = {
          latitude: res.latitude,
          longitude: res.longitude
        }
        common.reverseGeocoder(location).then(res => {
          if (res) {
            var res = res.result;
            let address = res.address + res.formatted_addresses.recommend;
            let form = _this.data.form;
            // 小区或POI
            form.customerForm.addressName = res.formatted_addresses.recommend;
            form.customerForm.address = address;
            form.customerForm.addressGcj02 = location;
            // 行政区划
            form.customerForm.addressArea = {
              province: res.address_component.province,
              city: res.address_component.city,
              district: res.address_component.district
            }
            _this.setData({
              form: form,
            })
          }
        })
      },
      fial: res => { }
    })

  },

  /**
   * @desc : 小程序地图调用
   * @author : 于继渤
   * @date : 2022/5/31 18:16
   */
  onClickWxchartAddress() {
    this.setData({
      locationFlag: true
    })
    // 跳转新建地图实例
    common.onClickWxchartAddress();
  },
  /**
   * @desc : 编辑商品算折扣
   * @author : 于继渤
   * @date : 2022/5/31 18:16
   */
  editGoodsCalculatedAmount() {
    let currentChoosedItem = this.data.currentChoosedItem
    if (currentChoosedItem.priceSale > 0 && currentChoosedItem.itemPrice > 0) {
      currentChoosedItem.discountStandard = Number((currentChoosedItem.priceSale / currentChoosedItem.itemPrice) * 100).toFixed(2) // 售价/标价
    }
    if (currentChoosedItem.priceSale > 0 && currentChoosedItem.pricePromotion > 0) {
      currentChoosedItem.discountPromotion = Number((currentChoosedItem.priceSale / currentChoosedItem.pricePromotion) * 100).toFixed(2) // 售价/标准
    }
    currentChoosedItem.priceSale = Number(currentChoosedItem.priceSale).toFixed(2)
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
  },
  /**
   * @desc : 编辑商品反算折扣
   * @author : 于继渤
   * @date : 2022/5/31 18:16
   */
  editGoodsCalculatedAmountBack(e) {
    let currentChoosedItem = this.data.currentChoosedItem
    if (e === 'discountStandard') {
      currentChoosedItem.priceSale = Number(currentChoosedItem.itemPrice * (currentChoosedItem.discountStandard / 100)).toFixed(2)
    } else if (e === 'discountPromotion') {
      currentChoosedItem.priceSale = Number(currentChoosedItem.pricePromotion * (currentChoosedItem.discountPromotion / 100)).toFixed(2)
    }
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
  },
  /**
   * @desc : 修改销售金额
   * @author : 周兴
   * @date : 2022/7/4 14:45
   */
  changeItemAmountField(e) {
    let currentChoosedItem = this.data.currentChoosedItem
    currentChoosedItem.itemAmount = e.detail.value // 销售金额赋值
    if (currentChoosedItem.flgNonStandardType == 1 || currentChoosedItem.flgNonStandardType == 2) {

      let nonStandardArea = Number(currentChoosedItem.nonStandardArea)
      //非标

      if (currentChoosedItem.itemQuantity && (currentChoosedItem.itemQuantity > 0) && nonStandardArea && (nonStandardArea > 0)) {
        let tempNumber = Number(currentChoosedItem.itemAmount / currentChoosedItem.itemQuantity).toFixed(2)
        currentChoosedItem.priceSale = Number(tempNumber / currentChoosedItem.nonStandardArea).toFixed(2)

      }
    } else {
      if (currentChoosedItem.itemQuantity && currentChoosedItem.itemQuantity > 0) {
        currentChoosedItem.priceSale = Number(currentChoosedItem.itemAmount / currentChoosedItem.itemQuantity).toFixed(2)
      }
    }

    // 如果销售价格有值，那么赠品标识需要不勾选
    // if (currentChoosedItem.priceSale && currentChoosedItem.priceSale != 0) {
    //     currentChoosedItem.flgGift = false
    // } else {
    //     currentChoosedItem.flgGift = true
    // }
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
    // 计算折扣
    this.getDiscount();
  },
  /**
   * @desc : 刷新折扣
   * @author : 周兴
   * @date : 2022/7/4 14:45
   */
  getDiscount() {
    let currentChoosedItem = this.data.currentChoosedItem
    //标价计算折扣
    if (currentChoosedItem.priceStandard && currentChoosedItem.priceStandard != 0) {
      // 售价/标价
      currentChoosedItem.discountStandard = Number((currentChoosedItem.priceSale / currentChoosedItem.priceStandard) * 100).toFixed(2)
    } else {
      currentChoosedItem.discountStandard = 0
    }

    //促销价计算折扣
    if (currentChoosedItem.discountPromotion && currentChoosedItem.pricePromotion && currentChoosedItem.pricePromotion != 0) {
      // 售价/促销价
      currentChoosedItem.discountPromotion = Number((currentChoosedItem.priceSale / currentChoosedItem.pricePromotion) * 100).toFixed(2)
    } else {
      currentChoosedItem.discountPromotion = 0
    }
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
  },
  /**
   * @desc : 销售价格编辑
   * @author : 于继渤
   * @date : 2022/5/31 14:45
   */
  changeSalesPriceField(e) {
    let priceSale = e.detail.value;
    this.changeSalesPrice(priceSale);
  },
  /**
   * @desc : 修改销售价格
   * @author : 于继渤
   * @date : 2022/7/6 14:45
   */
  changeSalesPrice(priceSale) {
    let currentChoosedItem = this.data.currentChoosedItem
    currentChoosedItem.priceSale = priceSale // 销售价格赋值

    if (currentChoosedItem.nonStandardArea) {
      currentChoosedItem.itemAmount = Number(currentChoosedItem.priceSale * currentChoosedItem.itemQuantity * currentChoosedItem.nonStandardArea).toFixed(2)
    } else {
      currentChoosedItem.itemAmount = Number(currentChoosedItem.priceSale * currentChoosedItem.itemQuantity).toFixed(2)
    }
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
    // 计算折扣
    this.getDiscount();
  },


  getDiscountForm() {
    let form = this.data.form
    let sumStandard = Number(form.sumStandard) //标价合计金额
    let sumAmount = Number(form.sumAmount) //合计金额
    let sumGoodsAmount = Number(form.sumGoodsAmount) //合计金额
    let sumGoodsAmountTemp = Number(form.sumGoodsAmountTemp) //临时合计金额(不包括标价为0的)
    let sumPromotion = Number(form.sumPromotion) //标准价合计金额
    let discountStandard = Number(0)
    // 标价折扣= 合计金额/标价金额
    // 订单开单时，标价为0和负数时，不参与整单折扣的计算
    if (sumStandard > 0 && sumStandard) {
      discountStandard = Number(sumGoodsAmountTemp * 100 / sumStandard).toFixed(2)
    } else {
      discountStandard = 0
    }
    form.discountStandard = discountStandard
    let discountPromotion = Number(100).toFixed(2)
    // 标准价折扣= 合计金额/标准价合计金额
    if (sumPromotion > 0 && sumPromotion) {

      // discountPromotion = Number(sumGoodsAmount * 100 / sumPromotion).toFixed(2)
      //2023/04/20 修改
      discountPromotion = Number(sumGoodsAmountTemp * 100 / sumPromotion).toFixed(2)

    } else {
      discountPromotion = 0
    }
    form.discountPromotion = discountPromotion
    form.discountPromotionTemp = discountPromotion
    form.sumGoodsAmountTemp = sumGoodsAmount
    this.setData({
      form: form
    })
  },
  getOrderTotals(goodsList) {
    let form = this.data.form
    let sumGoodsAmount = 0 // 货物总额
    let sumGoodsAmountTemp = 0 // 货物总额
    let sumQuantity = 0 // 总数量
    let sumStandard = 0 // 标价总额
    let sumPromotion = 0 // 标准价总额
    let categoryQuantityList = [] // 品类数
    goodsList.forEach(res => {
      let priceSale = res.priceSale //销售价格
      let itemQuantity = res.itemQuantity //数量
      sumGoodsAmount += Number(res.itemAmount)
      if (res.priceStandard && res.priceStandard != 0 && res.flgNonStandardType != 1 && res.flgNonStandardType != 2 && !res.cpFlgGift) {
        //计算合计金额忽略标价为0的 非标赠品
        sumGoodsAmountTemp += Number(res.itemAmount)
      }
      // sumStandard += Number(itemQuantity * res.priceStandard)
      // 订单开单时，标价为0和负数时，不参与整单折扣的计算
      if (res.priceStandard && res.priceStandard != 0 && res.priceStandard > 0) {
        if (res.nonStandardArea) {
          sumStandard += Number(res.itemQuantity) * Number(res.priceStandard) * Number(res.nonStandardArea)
        } else {
          sumStandard += Number(res.itemQuantity) * Number(res.priceStandard)
        }
      }
      //2023/04/19 修改
      if (res.pricePromotion && res.pricePromotion > 0) {
        // sumPromotion += Number(itemQuantity * res.pricePromotion)
        if (res.nonStandardArea) {
          sumPromotion += Number(res.itemQuantity) * Number(res.pricePromotion) * Number(res.nonStandardArea)
        } else {
          sumPromotion += Number(res.itemQuantity) * Number(res.pricePromotion)
        }
      } else {
        if (res.nonStandardArea) {
          sumPromotion += Number(res.itemQuantity) * Number(res.priceStandard) * Number(res.nonStandardArea)
        } else {

          console.log(' Number(res.priceStandard)', Number(res.priceStandard))
          sumPromotion += Number(res.itemQuantity) * Number(res.priceStandard)
        }
      }

      // 如果有子级，计算子级的数量
      if (res.goodsSkuList && res.goodsSkuList.length > 0) {
        res.goodsSkuList.forEach(it => {
          if (!it.flgBomCombined) {
            sumQuantity = util.numAdd(Number(sumQuantity), Number(it.itemQuantity * res.orderItemQuantity));
          }

        })
      } else {
        // 如果没有子级，就加上即可
        sumQuantity += Number(res.itemQuantity)
      }
    })

    form.sumGoodsAmount = Number(Number(sumGoodsAmount).toFixed(2))
    form.sumGoodsAmountTemp = Number(Number(sumGoodsAmountTemp).toFixed(2))
    form.sumQuantity = sumQuantity

    form.sumStandard = sumStandard
    form.sumPromotion = sumPromotion
    form.categoryQuantity = common.getCategoryQuantity(goodsList); // 计算品类数
    this.setData({
      form: form
    })
  },


  /**
   * @desc :  生命周期函数--监听页面显示
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  onShow: function () { },

  /**
   * @desc : 打开商品
   * @author : 于继渤
   * @date : 2022/5/26 12:16
   */
  openChoosedItemInfo(e) {
    let item = e.currentTarget.dataset.item
    item.itemQuantity = item.outGoingQuantity
    let index = e.currentTarget.dataset.index
    this.setData({
      usedLocation: item.usedLocation,
      ProductIndex: index,
      currentChoosedItem: item,
      showEditProduct: true,
      EditProduct_priceSale_temp: item.itemAmount
    })

    //非标淋浴房
    if ((item.flgNonStandardType == 1 || item.flgNonStandardType == 2) || (item.nonGlassList && item.nonGlassList.length > 0)) {
      // item.nonStandardList = []
      //加载默认spu非标参数数据
      let copyItem = util.copyObj(item)
      this.getFlgNonStandardList(copyItem)
      this.setData({
        show7: true
      })

      this.getSkuBySpuId(copyItem.spuId)
      this.setData({
        show6: true
      })
    } else {
      this.setData({
        show6: false,
        show7: false
      })
    }
  },
  /**
   * @desc : 根据spuid查询非标参数
   * @author : 于继渤
   * @date : 2022/8/24 13:16
   */
  getFlgNonStandardList(item) {
    let param = {
      spuId: item.spuId,
      cpId: app.globalData.user.cpId
    }
    api.request(Constants.GOODS_SPU_API + 'get_flg_non_standard_list', 'POST', param).then(res => {

      if (res.data.code == 200) {
        let data = res.data.data
        if (data && data.length > 0) {
          data.forEach(item => {
            if (item.options && item.options.value && item.options.value != '[]') {
              item.options = JSON.parse(item.options.value)
              item.options.forEach(it => {
                it.infotype = 'default'
              })
            }
          })
        }
        let dataTemp = util.copyObj(data) //拷贝数据
        let data_nonStandardList = [...data]
        item.nonStandardList = data_nonStandardList
        this.setData({
          nonStandardList: dataTemp
        })
        if (this.data.orderEdit_type == 1) {
          this.setData({
            currentChoosedItem: item,
          })
          //显示查询的参数
          this.setDefault(item)
        } else {

          item.nonGlassListShow = ''
          item.nonGlassList = []
        }
      }
    })
  },
  /**
   * @desc :非标标价设置默认值
   * @date : 2022/8/25 9:56
   * @author : 于继渤
   */
  setDefault(item) {
    //当前选中的商品非标参数数组
    let currentChoosedItem = util.copyObj(item)

    //校验数据不为空 否则报异常
    if (currentChoosedItem.nonStandardList && currentChoosedItem.nonStandardList.length > 0) {
      //视图初始化非标标价组
      let nonStandardList = currentChoosedItem.nonStandardList
      let nonGlassList = currentChoosedItem.nonGlassList
      nonStandardList.forEach(res => {
        let temp = nonGlassList.filter((item) => {
          return item.fieldCode == res.fieldCode;
        })
        if (temp && temp.length > 0 && temp[0].isScope == 0) {

          let options = res.options.filter((it) => {
            return it.code == temp[0].optionCode;
          })
          options[0].infotype = 'info'
        }
        if (temp && temp.length > 0 && temp[0].isScope == 1) {
          res.optionCode = temp[0].optionCode
          res.optionName = temp[0].optionName
        }
      })
      currentChoosedItem.nonStandardList = nonStandardList
      this.setData({
        currentChoosedItem: currentChoosedItem
      })

    } else {

    }

  },

  getSkuBySpuId(spuId) {
    let param = {}
    param.spuId = spuId
    param.cpId = app.globalData.user.cpId;
    param.orgId = app.globalData.user.orgId;
    api.request(Constants.GOODS_SPU_SPECS + 'select_sku_by_spu_id', 'POST', param).then(res => {
      if (res.data.code === 200) {
        if (res.data.data.skuData && res.data.data.skuData.length > 0) {
          let list = util.copyObj(res.data.data.skuData)
          let currentChoosedItem = this.data.currentChoosedItem
          list.forEach(it => {
            if (it.skuId == currentChoosedItem.skuId) {
              it.infotype = 'info'
            }
          })
          this.setData({
            skuData: list,

          })
        }
      }
    })
  },

  /**
   * @desc : 选择非标参数事件
   * @author : 于继渤
   * @date : 2022/8/24 13:16
   */
  nonStandardTap(e) {

    let currentChoosedItem = this.data.currentChoosedItem
    let nonStandardList = currentChoosedItem.nonStandardList
    let pindex = e.currentTarget.dataset.pindex //父索引
    let indext = e.currentTarget.dataset.indext //子索引
    let itemt = e.currentTarget.dataset.itemt //子对象
    nonStandardList[pindex].options.forEach(res => {
      res.infotype = 'default'
    })
    if (itemt.infotype == 'info') {
      return
    }

    nonStandardList[pindex].options[indext].infotype = itemt.infotype == 'info' ? 'default' : 'info'
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
    //设置非标匹配参数
    this.setNonStandardMatchingParameters()
  },

  /**
   * @desc : 设置非标匹配参数
   * @author : 于继渤
   * @date : 2022/8/24 13:16
   */
  setNonStandardMatchingParameters() {
    //当前选择的商品信息
    let currentChoosedItem = this.data.currentChoosedItem
    //非标参数 数组(根据参数不同对应不同数据)
    let nonStandardList = currentChoosedItem.nonStandardList
    //非标参数保存用的 json 数据
    let nonGlassList = []
    let skuData = this.data.skuData
    if (nonStandardList && nonStandardList.length > 0) {
      //判断哪些按钮状态为info 代表当前选中
      nonStandardList.forEach(res => {
        if (res.options && res.options.length > 0) {
          //遍历可选中的参数
          res.options.forEach(item => {
            if (item.infotype == 'info') {
              //选中的数据
              //编辑非标JSON
              nonGlassList.push({
                fieldId: res.fieldId,
                fieldCode: res.fieldCode,
                fieldName: res.fieldName,
                option_code: item.code,
                option_name: item.name,
              })
            }
          })
        }
      })
      currentChoosedItem.nonGlassList = nonStandardList
      //设置显示非标参数 (展示非标text)
      if (nonGlassList && nonGlassList.length > 0) {
        let nonGlassListShowTemp = []
        nonGlassList.forEach(it => {
          // if (it.optionName && it.optionName != undefined) {
          nonGlassListShowTemp.push(it.fieldName + '：' + it.option_name)
          // }

        })
        //非标参数显示/匹配命中标价的数据
        currentChoosedItem.nonGlassListShow = nonGlassListShowTemp.join('，')
      }
      //设置当前sku的所有非标标价数组
      skuData.forEach(res => {
        if (res.skuId == currentChoosedItem.skuId) {
          //赋值
          currentChoosedItem.nonGlassPriceItems = res.nonGlassPriceItems
        }
      })
      //非标商品匹配标价
      this.matchingListPrice(currentChoosedItem, currentChoosedItem.nonGlassPriceItems, currentChoosedItem.nonGlassListShow)
      this.setData({
        currentChoosedItem: currentChoosedItem
      })
    }
  },

  /**
   * @desc : 非标商品匹配标价
   * @author : 于继渤
   * @date : 2022/8/24 13:16
   */
  matchingListPrice(currentChoosedItem, nonGlassPriceItems, nonGlassListShow) {

    if (nonGlassPriceItems && nonGlassPriceItems.length > 0) {
      let flgItemList = [] //匹配到的标价数据
      nonGlassPriceItems.forEach(res => {

        let flag = true
        let nonGlassListShowArr = res.nonGlassListShowArr
        if (nonGlassListShowArr && nonGlassListShowArr.length > 0) {
          res.nonGlassListShowArr.forEach(item => {
            let nonGlassListShowTwo = res.nonGlassListShow.split('，')


            if (nonGlassListShow.indexOf(item) == -1 && res.nonGlassListShow.length != nonGlassListShowArr.length) {
              flag = false
            }
          })
        } else {
          flag = false
        }
        if (flag) {
          flgItemList.push(res)
        }
      })
      //如果匹配到数据 设置默认标价
      if (flgItemList.length > 0) {

        currentChoosedItem.priceStandard = flgItemList[0].itemPrice //标价
        currentChoosedItem.priceSale = currentChoosedItem.priceStandard
        currentChoosedItem.itemAmount = currentChoosedItem.orderItemQuantity * currentChoosedItem.priceSale
        this.getCombinedDiscount(currentChoosedItem)
        //面积计算
        if (currentChoosedItem.nonStandardArea) {
          chooseGoodsCommon.calculateFormulaItemAmount(currentChoosedItem, currentChoosedItem.nonStandardArea)
          this.setData({
            currentChoosedItem: currentChoosedItem
          })
        }
      } else {

        currentChoosedItem.priceStandard = currentChoosedItem.nonGlassPriceDef ? currentChoosedItem.nonGlassPriceDef : Number(0)
        currentChoosedItem.priceSale = currentChoosedItem.priceStandard
        currentChoosedItem.itemAmount = currentChoosedItem.orderItemQuantity * currentChoosedItem.priceSale
      }
    } else {

    }

  },
  /**
   * @desc : 非标商品非标参数输入事件
   * @author : 于继渤
   * @date : 2022/8/24 13:16
   */
  bindInputIsScopeOne(e) {

    let currentChoosedItem = util.copyObj(this.data.currentChoosedItem)
    let nonStandardList = currentChoosedItem.nonStandardList
    let index = e.currentTarget.dataset.pindex //大数组所在索引
    nonStandardList[index].optionName = e.detail.value
    nonStandardList[index].optionCode = e.detail.value
    this.setData({
      currentChoosedItem: currentChoosedItem
    })
  },
  bindBlurIsScopeOne(e) {
    chooseGoodsCommon.bindBlurIsScopeOne(e, this)
  },
  //赠品标识事件
  cpFlgGift_bindtap(e) {

    this.setData({
      cpFlgGiftFlag: true,
      currentSkuChoosedItem: e.detail.item,
      currentSkuChoosedItemIndex: e.detail.index, //父级索引
      currentSkuChoosedItemIndex2: e.detail.index2 //子级索引
    })
  },
  //坑距
  flgAllowSpecsUndefine_bindtap(e) {
    this.setData({
      flgAllowSpecsUndefineFlag: true,
      currentSkuChoosedItem: e.detail.item,
      currentSkuChoosedItemIndexflgAllow: e.detail.index, //父级索引
      currentSkuChoosedItemIndex2flgAllow: e.detail.index2 //子级索引
    })
  },
  closeChoosedItemInfo_flgAllowSpecsUndefine() {
    this.setData({
      flgAllowSpecsUndefineFlag: false
    })
  },
  changeSkuFlgSpecsUndefine(e) {
    let currentSkuChoosedItem = util.copyObj(this.data.currentSkuChoosedItem)
    currentSkuChoosedItem.flgSpecsUndefine = e.detail
    this.setData({
      currentSkuChoosedItem: currentSkuChoosedItem
    })
  },


  formatDate_hours_minutes_seconds(timestamp) {
    // 创建一个新的Date对象
    var date = new Date(timestamp);

    // 获取年、月、日、时、分、秒
    var year = date.getFullYear();
    var month = ('0' + (date.getMonth() + 1)).slice(-2);
    var day = ('0' + date.getDate()).slice(-2);
    var hours = ('0' + date.getHours()).slice(-2);
    var minutes = ('0' + date.getMinutes()).slice(-2);
    var seconds = ('0' + date.getSeconds()).slice(-2);

    // 组合成YY-MM-DD HH:mm:ss格式
    return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
  },

  /**
   * @desc : 暂存-保存
   * @author : 王英杰
   * @date : 2023年8月25日
   */
  allClean(e) {
    // 校验
    let flag = this.beforeSaveCheck(e.type)
    let that = this
    let form = this.data.form
 
    if (flag) {
      let objItem = this.data.form
      //保存前校验 
      let param = { //取部门的这四个属性
        sale1Id: objItem.sale1Id,
        sale2Id: objItem.sale2Id,
        cpId: objItem.cpId,
        ascpId: objItem.ascpId,
      }
      param.outId = objItem.outId
      param.outNo = objItem.outNo
      param.customerId = objItem.customerId
      param.customerName = objItem.customerName
      param.customerPhone = objItem.customerPhone
      param.contactName = objItem.contactName
      param.deliveryPhone = objItem.deliveryPhone
      param.salesChannel = objItem.salesChannel 
      param.orgId = objItem.orgId //部门
      param.orderId = objItem.orderId  
      param.orderNo = objItem.orderNo  
      param.outStatus = 4  //2：出库中 3：已出库 4：出库暂存
      param.sumOutGoingQuantity = objItem.sumOutGoingQuantity  //合计出库中数量
      param.sumOutGoingAmount = objItem.sumOutGoingAmount  //合计出库中金额
      param.sumOutQuantity = objItem.autoOutFlg?objItem.sumOutGoingQuantity:0  //合计已出库数量
      param.sumOutAmount = objItem.autoOutFlg?objItem.sumOutGoingAmount:0 //合计已出库金额
      param.remarks = objItem.remarks||""   //备注
      param.cpId = objItem.cpId  //账套
      param.sale1Id = objItem.sale1Id  //经销商ID
      param.sale2Id = objItem.sale2Id  //分销商ID
      param.ascpId = objItem.ascpId    //所属公司ID
      param.supplierId = "" //供应商ID
      param.outKind = "出库类型-销售"   //出库类型 
      param.outDate = this.formatDate(Date.now())    //出库日期
      param.categoryQuantity = objItem.categoryQuantity   //品类数量 
      param.makingUser = app.globalData.user.userId  //制单人
      param.makingTime = this.formatDate_hours_minutes_seconds(Date.now())//制单时间
      param.doneUser = app.globalData.user.userId   //办理人
      param.doneTime = this.formatDate_hours_minutes_seconds(Date.now()) //办理时间 
      param.salesChannelCode = objItem.salesChannelCode   //销售渠道编码  
      param.deliveryUser = objItem.deliveryUser||""  //送货员   
      param.installUser = objItem.installUser||""   //安装员   
      param.remarksInside =  ""  //内部备注
      param.autoOutFlg = false  //自动出库标识
      param.orderOutItemVOList = this.data.goodsList  //商品明细
      param.allEdit = true  //大编辑
      // 保存和暂存的 扫码数据  全部扫码信息 
      param.barcodeList = this.data.barcodeList || []
      param.annexPaths = this.data.annexPaths  || [] 
      param.orderOutItemDeleteList = []
      api.request(Constants.SALES_OUTBOUND + 'sale_out_update_no_erp', 'POST', param).then(res => {
        this.setData({
          loading: false
        })

        if (res.data.code === 200) {
          wx.navigateBack({
            delta: 1
          })

        }
      })

    }
  },
  /**
   * @desc : 出库-保存
   * @author : 王英杰
   * @date : 2023年8月25日
   */
  submit(e) {
    if(this.data.loading){
      return
    } 
    // 校验
    let flag = this.beforeSaveCheck(e.type)
    let that = this
    let form = this.data.form
    let goodsList = this.data.goodsList
    for (let i = 0; i < goodsList.length; i++) {
      if (goodsList[i].outGoingQuantity != goodsList[i].outQuantity) {
        wx.showToast({ title: '【' + goodsList[i].skuName + '】 的本次出库量不足', icon: 'none' });
        return
      }
    }
    if (flag) {
      let objItem = this.data.form
      //保存前校验 
      let param = { //取部门的这四个属性
        sale1Id: objItem.sale1Id,
        sale2Id: objItem.sale2Id,
        cpId: objItem.cpId,
        ascpId: objItem.ascpId,
      }
      param.outId = objItem.outId
      param.outNo = objItem.outNo
      param.customerId = objItem.customerId
      param.customerName = objItem.customerName
      param.customerPhone = objItem.customerPhone
      param.contactName = objItem.contactName
      param.deliveryPhone = objItem.deliveryPhone
      param.salesChannel = objItem.salesChannel 
      param.orgId = objItem.orgId //部门
      param.orderId = objItem.orderId  
      param.orderNo = objItem.orderNo  
      param.outStatus = 3  //2：出库中 3：已出库 4：出库暂存
      param.sumOutGoingQuantity = objItem.sumOutGoingQuantity  //合计出库中数量
      param.sumOutGoingAmount = objItem.sumOutGoingAmount  //合计出库中金额
      param.sumOutQuantity = objItem.autoOutFlg?objItem.sumOutGoingQuantity:0  //合计已出库数量
      param.sumOutAmount = objItem.autoOutFlg?objItem.sumOutGoingAmount:0 //合计已出库金额
      param.remarks = objItem.remarks||""   //备注
      param.cpId = objItem.cpId  //账套
      param.sale1Id = objItem.sale1Id  //经销商ID
      param.sale2Id = objItem.sale2Id  //分销商ID
      param.ascpId = objItem.ascpId    //所属公司ID
      param.supplierId = "" //供应商ID
      param.outKind = "出库类型-销售"   //出库类型 
      param.outDate = this.formatDate(Date.now())    //出库日期
      param.categoryQuantity = objItem.categoryQuantity   //品类数量 
      param.makingUser = app.globalData.user.userId  //制单人
      param.makingTime = this.formatDate_hours_minutes_seconds(Date.now())//制单时间
      param.doneUser = app.globalData.user.userId   //办理人
      param.doneTime = this.formatDate_hours_minutes_seconds(Date.now()) //办理时间 
      param.salesChannelCode = objItem.salesChannelCode   //销售渠道编码  
      param.deliveryUser = objItem.deliveryUser||""  //送货员   
      param.installUser = objItem.installUser||""   //安装员   
      param.remarksInside =  ""  //内部备注
      param.autoOutFlg = true  //自动出库标识
      param.orderOutItemVOList = this.data.goodsList  //商品明细
      param.allEdit = true  //大编辑
      // 保存和暂存的 扫码数据  全部扫码信息 
      param.barcodeList = this.data.barcodeList || []
      param.annexPaths = this.data.annexPaths  || [] 
      param.orderOutItemDeleteList = []
      this.setData({
        loading: true
      })
      api.request(Constants.SALES_OUTBOUND + 'sale_out_update_no_erp', 'POST', param).then(res => {
        this.setData({
          loading: false
        })
        if (res.data.code === 200) {
          wx.navigateBack({
            delta: 1
          })

        }
      })

    }
  },
  formatDate(dateString) {
    var date = new Date(dateString);
    var year = date.getFullYear();
    var month = ("0" + (date.getMonth() + 1)).slice(-2);
    var day = ("0" + date.getDate()).slice(-2);

    return year + "-" + month + "-" + day;
  },
  /**
  * 消息封装
  */
  showMessage(message) {
    let _this = this
    wx.showModal({
      title: '提示',
      content: message,
      showCancel: false,
      success(res) {
        if (res.confirm) {
          _this.setData({
            scanFunctionIsUseAble: true,
          })
        } else {
          _this.setData({
            scanFunctionIsUseAble: true,
          })
        }
      }
    })
  },
  /**
   * @desc :扫描信息
   */
  takeCode(e) {
    let _this = this
    if (_this.data.goodsList.length > 0) {
      if (_this.data.scanFunctionIsUseAble) {
        // 锁方法
        _this.setData({
          scanFunctionIsUseAble: false,
        })
        let res = e.detail;
        soundUtil.playInnerAudio()
        if (!res.result) {
          wx.vibrateLong({})
          this.showMessage('条码不存在')
          return
        }
        _this.setData({
          loading: true
        })
        let barcode = res.result 
        let param = {
          cpId: app.globalData.user.cpId,
          ascpId: app.globalData.user.ascpId,
          code: barcode,
        }
        api.request(Constants.ORDER_OTHER_GET_SCAN_CODE + 'select_barcode_information', 'POST', param).then(res => {
          _this.setData({
            loading: false
          })
          console.log("select_barcode_information", res.data.data);
          if (res.data.code == 200 && res.data.data.length > 0) {
            setTimeout(function () {
              _this.scanData(res,barcode)
            }, 1000)
          } else {
            wx.vibrateLong({})
            _this.showMessage('条码不存在')
            return
          }
        })

      }
    } else {
      wx.vibrateLong({})
      _this.showMessage('无其他出库数据')
      return;
    }
  },

  /**
    * @desc :扫码添加信息
    * @param {*} CodeID 
    */
  scanData(resScan,barcode) {
    console.log('resScan', resScan,barcode)
    let _this = this
    let goodsList = _this.data.goodsList // 商品
    let scanGoodsList = _this.data.barcodeList || []// 扫码信息 
    let CodeID = resScan.data.data[0].skuId // 唯一值  不管是包还是个 都应该是一个商品  不能出现一个包内出现各种商品。
 
    let OutQuantityNumber = 0; // 对应的单据总共能出库的数量
    let bool = true //查看是否在当前商品中
    let scanBool = true // 用于条码是否已出库  
    // 找到商品
    // 判断扫码信息是否在单据内 并获扫码对应的单据
    goodsList.forEach(res => {
      if (res.skuId == CodeID) {
        bool = false // 找到了商品 赋值false
        // // 获取单据信息
        // 获取单据总共还能出库多少        
        if(resScan.data.data[0].nonStdNum !=null){
          OutQuantityNumber += res.outGoingQuantity - res.outQuantity /  resScan.data.data[0].nonStdNum
        }else{
          OutQuantityNumber += res.outGoingQuantity - res.outQuantity
        }
      }
    }) 
    //异常
    if (bool) {
      wx.vibrateLong({})
      this.showMessage('扫码信息不在当前单据内')
      return
    }
    /// 当前条码已出库
    // 当前商品条形码全部循环 // 可能返回多条数据
    for (let scanIndex = 0; scanIndex < resScan.data.data.length; scanIndex++) {
      let scanCode = resScan.data.data[scanIndex]
      scanBool = true 
      // 返回值 是商品编码的时候 两个值都为空
      if (scanCode.barcode == null || scanCode.barcode == ""){
        scanCode.barcode = barcode
      //  scanCode.boxcode = barcode
      }

      // 判断该单据已经骚的码数据是否以出库
      scanGoodsList.forEach(scan => {
        if (scan.skuId == scanCode.skuId && (
          (scanCode.nonStdCode != '' && scanCode.nonStdCode != null && scanCode.nonStdCode == scan.nonStdCode)
          || (scanCode.nonStdCode == '' || scanCode.nonStdCode == null)
        )
        ) {
          if (scan.barcode == scanCode.barcode) {
            scanBool = false
            return
          }

        }
      })

      if (!scanBool) {
        wx.vibrateLong({})
        this.showMessage('该条码已扫过了，不用重复扫码')
        return
      }
      //判断该条码是否已部分出库扫码 

      //同一天同一类型 已经利库的状态
      if (scanCode.barcodeStatus == 2) {
        wx.vibrateLong({})
        this.showMessage('当前条码已经出库状态')
        return
      }
      else {
        _this.setData({
          scanPartFlag: false,
        })

        // 判断数量是否超过了商品
        if (resScan.data.data.length > OutQuantityNumber) {
          wx.vibrateLong({})
          // app.playInnerAudio(1)
          this.showMessage('当前商品出库数量超出')
          return
        }
        // 运行数据 
        //大码表里查询
        let scanFlag = false
        for (let index = 0; index < goodsList.length; index++) {
          let res = goodsList[index]
          // 扫码返回的非标类型 0标品 1非标淋浴房 2定制浴室柜
          if (scanCode.flgNonStdType == 2) {
            // 原来的BX999999999B99 
            if (res.skuId == CodeID && (res.outQuantity/scanCode.nonStdNum < res.outGoingQuantity)) {
              //2定制浴室柜
              if (scanCode.nonStdCode != '' && scanCode.nonStdCode != null) {
                res.nonStdCode = res.nonStdCode.replace(/\\\\/g, '\\')
                scanCode.nonStdCode = scanCode.nonStdCode.replace(/\\\\/g, '\\')
                // 非标色号
                if (scanCode.nonStdCode == res.nonStdCode) {
                  scanFlag = true
                }
                else {
                  scanFlag = false
                }
              }
              else {
                scanFlag = true
              }

              if (scanFlag) {
                res.checked = true
                res.outQuantity = 1 + res.outQuantity

                res.BoxQuantity = scanCode.nonStdNum
                scanCode.outQuantity = 1 // 出库数量数量  
                scanCode.outItemId = res.itemId // 出库商品ID  
                // 上面已经有了。
                scanCode.nonStdCode =  (res.nonStdCode!=null?res.nonStdCode:'')   // 将明细的色号加入扫码信息中   

                scanGoodsList.push(scanCode)
                // 明细的扫码信息
                if (res.barcodeList==null){
                  res.barcodeList = []
                }
                res.barcodeList.push(scanCode)

                goodsList.splice(index, 1)
                goodsList.unshift(res)

                _this.setData({
                  barcodeList: scanGoodsList,
                  goodsList: goodsList,
                  scanFunctionIsUseAble: true,
                })
                break
              }
            }

          } else {
            if (res.skuId == CodeID && (res.outQuantity < res.outGoingQuantity)) {
              //淋浴房
              if (scanCode.nonStdCode != '' && scanCode.nonStdCode != null) {
                res.nonStdCode = res.nonStdCode.replace(/\\\\/g, '\\')
                scanCode.nonStdCode = scanCode.nonStdCode.replace(/\\\\/g, '\\')
                // 非标色号
                if (scanCode.nonStdCode == res.nonStdCode) {
                  scanFlag = true
                }
                else {
                  scanFlag = false
                }
              }
              else {
                scanFlag = true
              }

              if (scanFlag) {
                res.checked = true
                res.outQuantity = 1 + res.outQuantity 
                scanCode.outQuantity = 1 // 出库数量数量 
                scanCode.outItemId = res.itemId // 出库商品ID  
                scanCode.nonStdCode =  (res.nonStdCode!=null?res.nonStdCode:'')   //将明细的色号加入扫码信息中

                scanGoodsList.push(scanCode)
                 // 明细的扫码信息
                 if (res.barcodeList==null){
                  res.barcodeList = []
                }
                res.barcodeList.push(scanCode)

                goodsList.splice(index, 1)
                goodsList.unshift(res)

                _this.setData({
                  barcodeList: scanGoodsList,
                  goodsList: goodsList,
                  scanFunctionIsUseAble: true,
                })
                console.log("goodsList-barcodeList",this.data.barcodeList,this.data.goodsList);
                break
              }
            }
          }

        }
        if (!scanFlag) {
          //色号匹配不上
          wx.vibrateLong({})
          _this.showMessage('该条码色号与商品不匹配')
          return
        }

      }
    }

  },

  /**
   * @desc : 生命周期函数--监听页面加载
   * @author : 王英杰
   * @date : 2023年9月5日
   */
  onLoad: function (options) { 
 
 
  },
  /**
   * @desc : 出库原因
   * @author : 王英杰
   * @date : 2023年8月22日
   */
  catchtapOutReasons() {
    this.setData({
      outReasonFlag: true
    })
  },
  /**
   * @desc : 责任人（业务员）
   * @author : 王英杰
   * @date : 2023年8月22日
   */
  catchtapStaff() {
    this.setData({
      staffFlag: true
    })
  },
  /**
   * @desc : 部门（业务部门）
   * @author : 王英杰
   * @date : 2023年8月22日
   */
  catchtapOrg() {
    this.setData({
      orgFlag: true
    })
  },
  /**
   * @desc : 小程序出库办理分页查询
   * @author : 王英杰
   * @date : 2023年8月21日
   */
  getData(item) {
    this.setData({
      loading: true
    })

    let param = {
      cpId: app.globalData.user.cpId,
      outId: item.outId,
    }
    param.outId = this.data.item.outId
    api.request(Constants.SALES_OUTBOUND + 'select_sale_out_by_out_id', 'POST', param).then(res => {
      this.setData({
        loading: false
      })

      if (res.data.code === 200) {
 
        let goodsList = res.data.data.orderOutItemResponseList 
      
        let detailData = res.data.data
        detailData.staffId = app.globalData.user.userId
        detailData.staffName =  app.globalData.user.userName
        detailData.orgId = app.globalData.user.orgId
        detailData.orgName =  app.globalData.user.orgName
        if (detailData.deliveryTime) {
          detailData.deliveryTime = (detailData.deliveryTime).replace(/\-/g, "/")
        }
        let annexPaths = res.data.data.annexPaths || []
        let fileList = []
        if(annexPaths){ //把查出的附件 赋值给当前页面 
          annexPaths.forEach(function(item, index, array) {
            fileList.push({"FilePath":item.url,"deletable":true,url:'https://hgscrm-dev.oss-cn-shenzhen.aliyuncs.com/'+item.url})
          })
        }
        let orderAnnexPaths = res.data.data.orderAnnexPaths || []
          let orderfileList = []
          if (orderAnnexPaths) { //把查出的附件 赋值给当前页面 
            orderAnnexPaths.forEach(function (item, index, array) {
              orderfileList.push({
                "FilePath": item.url,
                "deletable": true,
                url: 'https://hgscrm-dev.oss-cn-shenzhen.aliyuncs.com/' + item.url
              })
            })
          }
        let checked_num = 0
        for (let i = 0; i < goodsList.length; i++) {
          if (goodsList[i].outGoingQuantity == goodsList[i].outQuantity) {
            goodsList[i].checked = true
            checked_num++
          }
        }
        if (checked_num == goodsList.length) {
          this.setData({
            checkedSelectAll: true
          })
        }
        this.setData({ 
          goodsList,
          annexPaths, 
          fileList:fileList, 
          orderAnnexPaths, 
          orderfileList:orderfileList, 
          form:detailData,
        })
      }
      // 查询当前单据的扫码信息数据
      this.getScanData()
    })
  },

  /**
   * @desc : 小程序出库-扫码数据
   * @author : 王英杰
   * @date : 2023年8月21日
   */
  getScanData() {
    this.setData({
      loading: true
    })

    let param = {
      cpId: app.globalData.user.cpId,
      ascpId: app.globalData.user.ascpId,
      sale1Id: app.globalData.user.sale1Id,
      sale2Id: app.globalData.user.sale2Id,
    }
    param.outId = this.data.item.outId
    api.request(Constants.ORDER_OTHER_OUT_SCAN_CODE + 'list_by', 'POST', param).then(res => {
      this.setData({
        loading: false
      })
      // 返回值
      if (res.data.code === 200) {
        console.log("list_by", res.data, this.data.goodsList);
        let barcodeList = res.data.data || []
        // 返回 值 按著 明細 放入相應的 明細的 barcodeList
        this.data.goodsList.forEach(gooditem => {
          if (gooditem.barcodeList == null) {
            gooditem.barcodeList = []
          }
          barcodeList.forEach(it => {
            it.itemID = it.outItemId
            it.isNotDelFlg = true //是否能删除
            if (gooditem.itemId == it.outItemId) {              
              gooditem.barcodeList.push(it)
            }
          })
        })

        this.setData({
          barcodeList
        })
      }
    })
  },

  /**
   * 2023/08/16  三期新增代码
   */

  /**
   * @desc : 收货日期
   * @author : 于继渤
   * @date : 2023/08/16 14:45
   */
  onClickDeliveryTime(e) {
    let key = e.currentTarget.dataset.key
    //收货日期
    if (key === 'deliveryTime') {
      this.setData({
        deliveryTimeDefaultSearch: new Date().getTime() + 100,
        deliveryFlag: true
      })
    }

  },
  /**
   * @desc : 收货日期关闭事件
   * @author : 于继渤
   * @date : 2022/5/26 17:16
   */
  onConfirmChooseDateClose() {
    this.setData({
      deliveryFlag: false
    })
  },

  /**
   * @desc : 出库日期确认事件
   * @author : 王英杰
   * @date : 2023年9月5日
   */
  onConfirmChooseDate(e) {
    let key = e.currentTarget.dataset.key
    let form = this.data.form
    if (key === 'deliveryTime') {
      form.outboundForm.deliveryTime = util.formatDataTime(new Date(this.data.deliveryTimeDefaultSearch)).replaceAll('-', '/')
      this.setData({
        deliveryFlag: false,
        form: form
      })
    }
  },



  /**
   * @desc : 折叠面板
   * @author : 王英杰
   * @date : 2023/08/16 14:45
   */
  onChangeCollapse(e) {
    this.setData({
      activeNames: e.detail,
    });
  },



  /**
   * @desc : 选择收货人
   * @author : 于继渤
   * @date : 2023/08/16 14:45
   */
  changeContact() {
    // this.getContactData()
    this.setData({
      contactFlag: true
    })
  },

  /**
   * @desc : 选择出库对象
   * @author : 王英杰
   * @date : 2023年8月18日
   */
  changeWarehousingObject() {
    let that = this
    let pageData = {
      ascpId: that.data.form.ascpId,
      cpId: that.data.form.cpId
    }
    wx.navigateTo({
      url: '/package6/pages/choose-storage-object/choose-storage-object?sourcePage=' + 'warehousingProcessing' + '&title=其他出库' + '&pageData=' + JSON.stringify(pageData),
    })
  },

  /**
   * @desc : 收货人popup关闭
   * @author : 于继渤
   * @date : 2023/08/16 14:45
   */
  closeChoosedItemInfo_contact() {
    this.setData({
      contactFlag: false
    })
  },

  /**
   * @desc : 收货人新建
   * @author : 于继渤
   * @date : 2023/08/16 14:45
   */
  contactAdd() {
    wx.navigateTo({
      url: '/package6/pages/address-management/add/add?type=purchase-orders',
    })
  },
  /**
   * @desc : 收货人选择复选框
   * @author : 于继渤
   * @date : 2023/08/16 14:45
   */
  consigneeSelection(e) {
    let index = e.currentTarget.dataset.index
    let contactList = this.data.contactList
    contactList.forEach((item, index_) => {
      if (index_ === index) {
        item.checked = true
      } else {
        item.checked = false
      }
    })
    this.setData({
      contactList: contactList
    })
  },

  /**
   * @desc : 收货人选择确认
   * @author : 于继渤
   * @date : 2023/08/16 14:45
   */
  contactUpdate() {
    let contactList = this.data.contactList.filter(res => {
      return res.checked
    })

    this.setData({
      contactFlag: false
    })
  },

  /**
   * @desc : 获取收货人地址
   * @author : 于继渤
   * @date : 2023/08/16 14:45
   */
  getContactData(e) {
    this.setData({
      loading: true
    })
    let param = {}
    param.cpId = app.globalData.user.cpId
    param.flgValid = true
    param.customerId = app.globalData.user.sale2CustomerId
    api.request(Constants.SALE_CSM_ADDRESS_API + 'select_by_csm_address_list', 'POST', param).then(res => {
      this.setData({
        loading: false
      })
      if (res.data.code === 200) {
        let list = res.data.data.list; //后台返回数据
        let customerForm = {}
        if (list && list.length > 0) {
          list.forEach(it => {
            if (it.flgDefault) {
              it.checked = true
              customerForm = it
            }
          })
        }
        //客户/收货人 相关信息赋值
        let form = this.data.form


        this.setData({
          contactList: list
        })
      }
    })
  },


  /**
   * @desc : 删除图片
   * @author : 于继渤
   * @date : 2022/5/31 18:16
   */
  deleteImg(e) {
    let index = e.detail.index;
    let arr = this.data.fileList;
    arr.splice(index, 1);
    this.setData({
      fileList: arr
    })
  },

  /**
   * @desc : 图片上传
   * @author : 于继渤
   * @date : 2022/5/31 18:16
   */
  afterRead(event) {
    const _this = this;
    const {
      file
    } = event.detail;
    let annexPaths = _this.data.annexPaths || []
    let arr = _this.data.fileList;
    file.forEach(res => {
      // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
      wx.uploadFile({
        url: `${config.server_add}:${config.server_port}` + '/basic-server/file/upload',
        filePath: res.path,
        name: 'file',
        formData: {
          'folder': 't_order/annex_paths'
        },
        header: {
          'Authorization': 'Bearer ' + app.globalData.token
        },
        success(res) {
          let data = JSON.parse(res.data)
          if (data.code === 200) {

            arr.push({
              url: data.data.absolutelyPath,
              FilePath: data.data.relativePath,
              deletable: true
            })
            let file = data.data.relativePath.split('/')
            annexPaths.push({
              url: data.data.relativePath,
              type: 'image',
              name: file[file.length - 1],
              createTime: util.formatDataTime(new Date())
            })
            _this.setData({
              fileList: arr,
              annexPaths: annexPaths
            })
          }
        },
      })
    })

  },
})