<template>
  <div
      id="electronics_invoice"
      class="body"
      v-loading="load"
      element-loading-text="开具中，请稍等"
  >
    <div
        class="body"
        v-loading="electronicsStatus"
        :element-loading-text="electronicsMessage"
        element-loading-spinner="22"
    >
      <div>
        <div class="invoice_print">
          <div v-if="status == 0" class="flex: 1">
            <!--            <el-radio-group class="invoice_radio" v-model="numericalValue">-->
            <!--                <el-radio-button label="正数"></el-radio-button>-->
            <!--                <el-radio-button label="负数"></el-radio-button>-->
            <!--            </el-radio-group>-->
            <!--            <el-radio-group class="invoice_radio" v-model="taxation">-->
            <!--                <el-radio-button label="普通征税"></el-radio-button>-->
            <!--                <el-radio-button label="差额征税"></el-radio-button>-->
            <!--            </el-radio-group>-->
            <el-radio-group
                class="invoice_radio"
                v-model="taxIncluded"
                v-on:change="taxIncludedState"
            >
              <el-radio-button label="含税"></el-radio-button>
              <el-radio-button label="不含税"></el-radio-button>
            </el-radio-group>
            <el-radio-group
                class="invoice_radio"
                v-model="detailed"
                v-on:change="detailedState"
            >
              <el-radio-button label="明细"></el-radio-button>
              <el-radio-button label="清单"></el-radio-button>
            </el-radio-group>
            <div class="invoice_radio">
              <Policy2022040101EnableSwitch>
                <el-link type="warning" @click="handlePolicy2022040101Detail">详情>></el-link>
              </Policy2022040101EnableSwitch>
            </div>
          </div>
          <div class="flex: 1">
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="showInvoiceInfo"
                v-if="status == 0"
            >发票概览
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="seeProductList"
                v-if="status === 0"
            >查看商品信息
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="invoiceCopy"
                v-if="status == 0"
            >复制开票
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="exportTemplate"
                v-if="status === 0"
            >
              发票清单导入模版
            </el-button>
          </div>
        </div>
        <div class="invoice_print">
          <div>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="addDomain"
                v-if="status === 0"
            >新增行
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="removeDomain"
                v-if="status === 0"
            >删除行
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="productDiscountShow"
                v-if="status === 0 && invoiceOperation === 0"
            >折扣行
            </el-button>
            <input
                ref="excel-import"
                style="display: none"
                type="file"
                accept=".xls, .xlsx"
                @change="excelDataImport"
            />
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="invoiceListImport"
                v-if="status === 0 || status === 3"
            >发票清单导入
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="nextInvoice"
                v-if="status == 1"
            >下一张
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="handleDownloadInvoicePDF"
                v-if="status == 1"
            >下载PDF格式发票
            </el-button>
          </div>
          <div>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="invoiceTemporaryStorage"
                v-if="status === 0 || status === 3"
            >暂存
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="invoiceTemporaryStorageLoad"
                v-if="status === 0 || status === 3"
            >加载
            </el-button>
            <el-button
                style="
                                width: 170px;
                                margin: 5px;
                                background: #e9967a;
                                border-color: #e9967a;
                            "
                type="primary"
                v-on:click="handlePolicy20230109InvoiceSubmit"
                v-if="status == 0"
            >提交开票
            </el-button>
          </div>
        </div>
        <div style="margin-top: 20px">
          <div id="invoice-container" class="invoice">
            <ul class="pointGroup">
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
            </ul>
            <div class="invoiceMain">
              <div class="invoiceType electric">
                <i class="iconfont bw-dianpiao"></i>
              </div>
              <div class="ticket-type">
                <span></span>
              </div>
              <div class="region">
                <span>增值税电子发票</span>
                <p class="hr"></p>
              </div>
              <div class="invoice-head">
                <p class="fontColor fl">
                  机器编号：
                  <span class="elecColor">{{
                      machineNo
                    }}</span>
                </p>
              </div>
              <div class="invoice-right-header">
                <p class="fontColor">
                  发票代码：
                  <span class="date">{{ invoiceCode }}</span>
                </p>
                <p class="fontColor">
                  发票号码：
                  <span class="date">{{
                      invoiceNumber
                    }}</span>
                </p>
                <p class="fontColor">
                  开票日期：
                  <span class="date">{{ nowTime }}</span>
                </p>
                <p class="fontColor">
                  校验码：
                  <span class="date">{{
                      invoiceCheckCode
                    }}</span>
                </p>
              </div>
              <div class="invoice-body">
                <div data-v-ab32345e class="grid-hf">
                  <div
                      data-v-ab32345e
                      class="grid-hf-col col-a"
                  >
                    购买单位
                  </div>
                  <div
                      data-v-ab32345e
                      class="grid-hf-col col-b roll-height"
                  >
                    <ul data-v-ab32345e class="trader">
                      <li
                          data-v-ab32345e
                          v-if="status == 0"
                      >
                                                <span
                                                    data-v-ab32345e
                                                    class="label"
                                                >名称</span
                                                >：
                        <div
                            data-v-ab32345e
                            style="
                                                        display: inline-block;
                                                        width: 72.5%;
                                                        margin-left: 1px;
                                                    "
                        >
                          <div
                              data-v-ab32345e
                              class="ivu-auto-complete input name ivu-select ivu-select-single ivu-select-default"
                              remote
                              type="text"
                          >
                            <div
                                tabindex="-1"
                                class
                            >
                              <div
                                  class="ivu-input-wrapper ivu-input-wrapper-default ivu-input-type"
                              >
                                <i
                                    class="ivu-icon ivu-icon-ios-loading ivu-load-loop ivu-input-icon ivu-input-icon-validate"
                                ></i>
                                <input
                                    autocomplete="off"
                                    v-model.trim="purchaserName"
                                    spellcheck="false"
                                    type="text"
                                    placeholder
                                    class="ivu-input ivu-input-default"
                                    v-on:input="buyerChange"
                                    v-on:blur="showBlur"
                                    v-on:focus="showHistory"
                                />
                              </div>
                              <div
                                  v-if="isShow == true"
                                  style="
                                                                    position: absolute;
                                                                    background-color: #ffffff;
                                                                    width: 370px;
                                                                    height: 250px;
                                                                    z-index: 1;
                                                                    border-style: solid;
                                                                    border-width: 1px;
                                                                    border-color: #cc7200;
                                                                "
                              >
                                <ul>
                                  <li
                                      v-bind:key="
                                                                            index
                                                                        "
                                      v-for="(
                                                                            row,
                                                                            index
                                                                        ) in buyerData"
                                      style="
                                                                            margin: 5px;
                                                                        "
                                  >
                                    <a v-if="index < 10" v-on:click="selectCustomerData(row)">{{row.customerName }}</a>
                                  </li>
                                </ul>
                              </div>
                              <div
                                  v-if="isHistoryShow === true"
                                  style="position: absolute;background-color: #ffffff;
                                         width: 370px;
                                         height: 250px;
                                         z-index: 1;
                                         border-style: solid;
                                         border-width: 1px;
                                         border-color: #cc7200;"
                              >
                                <ul>
                                  <li
                                      v-bind:key="index"
                                      v-for="(historyName, index) in historyData"
                                      style="margin: 5px;"
                                  >
                                    <a v-on:click="historyNameSelect(historyName)">{{ historyName }}</a>
                                  </li>
                                </ul>
                              </div>
                            </div>
                          </div>
                        </div>
                        <span
                            data-v-ab32345e
                            class="selector ellipsis2 skin-background"
                            v-on:click="
                                                        selectCustomer()
                                                    "
                        >···</span
                        >
                      </li>
                      <li
                          data-v-ab32345e
                          v-if="status == 1"
                      >
                                                <span
                                                    data-v-ab32345e
                                                    class="label"
                                                >名称</span
                                                >：
                        <div
                            data-v-ab32345e
                            style="
                                                        display: inline-block;
                                                        width: 72.5%;
                                                        margin-left: 1px;
                                                    "
                        >
                          <div
                              data-v-ab32345e
                              class="ivu-auto-complete input name ivu-select ivu-select-single ivu-select-default"
                              remote
                              type="text"
                          >
                            <div
                                tabindex="-1"
                                class
                            >
                              <div
                                  class="ivu-input-wrapper ivu-input-wrapper-default ivu-input-type"
                              >
                                <i
                                    class="ivu-icon ivu-icon-ios-loading ivu-load-loop ivu-input-icon ivu-input-icon-validate"
                                ></i>
                                <input
                                    autocomplete="off"
                                    v-model.trim="
                                                                        purchaserName
                                                                    "
                                    spellcheck="false"
                                    type="text"
                                    placeholder
                                    class="ivu-input ivu-input-default"
                                    readonly="readonly"
                                />
                              </div>
                            </div>
                          </div>
                        </div>
                      </li>
                      <li
                          data-v-ab32345e
                          v-if="status == 0"
                      >
                                                <span
                                                    data-v-ab32345e
                                                    class="label"
                                                >纳税人识别号</span
                                                >：
                        <input
                            data-v-ab32345e
                            type="text"
                            v-model.trim="taxNumber"
                            class="input"
                        />
                      </li>
                      <li
                          data-v-ab32345e
                          v-if="status == 1"
                      >
                                                <span
                                                    data-v-ab32345e
                                                    class="label"
                                                >纳税人识别号</span
                                                >：
                        <input
                            data-v-ab32345e
                            type="text"
                            v-model.trim="taxNumber"
                            class="input"
                            readonly="readonly"
                        />
                      </li>
                      <li
                          data-v-ab32345e
                          v-if="status == 0"
                      >
                                                <span
                                                    data-v-ab32345e
                                                    class="label"
                                                >地址、电话</span
                                                >：
                        <input
                            data-v-ab32345e
                            type="text"
                            class="input"
                            v-model.trim="addressPhone"
                        />
                      </li>
                      <li
                          data-v-ab32345e
                          v-if="status == 1"
                      >
                                                <span
                                                    data-v-ab32345e
                                                    class="label"
                                                >地址、电话</span
                                                >：
                        <input
                            data-v-ab32345e
                            type="text"
                            class="input"
                            v-model.trim="addressPhone"
                            readonly="readonly"
                        />
                      </li>
                      <li
                          data-v-ab32345e
                          v-if="status == 0"
                      >
                                                <span
                                                    data-v-ab32345e
                                                    class="label"
                                                >开户行及账号</span
                                                >：
                        <input
                            data-v-ab32345e
                            type="text"
                            class="input"
                            v-model.trim="openingBank"
                        />
                      </li>
                      <li
                          data-v-ab32345e
                          v-if="status == 1"
                      >
                                                <span
                                                    data-v-ab32345e
                                                    class="label"
                                                >开户行及账号</span
                                                >：
                        <input
                            data-v-ab32345e
                            type="text"
                            class="input"
                            v-model.trim="openingBank"
                            readonly="readonly"
                        />
                      </li>
                    </ul>
                  </div>
                  <div
                      data-v-ab32345e
                      class="grid-hf-col col-c"
                  >
                    密码区
                  </div>
                  <div
                      data-v-ab32345e
                      class="grid-hf-col col-d last"
                  >
                    <p
                        data-v-ab32345e
                        class="password-area"
                    >
                      {{ taxControlCode }}
                    </p>
                  </div>
                </div>
                <div class="grid-list">
                  <div class="grid-list-main">
                    <div class="grid-list-head">
                      <div
                          class="grid-list-col col-index"
                      >
                        行号
                      </div>
                      <div
                          class="grid-list-col col-index"
                          v-if="checkShow"
                      >
                        <el-checkbox
                            :indeterminate="
                                                        isIndeterminate
                                                    "
                            v-model="productCheckAll"
                            v-on:change="
                                                        productCheckAllChange
                                                    "
                        ></el-checkbox>
                      </div>
                      <div
                          class="grid-list-col col-a"
                          v-if="isDetailed == false"
                      >
                                                <span
                                                >货物或应税劳务.服务名称</span
                                                >
                      </div>
                      <div
                          class="grid-list-col col-a"
                          v-if="isDetailed == true"
                      >
                                                <span class="fontColor: red"
                                                >(清单)</span
                                                >货物或应税劳务.服务名称
                      </div>
                      <div class="grid-list-col col-b">
                        规格型号
                      </div>
                      <div class="grid-list-col col-c">
                        单位
                      </div>
                      <div class="grid-list-col col-d">
                        数 量
                      </div>
                      <div
                          class="grid-list-col col-e"
                          v-if="isTaxIncluded == false"
                      >
                        单价
                        <span>(不含税)</span>
                      </div>
                      <div
                          class="grid-list-col col-e"
                          v-if="isTaxIncluded == true"
                      >
                        单价
                        <span class="fontColor: red"
                        >(含税)</span
                        >
                      </div>
                      <div
                          class="grid-list-col col-f"
                          v-if="isTaxIncluded == false"
                      >
                        金额
                        <span>(不含税)</span>
                      </div>
                      <div
                          class="grid-list-col col-f"
                          v-if="isTaxIncluded == true"
                      >
                        金额
                        <span class="fontColor: red"
                        >(含税)</span
                        >
                      </div>
                      <div class="grid-list-col col-g">
                        税率
                      </div>
                      <div
                          class="grid-list-col col-h col-i tax"
                      >
                        税 额
                      </div>
                      <div
                          class="grid-list-col col-j last"
                      ></div>
                    </div>
                    <el-form
                        :model="productData"
                        ref="dynamicValidateForm"
                        class="from-item"
                    >
                      <div class="grid-list-body">
                        <div
                            class="grid-list-body-outline"
                        >
                          <div
                              class="grid-list-col col-index"
                          ></div>
                          <div
                              class="grid-list-col col-index"
                              v-if="checkShow"
                          ></div>
                          <div
                              class="grid-list-col col-a"
                          ></div>
                          <div
                              class="grid-list-col col-b"
                          ></div>
                          <div
                              class="grid-list-col col-c"
                          ></div>
                          <div
                              class="grid-list-col col-d"
                          ></div>
                          <div
                              class="grid-list-col col-e"
                          ></div>
                          <div
                              class="grid-list-col col-f"
                          ></div>
                          <div
                              class="grid-list-col col-g"
                          ></div>
                          <div
                              class="grid-list-col col-h col-i tax"
                          ></div>
                          <div
                              class="grid-list-col col-j last"
                          ></div>
                        </div>
                        <div
                            class="grid-list-body-data"
                        >
                          <div
                              class="grid-list-item"
                              v-bind:key="index"
                              v-for="(
                                                            domain, index
                                                        ) in productData.product"
                          >
                            <div
                                class="grid-list-col col-index"
                            >
                              {{ index + 1 }}
                            </div>
                            <div
                                class="grid-list-col col-index"
                                v-if="checkShow"
                            >
                              <el-checkbox
                                  v-bind:key="
                                                                    index
                                                                "
                                  v-model="
                                                                    domain.productCheck
                                                                "
                                  v-on:change="
                                                                    productCheckChange
                                                                "
                              ></el-checkbox>
                            </div>
                            <div
                                class="grid-list-col col-a"
                                v-if="
                                                                domain.rowStatus ==
                                                                    0 ||
                                                                domain.rowStatus ==
                                                                    4
                                                            "
                            >
                              <div
                                  style="
                                                                    display: inline-block;
                                                                    width: 85%;
                                                                "
                              >
                                <div
                                    class="ivu-auto-complete name ivu-select ivu-select-single ivu-select-default"
                                    remote
                                    type="text"
                                >
                                  <div
                                      tabindex="-1"
                                      class
                                  >
                                    <div
                                        class="ivu-input-wrapper ivu-input-wrapper-default ivu-input-type ground"
                                    >
                                      <i
                                          class="ivu-icon ivu-icon-ios-loading ivu-load-loop ivu-input-icon ivu-input-icon-validate"
                                      ></i>
                                      <input
                                          autocomplete="off"
                                          spellcheck="false"
                                          type="text"
                                          placeholder
                                          v-model="domain.productName"
                                          class="ivu-input ivu-input-default"
                                          v-on:blur="showProductBlur"
                                          v-on:input="searchProductChange(domain.productName, index)"
                                      />
                                    </div>
                                  </div>
                                </div>
                              </div>
                              <span
                                  class="selector ellipsis skin-background"
                                  v-on:click="
                                                                    selectCommodity(
                                                                        index
                                                                    )
                                                                "
                              >...</span
                              >
                            </div>
                            <div
                                class="grid-list-col col-a"
                                v-if="
                                                                domain.rowStatus ==
                                                                    1 ||
                                                                domain.rowStatus ==
                                                                    3
                                                            "
                            >
                              <div
                                  style="
                                                                    display: inline-block;
                                                                    width: 85%;
                                                                "
                              >
                                <div
                                    class="ivu-auto-complete name ivu-select ivu-select-single ivu-select-default"
                                    remote
                                    type="text"
                                >
                                  <div
                                      tabindex="-1"
                                      class
                                  >
                                    <div
                                        class="ivu-input-wrapper ivu-input-wrapper-default ivu-input-type ground"
                                    >
                                      <i
                                          class="ivu-icon ivu-icon-ios-loading ivu-load-loop ivu-input-icon ivu-input-icon-validate"
                                      ></i>
                                      <input
                                          autocomplete="off"
                                          spellcheck="false"
                                          type="text"
                                          placeholder
                                          readonly="readonly"
                                          v-model="
                                                                                    domain.productName
                                                                                "
                                          class="ivu-input ivu-input-default"
                                      />
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                            <div
                                class="grid-list-col col-a"
                                v-if="
                                                                domain.rowStatus ==
                                                                2
                                                            "
                            >
                              <div
                                  style="
                                                                    display: inline-block;
                                                                    width: 85%;
                                                                "
                              >
                                <div
                                    class="ivu-auto-complete name ivu-select ivu-select-single ivu-select-default"
                                    remote
                                    type="text"
                                >
                                  <div
                                      tabindex="-1"
                                      class
                                  >
                                    <div
                                        class="ivu-input-wrapper ivu-input-wrapper-default ivu-input-type ground"
                                    >
                                      <i
                                          class="ivu-icon ivu-icon-ios-loading ivu-load-loop ivu-input-icon ivu-input-icon-validate"
                                      ></i>
                                      <input
                                          autocomplete="off"
                                          spellcheck="false"
                                          type="text"
                                          placeholder
                                          readonly="readonly"
                                          style="
                                                                                    color: red;
                                                                                "
                                          v-model="
                                                                                    domain.productName
                                                                                "
                                          class="ivu-input ivu-input-default"
                                      />
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                            <div
                                class="grid-list-col col-b"
                                v-if="
                                                                domain.rowStatus ==
                                                                    0 ||
                                                                domain.rowStatus ==
                                                                    4
                                                            "
                            >
                              <input
                                  type="text"
                                  class="input"
                                  v-model="
                                                                    domain.specification
                                                                "
                              />
                            </div>
                            <div
                                class="grid-list-col col-b"
                                v-if="
                                                                domain.rowStatus !=
                                                                    0 &&
                                                                domain.rowStatus !=
                                                                    4
                                                            "
                            >
                              <input
                                  type="text"
                                  readonly="readonly"
                                  class="input"
                                  v-model="
                                                                    domain.specification
                                                                "
                              />
                            </div>
                            <div
                                class="grid-list-col col-c"
                                v-if="
                                                                domain.rowStatus ==
                                                                    0 ||
                                                                domain.rowStatus ==
                                                                    4
                                                            "
                            >
                              <input
                                  type="text"
                                  class="input"
                                  v-model="
                                                                    domain.units
                                                                "
                              />
                            </div>
                            <div
                                class="grid-list-col col-c"
                                v-if="
                                                                domain.rowStatus !=
                                                                    0 &&
                                                                domain.rowStatus !=
                                                                    4
                                                            "
                            >
                              <input
                                  type="text"
                                  readonly="readonly"
                                  class="input"
                                  v-model="
                                                                    domain.units
                                                                "
                              />
                            </div>
                            <div
                                class="grid-list-col col-d"
                                v-if="
                                                                domain.rowStatus ==
                                                                    0 ||
                                                                domain.rowStatus ==
                                                                    4
                                                            "
                            >
                              <div
                                  data-v-33b11dca
                                  class
                              >
                                <input
                                    data-v-33b11dca
                                    type="text"
                                    autocomplete="off"
                                    class="input"
                                    v-model="
                                                                        domain.number
                                                                    "
                                    v-on:change="
                                                                        numberChange(
                                                                            domain.number,
                                                                            index
                                                                        )
                                                                    "
                                />
                              </div>
                            </div>
                            <div
                                class="grid-list-col col-d"
                                v-if="
                                                                domain.rowStatus !=
                                                                    0 &&
                                                                domain.rowStatus !=
                                                                    4
                                                            "
                            >
                              <div
                                  data-v-33b11dca
                                  class
                              >
                                <input
                                    data-v-33b11dca
                                    type="text"
                                    autocomplete="off"
                                    readonly="readonly"
                                    class="input"
                                    v-model="
                                                                        domain.number
                                                                    "
                                />
                              </div>
                            </div>
                            <div
                                class="grid-list-col col-e"
                                v-if="
                                                                domain.rowStatus ==
                                                                    0 ||
                                                                domain.rowStatus ==
                                                                    4
                                                            "
                            >
                              <div
                                  data-v-33b11dca
                                  class
                              >
                                <input
                                    data-v-33b11dca
                                    type="text"
                                    autocomplete="off"
                                    class="input"
                                    v-model="
                                                                        domain.price
                                                                    "
                                    v-on:change="
                                                                        priceChange(
                                                                            domain.price,
                                                                            index
                                                                        )
                                                                    "
                                />
                              </div>
                            </div>
                            <div
                                class="grid-list-col col-e"
                                v-if="
                                                                domain.rowStatus !=
                                                                    0 &&
                                                                domain.rowStatus !=
                                                                    4
                                                            "
                            >
                              <div
                                  data-v-33b11dca
                                  class
                              >
                                <input
                                    data-v-33b11dca
                                    type="text"
                                    autocomplete="off"
                                    readonly="readonly"
                                    class="input"
                                    v-model="
                                                                        domain.price
                                                                    "
                                    v-on:change="
                                                                        priceChange(
                                                                            domain.price,
                                                                            index
                                                                        )
                                                                    "
                                />
                              </div>
                            </div>
                            <div
                                class="grid-list-col col-f"
                                v-if="
                                                                domain.rowStatus ==
                                                                    0 ||
                                                                domain.rowStatus ==
                                                                    4
                                                            "
                            >
                              <div
                                  data-v-33b11dca
                                  class
                              >
                                <input
                                    data-v-33b11dca
                                    type="text"
                                    autocomplete="off"
                                    class="input"
                                    v-model="
                                                                        domain.amount
                                                                    "
                                    v-on:change="
                                                                        amountChange(
                                                                            domain.amount,
                                                                            index
                                                                        )
                                                                    "
                                />
                              </div>
                            </div>
                            <div
                                class="grid-list-col col-f"
                                v-if="
                                                                domain.rowStatus ==
                                                                2
                                                            "
                            >
                              <div
                                  data-v-33b11dca
                                  class
                              >
                                <input
                                    data-v-33b11dca
                                    type="text"
                                    autocomplete="off"
                                    readonly="readonly"
                                    style="
                                                                        color: red;
                                                                    "
                                    class="input"
                                    v-model="
                                                                        domain.amount
                                                                    "
                                    v-on:change="
                                                                        amountChange(
                                                                            domain.amount,
                                                                            index
                                                                        )
                                                                    "
                                />
                              </div>
                            </div>
                            <div
                                class="grid-list-col col-f"
                                v-if="
                                                                domain.rowStatus ==
                                                                    1 ||
                                                                domain.rowStatus ==
                                                                    3
                                                            "
                            >
                              <div
                                  data-v-33b11dca
                                  class
                              >
                                <input
                                    data-v-33b11dca
                                    type="text"
                                    autocomplete="off"
                                    readonly="readonly"
                                    class="input"
                                    v-model="
                                                                        domain.amount
                                                                    "
                                    v-on:change="
                                                                        amountChange(
                                                                            domain.amount,
                                                                            index
                                                                        )
                                                                    "
                                />
                              </div>
                            </div>
                            <div
                                class="grid-list-col col-g"
                                v-if="
                                                                domain.rowStatus ==
                                                                0
                                                            "
                            >
                              <select
                                  class
                                  style="
                                                                    width: 96%;
                                                                "
                                  v-model="
                                                                    domain.taxRate
                                                                "
                                  v-on:change="
                                                                    rateChange(
                                                                        $event,
                                                                        index
                                                                    )
                                                                "
                              >
                                <option
                                    :value="
                                                                        value
                                                                    "
                                    v-bind:key="
                                                                        row
                                                                    "
                                    v-for="(
                                                                        value,
                                                                        row
                                                                    ) in domain.taxRates"
                                >
                                  {{ isNaN(value * 100)?value: `${value * 100}%`}}
                                </option>
                              </select>
                            </div>
                            <div
                                class="grid-list-col col-g"
                                v-if="
                                                                domain.rowStatus !==
                                                                    0 &&
                                                                domain.zeroRateFlag ===
                                                                    null
                                                            "
                            >
                              <select
                                  class
                                  style="
                                                                    width: 96%;
                                                                "
                                  v-model="
                                                                    domain.taxRate
                                                                "
                                  v-on:change="
                                                                    rateChange(
                                                                        $event,
                                                                        index
                                                                    )
                                                                "
                                  disabled="true"
                              >
                                <option
                                    :value="
                                                                        value
                                                                    "
                                    v-bind:key="
                                                                        row
                                                                    "
                                    v-for="(
                                                                        value,
                                                                        row
                                                                    ) in domain.taxRates"
                                >
                                  {{ isNaN(value * 100)?value: `${value * 100}%`}}
                                </option>
                              </select>
                            </div>
                            <div
                                class="grid-list-col col-g"
                                v-if="
                                                                domain.rowStatus !==
                                                                    0 &&
                                                                domain.zeroRateFlag ===
                                                                    1
                                                            "
                            >
                              <input
                                  type="text"
                                  class="input"
                                  v-model="
                                                                    taxRateFree
                                                                "
                                  :disabled="true"
                                  :title="
                                                                    domain.preferentialType
                                                                "
                              />
                            </div>
                            <div
                                class="grid-list-col col-g"
                                v-if="
                                                                domain.rowStatus !==
                                                                    0 &&
                                                                domain.zeroRateFlag ===
                                                                    2
                                                            "
                            >
                              <input
                                  type="text"
                                  class="input"
                                  v-model="
                                                                    taxRateNo
                                                                "
                                  :disabled="true"
                                  :title="
                                                                    domain.preferentialType
                                                                "
                              />
                            </div>
                            <!--                            <div class="grid-list-col col-g"-->
                            <!--                                v-if="domain.rowStatus !== 0 && domain.preferentialFlag === 1">-->
                            <!--                              <input type="text" class="input" v-model="domain.preferentialType"-->
                            <!--                                  :disabled="true"-->
                            <!--                                  :title="domain.preferentialType"/>-->
                            <!--                            </div>-->
                            <div
                                class="grid-list-col col-h col-i tax"
                                v-if="
                                                                domain.rowStatus !=
                                                                2
                                                            "
                            >
                              <input
                                  type="text"
                                  readonly="readonly"
                                  class="input"
                                  v-model="
                                                                    domain.taxAmount
                                                                "
                              />
                            </div>
                            <div
                                class="grid-list-col col-h col-i tax"
                                v-if="
                                                                domain.rowStatus ==
                                                                2
                                                            "
                            >
                              <input
                                  type="text"
                                  readonly="readonly"
                                  style="
                                                                    color: red;
                                                                "
                                  class="input"
                                  v-model="
                                                                    domain.taxAmount
                                                                "
                              />
                            </div>
                          </div>
                          <div v-if="isProductSearchShow === true"
                               style="position: relative; background-color: #FFFFFF; width: 270px;height: 100px; z-index: 999;
                                border-style: solid;border-width: 1px;border-color: #cc7200; left: 80px">
                            <ul style="z-index: 999">
                              <li v-bind:key="index" v-for="(row, index) in productList" style="margin: 5px">
                                <a v-if="index < 4" style="font-size: 13px" v-on:click="handleUseProduct(row)">
                                  {{ row.productName + " " + row.specsModel + " " + row.unit }}
                                </a>
                              </li>
                            </ul>
                          </div>
                        </div>
                      </div>
                    </el-form>
                    <div class="grid-list-foot">
                      <div
                          class="grid-list-col col-a sum red"
                      >
                        合计折扣
                      </div>
                      <div class="grid-list-col col-b">
                        &nbsp;
                      </div>
                      <div class="grid-list-col col-c">
                        &nbsp;
                      </div>
                      <div class="grid-list-col col-d">
                        &nbsp;
                      </div>
                      <div class="grid-list-col col-e">
                        &nbsp;
                      </div>
                      <div class="grid-list-col col-f">
                        {{ discountTotalAmount }}
                      </div>
                      <div
                          class="grid-list-col col-g"
                      ></div>
                      <div class="grid-list-col col-h">
                        {{ discountTotalRate }}
                      </div>
                      <div class="grid-list-col col-i">
                        &nbsp;
                      </div>
                      <div
                          class="grid-list-col col-j last"
                      >
                        &nbsp;
                      </div>
                    </div>
                    <div class="grid-list-foot">
                      <div
                          class="grid-list-col col-a sum"
                      >
                        合计
                      </div>
                      <div class="grid-list-col col-b">
                        &nbsp;
                      </div>
                      <div class="grid-list-col col-c">
                        &nbsp;
                      </div>
                      <div class="grid-list-col col-d">
                        &nbsp;
                      </div>
                      <div class="grid-list-col col-e">
                        &nbsp;
                      </div>
                      <div class="grid-list-col col-f">
                        ￥
                        <span>{{ totalAmount }}</span>
                      </div>
                      <div
                          class="grid-list-col col-g"
                      ></div>
                      <div class="grid-list-col col-h">
                        ￥{{ totalTaxAmount }}
                      </div>
                      <div class="grid-list-col col-i">
                        &nbsp;
                      </div>
                      <div
                          class="grid-list-col col-j last"
                      >
                        &nbsp;
                      </div>
                    </div>
                    <div class="grid-list-extra">
                      <div class="grid-list-col col-a">
                        价税合计（大写）
                      </div>
                      <div class="grid-list-col col-b">
                        ⓧ
                        <span style="display: none"
                        >壹佰贰拾叁圆整</span
                        >
                        <span style>{{
                            capitalization
                          }}</span>
                      </div>
                      <div class="grid-list-col col-c">
                        (小写)
                      </div>
                      <div
                          class="grid-list-col col-d last"
                      >
                        ￥
                        <span>{{
                            totalAmountRate
                          }}</span>
                      </div>
                    </div>
                  </div>
                </div>
                <div data-v-531e591a class="grid-hf">
                  <div
                      data-v-531e591a
                      class="grid-hf-col col-a"
                  >
                    销货单位
                  </div>
                  <div
                      data-v-531e591a
                      class="grid-hf-col col-b"
                  >
                    <ul data-v-531e591a class="trader">
                      <li data-v-531e591a>
                                                <span
                                                    data-v-531e591a
                                                    class="label"
                                                >名称</span
                                                >：
                        <span
                            data-v-531e591a
                            class="info"
                        >{{ billingName }}</span
                        >
                      </li>
                      <li data-v-531e591a>
                                                <span
                                                    data-v-531e591a
                                                    class="label"
                                                >纳税人识别号</span
                                                >：
                        <span
                            data-v-531e591a
                            class="info"
                        >{{ billingTaxId }}</span
                        >
                      </li>
                      <li
                          data-v-531e591a
                          v-if="status == 0"
                      >
                                                <span
                                                    data-v-531e591a
                                                    class="label"
                                                >地址、电话</span
                                                >：
                        <input
                            data-v-531e591a
                            type="text"
                            class="input"
                            v-model.trim="
                                                        billingAddress
                                                    "
                        />
                      </li>
                      <li
                          data-v-531e591a
                          v-if="status == 1"
                      >
                                                <span
                                                    data-v-531e591a
                                                    class="label"
                                                >地址、电话</span
                                                >：
                        <input
                            data-v-531e591a
                            type="text"
                            class="input"
                            v-model.trim="
                                                        billingAddress
                                                    "
                            readonly="readonly"
                        />
                      </li>
                      <li
                          data-v-531e591a
                          style="position: relative"
                          v-if="status == 0"
                      >
                                                <span
                                                    data-v-531e591a
                                                    class="label"
                                                >开户行及账号</span
                                                >：
                        <input
                            data-v-531e591a
                            type="text"
                            class="input modify-input"
                            v-model.trim="billingBank"
                        />
                      </li>
                      <li
                          data-v-531e591a
                          style="position: relative"
                          v-if="status == 1"
                      >
                                                <span
                                                    data-v-531e591a
                                                    class="label"
                                                >开户行及账号</span
                                                >：
                        <input
                            data-v-531e591a
                            type="text"
                            class="input modify-input"
                            v-model.trim="billingBank"
                            readonly="readonly"
                        />
                      </li>
                    </ul>
                  </div>
                  <div
                      data-v-531e591a
                      class="grid-hf-col col-c"
                  >
                    备注
                  </div>
                  <div
                      data-v-531e591a
                      class="grid-hf-col col-d last"
                      v-if="status == 0"
                  >
                                        <textarea
                                            v-if="invoiceOperation === 0"
                                            data-v-531e591a
                                            class="remark"
                                            v-model="remark"
                                        ></textarea>
                    <p
                        v-if="invoiceOperation === 1"
                        style="color: red"
                    >
                      对应正数发票代码{{
                        positiveInvoiceCode
                      }}号码{{ positiveInvoiceNumber }}
                    </p>
                    <textarea
                        v-if="invoiceOperation === 1"
                        data-v-531e591a
                        class="remark"
                        style="height: 60%"
                        v-model="remark"
                    ></textarea>
                  </div>
                  <div
                      data-v-531e591a
                      class="grid-hf-col col-d last"
                      v-if="status == 1"
                  >
                                        <textarea
                                            data-v-531e591a
                                            class="remark"
                                            v-model="remark"
                                            readonly="readonly"
                                        ></textarea>
                  </div>
                </div>
              </div>
              <div class="invoice-foot">
                <div class="skxx">
                  <span>收款人：</span>
                  <el-autocomplete
                      popper-class="my-payees"
                      v-model.trim="payees"
                      :fetch-suggestions="getPayeesList"
                      placeholder="请输入内容"
                      v-if="status == 0"
                      ref="payeesInfo"
                  >
                    <i
                        class="el-icon-arrow-down el-input__icon"
                        slot="suffix"
                        v-on:click="payeesClick"
                    ></i>
                    <template slot-scope="{ item }">
                      <div class="name">
                        {{ item.value }}
                      </div>
                    </template>
                  </el-autocomplete>
                  <el-autocomplete
                      popper-class="my-payees"
                      v-model.trim="payees"
                      :fetch-suggestions="getPayeesList"
                      placeholder="请输入内容"
                      :disabled="true"
                      v-if="status == 1"
                      ref="payeesInfo"
                  >
                    <i
                        class="el-icon-arrow-down el-input__icon"
                        slot="suffix"
                        v-on:click="payeesClick"
                    ></i>
                    <template slot-scope="{ item }">
                      <div class="name">
                        {{ item.value }}
                      </div>
                    </template>
                  </el-autocomplete>
                  <span>复核人：</span>
                  <el-autocomplete
                      popper-class="my-reviewers"
                      v-model.trim="reviewers"
                      :fetch-suggestions="getReviewersList"
                      placeholder="请输入内容"
                      v-if="status == 0"
                      ref="reviewersInfo"
                  >
                    <i
                        class="el-icon-arrow-down el-input__icon"
                        slot="suffix"
                        v-on:click="reviewersClick"
                    ></i>
                    <template slot-scope="{ item }">
                      <div class="name">
                        {{ item.value }}
                      </div>
                    </template>
                  </el-autocomplete>
                  <el-autocomplete
                      popper-class="my-reviewers"
                      v-model.trim="reviewers"
                      :fetch-suggestions="getReviewersList"
                      placeholder="请输入内容"
                      :disabled="true"
                      v-if="status == 1"
                      ref="reviewersInfo"
                  >
                    <i
                        class="el-icon-arrow-down el-input__icon"
                        slot="suffix"
                        v-on:click="reviewersClick"
                    ></i>
                    <template slot-scope="{ item }">
                      <div class="name">
                        {{ item.value }}
                      </div>
                    </template>
                  </el-autocomplete>
                  <span>开票人：</span>
                  <el-autocomplete
                      popper-class="my-drawers"
                      v-model.trim="drawers"
                      :fetch-suggestions="getDrawersList"
                      placeholder="请输入内容"
                      v-if="status == 0"
                      ref="drawersInfo"
                  >
                    <i
                        class="el-icon-arrow-down el-input__icon"
                        slot="suffix"
                        v-on:click="drawersInfoClick"
                    ></i>
                    <template slot-scope="{ item }">
                      <div class="name">
                        {{ item.value }}
                      </div>
                    </template>
                  </el-autocomplete>
                  <el-autocomplete
                      popper-class="my-drawers"
                      v-model.trim="drawers"
                      :fetch-suggestions="getDrawersList"
                      placeholder="请输入内容"
                      :disabled="true"
                      v-if="status == 1"
                      ref="drawersInfo"
                  >
                    <i
                        class="el-icon-arrow-down el-input__icon"
                        slot="suffix"
                        v-on:click="drawersInfoClick"
                    ></i>
                    <template slot-scope="{ item }">
                      <div class="name">
                        {{ item.value }}
                      </div>
                    </template>
                  </el-autocomplete>
                  <!-- <input
                                        type="text"
                                        maxlength="20"
                                        v-model="drawers"
                                        readonly="readonly"
                                    /> -->
                  <span>销货单位（章）</span>
                </div>
                <!--                <div class="tishi"></div>-->
              </div>
            </div>
            <ul class="pointGroup">
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
            </ul>
          </div>
          <div class="invoice_customer">
            <div style="display: flex; height: 98px; justify-content: center; align-items: center; font-size: 16px;
                font-family: PingFang SC;
                font-weight: 400;
                line-height: 22px;
                color: #3E3E3E;
                opacity: 1;">
              <p style="color: red">*</p>电子发票交付方式：
            </div>
            <div style="display: flex ; flex-direction: column; height: 98px; width: 500px">
              <div v-if="status === 0" style="margin-top: 10px; margin-left: 10px">
                <el-radio v-model="deliverType" label="1" v-on:change="deliverChange">交付邮箱</el-radio>
                <el-radio v-model="deliverType" label="2" v-on:change="deliverChange">交付短信</el-radio>
              </div>
              <div v-if="status === 1">
                <el-radio disabled v-model="deliverType" label="1" v-on:change="deliverChange">交付邮箱</el-radio>
                <el-radio disabled v-model="deliverType" label="2" v-on:change="deliverChange">交付短信</el-radio>
              </div>
              <el-input
                  style="width: 300px; margin-top: 10px; margin-left: 10px"
                  placeholder
                  v-model="deliverData"
                  v-if="status === 0 && deliverType === '1'"
              >
                <template slot="prepend">交付邮箱</template>
              </el-input>
              <el-input
                  style="width: 300px; margin-top: 10px; margin-left: 10px"
                  placeholder
                  v-model="deliverData"
                  class="invoice_input"
                  v-if="status === 1 && deliverType === '1'"
                  :disabled="true"
              >
                <template slot="prepend">交付邮箱</template>
              </el-input>
              <div style="display: flex">
                <el-input
                    style="width: 230px; margin-top: 10px; margin-left: 10px"
                    placeholder
                    v-model="deliverData"
                    class="invoice_input"
                    maxlength="11"
                    type="tel"
                    oninput="value=value.replace(/^\.+|[^\d.]/g,'')"
                    @blur="deliverPhoneChange"
                    v-if="status === 0 && deliverType === '2' && phoneStatus === false"
                >
                  <template slot="prepend">移动电话</template>
                </el-input>
                <el-popover
                    v-if="status === 0 && deliverType === '2' && phoneStatus === true"
                    placement="top-start"
                    width="210"
                    trigger="hover"
                    content="您的短信余量不足，请点击右侧短信充值，或切换为交付邮箱。">
                  <el-input
                      slot="reference"
                      style="width: 230px; margin-top: 10px; margin-left: 10px"
                      placeholder
                      v-model="deliverData"
                      class="invoice_input"
                      disabled
                  >
                    <template slot="prepend">移动电话</template>
                  </el-input>
                </el-popover>
                <el-input
                    style="width: 230px; margin-top: 10px; margin-left: 10px"
                    placeholder
                    v-model="deliverData"
                    class="invoice_input"
                    v-if="status === 1 && deliverType === '2'"
                    disabled
                >
                  <template slot="prepend">移动电话</template>
                </el-input>
                <div style="display: flex; align-items: center; justify-content: center">
                  <p v-if="deliverType === '2'" style="margin-left: 20px;">短信余量：{{ messageNumber }}</p>
                  <el-button v-if="deliverType === '2'" type="text" style="color: #42B983; margin-left: 10px"
                             v-on:click="messageRecharge">短信充值
                  </el-button>
                </div>
              </div>
            </div>

            <!--                    <el-input placeholder="" v-model="customerPhone" class="invoice_input">-->
            <!--                        <template slot="prepend">手机号码</template>-->
            <!--                    </el-input>-->
          </div>
        </div>
        <el-dialog title="选择客户信息" :visible.sync="isCustomer">
          <div>
            <el-input
                placeholder
                v-model="queryTaxName"
                class="invoice_input"
            >
              <template slot="prepend">客户名称</template>
            </el-input>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="customerQuery"
            >查询
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="addBuyer()"
            >新增
            </el-button>
          </div>
          <el-table
              :data="customerData"
              height="250px"
              style="width: 100%"
              highlight-current-row
              border
              @row-dblclick="selectCustomerData"
              @row-click="setCustomerInfo"
          >
            <el-table-column
                prop="customerEntTaxId"
                label="企业税号"
                width="180"
            ></el-table-column>
            <el-table-column
                prop="customerName"
                label="客户名称"
                width="180"
            ></el-table-column>
            <el-table-column
                prop="customerMobile"
                label="客户手机号"
                width="100"
            ></el-table-column>
            <el-table-column
                prop="address"
                label="客户地址"
                width="160"
            ></el-table-column>
            <el-table-column
                prop="contactPhone"
                label="联系电话"
                width="100"
            ></el-table-column>
            <el-table-column
                prop="bankName"
                label="开户银行"
                width="120"
            ></el-table-column>
            <el-table-column
                prop="bankAccountNumber"
                label="银行账户"
                width="120"
            ></el-table-column>
          </el-table>
          <div slot="footer" class="customer">
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="selectCustomerButton"
            >确 定
            </el-button>
          </div>
        </el-dialog>
        <el-dialog
            title="选择产品信息"
            :visible.sync="isCommodity"
            v-on:opened="productPageOpen"
            v-on:closed="productPageClose"
        >
          <div>
            <el-input
                placeholder
                v-model="queryProductName"
                class="invoice_input"
            >
              <template slot="prepend">产品名称</template>
            </el-input>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="productQuery"
            >查询
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="addCommodity()"
            >新增
            </el-button>
          </div>
          <el-table
              :data="productList"
              height="250px"
              style="width: 100%"
              highlight-current-row
              border
          >
            <el-table-column
                prop="taxationCateCode"
                label="税收分类编码"
                width="180"
            ></el-table-column>
            <el-table-column
                prop="taxationCateAbbr"
                label="税收分类简称"
                width="180"
            ></el-table-column>
            <el-table-column
                prop="productName"
                label="产品名称"
                width="180"
            ></el-table-column>
            <el-table-column
                prop="productCode"
                label="商品编码"
                width="120"
            ></el-table-column>
            <el-table-column
                prop="specsModel"
                label="规格型号"
                width="100"
            ></el-table-column>
            <el-table-column
                prop="price"
                label="单价"
                width="60"
            ></el-table-column>
            <el-table-column
                prop="unit"
                label="计量单位"
                width="80"
            ></el-table-column>
            <el-table-column
                prop="taxRate"
                label="税率"
                width="60"
            ></el-table-column>
            <el-table-column
                prop="taxRates"
                label="可用税率"
                width="180"
            ></el-table-column>
            <el-table-column
                fixed="right"
                label="操作"
                align="center"
                width="240"
            >
              <template slot-scope="scope">
                <el-button
                    @click="handleUseProduct(scope.row)"
                    type="primary"
                    size="small"
                >使用
                </el-button>
                <el-button
                    @click="editCommodity(scope.row)"
                    size="small"
                >编辑
                </el-button>
                <el-button
                    @click="handleDeleteProduct(scope.row)"
                    size="small"
                >删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="block">
            <el-pagination
                @current-change="productPageChange"
                :page-size="10"
                layout="total, prev, pager, next"
                :total="totalNumber"
            ></el-pagination>
          </div>
          <!-- <div slot="footer" class="customer">
                        <el-button
                            class="invoice_button"
                            type="primary"
                            v-on:click="selectProductButton"
                            >确 定
                        </el-button>
                    </div> -->
        </el-dialog>
        <el-dialog
            title="折扣"
            :visible.sync="isDiscount"
            v-on:opened="discountPageOpen"
            v-on:closed="discountPageClose"
        >
          <invoice_discount
              ref="invoiceDiscount"
              :invoiceDiscount="this"
          />
          <div slot="footer" class="customer">
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="productDiscount"
            >确 定
            </el-button>
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="isDiscount = false"
            >取 消
            </el-button>
          </div>
        </el-dialog>
        <el-dialog
            title="新增购方信息"
            :visible.sync="customerAddData.dialogVisible"
            center
            @close="handleCloseDialog('customerAdd')"
        >
          <buyer_info_add
              ref="customerAdd"
              :inputCustomerInfo="customerAddData.inputCustomerInfo"
          ></buyer_info_add>
          <span slot="footer">
                        <el-button
                            type="primary"
                            @click="
                                handleCustomerModifyOrAddSubmit('customerAdd')
                            "
                        >立即添加</el-button
                        >
                        <el-button
                            @click="customerAddData.dialogVisible = false"
                        >取 消</el-button
                        >
                    </span>
        </el-dialog>
        <el-dialog
            title="商品信息"
            :visible.sync="productAddData.productAddShow"
            center
            @close="handleCloseDialog('productAddForm')"
        >
          <product_info_add
              ref="productAddForm"
              :inputProductInfo="productAddData.inputProductInfo"
          ></product_info_add>
          <span slot="footer">
                        <el-button
                            type="primary"
                            @click="
                                handleProductModifyOrAddSubmit('productAddForm')
                            "
                        >立即添加</el-button
                        >
                        <el-button
                            @click="productAddData.productAddShow = false"
                        >取 消</el-button
                        >
                    </span>
        </el-dialog>
        <el-dialog
            title="开票信息选择"
            :visible.sync="isShowInvoiceCopy"
            center
            v-on:opened="invoiceCopyPageOpen"
            @close="selectInvoiceShow"
            width="70%"
        >
          <invoice_copy
              ref="invoiceCopy"
              :invoiceSpecial="this"
          ></invoice_copy>
          <span slot="footer">
                        <el-button type="primary" @click="invoiceConfirm()"
                        >立即添加</el-button
                        >
                        <el-button @click="selectInvoiceShow">取 消</el-button>
                    </span>
        </el-dialog>
        <el-dialog :visible.sync="isInvoiceInfo">
          <invoice-overview></invoice-overview>
        </el-dialog>
        <el-dialog
            title="商品列表"
            :visible.sync="isShowProduct"
            v-on:opened="productListPageOpen"
            v-on:closed="productListPageClose"
            width="70%"
        >
          <product_list ref="productList" :productList="this"/>
          <div slot="footer" class="customer">
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="isShowProduct = false"
            >取 消
            </el-button>
          </div>
        </el-dialog>
        <el-dialog
            title="发票拆分开票"
            :visible.sync="isShowSplit"
            v-on:opened="invoiceSplitOpen"
            :before-close="invoiceSplitClose"
            width="70%"
            :close-on-click-modal="false"
            :show-close="isClose"
        >
          <invoice_split ref="invoiceSplit" :invoiceSplit="this"/>
          <div slot="footer" class="customer" v-if="isClose">
            <el-button
                class="invoice_button"
                type="primary"
                v-on:click="invoiceSplitCancel"
            >取 消
            </el-button>
          </div>
        </el-dialog>
        <el-dialog width="50%" title="短信余量充值" :visible.sync="messageStatus" :before-close="messageRechargeClose">
          <div>
            <div style="display: flex; flex-direction: row; flex: 1; flex-wrap: wrap">
              <div v-for="item in this.messageList">
                <div v-if="item.isSelect === true" v-on:click="messageClick(item.key)"
                     style="display: flex; flex-direction: column; border: 1px solid #E85033; height: 110px; width: 180px; opacity: 1; border-radius: 6px; justify-content: center; align-items: center; cursor: pointer; margin-bottom: 10px; margin-right: 10px">
                  <div style="margin: 10px">
                    <p style="color: #505050; font-size: 14px; font-family: PingFang SC; font-weight: 500; line-height: 20px; opacity: 1;">
                      {{ item.title }}</p>
                  </div>
                  <div style="display: flex; margin-bottom: 10px">
                    <p style="font-size: 26px;
                    font-family: PingFang SC;
                    font-weight: 500;
                    line-height: 21px;
                    color: #E85033;
                    opacity: 1;">{{ item.discount }}</p>
                    <p style="font-size: 10px;
                    font-family: PingFang SC;
                    font-weight: 500;
                    line-height: 20px;
                    color: #595959;
                    opacity: 1; margin-top: 5px">元</p>
                    <p style="font-size: 9px;
                      font-family: PingFang SC;
                      font-weight: 400;
                      line-height: 20px;
                      color: #8C8C8C;
                      opacity: 1; text-decoration: line-through; margin-top: 5px">{{ item.amount }}元</p>
                  </div>
                  <div
                      style="display: flex; background-color: #E85033; height: 14px; width: 24px; opacity: 1; border-radius: 0px 0px 5px 0px; position: relative; right: -78px; bottom: -9px; justify-content: center; align-items: center">
                    <img style="height: 7px; width: 9px" src="../../utils/img/select.png"/>
                  </div>
                  <!--                  <div style="width: 170px; height: 0px; border: 1px solid #EBEBEB; opacity: 1"/>-->
                  <!--                  <div style="display: flex; justify-content: center; align-items: center; margin: 10px">-->
                  <!--                    <p style="font-size: 10px;-->
                  <!--                      font-family: PingFang SC;-->
                  <!--                      font-weight: 400;-->
                  <!--                      line-height: 22px;-->
                  <!--                      color: #ADADAD;-->
                  <!--                      opacity: 1;">无期限限制使用</p>-->
                  <!--                  </div>-->
                </div>
                <div v-else v-on:click="messageClick(item.key)"
                     style="display: flex; flex-direction: column; border: 1px solid #E5E5E5; height: 110px; width: 180px; opacity: 1; border-radius: 6px; justify-content: center; align-items: center; cursor: pointer; margin-bottom: 10px; margin-right: 10px">
                  <div style="margin: 10px">
                    <p style="color: #505050; font-size: 14px; font-family: PingFang SC; font-weight: 500; line-height: 20px; opacity: 1;">
                      {{ item.title }}</p>
                  </div>
                  <div style="display: flex; margin-bottom: 10px">
                    <p style="font-size: 26px;
                    font-family: PingFang SC;
                    font-weight: 500;
                    line-height: 21px;
                    color: #E85033;
                    opacity: 1;">{{ item.discount }}</p>
                    <p style="font-size: 10px;
                    font-family: PingFang SC;
                    font-weight: 500;
                    line-height: 20px;
                    color: #595959;
                    opacity: 1; margin-top: 5px">元</p>
                    <p style="font-size: 9px;
                      font-family: PingFang SC;
                      font-weight: 400;
                      line-height: 20px;
                      color: #8C8C8C;
                      opacity: 1; text-decoration: line-through; margin-top: 5px">{{ item.amount }}元</p>
                  </div>
                  <!--                  <div style="width: 170px; height: 0px; border: 1px solid #EBEBEB; opacity: 1"/>-->
                  <!--                  <div style="display: flex; justify-content: center; align-items: center; margin: 10px">-->
                  <!--                    <p style="font-size: 10px;-->
                  <!--                      font-family: PingFang SC;-->
                  <!--                      font-weight: 400;-->
                  <!--                      line-height: 22px;-->
                  <!--                      color: #ADADAD;-->
                  <!--                      opacity: 1;">无期限限制使用</p>-->
                  <!--                  </div>-->
                </div>
              </div>
            </div>
            <div
                style="display: flex; justify-content: center; align-items: center; flex-direction: column; height: 100px">
              <div style="display: flex">
                <p style="font-size: 14px;
                  font-family: PingFang SC;
                  font-weight: 500;
                  line-height: 22px;
                  color: #4B4B4B;
                  opacity: 1;">应付金额：</p>
                <p style="font-size: 26px;
                  font-family: PingFang SC;
                  font-weight: 500;
                  line-height: 21px;
                  color: #E85033;
                  opacity: 1;">{{ this.selectAmount }}</p>
                <p style="font-size: 10px;
                  font-family: PingFang SC;
                  font-weight: 500;
                  line-height: 20px;
                  color: #595959;
                  opacity: 1; margin-top: 5px">元</p>
              </div>
              <p style="font-size: 10px;
                font-family: PingFang SC;
                font-weight: 400;
                line-height: 22px;
                color: #ADADAD;
                opacity: 1;">支付即同意《云票在线服务协议》</p>
            </div>
            <div style="display: flex; flex-direction: column">
              <div style="display: flex; justify-content: center; align-items: center; margin-bottom: 10px">
                <el-radio-group v-model="paySelect" v-on:change="payTypeChange">
                  <el-radio-button label="微信"></el-radio-button>
                  <el-radio-button label="支付宝"></el-radio-button>
                </el-radio-group>
              </div>
              <div v-if="paySelect === '支付宝'"
                   style="display: flex; flex: 1; justify-content: center; align-items: center; flex-direction: column">
                <div style="background: #FFFFFF;
                    border: 1px solid #E5E5E5;
                    opacity: 1;
                    border-radius: 4px; height: 140px; width: 140px">
                  <ali-pay-code ref="aliPay" :aliPay="this"/>
                </div>
                <div style="display: flex; align-items: center; margin-top: 10px">
                  <img style="width: 18px; height: 16px; margin-right: 10px" src="../../utils/img/alipay.png"/>
                  <p>支付宝扫码支付</p>
                </div>
              </div>
              <div v-if="paySelect === '微信'"
                   style="display: flex; flex: 1; justify-content: center; align-items: center; flex-direction: column">
                <div style="background: #FFFFFF;
                    border: 1px solid #E5E5E5;
                    opacity: 1;
                    border-radius: 4px; height: 140px; width: 140px">
                  <we-chat-code ref="weChat" :weChat="this"/>
                </div>
                <div style="display: flex; align-items: center; margin-top: 10px">
                  <img style="width: 18px; height: 16px; margin-right: 10px" src="../../utils/img/wechat.png"/>
                  <p>微信扫码支付</p>
                </div>
              </div>
            </div>
          </div>
        </el-dialog>
        <el-dialog width="50%" title="充值成功" :visible.sync="successStatus">
          <div style="display: flex; justify-content: center; align-items: center; flex-direction: column">
            <div>
              <img style="height: 88px; width: 88px" src="../../utils/img/success.png"/>
            </div>
            <div style="display: flex; justify-content: center; align-items: center; flex-direction: column">
              <p style="font-size: 24px;
                  font-family: PingFangSC-Medium;
                  line-height: 32px;
                  color: rgba(0, 0, 0, 0.85);
                  opacity: 1;">短信余量充值成功</p>
              <p style="font-size: 14px;
                  font-family: PingFangSC-Regular;
                  line-height: 22px;
                  color: rgba(0, 0, 0, 0.45);
                  opacity: 1;">云票在线感谢您的支持</p>
            </div>
            <el-button style="margin-top: 20px" type="primary" v-on:click="this.successStatus = false">确认</el-button>
          </div>
        </el-dialog>
        <el-dialog
            title="商品清单导入进度"
            :visible.sync="isInvoiceList"
            v-on:closed="invoiceListPageClose"
            width="30%"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
            :show-close="false"
            :center="true"
        >
          <div style="display: flex; flex: 1; justify-content: center; align-items: center">
            <div>
              <el-progress type="circle" :percentage="progressStatus" width="150" :status="statusFont"></el-progress>
            </div>
          </div>
          <!--        <div slot="footer" class="customer">-->
          <!--          <el-button class="invoice_button" type="primary" v-on:click="invoiceListPageClose">确认</el-button>-->
          <!--        </div>-->
        </el-dialog>
        <div>
          <object
              classid="clsid:045DA91D-B927-483D-9971-6C63AC3517DC"
              width="100%"
              height="100%"
              id="print_form"
              name="print_form"
          ></object>
        </div>
      </div>
    </div>

    <!-- 2022年4月1日增值税小规模纳税人适用3%征收率免税政策 -->
    <Policy2022040101ContentDialog ref="policy2022040101ContentDialog"></Policy2022040101ContentDialog>

    <!-- 2022年4月1日增值税小规模纳税人适用3%征收率免税政策，含有 1% 税率发票时提示弹窗 -->
    <Policy2022040101ContentDialogToInvoiceSubmit
      ref="policy2022040101ContentDialogToInvoiceSubmit"
      @continue="handlePolicy2022040101InvoiceSubmitContinue">
    </Policy2022040101ContentDialogToInvoiceSubmit>

    <!-- 2023年1月10日减免增值税等政策，含有"免税"税率发票时提示弹窗 -->
    <Policy20230109ContentDialogToInvoiceSubmit
      ref="policy20230109ContentDialogToInvoiceSubmit"
      @continue="handlePolicy20230109InvoiceSubmitContinue"/>
  </div>
