988 lines
33 KiB
Vue
988 lines
33 KiB
Vue
<template>
|
||
<div class="app-container" style="padding-top: 1px">
|
||
|
||
<div class="card-change-1-search">
|
||
<div class="" style="height: 90px; display: flex; justify-content: space-between;">
|
||
<div style="height: 100%; display: flex; justify-content: space-between;">
|
||
<div style="height: 100%; width: 70%; display: flex; justify-content: space-between;align-items: center">
|
||
<div class="box">
|
||
<span style="font-size: 26px;color: #0DC291;font-weight: bold">{{ purchasedTonnage }}</span>
|
||
<span style="display: flex;font-size: 14px;font-weight: bold">
|
||
<div
|
||
style="background-color: #0DC291;width: 10px;height: 10px;border-radius: 50%;margin-top: 6px;margin-right: 10px"></div>
|
||
采购吨数
|
||
</span>
|
||
</div>
|
||
<div class="box">
|
||
<span style="font-size: 26px;color: #00CAFF;font-weight: bold">{{ purchaseLiters }}</span>
|
||
<span style="display: flex;font-size: 14px;font-weight: bold">
|
||
<div
|
||
style="background-color: #00CAFF;width: 10px;height: 10px;border-radius: 50%;margin-top: 6px;margin-right: 10px"></div>
|
||
采购升数</span>
|
||
</div>
|
||
<div class="box">
|
||
<span style="font-size: 26px;color: #F44522;font-weight: bold">{{ totalAmountPurchased }}</span>
|
||
<span style="display: flex;font-size: 14px;font-weight: bold">
|
||
<div
|
||
style="background-color: #F44522;width: 10px;height: 10px;border-radius: 50%;margin-top: 6px;margin-right: 10px"></div>
|
||
采购总额</span>
|
||
</div>
|
||
</div>
|
||
<div style="height: 100%; width: 40%; display: flex; flex-direction: column; justify-content: space-between;">
|
||
<el-form ref="myForm" label-width="100px">
|
||
<el-form-item label="进货单号">
|
||
<el-input v-model="purchaseForm.purchaseNo" @change="saveJudgment" :disabled="numberInput"
|
||
style="width: 220Px">
|
||
<el-button slot="append" @click="refresh()" icon="el-icon-refresh"></el-button>
|
||
</el-input>
|
||
</el-form-item>
|
||
<el-form-item label="进货时间">
|
||
<el-date-picker
|
||
style="width: 220Px"
|
||
v-model="purchaseForm.purchaseDate"
|
||
@change="saveJudgment"
|
||
:disabled="numberInput"
|
||
type="date"
|
||
placeholder="选择日期">
|
||
</el-date-picker>
|
||
</el-form-item>
|
||
</el-form>
|
||
</div>
|
||
</div>
|
||
<div style="height: 100%; width: 30%; display: flex; align-items: center; justify-content: flex-end;">
|
||
<el-button type="primary" @click="cancelPurchase" v-if="state=='qrts'">关闭</el-button>
|
||
<el-button @click="cancelPurchase" v-else>取消</el-button>
|
||
<el-button type="success" v-if="state=='await'" :disabled="saveFlag" @click="savePurchase()">保存</el-button>
|
||
<el-button type="primary" v-if="state=='await'" :disabled="auditFlag" @click="audit">保存并审核</el-button>
|
||
<el-button type="danger" v-if="state=='ysh'" :disabled="voidFlag" @click="abolition()">作废</el-button>
|
||
<el-button type="primary" v-if="state=='ysh'" :disabled="storageFlag" @click="storage">收货并入库</el-button>
|
||
<!-- state=='yzf'-->
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
<div class="card-change-1-1">
|
||
<el-row :gutter="10" class="mb8">
|
||
<el-col :span="1.5" style="text-align: right; float: right">
|
||
<el-button
|
||
v-if="state =='await'"
|
||
type="primary"
|
||
icon="el-icon-plus"
|
||
@click="orderAdd"
|
||
>添加采购油品
|
||
</el-button>
|
||
</el-col>
|
||
</el-row>
|
||
<div style="height: 60vh;overflow: auto">
|
||
|
||
<el-table ref="tables"
|
||
v-loading="loading"
|
||
:data="orderList"
|
||
border
|
||
:default-sort="defaultSort">
|
||
<el-table-column label="油品油号" align="center" prop="numberName"/>
|
||
<el-table-column label="入库油罐" align="center" prop="tankName"/>
|
||
<el-table-column label="供应商" align="center" prop="supplierName"/>
|
||
<el-table-column label="当前库存" align="center" prop="storedQuantity"/>
|
||
<!-- <el-table-column label="入库前库存" align="center" prop="preInboundInventory"/>-->
|
||
<el-table-column label="油品密度(g/ml)" align="center" prop="productDensity">
|
||
<template slot-scope="scope">
|
||
<el-input-number :disabled="numberInput" v-model="scope.row.productDensity" @change="change(scope.row)"
|
||
controls-position="right" :min="0" :max="10000000" :step="1"
|
||
style="max-width: 100%"></el-input-number>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="采购吨数(t)" align="center" prop="purchaseWeight">
|
||
<template slot-scope="scope">
|
||
<el-input-number :disabled="numberInput" v-model="scope.row.purchaseWeight" @change="change(scope.row)"
|
||
controls-position="right" :min="0" :step="0.01"
|
||
style="max-width: 100%"></el-input-number>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :disabled="numberInput" label="采购单价(元/吨)" align="center" prop="purchasePrice">
|
||
<template slot-scope="scope">
|
||
<el-input-number :disabled="numberInput" v-model="scope.row.purchasePrice" @change="change(scope.row)"
|
||
controls-position="right" :min="0" :step="1" style="max-width: 100%"></el-input-number>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="小计金额(元)" align="center" prop="totalAmount">
|
||
<template slot-scope="scope">
|
||
{{ scope.row.totalAmount }}
|
||
<!-- <el-input-number :disabled="numberInput" v-model="scope.row.totalAmount" @change="change(scope.row)" controls-position="right" :min="0" :max="10000000" :step="1" style="max-width: 100%"></el-input-number> -->
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="采购升数(L)" align="center" prop="purchaseVolume"/>
|
||
<el-table-column label="成本价(元/升)" align="center" prop="discountedPrice"/>
|
||
<el-table-column v-if="state =='await'" label="操作" align="center" class-name="small-padding fixed-width">
|
||
<template slot-scope="scope">
|
||
<el-button
|
||
size="mini"
|
||
type="text"
|
||
icon="el-icon-edit"
|
||
@click="orderDel(scope.row)"
|
||
>删除
|
||
</el-button>
|
||
</template>
|
||
<!-- v-hasPermi="['']"-->
|
||
|
||
</el-table-column>
|
||
</el-table>
|
||
|
||
</div>
|
||
<pagination
|
||
v-show="total>0"
|
||
:total="total"
|
||
:page.sync="queryParams.page"
|
||
:limit.sync="queryParams.pageSize"
|
||
@pagination="getList"
|
||
/>
|
||
</div>
|
||
|
||
<!-- 添加采购油品-->
|
||
<el-dialog center :title="title" :visible.sync="open" width="500px" append-to-body :close-on-click-modal="false">
|
||
<el-form ref="form" :model="orderForm" :rules="rules" label-width="120px">
|
||
<el-row :gutter="24">
|
||
<el-col :span="22">
|
||
<el-form-item label="采购油品号" prop="numberId">
|
||
<el-select v-model="orderForm.numberId" placeholder="请选择油品" style="width:100%"
|
||
@change="chooseOilNumber($event)">
|
||
<el-option
|
||
v-for="option in numberList"
|
||
:key="option.numberId"
|
||
:label="option.oilType +' '+option.oilName"
|
||
:value="option.numberId"
|
||
></el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="24">
|
||
<el-col :span="22">
|
||
<el-form-item label="入库油罐" prop="tankId">
|
||
<el-select v-model="orderForm.tankId" placeholder="请选择油罐" style="width:100%"
|
||
@change="chooseTank($event),getSecondName()">
|
||
<el-option
|
||
v-for="option in tankList"
|
||
:key="option.id"
|
||
:label="option.tankName "
|
||
:value="option.id"
|
||
></el-option>
|
||
</el-select>
|
||
|
||
|
||
</el-form-item>
|
||
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="24">
|
||
<el-col :span="22">
|
||
<el-form-item label="供应商" prop="supplierId">
|
||
<el-select v-model="orderForm.supplierId" placeholder="请选择供应商" style="width:100%">
|
||
<el-option
|
||
v-for="option in suppliersList"
|
||
:key="option.id"
|
||
:label="option.supplierName"
|
||
:value="option.id"
|
||
></el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="24">
|
||
<el-col :span="22">
|
||
<el-form-item label="油品密度" prop="productDensity">
|
||
<el-input v-model="orderForm.productDensity" @input="aaa()" placeholder="请输入油品密度">
|
||
<template slot="append">g/ml</template>
|
||
</el-input>
|
||
<el-alert
|
||
v-if="orderForm.tankId"
|
||
style="height: auto;line-height: 16px;padding: 0 0 0 0;"
|
||
:title='tTitle'
|
||
type="warning"
|
||
:closable="false">
|
||
</el-alert>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="24">
|
||
<el-col :span="22">
|
||
<el-form-item label="采购吨数" prop="purchaseWeight">
|
||
<el-input v-model="orderForm.purchaseWeight" placeholder="请输入采购吨数" @input="inputPurchaseWeight()">
|
||
<template slot="append">吨</template>
|
||
</el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row :gutter="24">
|
||
<el-col :span="22">
|
||
<el-form-item label="采购单价" prop="purchasePrice">
|
||
<el-input v-model="orderForm.purchasePrice" placeholder="请输入采购单价">
|
||
<template slot="append">元/吨</template>
|
||
</el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form>
|
||
<div slot="footer" class="dialog-footer">
|
||
<el-button @click="cancel">取 消</el-button>
|
||
<el-button type="primary" @click="submitForm">保 存</el-button>
|
||
|
||
</div>
|
||
</el-dialog>
|
||
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import {getSuppliersListApi2} from "@/api/oilConfig/oilSuppliers";
|
||
import {
|
||
editPurchuseApi,
|
||
getPurchaseOrderApi, unifiedProcessingApi,
|
||
insertPurchaseApi,
|
||
insertPurchaseOrderApi,
|
||
disposeBatchApi,
|
||
updatePurchaseOrderApi,
|
||
updatePurchaseApi, auditApi, abolitionApi, storageApi, delPurchaseOrderApi
|
||
} from "@/api/oilConfig/oilPurchase";
|
||
import {getOilNameListApi} from "@/api/oilPrice";
|
||
import {selectTankByNumberApi} from "@/api/oilConfig/oilGuns";
|
||
import {BigNumber} from "bignumber.js";
|
||
import {getAuditPremApi} from "@/api/oilConfig/staff";
|
||
|
||
export default {
|
||
name: "purchaseOrder",
|
||
|
||
data() {
|
||
var valiNumberPass = (rule, value, callback) => {//包含小数的数字
|
||
let reg = /^[+-]?(0|([1-9]\d*))(\.\d{1,2})?$/;
|
||
if (value === '') {
|
||
callback(new Error('请输入内容'));
|
||
} else if (!reg.test(value)) {
|
||
callback(new Error('请输入数字,最多保留两位小数'));
|
||
} else {
|
||
callback();
|
||
}
|
||
};
|
||
return {
|
||
orderList: [],
|
||
orderForm: {
|
||
id: null,
|
||
purchaseId: null,
|
||
numberId: null,
|
||
tankId: null,
|
||
tankName: null,
|
||
supplierId: null,
|
||
productDensity: null,
|
||
purchaseWeight: null,
|
||
purchasePrice: null,
|
||
totalAmount: null,
|
||
purchaseVolume: null,
|
||
preInboundInventory: null,
|
||
discountedPrice: null
|
||
},
|
||
|
||
// 油罐文字提示
|
||
tankVolume: 0, // 总升数
|
||
nowVolume: 0, // 现有升数
|
||
canUseVolume: 0,// 可用升数
|
||
canUseT: 0,//吨数计算
|
||
unit: 'L',//单位
|
||
// tTitle:'',
|
||
|
||
|
||
purchaseId: null,
|
||
numberInput: false,
|
||
|
||
purchaseOrderNumber: null, // 进货单号
|
||
incomingTime: '', //进货时间
|
||
|
||
purchasedTonnage: 0, //采购吨数
|
||
purchaseLiters: 0, //采购升数
|
||
totalAmountPurchased: 0, //采购总额
|
||
numberList: [],
|
||
tankList: [],
|
||
suppliersList: [],
|
||
|
||
saveFlag: false,
|
||
auditFlag: true,
|
||
voidFlag: false,
|
||
storageFlag: true,
|
||
state: '',
|
||
|
||
// 弹出框标题
|
||
title: '',
|
||
// 显示搜索条件
|
||
showSearch: true,
|
||
disableInput: false, // 默认不禁用
|
||
// 是否显示弹出层
|
||
open: false,
|
||
// 总条数
|
||
total: 0,
|
||
// 查询参数
|
||
queryParams: {
|
||
supplierId: '',
|
||
purchaseId: null,
|
||
page: null,
|
||
pageSize: null
|
||
},
|
||
// 遮罩层
|
||
loading: false,
|
||
// 默认排序
|
||
defaultSort: {prop: 'createTime', order: 'ascending'},
|
||
// 表单校验
|
||
|
||
purchaseForm: {
|
||
purchaseNo: null,
|
||
purchaseDate: null
|
||
},
|
||
|
||
// 表单校验
|
||
rules: {
|
||
productDensity: [
|
||
{required: true, validator: valiNumberPass, trigger: "blur"}
|
||
],
|
||
purchaseWeight: [
|
||
{required: true, validator: valiNumberPass, trigger: "blur"},
|
||
],
|
||
purchasePrice: [
|
||
{required: true, validator: valiNumberPass, trigger: "blur"}
|
||
],
|
||
numberId: [
|
||
{required: true, message: "请选择采购油品", trigger: "blur"}
|
||
],
|
||
tankId: [
|
||
{required: true, message: "请选择油罐", trigger: "blur"}
|
||
],
|
||
supplierId: [
|
||
{required: true, message: "请选择供应商", trigger: "blur"}
|
||
]
|
||
},
|
||
|
||
|
||
form: {
|
||
id: "", // ID(标识)
|
||
productDensity: "", // 产品密度
|
||
purchaseWeight: "", // 采购重量
|
||
purchasePrice: "", // 采购价格
|
||
totalAmount: "", // 总金额
|
||
purchaseVolume: "", // 采购体积
|
||
discountedPrice: "", // 折扣价格
|
||
oilType: "", // 油品类型
|
||
oilName: "", // 油品名称
|
||
supplierName: "", // 供应商名称
|
||
tankName: "", // 储罐名称
|
||
storedQuantity: "", // 储存数量
|
||
},
|
||
}
|
||
},
|
||
|
||
async created() {
|
||
if (this.$route.query.purchaseId != null) {
|
||
this.queryParams.purchaseId = this.$route.query.purchaseId;
|
||
this.purchaseId = this.$route.query.purchaseId;
|
||
} else if (this.$route.query.purchaseId == null && this.purchaseId > 0) {
|
||
|
||
} else {
|
||
// this.queryParams.purchaseId = -parseInt(new Date().getTime())% 100000000;
|
||
// this.purchaseId = -parseInt(new Date().getTime()) % 100000000;
|
||
}
|
||
|
||
this.state = this.$route.query.state;
|
||
|
||
if (this.state == null) {
|
||
this.state = 'await'
|
||
}
|
||
|
||
if (this.state == 'await') {
|
||
this.numberInput = false
|
||
} else {
|
||
this.numberInput = true
|
||
}
|
||
|
||
|
||
// this.purchaseForm.purchaseDate = localDate;
|
||
// console.log("this.purchaseForm.purchaseDate:", this.purchaseForm.purchaseDate);
|
||
if (this.$route.query.purchaseDate != null) {
|
||
this.purchaseForm.purchaseDate = new Date(parseInt(this.$route.query.purchaseDate))
|
||
}
|
||
|
||
if (this.purchaseForm.purchaseDate == null) {
|
||
this.purchaseForm.purchaseDate = new Date()
|
||
}
|
||
|
||
|
||
this.purchaseForm.purchaseNo = this.$route.query.purchaseNo;
|
||
|
||
if (this.purchaseForm.purchaseNo == null) {
|
||
this.refresh();
|
||
}
|
||
|
||
await this.JudgmentButton();
|
||
await this.getList();
|
||
|
||
},
|
||
computed: {
|
||
tTitle() {
|
||
return "油罐总容量" + this.tankVolume + ' ' + this.unit + ",当前密度下可用约" + this.canUseT + "吨"
|
||
}
|
||
},
|
||
methods: {
|
||
// 返回页面
|
||
cancelPurchase() {
|
||
this.$router.back()
|
||
},
|
||
aaa() {
|
||
this.densityCalculations()
|
||
this.$forceUpdate();
|
||
console.log(" orderForm.productDensity()\n", this.orderForm.productDensity)
|
||
|
||
},
|
||
getList() {
|
||
this.loading = true;
|
||
getPurchaseOrderApi(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||
this.orderList = response.data.records;
|
||
this.total = response.data.total;
|
||
// console.log("response",response.data.records[0].purchaseWeight)
|
||
// console.log("orderList",this.orderList)
|
||
// 总数计算
|
||
if (this.orderList) {
|
||
this.sumMethod(response.data.records);
|
||
}
|
||
})
|
||
this.loading = false;
|
||
},
|
||
// 添加采购油品
|
||
orderAdd() {
|
||
// 初始化
|
||
this.orderForm = {}
|
||
this.open = true;
|
||
this.title = "添加采购油品"
|
||
this.getOilNameList()
|
||
this.selectSuppliers()
|
||
},
|
||
orderDel(data) {
|
||
if (data.id != null) {
|
||
delPurchaseOrderApi(data).then(res => {
|
||
})
|
||
}
|
||
const index = this.orderList.indexOf(data); // 查找要删除的对象的索引
|
||
if (index !== -1) {
|
||
this.orderList.splice(index, 1); // 使用splice方法删除对象
|
||
}
|
||
// this.numberOfTanks = this.numberOfTanks-1
|
||
// delPurchaseOrderApi(data).then(response => {
|
||
// this.$modal.msgSuccess("删除成功");
|
||
// this.getList()
|
||
// })
|
||
},
|
||
// 提交
|
||
submitForm: function () {
|
||
this.$refs["form"].validate(valid => {
|
||
if (valid) {
|
||
// 密度计算
|
||
this.orderForm.purchaseVolume = new BigNumber(this.orderForm.purchaseWeight).times(1000).dividedBy(this.orderForm.productDensity).toFixed(2);
|
||
// 计算小计价格
|
||
this.orderForm.totalAmount = new BigNumber(this.orderForm.purchasePrice).times(this.orderForm.purchaseWeight);
|
||
// 折合单价
|
||
this.orderForm.discountedPrice = new BigNumber(this.orderForm.totalAmount).dividedBy(this.orderForm.purchaseVolume).toFixed(2);
|
||
|
||
this.orderForm.totalAmount = Number(this.orderForm.totalAmount);
|
||
|
||
// 复制id
|
||
this.orderForm.purchaseId = this.purchaseId
|
||
|
||
|
||
let numberName = this.numberList.find(item => item.numberId === this.orderForm.numberId);
|
||
let tankName = this.tankList.find(item => item.id === this.orderForm.tankId);
|
||
let supplierName = this.suppliersList.find(item => item.id === this.orderForm.supplierId);
|
||
console.log("numberName", numberName)
|
||
// 去重
|
||
let isDuplicate = false
|
||
if (this.orderList.length > 0) {
|
||
isDuplicate = this.orderList.some(order => order.tankId === this.orderForm.tankId);
|
||
}
|
||
if (isDuplicate) {
|
||
this.$message({
|
||
message: '有重复油罐,请重新选择',
|
||
type: 'warning'
|
||
});
|
||
this.orderForm = {}
|
||
return;
|
||
}
|
||
let addFrom = {
|
||
"discountedPrice": this.orderForm.discountedPrice,
|
||
// "id": 47,
|
||
"numberId": this.orderForm.numberId,
|
||
"numberName": numberName.oilType + ' ' + numberName.oilName,
|
||
"oilName": numberName.oilName,
|
||
"oilType": numberName.oilType,
|
||
// "preInboundInventory": null,
|
||
"productDensity": this.orderForm.productDensity,
|
||
// "purchaseId": this.purchaseId,
|
||
"purchasePrice": this.orderForm.purchasePrice,
|
||
"purchaseVolume": this.orderForm.purchaseVolume,
|
||
"purchaseWeight": this.orderForm.purchaseWeight,
|
||
// "preInboundInventory": tankName.storedQuantity,
|
||
"storedQuantity": tankName.storedQuantity,
|
||
"supplierId": this.orderForm.supplierId,
|
||
"supplierName": supplierName.supplierName,
|
||
"tankId": this.orderForm.tankId,
|
||
"tankName": tankName.tankName,
|
||
"totalAmount": this.orderForm.totalAmount,
|
||
"canUseT": this.canUseT,
|
||
|
||
}
|
||
|
||
|
||
this.orderList.push(addFrom)
|
||
this.open = false;
|
||
this.sumMethod(this.orderList)
|
||
console.log(" this.orderForm", this.orderForm)
|
||
|
||
// if (!this.orderForm.id) {
|
||
// insertPurchaseOrderApi(this.orderForm).then(response => {
|
||
// this.$modal.msgSuccess("新增成功");
|
||
// this.open = false;
|
||
// // this.saveJudgment()
|
||
// this.getList();
|
||
// });
|
||
// } else {
|
||
// updatePurchaseOrderApi(this.orderForm).then(response => {
|
||
// this.$modal.msgSuccess("修改成功");
|
||
// this.open = false;
|
||
// this.getList();
|
||
// });
|
||
// }
|
||
}
|
||
});
|
||
},
|
||
// 取消
|
||
cancel() {
|
||
this.open = false;
|
||
},
|
||
// 改变数字时
|
||
change(data) {
|
||
|
||
if (data.purchaseWeight > data.canUseT) {
|
||
this.$message('不能超过油罐储存的最大值!');
|
||
data.purchaseWeight = data.canUseT
|
||
return
|
||
}
|
||
// 密度计算
|
||
data.purchaseVolume = new BigNumber(data.purchaseWeight).times(1000).dividedBy(data.productDensity).toFixed(2);
|
||
// 计算小计价格
|
||
data.totalAmount = new BigNumber(data.purchasePrice).times(data.purchaseWeight);
|
||
// 折合单价
|
||
if (data.purchasePrice == 0 || data.purchaseWeight == 0) {
|
||
data.discountedPrice = 0
|
||
} else {
|
||
data.discountedPrice = new BigNumber(data.totalAmount).dividedBy(data.purchaseVolume).toFixed(2);
|
||
}
|
||
this.sumMethod(this.orderList)
|
||
|
||
|
||
// 进行保存
|
||
// this.orderForm = data
|
||
// this.edit()
|
||
},
|
||
edit() {
|
||
updatePurchaseOrderApi(this.orderForm).then(response => {
|
||
// this.$modal.msgSuccess("修改成功");
|
||
// this.open = false;
|
||
this.orderForm = {}
|
||
this.getList();
|
||
});
|
||
},
|
||
// 选择油品号之后
|
||
chooseOilNumber(data) {
|
||
this.orderForm.tankId = '',
|
||
this.selectTankByNumber(this.orderForm.numberId);
|
||
},
|
||
// 选择油罐添加密度
|
||
chooseTank(data) {
|
||
// 根据id找密度
|
||
this.tankList.forEach(su => {
|
||
if (data == su.id) {
|
||
this.orderForm.productDensity = su.oilDensity
|
||
console.log("su", su)
|
||
this.tankVolume = su.tankVolume
|
||
this.nowVolume = su.storedQuantity
|
||
this.unit = su.unit
|
||
this.densityCalculations();
|
||
}
|
||
})
|
||
},
|
||
// 根据升数计算密度
|
||
densityCalculations() {
|
||
this.canUseVolume = this.tankVolume - this.nowVolume
|
||
// 定义油的体积和密度
|
||
const volumeLiters = new BigNumber(this.canUseVolume); // 体积,单位:升
|
||
const densityGramsPerML = new BigNumber(this.orderForm.productDensity ? this.orderForm.productDensity : 0); // 密度,单位:克/毫升
|
||
|
||
|
||
// 计算油的质量(吨)
|
||
// const massTons = volumeLiters.times(densityGramsPerML).times(1e-3).toFixed(2);
|
||
const massTons = Math.floor(volumeLiters.times(densityGramsPerML).times(1e-3) * 100) / 100;
|
||
|
||
this.canUseT = massTons; // 将结果转换为数字类型并赋值给属性
|
||
console.log("canUseT", this.canUseT)
|
||
|
||
},
|
||
inputPurchaseWeight() {
|
||
if (!this.orderForm.purchaseWeight) {
|
||
this.orderForm.purchaseWeight = ''
|
||
return
|
||
}
|
||
if (!this.canUseT) {
|
||
this.$message('请先选择油罐和填写密度!');
|
||
this.orderForm.purchaseWeight = ''
|
||
return
|
||
}
|
||
|
||
const purchaseWeight = parseFloat(this.orderForm.purchaseWeight);
|
||
const canUseT = parseFloat(this.canUseT);
|
||
console.log("purchaseWeight", purchaseWeight)
|
||
console.log("canUseT", canUseT)
|
||
if (canUseT <= 0) {
|
||
this.$message('已无可用吨数!');
|
||
this.orderForm.purchaseWeight = ''
|
||
return
|
||
} else if (purchaseWeight > canUseT) {
|
||
this.orderForm.purchaseWeight = canUseT
|
||
}
|
||
},
|
||
// 查询所有的油品
|
||
getOilNameList() {
|
||
let this_ = this
|
||
getOilNameListApi().then(response => {
|
||
let list = response.data
|
||
this_.numberList = list
|
||
});
|
||
},
|
||
// 根据油品查询油罐
|
||
selectTankByNumber(data) {
|
||
let numberId = data
|
||
selectTankByNumberApi(numberId).then(response => {
|
||
this.tankList = response.data;
|
||
});
|
||
},
|
||
// 查询所有供应商
|
||
selectSuppliers() {
|
||
getSuppliersListApi2().then(response => {
|
||
this.suppliersList = response.data;
|
||
});
|
||
},
|
||
// 刷新订单编号
|
||
refresh() {
|
||
var timestamp = new Date().getTime();
|
||
var min = 100; // 最小的四位数是 1000
|
||
var max = 999; // 最大的四位数是 9999
|
||
var randomFourDigitNumber = Math.floor(Math.random() * (max - min + 1)) + min;
|
||
// this.purchaseOrderNumber = timestamp+randomFourDigitNumber.toString();
|
||
this.purchaseForm.purchaseNo = timestamp + randomFourDigitNumber.toString();
|
||
},
|
||
// 总数计算
|
||
sumMethod(data) {
|
||
this.purchasedTonnage = new BigNumber(0),
|
||
this.purchaseLiters = new BigNumber(0),
|
||
this.totalAmountPurchased = new BigNumber(0),
|
||
data.forEach(da => {
|
||
this.purchasedTonnage = this.purchasedTonnage.plus(da.purchaseWeight);
|
||
this.purchaseLiters = this.purchaseLiters.plus(da.purchaseVolume);
|
||
this.totalAmountPurchased = this.totalAmountPurchased.plus(da.totalAmount);
|
||
})
|
||
},
|
||
// 保存订单信息
|
||
async savePurchase(flag) {
|
||
if (this.purchaseForm.purchaseNo == null) {
|
||
this.$modal.msgWarning("请先选择进货单号");
|
||
return -1;
|
||
} else if (this.purchaseForm.purchaseDate == null) {
|
||
this.$modal.msgWarning("请先选择进货时间");
|
||
return -1;
|
||
}
|
||
if (this.orderList.length <= 0) {
|
||
this.$modal.msgWarning("请选择至少一个油品");
|
||
return -1;
|
||
}
|
||
|
||
let from = {
|
||
id: this.purchaseId,
|
||
purchaseNo: this.purchaseForm.purchaseNo,
|
||
purchaseDate: this.purchaseForm.purchaseDate,
|
||
theDocumentAmount: this.totalAmountPurchased,
|
||
}
|
||
|
||
await unifiedProcessingApi({oilPurchase: from, oilPurchaseOrders: this.orderList}).then(res => {
|
||
if (res.code === 200) {
|
||
this.purchaseId = res.data.id
|
||
|
||
this.$router.push({path: '/oilConfig/oilPurchase/list'});
|
||
} else {
|
||
return -1;
|
||
}
|
||
}).catch({})
|
||
|
||
// if(this.purchaseId != null) {
|
||
// // 修改
|
||
// from.id = this.purchaseId
|
||
// updatePurchaseApi(from).then(res => {
|
||
// // this.purchaseId = res.data.id
|
||
// this.orderList.forEach(ord=>{
|
||
// ord.purchaseId = res.data.id
|
||
// })
|
||
// // if (flag != -1) {
|
||
// // // 处理列表
|
||
|
||
// // this.$router.push('/oilConfig/oilPurchase/list');
|
||
// // }
|
||
// disposeBatchApi(this.orderList).then(response=> {
|
||
// // 保存成功
|
||
// this.$modal.msgSuccess("保存成功");
|
||
// // this.getList()
|
||
// this.$router.push({ path: '/oilConfig/oilPurchase/list', query: {
|
||
// } });
|
||
// })
|
||
// })
|
||
// }else{
|
||
// insertPurchaseApi(from).then(res => {
|
||
// this.orderList.forEach(ord=>{
|
||
// ord.purchaseId = res.data.id
|
||
// })
|
||
// disposeBatchApi(this.orderList).then(response=> {
|
||
// // 保存成功
|
||
// this.$modal.msgSuccess("保存成功");
|
||
// // this.getList()
|
||
// this.$router.push({ path: '/oilConfig/oilPurchase/list', query: {
|
||
// } });
|
||
// })
|
||
// })
|
||
// }
|
||
|
||
|
||
// 判断是新增还是修改
|
||
// if (this.queryParams.purchaseId < 0) {
|
||
// insertPurchaseApi(from).then(response => {
|
||
// console.log("response",response)
|
||
// this.$modal.msgSuccess("添加成功");
|
||
// // 修改进货单的父id
|
||
// let oilPurchase = {
|
||
// purchaseId:response.data.id,
|
||
// id:this.queryParams.purchaseId
|
||
// }
|
||
// this.queryParams.purchaseId = response.data.id,
|
||
// this.purchaseId = response.data.id,
|
||
// this.purchaseNo = response.data.purchaseNo,
|
||
// this.state = response.data.status
|
||
// //todo 优化 将这些代码加到后台中完成并进行事务管理
|
||
|
||
// editPurchuseApi(oilPurchase).then(response2 => {
|
||
// if (flag != -1) {
|
||
// // this.$router.push({ path: '/oilPurchase/purchaseOrder', query: {
|
||
// // purchaseId: oilPurchase.purchaseId,
|
||
// // purchaseNo: response.data.purchaseNo,
|
||
// // state: response.data.status
|
||
// // }});
|
||
// this.$router.push('/oilConfig/oilPurchase/list');
|
||
|
||
// }
|
||
// })
|
||
// this.getList();
|
||
// });
|
||
// } else {
|
||
// from.id = this.queryParams.purchaseId
|
||
// updatePurchaseApi(from).then(response => {
|
||
// this.$modal.msgSuccess("添加成功");
|
||
// })
|
||
// }
|
||
},
|
||
// 判断是否可以保存
|
||
saveJudgment() {
|
||
// if (this.purchaseForm.purchaseNo != null && this.purchaseForm.purchaseDate != null && this.orderList.length > 0) {
|
||
// this.saveFlag = false;
|
||
// }
|
||
},
|
||
// 判断按钮是否可用
|
||
async JudgmentButton() {
|
||
let judgmentPermissions1 = await this.judgmentPermissions("进油审核");
|
||
if (judgmentPermissions1 > 0) {
|
||
this.auditFlag = false
|
||
} else {
|
||
this.auditFlag = true
|
||
}
|
||
let judgmentPermissions2 = await this.judgmentPermissions("进油入库");
|
||
if (judgmentPermissions2 > 0) {
|
||
this.storageFlag = false
|
||
} else {
|
||
this.storageFlag = true
|
||
}
|
||
let judgmentPermissions3 = await this.judgmentPermissions("进油废止");
|
||
if (judgmentPermissions3 > 0) {
|
||
this.voidFlag = false
|
||
} else {
|
||
this.voidFlag = true
|
||
}
|
||
},
|
||
// 判断权限
|
||
async judgmentPermissions(data) {
|
||
let fil = {
|
||
auditPrem: data
|
||
}
|
||
return await getAuditPremApi(fil).then(res => {
|
||
return res.data
|
||
});
|
||
},
|
||
// 保存并审核
|
||
async audit() {
|
||
// 保存
|
||
let number = await this.savePurchase(-1);
|
||
|
||
if (number != -1) {
|
||
// 审核
|
||
let fil = {
|
||
id: this.purchaseId
|
||
}
|
||
console.log(" id: this.purchaseId", fil)
|
||
await auditApi(fil).then(res => {
|
||
if (res.data) {
|
||
this.state = 'ysh'
|
||
this.numberInput = true
|
||
this.$modal.msgWarning("审核成功");
|
||
this.$router.push('/oilConfig/oilPurchase/list');
|
||
} else {
|
||
this.$modal.msgWarning("暂无审核权限");
|
||
}
|
||
|
||
})
|
||
}
|
||
|
||
},
|
||
// 入库
|
||
storage() {
|
||
if (this.purchaseForm.purchaseNo == null) {
|
||
this.$modal.msgWarning("请先选择进货单号");
|
||
return;
|
||
} else if (this.purchaseForm.purchaseDate == null) {
|
||
this.$modal.msgWarning("请先选择进货时间");
|
||
return;
|
||
}
|
||
this.$confirm('确认后单据中的对应油品入库油罐库存将发生变化,且不可逆,确认已按照采购单据收货并入库吗?', '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
// 审核
|
||
let fil = {
|
||
id: this.purchaseId
|
||
}
|
||
storageApi(fil).then(res => {
|
||
if (res.data) {
|
||
this.state = 'qrts'
|
||
this.$modal.msgWarning("入库成功");
|
||
this.numberInput = true
|
||
|
||
this.$router.push('/oilConfig/oilPurchase/list');
|
||
|
||
} else {
|
||
this.$modal.msgWarning("暂无入库权限");
|
||
}
|
||
|
||
})
|
||
}).catch(() => {
|
||
this.$message({
|
||
type: 'info',
|
||
message: '已取消'
|
||
});
|
||
});
|
||
|
||
|
||
},
|
||
// 作废
|
||
abolition() {
|
||
if (this.purchaseId < 0) {
|
||
this.$modal.msgWarning("数据未保存,不可废弃");
|
||
return;
|
||
}
|
||
|
||
this.$confirm('确认废弃订单吗?', '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
// 审核
|
||
let fil = {
|
||
id: this.purchaseId
|
||
}
|
||
abolitionApi(fil).then(res => {
|
||
if (res.data) {
|
||
this.state = 'yzf'
|
||
this.$modal.msgWarning("审核废弃");
|
||
this.numberInput = true
|
||
this.$router.push('/oilConfig/oilPurchase/list');
|
||
} else {
|
||
this.$modal.msgWarning("暂无废弃权限");
|
||
}
|
||
})
|
||
}).catch(() => {
|
||
this.$message({
|
||
type: 'info',
|
||
message: '已取消'
|
||
});
|
||
})
|
||
|
||
|
||
},
|
||
// 页面跳转
|
||
goToAbout() {
|
||
this.$router.push('/oilConfig/oilPurchase/list');
|
||
},
|
||
// 搜索按钮操作
|
||
handleQuery() {
|
||
this.queryParams.page = 1;
|
||
this.getList();
|
||
},
|
||
|
||
getSecondName() {
|
||
this.$forceUpdate();
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.app-container {
|
||
width: 100%;
|
||
height: 100%;
|
||
background: #f6f8f9;
|
||
margin: 0px 0px 0px 0px;
|
||
padding: 0px;
|
||
}
|
||
|
||
.box {
|
||
height: 80%;
|
||
width: 212px;
|
||
margin-right: 10px;
|
||
background: #FFFFFF;
|
||
border: 1px solid #FF9655;
|
||
border-radius: 10px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
align-items: start;
|
||
padding-left: 20px;
|
||
}
|
||
|
||
.card-change-1-search{
|
||
margin: 10px;
|
||
}
|
||
|
||
.card-change-1-1{
|
||
margin: 10px;
|
||
height: 74vh;
|
||
}
|
||
|
||
|
||
</style>
|