Browse Source

结算中心新加凭证数据模块

Qukatie 1 week ago
parent
commit
bebe2a4812

+ 10 - 0
src/api/iosBasicData/finstlbills.js

@@ -238,4 +238,14 @@ export const getListAll  = (data) => {
     method: 'get',
     params: data
   })
+}
+// 付费申请删除从表数据
+export const voucherRemove = (ids) => {
+  return request({
+    url: '/api/blade-los/finstlbillsvoucheritems/remove',
+    method: 'post',
+    params: {
+      ids,
+    }
+  })
 }

+ 649 - 0
src/views/iosBasicData/ComputationCenter/components/fromtableDetails.vue

@@ -0,0 +1,649 @@
+<template>
+  <div>
+    <el-table
+      ref="tableRef"
+      :cell-style="{ padding: '0px', fontSize: '12px' }"
+      :header-cell-style="tableHeaderCellStyle"
+      :data="tableData"
+      :border="true"
+      show-summary
+      :summary-method="summaryMethod"
+      style="width: 100%"
+      @selection-change="handleSelectionChange"
+      @row-click="rowClick"
+      :row-style="rowStyle"
+      :row-class-name="rowClassName"
+    >
+      <el-table-column fixed="left" type="selection" width="50" align="center"></el-table-column>
+      <el-table-column type="index" width="40" align="center"> </el-table-column>
+      <el-table-column prop="descr" label="摘要" min-width="150px" style="padding: 0" align="center">
+        <template slot-scope="{ row }">
+          <el-input
+            style="width: 100%"
+            type="text"
+            v-model="row.descr"
+            size="small"
+            autocomplete="off"
+            clearable
+            placeholder="请输入摘要"
+            :disabled="disabled"
+          >
+          </el-input>
+        </template>
+      </el-table-column>
+      <el-table-column prop="accountCode" label="科目代码" width="360px">
+        <template slot-scope="{ row }">
+          <div style="display: flex; align-items: center; justify-content: space-between">
+            <search-query
+              style="width: 100%"
+              :datalist="accountData"
+              :selectValue="row.accountCode"
+              :filterable="true"
+              :clearable="true"
+              :remote="true"
+              :buttonIf="false"
+              :desc="true"
+              :forParameter="{ key: 'code', label: 'code', value: 'code', desc: 'fullName' }"
+              :disabled="disabled"
+              @corpFocus="accountsListfun"
+              @remoteMethod="accountsListfun"
+              @corpChange="corpChange($event, 'accountId', row)"
+            >
+            </search-query>
+            <el-tooltip
+              v-if="!disabled && (row.isEmpl === 1 || row.isCorp === 1 || row.isDept === 1 || row.isItem === 1)"
+              class="item"
+              effect="dark"
+              content="核算项目"
+              placement="top"
+            >
+              <el-button size="mini" type="primary" icon="el-icon-edit" circle @click="auxiliaryAccountingfun(row)" :disabled="disabled"></el-button>
+            </el-tooltip>
+            <el-tooltip v-if="!disabled && row.isDc === 1" class="item" effect="dark" content="预收/预付核销" placement="top">
+              <el-button size="mini" type="primary" icon="el-icon-scissors" circle @click="showOffRecordsfun(row)" :disabled="disabled"></el-button>
+            </el-tooltip>
+          </div>
+          <div style="display: flex">
+            <span>{{
+              (row.accountCnName ? row.accountCnName : " ") +
+                (row.isEmpl === 1 && row.emplName ? "/" + row.emplName : "") +
+                (row.isDept === 1 && row.deptName ? "/" + row.deptName : "") +
+                (row.isCorp === 1 && row.corpShortName ? "/" + row.corpShortName : "") +
+                (row.isItem === 1 ? "/" + row.itemClassify + "-" + (row.itemName ? row.itemName : "") : "")
+            }}</span>
+          </div>
+        </template>
+      </el-table-column>
+
+      <el-table-column prop="dc" label="方向" min-width="45px" style="padding: 0" align="center">
+        <template slot-scope="{ row }">
+          <span>{{ row.dc == "D" ? "借" : "贷" }}</span>
+        </template>
+      </el-table-column>
+
+      <el-table-column label="本币金额">
+        <el-table-column prop="amountDr" label="借方" min-width="90px" align="center">
+          <template slot-scope="{ row }">
+            <el-input-number
+              style="width: 100%"
+              v-model="row.amountDr"
+              size="small"
+              autocomplete="off"
+              :disabled="!row.accountId || disabled"
+              placeholder="请输入借方"
+              :precision="2"
+              @change="amountBlur(row, 'D')"
+              @keydown.native="handleKeydown($event, row, 'amountDr')"
+              :controls="false"
+            >
+            </el-input-number>
+          </template>
+        </el-table-column>
+        <el-table-column prop="amountCr" label="货方" min-width="90px" align="center">
+          <template slot-scope="{ row }">
+            <el-input-number
+              style="width: 100%"
+              v-model="row.amountCr"
+              size="small"
+              autocomplete="off"
+              :disabled="!row.accountId || disabled"
+              placeholder="请输入货方"
+              :precision="2"
+              @change="amountBlur(row, 'C')"
+              @keydown.native="handleKeydown($event, row, 'amountCr')"
+              :controls="false"
+            >
+            </el-input-number>
+          </template>
+        </el-table-column>
+      </el-table-column>
+      <el-table-column label="外币金额">
+        <el-table-column prop="curCode" label="币种" min-width="60px" align="center"> </el-table-column>
+        <el-table-column prop="exrate" label="汇率" min-width="80px" align="center">
+          <template slot-scope="{ row }">
+            <el-input-number
+              v-if="row.curCode === 'USD'"
+              style="width: 100%"
+              v-model="row.exrate"
+              size="small"
+              autocomplete="off"
+              clearable
+              placeholder="请输入借方"
+              :precision="4"
+              @change="amountBlur(row, 'exrate')"
+              :disabled="disabled"
+              :controls="false"
+            >
+            </el-input-number>
+            <!--            {{ row.exrate }}-->
+            <span v-else></span>
+          </template>
+        </el-table-column>
+        <el-table-column prop="amountDrUsd" label="借方" min-width="90px" align="center">
+          <template slot-scope="{ row }">
+            <el-input-number
+              v-if="row.changeMode !== 'd'"
+              style="width: 100%; text-align: right"
+              v-model="row.amountDrUsd"
+              size="small"
+              autocomplete="off"
+              :disabled="row.curCode === 'CNY' || !row.accountId || disabled"
+              clearable
+              placeholder="请输入借方"
+              :precision="2"
+              @change="amountUSDBlur(row, 'Dusd')"
+              :controls="false"
+            >
+            </el-input-number>
+          </template>
+        </el-table-column>
+        <el-table-column prop="amountCrUsd" label="货方" min-width="90px" align="center">
+          <template slot-scope="{ row }">
+            <el-input-number
+              v-if="row.changeMode !== 'd'"
+              style="width: 100%"
+              v-model="row.amountCrUsd"
+              size="small"
+              autocomplete="off"
+              :disabled="row.curCode === 'CNY' || !row.accountId || disabled"
+              clearable
+              placeholder="请输入货方"
+              :precision="2"
+              @change="amountUSDBlur(row, 'Cusd')"
+              :controls="false"
+            >
+            </el-input-number>
+          </template>
+        </el-table-column>
+      </el-table-column>
+      <!--
+      <el-table-column prop="remarks" label="备注" width="200px">
+        <template slot-scope="{ row }">
+          <el-input
+            style="width: 100%;"
+            type="textarea"
+            v-model="row.remarks"
+            size="small"
+            autocomplete="off"
+            clearable
+            placeholder="请输入备注"
+            :disabled="disabled"
+          >
+          </el-input>
+        </template>
+      </el-table-column>
+      -->
+      <el-table-column v-if="!disabled" label="操作" fixed="right" width="100px">
+        <template slot-scope="scope">
+          <el-tooltip class="item" effect="dark" content="添加" placement="top">
+            <el-button
+              size="mini"
+              type="primary"
+              icon="el-icon-plus"
+              circle
+              @click="addRowsfun(scope.row, scope.$index)"
+              :disabled="disabled"
+            ></el-button>
+          </el-tooltip>
+          <el-tooltip class="item" effect="dark" :content="scope.row.changeMode === 'd' ? '恢复' : '删除'" placement="top">
+            <el-button
+              size="mini"
+              type="danger"
+              icon="el-icon-delete"
+              circle
+              @click="deletefun(scope.row, scope.$index)"
+              :disabled="disabled"
+            ></el-button>
+          </el-tooltip>
+        </template>
+      </el-table-column>
+    </el-table>
+  </div>
+</template>
+
+<script>
+import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
+import { accountsList } from "@/api/iosBasicData/accounts";
+import { bcurrencyGetExrate } from "@/api/iosBasicData/rateManagement";
+import { dateFormat } from "@/util/date";
+
+export default {
+  components: { SearchQuery },
+  data() {
+    return {
+      accountData: [] // 科目数据
+    };
+  },
+  props: {
+    assemblyForm: {
+      type: Object,
+      default: {}
+    },
+    tableData: {
+      type: Array,
+      default: []
+    },
+    handleSelectionData: {
+      type: Array,
+      default: []
+    },
+    disabled: {
+      type: Boolean,
+      default: false
+    }
+  },
+  async created() {
+    this.accountsListfun();
+    // this.option = await this.getColumnData(this.getColumnName(321.1), this.optionBack);
+  },
+  methods: {
+    forceNumber(s, d) {
+      let N = Number(s);
+      return isNaN(N) ? 0.0 : Number(N.toFixed(d));
+    },
+    // 自定义合计
+    summaryMethod(param) {
+      const { columns, data } = param;
+      const sums = [];
+      columns.forEach((column, index) => {
+        if (index === 2) {
+          sums[index] = "合计";
+          return;
+        }
+        const values = data.map(item => (item.changeMode === "d" ? 0.0 : Number(item[column.property])));
+        // 显示列的统计 金额
+        let arr = ["amountDr", "amountCr", "amountDrUsd", "amountCrUsd"];
+        // 判断是否有这个数据
+        if (arr.indexOf(column.property) != -1) {
+          if (!values.every(value => isNaN(value))) {
+            sums[index] = values.reduce((prev, curr) => {
+              const value = Number(curr);
+              if (!isNaN(value)) {
+                return prev + curr;
+              } else {
+                return prev;
+              }
+            }, 0);
+            sums[index] = sums[index].toFixed(2); // 把合计的参数保留两位小数
+            // sums[index] += " 元";
+          } else {
+            sums[index] = " ";
+          }
+        }
+      });
+      return sums;
+    },
+    handleKeydown(e, row, name) {
+      console.log("handleKeydown", e, name);
+      if (e.key === "=") {
+        e.preventDefault();
+        // amountDr,amountCr
+        let amtDr = 0.0,
+          amtCr = 0.0;
+        this.tableData.forEach(item => {
+          if (item !== row) {
+            amtDr = this.forceNumber(amtDr + item.amountDr, 2);
+            amtCr = this.forceNumber(amtCr + item.amountCr, 2);
+          }
+        });
+        if (name === "amountDr") {
+          this.$set(row, "amountCr", 0.0);
+          this.$set(row, name, this.forceNumber(amtCr - amtDr, 2));
+        }
+        if (name === "amountCr") {
+          this.$set(row, "amountDr", 0.0);
+          this.$set(row, name, this.forceNumber(amtDr - amtCr, 2));
+        }
+
+        if (row.curCode === "USD") {
+          if (row.exrate.toFixed(4) === "0.0000") {
+            row.exrate = 1;
+          }
+
+          this.$set(row, "amountDrUsd", this.forceNumber(row.amountDr / row.exrate, 2));
+          this.$set(row, "amountCrUsd", this.forceNumber(row.amountCr / row.exrate, 2));
+        }
+      }
+    },
+    // 借方/贷方 本币的计算
+    amountBlur(row, name) {
+      console.log("amountBlur", row, name);
+      if (name == "D") {
+        this.$set(row, "amountCr", 0);
+      }
+      if (name == "C") {
+        this.$set(row, "amountDr", 0);
+      }
+      // if (name == 'Dusd') {
+      //     this.$set(row,'amountCrUsd',0)
+      // }
+      // if (name == 'Cusd') {
+      //     this.$set(row,'amountDrUsd',0)
+      // }
+      if (row.curCode == "USD") {
+        this.$set(row, "exrate", row.exrate ? Number(row.exrate) : 1);
+        this.$set(row, "amountCr", row.amountCr ? Number(row.amountCr) : 0);
+        this.$set(row, "amountDr", row.amountDr ? Number(row.amountDr) : 0);
+
+        this.$set(row, "amountCrUsd", (row.amountCr / row.exrate).toFixed(2));
+        this.$set(row, "amountDrUsd", (row.amountDr / row.exrate).toFixed(2));
+      }
+      // 合计本位币
+      this.$set(row, "amountDrLoc", row.amountDr);
+      this.$set(row, "amountCrLoc", row.amountCr);
+    },
+    // 外币的计算
+    amountUSDBlur(row, name) {
+      console.log("amountUSDBlur", row, name);
+      if (name == "Dusd") {
+        this.$set(row, "amountCrUsd", 0);
+      }
+      if (name == "Cusd") {
+        this.$set(row, "amountDrUsd", 0);
+      }
+      this.$set(row, "exrate", row.exrate ? Number(row.exrate) : 1);
+      this.$set(row, "amountCrUsd", row.amountCrUsd ? Number(row.amountCrUsd) : 0);
+      this.$set(row, "amountDrUsd", row.amountDrUsd ? Number(row.amountDrUsd) : 0);
+
+      this.$set(row, "amountCr", (row.amountCrUsd * row.exrate).toFixed(2));
+      this.$set(row, "amountDr", (row.amountDrUsd * row.exrate).toFixed(2));
+      // 合计本位币
+      this.$set(row, "amountDrLoc", (row.amountDrUsd * row.exrate).toFixed(2));
+      this.$set(row, "amountCrLoc", (row.amountCrUsd * row.exrate).toFixed(2));
+    },
+    // 获取科目类型数据
+    accountsListfun(code) {
+      // isManual == 1 的允许手工添加
+      accountsList(1, 10, { code, isDetail: 1, isManual: 1 }).then(res => {
+        console.log(res.data.data.records);
+        this.accountData = res.data.data.records;
+      });
+    },
+    // 行删除
+    deletefun(row, index) {
+      this.$emit("deletefun", row, index);
+    },
+    // 行添加
+    addRowsfun(row, index) {
+      this.$emit("addRowsfun", row, index);
+    },
+    // 辅助核算
+    auxiliaryAccountingfun(row) {
+      if (!row.accountId) {
+        return this.$message.warning("请先选择科目代码");
+      }
+      this.$emit("auxiliaryAccountingfun", row);
+    },
+    showOffRecordsfun(row) {
+      if (!row.accountId) {
+        return this.$message.warning("请先选择科目代码");
+      }
+      this.$emit("showOffRecordsfun", row);
+    },
+    // 下拉回调
+    corpChange(value, name, row) {
+      let found = false;
+      if (name === "accountId") {
+        for (let item of this.accountData) {
+          console.log(item);
+          if (item.code == value) {
+            found = true;
+            console.log(item, item.id);
+            this.$set(row, "accountId", item.id);
+            this.$set(row, "accountCode", item.code);
+            this.$set(row, "accountCnName", item.cnName);
+            this.$set(row, "accountEnName", item.enName);
+            this.$set(row, "accountFullName", item.fullName);
+            this.$set(row, "accountLevel", item.level);
+            this.$set(row, "accountProperty", item.property);
+            this.$set(row, "dc", item.dc);
+
+            // 币种
+            this.$set(row, "curCode", item.curCode === "USD" ? item.curCode : "CNY");
+            // 汇率
+            this.$set(row, "exrate", item.exrate);
+            // 其他
+            this.$set(row, "isForeign", item.isForeign);
+            this.$set(row, "isQuantity", item.isQuantity);
+            this.$set(row, "isCorp", item.isCorp);
+            this.$set(row, "isDept", item.isDept);
+            this.$set(row, "isEmpl", item.isEmpl);
+            this.$set(row, "isItem", item.isItem);
+            this.$set(row, "itemClassifyId", item.itemClassifyId);
+            this.$set(row, "itemClassify", item.itemClassify);
+
+            this.$set(row, "isDc", item.isDc);
+            this.$set(row, "isArAp", item.isArAp);
+            // 打开弹窗
+            this.$emit("auxiliaryAccountingfun", row);
+          }
+        }
+        if (!found) {
+          console.log("not found");
+          this.$set(row, "accountId", 0);
+          this.$set(row, "accountCode", "");
+          this.$set(row, "accountCnName", "");
+          this.$set(row, "accountEnName", "");
+          this.$set(row, "accountFullName", "");
+          this.$set(row, "accountLevel", 0);
+          this.$set(row, "accountProperty", 0);
+          this.$set(row, "dc", "");
+
+          // 币种
+          this.$set(row, "curCode", "");
+          // 汇率
+
+          // 其他
+          this.$set(row, "isForeign", 0);
+          this.$set(row, "isQuantity", 0);
+          this.$set(row, "isCorp", 0);
+          this.$set(row, "isDept", 0);
+          this.$set(row, "isEmpl", 0);
+          this.$set(row, "isItem", 0);
+          this.$set(row, "itemClassifyId", 0);
+          this.$set(row, "itemClassify", "");
+
+          this.$set(row, "isDc", 0);
+          this.$set(row, "isArAp", 0);
+
+          this.$set(row, "exrate", 0);
+        }
+
+        if (row.curCode === "USD") {
+          bcurrencyGetExrate({
+            date: this.assemblyForm.voucherDate
+              ? this.assemblyForm.voucherDate.slice(0, 10) + " 00:00:00"
+              : dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00", // 凭证日期
+            dc: row.dc,
+            type: 1
+          }).then(res => {
+            for (let item of res.data.data) {
+              if (item.code === row.curCode) {
+                this.$set(row, "exrate", this.forceNumber(item.exrate, 4));
+                this.$set(row, "amountDr", this.forceNumber(row.amountDr, 2));
+                this.$set(row, "amountCr", this.forceNumber(row.amountCr, 2));
+                this.$set(row, "amountDrUsd", this.forceNumber(row.amountDrUsd, 2));
+                this.$set(row, "amountCrUsd", this.forceNumber(row.amountCrUsd, 2));
+                if (row.amountDrUsd !== 0.0) {
+                  this.$set(row, "amountCrUsd", 0.0);
+                  this.$set(row, "amountCr", 0.0);
+                  this.$set(row, "amountDr", this.forceNumber(row.amountDrUsd * item.exrate, 2));
+                } else {
+                  this.$set(row, "amountDrUsd", 0.0);
+                  this.$set(row, "amountDr", 0.0);
+                  this.$set(row, "amountCr", this.forceNumber(row.amountCrUsd * item.exrate, 2));
+                }
+              }
+            }
+          });
+        } else {
+          this.$set(row, "exrate", 0);
+          this.$set(row, "amountDrUsd", 0.0);
+          this.$set(row, "amountCrUsd", 0.0);
+        }
+      }
+
+      console.log(row);
+    },
+    // 表头样式
+    tableHeaderCellStyle({ row, column, rowIndex, columnIndex }) {
+      return "padding:4px 0px;fontSize:12px;color:#000;background:#ecf5ff;text-align:center";
+    },
+    // 列表多选
+    // 多选选择的数据
+    handleSelectionChange(arr) {
+      this.$emit("handleSelectionChange", arr);
+    },
+    // 监听点击表格事件
+    rowClick(row, column, event) {
+      let refsElTable = this.$refs.tableRef; // 获取表格对象
+      if (this.CtrlDown) {
+        refsElTable.toggleRowSelection(row); // ctrl多选 如果点击两次同样会取消选中
+        return;
+      }
+      if (this.shiftOrAltDown && this.handleSelectionData.length > 0) {
+        // 通过rowIndex判断已选择的行中最上面和最下面的是哪行,再对比按住shift/alt点击的当前行得到新的最上面和最下面的行,把这两行中间的行进行循环选中。
+        let topAndBottom = this.getTopAndBottom(row, this.bottomSelectionRow, this.topSelectionRow);
+        refsElTable.clearSelection(); //先清空 不然会导致在这两行中间之外的行状态不变
+        for (let index = topAndBottom.top; index <= topAndBottom.bottom; index++) {
+          //选中两行之间的所有行
+          refsElTable.toggleRowSelection(this.tableData[index], true);
+        }
+      } else {
+        let findRow = this.handleSelectionData.find(c => c.rowIndex == row.rowIndex); //找出当前选中行
+        //如果只有一行且点击的也是这一行则取消选择 否则清空再选中当前点击行
+        if (findRow && this.handleSelectionData.length === 1) {
+          refsElTable.toggleRowSelection(row, false);
+          return;
+        }
+        // refsElTable.clearSelection(); // 清空之前选择的数据(如果放开,选择之前会变成单选)
+        refsElTable.toggleRowSelection(row); // 调用选中行方法
+      }
+    },
+    // 行的 style 的回调方法
+    rowStyle({ row, rowIndex }) {
+      // 直接在一个对象上定义一个新属性,或者修改一个对象的现有属性,并返回此对象
+      // object: 要添加或者修改属性的目标对象;prop: 要定义或修改属性的名称;descript: 是一个对象,里面是我们上述的对象属性的特性;
+      Object.defineProperty(row, "rowIndex", {
+        //给每一行添加不可枚举属性rowIndex来标识当前行
+        value: rowIndex, // 设置age的值,不设置的话默认为undefined
+        writable: true, // 表示属性的值true可以修改,false不可以被修改
+        enumerable: false // 设置为false表示不能通过 for-in 循环返回
+        // configurable: false, // configurable 设置为 false,意味着这个属性不能从对象上删除
+      });
+    },
+    keyDown(event) {
+      let key = event.keyCode;
+      if (key == 17) this.CtrlDown = true;
+      if (key == 16 || key == 18) this.shiftOrAltDown = true;
+    },
+    keyUp(event) {
+      let key = event.keyCode;
+      if (key == 17) this.CtrlDown = false;
+      if (key == 16 || key == 18) this.shiftOrAltDown = false;
+    },
+    // 文章说明 https://www.jianshu.com/p/48f2c522d2a2
+    getTopAndBottom(row, bottom, top) {
+      let n = row.rowIndex,
+        mx = bottom.rowIndex,
+        mi = top.rowIndex;
+      if (n > mx) {
+        return {
+          top: mi,
+          bottom: n
+        };
+      } else if (n < mx && n > mi) {
+        return {
+          top: mi,
+          bottom: n
+        };
+      } else if (n < mi) {
+        return {
+          top: n,
+          bottom: mx
+        };
+      } else if (n == mi || n == mx) {
+        return {
+          top: mi,
+          bottom: mx
+        };
+      }
+    },
+    // 给选中行加上current-row这个class类,所以要使用row-class-name这个属性(其实给每一行添加rowIndex也可以用这个属性),
+    // 判断方式也是通过判断rowIndex对比
+    rowClassName({ row, rowIndex }) {
+      let rowName = "",
+        findRow = this.handleSelectionData.find(c => c.rowIndex === row.rowIndex);
+      if (findRow) {
+        rowName = "current-row "; // elementUI 默认高亮行的class类 不用再样式了^-^,也可通过css覆盖改变背景颜色
+      }
+      return rowName; //也可以再加上其他类名 如果有需求的话
+    }
+  },
+  mounted() {
+    // 按住ctrl实现多选 设置监听keydown事件,以及keyup事件,
+    addEventListener("keydown", this.keyDown, false);
+    addEventListener("keyup", this.keyUp, false);
+  },
+  beforeDestroy() {
+    //解绑
+    removeEventListener("keydown", this.keyDown);
+    removeEventListener("keyup", this.keyUp);
+  },
+  computed: {
+    //实时得到最上行和最下行
+    bottomSelectionRow() {
+      if (this.handleSelectionData.length == 0) return null;
+      return this.handleSelectionData.reduce((start, end) => {
+        return start.rowIndex > end.rowIndex ? start : end;
+      });
+    },
+    topSelectionRow() {
+      if (this.handleSelectionData.length == 0) return null;
+      return this.handleSelectionData.reduce((start, end) => {
+        return start.rowIndex < end.rowIndex ? start : end;
+      });
+    }
+  }
+};
+</script>
+
+<style scoped>
+::v-deep input::-webkit-outer-spin-button,
+::v-deep input::-webkit-inner-spin-button {
+  -webkit-appearance: none !important;
+}
+::v-deep input[type="number"] {
+  -moz-appearance: textfield !important;
+}
+::v-deep .el-table td {
+  padding: 0;
+}
+::v-deep .el-table .cell {
+  padding-left: 2px !important;
+  padding-right: 2px !important;
+}
+::v-deep .el-input-number .el-input__inner {
+  text-align: right;
+}
+</style>