</template>

<script>
import '../../utils/css/54.bdcd03887ce3138b0f6f.css'
import '../../utils/css/vendors_cloud.5d0cbba7097d23ee8c5f.css'
import '../../utils/css/cloud.28e91b0965c466baef7a.css'
import '../../utils/54.83af1a94df1e7e208022'
import cache from '@/utils/cache'
import { AxiosRequestData } from '../../data/axios_request'
import {
  ProductListCalculation,
  InvoiceTotalAmount,
  InvoiceProducts,
  ProductTaxRateSwitch,
  InvoiceReopen,
  ProductsListChange
} from '../../data/invoice_calculation'
import {
  NumberCapitalization,
  NumberTwoDecimal
} from '../../data/general_method'
import BuyerInfo from './components/buyer_Info_add'
import ProductInfo from './components/product_info_add'
import InvoiceCopy from './components/invoice_copy'
import { customerModifyOrAdd, productModifyOrAdd, deleteProduct } from '@/api/user_config'
import InvoiceDiscount from './components/invoice_discount'
import ProductList from '@/pages/invoice/components/product_list'
import { timeCompare } from '@/utils/time_handle'
import InvoiceSplit from '@/pages/invoice/components/invoice_split'
// import invoice from '@/utils/cache_invoice'
import invoice from '@/api/cache_invoice'
import { invoiceQuery } from '@/api/invoice'
import { GetInvoiceDownloadUrl } from '@/api/invoice_info'
import InvoiceOverview from './components/invoice-overview'
import AliPay from '@/components/payCode/aliPay'
import WeChat from '@/components/payCode/weChat'
import { get_excel_data } from '@/utils/Export2Excel'

