
<template>
  <div class="page1">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div v-if="topList[0].changed==true">
    <div class="main">
      <div class="contain" ref="box">
        <div class="tit">{{ '信息配置' }}</div>
        <div class="xian"></div>
        <el-form ref="form" :rules="rules" :model="form" label-width="80px">
          <el-row>
            <!-- 第一行 -->
            <el-col :span="4">
              <el-form-item required :label="'服务中心'" prop="applicantNo">
                <el-input
                  clearable
                  v-model="form.applicantNo"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'申请级别'" prop="userLevel">
                <el-select clearable v-model="form.userLevel">
                  <el-option
                    v-for="item in gradeAllList"
                    :key="item.pkId"
                    :label="item.gradeName"
                    :value="item.pkId"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'注册金额'" prop="registerPrice">
                <el-input
                  clearable
                  v-model="form.registerPrice"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'注册业绩'" prop="registerPv">
                <el-input
                  clearable
                  v-model="form.registerPv"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'推荐编号'" prop="parent">
                <el-input
                  clearable
                  v-model="form.parent"
                  :placeholder="'请输入'"
                  @change="checkCode"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'推荐姓名'" prop="tjname">
                <el-input
                  clearable
                  v-model="form.tjname"
                  :placeholder="'请输入'"
                  disabled
                ></el-input>
              </el-form-item>
            </el-col>
            <!-- 第二行 -->
            <el-col :span="4">
              <el-form-item required :label="'安置编号'" prop="placeParent">
                <el-input
                  clearable
                  v-model="form.placeParent"
                  :placeholder="'请输入'"
                  @change="checkCode2"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'安置姓名'" prop="azname">
                <el-input
                  clearable
                  v-model="form.azname"
                  disabled
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'安置位置'" prop="placeDept">
                <el-select clearable v-model="form.placeDept">
                  <el-option
                    v-for="item in placeDeptList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'会员姓名'" prop="memberName">
                <el-input
                  clearable
                  v-model="form.memberName"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'联系方式'" prop="phone">
                <el-input
                  clearable
                  v-model="form.phone"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'选购商品'" prop="teamCode">
                <el-select clearable v-model="form.xgsp">
                  <el-option
                    v-for="item in yesornoList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <!-- 第三行 -->
            <el-col :span="4">
              <el-form-item required :label="'真实奖衔'" prop="userAwards">
                <el-select clearable v-model="form.userAwards">
                  <el-option
                    v-for="item in pkAwardsList"
                    :key="item.pkId"
                    :label="item.awardsName"
                    :value="item.pkId"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'点位状态'" prop="isSettlement">
                <el-select clearable v-model="form.isSettlement">
                  <el-option
                    v-for="item in yesornoList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'注册类型'" prop="teamCode">
                <el-select clearable v-model="form.zclx">
                  <el-option
                    v-for="item in kdzcList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'回填金额'" prop="backfillPrice">
                <el-input
                  clearable
                  v-model="form.backfillPrice"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'证件类型'" prop="idType">
                <el-select clearable v-model="form.idType">
                  <el-option
                    v-for="item in cardTypeList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'预售状态'" prop="preSaleStatus">
                <el-select clearable v-model="form.preSaleStatus">
                  <el-option
                    v-for="item in presaleStatusList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <!-- 第四行 -->
            <el-col :span="4">
              <el-form-item :label="'证件号码'" prop="idCard">
                <el-input
                  clearable
                  v-model="form.idCard"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'发货方式'" prop="deliveryWay">
                <el-select clearable v-model="form.deliveryWay">
                  <el-option
                    v-for="item in deliveryWayList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'运输方式'" prop="tranType">
                <el-select clearable v-model="form.tranType">
                  <el-option
                    v-for="item in transportTypeList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'银行名称'" prop="bankId">
                <el-select clearable v-model="form.bankId">
                  <el-option
                    v-for="item in bankAllList"
                    :key="item.pkId"
                    :label="item.bankName"
                    :value="item.pkId"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'银行卡号'" prop="bankCard">
                <el-input
                  clearable
                  v-model="form.bankCard"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'开户支行'" prop="openingBranch">
                <el-input
                  clearable
                  v-model="form.openingBranch"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <!-- 第五行 -->
            <el-col :span="4">
              <el-form-item :label="'开户姓名'" prop="openingName">
                <el-input
                  clearable
                  v-model="form.openingName"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'预留电话'" prop="reservedPhone">
                <el-input
                  clearable
                  v-model="form.reservedPhone"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="'联系邮箱'" prop="email">
                <el-input
                  clearable
                  v-model="form.email"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'结算业绩'" prop="settleAccounts">
                <el-input
                  clearable
                  v-model="form.settleAccounts"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'传输业绩'" prop="transferAccounts">
                <el-input
                  clearable
                  v-model="form.transferAccounts"
                  :placeholder="'请输入'"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'订单类型'" prop="orderType">
                <el-select clearable v-model="form.orderType">
                  <el-option
                    v-for="item in orderTypeList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <!-- 第六行 -->
            <el-col :span="4">
              <el-form-item required :label="'自然国家'" prop="pkCountry">
                <el-select clearable v-model="form.pkCountry">
                  <el-option
                    v-for="item in countryAllList"
                    :key="item.pkId"
                    :label="item.shortName"
                    :value="item.pkId"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item required :label="'结算国家'" prop="pkSettleCountry">
                <el-select clearable v-model="form.pkSettleCountry">
                  <el-option
                    v-for="item in countryAllList"
                    :key="item.pkId"
                    :label="item.shortName"
                    :value="item.pkId"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-table
            :data="tableData"
            style="width: 100%"
            :header-cell-style="{ background: '#EEEEEE' }"
          >
            <el-table-column align="center" prop="receivingName" :label="'收货人'">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.receivingName"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              prop="receivingPhone"
              :label="'收货电话'"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.receivingPhone"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              prop="backgroundImg"
              :label="'省/市/区/县'"
            >
              <template slot-scope="scope">
                <el-cascader
                  style="width: 100%"
                  v-model="scope.row.shoppingAddress"
                  :options="areaData"
                  :props="regionParams"
                  @change="handleChange"
                ></el-cascader>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="address"  :label="'详细地址'">
              <template slot-scope="scope">
                <el-input clearable v-model="scope.row.address"></el-input>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="remark" :label="'备注'">
              <template slot-scope="scope">
                <el-input clearable v-model="scope.row.remark"></el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </div>
      <div v-if="this.form.xgsp == 0" class="contain">
        <div class="maintop">
          <div class="mainbtn">
            <el-button size="small" class="thebtn1" @click="choiceProduct"
              >{{ '选择商品' }}</el-button
            >
          </div>
        </div>
        <!-- 下方商品列表 -->
        <el-table
          :data="productData"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
        >
          <el-table-column align="center" prop="sort" :label="'排序'">
          </el-table-column>
          <el-table-column align="center" prop="cover" :label="'产品主图'">
            <template slot-scope="scope">
              <img
                :src="scope.row.cover"
                alt=""
                style="width: 44px; height: 44px"
              />
            </template>
          </el-table-column>
          <el-table-column align="center" prop="waresName" :label="'商品名称'">
          </el-table-column>
          <el-table-column align="center" prop="waresCode" :label="'商品编号'">
          </el-table-column>
          <el-table-column align="center" prop="specsName" :label="'产品规格'">
          </el-table-column>
          <el-table-column align="center" prop="waresPrice" :label="'商品价格'+'(¥)'">
          </el-table-column>
          <el-table-column align="center" prop="waresPv" :label="'商品业绩'+`(${isLocals()})`">
          </el-table-column>
          <el-table-column
            align="center"
            prop="specialAreaStr"
            :label="'所属专区'"
          >
          </el-table-column>
          <el-table-column align="center" prop="isSingle" :label="'套餐类型'">
            <template slot-scope="scope">
              <span v-if="scope.row.isSingle == 0">{{ '单品' }}</span>
              <span v-if="scope.row.isSingle == 1">{{ '套装' }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="quantity" :label="'商品数量'">
          </el-table-column>
          <el-table-column
            align="center"
            prop="amountPrice"
            :label="'金额小计'+'(¥)'"
          >
          </el-table-column>
          <el-table-column align="center" prop="" :label="'金额合计'+'(¥)'">
          </el-table-column>
        </el-table>
      </div>
      <div class="footer">
        <div style="margin: 0 auto">
          <!-- <el-button
            v-for="(item, index) in processTypeList"
            :key="index"
            :class="`thebtn${item.value}`"
            @click="saveDate(item.value)"
            >{{ item.label }}</el-button
          > -->
          <el-button class="thebtn0" @click="saveDate(0)"> {{ '取消' }}</el-button>
          <el-button
            v-hasButtons="['EmptyOrderExemptSign']"
            class="thebtn1"
            @click="saveDate(1)"
            >{{'免签'}}</el-button
          >
          <el-button
            v-hasButtons="['EmptyOrderExemptPay']"
            class="thebtn2"
            @click="saveDate(2)"
            >{{'免付'}}</el-button
          >
          <el-button
            v-hasButtons="['EmptyOrderExemptAll']"
            class="thebtn3"
            @click="saveDate(3)"
            >{{'全免'}}</el-button
          >
          <el-button
            v-hasButtons="['EmptyOrderConfirm']"
            class="thebtn4"
            @click="saveDate(4)"
            > {{ '确认' }}</el-button
          >
        </div>
      </div>
    </div >
    <el-dialog
      :title="'选择商品'"
      :visible.sync="productShow"
      width="60%"
      :close-on-click-modal="false"
      center
    >
      <div>
        <div style="width: 400px; margin-bottom: 20px; display: flex">
          <el-input v-model="searchProduct" style="margin-right: 20px">
            <i slot="prefix" class="el-input__icon el-icon-search"></i>
          </el-input>
          <el-button type="primary" @click="getProductSearch"> {{ '搜索' }}</el-button>
        </div>
        <div>
          <el-table
            :data="productTable"
            height="400px"
            style="width: 100%"
            :header-cell-style="{ background: '#EEEEEE' }"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55"> </el-table-column>
            <el-table-column align="center" prop="memberCode" :label="'商品主图'">
              <template slot-scope="scope">
                <img
                  :src="scope.row.waresImg"
                  alt=""
                  style="width: 44px; height: 44px"
                />
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              prop="waresName"
              :label="'商品名称'"
            ></el-table-column>
            <el-table-column
              align="center"
              prop="waresCode"
              :label="'商品编号'"
            ></el-table-column>
            <el-table-column
              :show-overflow-tooltip="true"
              align="center"
              prop=""
              :label="'产品规格'"
            >
              <template slot-scope="scope">
                <el-button
                  @click="clickChoiceGg(scope.row)"
                  v-if="!scope.row.spggTitle"
                  type="text"
                  >{{'请选择'}}  {{'产品规格'}}</el-button
                >
                <span v-else>{{ scope.row.spggTitle }}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              prop="waresPrice"
              :label="'商品价格'+'(￥)'"
            ></el-table-column>
            <el-table-column
              align="center"
              width="200px"
              prop="number"
              :label="'商品数量'"
            >
              <template slot-scope="scope">
                <div>
                  <el-input-number
                    v-model="scope.row.number"
                    :min="1"
                  ></el-input-number>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              prop="waresAchieve"
              :label="'商品业绩'+`(${isLocals()})`"
            ></el-table-column>
          </el-table>
        </div>
        <div style="text-align: center; margin-top: 20px">
          <el-button @click="productShow = false"> {{ '取消' }}</el-button>
          <el-button type="primary" @click="saveProduct">{{'确定'}}</el-button>
        </div>
      </div>
    </el-dialog>
    <!-- 选择产品规格弹窗 -->
    <el-dialog
      title=""
      :visible.sync="choiceGgShow"
      width="30%"
      :close-on-click-modal="false"
      center
    >
      <div class="gui">
        <div
          v-for="(item, index) in choiceGgForm.productEntnyOrderVoList"
          :key="item.pkProduct"
        >
          <div class="gui_t">
            <div>{{'规格'}}:</div>
            <div class="gui_tt">
              {{ item.productName }}
              <span class="coloNum">*{{ item.quantity }}</span>
            </div>
          </div>
          <div class="gui_b">
            <div class="gui_bt">{{ '型号' }}:</div>
            <div class="gui_bb">
              <div
                v-for="(ctem, cndex) in item.waresSpecsEntnyOrterVo"
                :key="ctem.specsIds"
                class="gui_i"
              >
                <div
                  @click.stop="tapSku(index, cndex, ctem.quantity)"
                  :class="['gui_ii', ctem.checked ? 'gui_a' : '']"
                >
                  <!-- <img :src="ctem.specCover" alt="" /> -->
                  <div>{{ ctem.specsName }}</div>
                </div>
                <div class="jbq" v-show="ctem.checked">
                  <el-input-number
                    size="mini"
                    @change="getNum(index, cndex, $event)"
                    v-model="ctem.quantity"
                    :max="ctem.maxNum"
                    :min="0"
                  >
                  </el-input-number>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div style="text-align: center; margin-top: 20px">
        <el-button @click="choiceGgShow = false"> {{ '取消' }}</el-button>
        <el-button type="primary" @click="saveChoiceGg">{{'确定'}}</el-button>
      </div>
    </el-dialog>
  </div>
  </div>
</template>
<script>
import topBar from "@/components/topBar";
import { getPubEnumsProcessTyepe } from "@/api/business.js";
import * as log from "@/api/logistics";
import * as del from "@/api/delivery.js";
import * as api from "@/api/site.js";
import { getAwardsListChiose } from "@/api/level";
import * as spe from "@/api/specialBusiness";
import { gettheMemberInfo } from "@/api/affiliatedteam";
import {getRouters} from "@/api/settle";
import {isLocals} from "@/utils/numberToCurrency";
export default {
  name: "EmptyOrder",
  components: { topBar },
  data() {
    return {
      moren: "emptyOrder",
      topList: [
        {
          name: '空单注册',
          path: "emptyOrder",
          changed:false,
        },
        {
          name: '修改直推',
          path: "modifyDirectpush",
          changed:false,
        },
        {
          name: '修改安置',
          path: "modifyPlacement",
          changed:false,
        },
        {
          name: '注水业绩',
          path: "waterPv",
          changed:false,
        },
        {
          name: '修改编号',
          path: "modifyCode",
          changed:false,
        },
        {
          name: '真实奖衔控制',
          path: "awardControl",
          changed: false,
        },
        {
          name: '修改结算国家',
          path: "modifySettleCountry",
          changed:false,
        },
        {
          name: '政策币业务',
          path: "policyMoney",
          changed:false,
        }, {
          name: '分红配置',
          path: 'bonusConfig',
          changed:false,
        }
      ],
      rules: [],
      form: {
        applicantNo: "", //服务中心
        userLevel: "", //申请级别
        registerPrice: "", //注册金额
        registerPv: "", //注册业绩
        tjname: "", //推荐编号
        userLevel: "", //推荐姓名
        placeParent: "", //安置编号
        placeDept: "", //安置位置
        azname: "", //安置姓名
        memberName: "", //会员姓名
        phone: "", //联系方式
        userAwards: "", //真实奖衔
        userAwards: "", //是否结算
        zclx: "1", //注册类型
        backfillPrice: "", //回填金额
        idType: "", //证件类型
        preSaleStatus: "", //预售状态
        idCard: "", //证件号码
        deliveryWay: "", //发货方式
        tranType: "", //运输方式
        bankId: "", //银行名称
        bankCard: "", //银行卡号
        openingBranch: "", //开户支行
        openingName: "", //开户姓名
        reservedPhone: "", //预留电话
        email: "", //联系邮箱
        settleAccounts: "", //结算业绩
        transferAccounts: "", //传输业绩
        orderType: "", //订单类型
        pkCountry: "", //自然国家
        pkSettleCountry: "", //结算国家
        xgsp: 1, //选购商品
        processType: "", //签呈流程类型
      },
      kdzcList: [
        {
          value: "1",
          label: '空单注册',
        },
      ], //注册类型
      areaData: [],
      agreeList: [
        {
          text: '允许',
          val: 0,
        },
        {
          text: '禁止',
          val: 1,
        },
      ],
      tableData: [
        {
          receivingName: "",
          receivingPhone: "",
          province: "",
          city: "",
          county: "",
          address: "",
          remark: "",
          shoppingAddress: [],
        },
      ],
      productData: [],
      processTypeList: [],
      deliveryWayList: [], //发货方式
      transportTypeList: [], //运输方式
      orderTypeList: [], //订单类型
      presaleStatusList: [], //预售状态
      yesornoList: [], //是否
      cardTypeList: [], //证件类型
      pkAwardsList: [], //真实奖衔
      gradeAllList: [], //申请级别
      placeDeptList: [], //安置位置
      countryAllList: [], //自然/结算国家
      bankAllList: [], //银行卡
      regionParams: {
        label: "name",
        value: "id",
        children: "children",
        expandTrigger: "hover",
      },
      productShow: false,
      searchProduct: "",
      productTable: [],
      choiceGgShow: false, //产品规格弹窗
      choiceGgForm: {}, //单条产品规格
      pkWaresSpecsSkus: [],
    };
  },
  created() {
    this.getPubEnumsProcessTyepe();
    this.getOtherList();

    this.getUserRoute()
  },
  methods: {
    isLocals,
    getUserRoute() {
      getRouters().then((res)=>{
        res.data.forEach((item)=>{
          this.topList.forEach((items)=>{
            if (item.path == items.url){
              items.changed = true
            }
          })
        })
      })
    },
    //根据会员编号查会员姓名
    checkCode() {
      gettheMemberInfo(this.form.parent).then((res) => {
        this.form.tjname = res.data.memberName;
      });
    },
    checkCode2() {
      gettheMemberInfo(this.form.placeParent).then((res) => {
        this.form.azname = res.data.memberName;
      });
    },
    saveProduct() {
      spe
        .emptyOrderWares({ pkWaresSpecsSkus: this.pkWaresSpecsSkus })
        .then((res) => {
          if (res.code == 200) {
            this.productData = res.data;
            // console.log("🌈", res.data);
            this.productShow = false;
          }
        });
    },

    //商品规格多选
    handleSelectionChange(selection) {
      this.pkWaresSpecsSkus = [];
      console.log("🌈selection", selection);
      selection.forEach((element) => {
        if (element.spggTitle) {
          element.productEntnyOrderVoList.forEach((ele) => {
            ele.waresSpecsEntnyOrterVo.forEach((item) => {
              if (item.pkWaresSpecsSkus) {
                this.pkWaresSpecsSkus.push(item.pkWaresSpecsSkus);
              }
            });
          });
        } else {
          this.$message({
            message: "请先选择规格",
            type: "warning",
          });
          return;
        }
      });
    },
    //确认选择规格
    saveChoiceGg() {
      console.log("🌈商品", this.choiceGgForm);
      var spggTitle = "";
      this.choiceGgForm.productEntnyOrderVoList.forEach((item) => {
        for (var i = 0; i < item.waresSpecsEntnyOrterVo.length; i++) {
          if (item.waresSpecsEntnyOrterVo[i].quantity > 0) {
            spggTitle += item.waresSpecsEntnyOrterVo[i].specsName;
            this.productTable.forEach((el) => {
              if (el.pkWares == this.choiceGgForm.pkWares) {
                el.spggTitle = spggTitle;

                this.choiceGgShow = false;
                this.productShow = true;
                this.$forceUpdate();
              }
            });
            item.waresSpecsEntnyOrterVo[i].pkWaresSpecsSkus = {
              pkWaresSpecsSku: item.waresSpecsEntnyOrterVo[i].pkWaresSpecsSku,
              quantity: item.waresSpecsEntnyOrterVo[i].quantity,
            };
          }
        }
      });
    },
    //点击选择产品规格
    clickChoiceGg(row) {
      this.productShow = false;
      this.choiceGgShow = true;
      row.productEntnyOrderVoList.forEach((item, index) => {
        item.waresSpecsEntnyOrterVo.forEach((ctem, cndex) => {
          ctem.checked = false;
          ctem.quantity = 0;
          ctem.maxNum = 0;
        });
      });
      // 赋初值
      row.productEntnyOrderVoList.forEach((item, index) => {
        this.$set(item, "quantity", item.quantity * row.number);
        item.waresSpecsEntnyOrterVo.forEach((ctem, cndex) => {
          if (cndex == 0) {
            this.$set(ctem, "checked", true);
            this.$set(ctem, "quantity", item.quantity);
            this.$set(ctem, "maxNum", item.quantity);
          }
        });
      });

      this.choiceGgForm = row;
    },
    tapSku(index, cndex, quantity) {
      let ggNum = 0;
      this.choiceGgForm.productEntnyOrderVoList[
        index
      ].waresSpecsEntnyOrterVo.forEach((item) => {
        ggNum += item.quantity;
      });
      let tidai = quantity;

      if (quantity == 0) {
        tidai = 1;
      }
      if (ggNum < this.choiceGgForm.productEntnyOrderVoList[index].quantity) {
        this.$set(
          this.choiceGgForm.productEntnyOrderVoList[index]
            .waresSpecsEntnyOrterVo[cndex],
          "checked",
          true
        );
        this.$set(
          this.choiceGgForm.productEntnyOrderVoList[index]
            .waresSpecsEntnyOrterVo[cndex],
          "quantity",
          tidai
        );
        this.$forceUpdate();
      }

      if (
        this.choiceGgForm.productEntnyOrderVoList[index].quantity -
          (ggNum + tidai) >=
        0
      ) {
        this.choiceGgForm.productEntnyOrderVoList[
          index
        ].waresSpecsEntnyOrterVo.forEach((stem, sndex) => {
          if (sndex == cndex) {
            this.$set(
              stem,
              "maxNum",
              this.choiceGgForm.productEntnyOrderVoList[index].quantity - ggNum
            );
            this.$forceUpdate();
          } else {
            this.$set(
              stem,
              "maxNum",
              this.choiceGgForm.productEntnyOrderVoList[index].quantity -
                (ggNum + tidai - stem.quantity)
            );
            this.$forceUpdate();
          }
        });
      }
      // this.calPrice()
      this.$forceUpdate();
    },
    getNum(index, cndex, quantity) {
      // 数量为0，关闭高亮
      if (quantity == 0) {
        this.$set(
          this.choiceGgForm.productEntnyOrderVoList[index]
            .waresSpecsEntnyOrterVo[cndex],
          "checked",
          false
        );
        this.$forceUpdate();
      } else {
        this.$set(
          this.choiceGgForm.productEntnyOrderVoList[index]
            .waresSpecsEntnyOrterVo[cndex],
          "checked",
          true
        );
        this.$forceUpdate();
      }
      let ggNum = 0;
      this.choiceGgForm.productEntnyOrderVoList[
        index
      ].waresSpecsEntnyOrterVo.forEach((item) => {
        ggNum += item.quantity;
      });
      if (
        this.choiceGgForm.productEntnyOrderVoList[index].quantity - quantity >=
        0
      ) {
        this.choiceGgForm.productEntnyOrderVoList[
          index
        ].waresSpecsEntnyOrterVo.forEach((stem, sndex) => {
          if (sndex != cndex) {
            this.$set(
              stem,
              "maxNum",
              this.choiceGgForm.productEntnyOrderVoList[index].quantity -
                (ggNum - stem.quantity)
            );
            this.$forceUpdate();
          }
        });
      }
    },
    handleChange() {},
    //选择产品
    choiceProduct() {
      this.productShow = true;
      spe.getWaresList().then((res) => {
        res.data.forEach((ele) => {
          ele.number = 1;
        });
        this.productTable = res.data;
      });
    },
    getProductSearch() {
      spe.getWaresList({ waresName: this.searchProduct }).then((res) => {
        this.productTable = res.data;
      });
    },
    saveDate(index) {
      this.$refs["form"].validate((valid) => {
        if (!valid) {
          this.$message({
            message:'请填写必填项',
            type:'warning'
          })
          return false;
        } else {
          this.form.processType = index;

          //点击下方按钮
          if (this.tableData[0].shoppingAddress.length > 0) {
            this.tableData[0].province = this.tableData[0].shoppingAddress[0];
            this.tableData[0].city = this.tableData[0].shoppingAddress[1];
            this.tableData[0].county = this.tableData[0].shoppingAddress[2];
            if (index == 2 || index == 4) {

              this.$router.push({
                path: "emptyZxqc",
                query: {
                  data: JSON.stringify(
                    Object.assign({}, this.form, this.tableData[0], {
                      orderItems: this.productData,
                    })
                  ),
                  processType: this.form.processType,
                  businessType: 252,
                },
              });
            } else if (index == 1 || index == 3) {
              spe
                .getRegisterEnptyOrder({
                  orderBlankRegParams: Object.assign(
                    {},
                    this.form,
                    this.tableData[0],
                    { orderItems: this.productData }
                  ),
                  processType: this.form.processType,
                })
                .then((res) => {
                  if (res.code == 200) {
                    this.$message({
                      message: res.msg,
                      type: "success",
                    });
                  }
                });
            } else if (index == 0) {
              return;
            }
          } else {
            this.$message({
              message: '请先选择省市区',
              type: "warning",
            });
            return;
          }
        }
      });
    },
    getPubEnumsProcessTyepe() {
      getPubEnumsProcessTyepe().then((res) => {
        this.processTypeList = res.data;
      });
    },
    getOtherList() {
      log.getOrderType().then((res) => {
        this.orderTypeList = res.data;
      });
      del.getDeliveryWayList().then((res) => {
        this.deliveryWayList = res.data;
      });
      del.getTransportType().then((res) => {
        this.transportTypeList = res.data;
      });
      del.getPresaleStatus().then((res) => {
        this.presaleStatusList = res.data;
      });
      del.getDealerYesNo().then((res) => {
        this.yesornoList = res.data;
      });
      getAwardsListChiose().then((res) => {
        this.pkAwardsList = res.rows;
      });
      spe.getCardTypeList().then((res) => {
        this.cardTypeList = res.data;
      });
      spe.getGradeAllList().then((res) => {
        this.gradeAllList = res.data;
      });
      spe.getBankFindAll().then((res) => {
        this.bankAllList = res.data;
      });
      spe.getCountryFindAll().then((res) => {
        this.countryAllList = res.data;
      });
      spe.getPlacedeptList().then((res) => {
        this.placeDeptList = res.data;
      });
      api.areaList().then((res) => {
        this.areaData = res.data;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-form-item {
  margin-bottom: 10px;
}
.gui {
  display: flex;
  margin: 20px 0;
  // border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px 20px;
  flex-direction: column;
  .gui_t {
    padding-top: 30px;
    display: flex;
    align-items: center;
    .gui_tt {
      margin-left: 10px;
      .coloNum {
        color: #b42b2a;
        font-weight: 600;
      }
    }
  }
  .gui_b {
    display: flex;
    align-items: center;
    margin-top: 10px;
    .gui_bt {
      line-height: 85px;
    }
    .gui_bb {
      margin-left: 10px;
      flex: 1;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
    }
    .gui_i {
      position: relative;
    }
    .gui_ii {
      display: flex;
      justify-content: center;
      align-items: center;
      background: #ededed;
      border-radius: 10px;
      font-size: 18px;
      color: #333333;
      margin: 5px 60px 40px 0;
      padding: 10px;
    }
    .gui_a {
      background: #ff5654;
      color: #fff;
    }
    .jbq {
      position: absolute;
      top: 60px;
      margin-right: 30px;
    }
  }
}
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px 0;

  .thebtn0 {
    width: 120px;
    height: 38px;
  }
  .thebtn1 {
    width: 120px;
    height: 38px;
    background: rgba(0, 155, 88, 1);
    color: #ffffff;
    border: none;
  }
  .thebtn2 {
    width: 120px;
    height: 38px;
    background: rgba(243, 169, 0, 1);
    border: none;
    color: #ffffff;
  }
  .thebtn3 {
    width: 120px;
    height: 38px;
    border: none;
    color: #ffffff;
    background: rgba(228, 27, 27, 1);
  }
  .thebtn4 {
    width: 120px;
    height: 38px;
    border: none;
    color: #ffffff;
    background: rgba(72, 178, 253, 1);
  }
  .thebtn {
    width: 120px;
    height: 38px;
    border: none;
    color: #ffffff;
    background: rgba(204, 204, 204, 1);
  }
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}
.page1 {
  // height: calc(100vh - 50px);
  padding: 10px;
  overflow: hidden;
  background: #f9f9f9;
  padding-bottom: 80px;
  .main {
    display: flex;
    flex-direction: column;
    // height: calc(100vh - 124px);
    overflow: hidden;
  }
  .contain {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    margin: 10px 0 0 0;
    height: 100%;
    overflow-y: auto;
    padding: 10px 20px;
    .maintop {
      display: flex;
      padding-bottom: 10px;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn1 {
          background: rgba(0, 155, 88, 1);
          color: #ffffff;
          height: 32px;
        }
        .thebtn2 {
          background: #ffad41;
          color: #ffffff;
        }
      }
    }
  }
}

.footer {
  height: 68px;
  background: #ffffff;
  box-shadow: 0px -3px 20px 0px rgba(204, 204, 204, 0.5);
  // margin: 0 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  // width: 1700px;
  .thebtn1 {
    background: #3181e5;
    color: #ffffff;
    padding: 9px 45px;
  }
  .thebtn2 {
    background: #cccccc;
    color: #ffffff;
    padding: 9px 45px;
  }
  .thebtn3 {
    background: #53b11e;
    color: #ffffff;
    padding: 9px 45px;
  }
  .thebtn4 {
    background: #ffad41;
    color: #ffffff;
    padding: 9px 45px;
  }
}
.xian {
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}
.tit {
  font-size: 14px;
  font-weight: bold;
  color: #333333;
  padding: 0 20px;
  border-left: 5px solid #4391fd;
  margin: 8px 0;
  margin-right: -20px;
}
</style>
