文件
mashangyoujiu/Application/Retail/View/SModifyPriceOrder/addModifyPrice.html

648 行
25 KiB
HTML
可执行文件

<!DOCTYPE html>
<html>
<!--[1.7.14]-->
<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">
<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;
}
</style>
<body>
<div class="app" id="goods" v-cloak>
<div class="text item" id="loading_examine">
<div style="display: flex">
<span class="must-edit">*</span>
<el-select v-model="type" placeholder="请选择类型"
@change="typeSelect"
size="small"
clearable
style="margin-right:20px">
<el-option label="初始化入库" value="1"></el-option>
<el-option label="采购批次号" value="2"></el-option>
<el-option label="其他入库" value="3"></el-option>
</el-select>
<el-input placeholder="修改单号"
clearable
type="text"
size="small"
v-model="modify_order_number" style="width:220px;margin-right: 20px"></el-input>
<if condition="$authArr['goodsChoice'] eq true">
<el-button size="small" @click="goodsChoice">选择商品</el-button>
</if>
</div>
<div class="form-table">
<el-table
:data="goodsList"
border
v-loading="loading"
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_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 prop="goods_code" 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="company" label="单位"></el-table-column>
<el-table-column prop="purchase_price" label="原进价"
v-if="showPrice != 2 || identity == 1"></el-table-column>
<el-table-column label="进价">
<template slot-scope="scope">
<div class="el-form-item" @input="priceVerification(scope.row.cost_price)"
:class="color1?'':'is-error'">
<el-input size="mini" v-model="scope.row.cost_price "></el-input>
</div>
</template>
</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>
<!--/弹出框/-->
<div class="dialog-details">
<template>
<el-dialog title="选择商品" :modal-append-to-body="false" :visible.sync="outerVisible">
<div class="dialog-details-first">
<template>
<div style="display: flex;">
<el-input
style="margin-right: 20px;width: 200px"
class="el-input-remote"
v-model="searchText"
placeholder="名称/货号/条码">
</el-input>
<el-select filterable clearable v-if="goodsClass1.length"
@change="changeGoodsClass1($event)"
v-model="goodsClassId1" placeholder="请选择一级分类">
<el-option key="0" value="0" label="请选择一级分类"></el-option>
<el-option
v-for="item in goodsClass1"
:key="item.id"
:label="item.class_name"
:value="item.id">
</el-option>
</el-select>
<el-select filterable clearable v-if="goodsClass2.length"
@change="changeGoodsClass2($event)"
v-model="goodsClassId2" placeholder="请选择二级分类">
<el-option key="0" value="0" label="请选择二级分类"></el-option>
<el-option
v-for="item in goodsClass2"
:key="item.id"
:label="item.class_name"
:value="item.id">
</el-option>
</el-select>
<el-select filterable clearable v-if="goodsClass3.length"
@change="changeGoodsClass3($event)"
v-model="goodsClassId3" placeholder="请选择三级分类">
<el-option key="0" value="0" label="请选择三级分类"></el-option>
<el-option
v-for="item in goodsClass3"
:key="item.id"
:label="item.class_name"
:value="item.id">
</el-option>
</el-select>
<el-button type="primary" plain @click="searchGoods" size="small">搜索</el-button>
</div>
</template>
</div>
<template>
<el-table
: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 prop="index" 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 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 prop="goods_code" 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="company" label="单位"></el-table-column>
<el-table-column prop="cost_price" label="进价"
v-if="showPrice != 2 || identity == 1"></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>
</template>
</div>
</div>
</body>
<script>
new Vue({
el: "#goods",
data: {
showPrice: "{$showPrice}",
identity: "{$identity}",
type: '',
modify_order_number: '',
color: true,
searchText: "",
status: "",
stock_status: "",
goodsClass1: {$goodsClass1},
goodsClass2: [],
goodsClass3: [],
goodsClassId1: "",
goodsClassId2: "",
goodsClassId3: "",
goodsArr: [], //商品档案信息
currentPage: 1,
currentLimit: 10,
currentLen: 0,
color1: true,
color2: true,
remarks: '',
num: 1,
size: true,
outerVisible: false,
innerVisible: false, //规格弹框
goodsList: [],
goodsSelection: [], //选中的商品
loading: false,
},
methods: {
//下拉框事件
typeSelect: function () {
this.goodsList = [];
this.goodsSelection = [];
this.goodsClassId1 = "";
this.goodsClassId2 = "";
this.goodsClassId3 = "";
this.searchText = "";
this.page = 1;
this.limit = 10;
this.modify_order_number = '';
},
//选择商品
goodsChoice: function () {
var type = this.type;
var modify_order_number = this.modify_order_number;
if (type == '') {
this.$message({
type: 'error',
message: '请选择类型',
duration: 1000
})
return;
}
if ((type == 2 || type == 3) && modify_order_number == '') {
this.$message({
type: 'error',
message: '请输入修改的订单号',
duration: 1000
})
return;
}
this.outerVisible = true;
this.getData();
},
//调价商品搜索
searchGoods: function () {
this.currentPage = 1;
this.getData();
},
//调价商品
getData: function () {
var that = this;
var type = that.type;
var modify_order_number = that.modify_order_number;
var status = that.status;
var stock_status = that.stock_status;
var goodsList = that.goodsList;
var notInIds = [];
if (goodsList.length > 0) {
for (var i = 0; i < goodsList.length; i++) {
notInIds.push(goodsList[i].id);
}
}
$.ajax({
url: "{:U(goodsList)}",
type: 'POST',
data: {
type: type,
modify_order_number: modify_order_number,
notInIds: notInIds,
searchText: this.searchText,
person1: this.goodsClassId1,
person2: this.goodsClassId2,
person3: this.goodsClassId3,
page: this.currentPage,
limit: this.currentLimit,
},
success: function (res) {
if (res.status == 1) {
that.loading = false;
that.goodsArr = [];
that.goodsArr = res.data;
that.$nextTick(function () {
that.currentLen = parseInt(res.count);
})
} else {
that.$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();
},
//分类
getGoodsClass: function (id, type) {
var that = this;
$.post("{:U('Sale/getChildClass')}", {
id: id,
type: type
}, function (res) {
if (res.status == 1) {
switch (type) {
case 2:
that.goodsClass2 = [];
that.goodsClass2 = res.data;
that.goodsClassId2 = '';
that.goodsClass3 = [];
that.goodsClassId3 = '';
break;
case 3:
that.goodsClass3 = [];
that.goodsClass3 = res.data;
that.goodsClassId3 = '';
break;
}
} else {
switch (type) {
case 2:
that.goodsClass2 = [];
that.goodsClassId2 = '';
that.goodsClass3 = [];
that.goodsClassId3 = '';
break;
case 3:
that.goodsClass3 = [];
that.goodsClassId3 = '';
break;
}
}
})
},
changeGoodsClass1: function (val) {
if (val == 0) {
this.goodsClass2 = [];
this.goodsClassId2 = '';
this.goodsClass3 = [];
this.goodsClassId3 = '';
} else {
this.getGoodsClass(val, 2);
}
},
changeGoodsClass2: function (val) {
if (val == 0) {
this.goodsClass3 = [];
this.goodsClassId3 = '';
} else {
this.getGoodsClass(val, 3);
}
},
changeGoodsClass3: function (val) {
if (val == 0) {
this.goodsClassId3 = '';
}
},
//选中的调价商品
handleSelectionChange: function (data) {
var that = this;
that.goodsSelection = data;
},
//商品提交
goodsSub: function (type) {
var that = this;
var goodsSelection = JSON.parse(JSON.stringify(that.goodsSelection));
var goodsList = that.goodsList;
if (!goodsSelection || goodsSelection.length == 0) {
that.$message({type: "error", message: "请选择调价的商品", duration: 1000})
return;
}
for (var i = 0; i < goodsSelection.length; i++) {
goodsSelection[i].remarks = "";
goodsSelection[i].purchase_price = goodsSelection[i].cost_price;
goodsList.push(goodsSelection[i]);
}
that.goodsList = [];
that.goodsList = goodsList;
if (type == 2) {
that.outerVisible = false
} else {
that.searchGoods();
}
},
//进价
priceVerification: function (price) {
var reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/;
if (!reg.test(price)) {
this.color1 = false;
} else {
this.color1 = true;
}
return color1;
},
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 type = that.type;
var modify_order_number = that.modify_order_number;
var goods_id = [];
var goodsList = that.goodsList;
var remarks = that.remarks;
var reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/;
if (!goodsList || goodsList.length == 0) {
that.$message({type: "error", message: "请选择调价商品", duration: 1000})
return;
}
for (var i = 0; i < goodsList.length; i++) {
if (!goodsList[i].cost_price) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "进价有误",
duration: 1000
})
return;
}
if (!reg.test(goodsList[i].cost_price)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "进价有误",
duration: 1000
})
return;
}
if (goods_id.includes(goodsList[i].id)) {
that.$message({
type: "error",
message: goodsList[i].goods_name + goodsList[i].sku_name + "存在重复",
duration: 1000
})
return;
}
goods_id.push(goodsList[i].id);
}
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('ModifyOperation')}",
type: "post",
data: {
goodsList: goodsList,
remarks: remarks,
type: type,
modify_order_number: modify_order_number
},
success: function (res) {
if (res.status == 1) {
that.$message({
type: "success",
message: res.message,
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.message,
duration: 3000,
onClose: function () {
loading_examine.close();
}
})
}
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
},
})
</script>
</html>