<template>
  <div class="sign-for-package">
    <el-form
      :model="orderForm"
      ref="orderDetail"
      size="mini"
      :inline="true"
      label-width="140px"
      class="mini-form2 mini-form-sign"
      label-position="left"
      :rules="rules"
    >
      <el-card shadow="never" class="box-card box-card1">
        <div slot="header">
          <h3><span></span>售后单信息</h3>
        </div>
        <el-descriptions :column="2" labelClassName="all-class">
          <el-descriptions-item label="平台订单号"
            >{{ orderDetail.platformCode || "--"
            }}<i
              v-if="orderDetail.platformCode"
              class="el-icon-document-copy"
              @click="copyText(orderDetail.platformCode)"
            ></i
          ></el-descriptions-item>

          <el-descriptions-item label="店铺">
            {{ orderDetail.platformName || "--" }}</el-descriptions-item
          >
          <el-descriptions-item label="发货状态">{{
            orderDetail.deliveryStatus || "--"
          }}</el-descriptions-item>
          <el-descriptions-item label="购买会员">{{
            orderDetail.vipName || "--"
          }}</el-descriptions-item>
          <el-descriptions-item label="收货人手机">{{
            orderDetail.userMobile || "--"
          }}</el-descriptions-item>
          <el-descriptions-item label="收货人">{{
            orderDetail.userName || "--"
          }}</el-descriptions-item>
          <el-descriptions-item label="售后单编号"
            >{{ orderDetail.afterSalesNo || "--"
            }}<i
              v-if="orderDetail.afterSalesNo"
              class="el-icon-document-copy"
              @click="copyText(orderDetail.afterSalesNo)"
            ></i
          ></el-descriptions-item>
          <el-descriptions-item
            label="售后单状态"
            contentClassName="state-color1"
          >
            {{
              orderDetail.afterSalesStatus
                ? typefilter(orderDetail.afterSalesStatus, orderStateList)
                : "--"
            }}
          </el-descriptions-item>
          <el-descriptions-item
            label="售后单类型"
            contentClassName="state-color1"
          >
            {{
              orderDetail.afterSalesType
                ? typefilter(orderDetail.afterSalesType, orderTypeList)
                : "--"
            }}
          </el-descriptions-item>
          <el-descriptions-item label="售后原因">{{
            orderDetail.refundReason || "--"
          }}</el-descriptions-item>
          <el-descriptions-item label="对接客服人员">{{
            orderDetail.customerService || "--"
          }}</el-descriptions-item>
          <el-descriptions-item label="售后申请时间">{{
            orderDetail.auditTime || "--"
          }}</el-descriptions-item>
          
        </el-descriptions>
      </el-card>

      <el-card
        shadow="never"
        class="box-card"
        v-if="orderDetail.afterSalesType !== 'COMPENSATION_REFUND'"
      >
        <div slot="header">
          <h3><span></span>申请售后商品信息</h3>
        </div>
        <el-table :data="orderDetail.items" border stripe class="w100">
          <el-table-column prop="skuNo" min-width="160" label="售后商品信息">
            <template slot-scope="scope">
              <span>{{ scope.row.skuNo }}</span>
              <span>{{ scope.row.skuName }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="num" label="销售数量(件)" align="center" />
          <el-table-column prop="costPrice" label="成本价(元)" align="center">
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.costPrice) }}
            </template>
          </el-table-column>
          <el-table-column prop="salePrice" label="销售单价(元)" align="center">
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.salePrice) }}
            </template>
          </el-table-column>
          <el-table-column
            label="销售金额(元)"
            align="center"
            prop="totalAmount"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.totalAmount) }}
            </template>
          </el-table-column>
          <el-table-column
            label="实付单价(元)"
            align="center"
            prop="actualPrice"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.actualPrice) }}
            </template>
          </el-table-column>
          <el-table-column
            label="实付金额(元)"
            align="center"
            prop="actualAmount"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.actualAmount) }}
            </template>
          </el-table-column>
          <el-table-column
            label="已申请售后数量"
            align="center"
            prop="alreadyAfterSalesNum"
          >
          </el-table-column>
          <el-table-column
            label="已申请售后金额"
            align="center"
            prop="alreadyAfterSalesAmount"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.alreadyAfterSalesAmount) }}
            </template>
          </el-table-column>
          <el-table-column
            label="申请售后数量(件)"
            align="center"
            prop="requestedRefundQuantity"
          >
          </el-table-column>
          <el-table-column
            label="申请售后金额(元)"
            align="center"
            prop="requestedRefundAmount"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.requestedRefundAmount) }}
            </template>
          </el-table-column>
        </el-table>
        <div class="after-sales-products-total">
          <span style="margin-right: 10px">总售后数量：{{ total.num }}件</span>
          <span
            >总售后金额：<span class="state-color2"
              >￥{{ $numFormat(total.amount) }}</span
            >元</span
          >
        </div>
        <span v-show="orderDetail.afterSalesType == 'EXCHANGE_GOOD'"
          >换货商品列表:</span
        >
        <el-table
          v-show="orderDetail.afterSalesType == 'EXCHANGE_GOOD'"
          :data="orderDetail.goodsList"
          border
          stripe
          class="w100"
        >
          <el-table-column
            prop="skuName"
            min-width="160"
            label="换货商品信息"
          >
            <template slot-scope="scope">
              {{ scope.row.skuNo }}/{{ scope.row.skuName }}
            </template>
          </el-table-column>
          <el-table-column prop="price" label="成本价(元)" align="center">
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.price) }}
            </template>
          </el-table-column>
          <el-table-column prop="num" label="换货数量(件)" align="center" />
          <el-table-column
            prop="salePrice"
            label="换货销售单价(元)"
            align="center"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.salePrice) }}
            </template>
          </el-table-column>
          <el-table-column
            prop="saleAmount"
            label="换货销售金额(元)"
            align="center"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.saleAmount) }}
            </template>
          </el-table-column>
          <el-table-column
            prop="diffAmount"
            label="补差价金额(元)"
            align="center"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.diffAmount) }}
            </template>
          </el-table-column>
        </el-table>
        <div
          class="after-sales-products-total"
          v-show="orderDetail.afterSalesType == 'EXCHANGE_GOOD'"
        >
          <span
            >总补差价金额：<span class="state-color2"
              >￥{{ $numFormat(total.diffAmount) }}</span
            >元</span
          >
        </div>
      </el-card>

      <el-card shadow="never" class="box-card">
        <div slot="header">
          <h3><span></span>签收退货信息</h3>
        </div>
        <el-table
          :data="orderDetail.items"
          border
          stripe
          class="w100"
          v-if="orderDetail.afterSalesType !== 'COMPENSATION_REFUND'"
        >
          <el-table-column prop="skuNo" min-width="160" label="订单商品">
            <template slot-scope="scope">
              <span>{{ scope.row.skuNo }}</span>
              <span>{{ scope.row.skuName }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column prop="costPrice" label="成本价(元)" align="center">
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.costPrice) }}
            </template>
          </el-table-column>
          <el-table-column prop="salePrice" label="销售单价(元)" align="center">
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.salePrice) }}
            </template>
          </el-table-column>
          <el-table-column
            prop="totalAmount"
            label="销售金额(元)"
            align="center"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.totalAmount) }}
            </template>
          </el-table-column> -->
          <el-table-column
            label="申请售后数量(件)"
            align="center"
            prop="requestedRefundQuantity"
          >
          </el-table-column>
          <el-table-column
            label="单件申请售后金额(元)"
            align="center"
            prop="requestedRefundQuantity"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat( (scope.row.requestedRefundAmount/scope.row.requestedRefundQuantity).toFixed(2) ) }}
            </template>
          </el-table-column>
          <el-table-column
            label="申请售后金额(元)"
            align="center"
            prop="requestedRefundQuantity"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat(scope.row.requestedRefundAmount) }}
            </template>
          </el-table-column>
          <el-table-column
            label="已签收退货数量"
            align="center"
            prop="signedQty"
          >
          </el-table-column>
          <el-table-column align="center" prop="num" min-width="120">
            <template slot="header" slot-scope="scope">
              <span class="sign-class">签收退货数量(件)</span>
            </template>
            <template slot-scope="scope">
              <el-input
                v-model.trim="scope.row.qty"
                type="number"
                :max="scope.row.requestedRefundQuantity"
                :min="0"
                @input="value=>changeQty(value, scope.row)"
              />
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            min-width="120"
            prop="afterSalesOrder"
          >
            <template slot="header" slot-scope="scope">
              <span class="sign-class">签收退货商品串码</span>
            </template>
            <template slot-scope="scope">
              <el-input v-model.trim="scope.row.serials" type="text" />
            </template>
          </el-table-column>
          <el-table-column
            label="签收退货金额(元)"
            align="center"
            prop="actualAmount"
          >
            <template slot-scope="scope">
              ￥{{ $numFormat( (scope.row.qty*(scope.row.requestedRefundAmount/scope.row.requestedRefundQuantity)).toFixed(2) ) }}
            </template>
          </el-table-column>
          <el-table-column prop="goodCode" label="是否代发" align="center">
          </el-table-column>
          <el-table-column prop="goodCode" label="代发供应商" align="center">
          </el-table-column>
        </el-table>
        <div class="after-sales-products-total">
          <span style="margin-right: 10px">签收退货数量：{{ signNum }}件</span>
          <span>签收退货金额：￥{{ $numFormat(signAmount) }}元</span>
        </div>
        <el-descriptions :column="2" labelClassName="all-class">
          <el-descriptions-item label="" labelClassName="else-form">
            <el-form-item label="申请退货数量(件):" prop="">
              <span class="state-color1">{{ signNum3 || "--" }}</span>
            </el-form-item>
          </el-descriptions-item>
          <el-descriptions-item label="" labelClassName="else-form">
            <el-form-item label="总签收退货数量:" prop="">
              <span :class="signNum2<signNum3?'color-r':'state-color1'">{{ signNum2 }}</span>
            </el-form-item>
          </el-descriptions-item>
          <el-descriptions-item label="" labelClassName="else-form">
            <el-form-item
              label="退货物流单号:"
              :rules="[
                {
                  required: true,
                  message: '请输入退货物流单号',
                  trigger: 'blur',
                },
              ]"
              prop="returnLogisticsExpressNo"
            >
              <el-input
                v-model.trim="orderForm.returnLogisticsExpressNo"
                style="width: 245px"
                clearable
              />
            </el-form-item>
          </el-descriptions-item>
          <el-descriptions-item label="" labelClassName="else-form">
            <el-form-item
              label="退货物流公司:"
              :rules="[
                {
                  required: true,
                  message: '请选择退货物流公司',
                  trigger: 'blur',
                },
              ]"
              prop="returnLogisticsExpressComName"
            >
              <el-select
                filterable
                v-model="orderForm.returnLogisticsExpressComName"
                placeholder="请选择"
                clearable
                style="width: 245px"
              >
                <el-option
                  v-for="dict in returnLogisticsCompanyList"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-descriptions-item>
          <el-descriptions-item
            label="是否代发"
            contentClassName="state-color1"
            >{{
              orderDetail.hasSupplier == 0
                ? "否"
                : orderDetail.hasSupplier == 1
                ? "是"
                : "--"
            }}</el-descriptions-item
          >
          <el-descriptions-item label="代发供货商">{{
            orderDetail.supplierName || "--"
          }}</el-descriptions-item>
          <el-descriptions-item label="" labelClassName="else-form">
            <el-form-item
              label="退入仓库:"
              prop="warehouseCode"
            >
              <el-select
                filterable
                v-model="orderForm.warehouseCode"
                placeholder="请选择"
                clearable
                style="width: 245px"
              >
                <el-option
                  v-for="dict in warehouseLists"
                  :key="dict.warehouseCode"
                  :label="dict.warehouseName"
                  :value="dict.warehouseCode"
                />
              </el-select>
            </el-form-item>
          </el-descriptions-item>
          <el-descriptions-item label="" labelClassName="else-form">
            <el-form-item
              label="退货包裹寄回地:"
              :rules="[
                {
                  required: true,
                  message: '请选择退货包裹寄回地',
                  trigger: 'blur',
                },
              ]"
              prop="refundAddressType"
            >
              <el-select
                filterable
                v-model="orderForm.refundAddressType"
                placeholder="请选择"
                clearable
                style="width: 245px"
              >
                <el-option
                  v-for="dict in sendBackLandList"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-descriptions-item>
          <el-descriptions-item label="" labelClassName="else-form">
            <el-form-item
              label="备注:"
              :rules="[
                {
                  required: true,
                  message: '请输入备注',
                  trigger: 'blur',
                },
              ]"
              prop="remark"
              class="remarks-class"
            >
              <el-input
                v-model.trim="orderForm.remark"
                clearable
                type="textarea"
                maxlength="100"
                placeholder="填写备注，不超过100个字"
                resize="none"
                rows="3"
              />
            </el-form-item>
          </el-descriptions-item>
        </el-descriptions>
        <div class="notice-box">
          <div class="warning-alert">
            <div>
              <div>
                1、"退货退款"类型的售后单，全部确认收货后，系统将在管易中自动创建”退货"类型的退换货单以及退款单。售后人员需要到管易审批退换货单和退款单。
              </div>
              <div>
                2、"换货"类型的售后单，全部确认收货后，系统将创建换货类型的退换货单。售后人员需要到管易审批退换货单，并创建换货商品“换货"类型销售订单
              </div>
              <div>3、代发订单退货包裹寄回供货商的，系统会自动创建采退单</div>
            </div>
          </div>
        </div>
      </el-card>
    </el-form>
    <div class="btns-box">
      <el-button size="small" @click="confirmReceipt(0)"
        >强制全部收货</el-button
      >
      <el-button size="small" @click="confirmReceipt(2)"
        >打回退货包裹</el-button
      >
      <el-button size="small" @click="goBack">取消</el-button>
      <el-button type="primary" size="small" @click="confirmReceipt(1)"
        >确认收货</el-button
      >
    </div>
  </div>
