oil-station/fuintAdmin/src/views/convenienceStore/purchase/details.vue

765 lines
23 KiB
Vue
Raw Normal View History

2023-10-26 13:52:13 +08:00
<template>
<div class="app-container">
<el-card >
2023-10-31 17:55:49 +08:00
<div slot="header" class="clearfix" style="display: flex; justify-content: space-between;">
<div>
<i class="el-icon-back" @click="goToAbout">返回 | </i>
2023-10-26 13:52:13 +08:00
<!-- <el-link icon="el-icon-edit" :underline="false" @click="goToAbout">编辑</el-link>-->
2023-10-31 17:55:49 +08:00
<span> 进货详情</span>
</div>
2023-10-26 13:52:13 +08:00
</div>
<div style="height: 90px; display: flex; justify-content: space-between;">
<div style="height: 100%; width: 50%; display: flex; justify-content: space-between;">
<div style="height: 100%; width: 70%; display: flex; justify-content: space-between;">
<div class="box">
<span>{{purchaseForm.totalAmount}}</span>
<span>总金额</span>
</div>
<div class="box">
<span>{{purchaseForm.productQuantity}}</span>
<span>商品数量</span>
</div>
<div class="box">
<span>{{purchaseForm.quantityPurchased}}</span>
<span>进货数量</span>
</div>
</div>
<div style="height: 100%; width: 30%; display: flex; flex-direction: column; justify-content: space-between;">
<el-form ref="myForm" label-width="100px">
2023-10-31 17:55:49 +08:00
<el-form-item label="进货单号">
2023-10-26 13:52:13 +08:00
<el-input v-model="purchaseForm.orderNumber"
2023-10-28 17:12:18 +08:00
style="width: 220Px" :disabled="numberInput">
2023-10-31 17:55:49 +08:00
<el-button v-if="!numberInput" slot="append" @click="refresh()" icon="el-icon-refresh"></el-button>
2023-10-26 13:52:13 +08:00
</el-input>
</el-form-item>
2023-10-31 17:55:49 +08:00
<el-form-item label="进货时间" >
2023-10-26 13:52:13 +08:00
<el-date-picker
2023-10-28 17:12:18 +08:00
:disabled="numberInput"
2023-10-26 13:52:13 +08:00
style="width: 220Px"
v-model="purchaseForm.orderDate"
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" v-if="state=='await'" :disabled="saveFlag" @click="save()">保存</el-button>
<el-button type="success" v-if="state=='await'" :disabled="auditFlag" @click="audit">保存并审核</el-button>
2023-10-28 17:12:18 +08:00
<el-button type="success" v-if="state=='ysh'" :disabled=" storageFlag" @click="storage()">进货并入库</el-button>
2023-11-24 17:59:53 +08:00
<el-button type="warning" v-if="state =='!await' || state=='ysh'" :disabled="voidFlag" @click="abolition()">作废</el-button>
2023-10-31 17:55:49 +08:00
<el-button type="warning" v-if="state !='await'" @click="exportExcel()">导出</el-button>
2023-10-26 13:52:13 +08:00
</div>
</div>
</el-card>
<el-card style="margin-top: 20px" >
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
2023-10-31 17:55:49 +08:00
v-if="!numberInput"
2023-10-26 13:52:13 +08:00
type="primary"
icon="el-icon-plus"
@click="commodityAdd"
>添加进货</el-button>
</el-col>
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
</el-row>
<el-table ref="tables"
v-loading="loading"
:data="detailsList"
:default-sort="defaultSort">
2023-10-26 18:01:14 +08:00
<el-table-column label="商品名称" align="center" prop="commodityName"/>
<el-table-column label="分类名称" prop="cvsGoodId" align="center">
<template slot-scope="scope">
<span>{{ getName(cvsGoodList, scope.row.cvsGoodId) }}</span>
</template>
</el-table-column>
<el-table-column label="供应商" prop="supplierId" align="center">
<template slot-scope="scope">
<span>{{ getName(supplierList, scope.row.supplierId) }}</span>
</template>
</el-table-column>
<el-table-column label="单位" align="center" prop="unit">
2023-10-26 15:01:02 +08:00
<template slot-scope="scope">
2023-10-26 18:01:14 +08:00
<span>{{ scope.row.unit == null?"-":scope.row.unit}}</span>
2023-10-26 15:01:02 +08:00
</template>
</el-table-column>
2023-10-26 18:01:14 +08:00
<el-table-column label="当前库存" align="center" prop="stock"/>
<el-table-column label="进货数量" align="center" prop="quantityPurchased">
2023-10-26 15:01:02 +08:00
<template slot-scope="scope">
2023-10-31 17:55:49 +08:00
<el-input-number :disabled="numberInput" v-model="scope.row.quantityPurchased" @change="change(scope.row,1)" :precision="0" controls-position="right" :min="1" :max="100000000" :step="1" style="max-width: 100%"></el-input-number>
2023-10-26 15:01:02 +08:00
</template>
</el-table-column>
2023-10-26 18:01:14 +08:00
<el-table-column label="进货单价" align="center" prop="unitPrice">
2023-10-26 13:52:13 +08:00
<template slot-scope="scope">
2023-10-31 17:55:49 +08:00
<el-input-number :disabled="numberInput" v-model="scope.row.unitPrice" @change="change(scope.row,2)" :precision="2" controls-position="right" :min="0" :max="100000000" :step="1" style="max-width: 100%"></el-input-number>
2023-10-26 18:01:14 +08:00
</template>
</el-table-column>
<el-table-column label="小计金额" align="center" prop="subtotalAmount">
<template slot-scope="scope">
2023-10-31 17:55:49 +08:00
<el-input-number :disabled="numberInput" v-model="scope.row.subtotalAmount" @change="change(scope.row,3)" :precision="2" controls-position="right" :min="0" :max="100000000" :step="1" style="max-width: 100%"></el-input-number>
2023-10-26 13:52:13 +08:00
</template>
</el-table-column>
2023-11-23 18:33:25 +08:00
<el-table-column v-if="state =='await'" label="操作" align="center" class-name="small-padding fixed-width">
2023-10-26 13:52:13 +08:00
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="commodityDel(scope.row)"
>删除</el-button>
</template>
<!-- v-hasPermi="['']"-->
</el-table-column>
</el-table>
<!-- <pagination-->
<!-- v-show="total>0"-->
<!-- :total="total"-->
<!-- :page.sync="queryParams.page"-->
<!-- :limit.sync="queryParams.pageSize"-->
<!-- @pagination="getList"-->
<!-- />-->
</el-card>
2023-10-26 15:01:02 +08:00
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body :close-on-click-modal="false">
<el-container>
<el-header style="">
<el-form ref="tankForm" :model="commodityForm" label-width="80px">
<el-row :gutter="24">
<el-col :span="6">
<el-form-item label="商品分类">
2023-10-26 18:01:14 +08:00
<el-select
v-model="commodityForm.cvsGoodId"
placeholder="全部"
clearable
>
<el-option v-for="item in cvsGoodList" :key="item.id" :label="item.name" :value="item.id"/>
2023-10-26 15:01:02 +08:00
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
2023-10-26 18:01:14 +08:00
<el-form-item label="供应商" prop="supplierId">
<el-select
v-model="commodityForm.supplierId"
placeholder="全部"
clearable
>
<el-option v-for="item in supplierList" :key="item.id" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
2023-10-26 15:01:02 +08:00
</el-col>
<el-col :span="8">
<el-form-item label="详细信息">
2023-10-31 17:55:49 +08:00
<el-input v-model="commodityForm.remark" placeholder="商品名称,拼音码,条形码等信息" ></el-input>
2023-10-26 15:01:02 +08:00
</el-form-item>
</el-col>
<el-col :span="4">
<el-button type="primary" @click="inquire()">查询</el-button>
</el-col>
</el-row>
</el-form>
</el-header>
<el-main>
<el-table ref="tables"
v-loading="loading"
:data="commodityList"
@selection-change="handleSelectionChange"
border
:default-sort="defaultSort">
<el-table-column
type="selection"
width="55">
</el-table-column>
2023-10-26 18:01:14 +08:00
<el-table-column label="商品名称" align="center" prop="name"/>
<el-table-column label="商品编码" align="center" prop="goodsNo"/>
<el-table-column label="分类名称" prop="cvsGoodId" align="center">
<template slot-scope="scope">
<span>{{ getName(cvsGoodList, scope.row.cvsGoodId) }}</span>
</template>
</el-table-column>
<el-table-column label="供应商" prop="supplierId" align="center">
<template slot-scope="scope">
<span>{{ getName(supplierList, scope.row.supplierId) }}</span>
</template>
</el-table-column>
<el-table-column label="单位" align="center" prop="unit"/>
<el-table-column label="当前库存" align="center" prop="stock"/>
2023-10-26 15:01:02 +08:00
</el-table>
2023-10-31 17:55:49 +08:00
<!-- <pagination
v-show="commodityForm.total>0"
:total="commodityForm.total"
:page.sync="commodityForm.page"
:limit.sync="commodityForm.pageSize"
@pagination="getCommodityList"
/> -->
2023-10-26 15:01:02 +08:00
</el-main>
</el-container>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="addCommodity"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
2023-10-26 13:52:13 +08:00
</div>
</template>
<script>
import {getAuditPremApi} from "@/api/oilConfig/staff";
2023-10-28 17:12:18 +08:00
2023-10-26 15:01:02 +08:00
import {BigNumber} from "bignumber.js";
2023-10-26 18:01:14 +08:00
import {listLJGoods} from "@/api/convenienceStore/ljgoods";
import {getName,parseTime} from "../../../utils/fuint";
import {selectParentById, selectTree} from "@/api/convenienceStore/goods";
import {listSupplier} from "@/api/convenienceStore/supplier";
import {
getPurchaseDetailsPageApi,
delDetailsApi,
editPurchaseApi,
addPurchaseApi,
2023-10-28 17:12:18 +08:00
batchProcessingApi,
auditPurchaseApi,
storagePurchaseApi,
abolitionPurchaseApi,
2023-10-31 17:55:49 +08:00
exportExcelApi,
2023-10-26 18:01:14 +08:00
} from "@/api/convenienceStore/purchase";
2023-10-26 13:52:13 +08:00
export default {
name: "details",
2023-10-27 18:06:09 +08:00
props:[
'PpurchaseId',
'PorderNumber',
'PorderDate',
'PapprovalStatus'
],
2023-10-26 13:52:13 +08:00
data() {
return {
detailsList: [],
2023-10-26 15:01:02 +08:00
commodityList: [],
2023-10-26 18:01:14 +08:00
purchaseId:null,
2023-10-26 15:01:02 +08:00
commodityForm:{
cvsGoodId: "",
cvsGood: "",
supplierId: "",
supplier: "",
2023-10-26 18:01:14 +08:00
detailed: "",
2023-10-31 17:55:49 +08:00
remark: "",
2023-10-26 18:01:14 +08:00
page: 1,
2023-10-31 17:55:49 +08:00
pageSize: 1000,
total: 0,
2023-10-26 18:01:14 +08:00
isRecovery:0,
2023-10-26 13:52:13 +08:00
},
purchaseForm: {
2023-10-27 18:06:09 +08:00
orderNumber: null,
2023-10-26 13:52:13 +08:00
approvalStatus: "",
2023-10-27 18:06:09 +08:00
orderDate: null,
2023-10-26 13:52:13 +08:00
totalAmount: 0, //总金额
productQuantity: 0, //商品数量
quantityPurchased: 0 //进货数量
} ,
2023-10-26 18:01:14 +08:00
// 商品分类列表
cvsGoodList:[],
// 供应商列表
supplierList:[],
2023-10-26 15:01:02 +08:00
state:'await',
2023-10-26 13:52:13 +08:00
saveFlag:false,
auditFlag:false,
voidFlag:false,
2023-10-28 17:12:18 +08:00
storageFlag:false,
2023-10-26 15:01:02 +08:00
multipleSelection:[], // 表格
2023-10-26 13:52:13 +08:00
// 弹出框标题
2023-10-26 15:01:02 +08:00
title:'选择商品',
2023-10-26 13:52:13 +08:00
// 显示搜索条件
showSearch: true,
disableInput: false, // 默认不禁用
// 是否显示弹出层
open: false,
// 总条数
total: 0,
2023-10-31 17:55:49 +08:00
2023-10-26 13:52:13 +08:00
// 查询参数
queryParams: {
2023-10-28 17:12:18 +08:00
// supplierId: '',
purchaseId: null,
2023-10-31 17:55:49 +08:00
page:1,
pageSize:10000
2023-10-26 13:52:13 +08:00
},
// 遮罩层
loading: false,
// 默认排序
defaultSort: {prop: 'createTime', order: 'descending'},
// 表单校验
rules: {
supplierName: [
{ required: true, message: "供应商名称不能为空", trigger: "blur" },
],
},
}
},
async created() {
2023-10-27 18:06:09 +08:00
this.purchaseForm.purchaseId = this.$props.PpurchaseId
this.purchaseId = this.$props.PpurchaseId
2023-10-28 17:12:18 +08:00
this.queryParams.purchaseId = this.$props.PpurchaseId
2023-10-27 18:06:09 +08:00
this.purchaseForm.orderNumber = this.$props.PorderNumber
this.purchaseForm.orderDate = this.$props.PorderDate
this.purchaseForm.approvalStatus = this.$props.PapprovalStatus
this.state = this.$props.PapprovalStatus
console.log("this.purchaseForm",this.purchaseForm)
if ( this.state == null) {
this.state = 'await'
}
if (this.state=='await') {
this.numberInput = false
}else {
this.numberInput = true
}
2023-10-26 15:01:02 +08:00
if (this.purchaseForm.orderNumber == null) {
this.refresh();
}
2023-10-27 18:06:09 +08:00
if (this.purchaseForm.orderDate == null) {
this.purchaseForm.orderDate =new Date()
}
2023-10-26 18:01:14 +08:00
this.getDetailsList();
this.getQueryList();
2023-10-28 17:12:18 +08:00
this.JudgmentButton();
2023-10-26 13:52:13 +08:00
},
methods: {
2023-10-26 18:01:14 +08:00
getDetailsList() {
let this_ = this
2023-10-28 17:12:18 +08:00
getPurchaseDetailsPageApi(this.queryParams).then(res=>{
2023-10-26 18:01:14 +08:00
this_.detailsList = res.data.records;
this.total = res.data.total;
2023-10-27 18:06:09 +08:00
this.sumMethod(res.data.records);
2023-10-26 18:01:14 +08:00
})
},
getCommodityList() {
let this_ = this
listLJGoods(this_.commodityForm).then(res=>{
this_.commodityList = res.data.records;
2023-10-31 17:55:49 +08:00
this.commodityForm.total = response.data.total;
// this_.sumMethod(res.data.records);
2023-10-26 18:01:14 +08:00
})
},
2023-10-26 13:52:13 +08:00
// 页面跳转
goToAbout() {
2023-10-26 15:01:02 +08:00
this.$router.push('/convenienceStore/purchase/index');
2023-10-26 13:52:13 +08:00
},
commodityAdd() {
2023-10-26 15:01:02 +08:00
this.open = true;
2023-10-26 13:52:13 +08:00
},
2023-10-26 18:01:14 +08:00
commodityDel(data) {
2023-10-31 17:55:49 +08:00
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (data.id != null) {
delDetailsApi(data).then(res=>{
})
}
const index = this.detailsList.indexOf(data); // 查找要删除的对象的索引
if (index !== -1) {
this.detailsList.splice(index, 1); // 使用splice方法删除对象
}
2023-11-23 18:33:25 +08:00
this.sumMethod(this.detailsList);
2023-10-31 17:55:49 +08:00
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
2023-10-26 15:01:02 +08:00
},
// 查询商品
inquire() {
2023-10-26 18:01:14 +08:00
this.getCommodityList();
2023-10-26 15:01:02 +08:00
},
// 改变数字时
2023-10-26 18:01:14 +08:00
change(data,flag) {
let quantityPurchased = new BigNumber( data.quantityPurchased);
let unitPrice = new BigNumber( data.unitPrice);
let subtotalAmount = new BigNumber(data.subtotalAmount);
data.subtotalAmount = quantityPurchased.times(unitPrice)
if (flag == 3) {
data.unitPrice = subtotalAmount.dividedBy(quantityPurchased);
}
2023-10-27 18:06:09 +08:00
this.sumMethod(this.detailsList);
console.log("this.detailsList",this.detailsList)
2023-10-26 15:01:02 +08:00
// 进行保存
2023-10-26 18:01:14 +08:00
// this.detailsList = data
2023-10-26 15:01:02 +08:00
// this.edit()
},
// 计算header数据
sumMethod(data) {
2023-10-26 18:01:14 +08:00
let this_ = this
this_.purchaseForm.totalAmount = data.length
2023-10-27 18:06:09 +08:00
this_.purchaseForm.productQuantity = data.length,
this_.purchaseForm.totalAmount = new BigNumber(0),
2023-10-26 18:01:14 +08:00
this_.purchaseForm.quantityPurchased = new BigNumber(0),
2023-10-27 18:06:09 +08:00
2023-10-26 18:01:14 +08:00
data.forEach(da => {
if (da.unitPrice != null) {
2023-10-27 18:06:09 +08:00
this_.purchaseForm.quantityPurchased= this_.purchaseForm.quantityPurchased.plus(da.quantityPurchased)
2023-10-26 18:01:14 +08:00
}
if (da.subtotalAmount != null) {
2023-10-27 18:06:09 +08:00
this_.purchaseForm.totalAmount= this_.purchaseForm.totalAmount.plus(da.subtotalAmount)
2023-10-26 18:01:14 +08:00
}
})
2023-10-26 15:01:02 +08:00
},
addCommodity () {
let this_ = this
2023-10-31 17:55:49 +08:00
let sum = 0;
2023-10-26 15:01:02 +08:00
this.multipleSelection.forEach(mul=>{
2023-10-31 17:55:49 +08:00
let flag = true;
this_.detailsList.forEach(det=>{
if (mul.id == det.goodsId) {
flag = false
sum++
}
})
if(flag) {
let now = {
2023-10-26 18:01:14 +08:00
goodsId: mul.id,
commodityName: mul.name,
supplierId: mul.supplierId,
cvsGoodId: mul.cvsGoodId,
unit:mul.unit,
stock:mul.stock,
2023-10-31 17:55:49 +08:00
quantityPurchased: 1,
2023-10-26 18:01:14 +08:00
unitPrice: 0,
subtotalAmount: 0
2023-10-26 15:01:02 +08:00
}
2023-10-26 18:01:14 +08:00
this_.detailsList.push(now)
2023-10-31 17:55:49 +08:00
}
2023-10-26 15:01:02 +08:00
})
2023-10-31 17:55:49 +08:00
if(sum>0) {
this.$modal.msgError("同一退货单不能有两件相同的商品,您选择了"+sum+"件相同的商品,已为您剔除");
}
2023-10-26 15:01:02 +08:00
this_.open = false
2023-11-23 18:33:25 +08:00
this.multipleSelection = []
this.commodityForm = {
cvsGoodId: "",
cvsGood: "",
supplierId: "",
supplier: "",
detailed: "",
remark: "",
page: 1,
pageSize: 1000,
total: 0,
isRecovery:0,
}
this.commodityList = []
2023-10-26 15:01:02 +08:00
2023-10-26 18:01:14 +08:00
this_.sumMethod(this_.detailsList);
},
2023-10-26 15:01:02 +08:00
2023-10-26 18:01:14 +08:00
// 查询搜索列表信息
getQueryList(){
selectTree().then(response => {
this.cvsGoodList = response.data.records
});
listSupplier().then(response => {
this.supplierList = response.data.records
})
2023-10-26 15:01:02 +08:00
},
cancel() {
this.open = false;
},
// 表格选择器
handleSelectionChange(val) {
this.multipleSelection = val;
2023-10-26 13:52:13 +08:00
},
// 刷新订单编号
refresh() {
let timestamp = new Date().getTime();
2023-10-28 17:12:18 +08:00
let min = 100; // 最小的四位数是 100
let max = 999; // 最大的四位数是 999
2023-10-26 13:52:13 +08:00
let randomFourDigitNumber = Math.floor(Math.random() * (max - min + 1)) + min;
2023-10-26 15:01:02 +08:00
this.purchaseForm.orderNumber = timestamp+randomFourDigitNumber.toString();
2023-10-26 13:52:13 +08:00
},
2023-10-26 15:01:02 +08:00
2023-10-26 13:52:13 +08:00
// 判断按钮是否可用
async JudgmentButton(){
2023-10-28 17:12:18 +08:00
let judgmentPermissions1 = await this.judgmentPermissions("进货审核");
2023-10-26 13:52:13 +08:00
if (judgmentPermissions1 > 0){
2023-10-28 17:12:18 +08:00
this.auditFlag=false
// this.voidFlag=false
} else {
this.auditFlag=true
2023-10-26 13:52:13 +08:00
}
2023-10-28 17:12:18 +08:00
let judgmentPermissions2 = await this.judgmentPermissions("进货入库");
2023-10-26 13:52:13 +08:00
if (judgmentPermissions2 > 0){
this.storageFlag = false
2023-10-28 17:12:18 +08:00
}else {
this.storageFlag = true
2023-10-26 13:52:13 +08:00
}
2023-10-28 17:12:18 +08:00
let judgmentPermissions3 = await this.judgmentPermissions("进货废止");
2023-10-26 13:52:13 +08:00
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
});
},
2023-10-31 17:55:49 +08:00
2023-10-28 17:12:18 +08:00
async save(flag){
2023-10-26 18:01:14 +08:00
let this_ = this
2023-10-27 18:06:09 +08:00
// 保存之前进行判断
if (this_.purchaseForm.orderNumber == null) {
this.$modal.msgError("进货单号不能为空");
return -1;
}else if (this_.purchaseForm.orderDate == null) {
this.$modal.msgError("进货时间不能为空");
return -1;
}else if(this_.detailsList.length<=0) {
this.$modal.msgError("进货单不能为空");
return -1;
}
2023-10-26 18:01:14 +08:00
if (this_.purchaseId == null) {
// 新增
await addPurchaseApi(this_.purchaseForm).then(res=>{
this_.purchaseId = res.data.id
2023-10-28 17:12:18 +08:00
this.queryParams.purchaseId = res.data.id
2023-10-26 18:01:14 +08:00
}).catch(res=>{
2023-10-27 18:06:09 +08:00
this.$modal.msgError("保存失败");
2023-10-26 18:01:14 +08:00
return;
})
}else {
// 修改
2023-10-28 17:12:18 +08:00
this_.purchaseForm.id = this_.purchaseId
this.queryParams.purchaseId = this_.purchaseId
2023-10-26 18:01:14 +08:00
await editPurchaseApi(this_.purchaseForm).then(res=> {
}).catch(res=>{
2023-10-27 18:06:09 +08:00
this.$modal.msgError("保存失败");
2023-10-26 18:01:14 +08:00
return;
})
}
// 批量保存订单
2023-10-27 18:06:09 +08:00
this_.detailsList.forEach(data=>{
data.purchaseId = this_.purchaseId
})
2023-10-26 18:01:14 +08:00
await batchProcessingApi(this_.detailsList).then(res=>{
this.$modal.msgSuccess("保存成功");
2023-10-28 17:12:18 +08:00
if (flag == -1) {
this.goToAbout();
}
2023-10-27 18:06:09 +08:00
}).catch(res=>{
this.$modal.msgError("保存失败");
})
2023-10-26 13:52:13 +08:00
2023-10-26 15:01:02 +08:00
},
2023-10-26 13:52:13 +08:00
// 保存并审核
2023-10-28 17:12:18 +08:00
async audit(){
2023-10-26 13:52:13 +08:00
// 保存
2023-10-28 17:12:18 +08:00
let number = await this.save(-1);
2023-10-26 13:52:13 +08:00
if (number != -1) {
// 审核
let fil ={
2023-10-28 17:12:18 +08:00
id: this.purchaseId
2023-10-26 13:52:13 +08:00
}
2023-10-28 17:12:18 +08:00
console.log(" id: this.purchaseId1",fil)
await auditPurchaseApi(fil).then(res => {
if (res.data) {
this.state = 'ysh'
this.$modal.msgWarning("审核成功");
this.goToAbout()
} else {
this.$modal.msgWarning("暂无审核权限");
}
2023-10-26 13:52:13 +08:00
})
}
},
// 入库
2023-10-26 15:01:02 +08:00
storage() {
2023-10-26 13:52:13 +08:00
let this_ = this;
2023-10-28 17:12:18 +08:00
// 保存之前进行判断
if (this_.purchaseForm.orderNumber == null) {
this.$modal.msgError("进货单号不能为空");
return -1;
}else if (this_.purchaseForm.orderDate == null) {
this.$modal.msgError("进货时间不能为空");
return -1;
}else if(this_.detailsList.length<=0) {
this.$modal.msgError("进货单不能为空");
return -1;
2023-10-26 13:52:13 +08:00
}
2023-10-28 17:12:18 +08:00
2023-10-31 17:55:49 +08:00
this.$confirm('确认后进货中的对应商品入库,商品库存将发生变化,且不可逆,确认已按照进货数量入库吗?', '提示', {
2023-10-26 13:52:13 +08:00
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 审核
let fil ={
2023-10-28 17:12:18 +08:00
id: this.purchaseId
2023-10-26 13:52:13 +08:00
}
2023-10-28 17:12:18 +08:00
console.log("fil",fil)
storagePurchaseApi(fil).then(res => {
2023-10-26 13:52:13 +08:00
this.state = 'qrts'
this.$modal.msgWarning("入库成功");
2023-10-31 17:55:49 +08:00
this.goToAbout();
2023-10-26 13:52:13 +08:00
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
// 作废
abolition(){
2023-10-28 17:12:18 +08:00
if (this.PurchaseId < 0) {
2023-10-26 13:52:13 +08:00
this.$modal.msgWarning("数据未保存,不可废弃");
return;
}
2023-10-31 17:55:49 +08:00
this.$confirm('确定要废弃进货的数据吗', '提示', {
2023-10-26 13:52:13 +08:00
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let fil ={
2023-10-31 17:55:49 +08:00
id: this.purchaseId
2023-10-26 13:52:13 +08:00
}
2023-10-28 17:12:18 +08:00
abolitionPurchaseApi(fil).then(res => {
2023-10-26 13:52:13 +08:00
if (res.data) {
this.state = 'yzf'
this.$modal.msgWarning("作废成功");
this.goToAbout()
} else {
this.$modal.msgWarning("暂无作废权限");
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
})
},
2023-10-31 17:55:49 +08:00
// 导出
async exportExcel() {
let fil ={
purchaseId: this.purchaseId
}
exportExcelApi(fil).then(res=>{
console.log("res",res)
// this.downloadFile(res);
const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
this.$download.saveAs(blob,'库存统计.xLsx')
})
},
// downloadFile(blobData) {
// this.$down()
// // 创建一个 Blob 对象,并创建一个 URL用于下载文件
// const blob = new Blob([blobData], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
// const url = window.URL.createObjectURL(blob);
// const link = document.createElement('a');
// link.href = url;
// // 设置下载文件的名称
// link.setAttribute('download', 'exportedFile.xlsx');
// // 模拟点击链接进行下载
// link.click();
// },
2023-10-26 13:52:13 +08:00
}
}
</script>
<style scoped>
.app-container{
width: 100%;
height: 100%;
background: #f6f8f9;
}
2023-10-26 15:01:02 +08:00
.box {
height: 100%;
width: 50%;
margin-right: 10px;
background-color: rgba(204, 204, 204, 0.3);
border-radius: 10px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
2023-10-26 13:52:13 +08:00
</style>