import Policy2022040101EnableSwitch from './components/Policy2022040101/EnableSwitch.vue'
import Policy2022040101ContentDialog from "./components/Policy2022040101/ContentDialog.vue"
import Policy2022040101ContentDialogToInvoiceSubmit from "./components/Policy2022040101/ContentDialogToInvoiceSubmit.vue"

import Policy20230109ContentDialogToInvoiceSubmit from "./components/Policy20230109/ContentDialogToInvoiceSubmit.vue";

import { mapGetters, mapMutations, mapActions } from "vuex";

export default {
  name: 'electronics_invoice',
  components: {
    buyer_info_add: BuyerInfo,
    product_info_add: ProductInfo,
    invoice_copy: InvoiceCopy,
    invoice_discount: InvoiceDiscount,
    product_list: ProductList,
    invoice_split: InvoiceSplit,
    'invoice-overview': InvoiceOverview,
    weChatCode: WeChat,
    aliPayCode: AliPay,
    Policy2022040101EnableSwitch,
    Policy2022040101ContentDialog,
    Policy2022040101ContentDialogToInvoiceSubmit,
    Policy20230109ContentDialogToInvoiceSubmit
  },
  data() {
    return {
      status: 0, // 0：表示正在开票 1：表示开票已完成可以打印
      load: false,
      account: '',
      token: '',
      pageNum: 1,
      pageSize: 10,
      numericalValue: '正数',
      taxation: '普通征税',
      taxIncluded: '含税',
      detailed: '明细',
      purchaserName: '',
      taxNumber: '',
      addressPhone: '',
      openingBank: '',
      sellerAddress: '',
      sellerPhone: '',
      sellerBankName: '',
      sellerBankAccountNumber: '',
      purchaserNameTemporary: '',
      taxNumberTemporary: '',
      addressPhoneTemporary: '',
      openingBankTemporary: '',
      drawers: '', // 开票人
      payees: '', // 收款人
      reviewers: '', // 复核人
      drawersList: [],
      payeesList: [],
      reviewersList: [],
      remark: '',
      totalPage: 0,
      totalNumber: 0,
      selectIndex: -1,
      isIndeterminate: false,
      productCheckAll: false,
      productData: {
        product: [
          {
            productCheck: false,
            productName: '',
            productCode: '',
            specification: '',
            units: '',
            number: '',
            price: '',
            amount: '',
            taxRate: '',
            taxAmount: '',
            taxRates: '',
            totalAmountRate: '',
            preferentialFlag: 0,
            preferentialType: '',
            zeroRateFlag: null,
            rowStatus: 0 // 0表示正常行，1表示被折扣行，2表示折扣行，3表示开票成功展示数据, 4表示产品有优惠政策或者零税率，税率和税额不可修改
          }
        ]
      },
      billingName: '',
      billingTaxId: '',
      billingAddress: '',
      billingBank: '',
      buyerCustomerEmail: '',
      buyerCustomerPhone: '',
      productList: [],
      isCustomer: false,
      isCommodity: false,
      queryProductName: '',
      productRowInfo: {},
      customerData: [],
      queryTaxName: '',
      pageCustomerNum: 1,
      pageCustomerSize: 10,
      totalAmount: 0.0,
      totalTaxAmount: 0.0,
      totalAmountRate: 0.0,
      capitalizedAmount: '',
      rates: '',
      capitalization: '零圆整',
      isTaxIncluded: true,
      isDetailed: false,
      invoiceReqFlowNo: '',
      nowTime: '',
      invoiceCode: '',
      invoiceNumber: '',
      customerEmail: '',
      customerPhone: '',
      electronicsStatus: false,
      electronicsMessage: '',
      entTaxId: '',
      isDiscount: false,
      discountAmount: '1',
      originalAmount: '',
      discountAmounts: '',
      discountRatio: '',
      selectDiscount: -1,
      discountTotalAmount: 0.0,
      discountTotalRate: 0.0,
      timerRequestNum: 1,
      timer: '',
      buyerTimer: '',
      orderId: '',
      invoiceType: '',
      machineNo: '',
      invoiceCheckCode: '',
      taxControlCode: '',
      isShow: false,
      discountRowNumber: 1,
      invoiceProductNumber: 1,
      buyerData: [],
      blurTimer: '',
      customerAddData: {
        dialogVisible: false,
        inputCustomerInfo: {} // 绑定后，用于清空上次的输入
      },
      productAddData: {
        productAddShow: false,
        inputProductInfo: {} // 绑定后，用于清空上次的输入
      },
      isShowInvoiceCopy: false,
      searchInvoiceType: 1, // 发票种类 1.增值税普通电子发票   2.增值税电子专用发票  3.增值税普通纸质发票  4 增值税专用纸质发票
      isInvoiceInfo: false,
      checkShow: true,
      expirationTime: '',
      isShowProduct: false,
      isShowSplit: false,
      isSplit: false,
      defaultDeviceInfo: {},
      invoiceSplitList: [],
      isClose: true,
      customerType: 2,
      deviceType: '',
      deviceNumber: '',
      invoiceOperation: 0,
      billingType: 0,
      isRedInvoice: false,
      positiveInvoiceCode: '',
      positiveInvoiceNumber: '',
      taxRateFree: '免税',
      taxRateNo: '不征税',
      deliverType: '1',
      deliverData: '',
      messageNumber: 0,
      interactType: 1,
      messageStatus: false,
      phoneStatus: false,
      selectAmount: 0,
      messageList: [],
      aliPayUrl: '',
      weChatUrl: '',
      paySelect: '微信',
      successStatus: false,
      timerPay: '',
      payNumber: 0,
      userId: '',
      historyData: [],
      isHistoryShow: false,
      isProductSearchShow: false,
      searchProductTimer: null,
      blurProductTimer: null,
      invoiceProductList: [],
      productTax: '',
      isInvoiceList: false,
      invoiceListNumber: 0,
      statusFont: '',
      progressStatus: 0,
      exportNumber: 0
    }
  },
  created() {
    let user = JSON.parse(cache.getSession('user'))
    let company = JSON.parse(cache.getSession('company'))
    this.productTax = company.availableTaxes
    this.userId = user.userId
    this.entTaxId = company.entTaxId
    this.defaultDeviceInfo = company.defaultDeviceInfo
    this.account = user.account
    // this.drawers = user.userName;
    this.expirationTime = user.expirationTime
    this.token = cache.getToken()
    this.getDefaultCompany()
    this.TimeFormate()

    // 默认不显示发票概览弹窗页面
    // this.getInvoiceAmount();
    // this.isInvoiceInfo = true;

    this.getScanCodeRouteParams()
    this.getMessageNumber()
    // this.getInvoiceHistory()
    this.getProductList()
  },
  mounted() {
    if (parseInt(this.$route.params.invoiceOperation) === 1) {
      this.clearInfo(true)
      this.isRedInvoice = true
      this.invoiceOperation = 1
      this.billingType = 1
      this.setHongChongInvoiceInfo(
          this.$route.params.invoiceCode,
          this.$route.params.invoiceNumber,
          1
      )
    }
  },
  beforeDestroy() {
    // this.invoiceTemporaryStorage()
  },
  computed: {
    ...mapGetters("policy2022040101", ["useFlag"]),
  },
  watch: {
    $route: {
      handler: function (val, oldVal) {
        console.log('electronics_invoice路由监听：')
        console.log(val)
        if (val.name == 'electronics_invoice') {
          this.getScanCodeRouteParams()
          if (parseInt(this.$route.params.invoiceOperation) === 1) {
            this.clearInfo(true)
            this.isRedInvoice = true
            this.invoiceOperation = 1
            this.billingType = 1
            this.setHongChongInvoiceInfo(
                this.$route.params.invoiceCode,
                this.$route.params.invoiceNumber,
                1
            )
          }
        }
      },
      // 深度观察监听
      deep: true
    },
    /**
     * 监听 2022040101 免征增值税政策 默认启用开关，
     * 格式化处理已填写商品；
     */
    useFlag: {
      // immediate: true,
      handler(newVal, oldVal) {
        if (Array.isArray(this.productData.product)) {
          for (const item of this.productData.product) {
            this.fmtProductPolicy2022040101(item)
          }

          // 计算发票信息；
          this.computerInvoiceInfo()
        }
      },
    },
  },
  methods: {
    // 产品分页查询
    productPageChange(page) {
      this.pageNum = page
      this.getProductData()
    },
    // 产品查询
    productQuery() {
      this.pageNum = 1
      this.getProductData()
    },
    // 客户信息查询
    customerQuery() {
      this.pageCustomerNum = 1
      this.getCustomerData()
    },
    // 添加产品列表
    addDomain() {
      this.productData.product.push({
        key: Date.now(),
        productCheck: false,
        productName: '',
        productCode: '',
        specification: '',
        units: '',
        number: '',
        price: '',
        amount: '',
        taxRate: '',
        taxAmount: '',
        totalAmountRate: '',
        rowStatus: 0
      })
      if (this.productData.product.length === 9) {
        this.isDetailed = true
        this.detailed = '清单'
        this.$message({
          message:
              '超过8行明细将必须使用清单打印,票面将只显示（详见销货清单）和折扣!',
          type: 'warning'
        })
      }
      if (this.productCheckAll) {
        this.isIndeterminate = true
        this.productCheckAll = false
      }
    },
    // 删除产品列表
    removeDomain() {
      let productRows = 0
      for (let i = 0; i < this.productData.product.length; i++) {
        if (this.productData.product[i].rowStatus === 1) {
          if (this.productData.product[i].productCheck) {
            productRows++
            if (!this.productData.product[i + 1].productCheck) {
              this.$message({
                message:
                    '选择被折扣行时请同时选择折扣行再进行删除！',
                type: 'warning'
              })
              return
            }
          }
        } else {
          if (this.productData.product[i].productCheck) {
            productRows++
          }
        }
      }
      if (productRows <= 0) {
        this.$message({
          message: '请选择需要删除的信息！',
          type: 'warning'
        })
        return
      }
      this.$confirm('确定删除选中行的信息吗？')
          .then((_) => {
            for (let i = 0; i < this.productData.product.length; i++) {
              if (this.productData.product[i].productCheck === true) {
                if (this.productData.product[i].rowStatus === 2) {
                  if (i > 0) {
                    if (
                        this.productData.product[i - 1]
                            .rowStatus === 1
                    ) {
                      this.productData.product[
                      i - 1
                          ].rowStatus = 0
                    }
                  }
                  this.productData.product.splice(i, 1)
                } else {
                  this.productData.product.splice(i, 1)
                }
                i--
              }
            }
            this.isIndeterminate = false
            if (
                this.productData.product.length === 8 ||
                this.productData.product.length < 8
            ) {
              this.isDetailed = false
              this.detailed = '明细'
            }
            this.calculationTotalAmount(this.productData.product)
            this.productCheckChange(false)
          })
          .catch((_) => {
          })
    },
    // 显示选择购方信息页面
    selectCustomer() {
      this.getCustomerData()
      this.isCustomer = true
    },
    // 显示选择产品信息页面
    selectCommodity(rowNumber) {
      this.selectIndex = rowNumber
      this.isCommodity = true
    },

    // 提交开票信息
    async submitData() {
      this.invoiceTemporaryStorage()
      // this.customerEmail =
      //     this.customerEmail == null ? "" : this.customerEmail;
      // this.customerPhone =
      //     this.customerPhone == null ? "" : this.customerPhone;
      // if (this.customerEmail === "" && this.customerPhone === "") {
      //   this.$message({
      //     message: "客户邮箱、手机号码，二者不可以同时为空！！",
      //     type: "warning",
      //   });
      //   return;
      // }
      if (this.deliverType === '1') {
        let status = this.emailVerification()
        if (!status) {
          this.$message({
            message: '交付邮箱不正确，请输入正确的邮箱地址！',
            type: 'warning'
          })
          return
        }
      }
      if (this.deliverType === '2') {
        let status = this.checkPhone()
        if (!status) {
          this.$message({
            message: '交付短信不正确，请输入正确的手机号码！',
            type: 'warning'
          })
          return
        }
      }
      let product = InvoiceProducts(
          this.productData.product,
          this.isTaxIncluded,
          this.isRedInvoice
      )
      if (product.state !== 0) {
        this.$message({
          message: '货物或应税劳务.服务名称和金额不能为空！',
          type: 'warning',
        })
        return
      }
      if (this.billingAddress === '') {
        this.$message({
          message: '请输入销货单位地址、电话！',
          type: 'warning',
        })
        return
      }
      if (this.billingBank === '') {
        this.$message({
          message: '请输入销货单位开户行及账号！',
          type: 'warning',
        })
        return
      }
      if (this.taxNumber === '' || this.taxNumber == null) {
        this.customerType = 1
      }
      if (this.account && this.token) {
        await this.invoiceIssuing(product)
        // let invoiceInfo = await this.invoiceLimit()
        // if (invoiceInfo.code === 0) {
        //   if (invoiceInfo.overRange) {
        //     this.$confirm('当前开票金额已经超过开票限额，是否需要自动拆分发票？')
        //         .then(_ => {
        //           this.invoiceSplit(invoiceInfo.limitAmt, product)
        //         })
        //         .catch(_ => {
        //         })
        //   } else {
        //     await this.invoiceIssuing(product)
        //   }
        // }
      }
      // this.load = true;
      // if (this.account) {
      //   if (this.token) {
      //     const url = "/sys/blueInvoice/save";
      //     let response = await AxiosRequestData(
      //         url,
      //         this.token,
      //         {
      //           interactType: 1,
      //           interactTypeDetail: this.customerEmail,
      //           invoiceWay: 1,
      //           invoiceCategory: 1,
      //           cmdParam: {
      //             REQUEST_COMMON_FPKJ: {
      //               KPLX: 0, // 开票类型 0-蓝字发票；1-红字发票
      //               FPZL: 1, // 发票种类 1.增值税普通电子发票   2.增值税电子专用发票  3.增值税普通纸质发票  4 增值税专用纸质发票
      //               TTLX: customerType, // 收票客户抬头类型 1：个人  2：企业
      //               KPF_NSRSBH: this.billingTaxId, // 开票方纳税人识别号
      //               KPF_MC: this.billingName, // 开票方名称
      //               KPF_DZ: this.billingAddress, // 开票方地址
      //               KPF_DH: " ", // 开票方电话
      //               KPF_YHZH: " ", // 开票方银行账号
      //               KPF_KHHMC: this.billingBank, // 开票方开户行名称
      //               SPF_NSRSBH: this.taxNumber, // 收票方纳税人识别号
      //               SPF_MC: this.purchaserName, // 收票方名称
      //               SPF_DH: " ", // 收票方电话
      //               SPF_DZ: this.addressPhone, // 收票方地址
      //               SPF_YHZH: " ", // 收票方银行账号
      //               SPF_KHHMC: this.openingBank, // 收票方开户行名称
      //               KPR: this.drawers, // 开票人
      //               SKR: this.payees, // 收款人
      //               FHR: this.reviewers, // 复核人
      //               YFP_DM: "", // 原发票代码
      //               YFP_HM: "", // 原发票号码
      //               JSHJ: this.totalAmountRate, // 价税合计
      //               HJJE: this.totalAmount, // 合计金额
      //               HJSE: this.totalTaxAmount, // 合计税额
      //               BZ: this.remark, // 备注
      //               HYLX: 0, // 发票行性质 0 正常行、1 折扣行、2 被折扣行
      //               TSPZ: "00", // 特殊票种标识 “00”不是 “01”农产品销售“02”农产品收购“06”抵扣通行费“07”其它通行费“08”成品油销售说明:如果非特殊票种此节点可以没有。
      //               COMMON_FPKJ_XMXXS: {
      //                 COMMON_FPKJ_XMXX: product.products,
      //               }, // 产品列表
      //             },
      //           },
      //           mobile: this.account,
      //           reqChannel: 4,
      //         },
      //         false,
      //         1
      //     );
      //     if (response) {
      //       if (response.code === 0) {
      //         this.invoiceReqFlowNo =
      //             response.data.invoiceReqFlowNo;
      //         this.orderId = response.data.orderId;
      //         this.invoiceType = response.data.invoiceType;
      //         this.checkShow = false;
      //         this.timer = setInterval(() => {
      //           if (this.timerRequestNum > 3) {
      //             this.load = false;
      //             this.status = 1;
      //             clearInterval(this.timer);
      //             this.$message({
      //               showClose: true,
      //               message:
      //                   "发票开具超时，请到发票查询中查看开具情况！",
      //               type: "warning",
      //             });
      //           } else {
      //             this.getInvoiceInfo();
      //           }
      //         }, 3000);
      //       } else {
      //         this.load = false;
      //         this.$message.error(response.msg);
      //       }
      //     } else {
      //       this.load = false;
      //       // ShowToast('服务器故障！');
      //     }
      //   }
      // } else {
      //   this.load = false;
      //   // ShowToast('客户名称不能为空！');
      // }
    },
    // 发票拆分
    async invoiceSplit(limitAmt, product) {
      if (this.token) {
        this.isSplit = true
        const url = '/sys/invoiceExt/splitInvoice'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              limitAmt: limitAmt,
              cmdParam: {
                REQUEST_COMMON_FPKJ: {
                  KPLX: 0, // 开票类型 0-蓝字发票；1-红字发票
                  FPZL: 1, // 发票种类 1.增值税普通电子发票   2.增值税电子专用发票  3.增值税普通纸质发票  4 增值税专用纸质发票
                  TTLX: this.customerType, // 收票客户抬头类型 1：个人  2：企业
                  KPF_NSRSBH: this.billingTaxId, // 开票方纳税人识别号
                  KPF_MC: this.billingName, // 开票方名称
                  KPF_DZ: this.billingAddress, // 开票方地址
                  KPF_DH: ' ', // 开票方电话
                  KPF_YHZH: ' ', // 开票方银行账号
                  KPF_KHHMC: this.billingBank, // 开票方开户行名称
                  SPF_NSRSBH: this.taxNumber, // 收票方纳税人识别号
                  SPF_MC: this.purchaserName, // 收票方名称
                  SPF_DH: ' ', // 收票方电话
                  SPF_DZ: this.addressPhone, // 收票方地址
                  SPF_YHZH: ' ', // 收票方银行账号
                  SPF_KHHMC: this.openingBank, // 收票方开户行名称
                  KPR: this.drawers, // 开票人
                  SKR: this.payees, // 收款人
                  FHR: this.reviewers, // 复核人
                  YFP_DM: '', // 原发票代码
                  YFP_HM: '', // 原发票号码
                  JSHJ: this.totalAmountRate, // 价税合计
                  HJJE: this.totalAmount, // 合计金额
                  HJSE: this.totalTaxAmount, // 合计税额
                  BZ: this.remark, // 备注
                  HYLX: 0, // 发票行性质 0 正常行、1 折扣行、2 被折扣行
                  TSPZ: '00', // 特殊票种标识 “00”不是 “01”农产品销售“02”农产品收购“06”抵扣通行费“07”其它通行费“08”成品油销售说明:如果非特殊票种此节点可以没有。
                  COMMON_FPKJ_XMXXS: {
                    COMMON_FPKJ_XMXX: product.products,
                  }, // 产品列表
                },
              },
            },
            false,
            1
        )
        if (response) {
          if (response.code === 0) {
            this.invoiceSplitLists(response.data)
          } else {
            this.isSplit = false
            this.$message.error(response.msg)
          }
        } else {
          this.isSplit = false
        }
      }
    },
    // 处理发票拆分列表
    invoiceSplitLists(invoiceList) {
      this.invoiceSplitList = ProductsListChange(invoiceList, 1)
      this.isSplit = false
      this.isShowSplit = true
    },
    // 拆分开票页面显示
    invoiceSplitOpen() {
      this.$refs.invoiceSplit.getInvoiceSplitInfo(
          this.invoiceSplitList,
          this.billingTaxId
      )
    },
    // 拆分开票页面关闭
    invoiceSplitClose(done) {
      let status = this.$refs.invoiceSplit.status
      if (status === 0) {
        this.$confirm('确认退出开票页面吗？')
            .then((_) => {
              done()
              this.$refs.invoiceSplit.clean()
            })
            .catch((_) => {
            })
      } else {
        this.$message({
          message: '开票中不允许退出开票界面！',
          type: 'warning',
        })
      }
    },
    // 拆分开票页面取消
    invoiceSplitCancel() {
      let status = this.$refs.invoiceSplit.status
      if (status === 0) {
        this.$confirm('确认退出开票页面吗？')
            .then((_) => {
              this.isShowSplit = false
              this.$refs.invoiceSplit.clean()
            })
            .catch((_) => {
            })
      } else {
        this.$message({
          message: '开票中不允许退出开票界面！',
          type: 'warning',
        })
      }
    },
    // 设置开票状态的显示
    setInvoiceStatusShow(isShow) {
      this.load = isShow
    },
    // 发票开具
    async invoiceIssuing(product) {
      this.load = true
      const url = '/sys/invoice/save'
      let response = await AxiosRequestData(
          url,
          this.token,
          {
            interactType: this.interactType,
            interactTypeDetail: this.deliverData,
            invoiceWay: 1,
            invoiceCategory: 1,
            cmdParam: {
              REQUEST_COMMON_FPKJ: {
                SBLX: this.defaultDeviceInfo.deviceType, // 设备类型 设备类型1：证书  2：税控盘  3：金税盘  4：税控ukey  5:税控服务器
                SBBH: this.defaultDeviceInfo.taxDiscId, // 设备编号 税控盘盘号
                KPLX: this.billingType, // 开票类型 0-蓝字发票；1-红字发票
                FPZL: 1, // 发票种类 1.增值税普通电子发票   2.增值税电子专用发票  3.增值税普通纸质发票  4 增值税专用纸质发票
                TTLX: this.customerType, // 收票客户抬头类型 1：个人  2：企业
                KPF_NSRSBH: this.billingTaxId, // 开票方纳税人识别号
                KPF_MC: this.billingName, // 开票方名称
                KPF_DZ: this.billingAddress, // 开票方地址
                KPF_DH: ' ', // 开票方电话
                KPF_YHZH: ' ', // 开票方银行账号
                KPF_KHHMC: this.billingBank, // 开票方开户行名称
                SPF_NSRSBH: this.taxNumber, // 收票方纳税人识别号
                SPF_MC: this.purchaserName, // 收票方名称
                SPF_DH: ' ', // 收票方电话
                SPF_DZ: this.addressPhone, // 收票方地址
                SPF_YHZH: ' ', // 收票方银行账号
                SPF_KHHMC: this.openingBank, // 收票方开户行名称
                KPR: this.drawers, // 开票人
                SKR: this.payees, // 收款人
                FHR: this.reviewers, // 复核人
                YFP_DM: this.positiveInvoiceCode, // 原发票代码
                YFP_HM: this.positiveInvoiceNumber, // 原发票号码
                JSHJ: this.totalAmountRate, // 价税合计
                HJJE: this.totalAmount, // 合计金额
                HJSE: this.totalTaxAmount, // 合计税额
                BZ: this.remark, // 备注
                HYLX: 0, // 发票行性质 0 正常行、1 折扣行、2 被折扣行
                TSPZ: '00', // 特殊票种标识 “00”不是 “01”农产品销售“02”农产品收购“06”抵扣通行费“07”其它通行费“08”成品油销售说明:如果非特殊票种此节点可以没有。
                QDBZ: 0, // 清单标志
                COMMON_FPKJ_XMXXS: {
                  COMMON_FPKJ_XMXX: product.products
                }, // 产品列表
              },
            },
            mobile: this.account,
            reqChannel: 4,
          },
          false,
          1
      )
      if (response) {
        if (response.code === 0) {
          this.invoiceReqFlowNo = response.data.invoiceReqFlowNo
          this.orderId = response.data.orderId
          this.invoiceType = response.data.invoiceType
          this.checkShow = false
          await this.getInvoiceTimer()
          this.getMessageNumber()
          // this.timer = setInterval(() => {
          //   if (this.timerRequestNum > 3) {
          //     this.load = false;
          //     this.status = 1;
          //     clearInterval(this.timer);
          //     this.$message({
          //       showClose: true,
          //       message:
          //           "发票开具超时，请到发票查询中查看开具情况！",
          //       type: "warning",
          //     });
          //   } else {
          //     this.getInvoiceInfo();
          //   }
          // }, 3000);
        } else {
          this.load = false
          this.$message.error(response.msg)
        }
      } else {
        this.load = false
        // ShowToast('服务器故障！');
      }
    },
    // 设置开票成功后产品列表状态
    productPrintList() {
      this.productData.product.map((_, i) => {
        this.productData.product[i].rowStatus = 3
      })
    },
    // 获取产品列表数据
    async getProductData() {
      if (this.account) {
        const url = '/sys/product/findPage'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              productName: this.queryProductName,
              mobile: this.account,
              reqChannel: 4,
              pageNum: this.pageNum,
              pageSize: this.pageSize,
              entTaxId: this.billingTaxId,
            },
            false,
            2
        )
        if (response) {
          if (response.code === 0) {
            this.totalNumber = response.data.total
            this.totalPage = response.data.pages
            if (response.data.records.length > 0) {
              let rates = ''
              let productList = []
              for (
                  let i = 0;
                  i < response.data.records.length;
                  i++
              ) {
                const url = '/sys/entInfo/rates'
                let res = await AxiosRequestData(
                    url,
                    this.token,
                    {
                      entTaxId: this.billingTaxId,
                      taxCateCode:
                      response.data.records[i]
                          .taxationCateCode,
                    },
                    false,
                    2
                )
                if (res) {
                  let rate = response.data.records[
                      i
                      ].taxRate.toString()
                  if (res.code === 0) {
                    if (res.data.length > 0) {
                      for (
                          let i = 0;
                          i < res.data.length;
                          i++
                      ) {
                        if (
                            rate.indexOf(
                                res.data[i].toString()
                            ) == -1
                        ) {
                          rate =
                              rate +
                              ',' +
                              res.data[i]
                        }
                      }
                    }
                    rates = rate
                  } else {
                    rates = rate
                  }
                }
                let list = {
                  productId:
                  response.data.records[i].productId,
                  productName:
                  response.data.records[i].productName,
                  productCode:
                  response.data.records[i].productCode,
                  parentCode:
                  response.data.records[i].parentCode,
                  taxItem: response.data.records[i].taxItem,
                  shortCode:
                  response.data.records[i].shortCode,
                  taxRate: response.data.records[i].taxRate,
                  specsModel:
                  response.data.records[i].specsModel,
                  price:
                      response.data.records[i].price ==
                      null ||
                      response.data.records[i].price == ''
                          ? ''
                          : response.data.records[i].price,
                  unit: response.data.records[i].unit,
                  taxPriceFlag:
                  response.data.records[i].taxPriceFlag,
                  hiddenFlag:
                  response.data.records[i].hiddenFlag,
                  taxationCateCode:
                  response.data.records[i]
                      .taxationCateCode,
                  taxationCateName:
                  response.data.records[i]
                      .taxationCateName,
                  taxationCateAbbr:
                  response.data.records[i]
                      .taxationCateAbbr,
                  preferentialFlag:
                  response.data.records[i]
                      .preferentialFlag,
                  preferentialType:
                  response.data.records[i]
                      .preferentialType,
                  zeroRateFlag:
                  response.data.records[i].zeroRateFlag,
                  taxSpeManage:
                  response.data.records[i].taxSpeManage,
                  manageUserId:
                  response.data.records[i].manageUserId,
                  entName: response.data.records[i].entName,
                  entTaxId: response.data.records[i].entTaxId,
                  taxRates: rates,
                }
                productList = productList.concat(list)
              }
              this.productList = productList
            }
          }
        }
      }
    },
    // 获取产品的可用税率
    async getCompanyTaxRate(code) {
      if (this.account) {
        const url = '/sys/entInfo/rates'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              entTaxId: this.billingTaxId,
              taxCateCode: code,
            },
            false,
            2
        )
        if (response) {
          let rate = ''
          if (response.code === 0) {
            if (response.data.length > 0) {
              for (let i = 0; i < response.data.length; i++) {
                rate = rate + ',' + response.data[i]
              }
              rate = rate.substring(1, rate.length)
            }
            this.rates = rate
          } else {
            this.rates = rate
          }
        }
      }
    },
    // 获取客户信息
    async getCustomerData() {
      if (this.account) {
        const url = '/sys/customer/customerSearch'
        let args = {
          customerName: this.queryTaxName,
          entTaxId: this.billingTaxId,
          reqChannel: 4,
        }
        let response = await AxiosRequestData(
            url,
            this.token,
            args,
            false,
            2
        )
        if (response) {
          if (response.code === 0) {
            this.customerData = response.data
          } else {
            this.$message.error(response.msg)
          }
        }
      }
    },
    // 双击选择产品信息
    // selectProductData(row, event, column) {
    //     this.productData.product[this.selectIndex].productName =
    //         "*" + row.taxationCateAbbr + "*" + row.productName;
    //     this.productData.product[this.selectIndex].productCode =
    //         row.taxationCateCode;
    //     this.productData.product[this.selectIndex].specification =
    //         row.specsModel;
    //     this.productData.product[this.selectIndex].units = row.unit;
    //     this.productData.product[this.selectIndex].price = row.price;
    //     this.productData.product[this.selectIndex].taxRate = row.taxRate;
    //     if (row.taxRates.length > 0) {
    //         this.productData.product[
    //             this.selectIndex
    //         ].taxRates = row.taxRates.split(",");
    //     }
    //     this.productData.product[this.selectIndex].number = "";
    //     this.productData.product[this.selectIndex].amount = "";
    //     this.productData.product[this.selectIndex].taxAmount = "";
    //     if (row.preferentialFlag === 1 || row.zeroRateFlag != null) {
    //         this.productData.product[this.selectIndex].rowStatus = 4;
    //     } else {
    //         this.productData.product[this.selectIndex].rowStatus = 0;
    //     }
    //     this.productData.product[this.selectIndex].preferentialFlag =
    //         row.preferentialFlag;
    //     this.productData.product[this.selectIndex].preferentialType =
    //         row.preferentialType;
    //     this.productData.product[this.selectIndex].zeroRateFlag =
    //         row.zeroRateFlag;
    //     this.isCommodity = false;
    // },
    // 单击通过确认按钮选择产品信息
    // setProductInfo(row, event, column) {
    //     this.productRowInfo = row;
    // },
    // 产品选择确认
    // selectProductButton() {
    //     this.productData.product[this.selectIndex].productName =
    //         "*" +
    //         this.productRowInfo.taxationCateAbbr +
    //         "*" +
    //         this.productRowInfo.productName;
    //     this.productData.product[
    //         this.selectIndex
    //     ].productCode = this.productRowInfo.taxationCateCode;
    //     this.productData.product[
    //         this.selectIndex
    //     ].specification = this.productRowInfo.specsModel;
    //     this.productData.product[
    //         this.selectIndex
    //     ].units = this.productRowInfo.unit;
    //     this.productData.product[
    //         this.selectIndex
    //     ].price = this.productRowInfo.price;
    //     this.productData.product[
    //         this.selectIndex
    //     ].taxRate = this.productRowInfo.taxRate;
    //     if (this.productRowInfo.taxRates.length > 0) {
    //         this.productData.product[
    //             this.selectIndex
    //         ].taxRates = this.productRowInfo.taxRates.split(",");
    //     }
    //     this.productData.product[this.selectIndex].number = "";
    //     this.productData.product[this.selectIndex].amount = "";
    //     this.productData.product[this.selectIndex].taxAmount = "";
    //     if (
    //         this.productRowInfo.preferentialFlag === 1 ||
    //         this.productRowInfo.zeroRateFlag != null
    //     ) {
    //         this.productData.product[this.selectIndex].rowStatus = 4;
    //     } else {
    //         this.productData.product[this.selectIndex].rowStatus = 0;
    //     }
    //     this.productData.product[
    //         this.selectIndex
    //     ].preferentialFlag = this.productRowInfo.preferentialFlag;
    //     this.productData.product[
    //         this.selectIndex
    //     ].preferentialType = this.productRowInfo.preferentialType;
    //     this.productData.product[
    //         this.selectIndex
    //     ].zeroRateFlag = this.productRowInfo.zeroRateFlag;
    //     this.isCommodity = false;
    // },
    // 产品选择页面关闭
    productPageClose() {
    },
    // 产品选择页面打开
    productPageOpen() {
      let date = timeCompare(this.expirationTime)
      if (date.hour === 0 && date.minute <= 60) {
        this.getTokenStatus()
      }
    },
    // 双击选择客户信息
    selectCustomerData(row, event, column) {
      this.purchaserName = row.customerName
      this.taxNumber = row.customerEntTaxId
      if (row.address != null) {
        if (row.contactPhone != null) {
          this.addressPhone = row.address + ' ' + row.contactPhone
        } else {
          this.addressPhone = row.address
        }
      } else {
        if (row.contactPhone != null) {
          this.addressPhone = row.contactPhone
        } else {
          this.addressPhone = ''
        }
      }
      if (row.bankName != null) {
        if (row.bankAccountNumber != null) {
          this.openingBank =
              row.bankName + ' ' + row.bankAccountNumber
        } else {
          this.openingBank = row.bankName
        }
      } else {
        if (row.bankAccountNumber != null) {
          this.openingBank = row.bankAccountNumber
        } else {
          this.openingBank = ''
        }
      }
      this.customerEmail = row.email
      this.customerPhone = row.customerMobile
      this.isCustomer = false
      this.isShow = false
    },
    // 单击通过确认按钮选择客户信息
    setCustomerInfo(row, event, column) {
      this.purchaserNameTemporary = row.customerName
      this.taxNumberTemporary = row.customerEntTaxId
      if (row.address != null) {
        if (row.contactPhone != null) {
          this.addressPhoneTemporary =
              row.address + ' ' + row.contactPhone
        } else {
          this.addressPhoneTemporary = row.address
        }
      } else {
        if (row.contactPhone != null) {
          this.addressPhoneTemporary = row.contactPhone
        } else {
          this.addressPhoneTemporary = ''
        }
      }
      if (row.bankName != null) {
        if (row.bankAccountNumber != null) {
          this.openingBankTemporary =
              row.bankName + ' ' + row.bankAccountNumber
        } else {
          this.openingBankTemporary = row.bankName
        }
      } else {
        if (row.bankAccountNumber != null) {
          this.openingBankTemporary = row.bankAccountNumber
        } else {
          this.openingBankTemporary = ''
        }
      }
      this.buyerCustomerEmail = row.email
      this.buyerCustomerPhone = row.customerMobile
    },
    // 客户选择确认
    selectCustomerButton() {
      this.purchaserName = this.purchaserNameTemporary
      this.taxNumber = this.taxNumberTemporary
      this.addressPhone = this.addressPhoneTemporary
      this.openingBank = this.openingBankTemporary
      this.customerEmail = this.buyerCustomerEmail
      this.customerPhone = this.buyerCustomerPhone
      this.isCustomer = false
    },
    // 获取默认企业信息
    async getDefaultCompany() {
      let company = JSON.parse(cache.getSession('company'))
      if (company) {
        this.billingName = company.entName
        this.billingTaxId = company.entTaxId
        if (company.entAddress != null) {
          if (company.entPhone != null) {
            this.billingAddress =
                company.entAddress + ' ' + company.entPhone
          } else {
            this.billingAddress = company.entAddress
          }
        }
        // this.billingAddress = (company.entAddress == null ? '' : company.entAddress) + '\xa0' + (company.entPhone == null ? '' : company.entPhone)
        this.sellerAddress =
            company.entAddress == null ? '' : company.entAddress
        this.sellerPhone =
            company.entPhone == null ? '' : company.entPhone
        if (company.bankName != null) {
          if (company.bankAccountNumber != null) {
            this.billingBank =
                company.bankName + ' ' + company.bankAccountNumber
          } else {
            this.billingBank = company.bankName
          }
        }
        // this.billingBank = (company.bankName == null ? '' : company.bankName) + '\xa0' + (company.bankAccountNumber == null ? '' : company.bankAccountNumber)
        this.sellerBankName =
            company.bankName == null ? '' : company.bankName
        this.sellerBankAccountNumber =
            company.bankAccountNumber == null
                ? ''
                : company.bankAccountNumber
        if (company.payees != null) {
          if (company.payees.length > 0) {
            let payees = company.payees.split(',')
            this.payeesList = payees.map((_, i) => ({
              value: payees[i],
            }))
            this.payees = payees[0]
          }
        }
        if (company.reviewers != null) {
          if (company.reviewers.length > 0) {
            let reviewers = company.reviewers.split(',')
            this.reviewersList = reviewers.map((_, i) => ({
              value: reviewers[i],
            }))
            this.reviewers = reviewers[0]
          }
        }

        let drawers = []
        if (company.drawers != null) {
          if (company.drawers.length > 0) {
            drawers = company.drawers.split(',')
          }
        }
        let user = JSON.parse(cache.getSession('user'))
        drawers.unshift(user.userName)
        this.drawersList = drawers.map((_, i) => ({
          value: drawers[i]
        }))
        this.drawers = this.drawersList[0].value

        await this.getProductData()
      }
      // let user = JSON.parse(cache.getSession('user'))
      // let token = cache.getToken()
      // if (user && token) {
      //   const url = '/auth/comm/user/findDefaultChoose'
      //   let response = await AxiosRequestData(
      //       url,
      //       token,
      //       {
      //         mobile: user.account,
      //       },
      //       false,
      //       2
      //   ).then(res => {
      //     if (res.code === 0) {
      //       this.billingName = res.data.entName
      //       this.billingTaxId = res.data.entTaxId
      //       if (res.data.entAddress != null) {
      //         if (res.data.entPhone != null) {
      //           this.billingAddress = res.data.entAddress + ' ' + res.data.entPhone
      //         } else {
      //           this.billingAddress = res.data.entAddress
      //         }
      //       }
      //       // this.billingAddress = (res.data.entAddress == null ? '' : res.data.entAddress) + '\xa0' + (res.data.entPhone == null ? '' : res.data.entPhone)
      //       this.sellerAddress = (res.data.entAddress == null ? '' : res.data.entAddress)
      //       this.sellerPhone = (res.data.entPhone == null ? '' : res.data.entPhone)
      //       if (res.data.bankName != null) {
      //         if (res.data.bankAccountNumber != null) {
      //           this.billingBank = res.data.bankName + ' ' + res.data.bankAccountNumber
      //         } else {
      //           this.billingBank = res.data.bankName
      //         }
      //       }
      //       // this.billingBank = (res.data.bankName == null ? '' : res.data.bankName) + '\xa0' + (res.data.bankAccountNumber == null ? '' : res.data.bankAccountNumber)
      //       this.sellerBankName = (res.data.bankName == null ? '' : res.data.bankName)
      //       this.sellerBankAccountNumber = (res.data.bankAccountNumber == null ? '' : res.data.bankAccountNumber)
      //       if (res.data.payees != null) {
      //         if (res.data.payees.length > 0) {
      //           let payees = res.data.payees.split(',')
      //           this.payeesList = payees.map((_, i) => ({
      //             value: payees[i]
      //           }))
      //           this.payees = payees[0]
      //         }
      //       }
      //       if (res.data.reviewers != null) {
      //         if (res.data.reviewers.length > 0) {
      //           let reviewers = res.data.reviewers.split(',')
      //           this.reviewersList = reviewers.map((_, i) => ({
      //             value: reviewers[i]
      //           }))
      //           this.reviewers = reviewers[0]
      //         }
      //       }
      //       // this.getCustomerData()
      //       this.getProductData()
      //     }
      //   })
      // }
    },
    // 加载收款人列表
    getPayeesList(queryString, cb) {
      cb(this.payeesList)
    },
    // 加载复核人列表
    getReviewersList(queryString, cb) {
      cb(this.reviewersList)
    },
    // 加载开票人列表
    getDrawersList(queryString, cb) {
      cb(this.drawersList)
    },
    // 产品数量变化
    numberChange(value, rowId) {
      if (value === '') {
        this.productData.product[rowId].amount = ''
        this.productData.product[rowId].taxAmount = ''
      } else {
        let products = ProductListCalculation(
            this.productData.product,
            this.isTaxIncluded,
            this.isRedInvoice
        )
        this.productData.product = products
        this.calculationTotalAmount(products)
      }
    },
    // 产品单价变化
    priceChange(value, rowId) {
      if (value === '') {
        this.productData.product[rowId].amount = ''
        this.productData.product[rowId].taxAmount = ''
      } else {
        let products = ProductListCalculation(
            this.productData.product,
            this.isTaxIncluded,
            this.isRedInvoice
        )
        this.productData.product = products
        this.calculationTotalAmount(products)
      }
    },
    // 产品金额变化
    amountChange(value, rowId) {
      if (value === '') {
        this.productData.product[rowId].price = ''
        this.productData.product[rowId].amount = ''
        this.productData.product[rowId].taxAmount = ''
      } else {
        let products = ProductListCalculation(
            this.productData.product,
            this.isTaxIncluded,
            this.isRedInvoice
        )
        this.productData.product = products
        this.calculationTotalAmount(products)
      }
    },
    // 产品税率变化
    rateChange(value, row) {
      this.productData.product[row].taxRate = value.target.value
      let products = ProductListCalculation(
          this.productData.product,
          this.isTaxIncluded,
          this.isRedInvoice
      )
      this.productData.product = products
      this.calculationTotalAmount(products)
    },
    // 产品含税和不含税变化
    taxIncludedState() {
      this.isTaxIncluded = !this.isTaxIncluded
      let products = ProductTaxRateSwitch(
          this.productData.product,
          this.isTaxIncluded,
          this.isRedInvoice
      )
      this.productData.product = products
      this.calculationTotalAmount(products)
    },
    // 计算总金额和总折扣金额
    calculationTotalAmount(products) {
      let total = InvoiceTotalAmount(
          products,
          this.isTaxIncluded,
          this.isRedInvoice
      )
      this.totalAmount = total.totalAmount
      this.totalTaxAmount = total.totalTaxRate
      this.totalAmountRate = total.totalAmountRate
      this.discountTotalAmount = total.discountTotalAmount
      this.discountTotalRate = total.discountTotalRate
      this.capitalization = NumberCapitalization(total.totalAmountRate)
    },
    // 清单和明细切换
    detailedState() {
      if (this.detailed === '明细') {
        if (this.productData.product.length > 8) {
          this.$message({
            message: '超过8行清单不允许转换为明细!',
            type: 'warning',
          })
          this.detailed = '清单'
          return
        }
      }
      this.isDetailed = !this.isDetailed
    },
    // 获取当前时间，格式：2012年12月12日
    TimeFormate() {
      let nowDate = new Date()
      let date = {
        year: nowDate.getFullYear(),
        month: nowDate.getMonth() + 1,
        date: nowDate.getDate(),
      }
      this.nowTime =
          date.year + '年' + date.month + '月' + date.date + '日'
    },
    // 开具下一张票
    nextInvoice() {
      this.$confirm('是否清除购方信息?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
          .then(() => {
            this.clearInfo(true)
          })
          .catch(() => {
            this.clearInfo(false)
          })
    },
    // 企业发票领用存信息
    async entPurchaseQuery() {
      const url = '/sys/invoiceExt/purchaseQuery'
      let entTaxId = JSON.parse(cache.getSession('company')).entTaxId
      let deviceType = JSON.parse(cache.getSession('company'))
          .defaultInvoiceDevice
      let response = await AxiosRequestData(
          url,
          this.token,
          {
            entTaxId: entTaxId,
            deviceType: deviceType,
          },
          false,
          2
      )
      if (response) {
        if (response.code === 0) {
          if (
              response.data.isvPlatform == 2 ||
              response.data.isvPlatform == '2'
          ) {
          }
          let list = response.data.purchaseDetailVOs.map((_, i) => {
            if (
                response.data.purchaseDetailVOs[i]
                    .invoiceCategory == 1
            ) {
              let specialNumber =
                  response.data.purchaseDetailVOs[i]
                      .surplusTotalQuantity
              if (specialNumber > 0) {
                this.electronicsStatus = false
                this.electronicsMessage =
                    '你当前增值税电子发票剩余票量为零，无法操作!'
              }
            }
          })
        }
      }
    },
    // 清空信息
    clearInfo(state) {
      if (state) {
        this.purchaserName = ''
        this.taxNumber = ''
        this.addressPhone = ''
        this.openingBank = ''
        this.purchaserNameTemporary = ''
        this.taxNumberTemporary = ''
        this.addressPhoneTemporary = ''
        this.openingBankTemporary = ''
        this.customerEmail = ''
        this.deliverData = ''
        this.interactType = 1
        this.deliverType = '1'
      }
      this.status = 0
      this.load = false
      this.pageNum = 1
      this.pageSize = 10
      this.numericalValue = '正数'
      this.taxation = '普通征税'
      this.taxIncluded = '含税'
      this.isTaxIncluded = true
      this.invoiceOperation = 0
      this.billingType = 0
      this.isRedInvoice = false
      this.detailed = '明细'
      this.remark = ''
      this.totalPage = 0
      this.totalNumber = 0
      this.selectIndex = -1
      this.productData = {
        product: [
          {
            productCheck: false,
            productName: '',
            productCode: '',
            specification: '',
            units: '',
            number: '',
            price: '',
            amount: '',
            taxRate: '',
            taxAmount: '',
            taxRates: '',
            totalAmountRate: '',
            rowStatus: 0,
          },
        ],
      }
      this.queryProductName = ''
      this.productRowInfo = {}
      this.customerData = []
      this.queryTaxName = ''
      this.pageCustomerNum = 1
      this.pageCustomerSize = 10
      this.totalAmount = 0.0
      this.totalTaxAmount = 0.0
      this.capitalizedAmount = ''
      this.rates = ''
      this.capitalization = '零圆整'
      this.invoiceReqFlowNo = ''
      this.invoiceCode = ''
      this.invoiceNumber = ''
      this.originalAmount = ''
      this.discountAmounts = ''
      this.discountRatio = ''
      this.selectDiscount = -1
      this.discountTotalAmount = 0.0
      this.discountTotalRate = 0.0
      this.timer = ''
      this.orderId = ''
      this.invoiceType = ''
      this.machineNo = ''
      this.invoiceCheckCode = ''
      this.taxControlCode = ''
      this.discountRowNumber = 1
      this.invoiceProductNumber = 1
      this.getProductData()
      this.checkShow = true
      this.timerRequestNum = 1
      this.customerType = 2
      this.positiveInvoiceCode = ''
      this.positiveInvoiceNumber = ''
      this.customerEmail = ''
      this.paySelect = '微信'
      this.getMessageNumber()
      this.timerPay = ''
      this.payNumber = 0
    },
    // 折扣页面关闭清空输入框中内容
    discountPageClose() {
      this.$refs.invoiceDiscount.clean()
    },
    // 折扣页面打开
    discountPageOpen() {
      this.$refs.invoiceDiscount.getDiscountInfo(
          this.discountRowNumber,
          this.originalAmount
      )
    },
    // 商品折扣显示
    productDiscountShow() {
      let selectRow = 0
      this.productData.product.map((_, i) => {
        if (this.productData.product[i].productCheck === true) {
          if (this.productData.product[i].rowStatus !== 1 && this.productData.product[i].rowStatus !== 2) {
            selectRow++
          } else {
            this.productData.product[i].productCheck = false
          }
        }
      })
      if (selectRow === 0) {
        this.$message({
          message: '请选择需要折扣的行！',
          type: 'warning',
        })
        this.isIndeterminate = false
        this.productCheckAll = false
        return
      }
      for (let i = 0; i < this.productData.product.length; i++) {
        if (
            this.productData.product[i].productName === '' ||
            this.productData.product[i].productName == null
        ) {
          this.$message({
            message: '请输入商品名称！',
            type: 'warning',
          })
          return
        }
        if (
            this.productData.product[i].amount === '' ||
            this.productData.product[i].amount == null
        ) {
          this.$message({
            message: '请输入正确的商品金额！',
            type: 'warning',
          })
          return
        }
      }
      let productSelectNumber = 0
      let amount = 0.0
      this.productData.product.map((_, i) => {
        if (
            this.productData.product[i].rowStatus !== 1 &&
            this.productData.product[i].rowStatus !== 2
        ) {
          if (this.productData.product[i].productCheck === true) {
            productSelectNumber++
            amount += parseFloat(
                this.productData.product[i].amount
            )
          }
        } else {
          if (this.productData.product[i].productCheck === true) {
            this.productData.product[i].productCheck = false
          }
        }
      })
      this.discountRowNumber = productSelectNumber
      this.originalAmount = amount
      this.isDiscount = true
    },
    // 商品折扣
    productDiscount() {
      let discountRowNumber = this.$refs.invoiceDiscount
          .discountRowNumber
      let originalAmount = this.$refs.invoiceDiscount.originalAmount
      let discountRate = this.$refs.invoiceDiscount.discountRate
      let discountAmount = this.$refs.invoiceDiscount.discountAmount
      let amount = 0
      let rate = 0.0
      if (discountRate === null || discountAmount === null) {
        this.$message({
          message: '请输入正确的折扣率或者折扣金额！',
          type: 'warning',
        })
        return
      }
      for (let i = 0; i < this.productData.product.length; i++) {
        let rowStatus = this.productData.product[i].rowStatus
        let check = this.productData.product[i].productCheck
        if (check) {
          if (rowStatus === 0 || rowStatus === 4) {
            if (this.productData.product[i].rowStatus === 0) {
              this.productData.product[i].rowStatus = 1
            }

            // 税率特殊计算，适配 2022040101 免征增值税政策；
            const originalTaxRate = this.productData.product[i].taxRate
            const convertTaxRate = this.productData.product[i].usePolicy2022040101 && originalTaxRate === '免税' ? 0 : originalTaxRate

            amount = 0 - parseFloat(this.productData.product[i].amount) * (parseFloat(discountRate) / 100)
            rate = (amount / (1 + parseFloat(convertTaxRate))) * parseFloat(convertTaxRate)

            const productZK = {
              key: Date.now(),
              productCheck: false,
              productName: this.productData.product[i].productName,
              productCode: this.productData.product[i].productCode,
              // specification: this.productData.product[i].specification,
              specification: '',
              units: '',
              number: '',
              price: '',
              amount: NumberTwoDecimal(amount),
              taxRate: this.productData.product[i].taxRate,
              taxRates: this.productData.product[i].taxRates,
              taxAmount: NumberTwoDecimal(rate),
              totalAmountRate: this.productData.product[i].totalAmountRate,
              preferentialFlag: this.productData.product[i].preferentialFlag,
              preferentialType: this.productData.product[i].preferentialType,
              zeroRateFlag: this.productData.product[i].zeroRateFlag,
              rowStatus: 2
            }
            // 格式化；
            this.fmtProductPolicy2022040101(productZK)

            this.productData.product.splice(i + 1, 0, productZK)
            this.productData.product[i].productCheck = false
          }
        }
      }
      this.isIndeterminate = false
      this.productCheckAll = false
      this.isDiscount = false
      this.calculationTotalAmount(this.productData.product)
      if (this.productData.product.length > 8 && this.isDetailed === false) {
        this.isDetailed = true
        this.detailed = '清单'
        this.$message({
          message:
              '超过8行明细将必须使用清单打印,票面将只显示（详见销货清单）和折扣!',
          type: 'warning',
        })
      }
      if (this.productData.product.length === 8 || this.productData.product.length < 8) {
        this.isDetailed = false
        this.detailed = '明细'
      }
    },
    // 折扣方式选择
    radioChange(value) {
      if (value == 1) {
        this.discountRatio = ''
      }
      if (value == 2) {
        this.discountAmounts = ''
      }
    },
    // 获取开票成功后发票的相关信息
    async getInvoiceInfo() {
      if (this.token) {
        this.timerRequestNum += 1
        const url = '/sys/invoiceExt/getResultData'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              entTaxId: this.billingTaxId,
              orderId: this.orderId,
              invoiceType: this.invoiceType,
            },
            false,
            2
        )
        if (response) {
          if (
              response.code === 0 &&
              response.data.invoiceStatus === true
          ) {
            this.load = false
            this.status = 1
            clearInterval(this.timer)
            this.invoiceCode =
                response.data.invoiceData.invoiceCode
            this.invoiceNumber =
                response.data.invoiceData.invoiceNo
            this.machineNo = response.data.invoiceData.machineNo
            this.invoiceCheckCode =
                response.data.invoiceData.invoiceCheckCode
            this.taxControlCode =
                response.data.invoiceData.taxControlCode
            this.nowTime = response.data.invoiceData.invoiceDate
            this.productPrintList()
            this.$message({
              message: '开票成功！',
              type: 'success',
            })
            // this.invoiceTemporaryStorageDeleted();
            return true
          } else {
            return false
          }
        }
      }
    },
    // 获取发票信息定时器
    async getInvoiceTimer() {
      let status = await this.getInvoiceInfo()
      if (!status) {
        this.timer = setInterval(async () => {
          if (this.timerRequestNum > 3) {
            this.productPrintList()
            this.load = false
            this.status = 1
            clearInterval(this.timer)
            this.$message({
              showClose: true,
              message:
                  '发票开具超时，请到发票查询中查看开具情况！',
              type: 'warning',
            })
            this.invoiceTemporaryStorageDeleted()
          } else {
            let status = await this.getInvoiceInfo()
            if (status) {
              clearInterval(this.timer)
            }
          }
        }, 3000)
      }
    },
    // 新增购方信息
    addBuyer() {
      this.customerAddData.inputCustomerInfo = {}
      this.customerAddData.dialogVisible = true
    },
    // 新增商品信息
    addCommodity() {
      this.productAddData.inputProductInfo = {}
      this.productAddData.productAddShow = true
    },
    // 编辑商品
    editCommodity(row) {
      this.productAddData.inputProductInfo = { ...row }
      this.productAddData.productAddShow = true
    },
    // 销方信息变化触发事件
    buyerChange() {
      if (this.purchaserName.length > 0) {
        this.buyerTimer = setTimeout(() => {
          this.isHistoryShow = false
          this.getBuyerInfo(this.purchaserName)
        }, 1000)
      } else {
        this.isShow = false
      }
    },
    // 查询销方信息
    async getBuyerInfo(taxName) {
      if (this.account) {
        const url = '/sys/customer/customerSearch'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              customerName: taxName,
              entTaxId: this.billingTaxId,
              reqChannel: 4,
            },
            false,
            2
        )
        if (response) {
          if (response.code === 0) {
            this.buyerData = response.data
            if (response.data) {
              if (response.data.length > 0) {
                this.isShow = true
                clearInterval(this.timer)
              } else {
                this.isShow = false
              }
            } else {
              this.isShow = false
            }
          }
        }
      }
    },
    // 点击空白处隐藏购方信息查询列表
    showBlur() {
      this.blurTimer = setTimeout(() => {
        this.isHistoryShow = false
        this.isShow = false
        clearInterval(this.blurTimer)
      }, 300)
    },
    // 收款人点击箭头触发显示列表
    payeesClick() {
      this.$refs.payeesInfo.handleFocus()
    },
    // 复核人点击箭头触发显示列表
    reviewersClick() {
      this.$refs.reviewersInfo.handleFocus()
    },
    // 开票人点击箭头触发显示列表
    drawersInfoClick() {
      this.$refs.drawersInfo.handleFocus()
    },
    // 新增购方信息
    handleCustomerModifyOrAddSubmit(refName) {
      console.log('客户修改和添加 参数：' + refName)
      this.$refs[refName]
          .getCustomerInfo()
          .then((val) => {
            let args = {
              customerId: val.customerId,
              customerType: val.customerType,
              customerName: val.customerName,
              customerMobile: val.customerMobile,
              email: val.email,
            }
            if (args.customerType === 2) {
              // 企业客户
              args.customerEntTaxId = val.customerEntTaxId
              args.address = val.address
              args.bankName = val.bankName
              args.bankAccountNumber = val.bankAccountNumber
              args.contactPhone = val.contactPhone
            }
            customerModifyOrAdd(args)
                .then((val) => {
                  // 成功关闭弹窗
                  this.customerAddData.dialogVisible = false
                  // this.customerModifyData.dialogVisible = false
                  this.getCustomerData()
                  this.$message({
                    message: '购方信息添加成功！',
                    type: 'success',
                  })
                })
                .catch((err) => {
                  this.$message.error(err)
                })
          })
          .catch((err) => {
            this.$message.error(err)
          })
    },
    // 新增购方信息窗口关闭
    handleCloseDialog(refName) {
      // 取消验证提示
      this.$refs[refName].resetFormFields()
    },
    // 添加产品信息
    handleProductModifyOrAddSubmit(refName) {
      console.log('产品修改和添加 参数：' + refName)
      this.$refs[refName]
          .getProductInfo()
          .then((val) => {
            productModifyOrAdd({
              taxationCateCode: val.taxationCateCode,
              taxationCateName: val.taxationCateName,
              taxationCateAbbr: val.taxationCateAbbr,
              productId: val.productId,
              productName: val.productName,
              shortCode: val.shortCode,
              specsModel: val.specsModel,
              price: val.price,
              unit: val.unit,
              taxPriceFlag: val.taxPriceFlag,
              taxRate: val.taxRate,
              zeroRateFlag: val.zeroRateFlag,
              preferentialFlag: val.preferentialFlag,
              preferentialType: val.preferentialType
            })
                .then((val) => {
                  // 成功关闭弹窗
                  this.productAddData.productAddShow = false
                  // this.productModifyData.dialogVisible = false
                  this.getProductData()
                  this.$message({
                    message: '商品信息添加成功！',
                    type: 'success'
                  })
                })
                .catch((err) => {
                  this.$message.error(err)
                })
          })
          .catch((err) => {
            this.$message.error(err)
          })
    },
    // 复制开票
    invoiceCopy() {
      this.isShowInvoiceCopy = true
    },
    // 获取选择的开票信息
    async getInvoice(invoiceData) {
      let products = []
      this.purchaserName = invoiceData.buyerName
      this.taxNumber = invoiceData.buyerEntTaxId
      this.addressPhone = invoiceData.buyerAddressPhone
      this.openingBank = invoiceData.buyerBankAccount
      this.remark = invoiceData.remarks
      products = await InvoiceReopen(
          invoiceData.goodsDetailVOs,
          this.billingTaxId,
          this.token,
          this.isRedInvoice
      )
      products.map((_, i) => {
        if (
            products[i].preferentialFlag === '1' ||
            products[i].zeroRateFlag != null
        ) {
          if (products[i].zeroRateFlag != null) {
            products[i].zeroRateFlag = parseInt(
                products[i].zeroRateFlag
            )
          }
          products[i].preferentialFlag = parseInt(
              products[i].preferentialFlag
          )
          products[i].rowStatus = 4
        } else {
          products[i].zeroRateFlag = parseInt(
              products[i].zeroRateFlag
          )
          products[i].preferentialFlag = parseInt(
              products[i].preferentialFlag
          )
          products[i].rowStatus = 0
        }
      })
      products = ProductTaxRateSwitch(
          products,
          this.isTaxIncluded,
          this.isRedInvoice
      )
      this.calculationTotalAmount(products)
      this.productData.product = products
      this.isShowInvoiceCopy = false
    },
    // 确认选择的发票信息
    invoiceConfirm() {
      this.$refs.invoiceCopy.confirmInvoiceInfo()
    },
    // 重置查询信息
    selectInvoiceShow() {
      this.isShowInvoiceCopy = false
      this.$refs.invoiceCopy.resetInfo()
    },
    // 复制开票页面打开
    invoiceCopyPageOpen() {
      this.$refs.invoiceCopy.setInvoiceCopyInfo()
    },
    // 显示发票概览信息
    showInvoiceInfo() {
      this.isInvoiceInfo = true
    },
    // 商品选择折扣信息
    productCheckChange(value) {
      let productNumber = this.productData.product.length
      let checkNumber = 0
      this.productData.product.map((_, i) => {
        if (this.productData.product[i].productCheck === true) {
          checkNumber++
        }
      })
      if (checkNumber > 0 && productNumber === checkNumber) {
        this.productCheckAll = true
      } else {
        this.productCheckAll = false
      }
      if (checkNumber > 0 && checkNumber < productNumber) {
        this.isIndeterminate = true
      } else {
        this.isIndeterminate = false
      }
    },
    // 产品列表全选
    productCheckAllChange(value) {
      this.isIndeterminate = false
      if (value) {
        this.productData.product.map((_, i) => {
          if (this.productData.product[i].productCheck === false) {
            this.productData.product[i].productCheck = true
          }
        })
      } else {
        this.productData.product.map((_, i) => {
          if (this.productData.product[i].productCheck === true) {
            this.productData.product[i].productCheck = false
          }
        })
      }
    },
    // 获取并处理扫码开票页面传递的参数
    getScanCodeRouteParams() {
      if (
          this.$route.params &&
          this.$route.params.hasOwnProperty('customerName')
      ) {
        let customerName = this.$route.params.customerName
        let customerEntTaxId = this.$route.params.customerEntTaxId
        let address = this.$route.params.address
        let contactPhone = this.$route.params.contactPhone
        let bankName = this.$route.params.bankName
        let bankAccountNumber = this.$route.params.bankAccountNo
        let email = this.$route.params.customerEmail
        let customerMobile = this.$route.params.customerMobile
        let interactType = this.$route.params.interactType
        let remark = this.$route.params.remark
        if (interactType === 1) {
          this.deliverType = '1'
          this.deliverData = email
          this.interactType = 1
        }
        if (interactType === 2) {
          this.deliverType = '2'
          this.deliverData = customerMobile
          this.interactType = 2
        }
        this.purchaserName = customerName
        this.taxNumber = customerEntTaxId
        this.customerEmail = email
        this.customerPhone = customerMobile
        this.remark = remark
        if (address != null) {
          if (contactPhone != null) {
            this.addressPhone = address + ' ' + contactPhone
          } else {
            this.addressPhone = address
          }
        } else {
          if (contactPhone != null) {
            this.addressPhone = contactPhone
          } else {
            this.addressPhone = ''
          }
        }
        if (bankName != null) {
          if (bankAccountNumber != null) {
            this.openingBank = bankName + ' ' + bankAccountNumber
          } else {
            this.openingBank = bankName
          }
        } else {
          if (bankAccountNumber != null) {
            this.openingBank = bankAccountNumber
          } else {
            this.openingBank = ''
          }
        }
        this.isCustomer = false
        this.isShow = false
      } else {
        console.log('没有路由参数')
      }
    },
    // 判断token状态
    async getTokenStatus() {
      const url = '/auth/comm/user/refreshToken'
      if (this.token && this.account) {
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              account: this.account,
              reqChannel: 4,
            },
            false,
            1
        )
        if (response) {
          if (response.code === 0) {
            let user = JSON.parse(cache.getSession('user'))
            user.expirationTime = response.data.expirationTime
            // user.token = response.data.token
            cache.setToken(response.data.token)
            cache.setSession('user', user)
            this.token = response.data.token
            this.expirationTime = response.data.expirationTime
          }
        }
      }
    },
    // 显示产品列表
    seeProductList() {
      this.isShowProduct = true
    },
    // 商品列表打开
    productListPageOpen() {
      this.$refs.productList.getProductList(this.productData.product)
    },
    // 商品列表关闭
    productListPageClose() {
      this.$refs.productList.cleanProductList()
    },
    // 判断发票开票是否超限额
    async invoiceLimit() {
      if (this.token) {
        const url = '/sys/invoiceExt/judgeLimitAmt'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              entTaxId: this.entTaxId,
              taxDiscId: this.defaultDeviceInfo.taxDiscId,
              deviceType: this.defaultDeviceInfo.deviceType,
              invoiceCategory: 4,
              invoiceTotalAmt: this.totalAmount,
            },
            false,
            1
        )
        if (response) {
          console.log('拆分测试')
          console.log(response)
          if (response.code === 0) {
            return {
              code: response.code,
              limitAmt: response.data.limitAmt,
              overRange: response.data.overRange,
            }
          } else {
            return {
              code: response.code,
            }
          }
        } else {
          return {
            code: response.code,
          }
        }
      }
    },
    // 获取发票信息
    async setHongChongInvoiceInfo(invoiceCode, invoiceNumber, invoiceType) {
      if (this.token) {
        const url = '/sys/invoiceExt/getResultData'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              entTaxId: this.entTaxId,
              invoiceType: invoiceType,
              invoiceNumber: invoiceNumber,
              invoiceCode: invoiceCode,
            },
            false,
            2
        )
        if (response) {
          if (
              response.code === 0 &&
              response.data.invoiceStatus === true
          ) {
            await this.getInvoice(response.data.invoiceData)
            this.positiveInvoiceCode =
                response.data.invoiceData.invoiceCode
            this.positiveInvoiceNumber =
                response.data.invoiceData.invoiceNo
          }
        }
      }
    },
    // 电子邮箱验证
    emailVerification() {
      let email = this.deliverData
      let reg = /^([a-zA-Z]|[0-9])(\w|\\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/
      if (reg.test(email)) {
        return true
      } else {
        return false
      }
    },
    // 手机号码验证
    checkPhone() {
      let phone = this.deliverData
      if ((/^1[3456789]\d{9}$/.test(phone))) {
        return true
      } else {
        return false
      }
    },

    // 发票数据暂存
    invoiceTemporaryStorage() {
      let _this = this
      // _this.electronicsStatus = true;
      // _this.electronicsMessage = "暂存开票信息中...请稍等";
      invoice
          .saveInvoice(this.entTaxId, 1, this.drawers, this.$data)
          .then((val) => {
            // _this.electronicsStatus = false;
            // _this.electronicsMessage = "";
            _this.$message.success('暂存开票信息成功')
          })
          .catch((err) => {
            // _this.electronicsStatus = false;
            // _this.electronicsMessage = "";
            _this.$message.error(err)
          })
    },
    // 暂存发票数据加载
    invoiceTemporaryStorageLoad() {
      // let data = invoice.getInvoice(this.entTaxId, 1, this.drawers);
      // Object.assign(this.$data, data);
      // this.token = cache.getToken();

      let _this = this
      // _this.electronicsStatus = true;
      // _this.electronicsMessage = "加载暂存开票信息中...请稍等";
      invoice
          .getInvoice(this.entTaxId, 1, this.drawers)
          .then((val) => {
            // _this.electronicsStatus = false;
            // _this.electronicsMessage = "";
            Object.assign(_this.$data, val.data)
            _this.token = cache.getToken()
            _this.getMessageNumber()
          })
          .catch((err) => {
            // _this.electronicsStatus = false;
            // _this.electronicsMessage = "";
            _this.$message.error(err)
          })
    },
    // 删除发票缓存
    invoiceTemporaryStorageDeleted() {
      let _this = this
      // _this.electronicsStatus = true;
      // _this.electronicsMessage = "删除暂存开票信息中...请稍等";
      invoice
          .removeInvoice(this.entTaxId, 1, this.drawers)
          .then((val) => {
            // _this.electronicsStatus = false;
            // _this.electronicsMessage = "";
            _this.$message.success('删除暂存开票信息成功')
          })
          .catch((err) => {
            // _this.electronicsStatus = false;
            // _this.electronicsMessage = "";
            _this.$message.error(err)
          })
    },
    // 下载PDF格式发票；
    handleDownloadInvoicePDF() {
      let _this = this
      invoiceQuery({
        invoiceCode: this.invoiceCode,
        invoiceNumber: this.invoiceNumber,
        invoiceCategory: 1
      })
          .then((val) => {
            if (val.data.records && val.data.records.length > 0) {
              let row = val.data.records[0]
              let download = function (url) {
                let fullUrl = url + '.pdf'
                console.log(fullUrl)
                window.open(fullUrl)
              }
              let url = row.fileUrl
              if (url === null || url === '' || url === undefined) {
                GetInvoiceDownloadUrl({
                  invoiceCode: row.invoiceCode,
                  invoiceNumber: row.invoiceNumber
                })
                    .then((val) => {
                      if (val.data) {
                        download(val.data.fileUrl)
                      } else {
                        _this.$message.error(
                            'PDF格式发票文件下载链接无效！'
                        )
                      }
                    })
                    .catch((err) => {
                      _this.$message.error(err)
                    })
              } else {
                download(url)
              }
            } else {
              _this.$message.error('没有查询到发票信息，无法打印。')
            }
            // _this.loading = false;
          })
          .catch((err) => {
            _this.$message.error(err)
            // _this.loading = false;
          })
    },
    // 删除商品
    handleDeleteProduct(row) {
      let entTaxId = JSON.parse(cache.getSession('company')).entTaxId
      let delList = new Array()
      delList[0] = {
        productId: row.productId,
        productCode: row.productCode,
        entTaxId: entTaxId
      }
      let _this = this
      deleteProduct(delList)
          .then((val) => {
            _this.getProductData()
            _this.$message.success(val.msg)
          })
          .catch((err) => {
            _this.$message.error(err)
          })
    },
    // 选择商品页面的使用按钮功能
    handleUseProduct(row) {
      this.productRowInfo = row
      this.productData.product[this.selectIndex].productName =
          '*' + row.taxationCateAbbr + '*' + row.productName
      this.productData.product[this.selectIndex].productCode =
          row.taxationCateCode
      this.productData.product[this.selectIndex].specification =
          row.specsModel
      this.productData.product[this.selectIndex].units = row.unit
      this.productData.product[this.selectIndex].price = row.price
      this.productData.product[this.selectIndex].taxRate = row.taxRate
      if (row.taxRates.length > 0) {
        this.productData.product[
            this.selectIndex
            ].taxRates = row.taxRates.split(',')
      }
      this.productData.product[this.selectIndex].number = ''
      this.productData.product[this.selectIndex].amount = ''
      this.productData.product[this.selectIndex].taxAmount = ''
      // row.preferentialFlag 使用优惠政策，0：不使用，1：使用
      // row.zeroRateFlag 零税率标识，空：非零税率，只有税率为 0 的时候才有值，1：出口零税率和免税，2：不征收，3 普通零税率
      if (row.preferentialFlag === 1 || row.zeroRateFlag != null) {
        this.productData.product[this.selectIndex].rowStatus = 4
      } else {
        this.productData.product[this.selectIndex].rowStatus = 0

        // 格式化，适配 2022040101 免征增值税政策；
        this.fmtProductPolicy2022040101(this.productData.product[this.selectIndex])
      }
      this.productData.product[this.selectIndex].preferentialFlag =
          row.preferentialFlag
      this.productData.product[this.selectIndex].preferentialType =
          row.preferentialType
      this.productData.product[this.selectIndex].zeroRateFlag =
          row.zeroRateFlag

      this.isCommodity = false
    },

    // 交付类型变更
    deliverChange(value) {
      if (value === '1') {
        this.deliverData = ''
        this.interactType = 1
      } else {
        this.deliverData = ''
        this.interactType = 2
      }
    },

    // 处理充值信息选择状态
    messageClick(key) {
      this.messageList.map((item) => {
        if (item.key === key) {
          item.isSelect = true
          this.selectAmount = item.discount
          this.getPay('W01', item.key)
          this.getPay('A01', item.key)
        } else {
          item.isSelect = false
        }
      })
    },

    // 获取短信剩余数量
    async getMessageNumber() {
      let company = JSON.parse(cache.getSession('company'))
      if (this.token && company) {
        const url = '/marketing/ent/features/findPage'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              entName: company.entName,
              entTaxId: company.entTaxId,
              featureId: 'F0000001',
              featureName: '短信服务',
              pageNum: 1,
              pageSize: 10
            },
            false,
            2
        )
        if (response) {
          if (response.code === 0) {
            response.data.records.map((item) => {
              if (item.featureId === 'F0000001') {
                this.messageNumber = parseFloat(item.surplus)
                if (this.messageNumber > 0) {
                  this.phoneStatus = false
                } else {
                  this.phoneStatus = true
                }
              }
            })
          }
        }
      }
    },

    // 获取短信产品信息
    async getMessageProductList() {
      let company = JSON.parse(cache.getSession('company'))
      if (this.token && company) {
        const url = '/marketing/feature/product/findPage'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              featureId: 'F0000001',
              featureName: '短信服务',
              enable: true,
              pageNum: 1,
              pageSize: 10
            },
            false,
            2
        )
        if (response) {
          if (response.code === 0) {
            response.data.records.map((item, index) => {
              let list = {}
              if (index === 0) {
                list = {
                  key: item.productId,
                  title: item.productName,
                  amount: item.oriPrice,
                  discount: item.favouredPrice,
                  isSelect: true
                }
                this.selectAmount = item.favouredPrice
                this.getPay('W01', item.productId)
                this.getPay('A01', item.productId)
              } else {
                list = {
                  key: item.productId,
                  title: item.productName,
                  amount: item.oriPrice,
                  discount: item.favouredPrice,
                  isSelect: false
                }
              }
              this.messageList = this.messageList.concat(list)
            })
            this.searchPay()
          }
        }
      }
    },

    // 点击短信充值
    messageRecharge() {
      this.getMessageProductList()
      this.messageStatus = true
      this.paySelect = '微信'
    },

    // 充值页面关闭
    messageRechargeClose() {
      this.messageStatus = false
      this.messageList = []
      this.paySelect = '微信'
      this.getMessageNumber()
      clearInterval(this.timerPay)
      this.timerPay = ''
      this.payNumber = 0
    },

    // 循环查询支付结果
    searchPay() {
      this.timerPay = setInterval(async () => {
        if (this.payNumber > 5) {
          clearInterval(this.timerPay)
        } else {
          let id = ''
          this.messageList.map((item) => {
            if (item.isSelect) {
              id = item.key
            }
          })
          this.payNumber = this.payNumber + 1
          await this.getPay('W01', id)
          await this.getPay('A01', id)
        }
      }, 3000)
    },

    // 获取支付二维码
    async getPay(type, productId) {
      let company = JSON.parse(cache.getSession('company'))
      if (this.token && company) {
        const url = '/marketing/trans/pay'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              productId: productId,
              entTaxId: company.entTaxId,
              taxDiscId: this.defaultDeviceInfo.taxDiscId,
              deviceType: this.defaultDeviceInfo.deviceType,
              payType: type,
              reqChannel: 4
            },
            false,
            1
        )
        if (response) {
          if (response.code === 0) {
            if (type === 'W01') {
              this.weChatUrl = response.data.payInfo
              this.$refs.weChat.getUrl(this.weChatUrl)
            }
            if (type === 'A01') {
              this.aliPayUrl = response.data.payInfo
              this.$refs.aliPay.getUrl(this.aliPayUrl)
            }
            await this.getPayResult(response.data.transId)
          }
        }
      }
    },

    // 获取支付结果
    async getPayResult(transId) {
      let company = JSON.parse(cache.getSession('company'))
      if (this.token && company) {
        const url = '/marketing/trans/info'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              transId: transId,
              pageNum: 1,
              pageSize: 100,
            },
            false,
            2
        )
        if (response) {
          if (response.code === 0) {
            if (response.data.transId === transId) {
              if (response.data.transStatus === '2') {
                clearInterval(this.timerPay)
                this.messageStatus = false
                this.successStatus = true
                this.getMessageNumber()
              }
            }
          }
        }
      }
    },

    // 切换支付方式
    payTypeChange(value) {
      if (value === '微信') {
        this.$refs.weChat.getUrl(this.weChatUrl)
      }
      if (value === '支付宝') {
        this.$refs.aliPay.getUrl(this.aliPayUrl)
      }
    },

    // 监控交付手机号码只能输入数字
    deliverPhoneChange(e) {
      this.deliverData = e.target.value
    },

    // 获取发票信息
    async getInvoiceHistory() {
      if (this.token) {
        const url = '/sys/customer/getSearchHis'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              userId: this.userId
            },
            false,
            2
        )
        if (response) {
          if (response.code === 0) {
            this.historyData = response.data
            if (response.data) {
              if (response.data.length > 0) {
                this.isHistoryShow = true
              } else {
                this.isHistoryShow = false
              }
            } else {
              this.isHistoryShow = false
            }
          }
        }
      }
    },

    // 选择历史购方信息
    historyNameSelect(name) {
      this.isHistoryShow = false
      this.purchaserName = name
      this.getBuyerInfo(name)
    },

    // 显示历史搜索框
    showHistory() {
      this.getInvoiceHistory()
      // this.isHistoryShow = true
    },
    // 获取搜索到的产品信息
    searchProductChange(productName, index) {
      this.selectIndex = index
      if (productName.length > 0) {
        this.searchProductTimer = setTimeout(() => {
          // this.isHistoryShow = false
          this.queryProductName = productName
          this.getProductData()
          this.isProductSearchShow = true
        }, 1000)
      } else {
        this.queryProductName = ''
        this.isProductSearchShow = false
      }
    },
    // 点击空白处隐藏商品信息查询列表
    showProductBlur() {
      this.blurProductTimer = setTimeout(() => {
        this.isProductSearchShow = false
        // this.queryProductName = ''
        clearInterval(this.blurProductTimer)
      }, 300)
    },
    // 发票清单导入
    async invoiceListImport() {
      this.$refs['excel-import'].value = null
      this.$refs['excel-import'].click()
    },
    // excel数据处理
    excelDataImport(event) {
      const file = event.target.files[0]
      get_excel_data(file, (data) => {
        const { header, body } = data
        if (body.length > 0) {
          this.isInvoiceList = true
          this.invoiceListNumber = body.length
          this.exportNumber = 0
          let list = []
          for (let i = 0; i < body.length; i++) {
            if (body[i].产品名称 === undefined || body[i].产品名称 === '') {
              this.isInvoiceList = false
              this.$message.error('导入产品清单中第' + (i + 1) + '行产品名称不能为空!')
              return
            }
            if (body[i].数量 === undefined || body[i].数量 === '') {
              this.isInvoiceList = false
              this.$message.error('导入产品清单中第' + (i + 1) + '行产品数量不能为空!')
              return
            }
            if (body[i].金额含税 === undefined || body[i].金额含税 === '') {
              this.isInvoiceList = false
              this.$message.error('导入产品清单中第' + (i + 1) + '行产品金额含税不能为空!')
              return
            }
            if (body[i].税率 === undefined || body[i].税率 === '') {
              this.isInvoiceList = false
              this.$message.error('导入产品清单中第' + (i + 1) + '行产品税率不能为空!')
              return
            }
            if (body[i].规格型号 === undefined || body[i].规格型号 === '') {
              body[i].规格型号 = ''
            } else {
              body[i].规格型号 = body[i].规格型号.toString()
            }
            if (body[i].计量单位 === undefined || body[i].计量单位 === '') {
              body[i].计量单位 = ''
            } else {
              body[i].计量单位 = body[i].计量单位.toString()
            }
            for (let l = 0; l < this.invoiceProductList.length; l++) {
              if (this.invoiceProductList[l].specsModel === '' || this.invoiceProductList[l].specsModel === null) {
                this.invoiceProductList[l].specsModel = ''
              }
              if (this.invoiceProductList[l].unit === '' || this.invoiceProductList[l].unit === null) {
                this.invoiceProductList[l].unit = ''
              }
              if (body[i].产品名称.toString().trim() === this.invoiceProductList[l].productName) {
                if (body[i].规格型号 === this.invoiceProductList[l].specsModel) {
                  if (body[i].计量单位 === this.invoiceProductList[l].unit) {
                    let rowStatus = 0
                    if (this.invoiceProductList[l].preferentialFlag === 1 || this.invoiceProductList[l].zeroRateFlag != null) {
                      rowStatus = 4
                    }

                    /**
                     * @description 导入商品税率处理办法：
                     * 1.导入商品税率有效，与已管理商品中的税率进行匹配；
                     *   管理商品税率选项包含导入商品税率则使用导入商品税率，否则使用管理商品的默认税率；
                     * 2.导入商品税率无效，使用管理商品的默认税率；
                     * @description 判断商品税率是否有效？
                     * 把商品税率转换为 float,转换成功则有效，否则无效。
                     */
                    const currentImportTaxRate = parseFloat(body[i].税率)
                    let currentTaxRate = this.invoiceProductList[l].taxRate
                    let currentTaxRates = this.invoiceProductList[l].taxRates.split(',')
                    if (!isNaN(currentImportTaxRate)) {
                      const findTemp = currentTaxRates.find(elev => parseFloat(elev) === currentImportTaxRate)
                      if (findTemp) {
                        currentTaxRate = findTemp
                      }
                    }

                    let rate = Math.abs(parseFloat(body[i].金额含税)) /
                        (1 + Math.abs(currentTaxRate)) * Math.abs(currentTaxRate)
                    let price = Math.abs(parseFloat(body[i].金额含税)) / Math.abs(parseFloat(body[i].数量))
                    let data = {
                      productName: '*' + this.invoiceProductList[l].taxationCateAbbr + '*' + this.invoiceProductList[l].productName,
                      productCode: this.invoiceProductList[l].taxationCateCode,
                      specification: this.invoiceProductList[l].specsModel,
                      units: this.invoiceProductList[l].unit,
                      price: Math.abs(price),
                      taxRate: currentTaxRate,
                      taxRates: currentTaxRates,
                      number: body[i].数量,
                      amount: body[i].金额含税,
                      taxAmount: Math.abs(NumberTwoDecimal(rate)),
                      rowStatus: rowStatus,
                      preferentialFlag: this.invoiceProductList[l].preferentialFlag,
                      preferentialType: this.invoiceProductList[l].preferentialType,
                      zeroRateFlag: this.invoiceProductList[l].zeroRateFlag,
                      productCheck: false
                    }
                    list = list.concat(data)
                    this.exportNumber++
                    this.progressStatus = parseInt(this.exportNumber) / parseInt(this.invoiceListNumber) * 100
                    break
                  }
                }
              }
            }
          }
          this.productData.product = list
          this.calculationTotalAmount(list)
          this.isInvoiceList = false
          if (this.productData.product.length >= 9) {
            this.isDetailed = true
            this.detailed = '清单'
            this.$message({
              message:
                  '超过8行明细将必须使用清单打印,票面将只显示（详见销货清单）和折扣!',
              type: 'warning'
            })
          }
          this.$alert('总共' + this.invoiceListNumber + '条数据，导入成功' + this.exportNumber + '条，导入失败' + (this.invoiceListNumber - this.exportNumber) + '条', '发票清单导入完成', {
            confirmButtonText: '确定',
            callback: action => {
            }
          })
        }
      })
    },
    // 获取产品列表数据
    async getProductList() {
      if (this.account) {
        const url = '/sys/product/findPage'
        let response = await AxiosRequestData(
            url,
            this.token,
            {
              mobile: this.account,
              reqChannel: 4,
              pageNum: 1,
              pageSize: 100000,
              entTaxId: this.billingTaxId
            },
            false,
            2
        )
        if (response) {
          if (response.code === 0) {
            this.totalNumber = response.data.total
            this.totalPage = response.data.pages
            if (response.data.records.length > 0) {
              let productList = []
              for (let i = 0; i < response.data.records.length; i++) {
                let list = {
                  productId: response.data.records[i].productId,
                  productName: response.data.records[i].productName,
                  productCode: response.data.records[i].productCode,
                  parentCode: response.data.records[i].parentCode,
                  taxItem: response.data.records[i].taxItem,
                  shortCode: response.data.records[i].shortCode,
                  taxRate: response.data.records[i].taxRate,
                  specsModel: response.data.records[i].specsModel,
                  price: response.data.records[i].price === null || response.data.records[i].price === '' ? '' : response.data.records[i].price,
                  unit: response.data.records[i].unit,
                  taxPriceFlag: response.data.records[i].taxPriceFlag,
                  hiddenFlag: response.data.records[i].hiddenFlag,
                  taxationCateCode: response.data.records[i].taxationCateCode,
                  taxationCateName: response.data.records[i].taxationCateName,
                  taxationCateAbbr: response.data.records[i].taxationCateAbbr,
                  preferentialFlag: response.data.records[i].preferentialFlag,
                  preferentialType: response.data.records[i].preferentialType,
                  zeroRateFlag: response.data.records[i].zeroRateFlag,
                  taxSpeManage: response.data.records[i].taxSpeManage,
                  manageUserId: response.data.records[i].manageUserId,
                  entName: response.data.records[i].entName,
                  entTaxId: response.data.records[i].entTaxId,
                  taxRates: this.productTax
                }
                productList = productList.concat(list)
              }
              this.invoiceProductList = productList
            }
          }
        }
      }
    },
    // 发票清单导入界面关闭
    invoiceListPageClose() {
      this.exportNumber = 0
      this.invoiceListNumber = 0
      this.statusFont = ''
      this.progressStatus = 0
    },
    // 批量导入模版下载
    exportTemplate() {
      import('@/utils/Export2Excel').then(excel => {
        const tHeader = ['产品名称', '规格型号', '计量单位', '数量', '金额含税', '税率']
        excel.export_json_to_excel({
          'header': tHeader,
          'data': '',
          'filename': '发票清单'
        })
      })
    },
    handlePolicy2022040101Detail() {
      this.$refs.policy2022040101ContentDialog.open()
    },
    /**
     * 格式化产品，初步适配 2022040101 免征增值税政策；
     * 此处格式化用于保证显示正确和打标识；
     */
    fmtProductPolicy2022040101(product = {}) {
      // rowStatus === 2 折扣行；
      if (product.rowStatus === 0 || product.rowStatus === 2) {
        if (this.useFlag) {
          product.taxRateOld = product.taxRate
          product.taxRate = '免税'
          const taxRatesTemp = product.taxRates || []
          taxRatesTemp.unshift('免税')
          product.taxRates = taxRatesTemp

          // 商品添加特殊标识表示使用政策；
          product.usePolicy2022040101 = true
        } else {
          // 政策开关关闭商品恢复；
          if (product.usePolicy2022040101) {
            product.taxRate = product.taxRateOld
          }
          const taxRatesTemp = product.taxRates || []
          const delIndex = taxRatesTemp.indexOf('免税')
          if (delIndex !== -1) {
            taxRatesTemp.splice(delIndex, 1)
          }
          // 取消标识；
          product.usePolicy2022040101 = false
        }
      }
    },
    /**
     * 计算发票信息，主要是商品金额计算；
     */
    computerInvoiceInfo() {
      let products = ProductListCalculation(
          this.productData.product,
          this.isTaxIncluded,
          this.isRedInvoice
      )
      this.productData.product = products
      this.calculationTotalAmount(products)
    },
    /**
     * 适配 2022040101 政策的提交开票；
     */
    handlePolicy2022040101InvoiceSubmit() {
      const resultIndex = this.productData.product.findIndex((item) => {
          return item.taxRate.toString() === '0.01'
      })

      if (resultIndex === -1) {
        this.submitData()
      } else {
        this.$refs.policy2022040101ContentDialogToInvoiceSubmit.open()
      }
    },
    /**
     * 继续提交开票；
     */
    handlePolicy2022040101InvoiceSubmitContinue() {
      this.submitData()
    },

    /**
     * 适配 20230109 减免增值税等政策的提交开票；
     */
    handlePolicy20230109InvoiceSubmit() {
      let openFlag = false

      const entType = JSON.parse(cache.getSession('company')).entType
      if (entType === 2) {
        // 小规模纳税人
        const resultIndex = this.productData.product.findIndex((item) => {
          return item.taxRate.toString() !== '0.01'
        })

        if (resultIndex !== -1) {
          openFlag = true
        }
      }

      if (openFlag) {
        this.$refs.policy20230109ContentDialogToInvoiceSubmit.open()
      } else {
        this.submitData()
      }
    },
    /**
     * 适配 20230109 减免增值税等政策的继续提交开票；
     */
    handlePolicy20230109InvoiceSubmitContinue() {
      this.submitData()
    }
  }
}
</script>

<style scoped>
.body {
  flex: 1;
}

.invoice_print {
  display: flex;
  justify-content: space-between;
  flex-direction: row;
}

.invoice_img {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  height: 100%;
}

.invoice_radio {
  margin: 5px;
  display: inline-block;
}

.invoice_button {
  margin: 5px;
}

grid-item {
  margin-bottom: 0px;
}

.invoice_input {
  width: 250px;
  margin: 5px;
}

.customer {
  height: 40%;
}

.invoice_customer {
  /*margin-top: 5px;*/
  display: flex;
  /*width: 100%;*/
  align-items: center;
  justify-content: center;
  /*z-index: 10;*/
  position: relative;
  /*left: 0px;*/
  /*bottom: 0;*/
  height: 98px;
  background: transparent;
  /*box-shadow: 0px -3px 6px rgba(0, 0, 0, 0.16);*/
  opacity: 1;
  top: -100px;
}

.password-area {
  word-wrap: break-word;
  word-break: break-all;
}
</style>
