<template>
  <div>
    <div
      class="col userInp"
      style="display: flex; align-items: center"
      v-if="objData.packInfo"
    >
      <div class="label lable150 rx-cc" style="width: 100px !important"
        >是否拆包：</div
      >
      <span
        v-if="objData.packInfo.isUnpack == '1'"
        style="
          color: green;
          font-size: 14px;
          font-weight: 700;
          margin-left: 15px;
        "
        >是</span
      >

      <span
        v-else-if="objData.packInfo.isNewUnpack == 1"
        style="
          color: green;
          font-size: 14px;
          font-weight: 700;
          margin-left: 15px;
        "
        >手动拆包</span
      >
      <span
        v-else
        style="
          color: green;
          font-size: 14px;
          font-weight: 700;
          margin-left: 15px;
        "
        >否</span
      >
    </div>

    <div
      class="col userInp"
      style="display: flex; align-items: center"
      v-if="!storeType && objData.packInfo.isUnpack == '1'"
    >
      <div class="label lable150 rx-cc" style="width: 100px !important"
        >规格</div
      >
      <span style="width: 200px">{{
        objData.packInfo ? objData.packInfo.specText : ''
      }}</span>
      <div class="label lable150 rx-cc" style="width: 100px !important"
        >包装：</div
      >
      <el-select
        v-model="warehouseId"
        placeholder="请选择"
        @change="changeWarehouseType"
        :disabled="isDetails"
        v-if="!objData.packInfo.packUnitInfo"
      >
        <el-option
          v-for="item in warehouseSpecTypeList"
          :key="item.value"
          :label="item.text"
          :value="item.value"
        >
        </el-option>
      </el-select>

      <span v-else>{{
        objData.packInfo.packUnitInfo ? objData.packInfo.packUnitInfo : ''
      }}</span>
      <!-- multiple -->
      <!-- <zxz-uni-data-select :localdata="localdataList" v-model="Usertype"
				@change="changeUserType"></zxz-uni-data-select> -->
    </div>
    <div
      v-if="
        warehouseId != 1 &&
        objData.packInfo.isUnpack == '1' &&
        objData.packInfo.isNewUnpack != 1
      "
    >
      <div v-for="(item, i) in DispositionList" :key="i">
        <div class="title_box rx-bc mt6">
          <div class="name">{{ item.titel }}</div>

          <div class="rx-bc"> </div>
        </div>

        <div>
          <div class="material">
            <div class="content_table">
              <div class="item">
                <div class="lable rx-cc">包装总数 </div>
                <div class="content content_num">
                  <span>{{ totalNumber }}</span>
                  <div class="unit">{{ item.packageUnit }}</div>
                </div>
              </div>

              <div class="item rx-sc">
                <div class="rx ww55">
                  <div class="lable lable200 rx-cc">{{ item.titel }}单元</div>
                  <div class="content content_num">
                    <el-input
                      class="uni-el-input"
                      v-model="item.packageCell"
                      disabled
                      style="width: 160px"
                    ></el-input>
                    <div class="unit">{{ item.packageUnit }}</div
                    >/<div class="unit">{{ item.conversionUnit }}</div>
                  </div>
                </div>

                <div class="rx ww55" v-if="isReelSpecification">
                  <div class="lable lable200 rx-cc">盘具规格：</div>
                  <div class="content content_num">
                    <el-input
                      class="uni-el-input"
                      v-model="item.reelSpecification"
                      style="width: 160px"
                      disabled
                    ></el-input>
                  </div>
                </div>
              </div>
            </div>

            <div v-if="item.splitList.length">
              <ele-pro-table
                ref="table"
                :needPage="false"
                :columns="columnsMin"
                :datasource="item.splitList"
                class="time-form"
                max-height="400"
                row-key="index"
              >
                <template v-slot:feedQuantity="{ row, $index }">
                  <span>{{ row.feedQuantity }}{{ row.unit }}</span>
                </template>
              </ele-pro-table>
              <!-- <el-table :data="item.splitList" style="width: 100%">
              <el-table-column prop="computeSize" label="序号" width="65">
                <template v-slot="{ row, $index }">
                  {{ $index + 1 }}
                </template>
              </el-table-column>
              <el-table-column prop="name" label="数量"> </el-table-column>
              <el-table-column prop="totalQuantity" label="计量数" width="100">
              </el-table-column>
              <el-table-column prop="code" label="条码"> </el-table-column>
            </el-table> -->
            </div>
          </div>
        </div>

        <!-- <SearchPopup mode="center" v-if='show'>
			<template v-slot:list>
				<div class="search_list">

					<u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">

						<u-form-item label="外包装数:" class="required-form" borderBottom prop="assetType">
							<el-input class="uni-el-input" v-model="formData.wPackNum" style="width: 280rpx;"
								placeholder="外包装数"></el-input> / {{ splitList[0].unit }}
						</u-form-item>

					</u-form>

				</div>
			</template>

