110 行
4.6 KiB
HTML
可执行文件
110 行
4.6 KiB
HTML
可执行文件
<!--[1.8.38]-->
|
|
<style>
|
|
.el-input.is-disabled .el-input__inner {
|
|
cursor: not-allowed;
|
|
}
|
|
</style>
|
|
<div id="addMeal" v-cloak style="padding: 30px;">
|
|
<form class="layui-form" action="">
|
|
<span>(注:不需要的时限请勿输入价格,自定义时限套餐价格请输入一天的价格)</span>
|
|
<div class="layui-form-item" style="margin-left: -44px;margin-top: 20px">
|
|
<label class="layui-form-label">套餐名称</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="name" v-model="groupName" required lay-verify="required"
|
|
placeholder="请输入套餐名称" autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<template>
|
|
<el-table border :data="meal_list" style="width:400px;" @selection-change="handleSelectionChange" size="mini" max-height="500">
|
|
<el-table-column prop="goods_name" label="套餐时限">
|
|
<template slot-scope="scope">
|
|
<el-input size="small" v-model="scope.row.time_limit_name" style="width: 100%;height: 100%; fon" disabled="disabled"></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.price"></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</template>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label"></label>
|
|
<div class="layui-input-block">
|
|
<el-button type="primary" style="margin-top: 30px" @click="save">提交</el-button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var addMeal = new Vue({
|
|
el: '#addMeal',
|
|
data: function () {
|
|
return {
|
|
id: "{$meal.id}",
|
|
groupName: "{$meal.name}",
|
|
meal_list:{$meal_list},
|
|
checkedList:[], //选中内容
|
|
}
|
|
},
|
|
methods: {
|
|
handleSelectionChange: function (data) {
|
|
this.checkedList = [];
|
|
this.checkedList = data;
|
|
},
|
|
save: function () {
|
|
var reg = /(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/;
|
|
if(!this.groupName){
|
|
this.$message({message: '请先完善您的表单信息', type: 'warning', duration: 1000});
|
|
return false;
|
|
}
|
|
var meal_list = this.meal_list;
|
|
var num = 0; //判断有多少价格没有输入
|
|
for(var i=0;i<meal_list.length;i++){
|
|
if(meal_list[i].price != "" && meal_list[i].price !=0 && meal_list[i].price != null){
|
|
if(!reg.test(meal_list[i].price)){
|
|
this.$message({message: '请输入正确的价格', type: 'warning', duration: 1000});
|
|
return false;
|
|
}
|
|
}else{
|
|
num++;
|
|
}
|
|
}
|
|
if(num == 7){
|
|
this.$message({message: '请先完善您的表单信息', type: 'warning', duration: 1000});
|
|
return false;
|
|
}
|
|
var that = this;
|
|
$.ajax({
|
|
url: "{:U('addAgentMeal')}",
|
|
type: 'post',
|
|
data: {
|
|
id: that.id,
|
|
name: that.groupName,
|
|
meal_list: meal_list
|
|
},
|
|
success: function (res) {
|
|
if (res.status == 1) {
|
|
that.$message({
|
|
message: res.msg, type: 'success', duration: 1000,
|
|
onClose: function () {
|
|
MenuApp.backPreview()
|
|
}
|
|
});
|
|
} else {
|
|
that.$message({message: res.msg, type: 'error', duration: 1000});
|
|
}
|
|
},
|
|
error: function (error) {
|
|
that.$confirm(error.toString(), "出错了", {
|
|
confirmButtonText: '关闭',
|
|
type: 'info'
|
|
}).then(() => {
|
|
});
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
</script>
|