</template>

<script>
import {
  afterSalesOrderDetail,
  afterSalesOrderSign,
  afterSalesChangeQuery,
} from "@/api/afterSalesOrder/index";
import { warehouseList } from "@/api/goods/index";

export default {
  props: {},
  components: {},
  data() {
    return {
      afterSalesNo: "",
      orderForm: {
        afterSalesNo: "",
        refundAddressType: "",
        remark: "",
        returnLogisticsExpressComName: "",
        returnLogisticsExpressNo: "",
        signSkuList: [],
        warehouseCode: "",
        warehouseName: "",
      },
      orderDetail: {
        goodsList: [],
        exchangeItems: [],
        afterSalesNo: "",
        afterSalesStatus: "",
        afterSalesType: "",
        auditTime: "",
        changeItems: [],
        customerService: "",
        deliveryStatus: "",
        erpCode: "",
        hasRefundUser: "",
        hasSupplier: "",
        items: [],
        platformCode: "",
        platformName: "",
        platformNo: "",
        refundAddressType: "",
        refundAmount: "",
        refundExpressComName: "",
        refundExpressNo: "",
        refundReason: "",
        refundType: "",
        remark: "",
        returnLogisticsExpressComName: "",
        returnLogisticsExpressNo: "",
        shopCode: "",
        shopName: "",
        supplierCode: "",
        supplierName: "",
        userMobile: "",
        userName: "",
        vipName: "",
        orderItems: [],
      },
      sendBackLandList: [
        { label: "自有仓库", value: "SELF_WAREHOUSE" },
        { label: "代发供货商", value: "SUPPLIER" },
      ],
      whetherShippingList: [],
      warehouseList: [],
      // refundExpressComName 物流公司名称
      // refundExpressNo 物流公司id
      refundAddressTypeList: [],
      total: {
        num: 0,
        amount: 0,
        diffAmount: 0,
      },
      signNum: 0,
      signNum2: 0,
      signNum3: 0,
      signAmount: 0,
      totalNum: 0,
      rules: {
        afterSalesOrder: [
          { required: true, message: "请输入平台售后订单", trigger: "blur" },
        ],
      },
      orderStateList: [
        { label: "待客服主管复核", value: "AWAITING_SUPERVISOR_APPROVAL" },
        { label: "待接收退货包裹", value: "PENDING_RETURN_PACKAGES" },
        { label: "部分退货", value: "PART_SIGN" },
        { label: "待财务复核", value: "AWAITING_FINANCE_APPROVAL" },
        { label: "待换货", value: "PENDING_CHANGE" },
        { label: "已换货", value: "CONFIRM_SEND_CALLBACK" },
        { label: "待回传发货信息", value: "CONFIRM_SEND" },
        { label: "待退款", value: "PENDING_REFUNDS" },
        { label: "已退款/已处理", value: "REFUNDED" },
        { label: "打回退货包裹", value: "REJECT_PACKAGE" },
        { label: "取消", value: "CANCEL" },
      ],
      orderTypeList: [
        { label: "极速退款", value: "FIRST_REFUND" },
        { label: "仅退款", value: "ONLY_REFUND" },
        { label: "退货退款", value: "REFUND_MONEY_GOODS" },
        { label: "换货", value: "EXCHANGE_GOOD" },
        { label: "补偿退款", value: "COMPENSATION_REFUND" },
      ],
      returnLogisticsCompanyList: [
        { label: "顺丰速运", value: "SF_EXPRESS" },
        { label: "圆通速递", value: "YTO_EXPRESS" },
        { label: "中通快递", value: "ZTO_EXPRESS" },
        { label: "申通快递", value: "STO_EXPRESS" },
      ],
      warehouseLists: [],
    };
  },

  created() {
    this.getWarehouceList();
  },

  activated() {
    if (this.afterSalesNo != this.$route.query.afterSalesNo) {
      this.afterSalesNo = this.$route.query.afterSalesNo;
      this.total = {
        num: 0,
        amount: 0,
        diffAmount: 0,
      }
      this.orderDetail = {
        goodsList: [],
        exchangeItems: [],
        afterSalesNo: "",
        afterSalesStatus: "",
        afterSalesType: "",
        auditTime: "",
        changeItems: [],
        customerService: "",
        deliveryStatus: "",
        erpCode: "",
        hasRefundUser: "",
        hasSupplier: "",
        items: [],
        platformCode: "",
        platformName: "",
        platformNo: "",
        refundAddressType: "",
        refundAmount: "",
        refundExpressComName: "",
        refundExpressNo: "",
        refundReason: "",
        refundType: "",
        remark: "",
        returnLogisticsExpressComName: "",
        returnLogisticsExpressNo: "",
        shopCode: "",
        shopName: "",
        supplierCode: "",
        supplierName: "",
        userMobile: "",
        userName: "",
        vipName: "",
        orderItems: [],
      };
      this.orderForm =  {
        afterSalesNo: "",
        refundAddressType: "",
        remark: "",
        returnLogisticsExpressComName: "",
        returnLogisticsExpressNo: "",
        signSkuList: [],
        warehouseCode: "",
        warehouseName: "",
      },
      this.getDetails();
    }
  },
  methods: {
    getWarehouceList() {
      warehouseList().then((res) => {
        if (res.status == 200) {
          this.warehouseLists = res.data.list;
        }
      });
    },
    copyText(text) {
      window.navigator.clipboard
        .writeText(text)
        .then(() => {
          // this.$message.success("复制成功");
          this.$message({
            message: "复制成功",
            type: "success",
            customClass: "phone-message",
            center: true,
          });
        })
        .catch((error) => {
          // this.$message.warning("复制失败");
          this.$message({
            message: "复制失败",
            type: "warning",
            customClass: "phone-message",
            center: true,
          });
        });
    },
    getDetails() {
      const data = {
        afterSalesPlatformCode: this.afterSalesNo,
      };
      afterSalesOrderDetail(data)
        .then((response) => {
          if (response.status == 200) {
            const dataBak = JSON.parse(JSON.stringify(response.data));
            this.orderDetail = Object.assign(this.orderDetail, response.data);
            this.orderDetail.items.forEach((item) => {
              this.total.num += Number(item.requestedRefundQuantity+item.alreadyAfterSalesNum);
              this.total.amount += Number(item.requestedRefundAmount+item.alreadyAfterSalesAmount);
              item["qty"] = Number(item.requestedRefundQuantity) - Number(item.signedQty);
            });
            this.total.amount = this.total.amount.toFixed(2);
            this.orderForm.returnLogisticsExpressNo =
              dataBak.returnLogisticsExpressNo=='UNKNOWN'?'':dataBak.returnLogisticsExpressNo;
            this.orderForm.returnLogisticsExpressComName =
              dataBak.returnLogisticsExpressComName=='UNKNOWN'?'':dataBak.returnLogisticsExpressComName;
            this.orderForm.warehouseCode = dataBak.warehouseCode;
            this.orderForm.refundAddressType = dataBak.refundAddressType=='UNKNOWN'?'':dataBak.refundAddressType;
            this.orderForm.remark = dataBak.remark;

            this.changeQty();
          }
        })
        .catch((err) => {
          // this.$message.error(err);
        });

      // 换货信息查询
      afterSalesChangeQuery(data)
        .then((response) => {
          if (response.status == 200) {
            this.orderDetail.goodsList = response.data.goodsList;
            this.orderDetail.goodsList.forEach((item) => {
              this.total.diffAmount += Number(item.diffAmount);
            });
            this.total.diffAmount = this.total.diffAmount.toFixed(2);
          }
        })
        .catch((err) => {
          // this.$message.error(err);
        });
    },
    confirmReceipt(type) {
      this.$refs.orderDetail.validate((valid) => {
        if (valid) {
          if(type!=2&&!this.orderForm.warehouseCode){
            this.$message.warning('请选择退入仓库');
            return false;
          }
          const items = this.warehouseLists.find((item) => {
            return item.warehouseCode == this.orderForm.warehouseCode;
          });
          this.orderForm.warehouseName = items ? items.warehouseName : '';

          let status = false;
          let status2 = false;
          let status3 = false;
          const signSkuList = [];
          this.orderDetail.items.forEach((item) => {
            if (item.qty == "" && (item.serials == ""||item.serials==undefined)) {
              status = true;
            }

            if (item.qty > 0 && (item.serials == ""||item.serials==undefined) && type!=2) {
              status2 = true;
            }
            signSkuList.push({
              qty: item.qty,
              // 数量
              serials: item.serials,
              signId: item.id,
              skuNo: item.skuNo,
              // 商品编码
            });
          });

          if (this.signNum3 != this.signNum2) {
            status3 = true;
          }

          if (status2) {
            this.$message.warning("请填写签收退货商品串码");
            return false;
          }
          if (status) {
            this.$message.warning("请填写签收数量和串码");
            return false;
          }
          
          if (status3 && type == 1) {
            this.$confirm('总签收退货数量和申请退货数量不一致，确认要确认收货吗?确认收货后，售后单状态为部分收货。如果要强制完成售后单签收退货操作，请点击【强制全部收货】', 
            '确认完成签收退货', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              const data = {
                afterSalesPlatformCode: this.afterSalesNo,
                hasForced: type,
                // 签收类型 是否强制签收 0否 1是 2打回包裹
                refundAddressType: this.orderForm.refundAddressType,
                // 退货地址类型 SELF_WAREHOUSE 自有仓库 SUPPLIER 代发供货商
                remark: this.orderForm.remark,
                returnLogisticsExpressComName:
                  this.orderForm.returnLogisticsExpressComName,
                returnLogisticsExpressNo: this.orderForm.returnLogisticsExpressNo,
                // 退货物流单号
                signSkuList: signSkuList,
                warehouseCode: this.orderForm.warehouseCode,
                // 仓库编码
                warehouseName: this.orderForm.warehouseName,
                // 仓库名称
              };

              const loading = this.$loading({
                lock: true,
                text: "执行中",
                spinner: "el-icon-loading",
                background: "rgba(0, 0, 0, 0.7)",
              });
              afterSalesOrderSign(data)
                .then((response) => {
                  loading.close();
                  if (response.status == 200) {
                    this.$message.success("操作成功");
                    this.$tab.closeOpenPage('/afterSaleOrder/index');
                  }
                })
                .catch((err) => {
                  loading.close();
                });
            }).catch(() => {});
            return false;
          }

          const data = {
            afterSalesPlatformCode: this.afterSalesNo,
            hasForced: type,
            // 签收类型 是否强制签收 0否 1是 2打回包裹
            refundAddressType: this.orderForm.refundAddressType,
            // 退货地址类型 SELF_WAREHOUSE 自有仓库 SUPPLIER 代发供货商
            remark: this.orderForm.remark,
            returnLogisticsExpressComName:
              this.orderForm.returnLogisticsExpressComName,
            returnLogisticsExpressNo: this.orderForm.returnLogisticsExpressNo,
            // 退货物流单号
            signSkuList: signSkuList,
            warehouseCode: this.orderForm.warehouseCode,
            // 仓库编码
            warehouseName: this.orderForm.warehouseName,
            // 仓库名称
          };

          const loading = this.$loading({
            lock: true,
            text: "执行中",
            spinner: "el-icon-loading",
            background: "rgba(0, 0, 0, 0.7)",
          });
          afterSalesOrderSign(data)
            .then((response) => {
              loading.close();
              if (response.status == 200) {
                this.$message.success("操作成功");
                this.$tab.closeOpenPage('/afterSaleOrder/index');
              }
            })
            .catch((err) => {
              loading.close();
            });
        }
      });
    },
    typefilter(value, list) {
      const data = list.find((item) => {
        return item.value == value;
      });
      return data ? data.label : "";
    },
    changeQty(value, row) {
      if(value && (value > (Number(row.requestedRefundQuantity) - Number(row.signedQty)) )){
        this.$set(row, 'qty', Number(row.requestedRefundQuantity) - Number(row.signedQty));
        // return false;
      }
      this.signNum = 0;
      this.signNum2 = 0;
      this.signNum3 = 0;
      this.signAmount = 0;
      let list = JSON.parse(JSON.stringify(this.orderDetail.items));
      this.$set(this.orderDetail, "items", list);
      this.orderDetail.items.forEach((item) => {
        this.signNum += Number(item.qty);
        this.signNum2 += (Number(item.qty)+Number(item.signedQty));
        this.signNum3 += Number(item.requestedRefundQuantity);
        this.signAmount += Number(item.qty)*Number(item.requestedRefundAmount/item.requestedRefundQuantity);
      });
      this.signNum = this.signNum.toFixed(0);
      this.signAmount = this.signAmount.toFixed(2);
    },
  },

  computed: {},

  mounted() {
    this.afterSalesNo = this.$route.query.afterSalesNo;
    this.getDetails();
  },

  watch: {},
};
</script>
<style lang='scss' scoped>
.sign-for-package {
  height: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 16px;
}
.box-card {
  margin-bottom: 16px;
}
.box-card1 {
  margin-top: 16px;
}
.main-container {
  .minHeight {
    // min-height: 330px;
    flex: 1;
  }
  .box-card2 {
    height: 95%;
  }
  .price-container {
    width: 20%;
    float: right;
    margin-top: 10px;
    div {
      margin-bottom: 8px;
      span {
        color: #f56c6c;
      }
    }
  }
}
h3 {
  font-weight: bold;
  display: flex;
  align-items: center;
  margin: 0;
  font-size: 14px;
  span {
    display: block;
    width: 2px;
    height: 14px;
    background: #f56c6c;
    margin-right: 6px;
  }
}
.color-r {
  color: #f56c6c;
}
.color-y {
  color: #fbc576;
}
.mini-form {
  .el-form-item {
    margin-bottom: 0;
    margin-right: 0;
  }
}
.after-sales-products-total {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0 16px 0;
}
.sign-class {
  &::before {
    content: "*";
    color: #ff4949;
    margin-right: 4px;
  }
}
.mini-form {
  .el-form-item {
    margin-bottom: 0;
    margin-right: 0;
  }
}
.remarks-class {
  width: 100%;
  display: flex;
  ::v-deep .el-form-item__content {
    flex: 1;
  }
}
.notice-box {
  display: flex;
  justify-content: space-between;
  margin: 15px 0;
  .notice-left {
    display: flex;
    i {
      font-size: 30px;
      margin-right: 25px;
    }
    div {
      color: #ffba00;
    }
  }
}
.btns-box {
  text-align: center;
  margin: 16px 0;
}
.warning-alert {
  background-color: #fff8e6;
  color: #ffba00;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
}
</style>
<style lang="scss">
.sign-for-package {
  .el-timeline-item__content {
    .el-card__body {
      padding: 0 16px;
    }
  }
  .el-descriptions--medium:not(.is-bordered) .el-descriptions-item__cell {
    padding-bottom: 18px;
  }
  .el-descriptions-item__label {
    display: flex;
    align-items: center;
  }
  .all-class {
    width: 140px;
  }
  .state-color1 {
    color: #67c23a;
    font-weight: bold;
  }
  .state-color2 {
    color: red;
  }
  .else-form {
    margin-right: 0 !important;
    &::after {
      content: "" !important;
    }
  }
}
.mini-form-sign{
  .el-form-item--mini.el-form-item{
    margin: 0;
  }
}
</style>