| | |
| | | <i class="el-icon-circle-plus-outline" title="选择"></i> |
| | | </div> |
| | | <div class="common-select-btn" @click="clearupClient(scope.row)"> |
| | | <i class="el-icon-edit-outline" title="清除"></i> |
| | | <i class="el-icon-remove-outline" title="清除"></i> |
| | | </div> |
| | | </div> |
| | | </el-form-item> |
| | |
| | | <div v-if="!detailEnter" style="margin: 10px"> |
| | | <el-button size="small" type="primary" @click="add">新增</el-button> |
| | | <el-button size="small" type="primary" @click="empty">清空</el-button> |
| | | |
| | | <el-button size="small" v-if="recalculateShow" type="primary" @click="recalculate" :disabled="isRecalculate ? false : true" |
| | | >重算</el-button |
| | | > |
| | | </div> |
| | | <!-- 产品名称 --> |
| | | <SelectCommonDialog |
| | |
| | | total: false, |
| | | refundable: false, |
| | | sumProp: [], |
| | | titleProp:["#", "产品名称"], |
| | | mergeNumber: 1 |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | recalculateShow:{ |
| | | type:[Boolean], |
| | | defalut:true, |
| | | }, |
| | | |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | handleSelectionChange(val) { |
| | | this.$emit("getSelectArray", val) |
| | | }, |
| | | // 行合并 |
| | | arraySpanMethod() { |
| | | if (this.showSummary.show) { |
| | | this.$nextTick(() => { |
| | | if (this.$refs.table) { |
| | | var current = this.$refs.table.querySelector(".el-table__footer-wrapper").querySelector(".el-table__footer") |
| | | var cell = current.rows[0].cells |
| | | for (let i = 0; i < this.showSummary.mergeNumber; i++) { |
| | | cell[i].style.display = "none" |
| | | } |
| | | cell[this.showSummary.mergeNumber].classList.remove("is-left") |
| | | cell[this.showSummary.mergeNumber].colSpan = this.showSummary.mergeNumber.toString() |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | // 合计 |
| | | getSummaries(param) { |
| | | const { columns, data } = param |
| | | const sums = [] |
| | | columns.forEach((column, index) => { |
| | | // // 更改行名称 |
| | | if (index === this.showSummary.mergeNumber) { |
| | | sums[index] = "小计:" |
| | | return |
| | | } |
| | | const title = this.showSummary.titleProp |
| | | // 去除某些不需要计算的数据 |
| | | if (title.includes(column.label)) { |
| | | sums[index] = "" |
| | | return |
| | | } |
| | | // 把当前表格数据中同个分类的数据收集起来 |
| | | const values = data.map((item) => Number(item[column.property])) |
| | | // 过滤掉 |
| | | if (!values.every((value) => Number.isNaN(value))) { |
| | | sums[index] = ` ${values.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!Number.isNaN(value)) { |
| | | const num = prev + curr |
| | | return Number(num.toFixed(2)) |
| | | } else { |
| | | return Number(prev.toFixed(2)) |
| | | } |
| | | }, 0)}` |
| | | } else { |
| | | sums[index] = "" |
| | | } |
| | | if (column.property === "total") { |
| | | this.total = sums[index] |
| | | } |
| | | }) |
| | | return sums |
| | | }, |
| | | |
| | | // 数字换行为金额显示格式 |
| | | number_format(number, decimals, dec_point, thousands_sep) { |
| | | decimals = 2 //这里默认设置保留两位小数,也可以注释这句采用传入的参数 |