|
|
@@ -1,20 +1,149 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <ele-pro-table
|
|
|
- ref="table"
|
|
|
- :needPage="false"
|
|
|
- :columns="columns"
|
|
|
- :toolkit="[]"
|
|
|
- :datasource="tableForm.detailList"
|
|
|
- row-key="id"
|
|
|
- >
|
|
|
- </ele-pro-table>
|
|
|
+ <el-form ref="form" :model="tableForm">
|
|
|
+ <ele-pro-table
|
|
|
+ ref="table"
|
|
|
+ :needPage="false"
|
|
|
+ :columns="columns"
|
|
|
+ :datasource="tableForm.detailList"
|
|
|
+ row-key="id"
|
|
|
+ :selection.sync="selection"
|
|
|
+ class="time-form"
|
|
|
+ >
|
|
|
+ <template v-slot:toolbar>
|
|
|
+ <el-button type="primary" @click="handParent('', -1)">新增</el-button>
|
|
|
+ <el-button type="primary" @click="handGoods(-1)">选择商品</el-button>
|
|
|
+ <setAllValue :disabled="!selection.length" inputType="number" title="税率" valueKey="taxRate" @success="confirmBatchSet" />
|
|
|
+ <setAllValue :disabled="!selection.length" inputType="number" title="单价" valueKey="singlePrice" @success="confirmBatchSet" />
|
|
|
+ <setAllValue :disabled="!selection.length" inputType="number" title="折让比例" valueKey="discountRatio" @success="confirmBatchSet" />
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template v-slot:totalCount="scope">
|
|
|
+ <el-form-item
|
|
|
+ style="width: 100%;"
|
|
|
+ :prop="'detailList.' + scope.$index + '.totalCount'"
|
|
|
+ :rules="[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入数量',
|
|
|
+ trigger: 'blur'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value === undefined || value === null || value === '') {
|
|
|
+ callback('请输入数量');
|
|
|
+ } else if (parseFloat(value) <= 0) {
|
|
|
+ callback('数量必须大于0');
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ <span v-if="dialogType === 'view'">{{ scope.row.totalCount }}</span>
|
|
|
+ <el-input v-else v-model="scope.row.totalCount" type="number" @input="recalcDetailList(scope.row, scope.$index)"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 单价 -->
|
|
|
+ <template v-slot:singlePrice="scope">
|
|
|
+ <span v-if="dialogType === 'view'">{{ scope.row.singlePrice }}</span>
|
|
|
+ <el-input v-else v-model="scope.row.singlePrice" type="number" @input="recalcDetailList(scope.row, scope.$index)"></el-input>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 计价方式 -->
|
|
|
+ <template v-slot:pricingWay="scope">
|
|
|
+ <span v-if="dialogType === 'view'">{{ pricingWayLabel(scope.row.pricingWay) }}</span>
|
|
|
+ <el-select
|
|
|
+ v-else
|
|
|
+ v-model="scope.row.pricingWay"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="recalcDetailList(scope.row, scope.$index)"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in pricingWayList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 税率 -->
|
|
|
+ <template v-slot:taxRate="scope">
|
|
|
+ <span v-if="dialogType === 'view'">{{ scope.row.taxRate }}</span>
|
|
|
+ <el-input
|
|
|
+ v-else
|
|
|
+ v-model="scope.row.taxRate"
|
|
|
+ type="number"
|
|
|
+ @input="recalcDetailList(scope.row, scope.$index)"
|
|
|
+ ></el-input>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 折让比例 -->
|
|
|
+ <template v-slot:discountRatio="scope">
|
|
|
+ <span v-if="dialogType === 'view'">{{ scope.row.discountRatio }}</span>
|
|
|
+ <el-input
|
|
|
+ v-else
|
|
|
+ v-model="scope.row.discountRatio"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="100"
|
|
|
+ placeholder="请输入"
|
|
|
+ ></el-input>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 工艺路线 -->
|
|
|
+ <template v-slot:technologyRouteName="scope">
|
|
|
+ <span v-if="dialogType === 'view'">{{ scope.row.technologyRouteName }}</span>
|
|
|
+ <el-input
|
|
|
+ v-else
|
|
|
+ :value="scope.row.technologyRouteName"
|
|
|
+ placeholder="请选择"
|
|
|
+ readonly
|
|
|
+ @click.native="openVersion(scope.$index)"
|
|
|
+ ></el-input>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 操作:删除 -->
|
|
|
+ <template v-slot:action="scope">
|
|
|
+ <el-link
|
|
|
+ v-if="dialogType !== 'view'"
|
|
|
+ type="danger"
|
|
|
+ :underline="false"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ @click="removeRow(scope.$index)"
|
|
|
+ >删除</el-link>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ </ele-pro-table>
|
|
|
+ </el-form>
|
|
|
+ <product-list ref="productListRef" classType="1" :is-get-inventory-total="true" @changeParent="changeParent" :isSupplier="true"></product-list>
|
|
|
+ <commodityPriceListDialog ref="commodityPriceListDialogRef" @changeParent="changeParent"></commodityPriceListDialog>
|
|
|
+ <ProductionVersion ref="versionRefs" @changeProduct="changeProduct"></ProductionVersion>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+import setAllValue from '@/BIZComponents/setAllValue.vue'; //批量修改
|
|
|
+import productList from '@/BIZComponents/product-list.vue';
|
|
|
+import commodityPriceListDialog from './commodityPriceListDialog.vue';
|
|
|
+import ProductionVersion from '@/components/ProductionVersion2/index.vue';
|
|
|
+import { pricingWayList } from '@/enum/dict.js';
|
|
|
+const dayjs = require('dayjs');
|
|
|
+
|
|
|
+import {
|
|
|
+ changeCount,
|
|
|
+ getAllPrice,
|
|
|
+ getAllDiscountPrice,
|
|
|
+ formatPrice,
|
|
|
+ getAllQuantity
|
|
|
+} from '@/BIZComponents/setProduct.js';
|
|
|
export default {
|
|
|
name: 'tableInfo',
|
|
|
- components: {},
|
|
|
+ components: { setAllValue, productList, commodityPriceListDialog, ProductionVersion },
|
|
|
props: {
|
|
|
form: {
|
|
|
type: Object,
|
|
|
@@ -37,55 +166,106 @@
|
|
|
default: () => {
|
|
|
return {};
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ invoiceAmount: {
|
|
|
+ type: Number,
|
|
|
+ default: 0
|
|
|
+ },
|
|
|
+ contractBookType: {
|
|
|
+ //合同类型 1销售 2采购
|
|
|
+ type: [String, Number],
|
|
|
+ default: 1
|
|
|
+ },
|
|
|
+ //是否商品
|
|
|
+ isGoods: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
+ const defaultForm = {
|
|
|
+ key: null,
|
|
|
+ endTime: '',
|
|
|
+ isFirst: 0,
|
|
|
+ name: '',
|
|
|
+ startTime: '',
|
|
|
+ workHour: '',
|
|
|
+ guaranteePeriodUnitCode: '',
|
|
|
+ technicalDrawings: [],
|
|
|
+ arrivalWay: 1,
|
|
|
+ // 生产加工类型特有字段
|
|
|
+ thickNess: '',
|
|
|
+ squareNumber: '',
|
|
|
+ processingFeeBeforeTax: '',
|
|
|
+ packagingFeeNotTaxed: '',
|
|
|
+ transportationFeeWithoutTax: '',
|
|
|
+ extraTax: '',
|
|
|
+ quotationSubtotalTax: '',
|
|
|
+ // 新增未税小记字段
|
|
|
+ quotationSubtotalBeforeTax: '',
|
|
|
+ quoteWay: 1,
|
|
|
+ discountRatio: 100
|
|
|
+ };
|
|
|
return {
|
|
|
columns: [
|
|
|
{
|
|
|
width: 45,
|
|
|
- type: 'index',
|
|
|
- columnKey: 'index',
|
|
|
+ type: 'selection',
|
|
|
+ columnKey: 'selection',
|
|
|
align: 'center',
|
|
|
fixed: 'left'
|
|
|
},
|
|
|
-
|
|
|
{
|
|
|
- width: 100,
|
|
|
- prop: 'typeName',
|
|
|
- label: '类型',
|
|
|
- slot: 'typeName',
|
|
|
- align: 'center'
|
|
|
+ width: 45,
|
|
|
+ type: 'index',
|
|
|
+ columnKey: 'index',
|
|
|
+ align: 'center',
|
|
|
+ fixed: 'left'
|
|
|
},
|
|
|
// {
|
|
|
- // minWidth: 100,
|
|
|
- // prop: 'sourceCode',
|
|
|
- // label: '类型编码',
|
|
|
- // slot: 'sourceCode',
|
|
|
+ // width: 150,
|
|
|
+ // prop: 'key',
|
|
|
+ // label: '来源编码',
|
|
|
+ // align: 'center'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // width: 100,
|
|
|
+ // prop: 'key',
|
|
|
+ // label: '对账日期',
|
|
|
+ // align: 'center'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // width: 150,
|
|
|
+ // prop: 'sourceOrderNo',
|
|
|
+ // label: '销售订单编码',
|
|
|
// align: 'center'
|
|
|
// },
|
|
|
// {
|
|
|
// width: 100,
|
|
|
- // prop: 'productCategoryName',
|
|
|
- // label: '分类',
|
|
|
- // slot: 'productCategoryName',
|
|
|
- // align: "center"
|
|
|
+ // prop: 'key',
|
|
|
+ // label: '发货单编码',
|
|
|
+ // align: 'center'
|
|
|
// },
|
|
|
// {
|
|
|
// width: 100,
|
|
|
- // prop: 'productCode',
|
|
|
- // label: '编码',
|
|
|
- // slot: 'productCode',
|
|
|
- // align: "center"
|
|
|
+ // prop: 'key',
|
|
|
+ // label: '发货日期',
|
|
|
+ // align: 'center'
|
|
|
// },
|
|
|
{
|
|
|
- minWidth: 100,
|
|
|
+ width: 100,
|
|
|
+ prop: 'productCode',
|
|
|
+ label: '产品编码',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 150,
|
|
|
prop: 'productName',
|
|
|
- label: '名称',
|
|
|
+ label: '产品名称',
|
|
|
slot: 'productName',
|
|
|
align: 'center'
|
|
|
},
|
|
|
- {
|
|
|
+ {
|
|
|
minWidth: 100,
|
|
|
prop: 'modelType',
|
|
|
label: '型号',
|
|
|
@@ -100,75 +280,130 @@
|
|
|
slot: 'specification',
|
|
|
align: 'center'
|
|
|
},
|
|
|
- // {
|
|
|
- // width: 100,
|
|
|
- // prop: 'productBrand',
|
|
|
- // label: '牌号',
|
|
|
- // slot: 'productBrand',
|
|
|
- // align: "center"
|
|
|
- // },
|
|
|
-
|
|
|
+
|
|
|
+ {
|
|
|
+ minWidth: 100,
|
|
|
+ prop: 'batchNo',
|
|
|
+ label: '批次号',
|
|
|
+ slot: 'batchNo',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
{
|
|
|
- width: 80,
|
|
|
+ width: 100,
|
|
|
prop: 'totalCount',
|
|
|
label: '数量',
|
|
|
slot: 'totalCount',
|
|
|
+ align: 'center',
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ minWidth: 130,
|
|
|
+ prop: 'unit',
|
|
|
+ label: '计量单位',
|
|
|
+ slot: 'unit',
|
|
|
align: 'center'
|
|
|
},
|
|
|
-
|
|
|
{
|
|
|
- width: 100,
|
|
|
- prop: 'measuringUnit',
|
|
|
- label: '单位',
|
|
|
- slot: 'measuringUnit',
|
|
|
+ minWidth: 130,
|
|
|
+ prop: 'pricingWay',
|
|
|
+ label: '计价方式',
|
|
|
+ slot: 'pricingWay',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 130,
|
|
|
+ prop: 'technologyRouteName',
|
|
|
+ label: '工艺路线',
|
|
|
+ slot: 'technologyRouteName',
|
|
|
align: 'center'
|
|
|
},
|
|
|
- // {
|
|
|
- // width: 150,
|
|
|
- // prop: 'pricingWay',
|
|
|
- // label: '计价方式',
|
|
|
- // formatter: (row, column) => {
|
|
|
- // return row.pricingWay == 1
|
|
|
- // ? '按数量计费'
|
|
|
- // : row.pricingWay == 2
|
|
|
- // ? '按重量计费'
|
|
|
- // : '';
|
|
|
- // },
|
|
|
- // align: 'center'
|
|
|
-
|
|
|
- // },
|
|
|
{
|
|
|
- minWidth: 80,
|
|
|
+ minWidth: 130,
|
|
|
prop: 'singlePrice',
|
|
|
- label: '单价(¥)',
|
|
|
+ label: '单价',
|
|
|
slot: 'singlePrice',
|
|
|
align: 'center'
|
|
|
},
|
|
|
+ {
|
|
|
+ minWidth: 130,
|
|
|
+ prop: 'taxRate',
|
|
|
+ label: '税率',
|
|
|
+ align: 'center',
|
|
|
+ slot: 'taxRate',
|
|
|
+ // formatter: (_row, _column, cellValue) => {
|
|
|
+ // return _row.taxRate
|
|
|
+ // ? _row.taxRate+'%'
|
|
|
+ // : '';
|
|
|
+ // },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 100,
|
|
|
+ prop: 'noTaxSinglePrice',
|
|
|
+ label: '不含税单价',
|
|
|
+ slot: 'noTaxSinglePrice',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 130,
|
|
|
+ prop: 'weight',
|
|
|
+ label: '重量',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ minWidth: 130,
|
|
|
+ prop: 'weightUnit',
|
|
|
+ label: '重量单位',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
// {
|
|
|
- // width: 80,
|
|
|
- // prop: 'singleWeight',
|
|
|
- // label: '单量',
|
|
|
+ // width: 150,
|
|
|
+ // prop: 'quoteWay',
|
|
|
+ // label: '报价方式',
|
|
|
+ // formatter: (row, column) => {
|
|
|
+ // return row.quoteWay == 1
|
|
|
+ // ? '常规价'
|
|
|
+ // : row.quoteWay == 2
|
|
|
+ // ? '内部价'
|
|
|
+ // : row.quoteWay == 3 ? '议价' : '';
|
|
|
+ // },
|
|
|
// align: 'center'
|
|
|
+
|
|
|
// },
|
|
|
|
|
|
{
|
|
|
- minWidth: 80,
|
|
|
+ width: 100,
|
|
|
prop: 'totalPrice',
|
|
|
- label: '金额(¥)',
|
|
|
- slot: 'totalPrice',
|
|
|
+ label: '合计',
|
|
|
align: 'center'
|
|
|
},
|
|
|
{
|
|
|
- minWidth: 80,
|
|
|
- prop: 'taxRate',
|
|
|
- label: '税率',
|
|
|
- formatter: (_row, _column, cellValue) => {
|
|
|
- return _row.taxRate
|
|
|
- ? _row.taxRate+'%'
|
|
|
- : '';
|
|
|
- },
|
|
|
+ width: 100,
|
|
|
+ prop: 'discountRatio',
|
|
|
+ label: '折让比例',
|
|
|
+ slot: 'discountRatio',
|
|
|
align: 'center'
|
|
|
- }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 100,
|
|
|
+ prop: 'discountSinglePrice',
|
|
|
+ label: '折让单价',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 100,
|
|
|
+ prop: 'discountAmount',
|
|
|
+ label: '折让合计',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: 100,
|
|
|
+ columnKey: 'action',
|
|
|
+ label: '操作',
|
|
|
+ slot: 'action',
|
|
|
+ align: 'center',
|
|
|
+ fixed: 'right'
|
|
|
+ },
|
|
|
+
|
|
|
// {
|
|
|
// width: 100,
|
|
|
// prop: 'sourceType',
|
|
|
@@ -184,6 +419,18 @@
|
|
|
detailList: [],
|
|
|
link: []
|
|
|
},
|
|
|
+ defaultForm,
|
|
|
+ // 计数单位字段映射(本页数量字段为 totalCount)
|
|
|
+ countObj: {
|
|
|
+ countKey: 'totalCount',
|
|
|
+ unitKey: 'measuringUnit',
|
|
|
+ unitIdKey: 'measuringUnitId'
|
|
|
+ },
|
|
|
+ allPrice: 0,
|
|
|
+ allQuantity: 0,
|
|
|
+ allDiscountPrice: 0,
|
|
|
+ selection: [],
|
|
|
+ pricingWayList,
|
|
|
typeList: [
|
|
|
{
|
|
|
label: '销售发货',
|
|
|
@@ -201,57 +448,279 @@
|
|
|
label: '采购退货',
|
|
|
value: '21'
|
|
|
}
|
|
|
- ]
|
|
|
+ ],
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
this.tableForm = this.form;
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ form(val) {
|
|
|
+ this.tableForm = this.form;
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
- //获取选择的对账单数据
|
|
|
- async getAccountData(params) {
|
|
|
- if (params.children.orderType == 6) {
|
|
|
- this.tableForm.detailList = params.children.detailList;
|
|
|
- this.tableForm.detailList.forEach((item, index) => {
|
|
|
- item.sourceCode = params.children.orderNo;
|
|
|
- item.sourceId = params.children.id;
|
|
|
- item.sourceType = params.type == 1 ? 2 : 3;
|
|
|
- item.type = 12;
|
|
|
- item.singlePrice = item.discountSinglePrice;
|
|
|
- item.totalPrice = item.discountTotalPrice;
|
|
|
- item.typeName = '销售赔付';
|
|
|
+ guaranteePeriodUnit(code) {
|
|
|
+ return code == 3
|
|
|
+ ? 'day'
|
|
|
+ : code == 4
|
|
|
+ ? 'month'
|
|
|
+ : code == 5
|
|
|
+ ? 'year'
|
|
|
+ : 'second';
|
|
|
+ },
|
|
|
+ // 改变数量(适配本页面:数据源为 tableForm.detailList,数量字段为 totalCount)
|
|
|
+ // 参考 inventoryTable.changeCount 逻辑,独立实现,不依赖原方法
|
|
|
+ recalcDetailList(row, index, weightType) {
|
|
|
+ if (!row) {
|
|
|
+ // 全量重算
|
|
|
+ this.tableForm.detailList = this.tableForm.detailList.map((item) => {
|
|
|
+ const updated = changeCount(item, this.countObj, false);
|
|
|
+ return this.syncDiscountAmount(updated);
|
|
|
});
|
|
|
} else {
|
|
|
- this.tableForm.detailList = [];
|
|
|
- params.children.subList.forEach((item, index) => {
|
|
|
- item.detailList.forEach((i, n) => {
|
|
|
- i.sourceCode = item.statementSubOrderCode;
|
|
|
- i.sourceId = params.children.id;
|
|
|
- i.sourceType = params.type == 1 ? 2 : 3;
|
|
|
- i.type = item.subType;
|
|
|
- console.log(item.subType);
|
|
|
- i.typeName = this.typeList.find(
|
|
|
- (i) => i.value == item.subType
|
|
|
- ).label;
|
|
|
- // i.singlePrice = item.discountSinglePrice
|
|
|
- i.totalPrice = i.discountTotalPrice;
|
|
|
- });
|
|
|
- this.tableForm.detailList.push(...item.detailList);
|
|
|
- });
|
|
|
- this.$refs.table.reload();
|
|
|
+ // 单行重算
|
|
|
+ const updatedRow = changeCount(row, this.countObj, false, weightType);
|
|
|
+ this.$set(this.tableForm.detailList, index, this.syncDiscountAmount(updatedRow));
|
|
|
}
|
|
|
- this.$emit('setPrice', params.children.amountTotalPrice);
|
|
|
- let row = {
|
|
|
- id: params.id,
|
|
|
- name: params.statementNo,
|
|
|
- code: params.statementNo,
|
|
|
- linkType: params.type == 1 ? 190 : 290,
|
|
|
- linkTypeName: params.type == 1 ? '销售对账单' : '采购对账单'
|
|
|
- };
|
|
|
- this.setSelectData(row);
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.getNotaxSinglePrice();
|
|
|
+ this.calcAllTotal();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 同步折让合计:changeCount 输出 discountTotalPrice,表格列用 discountAmount
|
|
|
+ syncDiscountAmount(row) {
|
|
|
+ this.$set(row, 'discountAmount', row.discountTotalPrice ?? '');
|
|
|
+ return row;
|
|
|
+ },
|
|
|
+ // 删除行并重新计算
|
|
|
+ removeRow(index) {
|
|
|
+ if (index < 0 || index >= this.tableForm.detailList.length) return;
|
|
|
+ this.tableForm.detailList.splice(index, 1);
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.calcAllTotal();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 计算不含税单价
|
|
|
+ getNotaxSinglePrice() {
|
|
|
+ this.tableForm.detailList.forEach((item, index) => {
|
|
|
+ if (item.singlePrice && item.taxRate) {
|
|
|
+ this.$set(
|
|
|
+ this.tableForm.detailList[index],
|
|
|
+ 'noTaxSinglePrice',
|
|
|
+ +((+item.singlePrice / (1 + +item.taxRate / 100)).toFixed(2))
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.$set(this.tableForm.detailList[index], 'noTaxSinglePrice', '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 汇总金额与数量
|
|
|
+ calcAllTotal() {
|
|
|
+ this.allPrice = getAllPrice(this.tableForm.detailList) || 0;
|
|
|
+ this.allQuantity = getAllQuantity(this.tableForm.detailList, this.countObj) || 0;
|
|
|
+ this.allDiscountPrice =
|
|
|
+ getAllDiscountPrice(this.tableForm.detailList) || 0;
|
|
|
+ // 通知父组件金额变化
|
|
|
+ this.$emit('setPrice', this.allPrice);
|
|
|
+ },
|
|
|
+ setDay(addDay, dateType = 'day', item) {
|
|
|
+ let tiem =
|
|
|
+ this.contractBookType == 1
|
|
|
+ ? item.produceDeliveryDeadline
|
|
|
+ : item.customerExpectDeliveryDeadline;
|
|
|
+ return dayjs(tiem || new Date())
|
|
|
+ .add(addDay, dateType)
|
|
|
+ .format('YYYY-MM-DD');
|
|
|
+ },
|
|
|
+ //选择产品回调
|
|
|
+ changeParent(obj, idx) {
|
|
|
+ console.log(obj, idx);
|
|
|
+ obj.forEach((item, index) => {
|
|
|
+ let i = idx == -1 ? index : idx;
|
|
|
+ let row = JSON.parse(JSON.stringify(this.defaultForm));
|
|
|
+ console.log(row);
|
|
|
+ row.key = this.tableForm.detailList.length + 1;
|
|
|
+ let parasm = idx == -1 ? row : this.tableForm.detailList[i];
|
|
|
+
|
|
|
+ this.$set(parasm, 'productId', item.id);
|
|
|
+ this.$set(parasm, 'categoryName', item.name);
|
|
|
+ this.$set(parasm, 'productCategoryId', item.categoryLevelId);
|
|
|
+ this.$set(parasm, 'productBrand', item.brandNum);
|
|
|
+ this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
|
|
|
+ this.$set(parasm, 'productCode', item.code);
|
|
|
+ this.$set(parasm, 'productName', item.name);
|
|
|
+ this.$set(parasm, 'modelType', item.modelType);
|
|
|
+ this.$set(parasm, 'availableCountBase', item.availableCountBase);
|
|
|
+ this.$set(parasm, 'measuringUnit', item.measuringUnit);
|
|
|
+ this.$set(parasm, 'specification', item.specification);
|
|
|
+ this.$set(parasm, 'weightUnit', item.weightUnit);
|
|
|
+ this.$set(parasm, 'singleWeight', item.netWeight);
|
|
|
+ this.$set(parasm, 'pricingWay', 1);
|
|
|
+ this.$set(parasm, 'goodsLevel', item.goodsLevel);
|
|
|
+ this.$set(parasm, 'guaranteePeriod', item.warrantyPeriod);
|
|
|
+ this.$set(
|
|
|
+ parasm,
|
|
|
+ 'customerExpectDeliveryDeadline',
|
|
|
+ dayjs(new Date()).format('YYYY-MM-DD')
|
|
|
+ );
|
|
|
+ // console.log('colorKey~~', item.colorKey);
|
|
|
+ this.$set(parasm, 'modelKey', item.modelKey?.split(',')?.[0] || '');
|
|
|
+ this.$set(parasm, 'colorKey', item.colorKey?.split(',')?.[0] || '');
|
|
|
+ this.$set(parasm, 'technologyRouteName', item.technologyRouteName || '');
|
|
|
+ this.$set(parasm, 'technologyRouteId', item.technologyRouteId || '');
|
|
|
+
|
|
|
+ this.$set(
|
|
|
+ parasm,
|
|
|
+ 'taxRate',
|
|
|
+ parasm.taxRate
|
|
|
+ );
|
|
|
+
|
|
|
+ // this.$set(
|
|
|
+ // parasm,
|
|
|
+ // 'guaranteePeriodUnitCode',
|
|
|
+ // item.warrantyPeriodUnit ? item.warrantyPeriodUnit + '' : ''
|
|
|
+ // );
|
|
|
+ // if (item.warrantyPeriod && item.warrantyPeriodUnit) {
|
|
|
+ // this.$set(
|
|
|
+ // parasm,
|
|
|
+ // 'guaranteePeriodDeadline',
|
|
|
+ // this.setDay(
|
|
|
+ // item.warrantyPeriod,
|
|
|
+ // this.guaranteePeriodUnit(item.warrantyPeriodUnit),
|
|
|
+ // {}
|
|
|
+ // )
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+
|
|
|
+ this.$set(
|
|
|
+ parasm,
|
|
|
+ 'packageDispositionList',
|
|
|
+ item.packageDispositionList
|
|
|
+ );
|
|
|
+ if (item.packageDispositionList?.length) {
|
|
|
+ this.$set(
|
|
|
+ parasm,
|
|
|
+ this.countObj.unitIdKey,
|
|
|
+ item.packageDispositionList[0].id
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ parasm,
|
|
|
+ this.countObj.unitKey,
|
|
|
+ item.packageDispositionList[0].conversionUnit
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$set(parasm, 'arrivalWay', item.arrivalWay || 1);
|
|
|
+
|
|
|
+ this.$set(parasm, 'imgCode', item.imgCode);
|
|
|
+ this.$set(parasm, 'produceType', item.componentAttribute);
|
|
|
+
|
|
|
+ if (this.isGoods && item.goodsId) {
|
|
|
+ this.$set(parasm, 'goodsId', item.goodsId);
|
|
|
+ this.$set(parasm, 'goodsPriceId', item.goodsPriceId);
|
|
|
+ this.$set(parasm, 'goodsPriceType', item.goodsPriceType);
|
|
|
+ this.$set(parasm, 'singlePrice', item.singlePrice);
|
|
|
+ this.$set(parasm, 'notaxSinglePrice', item.notaxSinglePrice);
|
|
|
+ this.$set(parasm, 'taxRate', item.taxRate);
|
|
|
+ this.$set(parasm, 'discountSinglePrice', item.singlePrice);
|
|
|
+ this.$set(parasm, 'totalCount', '');
|
|
|
+ this.$set(parasm, 'discountRatio', item.discountRatio);
|
|
|
+ this.$set(parasm, 'quoteWay', item.quoteWay || 1);
|
|
|
+ } else {
|
|
|
+ this.$set(parasm, 'singlePrice', parasm.singlePrice || 0);
|
|
|
+ this.$set(parasm, 'discountRatio', parasm.discountRatio || 100);
|
|
|
+ this.$set(parasm, 'quoteWay', parasm.quoteWay || 1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.$set(
|
|
|
+ parasm,
|
|
|
+ 'entrustedEnterpriseIdList',
|
|
|
+ item.entrustedEnterpriseIdList
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ parasm,
|
|
|
+ 'entrustedEnterpriseId',
|
|
|
+ item.entrustedEnterpriseId
|
|
|
+ );
|
|
|
+
|
|
|
+ this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
|
|
|
+ this.$set(
|
|
|
+ parasm,
|
|
|
+ 'packingSpecification',
|
|
|
+ item.extField.packingSpecification
|
|
|
+ );
|
|
|
+ this.$set(parasm, 'customerMark', this.customerMark);
|
|
|
+ if (item.purchaseOrigins?.length > 0) {
|
|
|
+ item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
|
|
|
+ }
|
|
|
+ this.$set(parasm, 'provenance', item.purchaseOrigins || []);
|
|
|
+
|
|
|
+ if (idx == -1) {
|
|
|
+ this.tableForm.detailList.push(row);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log('changeParent~~~', this.tableForm.detailList);
|
|
|
+ this.recalcDetailList();
|
|
|
+ },
|
|
|
+ //选择产品
|
|
|
+ handParent(row, index) {
|
|
|
+ let item = {
|
|
|
+ id: row?.productCode
|
|
|
+ };
|
|
|
+ if (row?.goodsId) {
|
|
|
+ this.handGoods(index);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$refs.productListRef.open(item, index);
|
|
|
+
|
|
|
+ },
|
|
|
+ handGoods(index) {
|
|
|
+ this.$refs.commodityPriceListDialogRef.open(index);
|
|
|
+ },
|
|
|
+ confirmBatchSet({ key, value }) {
|
|
|
+ if (!this.selection.length) {
|
|
|
+ this.$message.warning('请先勾选需要批量设置的行');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 批量设置选中行字段,并重算金额(合并回原对象,保持勾选引用不失效)
|
|
|
+ this.selection.forEach((item) => {
|
|
|
+ this.$set(item, key, value);
|
|
|
+ const updated = changeCount(item, this.countObj, false);
|
|
|
+ Object.keys(updated).forEach((k) => {
|
|
|
+ this.$set(item, k, updated[k]);
|
|
|
+ });
|
|
|
+ // 同步折让合计字段
|
|
|
+ this.$set(item, 'discountAmount', item.discountTotalPrice ?? '');
|
|
|
+ });
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.getNotaxSinglePrice();
|
|
|
+ this.calcAllTotal();
|
|
|
+ });
|
|
|
},
|
|
|
setValue(data) {
|
|
|
- this.tableForm.detailList = data;
|
|
|
+ console.log('data~~~', data);
|
|
|
+ // 将 productMap(对象,key 为订单号,值为明细数组)转换为扁平行数组
|
|
|
+ this.tableForm.detailList = this.convertProductMapToArray(data);
|
|
|
+ },
|
|
|
+ // productMap -> 扁平行数组(表格展示用),key 固定为 99
|
|
|
+ convertProductMapToArray(data) {
|
|
|
+ const productMap = data?.productMap || {};
|
|
|
+ const result = [];
|
|
|
+ Object.keys(productMap).forEach((key) => {
|
|
|
+ const details = productMap[key] || [];
|
|
|
+ details.forEach((detail) => {
|
|
|
+ result.push({
|
|
|
+ key: 'UNKNOWN_ORDER', // 固定 key 99,提交时用于还原分组
|
|
|
+ ...detail
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return result;
|
|
|
},
|
|
|
clearTable() {
|
|
|
this.tableForm = {
|
|
|
@@ -259,24 +728,68 @@
|
|
|
link: []
|
|
|
};
|
|
|
},
|
|
|
+ // 当数量变化时更新金额
|
|
|
+ updateTotalPrice(row) {
|
|
|
+ if (row.totalCount && row.singlePrice) {
|
|
|
+ row.totalPrice = (parseFloat(row.totalCount) * parseFloat(row.singlePrice)).toFixed(2);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 计价方式 label
|
|
|
+ pricingWayLabel(value) {
|
|
|
+ const item = this.pricingWayList.find((i) => i.id == value);
|
|
|
+ return item ? item.name : '';
|
|
|
+ },
|
|
|
+ // 打开工艺路线选择弹窗
|
|
|
+ openVersion(index) {
|
|
|
+ this.$refs.versionRefs.open(index);
|
|
|
+ },
|
|
|
+ // 工艺路线选择回调
|
|
|
+ changeProduct(data, index) {
|
|
|
+ if (data && this.tableForm.detailList[index]) {
|
|
|
+ this.$set(this.tableForm.detailList[index], 'technologyRouteName', data.name);
|
|
|
+ this.$set(this.tableForm.detailList[index], 'technologyRouteId', data.id);
|
|
|
+ this.$set(this.tableForm.detailList[index], 'technologyRouteVersion', data.version);
|
|
|
+ }
|
|
|
+ },
|
|
|
getTableValidate() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- if (this.tableForm.detailList.length == 0)
|
|
|
+ if (
|
|
|
+ this.tableForm.detailList.length == 0 &&
|
|
|
+ ![4, 5].includes(this.form.sourceType)
|
|
|
+ )
|
|
|
return this.$message.warning('请选择关联信息');
|
|
|
resolve(this.tableForm);
|
|
|
});
|
|
|
},
|
|
|
- setSelectData(val) {
|
|
|
- this.tableForm.link = [{}];
|
|
|
- this.$set(this.tableForm.link[0], 'linkId', val.id);
|
|
|
- this.$set(this.tableForm.link[0], 'linkName', val.name);
|
|
|
- this.$set(this.tableForm.link[0], 'linkCode', val.code);
|
|
|
- this.$set(this.tableForm.link[0], 'linkType', val.linkType);
|
|
|
- this.$set(this.tableForm.link[0], 'linkTypeName', val.linkTypeName);
|
|
|
+ validateForm(callback) {
|
|
|
+ //开始表单校验
|
|
|
+ this.$refs.form.validate((valid, obj) => {
|
|
|
+ if (obj) {
|
|
|
+ let messages = Object.keys(obj).map((key) => obj[key][0]);
|
|
|
+ if (messages.length > 0) {
|
|
|
+ this.$message.warning(messages[0].message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ callback(valid);
|
|
|
+ });
|
|
|
},
|
|
|
- getTableData() {}
|
|
|
+
|
|
|
+ // 扁平行数组 -> productMap(提交格式),key 固定为 99
|
|
|
+ getTableData() {
|
|
|
+ const data = JSON.parse(JSON.stringify(this.tableForm.detailList));
|
|
|
+ const productMap = { UNKNOWN_ORDER: [] };
|
|
|
+ data.forEach((item) => {
|
|
|
+ const { key, ...detail } = item;
|
|
|
+ productMap['UNKNOWN_ORDER'].push(detail);
|
|
|
+ });
|
|
|
+ return productMap;
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style scoped lang="scss"></style>
|
|
|
+<style scoped lang="scss">
|
|
|
+.time-form .el-form-item {
|
|
|
+ margin-bottom: 0 !important;
|
|
|
+}
|
|
|
+</style>
|