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

  /**
   * 页面的初始数据
   */
  data: {
    annexPaths: [],
    fileList: [],
    flgAllScan: false,
    form: {
      "addressArea": null,
      "addressFull": "辽宁省沈阳市和平区汤玉麟公馆旧址11",
      "addressGcj02": null,
      "addressName": "汤玉麟公馆旧址",
      "addressNo": "11",
      "ageComposition": 98,
      "ageCompositionName": "60后",
      "annexPaths": [],
      "ascpId": 29195,
      "ascpName": null,
      "categoryQuantity": 1,
      "contactName": null,
      "deliveryPhone": "",
      "contractNo": "222222",
      "cpId": 20760,
      "customerFrom": -1,
      "customerId": 3915,
      "customerName": "12.21.01",
      "customerPhone": "45454454444",
      "decisionMaker": 102,
      "decisionMakerName": "女主人",
      "deliveryDate": null,
      "deliveryTime": "2024/01/09 08:00:00",
      "deliveryType": null,
      "deliveryTypeName": null,
      "deliveryUser": null,
      "deliveryUserName": null,
      "docCode": null,
      "doneTime": "2024-01-08 10:54:50",
      "doneUser": 1005,
      "doneUserName": null,
      "erpOutNo": "ZJSA72924010800001",
      "erpPushResult": "操作成功",
      "erpPushStatus": 1,
      "erpPushStatusName": null,
      "fitupStyle": 91,
      "fitupStyleName": "酒店风",
      "fitupType": 87,
      "fitupTypeName": "老房换旧",
      "flgAllowReverse": false,
      "flgAllowTodone": false,
      "flgToErp": false,
      "flgValid": true,
      "fromName": "自然客流",
      "hgcrmPushResult": null,
      "hgcrmPushStatus": null,
      "hgcrmPushStatusName": null,
      "houseType": 84,
      "houseTypeName": "二手房",
      "installUser": null,
      "installUserName": null,
      "makingDate": null,
      "makingTime": "2024-01-08 10:54:55",
      "makingUser": 1005,
      "makingUserName": null,
      "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
      "opAppId": "48849faf-8bbb-4a29-9548-0ba1c3df963f",
      "opCreateTime": "2024-01-08 10:54:55",
      "opCreateTimeEnd": null,
      "opCreateTimeStart": null,
      "opCreateUserId": 1005,
      "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"113.225.142.137\"}",
      "opTimestamp": "2024-01-08 13:32:15",
      "opUpdateTime": "2024-01-08 13:32:13",
      "opUpdateUserId": 254,
      "orderAnnexPaths": [],
      "orderId": 11634,
      "orderNo": "SA-QZHJ-BFJ-202401080ROE",
      "orderOutItemResponseList": [
        {
          "bomSkuId": null,
          "brandName": "恒洁卫浴",
          "canOutQuantity": 1,
          "cpId": 20760,
          "decimalPlaces": null,
          "erpOutItemId": null,
          "erpOutNo": "ZJSA72924010800001",
          "flgNonStandardType": null,
          "flgNonStdType": null,
          "flgScanCode": 0,
          "flgValid": true,
          "iconPathType": null,
          "iconThumPath": "haip/2023-04-21/19ae78a2639547d9aa961b58d20dbdbd.png",
          "itemId": 6076,
          "ivtId": null,
          "ivtQty": 3,
          "ivtUsableQty": 0,
          "nonStandardArea": 1,
          "nonStandardCode": "-",
          "nonStdCode": "-",
          "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
          "opAppId": "48849faf-8bbb-4a29-9548-0ba1c3df963f",
          "opCreateTime": "2024-01-08 10:54:55",
          "opCreateUserId": 1005,
          "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"113.225.142.137\"}",
          "opTimestamp": "2024-01-08 13:32:14",
          "opUpdateTime": "2024-01-08 13:32:13",
          "opUpdateUserId": 254,
          "orderAmount": 999,
          "orderId": 11634,
          "orderItemId": 35171,
          "orderNo": null,
          "orderPriceSale": 999,
          "orderQuantity": 1,
          "originalDocumentNo": null,
          "originalDocumentType": null,
          "originalOutGoingAmount": 999,
          "originalOutGoingQuantity": 1,
          "outAmount": 999,
          "outDate": null,
          "outGoingAmount": 999,
          "outGoingQty": null,
          "outGoingQuantity": 1,
          "outId": 3325,
          "outQuantity": 1,
          "outStatus": 3,
          "outStatusName": null,
          "refCostAmt": 3078,
          "refCostPrice": 3078,
          "rejectAmount": 0,
          "rejectId": null,
          "rejectItemId": null,
          "rejectQuantity": 0,
          "remarks": null,
          "skuCode": "EE920A00200B01",
          "skuId": 9537580,
          "skuModel": "HE920",
          "skuName": "【已淘汰】智能盖板HE920",
          "skuSpecs": " ",
          "skuType": 0,
          "skuTypeName": "智能马桶\\智能盖板",
          "skuVolume": null,
          "skuWeight": null,
          "soutId": null,
          "soutItemId": null,
          "specsList": [],
          "specsName": "智能盖板",
          "specsValues": null,
          "spuId": null,
          "titleTag": "HEGII",
          "unitName": null,
          "usableQty": 1,
          "whId": 552,
          "whName": "钦州运营仓",
          "entryGoingAmount": null,
          "barcodeList": []
        },
        {
          "bomSkuId": 161052,
          "brandName": "恒洁卫浴",
          "canOutQuantity": 1,
          "cpId": 20760,
          "decimalPlaces": null,
          "erpOutItemId": null,
          "erpOutNo": "ZJSA72924010800001",
          "flgNonStandardType": null,
          "flgNonStdType": null,
          "flgScanCode": 0,
          "flgValid": true,
          "iconPathType": null,
          "iconThumPath": null,
          "itemId": 6077,
          "ivtId": null,
          "ivtQty": null,
          "ivtUsableQty": null,
          "nonStandardArea": null,
          "nonStandardCode": "-",
          "nonStdCode": "-",
          "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
          "opAppId": "48849faf-8bbb-4a29-9548-0ba1c3df963f",
          "opCreateTime": "2024-01-08 10:54:55",
          "opCreateUserId": 1005,
          "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"113.225.142.137\"}",
          "opTimestamp": "2024-01-08 13:32:15",
          "opUpdateTime": "2024-01-08 13:32:13",
          "opUpdateUserId": 254,
          "orderAmount": 3303,
          "orderId": 11634,
          "orderItemId": 35172,
          "orderNo": null,
          "orderPriceSale": 3303,
          "orderQuantity": 1,
          "originalDocumentNo": null,
          "originalDocumentType": null,
          "originalOutGoingAmount": 3303,
          "originalOutGoingQuantity": 1,
          "outAmount": 3303,
          "outDate": null,
          "outGoingAmount": 3303,
          "outGoingQty": null,
          "outGoingQuantity": 1,
          "outId": 3325,
          "outQuantity": 1,
          "outStatus": 3,
          "outStatusName": null,
          "refCostAmt": 3303,
          "refCostPrice": 3303,
          "rejectAmount": 0,
          "rejectId": null,
          "rejectItemId": null,
          "rejectQuantity": 0,
          "remarks": null,
          "skuCode": "CT901DT2200B01",
          "skuId": 9605810,
          "skuModel": "HC0901DT-0",
          "skuName": "落地式坐便器HC0901DT\\地排305\\无盖板",
          "skuSpecs": " ",
          "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": "钦州运营仓",
          "entryGoingAmount": null,
          "barcodeList": []
        },
        {
          "bomSkuId": 161052,
          "brandName": "恒洁卫浴",
          "canOutQuantity": 1,
          "cpId": 20760,
          "decimalPlaces": null,
          "erpOutItemId": null,
          "erpOutNo": "ZJSA72924010800001",
          "flgNonStandardType": null,
          "flgNonStdType": null,
          "flgScanCode": 0,
          "flgValid": true,
          "iconPathType": null,
          "iconThumPath": null,
          "itemId": 6078,
          "ivtId": null,
          "ivtQty": null,
          "ivtUsableQty": null,
          "nonStandardArea": null,
          "nonStandardCode": "-",
          "nonStdCode": "-",
          "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
          "opAppId": "48849faf-8bbb-4a29-9548-0ba1c3df963f",
          "opCreateTime": "2024-01-08 10:54:55",
          "opCreateUserId": 1005,
          "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"113.225.142.137\"}",
          "opTimestamp": "2024-01-08 13:32:15",
          "opUpdateTime": "2024-01-08 13:32:13",
          "opUpdateUserId": 254,
          "orderAmount": 4450,
          "orderId": 11634,
          "orderItemId": 35173,
          "orderNo": null,
          "orderPriceSale": 4450,
          "orderQuantity": 1,
          "originalDocumentNo": null,
          "originalDocumentType": null,
          "originalOutGoingAmount": 4450,
          "originalOutGoingQuantity": 1,
          "outAmount": 4450,
          "outDate": null,
          "outGoingAmount": 4450,
          "outGoingQty": null,
          "outGoingQuantity": 1,
          "outId": 3325,
          "outQuantity": 1,
          "outStatus": 3,
          "outStatusName": null,
          "refCostAmt": 4450,
          "refCostPrice": 4450,
          "rejectAmount": 0,
          "rejectId": null,
          "rejectItemId": null,
          "rejectQuantity": 0,
          "remarks": null,
          "skuCode": "CQ501000000N01",
          "skuId": 9607630,
          "skuModel": null,
          "skuName": "电控盖板HQ501",
          "skuSpecs": " ",
          "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": "钦州运营仓",
          "entryGoingAmount": null,
          "barcodeList": []
        }
      ],
      "orgId": 32402,
      "orgName": "北海富安居店",
      "outDate": "2024-01-08",
      "outId": 3325,
      "outKind": "出库类型-销售",
      "outKindName": null,
      "outNo": "WO-QZHJ-000-202401080ROF",
      "outObjectId": null,
      "outObjectName": null,
      "outObjectType": null,
      "outReason": null,
      "outReasonName": null,
      "outServiceType": null,
      "outStatus": 3,
      "outStatusName": null,
      "rejectId": null,
      "rejectNo": null,
      "remarks": null,
      "remarksInside": null,
      "returnAddressFull": null,
      "returnContactName": null,
      "returnContactPhone": null,
      "sale1Id": 20760,
      "sale2EntryWhId": null,
      "sale2Id": 29195,
      "sale2OpeMode": "分销模式-代送",
      "salesChannel": 1,
      "salesChannelCode": null,
      "serviceType": 1,
      "serviceTypeName": "送安一体",
      "soutId": null,
      "staffId": 643,
      "staffName": "王英杰",
      "sumAmount": null,
      "sumOutAmount": 8752,
      "sumOutGoingAmount": 8752,
      "sumOutGoingQuantity": 3,
      "sumOutQuantity": 3,
      "sumQuantity": 3,
      "sumRejectAmount": null,
      "sumRejectQuantity": null,
      "supplierId": null,
      "supplierName": null,
      "toiletCount": 2,
      "toiletCountName": null,
      "sumEntryGoingAmount": null,
      "sumEntryGoingQuantity": null
    },
    goodsList: [
      {
        "bomSkuId": null,
        "brandName": "恒洁卫浴",
        "canOutQuantity": 1,
        "cpId": 20760,
        "decimalPlaces": null,
        "erpOutItemId": null,
        "erpOutNo": "ZJSA72924010800001",
        "flgNonStandardType": null,
        "flgNonStdType": null,
        "flgScanCode": 0,
        "flgValid": true,
        "iconPathType": null,
        "iconThumPath": "haip/2023-04-21/19ae78a2639547d9aa961b58d20dbdbd.png",
        "itemId": 6076,
        "ivtId": null,
        "ivtQty": 3,
        "ivtUsableQty": 0,
        "nonStandardArea": 1,
        "nonStandardCode": "-",
        "nonStdCode": "-",
        "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
        "opAppId": "48849faf-8bbb-4a29-9548-0ba1c3df963f",
        "opCreateTime": "2024-01-08 10:54:55",
        "opCreateUserId": 1005,
        "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"113.225.142.137\"}",
        "opTimestamp": "2024-01-08 13:32:14",
        "opUpdateTime": "2024-01-08 13:32:13",
        "opUpdateUserId": 254,
        "orderAmount": 999,
        "orderId": 11634,
        "orderItemId": 35171,
        "orderNo": null,
        "orderPriceSale": 999,
        "orderQuantity": 1,
        "originalDocumentNo": null,
        "originalDocumentType": null,
        "originalOutGoingAmount": 999,
        "originalOutGoingQuantity": 1,
        "outAmount": 999,
        "outDate": null,
        "outGoingAmount": 999,
        "outGoingQty": null,
        "outGoingQuantity": 1,
        "outId": 3325,
        "outQuantity": 1,
        "outStatus": 3,
        "outStatusName": null,
        "refCostAmt": 3078,
        "refCostPrice": 3078,
        "rejectAmount": 0,
        "rejectId": null,
        "rejectItemId": null,
        "rejectQuantity": 0,
        "remarks": null,
        "skuCode": "EE920A00200B01",
        "skuId": 9537580,
        "skuModel": "HE920",
        "skuName": "【已淘汰】智能盖板HE920",
        "skuSpecs": " ",
        "skuType": 0,
        "skuTypeName": "智能马桶\\智能盖板",
        "skuVolume": null,
        "skuWeight": null,
        "soutId": null,
        "soutItemId": null,
        "specsList": [],
        "specsName": "智能盖板",
        "specsValues": null,
        "spuId": null,
        "titleTag": "HEGII",
        "unitName": null,
        "usableQty": 1,
        "whId": 552,
        "whName": "钦州运营仓",
        "entryGoingAmount": null,
        "barcodeList": []
      },
      {
        "bomSkuId": 161052,
        "brandName": "恒洁卫浴",
        "canOutQuantity": 1,
        "cpId": 20760,
        "decimalPlaces": null,
        "erpOutItemId": null,
        "erpOutNo": "ZJSA72924010800001",
        "flgNonStandardType": null,
        "flgNonStdType": null,
        "flgScanCode": 0,
        "flgValid": true,
        "iconPathType": null,
        "iconThumPath": null,
        "itemId": 6077,
        "ivtId": null,
        "ivtQty": null,
        "ivtUsableQty": null,
        "nonStandardArea": null,
        "nonStandardCode": "-",
        "nonStdCode": "-",
        "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
        "opAppId": "48849faf-8bbb-4a29-9548-0ba1c3df963f",
        "opCreateTime": "2024-01-08 10:54:55",
        "opCreateUserId": 1005,
        "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"113.225.142.137\"}",
        "opTimestamp": "2024-01-08 13:32:15",
        "opUpdateTime": "2024-01-08 13:32:13",
        "opUpdateUserId": 254,
        "orderAmount": 3303,
        "orderId": 11634,
        "orderItemId": 35172,
        "orderNo": null,
        "orderPriceSale": 3303,
        "orderQuantity": 1,
        "originalDocumentNo": null,
        "originalDocumentType": null,
        "originalOutGoingAmount": 3303,
        "originalOutGoingQuantity": 1,
        "outAmount": 3303,
        "outDate": null,
        "outGoingAmount": 3303,
        "outGoingQty": null,
        "outGoingQuantity": 1,
        "outId": 3325,
        "outQuantity": 1,
        "outStatus": 3,
        "outStatusName": null,
        "refCostAmt": 3303,
        "refCostPrice": 3303,
        "rejectAmount": 0,
        "rejectId": null,
        "rejectItemId": null,
        "rejectQuantity": 0,
        "remarks": null,
        "skuCode": "CT901DT2200B01",
        "skuId": 9605810,
        "skuModel": "HC0901DT-0",
        "skuName": "落地式坐便器HC0901DT\\地排305\\无盖板",
        "skuSpecs": " ",
        "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": "钦州运营仓",
        "entryGoingAmount": null,
        "barcodeList": []
      },
      {
        "bomSkuId": 161052,
        "brandName": "恒洁卫浴",
        "canOutQuantity": 1,
        "cpId": 20760,
        "decimalPlaces": null,
        "erpOutItemId": null,
        "erpOutNo": "ZJSA72924010800001",
        "flgNonStandardType": null,
        "flgNonStdType": null,
        "flgScanCode": 0,
        "flgValid": true,
        "iconPathType": null,
        "iconThumPath": null,
        "itemId": 6078,
        "ivtId": null,
        "ivtQty": null,
        "ivtUsableQty": null,
        "nonStandardArea": null,
        "nonStandardCode": "-",
        "nonStdCode": "-",
        "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
        "opAppId": "48849faf-8bbb-4a29-9548-0ba1c3df963f",
        "opCreateTime": "2024-01-08 10:54:55",
        "opCreateUserId": 1005,
        "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"113.225.142.137\"}",
        "opTimestamp": "2024-01-08 13:32:15",
        "opUpdateTime": "2024-01-08 13:32:13",
        "opUpdateUserId": 254,
        "orderAmount": 4450,
        "orderId": 11634,
        "orderItemId": 35173,
        "orderNo": null,
        "orderPriceSale": 4450,
        "orderQuantity": 1,
        "originalDocumentNo": null,
        "originalDocumentType": null,
        "originalOutGoingAmount": 4450,
        "originalOutGoingQuantity": 1,
        "outAmount": 4450,
        "outDate": null,
        "outGoingAmount": 4450,
        "outGoingQty": null,
        "outGoingQuantity": 1,
        "outId": 3325,
        "outQuantity": 1,
        "outStatus": 3,
        "outStatusName": null,
        "refCostAmt": 4450,
        "refCostPrice": 4450,
        "rejectAmount": 0,
        "rejectId": null,
        "rejectItemId": null,
        "rejectQuantity": 0,
        "remarks": null,
        "skuCode": "CQ501000000N01",
        "skuId": 9607630,
        "skuModel": null,
        "skuName": "电控盖板HQ501",
        "skuSpecs": " ",
        "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": "钦州运营仓",
        "entryGoingAmount": null,
        "barcodeList": []
      }
    ],
    item: {
      "addressArea": null,
      "addressFull": "辽宁省沈阳市和平区汤玉麟公馆旧址11111",
      "addressGcj02": null,
      "addressName": null,
      "addressNo": null,
      "ageComposition": null,
      "ageCompositionName": null,
      "annexPaths": [],
      "ascpId": 29195,
      "ascpName": "无库无ERP00001",
      "categoryQuantity": null,
      "contactName": null,
      "deliveryPhone": "",
      "contractNo": "222222",
      "cpId": 20760,
      "customerFrom": null,
      "customerId": null,
      "customerName": "12.21.01",
      "customerPhone": "45454454444",
      "decisionMaker": null,
      "decisionMakerName": null,
      "deliveryDate": null,
      "deliveryTime": "2024/01/09 08:00:00",
      "deliveryType": null,
      "deliveryTypeName": null,
      "deliveryUser": null,
      "deliveryUserName": null,
      "docCode": "销售订单",
      "doneTime": "2024-01-08 10:54:50",
      "doneUser": 1005,
      "doneUserName": "无库无ERP00001",
      "erpOutNo": "ZJSA72924010800001",
      "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-08",
      "makingTime": "2024/01/08 10:54:55",
      "makingUser": 1005,
      "makingUserName": "无库无ERP00001",
      "opApiId": "ebf22701-3e48-48b6-8bdd-703a58bc4e42",
      "opAppId": "48849faf-8bbb-4a29-9548-0ba1c3df963f",
      "opCreateTime": "2024-01-08 10:54:55",
      "opCreateTimeEnd": null,
      "opCreateTimeStart": null,
      "opCreateUserId": 1005,
      "opDbUser": "{\"usesysid\":\"6376246\",\"usename\":\"hgscrm\",\"application_name\":\"PostgreSQL JDBC Driver\",\"client_addr\":\"113.225.142.137\"}",
      "opTimestamp": "2024-01-08 13:32:15",
      "opUpdateTime": "2024-01-08 13:32:13",
      "opUpdateUserId": 254,
      "orderAnnexPaths": null,
      "orderId": 11634,
      "orderNo": "SA-QZHJ-BFJ-202401080ROE",
      "orderOutItemResponseList": null,
      "orgId": 32402,
      "orgName": "北海富安居店",
      "outDate": "2024-01-08",
      "outId": 3325,
      "outKind": "出库类型-销售",
      "outKindName": "销售出库",
      "outNo": "WO-QZHJ-000-202401080ROF",
      "outObjectId": 3915,
      "outObjectName": "12.21.01",
      "outObjectType": 1,
      "outReason": null,
      "outReasonName": null,
      "outServiceType": null,
      "outStatus": 3,
      "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": 8752,
      "sumOutGoingAmount": 8752,
      "sumOutGoingQuantity": 3,
      "sumOutQuantity": 3,
      "sumQuantity": null,
      "sumRejectAmount": 0,
      "sumRejectQuantity": 0,
      "supplierId": null,
      "supplierName": null,
      "toiletCount": null,
      "toiletCountName": null
    },
    loading: false,
    sacnFlag: false,
    barcodeList: []
  },
    /**
    * @desc : 展开,收起更多功能事件
    * @author : 于继渤
    * @date : 2022/5/26 12:16
    */
   listToggle() {
    this.setData({
      showMore: !this.data.showMore
    })
  },
   /**
   * @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.form.outId
    api.request(Constants.ORDER_OTHER_OUT_SCAN_CODE + 'list_by', 'POST', param).then(res => {
      this.setData({
        loading: false
      })
      // 返回值
      if (res.data.code === 200) {
        let barcodeList = res.data.data || []
         
        // 返回 值 按著 明細 放入相應的 明細的 barcodeList
       
        this.data.goodsList.forEach(gooditem => {
          if (gooditem.barcodeList == null) {
            gooditem.barcodeList = []
          }
          barcodeList.forEach(it => {
            if (gooditem.itemId == it.outItemId) {
              gooditem.barcodeList.push(it)
            }
          })
        })
        //  条码 是否全部扫描完成
        let flgAllScan = true
        // 条码 是否全部扫描
        for (let index = 0; index < this.data.goodsList.length; index++) {
          const gooditem = this.data.goodsList[index];
          if (gooditem.flgNonStdType == 2) {
            if (gooditem.barcodeList.length == 0
              || gooditem.outQuantity != gooditem.barcodeList.length / gooditem.barcodeList[0].nonStdNum) {
              flgAllScan = false
              break
            }
          } else {
            if (gooditem.outQuantity != gooditem.barcodeList.length ) {
              flgAllScan = false
              break
            }
          }
        } 
        this.setData({
          barcodeList,
          flgAllScan
        })
      }
    })
  },
      /**查看条码里的收起  展开 */
      onClickScan(e){
        let barList = this.data.goodsList
        barList[e.currentTarget.dataset.index].checked = !barList[e.currentTarget.dataset.index].checked
        this.setData({
          goodsList: barList
        })
      },
      /**关闭查看条码 */
      closeChoosedItemInfo_scan(){
        this.setData({
          sacnFlag: false
        })
      },