<template v-slot:operate>
				<div class="operate_box rx-bc">
					<u-button size="small" class="u-reset-button" @click="calculationClose()">
						取消
					</u-button>

					<u-button type="success" size="small" class="u-reset-button" @click="calculationReset()">
						重置
					</u-button>


					<u-button type="success" size="small" class="u-reset-button" @click="calculationSave()">
						确定
					</u-button>

				</div>
			</template>

</SearchPopup> -->
      </div>
    </div>

    <div v-if="warehouseId != 1 && objData.packInfo.isNewUnpack == 1">
      <div class="title_box rx-bc mt6">
        <div class="name">包装信息</div>

        <div class="rx-bc"> </div>
      </div>
      <div class="material">
        <div
          class="content_table"
          v-for="(item, i) in DispositionList"
          :key="i"
        >
          <div class="item">
            <div class="lable rx-cc">总数 </div>
            <div class="content content_num">
              <span>{{ totalNumber }}</span>
              <div class="unit">{{ item.packageUnit }}</div>
            </div>
          </div>

          <div class="title_box rx-bc mt6">
            <div class="name">最小包装</div>

            <div class="rx-bc"> </div>
          </div>

          <div class="item">
            <div class="lable rx-cc">包装总数 </div>
            <div class="content content_num">
              <span>{{ item.minimumFormedNumLast }}</span>
              <div class="unit">{{ item.minimumConversionUnit }}</div>
            </div>
          </div>

          <div class="item rx-sc">
            <div class="rx ww55">
              <div class="lable lable200 rx-cc">最小包装单元</div>
              <div class="content content_num">
                <span>{{ item.minimumPackageCell }}</span>
                <div class="unit">{{ item.minimumPackageUnit }}</div
                >/<div class="unit">{{ item.minimumConversionUnit }}</div>
              </div>
            </div>

            <div class="rx ww55" v-if="isReelSpecification">
              <div class="lable lable200 rx-cc">盘具规格：</div>
              <div class="content content_num">
                <el-input
                  class="uni-el-input"
                  v-model="item.reelSpecification"
                  style="width: 160px"
                  disabled
                ></el-input>
              </div>
            </div>
          </div>

          <div class="title_box rx-bc mt6">
            <div class="name">内包装</div>

            <div class="rx-bc"> </div>
          </div>

          <div class="item">
            <div class="lable rx-cc">包装总数 </div>
            <div class="content content_num">
              <span>{{ item.withinFormedNumLast }}</span>
              <div class="unit">{{ item.withinConversionUnit }}</div>
            </div>
          </div>

          <div class="item rx-sc">
            <div class="rx ww55">
              <div class="lable lable200 rx-cc">内包装单元</div>
              <div class="content content_num">
                <span>{{ item.withinPackageCell }}</span>
                <div class="unit">{{ item.withinPackageUnit }}</div
                >/<div class="unit">{{ item.withinConversionUnit }}</div>
              </div>
            </div>
          </div>

          <div class="title_box rx-bc mt6">
            <div class="name">外包装</div>

            <div class="rx-bc"> </div>
          </div>

          <div class="item">
            <div class="lable rx-cc">包装总数 </div>
            <div class="content content_num">
              <span>{{ item.outsideFormedNumLast }}</span>
              <div class="unit">{{ item.outsideConversionUnit }}</div>
            </div>
          </div>

          <div class="item rx-sc">
            <div class="rx ww55">
              <div class="lable lable200 rx-cc">外包装单元</div>
              <div class="content content_num">
                <span>{{ item.outsidePackageCell }}</span>
                <div class="unit">{{ item.outsidePackageUnit }}</div
                >/<div class="unit">{{ item.outsideConversionUnit }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div v-for="(it, i) in DispositionList" :key="it.id">
        <div v-if="it.splitList.length">
          <ele-pro-table
            ref="table"
            :needPage="false"
            :columns="columnsMin"
            :datasource="it.splitList"
            class="time-form"
            max-height="400"
            row-key="index"
          >
            <template v-slot:feedQuantity="{ row, $index }">
              <span>{{ row.feedQuantity }}{{ row.unit }}</span>
            </template>

            <template v-slot:packageQuantity="{ row, $index }">
              <span
                >{{ row.packageQuantity ? row.packageQuantity : ''
                }}{{ row.packingUnit ? row.packingUnit : '' }}</span
              >
            </template>
          </ele-pro-table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {
    packageDisposition,
    packingReport,
    getPackingList
  } from '@/api/produce/workOrder';

  import { parameterGetByCode } from '@/api/system/dictionary-data';

  // import {
  // 	getByCode
  // } from '@/api/pda/common.js'
  // import {
  // 	cancelPacking,
  // 	packingReport,
  // 	getPackingReport,
  // 	packingReportRepeat,
  // 	packageDisposition,
  // 	getPackingReportRepeat
  // } from '@/api/pda/workOrder.js'
  // import SearchPopup from '../../components/searchPopup.vue'
  export default {
    // components: {
    // 	SearchPopup
    // },
    props: {
      objData: {
        type: Object,
        default: () => {}
      },

      taskId: {
        type: String,
        default: ''
      },

      workOrderId: {
        type: String,
        default: ''
      },
      isDetails: {
        type: Boolean,
        default: false
      },
      storeType: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        formedNumLast: 100,

        quantity: '',
        unit: '',
        Usertype: '', // 规格
        unitList: [],
        resObj: {},
        splitList: [],
        localdataList: [],
        newDispositionList: [],
        withinQuantity: '', //内包装数量
        withinUnit: '', //内包装单位
        outsideQuantity: '', //外包装数量
        outsideUnit: '', //外包装单位
        timeout: null,
        packUnit: null,
        temporaryNum: 0,
        temporaryCount: 0,
        temporaryList: [],
        packTwoList: [],

        selectList: [],
        span: '',
        value: '',
        minimumPackage: [], // 最小包装
        withinPackage: [], // 内包装
        minimumUnit: '',
        outsidePackage: [], //外包装
        newCategoryId: '',
        DispositionList: [],
        show: false,
        formData: {
          wPackNum: null
        },
        warehouseId: 2,
        warehouseSpecTypeList: [
          {
            text: '按计量',
            value: 1
          },
          {
            text: '最小包装',
            value: 2
          },
          {
            text: '内包装',
            value: 3
          },
          {
            text: '外包装',
            value: 4
          }
        ],
        cacheKeyUrlMin: 'cacheKeyUrlMin',
        totalNumber: 0,
        isReelSpecification: false
        // clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo").clientEnvironmentId,
      };
    },
    // watch: {
    //   objData: {
    //     handler(newVal) {
    //       if (newVal.product && newVal.product.length) {
    //         this.newCategoryId = newVal.product[0].categoryId;
    //         this.formedNumLast = newVal.product.reduce((acc, pro) => {
    //           return pro.extInfo.sourceQuantity
    //             ? acc + Number(pro.extInfo.sourceQuantity)
    //             : acc;
    //         }, 0);
    //         // this.formedNumLast =
    //         //   newVal.formedNumLast || newVal.product[0].feedQuantity;
    //       } else {
    //         this.formedNumLast = 0;
    //       }
    //       console.log(newVal);
    //       this.packageDispositionFn();
    //     },
    //     deep: true,
    //     immediate: true
    //   }
    // },

    computed: {
      columnsMin() {
        let areaCodeColumns = {
          width: 55,
          show: false
        };

        // if (this.isQualified) {
        //   areaCodeColumns = {
        //     minWidth: 120,
        //     prop: 'areaCode',
        //     label: '货位',
        //     align: 'center',
        //     showOverflowTooltip: true,
        //     show: true
        //   };
        // }
        return [
          {
            width: 55,
            type: 'index',
            columnKey: 'index',
            align: 'center',
            label: '序号',
            fixed: 'left'
          },
          areaCodeColumns,
          {
            minWidth: 120,
            prop: 'code',
            label: '编码',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            minWidth: 140,
            prop: 'name',
            label: '名称',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            minWidth: 120,
            prop: 'batchNo',
            slot: 'batchNo',
            label: '批次号',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            minWidth: 100,
            prop: 'rootCategoryLevelId',
            label: '类型',
            align: 'center',
            showOverflowTooltip: true,
            formatter: (row) => {
              return row.rootCategoryLevelId == 2
                ? '在制品'
                : row.rootCategoryLevelId == 23
                ? '半成品'
                : row.rootCategoryLevelId == 9
                ? '产品'
                : row.rootCategoryLevelId == 28
                ? '废品'
                : '';
            }
          },
          {
            minWidth: 120,
            prop: 'extInfo.packageDisposition',
            slot: 'packageDisposition',
            label: '包装规格',
            align: 'center',
            showOverflowTooltip: true
          },

          {
            minWidth: 150,
            prop: 'packageQuantity',
            slot: 'packageQuantity',
            label: '包装数量',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            minWidth: 120,
            prop: 'extInfo.engrave',
            label: '刻码',
            align: 'center'
          },
          {
            minWidth: 120,
            prop: 'packingCode',
            label: '包装编码',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            minWidth: 120,
            prop: 'packingType',
            label: '包装层级',
            align: 'center',
            showOverflowTooltip: true,
            formatter: (row) => {
              return row.packingType == 4
                ? '外包装'
                : row.packingType == 2
                ? '最小包装'
                : row.packingType == 3
                ? '内包装'
                : '计量';
            }
          },
          {
            minWidth: 120,
            prop: 'sendCode',
            label: '发货条码',
            slot: 'sendCode',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            minWidth: 160,
            prop: 'materielCode',
            label: '物料代号',
            align: 'center',
            slot: 'materielCode'
          },
          {
            minWidth: 100,
            prop: 'clientCode',
            label: '客户代号',
            align: 'center',
            slot: 'clientCode'
          },
          {
            minWidth: 150,
            prop: 'deviceName',
            label: '设备',
            align: 'center'
          },
          {
            minWidth: 100,
            prop: 'heatNumber',
            label: '炉次号',
            slot: 'heatNumber',
            align: 'center'
          },
          {
            width: 100,
            prop: 'feedQuantity',
            label: '数量',
            slot: 'feedQuantity',
            align: 'center'
          },
          {
            width: 180,
            prop: 'weight',
            label: '上道工序重量',
            slot: 'weight',
            align: 'center'
          },
          {
            width: 150,
            prop: 'reportWeight',
            label: '报工重量',
            slot: 'reportWeight',
            align: 'center'
          },
          // {
          //   width: 110,
          //   prop: 'isQualified',
          //   label: '是否合格',
          //   slot: 'isQualified',
          //   align: 'center'
          // },
          {
            minWidth: 100,
            prop: 'extInfo.isQualified',
            label: '是否合格',
            align: 'center',
            showOverflowTooltip: true,
            formatter: (row) => {
              return row.extInfo.isQualified == 1 ? '合格' : '不合格';
            }
          },
          {
            width: 160,
            prop: 'notType',
            label: '不合格品处置类型',
            align: 'center',
            slot: 'notType'
          },
          {
            width: 140,
            prop: 'taskName',
            label: '不良原因处置',
            slot: 'taskName',
            headerSlot: 'taskNameHeader',
            align: 'center'
          },

          {
            width: 80,
            prop: 'index',
            label: '次数',
            align: 'center',
            slot: 'index'
          },
          {
            width: 150,
            prop: 'modelType',
            label: '型号',
            slot: 'modelType',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            width: 150,
            prop: 'specification',
            label: '规格',
            slot: 'specification',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            width: 150,
            prop: 'brandNum',
            label: '牌号',
            slot: 'brandNum',
            align: 'center',
            showOverflowTooltip: true
          }
        ];
      }
    },

    created() {
      this.getReelSpecification();
      console.log(this.objData, 'objDataobjDataobjData');
      if (this.objData.packInfo && !this.storeType) {
        this.warehouseId = this.objData.packInfo.tier;
        if (
          this.objData.packInfo.isUnpack == '1' &&
          this.objData.packInfo.isNewUnpack != 1
        ) {
          console.log('42424');
          this.DispositionList.push({
            titel: '最小包装',
            splitList: this.objData.packInfo.minimumPackage,
            packageCell: this.objData.packInfo.minimumPackageCell,
            packageUnit: this.objData.packInfo.minimumPackageUnit,
            conversionUnit: this.objData.packInfo.minimumConversionUnit,
            reelSpecification: this.objData.packInfo.reelSpecification
          });
        } else if (this.objData.packInfo.isNewUnpack == 1) {
          this.DispositionList.push({
            titel: '',
            splitList:
              this.objData.packInfo.minimumPackage.length != 0
                ? this.objData.packInfo.minimumPackage
                : this.objData.packInfo.withinPackage.length != 0
                ? this.objData.packInfo.withinPackage
                : this.objData.packInfo.outsidePackage.length != 0
                ? this.objData.packInfo.outsidePackage
                : [],
            minimumPackageCell: this.objData.packInfo.minimumPackageCell,
            minimumPackageUnit: this.objData.packInfo.minimumPackageUnit,
            minimumConversionUnit: this.objData.packInfo.minimumConversionUnit,
            minimumFormedNumLast: this.objData.packInfo.minimumFormedNumLast,
            withinPackageCell: this.objData.packInfo.withinPackageCell,
            withinPackageUnit: this.objData.packInfo.withinPackageUnit,
            withinConversionUnit: this.objData.packInfo.withinConversionUnit,
            withinFormedNumLast: this.objData.packInfo.withinFormedNumLast,
            outsidePackageCell: this.objData.packInfo.outsidePackageCell,
            outsidePackageUnit: this.objData.packInfo.outsidePackageUnit,
            outsideConversionUnit: this.objData.packInfo.outsideConversionUnit,
            outsideFormedNumLast: this.objData.packInfo.outsideFormedNumLast,
            formedNumLast: this.objData.formingNum,
            packageUnit: this.objData.unit,
            reelSpecification: this.objData.packInfo.reelSpecification
          });
        }
      } else {
        if (this.objData.packInfo.isUnpack == '1') {
          this.DispositionList.push({
            titel: '最小包装',
            splitList: this.objData.product
            // packageCell: this.objData.packInfo.minimumPackageCell,
            // packageUnit: this.objData.packInfo.minimumPackageUnit,
            // conversionUnit: this.objData.packInfo.minimumConversionUnit
          });
        }
      }

      if (this.objData.product && this.objData.product.length != 0) {
        this.totalNumber = this.objData.product.reduce((acc, pro) => {
          return pro.feedQuantity ? acc + Number(pro.feedQuantity) : acc;
        }, 0);
      }

      if (
        this.objData.semiProductList &&
        this.objData.semiProductList.length != 0
      ) {
        this.totalNumber = this.objData.semiProductList.reduce((acc, pro) => {
          return pro.feedQuantity ? acc + Number(pro.feedQuantity) : acc;
        }, 0);
      }
    },

    methods: {
      // 输入数量变化
      changeinput(e) {
        clearTimeout(this.timeout);
        // 设置新的定时器
        this.timeout = setTimeout(() => {
          this.formedNumLast = e;

          this.initFn(this.selectList);
        }, 500); // 500毫秒后触发
      },

      changeUserType(e) {
        let list = this.localdataList.find((item) => item.value === e);
        // this.text = e.text;
        // this.value = e.value;
        this.selectList = list.arr;
        this.initFn(list.arr);
      },
      groupBy(arr, key) {
        return arr.reduce((acc, obj) => {
          const groupKey = obj[key];
          if (!acc[groupKey]) {
            acc[groupKey] = [];
          }
          console.log();
          acc[groupKey].push(obj);
          return acc;
        }, {});
      },

      async getReelSpecification() {
        await parameterGetByCode({
          code: 'dishware_specifications'
        }).then((res) => {
          this.isReelSpecification = res.value == '1' ? true : false;
        });
      },

      async packageDispositionFn() {
        console.log();
        if (!this.newCategoryId) return;

        let that = this;
        const res = await packageDisposition(this.newCategoryId);

        console.log(res, '66666666666');

        if (res.length) {
          res.shift();
          let data = JSON.parse(JSON.stringify(res));
          let list = this.groupBy(data, 'code');
          this.localdataList = [];
          Object.entries(list).forEach(([key, value]) => {
            let obj = {
              text: value[0].name,
              arr: value,
              value: key
            };
            this.localdataList.push(obj);
          });

          // console.log(this.localdataList, 'this.localdataList');

          this.Usertype = this.localdataList[0].value;
          // this.text = this.localdataList[0].text;
          // this.value = this.localdataList[0].value;
          // res.map((v) => {
          //   v.splitList = [];
          // });

          // // this.newDispositionList = res;
          // if (this.warehouseId == 2) {
          //   this.newDispositionList = [res[0]];
          // } else if (this.warehouseId == 3) {
          //   this.newDispositionList = [res[1]];
          // } else if (this.warehouseId == 4) {
          //   this.newDispositionList = [res[2]];
          // }
          // this.selectList = res;

          // this.initFn(this.localdataList[0].arr);
          // this.listFn(this.localdataList[0].arr);
        }
      },

      initFn(v) {
        if (v.length) {
          this.withinQuantity = v[1].packageCell; //内包装数量
          this.withinUnit = v[1].conversionUnit; //内包装单位
          this.outsideQuantity = v[2].packageCell; //外包装数量
          this.outsideUnit = v[2].conversionUnit; //外包装单位
          this.minimumUnit = v[0].conversionUnit;
        }
        this.handleSplit(v[0]);
      },

      async listFn(res) {
        let {
          minimumPackage,
          withinQuantity,
          outsidePackage,
          outsideQuantity,
          withinPackage
        } = res;
        let textList = [];
        let arr = [];
        if (this.warehouseId == 2) {
          textList.push('最小包装');
          arr.push({ list: minimumPackage });
        } else if (this.warehouseId == 3) {
          textList.push('内包装');
          arr.push({ list: withinPackage, num: withinQuantity });
        } else if (this.warehouseId == 4) {
          textList.push('外包装');
          arr.push({ list: outsidePackage, num: outsideQuantity });
        }

        // return;

        // let arr = [
        //   { list: minimumPackage },
        //   { list: withinPackage, num: withinQuantity },
        //   { list: outsidePackage, num: outsideQuantity }
        // ];

        this.minimumPackage = minimumPackage; // 最小包装
        this.withinPackage = withinPackage; // 内包装
        this.outsidePackage = outsidePackage; //外包装

        console.log(this.newDispositionList, 'this.newDispositionList1');

        this.newDispositionList.map((v, i) => {
          v.splitList = arr[0].list;
          v.titel = textList[0];
          if (i == 0) {
            v.formedNumLast = this.formedNumLast;
          } else {
            v.formedNumLast = arr.num;
          }
        });

        console.log(this.newDispositionList, 'this.newDispositionList2');

        this.$nextTick(() => {
          this.$set(this, 'DispositionList', this.newDispositionList);
        });
      },

      sunNum(v, i) {
        let _this = this;
        this.$nextTick(() => {
          switch (i) {
            case 0:
              console.log(_this.formedNumLast);
              return _this.formedNumLast;
            case 1:
              return v.splitList.length || 0;
            case 2:
              return v.splitList.length || 0;
          }
        });
      },

      byCode() {
        getByCode('packing_unit').then((res) => {
          this.unitList = [];

          res.forEach((obj, index) => {
            for (let key in obj) {
              if (obj.hasOwnProperty(key)) {
                // 确保key是对象自身的属性

                this.unitList.push({
                  Key: `${key}`,
                  Value: ` ${obj[key]}`
                });
              }
            }
          });
        });
      },

      getPackingDetails() {
        let param = {
          workOrderId: this.workOrderId,
          taskId: this.taskId,
          tier: 1
        };

        getPackingReport(param).then((res) => {
          this.splitList = res.detailList;
          this.formedNumLast = res.totalQuantity;
          this.quantity = res.quantity;
          this.unit = res.unit;
        });
      },

      // 第一次调用
      handleSplit(v) {
        console.log(v, 99655);

        if (this.splitList.length) {
          this.$message.error('产品已分包');

          return false;
        }

        if (!this.formedNumLast) {
          this.$message.error('包装总数数量不能为空');

          return false;
        }

        if (!v.packageCell) {
          this.$message.error('内包装数量不能为空');

          return false;
        }

        if (!v.packageUnit) {
          this.$message.error('包装单位不能为空');

          return false;
        }

        let param = {
          workOrderId: this.workOrderId, //工单id
          taskId: this.taskId,
          tier: this.warehouseId,
          totalQuantity: this.formedNumLast, //总数量
          quantity: v.packageCell, //数量
          unit: v.packageUnit, //单位
          minimumUnit: this.minimumUnit, //最小包装单位
          withinQuantity: this.withinQuantity, //内包装数量
          withinUnit: this.withinUnit, //内包装单位
          outsideQuantity: this.outsideQuantity, //外包装数量
          outsideUnit: this.outsideUnit, //外包装单位
          packageUnit: v.conversionUnit
        };

        getPackingList(param).then((res) => {
          console.log(res, '111111111111');

          if (this.warehouseId != 1) {
            this.listFn(res);
          }
        });
      },

      handleCheck(idx, it) {
        if (it.quantity <= 0) {
          uni.showToast({
            icon: 'none',
            title: '数量为空不能勾选'
          });

          return false;
        }

        this.$set(this.splitList[idx], 'check', it.check ? 0 : 1);

        this.temporaryList = [];

        this.temporaryList = this.splitList.filter((e) => {
          return e.check == 1;
        });
        this.temporaryNum = 0;
        this.temporaryCount = 0;
        if (this.temporaryList.length > 0) {
          this.temporaryList.forEach((e) => {
            this.temporaryNum = this.temporaryNum + 1;
            this.temporaryCount = this.temporaryCount + Number(e.quantity);
          });
        }
      },

      handclose(it) {
        this.splitList.forEach((f) => {
          if (f.computeSize == it.computeSize) {
            f.check = 0;
          }
        });

        this.temporaryList = [];

        this.temporaryList = this.splitList.filter((e) => {
          return e.check == 1;
        });
      },

      getPackingDetailsTwo(v) {
        console.log(v);
        let param = {
          totalQuantity: v.formedNumLast,
          quantity: v.packageCell,
          unit: v.conversionUnit,
          workOrderId: this.workOrderId,
          taskId: this.taskId,
          tier: 2
        };

        getPackingReportRepeat(param).then((res) => {
          resolve(res.detailList);
        });
      },

      changeWarehouseType() {
        console.log(this.warehouseId, 'warehouseId');
        // this.packageDispositionFn();
      },

      handlePack(v, s) {
        let _arr = [];
        _arr = s.map((m) => {
          return {
            ...m,
            isChecked: 1
          };
        });
        console.log(_arr, '123');

        let param = {
          detailList: _arr,
          quantity: v.temporaryCount,
          totalQuantity: v.formedNumLast,
          unit: v.packageUnit,
          taskId: this.taskId,
          workOrderId: this.workOrderId,
          tier: 2
        };
        return new Promise((resolve, reject) => {
          packingReportRepeat(param).then((res) => {
            console.log(res);
            // this.temporaryList = []
            this.getPackingDetails();
            // this.getPackingDetailsTwo()
          });
        });
      },

      scrolltolower() {},

      getData() {
        let _packingReportMarginList = [];

        _packingReportMarginList = this.splitList.filter((e) => {
          return !e.parentId;
        });

        console.log(this.DispositionList, 'this.DispositionList');
        let packInfo = {};
        if (this.warehouseId == 2) {
          packInfo = {
            // this.DispositionList[0]

            specText: this.span,
            specValue: this.value,
            minimumPackage: this.minimumPackage, // 最小包装
            tier: this.warehouseId,
            minimumPackageCell: this.DispositionList[0].packageCell, // 最小包装
            minimumPackageUnit: this.DispositionList[0].packageUnit, // 最小包装单位
            minimumConversionUnit: this.DispositionList[0].conversionUnit, // 最小包装单位
            minimumFormedNumLast: this.DispositionList[0].formedNumLast // 总包装数量
          };
        } else if (this.warehouseId == 3) {
          packInfo = {
            withinPackage: this.withinPackage, // 内包装
            tier: this.warehouseId,
            withinPackageCell: this.DispositionList[0].packageCell, // 最小包装名称
            withinPackageUnit: this.DispositionList[0].packageUnit, // 最小包装单位
            withinConversionUnit: this.DispositionList[0].conversionUnit, // 最小包装单位
            withinFormedNumLast: this.DispositionList[0].formedNumLast
          }; // 总包装数量
        } else if (this.warehouseId == 4) {
          packInfo = {
            outsidePackage: this.outsidePackage, //外包装
            tier: this.warehouseId,
            outsidePackageCell: this.DispositionList[0].packageCell, // 最小包装名称
            outsidePackageUnit: this.DispositionList[0].packageUnit, // 最小包装单位
            outsideConversionUnit: this.DispositionList[0].conversionUnit, // 最小包装单位
            outsideFormedNumLast: this.DispositionList[0].formedNumLast
          }; // 总包装数量
        }

        this.objData.packInfo = packInfo;
        this.objData.taskType = this.objData.currentTaskDiagram.type;
      },

      calculation() {
        this.show = true;
      },

      calculationSave() {
        let count = this.splitList.filter((item) => item.isChecked != 1).length;

        if (this.formData.wPackNum <= count && count != 0) {
          for (let i = 0; i < this.formData.wPackNum; i++) {
            this.splitList[i].check = 1;
          }
          this.handleCheck(0, 0);
          this.calculationClose();
        } else {
          if (count != 0) {
            for (let i = 0; i < count; i++) {
              this.splitList[i].check = 1;
            }
            this.handleCheck(0, 0);
            this.calculationClose();
          }
          uni.showToast({
            icon: 'none',
            title: '外包装数超出内包装条数'
          });
        }
      },

      calculationClose() {
        this.show = false;
      },

      calculationReset() {
        this.formData.wPackNum = null;
        this.splitList.forEach((f) => {
          f.check = null;
        });
        this.temporaryList = [];
        this.show = false;
      }
    }
  };
