文件

741 行
30 KiB
HTML
可执行文件

<!DOCTYPE html>
<html>
<!--[1.8.59]-->
<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__/jquery/js/jquery-3.2.1.min.js"></script>
</head>
<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>
<style>
.clearfix {
display: flex;
align-items: center;
}
.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;
}
.details-all {
padding: 10px;
background: #f5f7fa;
color: #606266;
border: 1px solid #ebeef5;
border-top: none;
margin-bottom: 20px;
}
.details-all-lists {
font-size: 14px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
width: 100%;
}
.details-all-list {
width: 33%;
}
.el-date-editor.el-input {
width: 135px;
}
#goods .el-table .el-form-item {
margin-bottom: 0;
}
#goods .serial span.num {
display: block;
}
</style>
<body>
<div class="app" id="goods" v-cloak>
<div class="text item" id="loading_examine">
<div class="details-all">
<div class="details-all-lists">
<div class="details-all-list">
调拨单号:<span>{{order_number}}</span>
</div>
<div class="details-all-list">
供应商:<span>{{supplier}}</span>
</div>
<div class="details-all-list">
入库仓库:<span>{{warehouse}}</span>
</div>
<div class="details-all-list">
创建时间:<span>{{add_time}}</span>
</div>
<div class="details-all-list">
合计:<span>{{goods_species}}种</span>
</div>
<div class="details-all-list" v-if="showPrice != 2 || identity == 1">
金额:<span>{{money_total}}</span>
</div>
</div>
</div>
<div class="form-table">
<el-table :data="goodsList" border show-summary v-loading="loading" :summary-method="getSummaries"
style="width: 100%; margin-top: 20px">
<el-table-column label="" type="index" width="80"></el-table-column>
<el-table-column label="操作">
<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_number" label="货号"></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 prop="sku_goods_number" label="规格货号"></el-table-column>
<el-table-column prop="company" label="单位"></el-table-column>
<el-table-column label="生产日期" width="156">
<template slot-scope="scope">
<el-date-picker size="small" 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" @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="stock_num" label="辅助数量"></el-table-column>
<el-table-column label="入库数量">
<template slot-scope="scope">
<div class="el-form-item"
@input="numVerification(scope.row.warehouse_num,scope.row.pricing_method,scope.row.warehouse_price,scope.$index)"
:class="color1?'':'is-error'" v-if="scope.row.serial_number_state != 1">
<el-input size="mini" v-model="scope.row.warehouse_num"></el-input>
</div>
<div class="serial" v-else>
<span class="num" v-if="scope.row.warehouse_num > 0">{{scope.row.warehouse_num}}</span>
<el-button type="text" size="mini" @click="selectSerial(scope.$index)">选择串码</el-button>
</div>
</template>
</el-table-column>
<el-table-column label="参考调拨价" v-if="showPrice != 2 || identity == 1">
<template slot-scope="scope">
<div class="el-form-item"
@input="priceVerification(scope.row.warehouse_price,scope.row.warehouse_num,scope.$index)"
:class="color2?'':'is-error'" v-if="allocation_state != 2">
<el-input size="mini" v-model="scope.row.warehouse_price"></el-input>
</div>
<div v-if="allocation_state == 2">
{{scope.row.warehouse_price}}
</div>
</template>
</el-table-column>
<el-table-column prop="subtotal" label="小计" v-if="showPrice != 2 || identity == 1">
</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>
<component-serial :visible.sync="serialVisible" dialog-type="multiple" :parent-index="serialGoodsIndex"
:parent-data="serialGoodsData" :data="serialData" @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: {
allocation_state: "{$allocation_state}",
showPrice: "{$showPrice}",
identity: "{$identity}",
id: "{$id}",
type: "{$type}",
supplier: "{$supplier}",
order_number: "{$info['order_number']}",
warehouse: "{$warehouse['name']}",
warehouse_id: "{$warehouse['id']}",
add_time: "{$info['add_time']}",
goods_species: "{$info['goods_species']}",
money_total: "{$info['money_total']}",
color: true,
searchText: "",
color1: true,
color2: true,
color3: true,
remarks: '',
num: 1,
size: true,
goodsList: [],
refuse_list: [], //拒收的商品
loading: false,
serialVisible: false, //串号录入窗口开关
serialGoodsIndex: 0, //串号录入当前商品索引
serialGoodsData: {}, //串号录入当前商品数据对象
serialData: [] //串号容器
},
methods: {
cancel: function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
},
//调拨的商品
getData: function () {
this.loading = true;
$.ajax({
url: "{:U(allocationList)}",
type: 'POST',
data: {
id: this.id,
type: this.type
},
success: (res) => {
if (res.status == 1) {
this.loading = false;
this.goodsList = [];
this.goodsList = res.data;
} else {
this.$confirm(res.msg, '提示', {
confirmButtonText: '确定',
type: 'warning'
}).then(() => {
}).catch(() => {
});
}
}
});
},
//保质期
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;
}
}
},
//数量
numVerification: function (num, pricing_method, price, index) {
if (pricing_method == 2) {
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[index].warehouse_num = 0;
this.refuse_list.push(this.goodsList[index]);
this.goodsList.splice(index, 1);
},
onSubmit: function () {
var that = this;
var id = that.id;
var type = that.type;
var order_number = that.order_number;
var goodsList = that.goodsList;
var warehouse_id = that.warehouse_id;
var remarks = that.remarks;
var refuse_goods = [];
var refuse_list = that.refuse_list;
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 (!warehouse_id) {
that.$message({type: "error", message: "请选择仓库", duration: 1000})
return;
}
if (!goodsList) {
that.$message({type: "error", message: "请选择商品", duration: 1000})
return;
}
for (var i = 0; i < goodsList.length; i++) {
if (goodsList[i].quality_guarantee_period && !reg3.test(goodsList[i].quality_guarantee_period)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确保质期",
duration: 1000
})
return;
}
if (!goodsList[i].warehouse_price) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确价格",
duration: 1000
})
return;
}
if (!goodsList[i].warehouse_num) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确数量",
duration: 1000
})
return;
}
if (!reg1.test(goodsList[i].warehouse_price)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "请输入正确价格",
duration: 1000
})
return;
}
if (goodsList[i].attribute_state == 1) {
//无规格
if (goodsList[i].pricing_method == 1) {
if (!reg3.test(goodsList[i].warehouse_num)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + "请输入正确数量",
duration: 1000
})
return;
}
} else {
if (!reg2.test(goodsList[i].warehouse_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].warehouse_num)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "规格商品数量为整数",
duration: 1000
})
return;
}
}
if (parseFloat(goodsList[i].warehouse_num) > parseFloat(goodsList[i].stock_num)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + "入库量不能大于调拨辅助最大数量",
duration: 1000
})
return;
}
if ((parseFloat(goodsList[i].stock_num) - parseFloat(goodsList[i].warehouse_num)) > 0) {
const goods = JSON.parse(JSON.stringify(goodsList[i]))
const refuseSerialList = []
const serial_list = []
if (goods.original_serial_list) {
goods.serial_list.forEach(serial => {
serial_list.push(serial.main_serial_number)
})
goods.original_serial_list.forEach(serial => {
serial_list.includes(serial.main_serial_number) || refuseSerialList.push(serial)
})
delete goods.original_serial_list
goods.serial_list = refuseSerialList
}
refuse_goods.push(goods);
}
//删除原始串号
goodsList[i].original_serial_list && delete goodsList[i].original_serial_list
}
if (refuse_goods.length > 0) {
refuse_list = refuse_list.concat(refuse_goods);
}
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);
refuse_list = JSON.stringify(refuse_list);
//先验证商品信息
$.ajax({
url: "{:U('goodsVerify')}",
type: "post",
data: {
goodsList: goodsList,
id: id,
},
success: function (res) {
if (res.status == 1) {
that.Operation(goodsList, warehouse_id, remarks, id, type, order_number, refuse_list);
} else if (res.status == 3) {
loading_examine.close();
that.$confirm(res.msg + '是否继续?', '提示', {
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)'
});
$.ajax({
url: "{:U('batchSync')}",
type: "post",
data: {goodsIds: res.goodsIds, type: type, id: id},
success: function (tes) {
if (tes.status == 1) {
that.Operation(goodsList, warehouse_id, remarks, id, type, order_number, refuse_list);
} else {
that.$message({
type: "error",
message: res.msg,
duration: 3000,
onClose: function () {
loading_examine.close();
}
})
}
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消',
duration: 1000,
onClose: function () {
loading_examine.close();
}
});
});
} else {
that.$message({
type: "error",
message: res.msg,
duration: 3000,
onClose: function () {
loading_examine.close();
}
})
}
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消',
onClose: function () {
loading_examine.close();
}
});
});
},
Operation: function (goodsList, warehouse_id, remarks, id, type, order_number, refuse_list) {
var that = this;
const loading_examine = that.$loading({
target: "#loading_examine",
lock: true,
text: '保存中,请等待',
spinner: 'el-icon-loading',
background: 'rgba(255, 255, 255, 0.7)'
});
$.ajax({
url: "{:U('allocationOperation')}",
type: "post",
data: {
goodsList: goodsList,
warehouse_id: warehouse_id,
remarks: remarks,
id: id,
type: type,
order_number: order_number,
refuse_list: refuse_list
},
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: 2000,
onClose: function () {
loading_examine.close();
}
})
}
}
})
},
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 (index === 10) {
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: 当前商品索引
*/
selectSerial(index) {
this.serialVisible = true
this.serialGoodsIndex = index
this.serialGoodsData = this.goodsList[index]
this.serialData = []
let serialList = this.goodsList[index].original_serial_list
if (!serialList) {
serialList = this.goodsList[index].serial_list
this.goodsList[index].original_serial_list = serialList
}
if (serialList && typeof serialList == 'object' && serialList.length > 0) {
serialList.forEach(serial => {
this.serialData.push({
id: serial.id,
mainSerial: serial.main_serial_number,
assistSerial1: serial.auxiliary_serial_number_one,
assistSerial2: serial.auxiliary_serial_number_two
})
})
}
},
/**
* @description: 串号子组件通道
* @param {Array} datas: 串号数据
* @param {Number} goodsIndex: 当前采购的商品索引
*/
serialChange(datas, goodsIndex) {
const serialList = []
datas.forEach(data => {
serialList.push({
id: data.id,
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, 'warehouse_num', serialList.length)
this.numVerification(goods.warehouse_num, goods.pricing_method, goods.warehouse_price, goodsIndex)
}
},
created: function () {
this.getData();
}
})
</script>
</html>