+ 692 - 5
src/views/iosBasicData/ComputationCenter/settlementDetails.vue

@@ -466,6 +466,49 @@
               </template>
             </finstlbillsitems>
           </el-tab-pane>
+          <el-tab-pane label="凭证数据" name="3">
+            <div style="margin-bottom: 10px">
+              <el-button
+                size="small"
+                type="primary"
+                style="margin-right: 8px"
+                :loading="saveLoading"
+                @click="addEntryfun"
+                :disabled="editSave || generateStatus"
+                >添加分录
+              </el-button>
+              <el-button
+                size="small"
+                type="primary"
+                style="margin-right: 8px"
+                :loading="saveLoading"
+                @click="oneClickSave"
+                :disabled="editSave || generateStatus"
+                >一键保存
+              </el-button>
+              <el-button
+                size="small"
+                type="danger"
+                style="margin-right: 8px"
+                :loading="saveLoading"
+                @click="deleteEntryfun"
+                :disabled="editSave || generateStatus"
+                >删除分录
+              </el-button>
+            </div>
+            <fromtable-details
+              :assemblyForm="form"
+              :tableData="form.finStlBillsVoucherItemsList"
+              :handleSelectionData="handleSelectionData2"
+              :disabled="editSave || generateStatus"
+              @handleSelectionChange="handleSelectionChange2"
+              @addRowsfun="addRowsfun"
+              @deletefun="deletefun"
+              @auxiliaryAccountingfun="auxiliaryAccountingfun"
+              @showOffRecordsfun="showOffRecordsfun"
+            >
+            </fromtable-details>
+          </el-tab-pane>
         </el-tabs>
       </el-card>
     </div>