</script>

<style lang="scss" scoped>
  .userInp {
    border: 1px solid #e5e5e5;
    border-top: none;
    padding: 2px 0;
  }

  .lable150 {
    width: 200px;
  }

  .title_box {
    margin-top: 20rpx;

    .ww20 {
      width: 20%;
    }

    .name {
      font-size: 28rpx;
      font-style: normal;
      font-weight: 400;
      padding-left: 20rpx;

      position: relative;
    }
  }

  .material {
    margin-top: 10rpx;

    .content_table {
      width: 100%;

      .item {
        display: flex;

        .lable {
          width: 132rpx;
          span-align: center;
          background-color: #f7f9fa;
          font-size: 26rpx;
          flex-shrink: 0;
        }

        .lable220 {
          width: 220rpx !important;
          font-size: 24rpx;
        }

        .lable150 {
          width: 156rpx !important;
          font-size: 24rpx;
        }

        .ww80 {
          width: 80rpx;
        }

        .content {
          width: 518rpx;
          min-height: 64rpx;
          font-size: 28rpx;
          line-height: 28rpx;
          font-style: normal;
          font-weight: 400;
          // padding: 18rpx 8rpx;
          box-sizing: border-box;
          word-wrap: break-word;
          flex-grow: 1 !important;

          .unit {
            padding: 0 4rpx;
            font-size: 24rpx;
            color: #404446;
          }
        }
      }

      .ww55 {
        width: 55%;
      }

      .ww45 {
        width: 45%;
      }
    }
  }

  .content_table2 {
    width: 100%;
    margin-top: 16rpx;
    padding: 10px 0;
    height: 200px;
    overflow-y: auto;

    .row {
      width: 100%;

      .item {
        color: #404446;
        font-size: 28rpx;
        padding-left: 12rpx;
      }

      .ww30 {
        width: 30%;
      }

      .ww50 {
        width: 50%;
      }

      .ww90 {
        width: 90%;
      }

      .ww15 {
        width: 15%;
      }

      .ww10 {
        width: 10%;
      }

      .ww30 {
        width: 30%;
      }

      .ww20 {
        width: 20%;
      }

      .ww40 {
        width: 40%;
      }

      .jsColor {
        font-size: 20rpx;
      }
    }

    .head {
      height: 64rpx;
      background: #f7f9fa;
      border-top: 2rpx solid #e3e5e5;
      border-left: 2rpx solid #e3e5e5;

      .item {
        height: 64rpx;
        line-height: 64rpx;
        border-right: 2rpx solid #e3e5e5;
        box-sizing: border-box;
      }
    }

    .tr {
      border-top: 2rpx solid #e3e5e5;
      border-left: 2rpx solid #e3e5e5;

      .item {
        font-size: 24rpx;
        min-height: 64rpx;
        display: flex;
        align-items: center;
        border-right: 2rpx solid #e3e5e5;
        box-sizing: border-box;
        white-space: normal;
        word-break: break-all;
      }
    }
  }

  .label {
    display: flex;
    height: 30px;
    width: 86px !important;
    font-size: 13px;
    align-items: center;
    justify-content: center;
    background-color: #f7f9fa;
  }

  .content_num {
    display: flex;
    align-items: center;
    padding: 0 4rpx;
  }

  .penalize {
    width: 86rpx;
    line-height: 60rpx;
    font-size: 24rpx;
    span-align: center;
    color: #fff;
  }

  .check {
    width: 30rpx;
    height: 30rpx;
  }

  .z_list {
    max-height: 500rpx;
  }

  .search_list {
    min-height: 100rpx;
    width: 80vw;
  }

  .operate_box {
    padding: 10rpx 32rpx;
  }

  ::v-deep .el-input__inner {
    height: 28px !important;
    line-height: 28px !important;
  }
</style>
