<template>
  <div class="await">
    <div class="search">
      <BaseNewForm
        ref="searchForm"
        :spanNumber="8"
        :formRow="SearchformRow"
        :ruleForm="searchForm"
        :isFunBtn="false"
        @onSelect="searchSelectChangeHandle"
        :newFlag="true"
        :formRule="false"
      ></BaseNewForm>
      <div class="btn">
        <el-button type="primary" @click="searchHandle">搜索</el-button>
        <el-button @click="resizeSearchHandle">重置</el-button>
      </div>
    </div>
    <div class="maintable">
      <div class="left">
        <BaseTable
          ref="mainTable"
          :tableData="tableData"
          :tableColumn="tableColumn"
          :showSelect="true"
          :tabLoading="mainTabLoading"
          :tableHeight="'60vh'"
          @onSelectionChange="onSelectionChange"
          :border="false"
        >
          <template v-slot:receipt_status="{ row: scope }">
            <div>{{ status[scope.row["receipt_status"]] }}</div>
          </template>
        </BaseTable>
        <div class="footer">
          <basePage
            :pageModel="pageModel"
            @update:pageModel="currentChangeHandle"
          ></basePage>
        </div>
      </div>
      <div class="right">
        <div class="wrap">
          <div class="title">制单参数</div>
          <div class="from">
            <BaseNewForm
              ref="searchForm"
              :spanNumber="24"
              :formRow="asideformRow"
              :ruleForm="aisdeForm"
              :isFunBtn="false"
              @onSelect="asideSelectChangeHandle"
              :newFlag="true"
              :formRule="false"
            ></BaseNewForm>
          </div>
          <div class="footer">
            <el-button
              type="primary"
              :loading="maleReceiptsLoding"
              @click="maleReceipts"
              >制作凭证</el-button
            >
            <el-button @click="dontMake">不制作</el-button>
          </div>
        </div>
      </div>
    </div>
    <baseDialog
      class="dialog"
      :loading="dialogCommitLoading"
      v-model="dialogSwitch"
      :fullscreen="true"
      @close="dialogCloseHandle"
      @confirm="dialogconfirmHandle"
      :footerShow="true"
      :lookFlag="lookFlag"
      :title="dontmake ? '不制单备注' : '凭证制单'"
    >
      <template v-if="dontmake">
        <div>
          <el-input
            type="textarea"
            :rows="4"
            placeholder="请输入内容"
            v-model="dontmakeRemark"
          >
          </el-input>
        </div>
      </template>
      <template v-else>
        <div v-if="dialogSwitch" class="receipts">
          <div class="title">{{ receiptsTitle }}</div>
          <div class="date">
            <span class="demonstration">制单时间:</span>
            <div class="datepick">
              <el-date-picker
                v-model="receiptsDate"
                type="date"
                placeholder="选择日期"
                value-format="yyyy-MM-dd"
                size="mini"
              >
              </el-date-picker>
            </div>
          </div>
          <div class="main">
            <div class="top">
              <div class="left">
                <div class="select">
                  <el-select v-model="receiptsSelect" placeholder="">
                    <el-option
                      v-for="item in receiptsOptions"
                      :key="item.id"
                      :label="item.label"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </div>
                <div class="input">
                  <el-input
                    v-model="receiptsnumber"
                    :disabled="true"
                    placeholder=""
                  ></el-input>
                </div>
              </div>
              <div class="right">
                <el-button type="primary" @click="addTableRow"
                  >新增行</el-button
                >
                <el-button @click="delectEow">删除行</el-button>
              </div>
            </div>
            <div class="table">
              <BaseTable
                ref="receiptsTable"
                :showIndex="true"
                :highlightCurrent="true"
                @onRowClick="tableClick"
                :tableData="receiptsTableData"
                :tableColumn="receiptsTableColumn"
                :tabLoading="receiptsabLoading"
                @doubleClick="receipDoubleClick"
                @sumsChange="sumsChangeHandle"
                :showsummary="true"
                :tableHeight="400"
                :receipSum="receipSum"
                :border="true"
                :SummariesIndex="[3, 4]"
              >
                <!-- 摘要 -->
                <template v-slot:abstract_msg="{ row: scope }">
                  <div v-if="!scope.row[scope.column.property + 'show']">
                    {{ scope.row[scope.column.property] }}
                  </div>
                  <div v-else>
                    <el-input
                      v-model="scope.row[scope.column.property]"
                      :ref="scope.column.property + scope.$index"
                      @blur="scope.row[scope.column.property + 'show'] = false"
                    ></el-input>
                  </div>
                </template>
                <!-- 科目 -->
                <template v-slot:subject="{ row: scope }">
                  <!-- <div v-if="!scope.row[scope.column.property + 'show']">
                    {{ scope.row[scope.column.property] }}
                  </div>
                  <div v-else> -->
                  <baseNewSelect
                    :lookflag="!scope.row[scope.column.property + 'show']"
                    :ref="scope.column.property + scope.$index"
                    v-model="scope.row[scope.column.property]"
                    :itemObj="scope.row"
                    @showValue="showValueHandle"
                    @selectChange="selectChangeHandle"
                    @blur="scope.row[scope.column.property + 'show'] = false"
                    :idKey="scope.column.property"
                    :journalingType="'subject'"
                  ></baseNewSelect>
                  <!-- </div> -->
                </template>
                <!-- 借方金额 -->
                <template v-slot:debit_amount="{ row: scope }">
                  <div v-if="!scope.row[scope.column.property + 'show']">
                    {{ scope.row[scope.column.property] }}
                  </div>
                  <div v-else>
                    <el-input-number
                      :precision="2"
                      v-model="scope.row[scope.column.property]"
                      :ref="scope.column.property + scope.$index"
                      controls-position="right"
                      @blur="
                        jineoneBlur(
                          scope.row,
                          scope.row[scope.column.property],
                          scope.row[scope.column.property + 'show']
                        )
                      "
                      @keyup.enter.native="
                        jineoneBlur(
                          scope.row,
                          scope.row[scope.column.property],
                          scope.row[scope.column.property + 'show']
                        )
                      "
                      :min="0"
                      :max="99999"
                    ></el-input-number>
                  </div>
                </template>
                <!-- 贷方金额 -->
                <template v-slot:credit_amount="{ row: scope }">
                  <div v-if="!scope.row[scope.column.property + 'show']">
                    {{ scope.row[scope.column.property] }}
                  </div>
                  <div v-else>
                    <el-input-number
                      :precision="2"
                      v-model="scope.row[scope.column.property]"
                      :ref="scope.column.property + scope.$index"
                      controls-position="right"
                      @blur="
                        credit_amountBlur(
                          scope.row,
                          scope.row[scope.column.property],
                          scope.row[scope.column.property + 'show']
                        )
                      "
                      @keyup.enter.native="
                        credit_amountBlur(
                          scope.row,
                          scope.row[scope.column.property],
                          scope.row[scope.column.property + 'show']
                        )
                      "
                      :min="0"
                      :max="99999"
                    ></el-input-number>
                  </div>
                </template>
              </BaseTable>
            </div>
            <div class="footer">
              <div class="left">
                <div class="top">
                  <div class="left">
                    分 录：{{
                      receiptsclickRow.index + 1
                        ? receiptsclickRow.index + 1
                        : ""
                    }}
                  </div>
                  <div class="right">
                    <el-radio
                      :disabled="true"
                      v-model="receiptsclickRow.direction"
                      label="1"
                      >借</el-radio
                    >
                    <el-radio
                      :disabled="true"
                      v-model="receiptsclickRow.direction"
                      label="2"
                      >贷</el-radio
                    >
                  </div>
                </div>
                <div class="bottom">
                  科 目：{{ receiptsclickRow.subjectShowValue }}
                </div>
              </div>
              <div class="right" @click="particularsClick">
                <div v-if="receiptsclickRow.project_flag" class="chunk">
                  <div class="smalltitle">项目：</div>
                  <div class="value">
                    <BaseRightLeftSelect
                      v-model="receiptsclickRow.project"
                      :lookflag="true"
                      :journalingType="'project'"
                    ></BaseRightLeftSelect>
                  </div>
                </div>
                <div v-if="receiptsclickRow.suppliter_flag" class="chunk">
                  <div class="smalltitle">供应商：</div>
                  <div class="value">
                    <BaseRightLeftSelect
                      v-model="receiptsclickRow.suppliter"
                      :lookflag="true"
                      :journalingType="'supplier'"
                    ></BaseRightLeftSelect>
                  </div>
                </div>
                <div v-if="receiptsclickRow.client_flag" class="chunk">
                  <div class="smalltitle">客户：</div>
                  <div class="value">
                    <BaseRightLeftSelect
                      v-model="receiptsclickRow.client"
                      :lookflag="true"
                      :journalingType="'client'"
                    ></BaseRightLeftSelect>
                  </div>
                </div>
                <div v-if="receiptsclickRow.salesman_flag" class="chunk">
                  <div class="smalltitle">业务员：</div>
                  <div class="value">
                    <BaseRightLeftSelect
                      v-model="receiptsclickRow.salesman"
                      :lookflag="true"
                      :journalingType="'salesman'"
                    ></BaseRightLeftSelect>
                  </div>
                </div>
                <div v-if="receiptsclickRow.section_flag" class="chunk">
                  <div class="smalltitle">部门：</div>
                  <div class="value">
                    <BaseRightLeftSelect
                      v-model="receiptsclickRow.section"
                      :lookflag="true"
                      :journalingType="'section'"
                    ></BaseRightLeftSelect>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <footer>
            <div class="top">
              <div class="chunk">
                <div class="smtitle">账套名称：</div>
                <div class="value">{{ attribute.sob }}</div>
              </div>
            </div>
            <div class="bottom">
              <div class="chunk">
                <div class="smtitle">账套年：</div>
                <div class="value">{{ attribute.year }}</div>
              </div>
              <div class="chunk">
                <div class="smtitle">制单：</div>
                <div class="value">{{ attribute.documenterman }}</div>
              </div>
              <div class="chunk">
                <div class="smtitle">审核：</div>
                <div class="value">{{ attribute.auditorman }}</div>
              </div>
              <div class="chunk">
                <div class="smtitle">审核日期：</div>
                <div class="value">{{ attribute.auditor_date }}</div>
              </div>
              <div class="chunk">
                <div class="smtitle">记帐：</div>
                <div class="value">{{ attribute.bookkeeperman }}</div>
              </div>
              <div class="chunk">
                <div class="smtitle">出纳：</div>
                <div class="value">{{ attribute.tellerman }}</div>
              </div>
            </div>
          </footer>
        </div>
      </template>
    </baseDialog>
    <baseDialog
      title="辅助核算参照"
      :loading="assistLoading"
      v-model="assistdialogSwitch"
      :fullscreen="true"
      @close="SondialogCloseHandle"
      @confirm="assistdialogconfirmHandle"
      :footerShow="true"
      :width="'40%'"
      :top="'30vh'"
    >
      <BaseNewForm
        ref="assistForm"
        :spanNumber="24"
        :formRow="assistformRow"
        :ruleForm="receiptsclickRowClone"
        :isFunBtn="false"
        :newFlag="true"
        @onSubmit="receiptsOnSubmit"
      ></BaseNewForm>
    </baseDialog>
  </div>