@@ -557,6 +600,256 @@
 
     <!--报表组件-->
     <reportContainer ref="reportContainer"></reportContainer>
+    <!--预收预付核销-->
+    <el-dialog
+      title="预收预付核销管理"
+      append-to-body
+      :visible.sync="offRecordsVisible"
+      class="el-dialogDeep"
+      width="80%"
+      :before-close="handleClose"
+    >
+      <div>
+        科目名称:
+        {{
+          subjectRow.accountCode +
+            " " +
+            subjectRow.accountFullName +
+            (subjectRow.isEmpl === 1 && subjectRow.emplName ? "/" + subjectRow.emplName : "") +
+            (subjectRow.isDept === 1 && subjectRow.deptName ? "/" + subjectRow.deptName : "") +
+            (subjectRow.isCorp === 1 && subjectRow.corpShortName ? "/" + subjectRow.corpShortName : "") +
+            (subjectRow.isItem === 1 ? "/" + subjectRow.itemClassify + "-" + (subjectRow.itemName ? subjectRow.itemName : "") : "")
+        }}
+        方向:{{ subjectRow.dc === "D" ? "借" : "贷" }}
+      </div>
+      <div>
+        借方金额: CNY {{ fixedAmt(subjectRow.amountDr, 16) }} {{ subjectRow.isForeign === 1 ? "USD " + fixedAmt(subjectRow.amountDrUsd, 16) : "" }}
+      </div>
+      <div>
+        贷方金额: CNY {{ fixedAmt(subjectRow.amountCr, 16) }} {{ subjectRow.isForeign === 1 ? "USD " + fixedAmt(subjectRow.amountCrUsd, 16) : "" }}
+      </div>
+      <div style="margin-top: 10px; margin-bottom: 10px">
+        <el-form :model="subjectRowOff" ref="subjectRowOff" label-width="70px" class="demo-ruleForm">
+          <el-row :gutter="40">
+            <el-col :span="12" v-if="subjectRowOff.isCorp">
+              <!--<div>客户核算:</div>-->
+              <el-form-item label="客户名称:" prop="corpCnName">
+                <search-query
+                  style="width: 100%"
+                  ref="searchQueryRef"
+                  :datalist="corpCnNameData"
+                  :selectValue="subjectRowOff.corpCnName"
+                  :filterable="true"
+                  :clearable="true"
+                  :remote="true"
+                  :buttonIf="true"
+                  placeholder="请选择客户名称"
+                  :forParameter="{ key: 'id', label: 'cnName', value: 'cnName' }"
+                  @corpFocus="getBcorpsListfun"
+                  @remoteMethod="getBcorpsListfun"
+                  @corpChange="corpChangeOff($event, 'corpCnName')"
+                  @eldialogConfirm="eldialogConfirmOff('bcorps')"
+                  @bottonSearchfun="bottonSearchfun('bcorps')"
+                >
+                  <bcorps ref="bcorps" :eldialog="true" @selectionChange="eldialogMultipleChoice($event, 'bcorps')"></bcorps>
+                </search-query>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12" v-if="subjectRowOff.isCorp">
+              <el-form-item label="" prop="">
+                <el-button type="primary" @click="regetOffVoucherItems">查询</el-button>
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </el-form>
+      </div>
+      <div style="margin-top: 10px">
+        <!--        show-summary-->
+        <!--        :summary-method="summaryMethodOff"-->
+        <el-table
+          ref="tableOffRecords"
+          :cell-style="{ padding: '0px', fontSize: '12px' }"
+          :header-cell-style="tableHeaderCellStyle"
+          :close-on-click-modal="false"
+          :data="offRecordsData"
+          :border="true"
+          style="width: 100%"
+          show-summary
+          :summary-method="summaryMethodOff"
+          @selection-change="handleOffRecordsSelectionChange"
+          :row-class-name="rowClassName"
+        >
+          <el-table-column fixed="left" type="selection" width="50"> </el-table-column>
+          <el-table-column type="index" width="40" style="text-align: center"> </el-table-column>
+          <el-table-column prop="voucherDate" label="凭证日期" width="120" style="padding: 0">
+            <template slot-scope="{ row }">
+              <span>{{ row.voucherDate }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column prop="descr" label="摘要" width="200" style="padding: 0">
+            <template slot-scope="{ row }">
+              <span>{{ row.descr }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column prop="accountCode" label="科目名称" width="240" style="padding: 0">
+            <template slot-scope="{ row }">
+              <span>
+                {{
+                  row.accountCode +
+                    " " +
+                    row.accountFullName +
+                    (row.isEmpl === 1 && row.emplName ? "/" + row.emplName : "") +
+                    (row.isDept === 1 && row.deptName ? "/" + row.deptName : "") +
+                    (row.isCorp === 1 && row.corpShortName ? "/" + row.corpShortName : "") +
+                    (row.isItem === 1 ? "/" + row.itemClassify + "-" + (row.itemName ? row.itemName : "") : "")
+                }}
+              </span>
+            </template>
+          </el-table-column>
+          <el-table-column prop="dc" label="借贷" width="40px" style="padding: 0">
+            <template slot-scope="{ row }">
+              <span>{{ row.dc === "C" ? "借" : "贷" }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column label="本币金额">
+            <el-table-column label="借方">
+              <el-table-column prop="amountDr" label="金额" width="100px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <span>{{ displayAmt(row.amountDr) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column prop="amountDrOffCurrent" label="本次可核销" width="120px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <el-input-number
+                    v-if="subjectRow.dc === 'C' && row.amountDrBlc !== '0.00'"
+                    style="width: 100%"
+                    v-model="row.amountDrOffCurrent"
+                    size="small"
+                    autocomplete="off"
+                    :disabled="form.voucherStatus == 1"
+                    placeholder="请输入借方"
+                    :precision="2"
+                    @change="offAmountBlur(row, 'D')"
+                    :controls="false"
+                  >
+                  </el-input-number>
+                  <span v-if="subjectRow.dc === 'D' || row.amountDr === '0.00'">{{ displayAmt(row.amountDrOff) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column prop="amountDrBlc" label="核销余额" width="100px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <span>{{ displayAmt(row.amountDrBlc) }}</span>
+                </template>
+              </el-table-column>
+            </el-table-column>
+            <el-table-column label="货方">
+              <el-table-column prop="amountCr" label="金额" width="100px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <span>{{ displayAmt(row.amountCr) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column prop="amountCrOffCurrent" label="本次可核销" width="120px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <el-input-number
+                    v-if="subjectRow.dc !== 'C' && row.amountCrBlc !== '0.00'"
+                    style="width: 100%"
+                    v-model="row.amountCrOffCurrent"
+                    size="small"
+                    autocomplete="off"
+                    :disabled="form.voucherStatus == 1"
+                    placeholder="请输入货方"
+                    :precision="2"
+                    @change="offAmountBlur(row, 'C')"
+                    :controls="false"
+                  >
+                  </el-input-number>
+                  <span v-if="subjectRow.dc === 'C' || row.amountCrBlc === '0.00'">{{ displayAmt(row.amountCrOff) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column prop="amountCrBlc" label="核销余额" width="100px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <span>{{ displayAmt(row.amountCrBlc) }}</span>
+                </template>
+              </el-table-column>
+            </el-table-column>
+          </el-table-column>
+          <el-table-column label="外币金额">
+            <el-table-column prop="curCode" label="币种" width="50px" align="center"> </el-table-column>
+            <el-table-column prop="exrate" label="汇率" width="80px" style="text-align: right">
+              <template slot-scope="{ row }">
+                <span>{{ row.exrate ? Number(row.exrate).toFixed(4) : "" }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column label="借方">
+              <el-table-column prop="amountDrUsd" label="金额" width="100px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <span>{{ displayAmt(row.amountDrUsd) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column prop="amountDrUsdOffCurrent" label="本次可核销" width="120px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <el-input-number
+                    v-if="subjectRow.dc === 'C' && row.amountDrUsdBlc !== '0.00'"
+                    style="width: 100%; text-align: right"
+                    v-model="row.amountDrUsdOffCurrent"
+                    size="small"
+                    autocomplete="off"
+                    :disabled="form.voucherStatus == 1 || row.curCode == 'CNY'"
+                    clearable
+                    placeholder="请输入借方"
+                    :precision="2"
+                    @change="offAmountUSDBlur(row, 'Dusd')"
+                    :controls="false"
+                  >
+                  </el-input-number>
+                  <span v-if="subjectRow.dc === 'D' || row.amountDrUsdBlc === '0.00'">{{ displayAmt(row.amountDrUsdOff) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column prop="amountDrUsdBlc" label="核销余额" width="100px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <span>{{ displayAmt(row.amountDrUsdBlc) }}</span>
+                </template>
+              </el-table-column>
+            </el-table-column>
+            <el-table-column label="货方">
+              <el-table-column prop="amountCrUsd" label="金额" width="100px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <span>{{ displayAmt(row.amountCrUsd) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column prop="amountCrUsdOffCurrent" label="金额" width="120px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <el-input-number
+                    v-if="subjectRow.dc !== 'C' && row.amountCrUsdBlc !== '0.00'"
+                    style="width: 100%"
+                    v-model="row.amountCrUsdOffCurrent"
+                    size="small"
+                    autocomplete="off"
+                    :disabled="form.voucherStatus == 1 || row.curCode == 'CNY'"
+                    clearable
+                    placeholder="请输入货方"
+                    :precision="2"
+                    @change="offAmountUSDBlur(row, 'Cusd')"
+                    :controls="false"
+                  >
+                  </el-input-number>
+                  <span v-if="subjectRow.dc === 'C' || row.amountCrUsdBlc === '0.00'">{{ displayAmt(row.amountCrUsdOff) }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column prop="amountCrUsdBlc" label="核销余额" width="100px" style="text-align: right">
+                <template slot-scope="{ row }">
+                  <span>{{ displayAmt(row.amountCrUsdBlc) }}</span>
+                </template>
+              </el-table-column>
+            </el-table-column>
+          </el-table-column>
+        </el-table>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="offRecordsVisible = false">取 消</el-button>
+        <el-button type="primary" @click="offRecordsDeterminefun">确 定</el-button>
+      </span>
+    </el-dialog>
   </div>
 </template>
 
@@ -573,7 +866,8 @@ import {
   finstlbillsRevokeSettlement,
   finstlbillsGetByDetail,
   finstlbillslistAccBillByCorp,
-  finstlbillsGenerateVoucher
+  finstlbillsGenerateVoucher,
+  voucherRemove
 } from "@/api/iosBasicData/finstlbills";
 import expand from "@/components/basic-container/expand.vue";
 import queryFinstlbillsitems from "@/views/iosBasicData/PaymentApplication/assembly/finstlbillsitems.vue";
@@ -586,6 +880,10 @@ import { generateFinStlBills } from "@/api/iosBasicData/fininvoices";
 import { dateFormat } from "@/util/date";
 import dicSelect from "@/components/dicSelect/main";
 import { isProcurement } from "@/api/basicData/configuration";
+import fromtableDetails from "./components/fromtableDetails.vue";
+import { getCurrentDate } from "@/util/date";
+import { accountsDetail } from "@/api/iosBasicData/accounts";
+import { getOffVoucherItems } from "@/api/iosBasicData/finvouchers";
 export default {
   components: {
     reportContainer,
@@ -595,7 +893,8 @@ export default {
     expand,
     finstlbillsitems,
     dicSelect,
-    queryFinstlbillsitems
+    queryFinstlbillsitems,
+    fromtableDetails
   },
   props: {
     // 编辑还是保存
@@ -610,6 +909,21 @@ export default {
   },
   data() {
     return {
+      handleSelectionData2: [], // 分录多选的数据
+      removedFinvouchersitems: [],
+      voucherTypeData: [], // 凭证字数据
+      voucherSourceData: [], // 业务类型
+      auxiliaryVisible: false, // 辅助核算弹窗
+      offRecordsVisible: false, // 预收预付核销弹窗
+      offRecordsData: [], // 预收预付核销数据
+      offRecordsSelectionData: [],
+      subjectRowOff: {}, // 核销科目弹窗的显示数据
+      subjectRow: {}, // 科目弹窗的显示数据
+      subjectAccount: {}, // 当前选择科目的数据
+      corpCnNameData: [], // 客户核算 下拉数据
+      deptData: [], // 部门核算 下拉数据
+      emplData: [], // 职员核算 下拉数据
+      itemData: [], // 项目核算 下拉数据
       generateStatus: false,
       amountSubSum: 0,
       amountDSubSum: 0,
@@ -674,7 +988,13 @@ export default {
       // 绑定的数据
       form: {
         dc: null,
-        billDate: dateFormat(new Date())
+        billDate: dateFormat(new Date()),
+        voucherSource: "MANUAL",
+        voucherSourceName: "手工凭证",
+        voucherType: "VOUNO-TRANS", // 凭证类型
+        voucherTypeName: "转账凭证",
+        voucherDate: getCurrentDate(),
+        finStlBillsVoucherItemsList: []
       },
       addData: [],
       handleSelectionData: [], // 表格选择的数据
@@ -750,7 +1070,7 @@ export default {
       this.voucher = res.data.data;
     });
     isProcurement({ param: "whether.open" }).then(res => {
-      res.data.data = '1'
+      res.data.data = "1";
       this.whetheropen = res.data.data;
     });
     isProcurement({ param: "whether.auditing" }).then(res => {
@@ -759,6 +1079,322 @@ export default {
     });
   },
   methods: {
+    corpChangeOff(value, name) {
+      let found = false;
+      // 客户名称
+      if (name == "corpCnName") {
+        for (let item of this.corpCnNameData) {
+          if (item.cnName == value) {
+            found = true;
+            this.$set(this.subjectRowOff, "corpEnName", item.enName);
+            this.$set(this.subjectRowOff, "corpCnName", item.cnName);
+            this.$set(this.subjectRowOff, "corpShortName", item.shortName);
+            this.$set(this.subjectRowOff, "corpId", item.id);
+          }
+        }
+        if (!found) {
+          this.$set(this.subjectRowOff, "corpEnName", "");
+          this.$set(this.subjectRowOff, "corpCnName", "");
+          this.$set(this.subjectRowOff, "corpShortName", "");
+          this.$set(this.subjectRowOff, "corpId", 0);
+        }
+      }
+      // 核算
+      else if (name == "deptName") {
+        for (let item of this.deptData) {
+          if (item.title == value) {
+            found = true;
+            this.$set(this.subjectRowOff, "deptName", item.title);
+            this.$set(this.subjectRowOff, "deptId", item.id);
+          }
+        }
+        if (!found) {
+          this.$set(this.subjectRowOff, "deptName", "");
+          this.$set(this.subjectRowOff, "deptId", 0);
+        }
+      }
+      // 职员
+      else if (name == "emplName") {
+        for (let item of this.emplData) {
+          if (item.name == value) {
+            found = true;
+            this.$set(this.subjectRowOff, "emplName", item.name);
+            this.$set(this.subjectRowOff, "emplId", item.id);
+          }
+        }
+        if (!found) {
+          this.$set(this.subjectRowOff, "emplName", "");
+          this.$set(this.subjectRowOff, "emplId", 0);
+        }
+      }
+      // 项目核算
+      else if (name == "itemName") {
+        for (let item of this.itemData) {
+          if (item.cnName == value) {
+            found = true;
+            this.$set(this.subjectRowOff, "itemName", item.cnName);
+            this.$set(this.subjectRowOff, "itemId", item.id);
+          }
+        }
+        if (!found) {
+          this.$set(this.subjectRowOff, "itemName", "");
+          this.$set(this.subjectRowOff, "itemId", 0);
+        }
+      } else if (name == "voucherType") {
+        this.$set(this.form, name, value);
+        for (let item of this.voucherTypeData) {
+          if (item.dictKey == value) {
+            found = true;
+            this.$set(this.form, "voucherTypeName", item.dictValue + "凭证");
+          }
+        }
+        if (!found) {
+          this.$set(this.subjectRowOff, "voucherTypeName", "");
+        }
+      } else if (name == "voucherSource") {
+        this.$set(this.form, name, value);
+      }
+    },
+    // 下拉多选弹窗的确认
+    eldialogConfirmOff(name) {
+      if (name == "bcorps") {
+        if (this.$refs.bcorps.isShow) {
+          console.log("列表确认");
+          this.$set(this.subjectRowOff, "corpCnName", this.$refs.bcorps.selectionList[0].cnName);
+          this.$set(this.subjectRowOff, "corpEnName", this.$refs.bcorps.selectionList[0].enName);
+          this.$set(this.subjectRowOff, "corpId", this.$refs.bcorps.selectionList[0].id);
+        } else {
+          console.log("详情确认");
+          this.$refs.bcorps.$refs.detail.submitForm();
+          this.$set(this.subjectRowOff, "corpCnName", this.$refs.bcorps.$refs.detail.formData.cnName);
+          this.$set(this.subjectRowOff, "corpEnName", this.$refs.bcorps.$refs.detail.formData.enName);
+          this.$set(this.subjectRowOff, "corpId", this.$refs.bcorps.$refs.detail.formData.id);
+        }
+      } else {
+        console.log("其他的组件");
+      }
+      this.$refs.searchQueryRef.corpVisible = false;
+    },
+    fixedAmt(amt, len) {
+      let N = Number(amt);
+      let S = isNaN(N) ? "0.00" : N.toFixed(2);
+      while (S.length < len) {
+        S = "_" + S;
+      }
+      return S;
+    },
+    displayAmt(amt, len) {
+      let N = Number(amt);
+      let S = isNaN(N) ? "" : N.toFixed(len ? len : 2);
+      let Z = 0;
+      return S === Z.toFixed(len ? len : 2) ? "" : S;
+    },
+    // 表头样式
+    tableHeaderCellStyle({ row, column, rowIndex, columnIndex }) {
+      return "padding:4px 0px;fontSize:12px;color:#000;background:#ecf5ff;text-align:center";
+    },
+    summaryMethodOff(param) {
+      const { columns, data } = param;
+      const sums = [];
+      columns.forEach((column, index) => {
+        if (index === 2) {
+          sums[index] = "合计";
+          return;
+        }
+        const values = data.map(item => Number(item[column.property]));
+        // 显示列的统计 金额
+        let arr = ["amountDrOffCurrent", "amountCrOffCurrent", "amountDrUsdOffCurrent", "amountCrUsdOffCurrent"];
+        // 判断是否有这个数据
+        if (arr.indexOf(column.property) != -1) {
+          if (!values.every(value => isNaN(value))) {
+            sums[index] = values.reduce((prev, curr) => {
+              const value = Number(curr);
+              if (!isNaN(value)) {
+                return prev + curr;
+              } else {
+                return prev;
+              }
+            }, 0);
+            sums[index] = this.displayAmt(sums[index]); // 把合计的参数保留两位小数
+            // sums[index] += " 元";
+          } else {
+            sums[index] = " ";
+          }
+        }
+      });
+      return sums;
+    },
+    rowClassName({ row, rowIndex }) {
+      let rowName = "",
+        findRow = this.handleSelectionData.find(c => c.rowIndex === row.rowIndex);
+      if (findRow) {
+        rowName = "current-row "; // elementUI 默认高亮行的class类 不用再样式了^-^,也可通过css覆盖改变背景颜色
+      }
+      return rowName; //也可以再加上其他类名 如果有需求的话
+    },
+    // 表格多选数据
+    handleOffRecordsSelectionChange(list) {
+      this.offRecordsSelectionData = list;
+    },
+    newGuid() {
+      let vd = "0123456789abcdefghijklmnopqrstuvwxyz".split("");
+      var i = vd,
+        o = [],
+        s = Math.random,
+        n;
+      (o[8] = o[13] = o[18] = o[23] = "-"), (o[14] = "4");
+      for (var r = 0; r < 36; r++) o[r] || ((n = 0 | (16 * s())), (o[r] = i[19 == r ? (3 & n) | 8 : 15 & n]));
+      return o.join("");
+    },
+    // 添加分录
+    addEntryfun() {
+      let obj = {
+        dynUID: this.newGuid().replace(/-/g, "")
+      };
+      console.log(obj);
+      if (this.form.finStlBillsVoucherItemsList.length > 0) {
+        obj.descr = this.form.finStlBillsVoucherItemsList[this.form.finStlBillsVoucherItemsList.length - 1].descr;
+      }
+      this.form.finStlBillsVoucherItemsList.push(obj);
+    },
+    forceNumber(n) {
+      try {
+        let N = parseFloat(n);
+        if (isNaN(N)) {
+          N = 0.0;
+        } else {
+          let S = N.toFixed(2);
+          N = Number(S);
+        }
+
+        return N;
+      } catch (e) {
+        return 0.0;
+      }
+    },
+    oneClickSave() {
+      if (this.form.finStlBillsVoucherItemsList.length < 2) {
+        return this.$message.warning("请填写至少凭证两笔分录后再保存!");
+      }
+      this.editCustomer();
+    },
+    // 行添加
+    addRowsfun(row, index) {
+      //第二个参数为0的时候,是可以添加参数的,1的时候是删除
+      let obj = {
+        dynUID: this.newGuid().replace(/-/g, "")
+      };
+      this.form.finStlBillsVoucherItemsList.splice(index, 0, obj);
+    },
+    // 行删除
+    deletefun(row, index) {
+      let offVouItems = Array.isArray(row.offVouItems) ? row.offVouItems : [];
+
+      if (row.id) {
+        this.$set(row, "changeMode", row.changeMode === "d" ? "u" : "d");
+        // this.finvouchersitemsRemovefun(row.id);
+        this.removedFinvouchersitems.push(row);
+        voucherRemove(row.id).then(res => {
+          this.form.finStlBillsVoucherItemsList.splice(index, 1);
+        });
+      } else {
+        this.form.finStlBillsVoucherItemsList.splice(index, 1);
+      }
+
+      offVouItems.forEach(item => {
+        let rowIdx = this.form.finStlBillsVoucherItemsList.indexOf(item);
+        if (rowIdx >= 0) {
+          if (item.id) {
+            this.$set(item, "changeMode", item.changeMode === "d" ? "u" : "d");
+            // this.finvouchersitemsRemovefun(row.id);
+            this.removedFinvouchersitems.push(item);
+            this.form.finStlBillsVoucherItemsList.splice(rowIdx, 1);
+          } else this.form.finStlBillsVoucherItemsList.splice(rowIdx, 1);
+        }
+      });
+    },
+    // 删除分录
+    deleteEntryfun() {
+      if (this.handleSelectionData2.length == 0) {
+        return this.$message.warning("请选择至少一条数据");
+      }
+      let offVouItems = [];
+      let multiList = this.handleSelectionData2;
+      let arr = this.form.finStlBillsVoucherItemsList;
+      // 获取有id 的数据
+      const itemsWithId = multiList.filter(item => item.id);
+      let arrIds = itemsWithId.map(item => item.id); // 获取id 数据
+      console.log(arrIds);
+      // 把选中的删除掉
+      multiList.forEach(item => {
+        offVouItems = offVouItems.concat(Array.isArray(item.offVouItems) ? item.offVouItems : []);
+
+        if (!item.hasOwnProperty("id")) {
+          for (let index in arr) {
+            if (JSON.stringify(item) == JSON.stringify(arr[index])) {
+              arr.splice(Number(index), 1);
+            }
+          }
+        }
+      });
+      // 有id 的处理
+      if (itemsWithId.length != 0) {
+        voucherRemove(arrIds.join(",")).then(res => {
+          arrIds.forEach(id => {
+            let i = this.form.finStlBillsVoucherItemsList.findIndex(item => item.id === id);
+            if (i >= 0) {
+              let row = this.form.finStlBillsVoucherItemsList[i];
+              this.$set(row, "changeMode", "d");
+              this.removedFinvouchersitems.push();
+              this.form.finStlBillsVoucherItemsList.splice(i, 1);
+            }
+          });
+          this.$message.success("删除成功");
+        });
+      }
+
+      offVouItems.forEach(item => {
+        let rowIdx = this.form.finStlBillsVoucherItemsList.indexOf(item);
+        if (rowIdx >= 0) {
+          if (item.id) {
+            this.$set(item, "changeMode", item.changeMode === "d" ? "u" : "d");
+            // this.finvouchersitemsRemovefun(row.id);
+            this.removedFinvouchersitems.push(item);
+            this.form.finStlBillsVoucherItemsList.splice(rowIdx, 1);
+          } else this.form.finStlBillsVoucherItemsList.splice(rowIdx, 1);
+        }
+      });
+    },
+    handleSelectionChange2(list) {
+      this.handleSelectionData2 = list;
+    },
+    // 科目编辑打开辅助核算弹窗
+    auxiliaryAccountingfun(row) {
+      // 获取状态
+      accountsDetail(row.accountId).then(res => {
+        this.subjectAccount = res.data.data;
+        this.subjectRow = row;
+        // 如果三个都没有勾选 直接不自动打开弹窗
+        if (res.data.data.isCorp || res.data.data.isDept || res.data.data.isEmpl || res.data.data.isItem) {
+          this.auxiliaryVisible = true;
+        }
+      });
+    },
+    // 辅助核算弹窗确认按钮
+    auxiliaryDeterminefun() {
+      this.auxiliaryVisible = false;
+    },
+    // 获取核销记录
+    showOffRecordsfun(row) {
+      // 获取状态
+      this.subjectRowOff = JSON.parse(JSON.stringify(row));
+      getOffVoucherItems(this.subjectRowOff).then(res => {
+        this.offRecordsSelectionData = [];
+        this.offRecordsData = Array.isArray(res.data.data) ? res.data.data : [];
+        this.subjectRow = row;
+        this.offRecordsVisible = true;
+      });
+    },
     lastPage() {
       if (this.pageIds.length) {
         const index = this.pageIds.indexOf(this.form.id);
@@ -1035,6 +1671,56 @@ export default {
             }
           }
         }
+        // 判断借方金额合计 是否等于 贷方金额合计
+        let msgs = [];
+        let amountDrSum = 0;
+        let amountCrSum = 0;
+        let index = 0;
+        for (let item of this.form.finStlBillsVoucherItemsList) {
+          // console.log(item);
+          index++;
+          let amtDr = this.forceNumber(item.amountDr);
+          let amtCr = this.forceNumber(item.amountCr);
+          amountDrSum += amtDr;
+          amountCrSum += amtCr;
+          let descr = item.descr ? item.descr.trim() : "";
+          if (!descr) {
+            msgs.push(`第 ${index} 行分录请填写摘要!`);
+          } else {
+            item.descr = descr;
+          }
+          if (!item.accountId) {
+            msgs.push(`第 ${index} 行分录缺少科目代码!`);
+          } else {
+            if (item.isCorp === 1 && !item.corpId) {
+              msgs.push(`第 ${index} 行分录科目 ${item.accountCode} ${item.accountFullName} 核算客户,请选择客户名称!`);
+            }
+            if (item.isDept === 1 && !item.deptId) {
+              msgs.push(`第 ${index} 行分录科目 ${item.accountCode} ${item.accountFullName} 核算部门,请选择部门名称!`);
+            }
+            if (item.isEmpl === 1 && !item.emplId) {
+              msgs.push(`第 ${index} 行分录科目 ${item.accountCode} ${item.accountFullName} 核算职员,请选择职员名称!`);
+            }
+            if (item.isItem === 1 && !item.itemId) {
+              msgs.push(`第 ${index} 行分录科目 ${item.accountCode} ${item.accountFullName} 核算项目,请选择项目名称!`);
+            }
+            if (amtDr.toFixed(2) === "0.00" && amtCr.toFixed(2) === "0.00") {
+              msgs.push(`第 ${index} 行分录科目 ${item.accountCode} ${item.accountFullName} 请填写金额!`);
+            }
+          }
+        }
+        if (amountDrSum !== amountCrSum) {
+          msgs.push(`凭证借贷金额不平衡!`);
+        }
+
+        if (msgs.length > 0) {
+          return this.$message({
+            dangerouslyUseHTMLString: true,
+            message: msgs.join("<br /><br />"),
+            type: "warning"
+          });
+        }
+        // this.form.finStlBillsVoucherItemsList = this.form.finStlBillsVoucherItemsList.concat(this.removedFinvouchersitems);
         this.saveLoading = true; // 打开按钮动画
         if (this.form.estimatedTime) {
           this.form.estimatedTime = this.form.estimatedTime + " 00:00:00";
@@ -1047,6 +1733,7 @@ export default {
         this.form.businessDateEnd = this.form.businessDateEnd ? this.form.businessDateEnd.slice(0, 10) + " 00:00:00" : null; // 财务开始日期
         this.form.billDate = this.form.billDate ? this.form.billDate.slice(0, 10) + " 00:00:00" : null;
         this.form.auditDateTo = this.form.auditDateTo ? this.form.auditDateTo.slice(0, 10) + " 00:00:00" : null;
+        this.form.voucherDate = this.form.voucherDate ? this.form.voucherDate.slice(0, 10) + " 00:00:00" : null;
         this.form.settlementType = this.settlementType;
         if (this.form.id) {
           if (type == "选定行") {
@@ -1702,7 +2389,7 @@ export default {
           item.accountBankNo = item.accountBank + " - " + item.accountNo;
           return item;
         });
-        if (this.bankData.length>0) {
+        if (this.bankData.length > 0) {
           this.$set(this.form, "bankId", res.data.data.records[0].id);
           this.$set(this.form, "bankAccountName", res.data.data.records[0].accountName);
           this.$set(this.form, "bankAccountBank", res.data.data.records[0].accountBank);

+ 4 - 0
src/views/iosBasicData/finvouchers/assembly/fromtableDetails.vue

@@ -628,6 +628,10 @@ export default {
 ::v-deep .el-table td {
   padding: 0;
 }
+::v-deep .el-table .cell{
+  padding-left: 2px !important;
+  padding-right: 2px !important;
+}
 ::v-deep .el-input-number .el-input__inner {
   text-align: right;
 }

+ 1 - 1
src/views/iosBasicData/finvouchers/finvouchersitems.vue

@@ -1029,7 +1029,7 @@ export default {
         let amtDr = this.forceNumber(item.amountDr);
         let amtCr = this.forceNumber(item.amountCr);
         amountDrSum += amtDr;
-        amountCrSum += amtDr;
+        amountCrSum += amtCr;
         let descr = item.descr ? item.descr.trim() : "";
         if (!descr) {
           msgs.push(`第 ${index} 行分录请填写摘要!`);