380 行
17 KiB
HTML
可执行文件
380 行
17 KiB
HTML
可执行文件
<!DOCTYPE html>
|
|
<html>
|
|
<!--[1.4.13]-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>layui</title>
|
|
<meta name="renderer" content="webkit">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
<link rel="stylesheet" href="__PUBLIC__/vue/element-ui.css">
|
|
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/myscroll.css"/>
|
|
<style>
|
|
.tip {
|
|
padding: 8px 16px;
|
|
background-color: #f8f8f8;
|
|
border-radius: 4px;
|
|
border-left: 5px solid #409EFF;
|
|
margin: 0 0 10px 0;
|
|
}
|
|
|
|
.mem-div {
|
|
width: 100%;
|
|
display: flex;
|
|
}
|
|
|
|
.mem-price {
|
|
width: 70%;
|
|
}
|
|
|
|
.mem-status-switch {
|
|
margin-left: 5px;
|
|
}
|
|
|
|
.preservation {
|
|
display: flex;
|
|
justify-content: center;
|
|
margin-top: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="app" v-cloak style="width: 100%">
|
|
<div class="tip" style="font-size: 14px;">
|
|
<p style="color: #666"><strong style="color: #409EFF;">称重商品</strong>货号建议长度最大为5,即小于等于99999,大于这个值的货号在称上无法识别</p>
|
|
<p style="color: #666"><strong style="color: #409EFF;">规格商品</strong>信息请单独设置</p>
|
|
</div>
|
|
<template>
|
|
<el-table border :data="mgoods_list" style="width: 100%">
|
|
<el-table-column type="index" label="序号" width="50"></el-table-column>
|
|
<el-table-column prop="goods_name" label="商品名称">
|
|
<template slot-scope="scope">
|
|
<el-input size="small" v-model="scope.row.goods_name" style="width: 100%;height: 100%;"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="good_number" label="商品货号">
|
|
<template slot-scope="scope">
|
|
<el-input size="small" v-model="scope.row.good_number"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="goods_code" label="商品条码">
|
|
<template slot-scope="scope">
|
|
<el-input size="small" v-model="scope.row.goods_code"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="goods_num" label="商品库存">
|
|
<template slot-scope="scope">
|
|
<el-input size="small" readonly v-model="scope.row.goods_num"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="can_exchange_weigh" label="是否称重" width="80">
|
|
<template slot-scope="scope">
|
|
<el-switch
|
|
v-if="scope.row.attribute == 2"
|
|
disabled
|
|
v-model="scope.row.can_exchange_weigh"
|
|
active-value="2"
|
|
inactive-value="1">
|
|
</el-switch>
|
|
<el-switch
|
|
v-if="scope.row.attribute == 1"
|
|
v-model="scope.row.can_exchange_weigh"
|
|
active-value="2"
|
|
inactive-value="1">
|
|
</el-switch>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="purch_price" label="商品成本价">
|
|
<template slot-scope="scope">
|
|
<el-input size="small" readonly v-model="scope.row.purch_price"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="retail_price" label="店内零售价">
|
|
<template slot-scope="scope">
|
|
<el-input size="small" v-model="scope.row.retail_price"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column type="online_price" label="商城零售价">
|
|
<template slot-scope="scope">
|
|
<el-input size="small" v-model="scope.row.online_price"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="store_mem_price" label="店内会员价" min-width="120">
|
|
<template slot-scope="scope">
|
|
<div class="mem-div">
|
|
<div class="mem-price">
|
|
<el-input size="small" v-model="scope.row.store_mem_price"
|
|
:disabled="scope.row.store_mem_status == 1 ? false : true"></el-input>
|
|
</div>
|
|
<el-switch
|
|
v-model="scope.row.store_mem_status"
|
|
active-value="1"
|
|
inactive-value="2"
|
|
class="mem-status-switch">
|
|
</el-switch>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="shop_mem_price" label="商城会员价" min-width="120">
|
|
<template slot-scope="scope">
|
|
<div class="mem-div">
|
|
<div class="mem-price">
|
|
<el-input size="small" v-model="scope.row.shop_mem_price"
|
|
:disabled="scope.row.shop_mem_status == 1 ? false : true"></el-input>
|
|
</div>
|
|
<el-switch
|
|
v-model="scope.row.shop_mem_status"
|
|
active-value="1"
|
|
inactive-value="2"
|
|
class="mem-status-switch">
|
|
</el-switch>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="plus_price" label="Plus会员价" min-width="120">
|
|
<template slot-scope="scope">
|
|
<div class="mem-div">
|
|
<div class="mem-price">
|
|
<el-input size="small" v-model="scope.row.plus_price"
|
|
:disabled="scope.row.plus_mem_status == 1 ? false : true"></el-input>
|
|
</div>
|
|
<el-switch
|
|
v-model="scope.row.plus_mem_status"
|
|
active-value="1"
|
|
inactive-value="2"
|
|
class="mem-status-switch">
|
|
</el-switch>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="attribute_name" label="规格" width="70"></el-table-column>
|
|
<el-table-column fixed="right" label="操作" width="80" style="border-right: none;">
|
|
<template slot-scope="scope">
|
|
<el-button type="text" size="small" @click="remove_goods(scope.$index)">移除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<div class="preservation">
|
|
<el-button type="primary" @click="preservation">批量保存</el-button>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</body>
|
|
<script src="__PUBLIC__/jquery/js/jquery-3.2.1.min.js"></script>
|
|
<script src="__PUBLIC__/vue/js/vue2.5.16.js"></script>
|
|
<script src="__PUBLIC__/vue/element-ui.js"></script>
|
|
<script>
|
|
var app = new Vue({
|
|
el: '#app',
|
|
data: function () {
|
|
return {
|
|
ids: "{$ids}", // 批量修改的商品id
|
|
mgoods_list: [], // 商品列表
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
/* 获取选中的商品数据 */
|
|
get_mgoods_list() {
|
|
var that = this;
|
|
$.ajax({
|
|
url: "get_update_mgoods_list",
|
|
type: "post",
|
|
data: {ids: that.ids},
|
|
success: function (res) {
|
|
if (res.status == 1) {
|
|
that.mgoods_list = res.mgoods_list;
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
/* 移除商品 */
|
|
remove_goods(index) {
|
|
var that = this;
|
|
var mgoods_list = that.mgoods_list;
|
|
that.$confirm('确定移除该商品吗?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
mgoods_list.splice(index, 1);
|
|
that.mgoods_list = mgoods_list;
|
|
});
|
|
},
|
|
|
|
/* 批量保存 */
|
|
preservation() {
|
|
var that = this;
|
|
var mgoods_list = that.mgoods_list;
|
|
var reg1 = /^\+?[0-9][0-9]*$/;
|
|
var reg2 = /^[0-9]+(.[0-9]{1,3})?$/;
|
|
if (!mgoods_list) {
|
|
this.$message({
|
|
showClose: true,
|
|
message: '修改数据缺失',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
for (var i = 0; i < mgoods_list.length; i++) {
|
|
if (!mgoods_list[i].goods_name) {
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条商品名称不正确',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
if (!mgoods_list[i].good_number) {
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条商品货号不正确',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
if (!mgoods_list[i].goods_num && mgoods_list[i].goods_num === '') {
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条商品库存不正确',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
if(mgoods_list[i].can_exchange_weigh == 2 && !reg2.test(Math.abs(mgoods_list[i].goods_num))){
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条商品库存与称重属性不符',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}else if(mgoods_list[i].can_exchange_weigh == 1 && !reg1.test(Math.abs(mgoods_list[i].goods_num))){
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条商品库存与称重属性不符',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
if(mgoods_list[i].attribute == 2 && mgoods_list[i].can_exchange_weigh == 2){
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条商品规格与称重不能同时开启',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
if (!mgoods_list[i].retail_price || mgoods_list[i].retail_price < 0) {
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条商品商城价不正确',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
if (!mgoods_list[i].retail_price || mgoods_list[i].retail_price < 0) {
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条店内零售价不正确',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
if(mgoods_list[i].attribute == 1){
|
|
if (!mgoods_list[i].online_price || mgoods_list[i].online_price < 0) {
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条商城零售价不正确',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
|
|
if (mgoods_list[i].store_mem_status == 1) {
|
|
if (!mgoods_list[i].store_mem_price || mgoods_list[i].store_mem_price < 0) {
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条店内会员价不正确',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
if (mgoods_list[i].shop_mem_status == 1) {
|
|
if (!mgoods_list[i].shop_mem_price || mgoods_list[i].shop_mem_price < 0) {
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条商城会员价不正确',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
if (mgoods_list[i].plus_mem_status == 1) {
|
|
if (!mgoods_list[i].plus_mem_status || mgoods_list[i].plus_price < 0) {
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条Plus会员价不正确',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
if(mgoods_list[i].shop_mem_status == 1 && mgoods_list[i].shop_mem_price > 0 && parseFloat(mgoods_list[i].shop_mem_price) < parseFloat(mgoods_list[i].plus_price)){
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条Plus会员价不能大于商城会员价',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
if(mgoods_list[i].attribute == 1 && mgoods_list[i].online_price > 0 && parseFloat(mgoods_list[i].online_price) < parseFloat(mgoods_list[i].plus_price)){
|
|
that.$message({
|
|
showClose: true,
|
|
message: '第' + (i + 1) + '条Plus会员价不能大于商城零售价',
|
|
type: 'warning'
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$.ajax({
|
|
url: "{:U('batch_save_mgoods')}",
|
|
type: 'post',
|
|
data: {mgoods_list: mgoods_list},
|
|
success: function (res) {
|
|
if (res.status == 1) {
|
|
that.$message({
|
|
showClose: true,
|
|
message: res.msg,
|
|
type: 'success',
|
|
duration:1500,
|
|
onClose:function () {
|
|
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
|
|
parent.layer.close(index); //再执行关闭
|
|
}
|
|
});
|
|
} else {
|
|
that.$message({
|
|
showClose: true,
|
|
message: res.msg,
|
|
type: 'error',
|
|
duration:1500
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created: function () {
|
|
this.get_mgoods_list();
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</html> |