</template>

<script>
import BaseNewForm from "./compoments/baseNewForm";
import BaseTable from "./compoments/baseTable";
import basePage from "./compoments/basePage.vue";
import baseDialog from "./compoments/baseDialog.vue";
import baseNewSelect from "./compoments/baseNewSelect.vue";
import ToString from "./utils/numChange";
import { deepClone } from "@/utils/index.js";
import { getUserModuleApi } from "@/api/integrationOption/integrationOption.js";
import BaseRightLeftSelect from "./compoments/baseLeftRightSelect.vue";
export default {
  data() {
    return {
      attribute: {},
      // 制单状态字典
      maleReceiptsLoding: false,
      status: {
        1: "未制单",
        2: "已制单",
        3: "不制单",
      },
      // 凭证相关数据
      assistformFooter: {},
      assistformRow: [],
      assistLoading: false,
      assistdialogSwitch: false,
      receipSum: 0,
      dictionaries: {},
      receiptsabLoading: false,
      receiptsclickRow: {},
      receiptsclickRowClone: {},
      receiptsnumber: "11",
      receiptsTableData: [],
      receiptsTableColumn: [
        {
          id: "abstract_msg",
          title: "摘要",
          width: 300,
        },
        {
          id: "subject",
          title: "科目",
          total: 20,
          width: 600,
        },
        {
          id: "debit_amount",
          title: "借方金额",
        },
        {
          id: "credit_amount",
          title: "贷方金额",
        },
      ],
      receiptsOptions: [
        {
          id: 1,
          label: "转",
          title: "转账凭证",
        },
        {
          id: 2,
          label: "银付",
          title: "银行付款凭证",
        },
        {
          id: 3,
          label: "银收",
          title: "银行收款证",
        },
        {
          id: 4,
          label: "现收",
          title: "现金收款凭证",
        },
        {
          id: 5,
          label: "现付",
          title: "现金付款凭证",
        },
        {
          id: 6,
          label: "调整",
          title: "调整器凭证",
        },
      ],
      receiptsSelect: 2,
      receiptsDate: "",
      //   不制单相关
      dontmakeRemark: "",
      dontmake: false,
      dialogSwitch: false,
      lookFlag: false,
      dialogCommitLoading: false,
      pageModel: {
        pageIndex: 1,
        total: 10,
        limit: 10,
      },
      mainTabLoading: false,
      searchForm: {},
      SearchformRow: [
        {
          elCol: [
            {
              type: "input",
              title: "标题",
              id: "receipt_title",
              row: 8,
            },
            {
              type: "newSelect",
              title: "单据类型",
              id: "receipt_type",
              row: 8,
              journalingType: "receiptConf",
            },
          ],
        },
      ],
      tableData: [],
      tableColumn: [
        {
          id: "receipt_title",
          title: "标题",
        },
        {
          id: "receipt_type_name",
          title: "单据类型",
        },
        {
          id: "receipt_status",
          title: "制单状态",
        },
      ],
      asideformRow: [
        {
          elCol: [
            {
              type: "select",
              title: "分录合并",
              id: "consolidationEntries",
              row: 24,
              options: [
                { id: "1", label: "不合并" },
                { id: "2", label: "相同科目+辅助核算" },
                { id: "3", label: "相同科目+辅助核算+摘要" },
              ],
            },
          ],
        },
        {
          elCol: [
            {
              type: "select",
              title: "分录顺序",
              id: "sortsType",
              row: 24,
              disabled: false,
              options: [
                { id: "1", label: "固定先借后贷" },
                { id: "2", label: "按表单先借后贷" },
                { id: "3", label: "按表单填制顺序" },
              ],
            },
          ],
        },
        {
          elCol: [
            {
              type: "onecheck",
              title: "多张表单生成同一张",
              id: "2",
              row: 24,
            },
          ],
        },
      ],
      aisdeForm: {
        sortsType: "1",
        consolidationEntries: "1",
      },
      checkTable: [],
    };
  },
  components: {
    BaseNewForm,
    BaseTable,
    basePage,
    baseDialog,
    baseNewSelect,
    BaseRightLeftSelect,
  },
  methods: {
    // 下拉字段查询（id找label)
    async selectChangeHandle(val) {
      if (val) {
        const res = await getUserModuleApi(
          {
            tl: "sys_voucherService",
            as: "sys_voucherService",
            dj: "account",
          },
          {
            account: val,
          }
        );
        if (res.status == 200) {
          if (!res.attribute.client_flag) {
            this.$set(this.receiptsclickRow, "client_flag", false);
            this.$set(this.receiptsclickRow, "client", null);
          } else {
            this.$set(this.receiptsclickRow, "client_flag", true);
          }
          if (!res.attribute.project_flag) {
            this.$set(this.receiptsclickRow, "project_flag", false);
            this.$set(this.receiptsclickRow, "project", null);
          } else {
            this.$set(this.receiptsclickRow, "project_flag", true);
          }
          if (!res.attribute.salesman_flag) {
            this.$set(this.receiptsclickRow, "salesman_flag", false);
            this.$set(this.receiptsclickRow, "salesman", null);
          } else {
            this.$set(this.receiptsclickRow, "salesman_flag", true);
          }
          if (!res.attribute.section_flag) {
            this.$set(this.receiptsclickRow, "section_flag", false);
            this.$set(this.receiptsclickRow, "section", null);
          } else {
            this.$set(this.receiptsclickRow, "section_flag", true);
          }
          if (!res.attribute.supplier_flag) {
            this.$set(this.receiptsclickRow, "supplier_flag", false);
            this.$set(this.receiptsclickRow, "supplier", null);
          } else {
            this.$set(this.receiptsclickRow, "supplier_flag", true);
          }
        }
      }
    },
    // 初始化主表
    async initMainTableHandele(obj = {}) {
      this.mainTabLoading = true;
      const res = await getUserModuleApi(
        {
          tl: "sys_voucherService",
          as: "sys_voucherService",
          dj: "queryVoucherPage",
        },
        {
          pageNum: this.pageModel.pageIndex,
          pageSize: this.pageModel.limit,
          receipt_status: "1",
          ...obj,
        }
      );
      this.mainTabLoading = false;
      if (res.status == 200) {
        this.pageModel.total = res.attribute.total;
        this.tableData = res.attribute.list;
      }
    },
    // 不制单请求
    async unfinishHandle(obj) {
      const res = await getUserModuleApi(
        {
          tl: "sys_voucherService",
          as: "sys_voucherService",
          dj: "notProofPrepare",
        },
        obj
      );
      if (res.status == 200) {
        this.dialogSwitch = false;
        this.$message({
          type: "success",
          message: "单据不制单成功",
        });
      }
      this.dialogCommitLoading = false;
    },
    // 凭证制单请求
    async finishHandle(obj) {
      const res = await getUserModuleApi(
        {
          tl: "sys_voucherService",
          as: "sys_voucherService",
          dj: "proofPrepare",
        },
        obj
      );
      this.maleReceiptsLoding = false;
      if (res.status == 200) {
        this.attribute = res.attribute;
        this.searchSob(res.attribute.sob_no, "sob").then((val) => {
          this.attribute.sob = val;
        });
        if (res.attribute.documenter) {
          this.searchSob(res.attribute.documenter, "salesman").then((val) => {
            this.attribute.documenterman = val;
          });
        }
        if (res.attribute.auditor) {
          this.searchSob(res.attribute.auditor, "salesman").then((val) => {
            this.attribute.auditorman = val;
          });
        }

        res.attribute.bookkeeper &&
          this.searchSob(res.attribute.bookkeeper, "salesman").then((val) => {
            this.attribute.bookkeeperman = val;
          });
        res.attribute.teller &&
          this.searchSob(res.attribute.teller, "salesman").then((val) => {
            this.attribute.tellerman = val;
          });
        this.dontmake = false;
        this.dialogSwitch = true;
        this.receiptsSelect = res.attribute.vou * 1;
        this.receiptsnumber = res.attribute.voucher_number;
        this.receiptsTableData = [];
        this.receiptsDate = res.attribute.certificate_date;
        let obj = {
          abstract_msgshow: false,
          subjectshow: false,
          debit_amountshow: false,
          credit_amountshow: false,
        };
        res.attribute.proofDetails.forEach((item) => {
          this.receiptsTableData.push({ ...item, ...obj });
        });
      }
    },
    // 寻找各种数据/账套/业务员
    async searchSob(val, type) {
      const res = await getUserModuleApi(
        {
          tl: "sys_proofService",
          as: "sys_proofService",
          dj: "getJournaling",
        },
        {
          journalingType: type,
          codes: val,
        }
      );
      // this.attribute.sob = res.attribute.names;

      return res.attribute ? res.attribute.names : "";
    },
    // 删除行
    delectEow() {
      if (this.receiptsclickRow.index || this.receiptsclickRow.index == 0) {
        this.receiptsTableData.splice(this.receiptsclickRow.index, 1);
        this.receiptsclickRow = {};
        this.$nextTick(() => {
          this.$refs.receiptsTable.setCurrent();
        });
      }
    },
    SondialogCloseHandle() {},
    // 子dialog点击提交后并验证通过
    receiptsOnSubmit() {
      this.receiptsclickRow["project"] = this.receiptsclickRowClone.project;
      this.receiptsclickRow["suppliter"] = this.receiptsclickRowClone.suppliter;
      this.receiptsclickRow["salesman"] = this.receiptsclickRowClone.salesman;
      this.receiptsclickRow["section"] = this.receiptsclickRowClone.section;
      this.receiptsclickRow["client"] = this.receiptsclickRowClone.client;
      this.assistdialogSwitch = false;
    },
    // 子dialog表单验证
    assistdialogconfirmHandle() {
      this.$refs.assistForm.submitForm();
    },
    // dialog关闭
    dialogCloseHandle() {
      if (this.receiptsclickRow) {
        this.receiptsclickRow = "";
        this.receiptsclickRowClone = "";
      }
    },
    // 保存凭证
    async saveFininshDataHanlde(obj) {
      const res = await getUserModuleApi(
        {
          tl: "sys_voucherService",
          as: "sys_voucherService",
          dj: "saveProofPrepare",
        },
        obj
      );
      if (res.status == 200) {
        this.dialogSwitch = false;
        this.$message({
          type: "success",
          message: "保存凭证成功！",
        });
        this.initMainTableHandele(this.searchForm);
      }
    },
    // 父dialog点击提交
    dialogconfirmHandle() {
      this.dialogCommitLoading = true;
      if (this.dontmake) {
        let obj = { ids: [], not_receipt_reason: "" };
        obj["not_receipt_reason"] = this.dontmakeRemark;
        this.checkTable.forEach((item) => {
          obj["ids"].push(item.id);
        });
        this.unfinishHandle(obj);
        // this.dialogSwitch = false;
      } else {
        if (this.receipSum) {
          this.dialogCommitLoading = false;
          this.attribute.vou = this.receiptsSelect;
          this.attribute.voucher_number = this.receiptsnumber;
          this.attribute.certificate_date = this.receiptsDate;
          this.attribute.proofDetails = this.receiptsTableData;
          this.dialogCommitLoading = true;
          this.saveFininshDataHanlde(this.attribute);
        } else {
          this.$message({
            type: "error",
            message: "贷款与借款金额不统一，无法提交！",
          });
        }
      }
    },
    // 底部盒子点击后显示孙dialog
    particularsClick() {
      this.assistformRow = [];
      if (this.receiptsclickRow.project_flag) {
        this.assistformRow.push({
          elCol: [
            {
              id: "project",
              title: "项目",
              // 改动了！
              type: "newRightSelect",
              journalingType: "project",
            },
          ],
        });
      }
      if (this.receiptsclickRow.suppliter_flag) {
        this.assistformRow.push({
          elCol: [
            {
              id: "suppliter",
              title: "供应商",
              type: "newRightSelect",
              journalingType: "supplier",
            },
          ],
        });
      }
      if (this.receiptsclickRow.client_flag) {
        this.assistformRow.push({
          elCol: [
            {
              id: "client",
              title: "客户",
              type: "newRightSelect",
              journalingType: "client",
            },
          ],
        });
      }
      if (this.receiptsclickRow.salesman_flag) {
        this.assistformRow.push({
          elCol: [
            {
              id: "salesman",
              title: "业务员",
              type: "newRightSelect",
              journalingType: "salesman",
            },
          ],
        });
      }
      if (this.receiptsclickRow.section_flag) {
        this.assistformRow.push({
          elCol: [
            {
              id: "section",
              title: "部门",
              type: "newRightSelect",
              required: true,
              journalingType: "section",
            },
          ],
        });
      }
      if (this.assistformRow.length) {
        this.assistdialogSwitch = true;
      }
    },
    // newselect回显value
    showValueHandle(val, row, idKey) {
      this.$set(row, idKey + "ShowValue", val);
    },
    // 合计换算答谢
    sumsChangeHandle(arr) {
      if (arr[3] == arr[4] && arr[3]) {
        this.receipSum = ToString(arr[3]);
      } else {
        this.receipSum = "";
      }
    },
    // 单据添加行
    addTableRow() {
      let obj = {
        abstract_msgshow: false,
        subjectshow: false,
        debit_amountshow: false,
        credit_amountshow: false,
      };
      this.receiptsTableData.push({ ...obj });
    },
    // 贷款失焦，改变状态清掉借款数据
    credit_amountBlur(row, val, flag) {
      if (val) {
        row["debit_amount"] = "";
        row.direction = 1;
      } else {
        row["credit_amount"] = "";
      }
      row.credit_amountshow = false;
    },
    // 借款失焦，改变状态清掉贷款数据
    jineoneBlur(row, val, flag) {
      if (val) {
        row["credit_amount"] = "";
        row.direction = 2;
      } else {
        row["debit_amount"] = "";
      }
      row.debit_amountshow = false;
    },
    // 双击单元格
    receipDoubleClick(row, column, cell, event) {
      row[column.property + "show"] = true;
      this.$nextTick(() => {
        this.$refs[column.property + row.index] &&
          this.$refs[column.property + row.index].focus();
      });
    },
    // 单机单元格（收集数据）
    tableClick(row) {
      if (row != this.receiptsclickRow) {
        this.receiptsclickRow = {};
      }
      this.$nextTick(() => {
        this.receiptsclickRow = row;
        this.receiptsclickRowClone = deepClone(row);
      });
    },
    // 点击制作凭证
    maleReceipts() {
      if (this.checkTable.length) {
        this.maleReceiptsLoding = true;
        let obj = { ids: [], ...this.aisdeForm };
        this.checkTable.forEach((item) => {
          obj["ids"].push(item.id);
        });
        this.finishHandle(obj);
      } else {
        this.$message({
          message: "请选择单据",
        });
      }
    },
    // 点击不制作
    dontMake() {
      if (this.checkTable.length) {
        this.dontmake = true;
        this.dialogSwitch = true;
      } else {
        this.$message({
          message: "请选择单据",
        });
      }
    },
    // 主表单多选返回
    onSelectionChange(val) {
      this.checkTable = val;
    },
    // 页码
    currentChangeHandle(pageModel) {
      this.pageModel = pageModel;
      this.$nextTick(() => {
        this.initMainTableHandele(this.searchForm);
      });
    },
    // 下拉框下拉事件
    searchSelectChangeHandle(val, index, indexRow, row) {},
    // 搜搜按钮
    searchHandle() {
      this.initMainTableHandele(this.searchForm);
    },
    // 重置按钮
    resizeSearchHandle() {
      this.searchForm = {};
    },
    // 制单参数下拉
    asideSelectChangeHandle(val, index, indexRow, row) {
      if (row.id == "consolidationEntries") {
        if (val == "1") {
          this.asideformRow[1]["elCol"][0].disabled = false;
        } else {
          this.asideformRow[1]["elCol"][0].disabled = true;
          if (this.aisdeForm["sortsType"]) {
            this.aisdeForm["sortsType"] = "1";
          }
        }
      }
    },
  },
  computed: {
    receiptsTitle() {
      return this.receiptsOptions.find((item) => item.id == this.receiptsSelect)
        .title;
    },
    subjectComputed() {},
  },
  created() {
    this.initMainTableHandele();
  },
};
</script>

