|
|
@@ -0,0 +1,545 @@
|
|
|
+<template>
|
|
|
+ <el-form ref="form" :model="form" :rules="rules">
|
|
|
+ <ele-pro-table
|
|
|
+ ref="table"
|
|
|
+ :needPage="false"
|
|
|
+ :columns="columns"
|
|
|
+ :datasource="form.datasource"
|
|
|
+ @columns-change="handleColumnChange"
|
|
|
+ :cache-key="cacheKeyUrl"
|
|
|
+ class="time-form"
|
|
|
+ :maxHeight="250"
|
|
|
+ >
|
|
|
+ <template v-slot:priceDifference="scope">
|
|
|
+ <el-form-item
|
|
|
+ style="margin-bottom: 20px"
|
|
|
+ :prop="'datasource.' + scope.$index + '.priceDifference'"
|
|
|
+ >
|
|
|
+ <!-- @input="handleSinglePriceDiffChange(scope.row, scope.$index)"
|
|
|
+ @blur="handleSinglePriceDiffChange(scope.row, scope.$index)" -->
|
|
|
+ <el-input
|
|
|
+ v-model="scope.row.priceDifference"
|
|
|
+ placeholder="请输入"
|
|
|
+ type="number"
|
|
|
+ disabled
|
|
|
+ @input="changeDiffPrice(scope.row, scope.$index)"
|
|
|
+ >
|
|
|
+ <!-- <template slot="append">元</template> -->
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ <template v-slot:headerPriceDifference="{ column }">
|
|
|
+ <span class="is-required">{{ column.label }}</span>
|
|
|
+ </template>
|
|
|
+ <!-- 操作列 -->
|
|
|
+ <template v-slot:action="{ $index }">
|
|
|
+ <el-popconfirm
|
|
|
+ v-if="type != '10'"
|
|
|
+ class="ele-action"
|
|
|
+ title="确定要删除吗?"
|
|
|
+ @confirm="remove($index)"
|
|
|
+ >
|
|
|
+ <template v-slot:reference>
|
|
|
+ <el-link type="danger" :underline="false" icon="el-icon-delete">
|
|
|
+ 删除
|
|
|
+ </el-link>
|
|
|
+ </template>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
+ </ele-pro-table>
|
|
|
+ </el-form>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import dictMixins from '@/mixins/dictMixins';
|
|
|
+ import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
+
|
|
|
+ export default {
|
|
|
+ mixins: [dictMixins, tabMixins],
|
|
|
+ props: {
|
|
|
+ sendId: String,
|
|
|
+ pricingWay: {
|
|
|
+ default: 1,
|
|
|
+ type: [Number, String]
|
|
|
+ },
|
|
|
+ returnSourceType: [Number, String],
|
|
|
+ entrustedCode: [Number, String],
|
|
|
+ sendNo: [Number, String],
|
|
|
+ returnType: {
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ type: {
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ countObj: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {
|
|
|
+ return {
|
|
|
+ countKey: 'quantity',
|
|
|
+ unitKey: 'saleUnit',
|
|
|
+ unitIdKey: 'saleUnitId'
|
|
|
+ };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+ components: { },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ cacheKeyUrl: 'eos-saleManage-saleOrder-adjustmentNote-inventoryTable',
|
|
|
+ payAmount: '',
|
|
|
+ form: {
|
|
|
+ datasource: [],
|
|
|
+ discountTotalPrice: 0
|
|
|
+ },
|
|
|
+ allPrice: 0,
|
|
|
+ rules: {
|
|
|
+ 'priceDifference': [
|
|
|
+ { required: true, message: '请输入', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ width: 45,
|
|
|
+ type: 'index',
|
|
|
+ columnKey: 'index',
|
|
|
+ align: 'center',
|
|
|
+ fixed: 'left'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 160,
|
|
|
+ prop: 'productCode',
|
|
|
+ label: '编码',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 120,
|
|
|
+ prop: 'productName',
|
|
|
+ label: '名称',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 120,
|
|
|
+ prop: 'specification',
|
|
|
+ label: '规格',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 120,
|
|
|
+ prop: 'modelType',
|
|
|
+ label: '型号',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 150,
|
|
|
+ prop: 'quantity',
|
|
|
+ label: '数量',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 100,
|
|
|
+ prop: 'adjustPrice',
|
|
|
+ label: '单价',
|
|
|
+ slot: 'adjustPrice',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 180,
|
|
|
+ prop: 'priceDifference',
|
|
|
+ label: '单价差异',
|
|
|
+ slot: 'priceDifference',
|
|
|
+ align: 'center',
|
|
|
+ headerSlot: 'headerPriceDifference'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 130,
|
|
|
+ prop: 'taxRate',
|
|
|
+ label: '税率',
|
|
|
+ formatter: (row, column) => {
|
|
|
+ return row.taxRate ? row.taxRate + '%' : '';
|
|
|
+ },
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 130,
|
|
|
+ prop: 'unTaxPrice',
|
|
|
+ label: '不含税单价',
|
|
|
+ slot: 'unTaxPrice',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 130,
|
|
|
+ prop: 'adjustDiscountPrice',
|
|
|
+ label: '折让单价',
|
|
|
+ slot: 'adjustDiscountPrice',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 120,
|
|
|
+ prop: 'adjustAmount',
|
|
|
+ slot: 'adjustAmount',
|
|
|
+ label: '合计',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 120,
|
|
|
+ prop: 'adjustDiscountAmount',
|
|
|
+ slot: 'adjustDiscountAmount',
|
|
|
+ label: '折让合计',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // columnKey: 'action',
|
|
|
+ // label: '操作',
|
|
|
+ // width: 120,
|
|
|
+ // align: 'center',
|
|
|
+ // resizable: false,
|
|
|
+ // slot: 'action',
|
|
|
+ // fixed: 'right',
|
|
|
+ // showOverflowTooltip: true
|
|
|
+ // }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ totalAmount() {
|
|
|
+ let num = 0;
|
|
|
+ this.form.datasource.forEach((item, index) => {
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'adjustAmount',
|
|
|
+ item.adjustPrice * item.quantity || 0
|
|
|
+ );
|
|
|
+ num += this.form.datasource[index].adjustAmount;
|
|
|
+ });
|
|
|
+ return parseFloat(num).toFixed(2);
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // changeSinglePriceDiff(row, index) {
|
|
|
+ // if (row.priceDifference && row.singlePrice) {
|
|
|
+ // this.$set(
|
|
|
+ // this.form.datasource[index],
|
|
|
+ // 'adjustAmount',
|
|
|
+ // row.priceDifference * row.quantity || 0
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ //改变数量
|
|
|
+ changeDiffPrice(row, index) {
|
|
|
+ if (!row) {
|
|
|
+ this.form.datasource.forEach((item, index) => {
|
|
|
+ this.$set(
|
|
|
+ this.form,
|
|
|
+ 'datasource[' + index + ']',
|
|
|
+ this.changeCount(item)
|
|
|
+ );
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('row~~~', row);
|
|
|
+ // 改变单价
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'adjustPrice',
|
|
|
+ row.priceDifference ? row.price + Number(row.priceDifference) : row.price
|
|
|
+ );
|
|
|
+ // 改变相关数据
|
|
|
+ this.$set(
|
|
|
+ this.form,
|
|
|
+ 'datasource[' + index + ']',
|
|
|
+ this.changeCount(row)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getNotaxSinglePrice();
|
|
|
+ this.changeAll();
|
|
|
+ this.$forceUpdate();
|
|
|
+ },
|
|
|
+
|
|
|
+ //改变数量
|
|
|
+ changeCount(row, countObj) {
|
|
|
+
|
|
|
+ // let total = row['quantity'] || 0;
|
|
|
+ let data = row;
|
|
|
+ // if (row.packageDispositionList) {
|
|
|
+ // let endIndex = row.packageDispositionList.findIndex(
|
|
|
+ // (ite) => row[countObj.unitIdKey] == ite.id
|
|
|
+ // );
|
|
|
+ // for (; 0 < endIndex; endIndex--) {
|
|
|
+ // total = Vue.prototype.$math.format(
|
|
|
+ // row.packageDispositionList[endIndex].packageCell * total,
|
|
|
+ // 14
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // data['totalCount'] = total;
|
|
|
+ data['adjustDiscountPrice'] = data.adjustPrice;
|
|
|
+
|
|
|
+
|
|
|
+ if (row['quantity'] && row.adjustPrice) {
|
|
|
+ data['adjustAmount'] = row['quantity'] * row.adjustPrice;
|
|
|
+ data['adjustDiscountAmount'] = data.adjustAmount;
|
|
|
+ } else {
|
|
|
+ data['adjustAmount'] = 0;
|
|
|
+ data['adjustDiscountAmount'] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return data;
|
|
|
+
|
|
|
+ },
|
|
|
+ // 计算合计
|
|
|
+ getAllPrice(arr) {
|
|
|
+ let sum = 0;
|
|
|
+ arr.forEach((item) => {
|
|
|
+ if (item.adjustAmount) {
|
|
|
+ sum += Number(item.adjustAmount);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return isNaN(sum) ? 0 : sum.toFixed(2);
|
|
|
+ },
|
|
|
+ // 计算总差异金额
|
|
|
+ getDiffPriceTotal(arr) {
|
|
|
+ let sum = 0;
|
|
|
+ arr.forEach((item) => {
|
|
|
+ if (item.priceDifference) {
|
|
|
+ sum += (Number(item.priceDifference)*Number(item.quantity));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return isNaN(sum) ? 0 : sum.toFixed(2);
|
|
|
+ },
|
|
|
+
|
|
|
+ changeAll() {
|
|
|
+ this.allPrice = this.getAllPrice(this.form.datasource) || 0;
|
|
|
+ this.diffPriceTotal = this.getDiffPriceTotal(this.form.datasource) || 0;
|
|
|
+ // if (this.isDiscountTotalPrice) {
|
|
|
+ this.form.discountTotalPrice = this.allPrice;
|
|
|
+ // this.$emit('setDiscountTotalPrice', this.allPrice);
|
|
|
+ // }
|
|
|
+ this.$emit('setCountAmount', this.allPrice, this.diffPriceTotal);
|
|
|
+ },
|
|
|
+ //设置优惠后总金额修改产品单价
|
|
|
+ discountInputByOrder(val) {
|
|
|
+ this.form.discountTotalPrice = val;
|
|
|
+
|
|
|
+ this.form.datasource.forEach((item, index) => {
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'adjustDiscountPrice',
|
|
|
+ this.getDiscountSinglePrice(item)
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'adjustDiscountAmount',
|
|
|
+ this.getDiscountTotalPrice(item)
|
|
|
+ );
|
|
|
+ });
|
|
|
+ this.$emit('setDiscountTotalPrice', val);
|
|
|
+
|
|
|
+ this.$forceUpdate();
|
|
|
+ this.$refs.table.reRenderTable();
|
|
|
+ },
|
|
|
+ // 处理单价差异变化,更新单价
|
|
|
+ handleSinglePriceDiffChange(row, index) {
|
|
|
+ // 确保原单价和单价差异都有值
|
|
|
+ const originalPrice = Number(row.price) || 0;
|
|
|
+ const priceDiff = Number(row.priceDifference) || 0;
|
|
|
+
|
|
|
+ // 计算新单价 = 原单价 + 单价差异
|
|
|
+ const newPrice = originalPrice + priceDiff;
|
|
|
+
|
|
|
+ // 使用$set更新单价字段
|
|
|
+ this.$set(this.form.datasource[index], 'adjustPrice', newPrice);
|
|
|
+
|
|
|
+ // 同时更新总价
|
|
|
+ if (row.quantity) {
|
|
|
+ this.$set(this.form.datasource[index], 'adjustAmount', row.quantity * newPrice);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$emit('changePrice', {
|
|
|
+ total: this.totalAmount,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //计算不含税单价
|
|
|
+ getNotaxSinglePrice() {
|
|
|
+ this.form.datasource.forEach((item, index) => {
|
|
|
+ if (item.adjustPrice && item.taxRate) {
|
|
|
+ this.$set(
|
|
|
+ this.form.datasource[index],
|
|
|
+ 'unTaxPrice',
|
|
|
+ parseFloat(
|
|
|
+ (item.adjustPrice / (1 + item.taxRate / 100)).toFixed(2)
|
|
|
+ )
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.$set(this.form.datasource[index], 'unTaxPrice', '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //获取折让单价
|
|
|
+ getDiscountSinglePrice(row) {
|
|
|
+ console.log('row~~~', this.allPrice);
|
|
|
+ let num =
|
|
|
+ (Number(this.form.discountTotalPrice) / Number(this.allPrice)) *
|
|
|
+ Number(row.adjustPrice);
|
|
|
+ return isNaN(num) ? '' : num;
|
|
|
+ },
|
|
|
+
|
|
|
+ //获取折让合计
|
|
|
+ getDiscountTotalPrice(row) {
|
|
|
+ let num = 0;
|
|
|
+ num = Number(row.adjustDiscountPrice) * Number(row.quantity);
|
|
|
+ return isNaN(num) ? '' : num.toFixed(2);
|
|
|
+ },
|
|
|
+ getTotalCount(row) {
|
|
|
+ let num = 0;
|
|
|
+ this.form.datasource
|
|
|
+ .filter((item) => item.warehouseId == row.warehouseId)
|
|
|
+ .forEach((item) => {
|
|
|
+ num += Number(item.totalCount);
|
|
|
+ });
|
|
|
+
|
|
|
+ return num;
|
|
|
+ },
|
|
|
+ // 返回列表数据
|
|
|
+ getTableValue() {
|
|
|
+ // let is = false;
|
|
|
+ // this.form.datasource.forEach((item) => {
|
|
|
+ // if (item.pricingWay == 2 && !item.adjustAmount) {
|
|
|
+ // is = true;
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // if (is) {
|
|
|
+ // this.$message.error('合计金额不能为空');
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ let comitDatasource = this.form.datasource;
|
|
|
+ if (comitDatasource.length === 0) return { productList: [] };
|
|
|
+ comitDatasource.forEach((v) => {
|
|
|
+ // v.totalCount = Number(v.totalCount);
|
|
|
+ // v.technicalDrawings = Array.isArray(v.technicalDrawings)
|
|
|
+ // ? v.technicalDrawings
|
|
|
+ // : [];
|
|
|
+ });
|
|
|
+ return { productList: comitDatasource, payAmount: this.totalAmount };
|
|
|
+ },
|
|
|
+ getPrice() {
|
|
|
+ return [this.allPrice];
|
|
|
+ },
|
|
|
+
|
|
|
+ //修改回显
|
|
|
+ putTableValue(data) {
|
|
|
+ if (data) {
|
|
|
+ // 创建数据的深拷贝,避免引用关系导致两边数据互相影响
|
|
|
+ const copyData = JSON.parse(JSON.stringify(data));
|
|
|
+
|
|
|
+ copyData.forEach((v) => {
|
|
|
+ v.sendTotalCount = v.packingQuantity || 0;
|
|
|
+ v.sendProductId = v.sendProductId || v.categoryId || v.productId;
|
|
|
+ // 初始化单价差异字段,如果未定义则设为0
|
|
|
+ if (v.adjustPrice !== undefined && v.priceDifference === undefined) {
|
|
|
+ v.priceDifference = '';
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // this.oldSendTotalWeightList = copyData.map((item) => {
|
|
|
+ // return {
|
|
|
+ // productCode: item.productCode,
|
|
|
+ // oldSendTotalWeight: item.sendTotalWeight,
|
|
|
+ // oldReceiveTotalWeight: item.receiveTotalWeight
|
|
|
+ // };
|
|
|
+ // });
|
|
|
+
|
|
|
+ this.form.datasource = copyData;
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ remove(index) {
|
|
|
+ this.form.datasource.splice(index, 1);
|
|
|
+ this.setSort();
|
|
|
+
|
|
|
+ },
|
|
|
+ // 清空表格
|
|
|
+ restTable() {
|
|
|
+ this.form.datasource = [];
|
|
|
+ },
|
|
|
+ // 重新排序
|
|
|
+ setSort() {
|
|
|
+ this.form.datasource.forEach((n, index) => {
|
|
|
+ n.key = index + 1;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ validateForm(callback) {
|
|
|
+ //开始表单校验
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ callback(valid);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .headbox {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .amount {
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: bold;
|
|
|
+ padding-right: 30px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .time-form .el-form-item {
|
|
|
+ margin-bottom: 0 !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep .period {
|
|
|
+ display: flex;
|
|
|
+
|
|
|
+ .borderleftnone {
|
|
|
+ .el-input--medium .el-input__inner {
|
|
|
+ border-top-right-radius: 0;
|
|
|
+ border-bottom-right-radius: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .borderrightnone {
|
|
|
+ .el-input--medium .el-input__inner {
|
|
|
+ border-top-left-radius: 0;
|
|
|
+ border-bottom-left-radius: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep .time-form tbody > tr:hover > td {
|
|
|
+ background-color: transparent !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep .time-form .el-table tr {
|
|
|
+ background-color: #ffffff;
|
|
|
+ }
|
|
|
+
|
|
|
+ .pricebox {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-start;
|
|
|
+ align-items: center;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+</style>
|