文件

741 行
35 KiB
HTML
可执行文件

<!doctype html>
<html>
<!--[1.6.48]-->
<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>Document</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>
<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>
* {
margin: 0;
padding: 0;
}
body {
padding: 20px;
}
[v-cloak] {
display: none;
}
th > .cell {
white-space: nowrap !important;
text-align: center;
}
th, td {
text-align: center;
line-height: 30px;
padding: 0;
}
th > .cell, td > .cell {
text-align: center;
}
.el-input__inner {
-webkit-appearance: none;
background-color: #fff;
background-image: none;
border-radius: 4px;
border: 1px solid #dcdfe6;
-webkit-box-sizing: border-box;
box-sizing: border-box;
color: #606266;
display: inline-block;
font-size: inherit;
height: 40px;
line-height: 40px;
outline: 0;
padding: 0 15px;
-webkit-transition: border-color .2s cubic-bezier(.645, .045, .355, 1);
transition: border-color .2s cubic-bezier(.645, .045, .355, 1);
width: 150px;
}
.el-date-range-picker__time-picker-wrap .el-input__inner {
width: 140px;
}
</style>
</head>
<body>
<div id="addAdvance" v-cloak style="padding: 30px 50px 100px;">
<div style="text-align: left">
<el-form id="formSet" :model="goods" :rules="ruleForm">
<el-form-item label="选择商品" prop="goods_id">
<img class="upload-img" src="__PUBLIC__/Group/add.png" @click="ChoiceGoods"
style="width: 100px;height: 100px;border: 1px dashed #c2ccd1;" id="image" v-if="edit == false">
<img class="upload-img" src="__PUBLIC__/Group/add.png" id="editImage"
style="width: 100px;height: 100px;border: 1px dashed #c2ccd1;" v-if="edit == true">
</el-form-item>
<el-form-item label="商品名称">
<div>{{goods.goods_name}}</div>
</el-form-item>
<hr>
<el-form-item label="预售方式" prop="advance_type" v-if="edit == false">
<el-radio v-model="goods.advance_type" label="1">全额</el-radio>
<el-radio v-model="goods.advance_type" label="2">定金</el-radio>
</el-form-item>
<el-form-item label="预售方式" prop="advance_type" v-if="edit == true">
<el-radio v-model="goods.advance_type" disabled label="1">全额</el-radio>
<el-radio v-model="goods.advance_type" disabled label="2">定金</el-radio>
</el-form-item>
<el-form-item :label="goods.attribute_state == 2?'规格选择':''" prop="ruleList">
<el-table border :data="goods.ruleList" style="width: calc(100vw - 208px);border: none;"
size="mini"
max-height="500"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="sku_name" label="规格" show-overflow-tooltip
v-if="goods.attribute_state == 2"></el-table-column>
<el-table-column prop="goods_num" label="商品库存" show-overflow-tooltip></el-table-column>
<el-table-column prop="surplus_num" label="剩余预售库存" show-overflow-tooltip
v-if="edit == true"></el-table-column>
<el-table-column prop="sold_num" label="已预售库存" show-overflow-tooltip
v-if="edit == true"></el-table-column>
<el-table-column prop="online_price" label="商品价格" show-overflow-tooltip></el-table-column>
<el-table-column label="预售价格" show-overflow-tooltip>
<template slot-scope="scope">
<el-input type="text" v-model="scope.row.advance_price" size="mini"
v-if="scope.row.edit_type == true" disabled></el-input>
<el-input type="text" v-model="scope.row.advance_price" size="mini" v-else></el-input>
</template>
</el-table-column>
<el-table-column label="预售库存" show-overflow-tooltip>
<template slot-scope="scope">
<el-input type="text"
v-model="scope.row.advance_num" size="mini"></el-input>
</template>
</el-table-column>
<el-table-column label="定金价格" show-overflow-tooltip v-if="goods.advance_type == 2">
<template slot-scope="scope">
<el-input type="text" v-model="scope.row.earnest_price" size="mini"
v-if="scope.row.edit_type == true" disabled></el-input>
<el-input type="text" v-model="scope.row.earnest_price" size="mini" v-else></el-input>
</template>
</el-table-column>
<el-table-column label="定金抵现" show-overflow-tooltip v-if="goods.advance_type == 2">
<template slot-scope="scope">
<el-input type="text" v-model="scope.row.arrive_price" size="mini"
v-if="scope.row.edit_type == true" disabled></el-input>
<el-input type="text" v-model="scope.row.arrive_price" size="mini" v-else></el-input>
</template>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item label="限购数量" prop="restrict_num">
<el-input v-model="goods.restrict_num" size="mini" style="width:190px"></el-input>
<span>(件/人)</span>
<span style="color: red">不填默认不限购,最大1000</span>
</el-form-item>
<el-form-item label="起购数量" prop="rise_num">
<el-input v-model="goods.rise_num" size="mini" style="width:190px"></el-input>
<span style="color: red">不填默认不限制,最大1000</span>
</el-form-item>
<el-form-item label="预订日期" prop="advance_time">
<el-date-picker
v-if="edit == false"
:picker-options="pickerOptions0"
width="400"
size="small"
v-model="goods.advance_time"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
<el-date-picker
v-if="edit == true"
disabled
width="400"
size="small"
v-model="goods.advance_time"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="尾款支付时间" prop="tail_time" v-if="goods.advance_type == 2">
<el-date-picker
v-if="edit == false"
:picker-options="pickerOptions1"
width="400"
size="small"
v-model="goods.tail_time"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
<el-date-picker
v-if="edit == true"
disabled
width="400"
size="small"
v-model="goods.tail_time"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="发货时间" prop="deliver_time">
<el-date-picker
width="400"
size="small"
v-model="goods.deliver_time"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="配送方式" prop="delivery_type">
<el-checkbox-group v-model="goods.delivery_type" @change="handleCheckedCitiesChange">
<el-checkbox v-for="item in goods.delivery_list"
:label="item.type" :key="item.type" :value="item.type" :value-key="item.type">
{{item.title}}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="配送模板" v-if="goods.express_state">
<el-select v-model="goods.delivery_template_id" size="small" placeholder="请选择配送模板" :clearable="true"
filterable>
<el-option
v-for="item in goods.delivery_template"
:value-key="item.id"
:key="item.id"
:label="item.title"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="未付尾款订单退款不退定金" v-if="edit == false && goods.advance_type == 2">
<el-switch
v-model="goods.refuse_earnest_price"
inactive-value="0"
active-value="1">
</el-switch>
</el-form-item>
<el-form-item label="未付尾款订单不退定金" v-if="edit == true && goods.advance_type == 2">
<el-switch
disabled
v-model="goods.refuse_earnest_price"
inactive-value="0"
active-value="1">
</el-switch>
</el-form-item>
<div style="display:block;margin:0 auto;">
<el-button type="primary" @click="SubSet(1)" v-if="edit == false">保存继续添加</el-button>
<el-button type="primary" @click="SubSet(2)">保存并返回</el-button>
</div>
</el-form>
</div>
<!-- 商品列表 -->
<el-dialog :visible.sync="listState" :modal-append-to-body="false" :width="'80%'">
<div>
<el-input placeholder="商品名称/货号/条码"
type="text"
size="small"
clearable
v-model="order_number"
style=" position: relative;font-size: 14px;display: inline-block;width:150px;"
></el-input>
<el-button type="primary" plain @click="search" size="small">查询</el-button>
</div>
<div>
<el-table border :data="GoodsList" style="border: none;"
size="mini"
max-height="500"
v-loading="loading"
element-loading-text="数据获取中"
element-loading-spinner="el-icon-loading">
<el-table-column prop="goods_name" label="商品名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="goods_number" label="货号" show-overflow-tooltip></el-table-column>
<el-table-column prop="goods_code" label="条码" show-overflow-tooltip></el-table-column>
<el-table-column prop="goods_num" label="库存" show-overflow-tooltip></el-table-column>
<el-table-column prop="status_name" label="状态" show-overflow-tooltip></el-table-column>
<el-table-column fixed="right" label="操作" width="150px" style="border-right: none;">
<template slot-scope="scope">
<el-button @click="Choice(scope.$index)" type="text" size="small">选择</el-button>
</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>
</div>
</el-dialog>
</div>
</body>
<script type="text/javascript">
var addAdvance = new Vue({
el: "#addAdvance",
data: function () {
return {
id: "{$id}",
edit: "{$edit}",
goods: {
goods_id: '',
goods_name: "", //商品名
advance_type: "1", //预售方式
ruleList: [],
attribute_state: "1",
restrict_num: "", //限购数量
rise_num: "", //起购数量
advance_time: "", //预订日期
tail_time: "", //尾款支付时间
deliver_time: "", //发货时间
delivery_type: [], //配送方式
delivery_list: [
{type: 1, title: "自提"},
{type: 2, title: "同城配送"},
{type: 3, title: "快递配送"}
], //配送方式列表
express_state: false,
delivery_template_id: "",
delivery_template: {$delivery_template},
refuse_earnest_price: "0", //款不退定金
},
listState: false,
loading: true,
order_number: "",
GoodsList: [],
currentPage: 1,
currentLimit: 10,
currentLen: 0,
ruleForm: {
Must: [{message: '请选择商品', required: true, trigger: 'change'}],
goodsList: [{message: '请设置规格', required: true, trigger: 'change'}],
deliver_time: [{message: '请选择发货时间', required: true, trigger: 'change'}],
tail_time: [{message: '请选择尾款支付时间', required: true, trigger: 'change'}],
advance_time: [{message: '请选择预订时间', required: true, trigger: 'change'}],
advance_type: [{message: '请选择预售方式', required: true, trigger: 'change'}],
delivery_type: [{message: '请选择配送方式', required: true, trigger: 'change'}],
},
pickerOptions0: {
disabledDate: (time) => {
return time.getTime() < new Date().getTime() - 86400000;
}
},
pickerOptions1: {
disabledDate: (time) => {
let _t = addAdvance.goods.advance_time;
if (!_t || !_t[0] || !_t[1]) {
return true;
} else {
let _start = Date.parse(_t[0]);
let _end = Date.parse(_t[1]);
let _thisTime = time.getTime();
return _thisTime < _start || _thisTime > _end + 86400000 * 30;
}
}
},
goodsSelection: [], //选中的规格
}
},
methods: {
//选中的预售商品
handleSelectionChange: function (data) {
var that = this;
that.goodsSelection = data;
},
//配送方式选择
handleCheckedCitiesChange: function (value) {
if (value.includes(3)) {
this.goods.express_state = true;
} else {
this.goods.express_state = false;
}
},
handleSizeChange: function (val) {
this.currentLimit = val;//切换每页数量
this.currentPage = 1;
this.ChoiceGoods();
},
handleCurrentChange: function (val) {
this.currentPage = val;
this.ChoiceGoods();//切换页数
},
search: function () {
this.currentPage = 1;
this.ChoiceGoods();
},
//商品列表
ChoiceGoods: function () {
var that = this;
that.listState = true;
$.ajax({
url: "{:U('goodsList')}",
type: "post",
data: {
order_number: that.order_number,
page: that.currentPage,
limit: that.currentLimit
},
success: function (res) {
that.GoodsList = [];
that.GoodsList = res.data;
that.loading = false;
that.$nextTick(function () {
that.currentLen = parseInt(res.count);
})
}
})
},
//选择商品
Choice: function (index) {
var that = this;
that.order_number = "";
var goodsInfo = that.GoodsList[index];
var list = [];
if (goodsInfo.num <= 0) {
that.$message({
type: "warning",
message: "商品库存不足",
duration: 1000
})
return;
}
if (goodsInfo.attribute_state == 1) {
that.goods.goods_id = goodsInfo.id;
that.goods.goods_name = goodsInfo.goods_name;
that.goods.attribute_state = goodsInfo.attribute_state;
that.goods.pricing_method = goodsInfo.pricing_method;
$("#image").val('');
$("#image").attr('src', goodsInfo.image);
list.push(goodsInfo);
that.goods.ruleList = [];
that.goods.ruleList = list;
that.listState = false;
} else if (goodsInfo.attribute_state == 2) {
var goods_id = goodsInfo.id;
$.ajax({
url: "{:U('getSkuList')}",
type: "post",
data: {
goods_id: goods_id
},
success: function (res) {
if (res.status == 1) {
that.goods.goods_id = goodsInfo.id;
that.goods.goods_name = goodsInfo.goods_name;
that.goods.attribute_state = goodsInfo.attribute_state;
$("#image").val('');
$("#image").attr('src', goodsInfo.image);
that.goods.ruleList = [];
that.goods.ruleList = res.data;
that.listState = false;
} else {
that.$message({
type: "warning",
message: res.msg,
duration: 1000
})
}
}
})
} else {
that.$message({
type: "warning",
message: "刷新页面重试",
duration: 1000
})
}
},
//提交
SubSet: function (type) {
var that = this;
var id = that.id;
var edit = that.edit;
var goods = JSON.parse(JSON.stringify(that.goods));
var goodsSelection = that.goodsSelection;
var reg1 = /^[0-9]*[1-9][0-9]*$/;
var reg2 = /^[0-9]+(.[0-9]{1,2})?$/;
var reg3 = /^[0-9]+(.[0-9]{1,3})?$/;
var name = '';
if (!goods.goods_id) {
that.$message({type: "warning", message: "请选择预售商品", duratioon: 2000})
return;
}
if (!goods.advance_type) {
that.$message({type: "warning", message: "请选择预售方式", duratioon: 2000})
return;
}
if (parseFloat(goods.restrict_num) > 1000 || goods.restrict_num === 0) {
that.$message({type: "warning", message: "请输入正确限购数量", duratioon: 2000})
return;
}
if (parseFloat(goods.rise_num) > 1000 || goods.rise_num === 0) {
that.$message({type: "warning", message: "请输入正确起购数量", duratioon: 2000})
return;
}
if (goods.rise_num && goods.restrict_num && parseFloat(goods.rise_num) > parseFloat(goods.restrict_num)) {
that.$message({type: "warning", message: "起购数量不能大于限购数量", duratioon: 2000})
return;
}
if (goods.attribute_state == 2 || (goods.attribute_state == 1 && goods.pricing_method == 1)) {
if (goods.restrict_num && !reg1.test(goods.restrict_num)) {
that.$message({type: "warning", message: "请输入正确限购数量", duratioon: 2000})
return;
}
if (goods.rise_num && !reg1.test(goods.rise_num)) {
that.$message({type: "warning", message: "请输入正确起购数量", duratioon: 2000})
return;
}
} else if (goods.attribute_state == 1 && goods.pricing_method == 2) {
if (goods.restrict_num && !reg3.test(goods.restrict_num)) {
that.$message({type: "warning", message: "请输入正确限购数量", duratioon: 2000})
return;
}
if (goods.rise_num && !reg3.test(goods.rise_num)) {
that.$message({type: "warning", message: "请输入正确起购数量", duratioon: 2000})
return;
}
}
if (!goods.advance_time) {
that.$message({type: "warning", message: "请选择预订日期", duratioon: 2000})
return;
}
if (goods.advance_type == 2) {
if (!goods.tail_time) {
that.$message({type: "warning", message: "请选择尾款支付时间", duratioon: 2000})
return;
}
}
if (goods.delivery_type.length <= 0) {
that.$message({type: "warning", message: "请选择配送方式", duratioon: 2000})
return;
}
if (goods.delivery_type.includes(3) && !goods.delivery_template_id) {
that.$message({type: "warning", message: "请选择模板", duratioon: 2000})
return;
}
if (goodsSelection.length <= 0 || !goodsSelection) {
that.$message({type: "warning", message: "请选择预售上架商品规格", duratioon: 2000})
return;
}
for (var i = 0; i < goodsSelection.length; i++) {
if (goods.attribute_state == 2) {
name = goods.ruleList[i].sku_name;
} else {
name = goods.goods_name;
}
if (!goodsSelection[i].advance_price || !reg2.test(goodsSelection[i].advance_price)) {
that.$message({
type: "warning",
message: name + "预售价格有误",
duratioon: 2000
})
return;
}
if (parseFloat(goodsSelection[i].advance_price) > parseFloat(goodsSelection.online_price)) {
that.$message({
type: "warning",
message: name + "预售价不能大于商城价",
duratioon: 2000
})
return;
}
if (!goodsSelection[i].advance_num) {
that.$message({
type: "warning",
message: name + "请输入预售库存",
duratioon: 2000
})
return;
}
if (edit == true) {
if (parseFloat(goodsSelection.advance_num) < parseFloat(goodsSelection[i].sold_num)) {
that.$message({type: "warning", message: name + "预售库存不能小于已售库存", duratioon: 2000})
return;
}
if (parseFloat(goodsSelection[i].advance_num) > (parseFloat(goodsSelection[i].goods_num) + parseFloat(goodsSelection[i].surplus_num))) {
that.$message({type: "warning", message: name + "预售库存不能大于总库存", duratioon: 2000})
return;
}
} else {
if (goodsSelection.goods_num <= 0) {
that.$message({type: "warning", message: name + "库存不足", duratioon: 2000})
return;
}
if (parseFloat(goodsSelection[i].advance_num) > parseFloat(goodsSelection[i].goods_num)) {
that.$message({type: "warning", message: name + "预售库存不能大于总库存", duratioon: 2000})
return;
}
}
if (goods.attribute_state == 2) {
if (!reg1.test(goodsSelection[i].advance_num)) {
that.$message({
type: "warning",
message: name + "预售库存有误",
duratioon: 2000
})
return;
}
} else if (goods.attribute_state == 1) {
if (goodsSelection[i].pricing_method == 2) {
//称重
if (!reg3.test(goodsSelection[i].advance_num)) {
that.$message({
type: "warning",
message: name + "预售库存有误",
duratioon: 2000
})
return;
}
} else {
if (!reg1.test(goodsSelection[i].advance_num)) {
that.$message({
type: "warning",
message: name + "预售库存有误",
duratioon: 2000
})
return;
}
}
}
if (goods.advance_type == 2) {
if (!reg2.test(goodsSelection[i].earnest_price) || !goodsSelection[i].earnest_price) {
that.$message({
type: "warning",
message: name + "定金有误",
duratioon: 2000
})
return;
}
if (parseFloat(goodsSelection[i].earnest_price) >= parseFloat(goodsSelection[i].advance_price)) {
that.$message({
type: "warning",
message: name + "定金必须小于预售价",
duratioon: 2000
})
return;
}
if (goodsSelection[i].arrive_price && !reg2.test(goodsSelection[i].arrive_price)) {
that.$message({
type: "warning",
message: name + "定金抵现有误",
duratioon: 2000
})
return;
}
if (goodsSelection[i].arrive_price) {
if ((parseFloat(goodsSelection[i].arrive_price) >= parseFloat(goodsSelection[i].advance_price)) || (parseFloat(goodsSelection[i].arrive_price) < parseFloat(goodsSelection[i].earnest_price))) {
that.$message({
type: "warning",
message: name + "抵现价必须小于预售价且大于等于定金价",
duratioon: 2000
})
return;
}
}
}
}
goods.ruleList = [];
goods.ruleList = goodsSelection;
that.$confirm(id ? '确认修改' : '确认添加, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const loadsing = that.$loading({
lock: true,
text: '保存中,请等待',
spinner: 'el-icon-loading',
background: 'rgba(255, 255, 255, 0.7)'
});
goods = JSON.stringify(goods);
$.ajax({
url: "{:U('addSet')}",
type: "post",
data: {
goods: goods,
id: id
},
success: function (res) {
if (res.status == 1) {
that.$message({
type: "success",
message: res.msg,
duration: 1000,
onClose: function () {
if (type == 1) {
that.goods.goods_id = "";
that.goods.goods_name = "";
that.goods.ruleList = [];
that.goods.delivery_template_id = "";
that.goods.advance_type = "1";
$("#image").val("");
$("#image").attr('src', "__PUBLIC__/Group/add.png");
loadsing.close();
} else {
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
}
}
})
} else {
that.$message({
type: "warning",
message: res.msg,
duration: 2000,
onClose: function () {
loadsing.close();
}
})
}
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
});
});
},
},
created: function () {
var that = this;
var id = that.id;
var edit = that.edit;
if (edit == true) {
$.ajax({
url: "{:U('editInfo')}",
type: "post",
data: {id: id},
success: function (res) {
if (res.status == 1) {
that.goods = res.info.goods;
$("#editImage").val('');
$("#editImage").attr('src', res.info.path);
}
}
})
}
}
})
</script>
</html>