<style scoped lang="scss">
.await {
  width: 100%;
  .search {
    padding: 20px;
    background-color: #fff;
    border-radius: 20px;
    .btn {
      display: flex;
      justify-content: flex-end;
    }
  }
  .maintable {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    width: 100%;
    .left {
      background-color: #fff;
      padding: 20px;
      border-radius: 20px;
      width: 75%;
      > .footer {
        margin-top: 20px;
      }
    }
    .right {
      margin-left: 20px;
      background-color: #fff;
      border-radius: 20px;
      width: 25%;
      position: relative;
      > .wrap {
        padding: 20px;
        .title {
          font-size: 20px;
          margin-bottom: 20px;
        }
        > .footer {
          position: absolute;
          bottom: 20px;
          right: 10px;
        }
      }
    }
  }
}
.dialog {
  .receipts {
    text-align: center;
    .title {
      font-size: 20px;
      font-weight: 600;
    }
    .date {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      .demonstration {
        margin-right: 30px;
      }
      .datepick {
        width: 200px;
      }
    }
    .main {
      margin-top: 10px;
      border: 1px solid #000;
      border-radius: 10px;
      > .top {
        padding: 10px 10px 0;
        display: flex;
        justify-content: space-between;
        .left {
          display: flex;
          text-align: left;
          .select {
            width: 130px;
          }
          .input {
            margin-left: 10px;
            width: 100px;
          }
        }
        .right {
        }
      }
      > .table {
        padding: 0 10px 0;
        margin-top: 10px;
      }
      > .footer {
        border-top: 1px solid #000;
        margin-top: 10px;
        padding: 10px;
        display: flex;
        align-items: center;
        font-weight: 700;
        > .left {
          display: flex;
          flex-direction: column;
          align-items: flex-start;
          > .top {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            .left {
              margin-right: 20px;
            }
          }
          > .bottom {
            margin-top: 10px;
            display: flex;
            justify-content: flex-start;
          }
        }
        > .right {
          padding: 20px;
          text-align: left;
          border: 1px solid #ccc;
          width: 80%;
          margin-left: 10px;
          height: 80px;
          display: flex;
          align-items: center;
          .chunk {
            width: 20%;
            display: flex;
            align-items: center;
            > .value {
              width: 60%;
              text-align: left;
              display: -webkit-box; /*作为弹性伸缩盒子模型显示。*/
              -webkit-box-orient: vertical; /*作为弹性伸缩盒子模型显示。*/
              -webkit-line-clamp: 1; //*显示的行*/
              overflow: hidden; /*溢出隐藏*/
              /* 对于连字情况或者纯字母，可以解决 */
              word-break: break-all;
            }
          }
        }
      }
    }
    footer {
      padding: 20px;
      margin-top: 20px;
      background-color: #e1e3e8;
      height: 80px;
      font-weight: 800;
      border-radius: 10px;
      > .top {
        text-align-last: left;
        > .chunk {
          display: flex;
          font-weight: 800;
        }
      }
      > .bottom {
        margin-top: 10px;
        text-align-last: left;
        display: flex;
        justify-content: space-between;
        .chunk {
          margin-right: 20px;
          display: flex;
          font-weight: 800;
        }
      }
    }
  }
}
</style>