// 补码扫描 查看
openSacn(e) {
  if (this.data.flgAllScan){
    this.setData({
      sacnFlag: true, 
    })
  }else{
    let outId = this.data.form.outId
    wx.navigateTo({
      url: '/package7/pages/supplementary_scan_barcode/supplementary_scan_barcode?outId=' + outId,
    })
  }
  
},
  /**
   * @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
            })
          }
        },
      })
    })

  },
   /**
   * @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,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {  },
    /**计算商品相关的属性 */
    countGoodsList(List) { 
      let goodsList = []
      let sumGoodsAmount = 0
      let sumEntryGoingQuantity = 0
      // 
      List.forEach(function (res, index) {
        if (res.bomItems) { //bom品进入
          res.bomItems.forEach(item => {
            item.itemQuantity = item.bomItemQuantity //入库中数量
            item.entryGoingQuantity = item.bomItemQuantity //入库中数量
            item.whId = res.whId //仓库
            item.whName = res.whName //仓库
            item.orderPriceSale = item.orderPriceSale ? item.orderPriceSale : 0 //入库单价
            item.entryGoingAmount = item.entryGoingQuantity * parseFloat(item.orderPriceSale)
            sumGoodsAmount += item.entryGoingAmount
            sumEntryGoingQuantity += item.entryGoingQuantity
            goodsList.push(item)
          })
        } else { //正常品进入
          res.entryGoingQuantity = res.itemQuantity //入库中数量
          res.orderPriceSale = res.orderPriceSale ? res.orderPriceSale : 0 //入库单价
          res.entryGoingAmount = res.entryGoingQuantity * parseFloat(res.orderPriceSale);
          sumGoodsAmount += res.entryGoingAmount
          sumEntryGoingQuantity += res.entryGoingQuantity
          goodsList.push(res)
        }
  
      })
      let form = this.data.form
      form.sumEntryGoingAmount = sumGoodsAmount
      form.sumEntryGoingQuantity = sumEntryGoingQuantity
      form.categoryQuantity = common.getCategoryQuantity(goodsList); // 计算品类数
      form.sumQuantity = goodsList.length
      this.setData({
        form: form,
  
      })
      this.setData({
        goodsList: goodsList,
      })
    },

    /** 转日期格式为 yy-mm-dd*/
    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;
    },
    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日
  */
  deal(e) {
    if(this.data.loading){
      return
    }
    let form = this.data.form
    let param = {
      sale1Id: form.sale1Id,
      sale2Id: form.sale2Id,
      cpId: form.cpId,
      ascpId: form.ascpId,
    }
    param.outId = this.data.item.outId
    this.setData({
      loading: true
    })
    api.request(Constants.SALES_OUTBOUND + 'sale_out_back_no_erp', 'POST', param).then(res => {
      this.setData({
        loading: false
      })

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

      }
    })
  },
   // 小编辑保存 
  submit(e) {
    // 校验
    let flag = this.beforeSaveCheck(e.type)
    let that = this 
    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 = objItem.outStatus  //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.orderOutItemVOList = this.data.goodsList  //商品明细
      param.allEdit = false  //大编辑
      // 保存和暂存的 扫码数据  全部扫码信息 
      param.barcodeList = this.data.barcodeList || []
      param.annexPaths = this.data.annexPaths  || [] 
      param.orderOutItemDeleteList = []
      param.remarksInside =   objItem.remarksInside||""  //内部备注
      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
          })

        }
      })

    }
  },
 
 
})