文件
mashangyoujiu/Application/Retail/View/SPurchaseOrder/addPurchaseOrder.html

907 行
40 KiB
HTML
可执行文件

<!DOCTYPE html>
<html>
<!--[1.8.68]-->
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>新增采购单</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/vue/element-ui.css">
<link rel="stylesheet" href="/Public/css/component-serial.css?v=1.0.0">
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/vue/js/vue2.5.16.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/vue/element-ui.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Retail/common/js/select-goods-category.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Retail/common/js/select-supplier.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/jquery/js/jquery-3.2.1.min.js"></script>
<style>
.header-title {
font-size: 20px;
padding-right: 30px;
}
.must-edit {
color: red;
}
.form-textarea {
margin: 20px 0;
}
.form-button {
display: flex;
justify-content: flex-end;
}
.form-textarea-title {
margin-bottom: 20px;
}
.form-table-total {
margin: 10px 0;
}
.table-total {
text-align: right;
padding: 15px;
background: #f5f7fa;
color: #606266;
border: 1px solid #ebeef5;
border-top: none;
}
.table-total > span {
color: #409EFF;
}
.el-input-remote {
width: 140px;
}
.size-details {
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: space-between;
padding-bottom: 20px;
border-bottom: 1px solid #ebeef5;
margin-bottom: 20px;
}
.size-details-list {
box-sizing: border-box;
width: 45%;
display: flex;
align-items: center;
justify-content: space-between;
}
.size-input {
width: 120px;
}
.size-title {
padding: 10px;
background: #f5f7fa;
color: #606266;
border: 1px solid #ebeef5;
margin-bottom: 20px;
}
.size-footer {
display: flex;
align-items: center;
justify-content: space-between;
}
.size-all {
display: flex;
align-items: center;
}
.size-all-input {
width: 60px;
}
[v-cloak] {
display: none;
}
.el-dialog {
width: 90%;
}
th > .cell,
td > .cell {
text-align: center;
}
.layui-table {
width: 100%;
margin-bottom: 20px;
border: 1px solid #ebeef5;
border-radius: 5px;
padding: 10px 0;
}
.layui-table td {
text-align: center;
}
.mini-input .el-input__inner {
padding-right: 4px;
}
.el-form-cell-center {
margin-bottom: 0;
}
#goods .serial span.num {
display: block;
}
</style>
</head>
<body>
<div class="app" id="goods" v-cloak>
<div style="margin: 20px;">
<el-collapse accordion>
<el-collapse-item>
<template slot="title">
添加采购单须知>>></i>
</template>
<div>1.选择商品时,点击提交不会关闭弹框</div>
<div>2.确定添加采购单前须选择采购单类型,供应商和入库仓库</div>
</el-collapse-item>
</el-collapse>
</div>
<div class="text item" id="loading_examine">
<div style="display: flex;align-items: center;justify-content: space-between;flex-wrap: wrap">
<div>
<span class="must-edit">*</span>
<el-select size="small" v-model="type" placeholder="类型" clearable>
<el-option label="常规采购单" value="1"></el-option>
<el-option label="补采购单" value="2"></el-option>
</el-select>
<el-date-picker size="small" clearable v-if="type == 2" v-model="add_time"
value-format="yyyy-MM-dd HH:mm:ss" align="right" type="datetime" placeholder="日期"
:picker-options="pickerOptions">
</el-date-picker>
<span class="must-edit">*</span>
<select-store-supplier :supplier-id.sync="supplier_id"></select-store-supplier>
<span class="must-edit">*</span>
<el-select size="small" v-model="warehouse_id" placeholder="选择入库仓库" clearable>
<el-option v-for="item in warehouse" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
<if condition="$authArr['goodsChoice'] eq true">
<el-button size="small" @click="goodsChoice" type="primary">选择商品</el-button>
</if>
</div>
<div>
<el-input placeholder="采购批量数量" style="width:200px;" type="text" clearable size="small"
v-model="batch_stock_num"></el-input>
<el-button size="small" @click="batch_num" type="primary" plain>确定</el-button>
</div>
</div>
<div class="form-table">
<el-table :data="goodsList" size="small"
:header-cell-style="{background:'#F5F7FA',color:'#606266'}"
border show-summary :summary-method="getSummaries" v-loading="loading"
style="width: 100%; margin-top: 20px">
<el-table-column label="序号" type="index" width="80"></el-table-column>
<el-table-column label="操作" width="60">
<template slot-scope="scope">
<el-button type="text" size="mini" @click="deleteTable(scope.$index)">删除</el-button>
</template>
</el-table-column>
<el-table-column prop="goods_name" label="商品" width="120"></el-table-column>
<el-table-column prop="sku_name" label="规格"></el-table-column>
<el-table-column label="货号">
<template slot-scope="scope">
<span v-if="scope.row.attribute_state == 1">{{scope.row.goods_number}}</span>
<span v-if="scope.row.attribute_state == 2">{{scope.row.sku_goods_number}}</span>
</template>
</el-table-column>
<el-table-column label="条码" width="130">
<template slot-scope="scope">
<span v-if="scope.row.attribute_state == 1">{{scope.row.goods_code}}</span>
<span v-if="scope.row.attribute_state == 2">{{scope.row.sku_code}}</span>
<span></span>
</template>
</el-table-column>
<el-table-column prop="company" label="单位" width="80"></el-table-column>
<el-table-column label="生产日期" width="140">
<template slot-scope="scope">
<el-date-picker style="width:100px" class="mini-input" size="mini"
v-model="scope.row.build_date" type="date" value-format="yyyy-MM-dd"
size="small"
clearable>
</el-date-picker>
</template>
</el-table-column>
<el-table-column label="保质期(天)" width="88">
<template slot-scope="scope">
<div class="el-form-item el-form-cell-center"
@input="guaranteeVerification(scope.row.quality_guarantee_period)"
:class="color3?'':'is-error'">
<el-input size="mini" v-model="scope.row.quality_guarantee_period"></el-input>
</div>
</template>
</el-table-column>
<el-table-column prop="goods_num" label="可售库存" width="100">
<template slot-scope="scope" slot="header">
<el-popover placement="bottom" title="详解" width="100" trigger="hover" content="供给仓的商品库存">
<span slot="reference" size="mini">可售库存 <i class="el-icon-question"></i></span>
</el-popover>
</template>
</el-table-column>
<el-table-column label="采购数量">
<template slot-scope="scope">
<div class="el-form-item el-form-cell-center"
@input="numVerification(scope.row.purchase_num,scope.row.pricing_method,scope.row.purchase_price,scope.row.attribute_state,scope.$index)"
:class="color1?'':'is-error'" v-if="scope.row.serial_number_state != 1">
<el-input size="mini" v-model="scope.row.purchase_num"></el-input>
</div>
<div class="el-form-item el-form-cell-center serial" v-else>
<span class="num">{{scope.row.purchase_num}}</span>
<el-button type="text" size="mini" @click="insertSerial(scope.$index)">录入串码</el-button>
</div>
</template>
</el-table-column>
<el-table-column label="进货价" v-if="storeAuth.showpurch_price==1" width="120">
<template slot-scope="scope" slot="header">
<el-popover placement="bottom" title="详解" width="100" trigger="hover"
content="默认商品成本价(已经采购过的商品默认最近一次进货价)">
<span slot="reference" size="mini">进货价 <i class="el-icon-question"></i></span>
</el-popover>
</template>
<template slot-scope="scope">
<div class="el-form-item el-form-cell-center"
@input="priceVerification(scope.row.purchase_price,scope.row.purchase_num,scope.$index)"
:class="color2?'':'is-error'">
<el-input size="mini" v-model="scope.row.purchase_price"></el-input>
</div>
</template>
</el-table-column>
<el-table-column label="门店零售价" width="100" v-if="modify_price_state == 2">
<template slot-scope="scope">
<div class="el-form-item el-form-cell-center"
@input="retailPriceVerify(scope.row.retail_price,scope.$index)"
:class="color4?'':'is-error'">
<el-input size="mini" v-model="scope.row.retail_price"></el-input>
</div>
</template>
</el-table-column>
<el-table-column label="商城零售价" width="100" v-if="modify_price_state == 2">
<template slot-scope="scope">
<div class="el-form-item el-form-cell-center"
@input="onlinePriceVerify(scope.row.online_price,scope.$index)"
:class="color5?'':'is-error'">
<el-input size="mini" v-model="scope.row.online_price"></el-input>
</div>
</template>
</el-table-column>
<el-table-column label="生产批号" width="100" v-if="set_batch_number == 1">
<template slot-scope="scope">
<el-input size="mini" maxLength="32" v-model="scope.row.goods_batch_number"></el-input>
</template>
</el-table-column>
<el-table-column prop="subtotal" label="进货价小计" v-if="storeAuth.showpurch_price==1" width="100">
</el-table-column>
<el-table-column prop="remarks" label="备注">
<template slot-scope="scope">
<el-input type="textarea" v-model="scope.row.remarks"></el-input>
</template>
</el-table-column>
</el-table>
</div>
<div class="form-textarea">
<div class="form-textarea-title">订单备注</div>
<el-input type="textarea" :rows="2" placeholder="订单备注" v-model="remarks">
</el-input>
</div>
<div class="form-button">
<el-button @click="cancel">取消</el-button>
<if condition="$authArr['onSubmit'] eq true">
<el-button type="primary" @click="onSubmit">确定</el-button>
</if>
</div>
</div>
<!--/弹出框/-->
<el-dialog title="选择商品" :append-to-body="true" top="5vh" :visible.sync="outerVisible">
<div class="dialog-details-first">
<template>
<div style="display: flex;">
<el-input clearable size="small" style="margin-right: 20px;" class="el-input-remote"
clearable
@keydown.enter.exact.native.prevent="searchGoods"
v-model="searchText" placeholder="名称/货号/条码">
</el-input>
<select-goods-category :user-type="2"
:store-id="store_id"
:category-id1.sync="goodsClassId1"
:category-id2.sync="goodsClassId2"
:category-id3.sync="goodsClassId3"></select-goods-category>
<el-button size="small" type="primary" plain @click="searchGoods" size="small">搜索
</el-button>
</div>
</template>
</div>
<template>
<el-table v-loading="loading" size="small"
:header-cell-style="{background:'#F5F7FA',color:'#606266'}"
:data="goodsArr" border @selection-change="handleSelectionChange"
style="width: 100%; margin-top: 20px">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column label="" type="index" width="80"></el-table-column>
<el-table-column prop="goods_name" label="商品名称"></el-table-column>
<el-table-column prop="sku_name" label="规格名称"></el-table-column>
<el-table-column label="货号">
<template slot-scope="scope">
<span v-if="scope.row.attribute_state == 1">{{scope.row.goods_number}}</span>
<span v-if="scope.row.attribute_state == 2">{{scope.row.sku_goods_number}}</span>
</template>
</el-table-column>
<el-table-column label="条码">
<template slot-scope="scope">
<span v-if="scope.row.attribute_state == 1">{{scope.row.goods_code}}</span>
<span v-if="scope.row.attribute_state == 2">{{scope.row.sku_code}}</span>
</template>
</el-table-column>
<el-table-column prop="goods_num" label="可售库存"></el-table-column>
<el-table-column prop="company" label="单位"></el-table-column>
<!-- <el-table-column prop="sku_kinds" label="数量">
<template slot-scope="scope">
<el-input size="mini" v-model="scope.row.purchase_num"></el-input>
</template>
</el-table-column>-->
</el-table>
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="currentPage" :page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
:page-size="100" layout="total, sizes, prev, pager, next, jumper" :total="currentLen">
</el-pagination>
</template>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="goodsSub(1)">提交</el-button>
<el-button @click="goodsSub(2)">提交并关闭</el-button>
</div>
</el-dialog>
<component-serial :visible.sync="serialVisible" dialog-type="insert" :parent-index="serialGoodsIndex"
:parent-data="serialGoodsData" :data="serialData" insert-validate="storePurchase"
@serial-change="serialChange"></component-serial>
</div>
</body>
<script src="/Public/js/component-serial.js?v=1.0.1"></script>
<script src="/Public/js/common.js"></script>
<script>
new Vue({
el: "#goods",
data: {
store_id: localStorage.store_id,
set_batch_number: "{$set_batch_number}",//是否能设置批号 1开启 2关闭
modify_price_state: "",
batch_stock_num: "",
type: "",
add_time: "",
color: true,
supplier_id: "",
warehouse: {$warehouse},
warehouse_id: "",
searchText: "",
goodsClassId1: "",
goodsClassId2: "",
goodsClassId3: "",
goodsArr: [], //商品档案信息
currentPage: 1,
currentLimit: 10,
currentLen: 0,
skuAttr: [], //规格信息
skuList: [],
sku_num_batch: "", //规格批量数量
goods_index: "", //选择规格的商品index
color1: true,
color2: true,
color3: true,
color4: true,
color5: true,
remarks: '',
num: 1,
size: true,
outerVisible: false,
innerVisible: false, //规格弹框
goodsList: [],
goodsSelection: [], //选中的商品
loading: false,
serialVisible: false, //串号录入窗口开关
serialGoodsIndex: 0, //串号录入当前商品索引
serialGoodsData: {}, //串号录入当前商品数据对象
serialData: [] //串号容器
},
methods: {
//初始化数据
basics: function () {
var that = this;
$.ajax({
url: "{:U('addPurchaseOrderBasics')}",
type: "post",
data: {},
success: function (res) {
if (res.status == 1) {
that.modify_price_state = res.data.inventory_set.modify_price_state;
} else {
that.$message.error(res.message);
}
}
})
},
//批量设置
batch_num: function () {
var that = this;
var reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,3})?$/;
var batch_stock_num = that.batch_stock_num;
var goodsList = that.goodsList;
if (!batch_stock_num || !reg.test(batch_stock_num)) {
that.$message.error("请输入正确数量");
return;
}
if (goodsList.length > 0) {
for (var i = 0; i < goodsList.length; i++) {
goodsList[i].purchase_num = batch_stock_num;
}
} else {
that.$message.error("请选择商品");
}
},
//选中的入库商品
handleSelectionChange: function (data) {
var that = this;
that.goodsSelection = data;
},
//选择商品
goodsChoice: function () {
var that = this;
that.outerVisible = true;
that.getData();
},
//搜索
searchGoods: function () {
this.currentPage = 1;
this.getData();
},
//商品
getData: function () {
this.loading = true;
var goodsList = this.goodsList;
var exists_id_arr = [];
if (goodsList.length > 0) {
for (var i = 0; i < goodsList.length; i++) {
exists_id_arr.push(goodsList[i].id);
}
}
$.ajax({
url: "{:U(goodsList)}",
type: 'POST',
data: {
page: this.currentPage,
limit: this.currentLimit,
modify_price_state: this.modify_price_state,
exists_id_arr: exists_id_arr,
search_info: this.searchText,
person1: this.goodsClassId1,
person2: this.goodsClassId2,
person3: this.goodsClassId3
},
success: (res) => {
if (res.status == 1) {
this.loading = false;
this.goodsArr = [];
this.goodsArr = res.data.list;
this.$nextTick(function () {
this.currentLen = parseInt(res.data.count);
})
} else {
this.$confirm(res.msg, '提示', {
confirmButtonText: '确定',
type: 'warning'
}).then(() => {
}).catch(() => {
});
}
}
});
},
//分页
handleSizeChange(val) {
this.currentLimit = val;
this.currentPage = 1;
this.getData();
},
handleCurrentChange(val) {
this.currentPage = val;
this.getData();//切换页数
},
//商品提交
goodsSub: function (type) {
var that = this;
var goodsArr = that.goodsSelection;
var goodsList = JSON.parse(JSON.stringify(that.goodsList));
var reg2 = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,3})?$/;
var reg3 = /^\+?[1-9][0-9]*$/;
if (goodsArr.length <= 0) {
that.$message({
type: "warning",
message: "请选择采购商品",
duration: 1000
})
return;
}
for (var i = 0; i < goodsArr.length; i++) {
goodsArr[i].subtotal = (goodsArr[i].purchase_price * goodsArr[i].purchase_num).toFixed(2);
goodsArr[i].remarks = ""; //备注
goodsList.unshift(goodsArr[i]);
}
that.goodsList = [];
that.goodsList = goodsList;
if (goodsList.length >= 400) {
that.$message({
type: "warning",
message: "采购的商品种数已达上限建议立即提交",
duration: 2000
})
}
if (type == 2) {
that.outerVisible = false
} else {
that.searchGoods();
}
},
//保质期
guaranteeVerification(quality_guarantee_period) {
if (quality_guarantee_period) {
var reg = /^[0-9]*[1-9][0-9]*$/;
if (!reg.test(quality_guarantee_period)) {
this.color3 = false;
} else {
this.color3 = true;
}
}
},
//门店零售价
retailPriceVerify: function (price, index) {
var reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/;
if (!reg.test(price)) {
this.color4 = false;
} else {
this.color4 = true;
}
},
//商城零售价
onlinePriceVerify: function (price, index) {
var reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/;
if (!reg.test(price)) {
this.color5 = false;
} else {
this.color5 = true;
}
},
//数量
numVerification: function (num, pricing_method, price, attribute_state, index) {
if (pricing_method == 2 && attribute_state == 1) {
var reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,3})?$/;
} else {
var reg = /^\+?[1-9][0-9]*$/;
}
if (!reg.test(num)) {
this.subtotalCalculation(price, num, index);
this.color1 = false;
} else {
this.subtotalCalculation(price, num, index);
this.color1 = true;
}
},
//进货价
priceVerification: function (price, num, index) {
var reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/;
if (!reg.test(price)) {
this.subtotalCalculation(price, num, index);
this.color2 = false;
} else {
this.subtotalCalculation(price, num, index);
this.color2 = true;
}
},
//计算单个商品的小计
subtotalCalculation: function (price, num, index) {
var that = this;
var reg = /^[0-9]+.?[0-9]*$/;
if (!reg.test(price) || !reg.test(num)) {
that.goodsList[index].subtotal = "";
return;
}
var subtotal = price * num * 1;
that.goodsList[index].subtotal = subtotal.toFixed(2);
},
deleteTable: function (index) {
this.goodsList.splice(index, 1);
},
cancel: function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
},
onSubmit: function () {
var that = this;
var goods_id = [];
var goodsList = that.goodsList;
var supplier_id = that.supplier_id;
var warehouse_id = that.warehouse_id;
var remarks = that.remarks;
var type = that.type;
var add_time = that.add_time;
var modify_price_state = that.modify_price_state;
var reg1 = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/;
var reg2 = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,3})?$/;
var reg3 = /^\+?[1-9][0-9]*$/;
if (!type) {
that.$message({type: "error", message: "请选择采购类型", duration: 1000})
return;
}
if (type == 2) {
if (!add_time) {
that.$message({type: "error", message: "请选择补采购单至日期", duration: 1000})
return;
}
}
if (!supplier_id) {
that.$message({type: "error", message: "请选择供货商", duration: 1000})
return;
}
if (!warehouse_id) {
that.$message({type: "error", message: "请选择仓库", duration: 1000})
return;
}
if (!goodsList || goodsList.length == 0) {
that.$message({type: "error", message: "请选择商品", duration: 1000})
return;
}
for (var i = 0; i < goodsList.length; i++) {
if (goods_id.includes(goodsList[i].id)) {
that.$message({type: "error", message: goodsList[i].goods_name + "存在重复", duration: 1000})
return;
}
goods_id.push(goodsList[i].id);
if (!goodsList[i].purchase_price) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确价格",
duration: 1000
})
return;
}
if (!goodsList[i].purchase_num) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确数量",
duration: 1000
})
return;
}
if (goodsList[i].purchase_num == 0) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确数量",
duration: 1000
})
return;
}
if (!reg1.test(goodsList[i].purchase_price)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确价格",
duration: 1000
})
return;
}
if (modify_price_state == 2) {
//开启采购修改售价
if (goodsList[i].retail_price && !reg1.test(goodsList[i].retail_price)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确店内零售价",
duration: 2000
})
return;
}
if (goodsList[i].online_price && !reg1.test(goodsList[i].online_price)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确商城零售价",
duration: 2000
})
return;
}
}
if (goodsList[i].attribute_state == 1) {
//无规格
if (goodsList[i].pricing_method == 1) {
if (!reg3.test(goodsList[i].purchase_num)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + "请输入正确数量",
duration: 1000
})
return;
}
} else {
if (!reg2.test(goodsList[i].purchase_num)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + "请输入正确数量",
duration: 1000
})
return;
}
}
} else if (goodsList[i].attribute_state == 2) {
if (!reg3.test(goodsList[i].purchase_num)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确数量",
duration: 1000
})
return;
}
}
}
that.$confirm('请确认采购商品信息无误,提交后无法修改,是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const loading_examine = that.$loading({
target: "#loading_examine",
lock: true,
text: '保存中,请等待',
spinner: 'el-icon-loading',
background: 'rgba(255, 255, 255, 0.7)'
});
goodsList = JSON.stringify(goodsList);
$.ajax({
url: "{:U('purchaseOperation')}",
type: "post",
data: {
goodsList: goodsList,
supplier_id: supplier_id,
warehouse_id: warehouse_id,
remarks: remarks,
type: type,
add_time: add_time,
modify_price_state:modify_price_state
},
success: function (res) {
if (res.status == 1) {
that.$message({
type: "success",
message: res.msg,
duration: 1000,
onClose: function () {
loading_examine.close();
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
}
})
} else {
that.$message({
type: "error",
message: res.msg,
duration: 3000,
onClose: function () {
loading_examine.close();
}
})
}
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
getSummaries: function (param) {
const {columns, data} = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
return;
}
const values = data.map(item => Number(item[column.property]));
if (index === 2) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] = param.data.length + ' 种';
}
if (this.storeAuth.showpurch_price == 1) {
if (index === 11) {
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return parseFloat((prev + curr).toFixed(2));
} else {
return prev;
}
}, 0);
sums[index] += ' 元';
} else {
sums[index] = '';
}
}
}
});
return sums;
},
/**
* @description: 打开串号录入窗口
* @param {Number} index: 当前商品索引
*/
insertSerial(index) {
this.serialVisible = true
this.serialGoodsIndex = index
this.serialGoodsData = this.goodsList[index]
this.serialData = []
const serialList = this.goodsList[index].serial_list
if (serialList && typeof serialList == 'object' && serialList.length > 0) {
serialList.forEach(serial => {
this.serialData.push({
mainSerial: serial.main_serial_number,
assistSerial1: serial.auxiliary_serial_number_one,
assistSerial2: serial.auxiliary_serial_number_two
})
})
}
// console.log(this.serialGoodsIndex)
// console.log(this.serialGoodsData)
},
/**
* @description: 串号子组件通道
* @param {Array} datas: 串号数据
* @param {Number} goodsIndex: 当前采购的商品索引
*/
serialChange(datas, goodsIndex) {
const serialList = []
datas.forEach(data => {
serialList.push({
main_serial_number: data.mainSerial,
auxiliary_serial_number_one: data.assistSerial1,
auxiliary_serial_number_two: data.assistSerial2
})
})
const goods = this.goodsList[goodsIndex]
goods.serial_list = serialList
this.$set(goods, 'purchase_num', serialList.length)
this.numVerification(goods.purchase_num, goods.pricing_method, goods.purchase_price, goods.attribute_state, goodsIndex)
}
},
created: function () {
this.basics();
}
})
</script>
</html>