|
|
@@ -1,13 +1,740 @@
|
|
|
+<!-- @desc:以销定采 @auth:姜宁 @time:2024/07/24 15:15 -->
|
|
|
<template>
|
|
|
+ <div class="main-div" style="position: relative;">
|
|
|
+ <!--按钮区-->
|
|
|
+ <BaseIndexButtonGroup ref="BaseIndexButtonGroup1" id="BaseIndexButtonGroup1">
|
|
|
+ <template #left>
|
|
|
+ <BaseIndexButton ref="chooseSalesForPurchase" name="chooseSalesForPurchase"
|
|
|
+ @click="chooseSalesForPurchase"></BaseIndexButton>
|
|
|
+ </template>
|
|
|
+ </BaseIndexButtonGroup>
|
|
|
|
|
|
+ <DkCollapse @on-change="changeCollapse" ref="collapse">
|
|
|
+ <DkPanel prop="essentialInformation">
|
|
|
+ <!-- 单据信息 -->
|
|
|
+ <DkForm slot="content" ref="formInline" v-model="formData"
|
|
|
+ style="width:100%" :label-max-words="5">
|
|
|
+ <!--来源单号-->
|
|
|
+ <DkFormItem prop="fromNo" :label="$t('fromNo')">
|
|
|
+ <InputPop ref="fromNo" v-model="formData.fromNos" :readonly="true"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--采购单号-->
|
|
|
+<!-- <DkFormItem prop="purNo" :label="$t('purNo')">-->
|
|
|
+<!-- <InputPop ref="purNo" v-model="formData.purNo" :readonly="true"/>-->
|
|
|
+<!-- </DkFormItem>-->
|
|
|
+ <!--供应商-->
|
|
|
+ <DkFormItem prop="supId" :label="$t('supplierName')" :required="true">
|
|
|
+ <SelectMagnifier v-model="formData.supId" :display-text="formData.supplierName"
|
|
|
+ :type="this.$config.MagnifierType.supplier"
|
|
|
+ :multiple="false"
|
|
|
+ :otherCondition="{supplierType:this.$config.kindCode.supplierPur}"
|
|
|
+ @ok="supplierOk"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--收货时间-->
|
|
|
+ <DkFormItem :label="$t('DeliveryDate')"
|
|
|
+ prop="pickupDate" :required="true" :data-type="$config.dataType.date">
|
|
|
+ <DatePickerPop v-model="formData.pickupDate"
|
|
|
+ :placeholder="$t('inputWords',{'search-name':$t('DeliveryDate')})"
|
|
|
+ type="date" :short-cut-flag="true"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--收货仓库-->
|
|
|
+ <DkFormItem prop="whId" :label="$t('wareHouse')" :required="true">
|
|
|
+ <SelectPop v-model="formData.whId" ref="whId"
|
|
|
+ :options="warehouseList"
|
|
|
+ :multiple="false"
|
|
|
+ labelKey="whName" valueKey="whId">
|
|
|
+ </SelectPop>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--收货人-->
|
|
|
+ <DkFormItem prop="contactName" :label="$t('contactName')">
|
|
|
+ <InputPop ref="contactName" :readonly="true" v-model="formData.contactName"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--收货电话-->
|
|
|
+ <DkFormItem prop="contactPhone" :label="$t('contactPhone')">
|
|
|
+ <InputPop :telephone="true" ref="contactPhone" :readonly="true" v-model="formData.contactPhone"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--备注-->
|
|
|
+ <DkFormItem prop="remarks">
|
|
|
+ <InputPop ref="remarks" v-model="formData.remarks"
|
|
|
+ maxlength=500 textareaFlag/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--开单并入库办理标识-->
|
|
|
+ <DkFormItem prop="inboundProcessingFlag" >
|
|
|
+ <dkSwitch ref="inboundProcessingFlag" v-model="formData.inboundProcessingFlag"/>
|
|
|
+ </DkFormItem>
|
|
|
+ </DkForm>
|
|
|
+ </DkPanel>
|
|
|
+ <!--商品信息-->
|
|
|
+ <DkPanel prop="goodsInformation">
|
|
|
+ <div id="search-cond-div-goods-info" ref="search-cond-div-goods-info" slot="content">
|
|
|
+ <EditTable slot="left"
|
|
|
+ ref="detailTable"
|
|
|
+ majorField="itemId"
|
|
|
+ :data="purchaseItemList"
|
|
|
+ :columns="goodsColumns"
|
|
|
+ :height="400"
|
|
|
+ :freeze="false"
|
|
|
+ :show-footer="true"
|
|
|
+ :add-flag="this.chooseFlag"
|
|
|
+ controlId="skuId"
|
|
|
+ @on-choose="getTotals"
|
|
|
+ @changeValue="getTotals"
|
|
|
+ @changeNonStandard="changeNonStandard"
|
|
|
+ ></EditTable>
|
|
|
+ <div>
|
|
|
+ <DkForm ref="goodsFootFormData" v-model="goodsFootFormData" :labelMaxWords="5" name="dk-form"
|
|
|
+ class="read-only-form">
|
|
|
+ <!--合计数量-->
|
|
|
+ <DkFormItem prop="sumQuantity">
|
|
|
+ <InputNumberPop ref="sumQuantity" v-model="goodsFootFormData.sumQuantity" :clearable="false"
|
|
|
+ :digits="2" :readonly="true"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--货物金额-->
|
|
|
+ <DkFormItem prop="sumAmount" class="amount">
|
|
|
+ <InputNumberPop ref="sumAmount" v-model="goodsFootFormData.sumAmount" :clearable="false"
|
|
|
+ :digits="2" :readonly="true"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--标价总额-->
|
|
|
+ <DkFormItem prop="sumStandard" class="amount">
|
|
|
+ <InputNumberPop ref="sumStandard" v-model="goodsFootFormData.sumStandard" :digits="2"
|
|
|
+ :readonly="true"/>
|
|
|
+ </DkFormItem>
|
|
|
+ </DkForm>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </DkPanel>
|
|
|
+ <!--附件-->
|
|
|
+ <DkPanel prop="files">
|
|
|
+ <div id="search-cond-div-files-info" ref="search-cond-div-files-info"
|
|
|
+ slot="content">
|
|
|
+ <DkPicWall v-model="formData.annexPaths"
|
|
|
+ :table="$config.tables.purchase" :accept="$config.uploadFileConfig.acceptPicType"></DkPicWall>
|
|
|
+ </div>
|
|
|
+ </DkPanel>
|
|
|
+ </DkCollapse>
|
|
|
+
|
|
|
+ <!-- 下部分按钮区域-->
|
|
|
+ <DkSaveButton ref="saveButton" :loading="loading" @save="save" @close="close"></DkSaveButton>
|
|
|
+
|
|
|
+ <!--以销定采-->
|
|
|
+ <DkModal
|
|
|
+ :loading="loading"
|
|
|
+ v-model="purchaseBasedOnSalesFlag"
|
|
|
+ :title="$t('chooseSalesForPurchase')"
|
|
|
+ width="1000px"
|
|
|
+ @modalOk="purchaseBasedOnSalesOk"
|
|
|
+ @modalCancel="clearPurchaseBasedOnSales"
|
|
|
+ >
|
|
|
+ <card :padding=0 style="margin-top: 1px;padding: 0">
|
|
|
+ <!--按钮区-->
|
|
|
+ <BaseIndexButtonGroup ref="BaseIndexButtonGroup" id="BaseIndexButtonGroup">
|
|
|
+ <template #left>
|
|
|
+ <BaseIndexButton ref="search" name="search"
|
|
|
+ @click="chooseSalesForPurchase(true)"></BaseIndexButton>
|
|
|
+ <BaseIndexButton ref="clear" name="clear"
|
|
|
+ @click="clearPurchaseBasedOnSales(true)"></BaseIndexButton>
|
|
|
+ </template>
|
|
|
+ </BaseIndexButtonGroup>
|
|
|
+ <!-- 查询条件-->
|
|
|
+ <DkForm ref="purchaseBasedOnSalesFormData" v-model="purchaseBasedOnSalesFormData"
|
|
|
+ name="purchase-based-on-sales-form"
|
|
|
+ class="form-content-class" style="margin-top: 5px">
|
|
|
+ <!--客户名称-->
|
|
|
+ <DkFormItem prop="cusName" :label="$t('cusName')">
|
|
|
+ <InputPop ref="cusName" v-model="purchaseBasedOnSalesFormData.customerName"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--客户电话-->
|
|
|
+ <DkFormItem prop="cusPhone" :label="$t('cusPhone')">
|
|
|
+ <InputPop ref="cusPhone" v-model="purchaseBasedOnSalesFormData.customerPhone"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--商品型号-->
|
|
|
+ <DkFormItem prop="skuModel" :label="$t('skuModel')">
|
|
|
+ <InputPop ref="skuModel" v-model="purchaseBasedOnSalesFormData.skuModel"/>
|
|
|
+ </DkFormItem>
|
|
|
+ <!--商品名称-->
|
|
|
+ <DkFormItem prop="skuName" :label="$t('skuName')">
|
|
|
+ <InputPop ref="skuName" v-model="purchaseBasedOnSalesFormData.skuName"/>
|
|
|
+ </DkFormItem>
|
|
|
+ </DkForm>
|
|
|
+ <DkTable primaryKey="itemId"
|
|
|
+ ref="table-purchase-based-on-sales-select"
|
|
|
+ :id="'table-'+$options.name"
|
|
|
+ name="table"
|
|
|
+ :data="purchaseBasedOnSalesTableData"
|
|
|
+ :height="purchaseBasedOnSalesHeight"
|
|
|
+ :lazy="false"
|
|
|
+ :selectFlag="false"
|
|
|
+ :operateFlag="false"
|
|
|
+ :link-click-checked="true">
|
|
|
+ <DkTableColumn v-for="(item,index) in purchaseBasedOnSalesColumns" :key="index" :field="item.field"
|
|
|
+ :title="item.title"
|
|
|
+ :width="item.width"
|
|
|
+ :filter="false"
|
|
|
+ :resize-flag="index === purchaseBasedOnSalesColumns.length - 1"></DkTableColumn>
|
|
|
+ </DkTable>
|
|
|
+ </card>
|
|
|
+ </DkModal>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+
|
|
|
+import {formMixin} from '@/mixins/form'
|
|
|
+
|
|
|
export default {
|
|
|
- name: "index"
|
|
|
-}
|
|
|
-</script>
|
|
|
+ components: {},
|
|
|
+ mixins: [formMixin],
|
|
|
+ data() {
|
|
|
+ let self = this
|
|
|
+ return {
|
|
|
+ //小数位数
|
|
|
+ decimalPlaces:0,
|
|
|
+ chooseFlag: false ,//商品信息新增
|
|
|
+ procureList: [],//每次以销定采选择后存放数据
|
|
|
+ //以销定采
|
|
|
+ purchaseBasedOnSalesFlag: false,
|
|
|
+ purchaseBasedOnSalesTableData: [],
|
|
|
+ purchaseBasedOnSalesHeight: 400,
|
|
|
+ purchaseBasedOnSalesColumns: [
|
|
|
+ {field: 'skuModel'},//商品型号
|
|
|
+ {field: 'skuName'},//商品名称
|
|
|
+ {field: 'skuCode'},//商品编码
|
|
|
+ {
|
|
|
+ field: 'transferableQuantity',
|
|
|
+ type: 'number',
|
|
|
+ digits: 0,
|
|
|
+ sum: true
|
|
|
+ },//可转采购数量
|
|
|
+ {field: 'brandName'},//商品品牌
|
|
|
+ {field: 'nonStdCode'},//非标号
|
|
|
+ {field: 'orderNo', width: '200px'},
|
|
|
+ {field: 'makingTime'},//订单日期
|
|
|
+ {field: 'orderStatusName'},//单据状态
|
|
|
+ {field: 'cusName'},//客户名称
|
|
|
+ {field: 'cusPhone'},//客户电话
|
|
|
+ {field: 'addressFull'},//客户地址
|
|
|
+ {field: 'orgName'},//业务部门
|
|
|
+ {field: 'staffName'},//业务员
|
|
|
+ // {field: 'warehouseName'},//仓库
|
|
|
+ // {field: 'skuWeight', type: 'number', digits: 2, sum: true},//重量
|
|
|
+ // {field: 'skuVolume', type: 'number', digits: 2, sum: true},//体积
|
|
|
+ // {field: 'remarks'},//备注
|
|
|
+ ],
|
|
|
+ orderId: null,
|
|
|
+ //连接业务接口
|
|
|
+ purchaseBasedOnSalesFormData: {
|
|
|
+ orderNo: null,//订单单号
|
|
|
+ deliveryTime: null,//送货日期
|
|
|
+ customerName: null,//客户名称
|
|
|
+ customerPhone: null,//客户电话
|
|
|
+ addressFull: null,//详细地址
|
|
|
+ orgId: null,//业务部门
|
|
|
+ orgName: null,//业务名称
|
|
|
+ skuModel: null,//商品型号
|
|
|
+ skuCode: null,//商品名称
|
|
|
+ skuName: null,//商品编码
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+ allCanNoEdit: false, //是否所有的都不允许编辑
|
|
|
+ formData: {
|
|
|
+ purId: null,
|
|
|
+ purNo: null,
|
|
|
+ supId: null,
|
|
|
+ supName:null,
|
|
|
+ whId:null,
|
|
|
+ whName:null,
|
|
|
+ pickupDate: new Date().addDays(1),
|
|
|
+ contactName: null,
|
|
|
+ contactPhone: null,
|
|
|
+ fromIds:null,
|
|
|
+ fromNos:null,
|
|
|
+ remarks: null,
|
|
|
+ annexPaths:null,
|
|
|
+ inboundProcessingFlag:false,
|
|
|
+ },
|
|
|
+ //明细
|
|
|
+ purchaseItemList: [],
|
|
|
+ goodsColumns: [
|
|
|
+ {
|
|
|
+ field: 'skuCode',
|
|
|
+ controlId: 'skuId',
|
|
|
+ treeNode: true,
|
|
|
+ type: 'disabled',
|
|
|
+ fixed: 'left',
|
|
|
+ promotionType: true,
|
|
|
+ dataType: self.$config.tableSelectType.goodsForPurchase,
|
|
|
+ tip: self.$t('W_117'),
|
|
|
+ fieldUpdate:self.$updateColumns.purchaseColum,
|
|
|
+ searchDetailFlag: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'skuName',
|
|
|
+ controlId: 'skuId',
|
|
|
+ type: 'disabled',
|
|
|
+ fixed: 'left',
|
|
|
+ promotionType: true,
|
|
|
+ dataType: self.$config.tableSelectType.goodsForPurchase,
|
|
|
+ fieldUpdate: self.$updateColumns.purchaseColum,
|
|
|
+ searchDetailFlag: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'itemQty',
|
|
|
+ type: 'number',
|
|
|
+ digits: 0,
|
|
|
+ sum: true,
|
|
|
+ formula: {
|
|
|
+ box: ['itemQty/packBox', 'itemQty', 'packBox'],
|
|
|
+ piece: ['itemQty%packBox', 'itemQty', 'packBox'],
|
|
|
+ }
|
|
|
+ },//数量
|
|
|
+ {
|
|
|
+ field: 'pricePur',
|
|
|
+ type: 'number',
|
|
|
+ digits: 2,
|
|
|
+ },//采购价
|
|
|
+ {
|
|
|
+ field: 'pricePurchase',
|
|
|
+ type: 'disabled',
|
|
|
+ digits: 2,
|
|
|
+ number: true,
|
|
|
+ },//采购标价
|
|
|
+ //基本单位
|
|
|
+ {
|
|
|
+ field: 'unitName',
|
|
|
+ title: self.$t('piece'),
|
|
|
+ type: 'disabled',
|
|
|
+ },
|
|
|
+ // //箱
|
|
|
+ // {
|
|
|
+ // field: 'box',
|
|
|
+ // type: 'number',
|
|
|
+ // digits: 0,
|
|
|
+ // sum: true,
|
|
|
+ // formula: {
|
|
|
+ // itemQty: ['box*packBox+piece', 'box', 'packBox','piece'],
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // //片
|
|
|
+ // {
|
|
|
+ // field: 'piece',
|
|
|
+ // type: 'number',
|
|
|
+ // digits: 0,
|
|
|
+ // sum: true,
|
|
|
+ // formula: {
|
|
|
+ // itemQty: ['box*packBox+piece', 'piece','box','packBox'],
|
|
|
+ // box: ['(box*packBox+piece)/packBox', 'piece', 'box' , 'packBox','packBox'],
|
|
|
+ // piece: ['(box*packBox+piece)%packBox', 'piece','box', 'packBox', 'packBox'],
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ field: 'packBox',
|
|
|
+ title: self.$t('boxPiece'),
|
|
|
+ type: 'disabled',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'remarks',
|
|
|
+ type: 'text',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ warehouseList: [],//仓库
|
|
|
+ //商品合计信息
|
|
|
+ goodsFootFormData: {
|
|
|
+ sumQuantity: 0,
|
|
|
+ sumAmount: 0,
|
|
|
+ sumStandard: 0,
|
|
|
+ saleDiscount:100,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 修改包装数
|
|
|
+ * @author : 周兴
|
|
|
+ * @date : 2024/5/24 15:02
|
|
|
+ */
|
|
|
+ changeNonStandard({row,rowIndex,field}){
|
|
|
+ let table = this.$refs['detailTable'].tableData
|
|
|
+ table[rowIndex][field] = (row['nonStandardForm']['box']?row['nonStandardForm']['box']:0)
|
|
|
+ + row['subUnitName']
|
|
|
+ +(row['nonStandardForm']['piece'] == 0 || row['nonStandardForm']['piece'] ?row['nonStandardForm']['piece']:'')
|
|
|
+ +(row['unitName']?(row['nonStandardForm']['piece']?row['unitName']:''):'')
|
|
|
+ table[rowIndex]['itemQty'] = row['packBox'] * (row['nonStandardForm']['box']?row['nonStandardForm']['box']:0) + (row['nonStandardForm']['piece'] ?row['nonStandardForm']['piece']:0)
|
|
|
+ table[rowIndex]['itemAmt'] = table[rowIndex]['itemQty'] * table[rowIndex]['priceSale']
|
|
|
+ table[rowIndex]['box'] = row['nonStandardForm']['box']?row['nonStandardForm']['box']:0
|
|
|
+ table[rowIndex]['piece'] = row['nonStandardForm']['piece'] ?row['nonStandardForm']['piece']:0
|
|
|
+ //计算合计
|
|
|
+ this.getTotale(table)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 获取商品表格中数量、金额后计算总单信息
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/26 14:55
|
|
|
+ */
|
|
|
+ getTotals(field, row, rowIndex) {
|
|
|
+ let table = this.$refs['detailTable'].tableData
|
|
|
+ if (table && table.length > 0) {
|
|
|
+ //计算合计
|
|
|
+ this.getTotale(table)
|
|
|
+ table.forEach(row => {
|
|
|
+ if (!row["itemQty"] || row["itemQty"] == '') {
|
|
|
+ this.$set(row, 'itemQty', 0);
|
|
|
+ }
|
|
|
+ if (!row["itemAmt"] || row["itemQty"] == '') {
|
|
|
+ this.$set(row, 'itemAmt', 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.decimalPlaces = row['decimalPlaces']
|
|
|
+ if(row['subUnitId']){
|
|
|
+ row.nonStandardForm = {
|
|
|
+ formula: (row['subUnitName']?'1'+row['subUnitName']+ '=':'' ) + row['packBox'] + row['unitName'],
|
|
|
+ box:(row['itemQty']/row['packBox'] >= 1 ? Math.floor(row['itemQty']/row['packBox']):0),
|
|
|
+ piece:row['itemQty']%row['packBox'],
|
|
|
+ }
|
|
|
+ row.nonStandardItems = [
|
|
|
+ {code:'formula',label:'计算公式',type:'text',readonly:true},
|
|
|
+ {code:'box',label:row['subUnitName'],type:'number' },
|
|
|
+ {code:'piece',label:row['unitName'],type:'number',digits:this.decimalPlaces}
|
|
|
+ ]
|
|
|
+ row['unitInfo'] = (row['itemQty']/row['packBox'] >= 1 ? Math.floor(row['itemQty']/row['packBox']):0) + row['subUnitName'] + (row['itemQty']%row['packBox']).toFixed(this.decimalPlaces) + row['unitName']
|
|
|
+ }else{
|
|
|
+ row.nonStandardForm = {
|
|
|
+ formula: (row['subUnitName']?'1'+row['subUnitName']+ '=':'' ) + row['packBox'] + row['unitName'],
|
|
|
+ piece:row['itemQty'],
|
|
|
+ }
|
|
|
+ row.nonStandardItems = [
|
|
|
+ {code:'formula',label:'计算公式',type:'text',readonly:true},
|
|
|
+ {code:'piece',label:row['unitName'],type:'number',digits: this.decimalPlaces}
|
|
|
+ ]
|
|
|
+ row['unitInfo'] = row['itemQty'] + row['unitName']
|
|
|
+ }
|
|
|
+ row['box'] = row['nonStandardForm']['box']
|
|
|
+ row['piece'] = row['nonStandardForm']['piece']
|
|
|
+
|
|
|
+ // if (!row["whId"] || row["whId"] == '') {
|
|
|
+ // this.$set(row, 'whId', this.defaultWh.whId);
|
|
|
+ // this.$set(row, 'whName', this.defaultWh.whName);
|
|
|
+ // }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
-<style scoped>
|
|
|
+ /**
|
|
|
+ * @desc : 计算合计
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:30
|
|
|
+ */
|
|
|
+ getTotale(table){
|
|
|
+ let sumQuantity = 0; // 合计数量
|
|
|
+ let sumAmount = 0; // 货物金额
|
|
|
+ let sumStandard = 0; // 标价总额
|
|
|
+ if (table && table.length > 0) {
|
|
|
+ table.forEach(row => {
|
|
|
+ row["itemAmt"] = parseFloat(row["pricePur"]) * parseFloat(row["itemQty"]);
|
|
|
+ row["amtStd"] = parseFloat(row["pricePurchase"]) * parseFloat(row["itemQty"]);
|
|
|
+ sumQuantity += parseFloat(row["itemQty"]);
|
|
|
+ sumAmount += row["itemAmt"];
|
|
|
+ sumStandard += row["amtStd"];
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.goodsFootFormData.sumQuantity = sumQuantity;
|
|
|
+ this.goodsFootFormData.sumAmount = sumAmount;
|
|
|
+ this.goodsFootFormData.sumStandard = sumStandard;
|
|
|
+ this.goodsFootFormData.saleDiscount = (sumAmount / sumStandard * 100).toFixed(2);
|
|
|
+ },
|
|
|
|
|
|
-</style>
|
|
|
+ /**
|
|
|
+ * @desc : 以销定采弹窗打开并查询数据
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:30
|
|
|
+ */
|
|
|
+ chooseSalesForPurchase(modalOpenFlag) {
|
|
|
+ this.purchaseBasedOnSalesFlag = true
|
|
|
+ let param = {
|
|
|
+ cpId: this.$store.state.user.cpId,
|
|
|
+ //客户名称
|
|
|
+ cusName: this.purchaseBasedOnSalesFormData.customerName,
|
|
|
+ //客户电话
|
|
|
+ cusPhone: this.purchaseBasedOnSalesFormData.customerPhone,
|
|
|
+ //商品型号
|
|
|
+ skuModel: this.purchaseBasedOnSalesFormData.skuModel,
|
|
|
+ //商品名称
|
|
|
+ skuName: this.purchaseBasedOnSalesFormData.skuName,
|
|
|
+ }
|
|
|
+ this.loading = true;
|
|
|
+ this.excute(this.$service.orderService, this.$service.orderService.purchaseBasedOnSales, param).then(res => {
|
|
|
+ if (res.code === this.$config.SUCCESS_CODE) {
|
|
|
+ this.purchaseBasedOnSalesTableData = res.data.list
|
|
|
+ } else {
|
|
|
+ this.$Message.warning(res.message)
|
|
|
+ this.purchaseBasedOnSalesTableData = []
|
|
|
+ }
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @desc : 以销定采选择商品确认带回方法
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:31
|
|
|
+ */
|
|
|
+ purchaseBasedOnSalesOk() {
|
|
|
+ this.purchaseBasedOnSalesFlag = false
|
|
|
+ let arr = this.$refs['table-purchase-based-on-sales-select'].batchRows
|
|
|
+ //本次选择的数据
|
|
|
+ if(arr){
|
|
|
+ arr.map(row =>{
|
|
|
+ let item = row
|
|
|
+ //采购数量
|
|
|
+ this.$set(item, 'itemQty', row['transferableQuantity'])
|
|
|
+ //采购价
|
|
|
+ this.$set(item, 'pricePur', row['pricePurchase'])
|
|
|
+ //采购金额
|
|
|
+ this.$set(item, 'itemAmt', row['pricePurchase'] * row['transferableQuantity'])
|
|
|
+ //采购标价
|
|
|
+ this.$set(item, 'pricePurchase', row['pricePurchase'])
|
|
|
+ //标价金额
|
|
|
+ this.$set(item, 'amtStd', row['pricePurchase'] * row['transferableQuantity'])
|
|
|
+ //销售订单ID
|
|
|
+ this.$set(item, 'fromId', row['orderId'])
|
|
|
+ //销售订单明细ID
|
|
|
+ this.$set(item, 'fromItemId', row['itemId'])
|
|
|
+ this.$set(item, 'packBox', row['packBox'])
|
|
|
+ // 不可查询
|
|
|
+ this.$set(item, 'readOnly', ['skuCode','skuName'])
|
|
|
+ // 去掉销售订单明细Id
|
|
|
+ delete row['itemId']
|
|
|
+ })
|
|
|
+ this.purchaseItemList = arr
|
|
|
+ //不重复Id集合
|
|
|
+ let ids = []
|
|
|
+ //不重复数据集合
|
|
|
+ let fromNos = []
|
|
|
+ let fromIds = []
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
+ if (ids.indexOf(arr[i].orderId) == -1) {
|
|
|
+ ids.push(arr[i].orderId)
|
|
|
+ fromNos.push(JSON.parse(JSON.stringify(arr[i]['orderNo'])))
|
|
|
+ fromIds.push(JSON.parse(JSON.stringify(arr[i]['orderId'])))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.formData.fromNos = fromNos
|
|
|
+ this.formData.fromIds = fromIds
|
|
|
+ this.chooseFlag = false
|
|
|
+ //计算合计
|
|
|
+ this.getTotale(this.purchaseItemList)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 关闭弹窗
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:32
|
|
|
+ */
|
|
|
+ clearPurchaseBasedOnSales() {
|
|
|
+ this.$refs.purchaseBasedOnSalesFormData.$refs['purchase-based-on-sales-form'].resetFields();
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 供应商选择后事件
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:32
|
|
|
+ */
|
|
|
+ supplierOk(val) {
|
|
|
+ this.formData.contactName = val[0]['contactName']
|
|
|
+ this.formData.contactPhone = val[0]['contactPhone']
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 数据校验
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:32
|
|
|
+ */
|
|
|
+ validData() {
|
|
|
+ // 明细必须有数据
|
|
|
+ if (!this.$refs.detailTable.tableData.filter(f => f.skuId).length) {
|
|
|
+ this.$Message.warning(this.$t('W_012'))
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 商品数量不能为空
|
|
|
+ if (this.$refs.detailTable.tableData.some(s => !s.itemQty)) {
|
|
|
+ this.$Message.warning(this.$t('W_001', {param: this.$t('itemQty')}))
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 采购价不能为空
|
|
|
+ if (this.$refs.detailTable.tableData.some(s => !s.pricePur)) {
|
|
|
+ this.$Message.warning(this.$t('W_001', {param: this.$t('pricePur')}))
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 明细必须有数据
|
|
|
+ // let itemTable = this.$refs['detailTable'].getTableDataFilter();
|
|
|
+ // for (let i = 0; i < itemTable.length; i++) {
|
|
|
+ // // 编辑时 商品数量不能小于已转入库数量
|
|
|
+ // if (itemTable[i].itemQty > itemTable[i].transferableQuantity) {
|
|
|
+ // this.$message.warning(this.$t('W_009', {'param1': this.$t('sequence') + (i + 1) + this.$t('rowNo') + this.$t('itemQty'),'param2':this.$t('已转入库数量')}))
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ return true
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 清空参数
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:32
|
|
|
+ */
|
|
|
+ clear() {
|
|
|
+ this.formData = {
|
|
|
+ purId: null,
|
|
|
+ purNo: null,
|
|
|
+ supId: null,
|
|
|
+ supName:null,
|
|
|
+ whId:null,
|
|
|
+ whName:null,
|
|
|
+ pickupDate: new Date().addDays(1),
|
|
|
+ contactName: null,
|
|
|
+ contactPhone: null,
|
|
|
+ fromIds:null,
|
|
|
+ fromNos:null,
|
|
|
+ remarks: null,
|
|
|
+ annexPaths:null,
|
|
|
+ inboundProcessingFlag:false,
|
|
|
+ }
|
|
|
+ this.purchaseItemList = []
|
|
|
+ this.goodsFootFormData = {
|
|
|
+ sumQuantity: 0,
|
|
|
+ sumAmount: 0,
|
|
|
+ sumStandard: 0,
|
|
|
+ saleDiscount:100,
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 给参数赋值
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:33
|
|
|
+ */
|
|
|
+ setParams() {
|
|
|
+ this.params = {...this.formData}
|
|
|
+ // 取货日期
|
|
|
+ if (this.formData.pickupDate) {
|
|
|
+ this.params.pickupDate = this.formData.pickupDate.format('yyyy-MM-dd')
|
|
|
+ }
|
|
|
+ // 部门
|
|
|
+ this.params.orgId = this.$store.state.user.orgId
|
|
|
+ // 员工
|
|
|
+ this.params.staffId = this.$store.state.user.staffId
|
|
|
+ // 制单员
|
|
|
+ this.params.makeStaff = this.$store.state.user.staffId
|
|
|
+ // 公司
|
|
|
+ this.params.cpId = this.$store.state.user.cpId
|
|
|
+ let tableFilter = this.$refs['detailTable'].getTableDataFilter();
|
|
|
+ let insertTale = this.countItem(tableFilter)
|
|
|
+ // 采购订单明细
|
|
|
+ this.params.purchaseItemVOList = insertTale
|
|
|
+ // 商品总数量
|
|
|
+ this.params.sumQuantity = insertTale.sum('itemQty')
|
|
|
+ // 标价合计
|
|
|
+ this.params.sumStandard = insertTale.sum('sumStandard').toFixed(2)
|
|
|
+ // 合计金额
|
|
|
+ this.params.sumAmount = insertTale.sum('sumAmount').toFixed(2)
|
|
|
+ // 采购折扣
|
|
|
+ this.params.purDiscount = (parseFloat(insertTale.sum('sumAmount').toFixed(2) )/ parseFloat(insertTale.sum('sumStandard').toFixed(2)) * 100).toFixed(2)
|
|
|
+ // 应付金额
|
|
|
+ this.params.amtPayable = this.params.sumAmount
|
|
|
+ // 还款金额
|
|
|
+ this.params.amtHandle = 0
|
|
|
+ // 剩余应付
|
|
|
+ this.params.amtResidue = parseFloat(this.params.amtPayable - this.params.amtHandle)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 计算明细数据
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:33
|
|
|
+ */
|
|
|
+ countItem(table){
|
|
|
+ let itemTable = table
|
|
|
+ itemTable.map(row => {
|
|
|
+ let item = row
|
|
|
+ // 标价合计 = 商品数量 * 采购标价
|
|
|
+ let sumStandard = parseFloat(row['itemQty']) * parseFloat(row['pricePurchase'])
|
|
|
+ // 合计金额 = 商品数量 * 采购价
|
|
|
+ let sumAmount = parseFloat(row['itemQty']) * parseFloat(row['pricePur']);
|
|
|
+ // 折扣
|
|
|
+ let priceDiscount = (parseFloat(row['pricePur']) / parseFloat(row['pricePurchase']) * 100).toFixed(2);
|
|
|
+ this.$set(item, 'sumStandard', sumStandard)
|
|
|
+ this.$set(item, 'sumAmount', sumAmount)
|
|
|
+ // 标价
|
|
|
+ this.$set(item, 'priceStd', row['pricePurchase'])
|
|
|
+ // 标价金额 = 商品数量 * 标价
|
|
|
+ this.$set(item, 'amtStd', sumStandard)
|
|
|
+ // 采购价
|
|
|
+ this.$set(item, 'pricePur', row['pricePur'])
|
|
|
+ // 采购金额 = 商品数量 * 采购价
|
|
|
+ this.$set(item, 'itemAmt', sumAmount)
|
|
|
+ // 折扣
|
|
|
+ this.$set(item, 'priceDiscount', priceDiscount)
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ let itemIndex = 1
|
|
|
+ itemTable.forEach(it =>{
|
|
|
+ this.$set(it,'itemIndex',itemIndex)
|
|
|
+ itemIndex++
|
|
|
+ })
|
|
|
+ return itemTable
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 保存
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:33
|
|
|
+ */
|
|
|
+ saveData() {
|
|
|
+ return this.excute(this.$service.purOrderService, this.$service.purOrderService.insert, this.params)
|
|
|
+ },
|
|
|
+ /***************************列表及其他事件************************************/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 获取仓库
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:33
|
|
|
+ */
|
|
|
+ getWareHouseList() {
|
|
|
+ let params = {
|
|
|
+ cpId:this.$store.state.user.cpId
|
|
|
+ }
|
|
|
+ this.excute(this.$service.commonService, this.$service.commonService.getWarehouse, params, false).then(res => {//调用api查询方法
|
|
|
+ if (res.code === this.$config.SUCCESS_CODE) {
|
|
|
+ this.warehouseList = res.data
|
|
|
+ let warehouseList = this.warehouseList
|
|
|
+ warehouseList.forEach(it =>{
|
|
|
+ if(it.flgDefault){
|
|
|
+ this.formData.whName = it.whName
|
|
|
+ this.formData.whId= it.whId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 加载数据
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:34
|
|
|
+ */
|
|
|
+ initData() {
|
|
|
+ this.getWareHouseList(); // 获取仓库数据
|
|
|
+ },
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @desc : 在实例创建完成后被立即同步调用
|
|
|
+ * @author : 姜宁
|
|
|
+ * @date : 2024/7/25 14:34
|
|
|
+ */
|
|
|
+ created() {
|
|
|
+ this.resizeTableFlag = true; // 计算表格高度
|
|
|
+ },
|
|
|
+}
|
|
|
+</script>
|