提交 a3da0ade 编写于 作者: L LAPTOP-UV1MNL38\18023

feat:新增门店会员

上级 4d53b1da
// 表格的序号
var rowNum = 1;
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'table', 'jquery', 'winui', 'textool'], function (exports) {
winui.renderColor();
layui.use(['form'], function (form) {
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
textool = layui.textool;
var selOption = getFileContent('tpl/template/select-option.tpl');
var usetableTemplate = $("#usetableTemplate").html();
var storeList = [];
// 加载我所在的门店
shopUtil.queryStaffBelongStoreList(function (json){
storeList = [].concat(json.rows);
$("#storeId").html(getDataUseHandlebars($("#selectTemplate").html(), json));
});
form.on('select(storeId)', function(data) {
calcMealChoose();
});
// 用户类型变化
form.on('radio(userType)', function(data) {
var val = data.value;
if(val == 1){
$(".memberMation").hide();
$(".anonymousUserMation").show();
} else {
$(".memberMation").show();
$(".anonymousUserMation").hide();
}
});
var carHasMealList = [];
// 车辆信息变化
form.on('select(memberCar)', function(data) {
var val = data.value;
if(isNull(val)){
$("#mealId").html("");
} else {
// 获取车辆用于的套餐信息
AjaxPostUtil.request({url: shopBasePath + "queryMealMationByCarId", params: {carId: val}, type: 'json', method: "GET", callback: function (json) {
carHasMealList = [].concat(json.rows);
calcMealChoose();
}, async: false});
}
});
// 套餐变化
form.on('select(mealId)', function(data) {
var val = data.value;
if(isNull(val)){
$("#mealExplain").html("");
$("#mealConsume").html("");
} else {
var item = getInPoingArr(carHasMealList, "id", val, null);
$("#mealExplain").html(item.mealExplain);
$("#mealConsume").html(item.mealConsume);
}
});
function calcMealChoose(){
// 获取选中门店所属的区域id
var storeId = $("#storeId").val();
var chooseStoreAreaId = getInPoingArr(storeList, "id", storeId, "areaId");
var tempList = [].concat(carHasMealList);
$.each(tempList, function (i, item) {
if(item.areaId != chooseStoreAreaId){
item.choose = "disabled";
} else {
item.choose = "";
}
});
$("#mealId").html(getDataUseHandlebars($("#mealTemplate").html(), {rows: tempList}));
form.render('select');
}
textool.init({eleId: 'remark', maxlength: 400});
matchingLanguage();
form.render();
form.on('submit(formAddBean)', function (data) {
if (winui.verifyForm(data.elem)) {
var tableData = new Array();
// $.each($("#useTable tr"), function(i, item) {
// // 获取行编号
// var rowNum = $(item).attr("trcusid").replace("tr", "");
// var row = {
// consumeExplain: $("#consumeExplain" + rowNum.toString()).val(),
// price: $("#price" + rowNum.toString()).val()
// };
// tableData.push(row);
// });
var userType = $("input[name='userType']:checked").val();
var params = {
storeId: $("#storeId").val(),
userType: userType,
memberId: userType == 1 ? "" : sysMemberUtil.memberMation.id,
memberCarId: userType == 1 ? "" : $("#memberCar").val(),
memberCarPlate: userType == 1 ? $("#memberCarPlate").val() : $("#memberCar").find("option:selected").text(),
mealOrderChildId: userType == 1 ? "" : $("#mealId").val(),
// servicePrice: $("#servicePrice").val(),
servicePrice: 0,
remark: $("#remark").val(),
type: 2,
consumeMationList: JSON.stringify(tableData)
};
if(userType == 1){
// 匿名客户
if(isNull(params.memberCarPlate)){
winui.window.msg('请输入车牌号.', {icon: 2, time: 2000});
return false;
}
} else {
// 会员
if(isNull(params.memberId)){
winui.window.msg('请选择会员.', {icon: 2, time: 2000});
return false;
}
if(isNull(params.memberCarId)){
winui.window.msg('请选择车辆信息.', {icon: 2, time: 2000});
return false;
}
}
AjaxPostUtil.request({url: shopBasePath + "insertKeepFitOrder", params: params, type: 'json', method: "POST", callback: function (json) {
winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000}, function() {
location.reload();
});
}, async: true});
}
return false;
});
// 新增行
$("body").on("click", "#addRow", function() {
addRow();
});
// 删除行
$("body").on("click", "#deleteRow", function() {
deleteRow();
});
// 新增行
function addRow() {
var par = {
id: "row" + rowNum.toString(), //checkbox的id
trId: "tr" + rowNum.toString(), //行的id
consumeExplain: "consumeExplain" + rowNum.toString(),
price: "price" + rowNum.toString()
};
$("#useTable").append(getDataUseHandlebars(usetableTemplate, par));
form.render();
rowNum++;
}
// 删除行
function deleteRow() {
var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked");
if(checkRow.length > 0) {
$.each(checkRow, function(i, item) {
// 移除界面上的信息
$(item).parent().parent().remove();
});
calcAllPrice();
} else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000});
}
}
// 会员选择
$("body").on("click", ".chooseMemberBtn", function (e) {
sysMemberUtil.openSysMemberChoosePage(function (memberMation){
$("#memberId").val(memberMation.contacts);
var params = {
memberId: memberMation.id,
enabled: 1
};
// 获取会员拥有的车辆信息(已启用)
AjaxPostUtil.request({url: shopBasePath + "memberCar001", params: params, type: 'json', method: "POST", callback: function (json) {
$.each(json.rows, function (i, item) {
item.name = item.modelType + "(" + item.plate + ")";
});
$("#memberCar").html(getDataUseHandlebars(selOption, json));
form.render('select');
}, async: false});
});
});
$("body").on("input", ".calcPrice", function() {
calcAllPrice();
});
$("body").on("change", ".calcPrice", function() {
calcAllPrice();
});
function calcAllPrice(){
var allPrice = "0.00";
$.each($("#useTable tr"), function(i, item) {
// 获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
allPrice = sum(allPrice, $("#price" + rowNum.toString()).val());
});
allPrice = sum(allPrice, $("#servicePrice").val());
$("#allPrice").html(allPrice + "");
}
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
});
});
\ No newline at end of file
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'table', 'jquery', 'winui', 'form', 'soulTable'], function (exports) {
winui.renderColor();
var $ = layui.$,
form = layui.form,
table = layui.table,
soulTable = layui.soulTable;
var selTemplate = getFileContent('tpl/template/select-option.tpl');
//门店会员
// 加载当前用户所属门店
AjaxPostUtil.request({url: sysMainMation.shopBasePath + "storeStaff005", params: {}, type: 'json', method: "GET", callback: function(json) {
$("#storeId").html(getDataUseHandlebars(selTemplate, json));
form.render('select');
initTable();
}, async: false});
var storeId = "";
form.on('select(storeId)', function(data) {
var thisRowValue = data.value;
storeId = isNull(thisRowValue) ? "" : thisRowValue;
loadTable();
});
function initTable(){
table.render({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: sysMainMation.shopBasePath + 'member001',
where: getTableParams(),
even: true,
page: true,
limits: getLimits(),
limit: getLimit(),
overflow: {
type: 'tips',
hoverTime: 300, // 悬停时间,单位ms, 悬停 hoverTime 后才会显示,默认为 0
minWidth: 150, // 最小宽度
maxWidth: 500 // 最大宽度
},
cols: [[
{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
{ field: 'name', title: '会员姓名', align: 'left', width: 250 },
{ field: 'phone', title: '联系电话', align: 'left', width: 250 },
{ field: 'email', title: '邮箱', align: 'left', width: 250 },
{ field: 'remark', title: '备注', align: 'left', width: 450 },
]],
done: function(json) {
matchingLanguage();
soulTable.render(this);
initTableSearchUtil.initAdvancedSearch(this, json.searchFilter, form, "请输入会员姓名", function () {
table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()});
}, `<label class="layui-form-label">门店</label><div class="layui-input-inline">
<select id="storeId" name="storeId" lay-filter="storeId" lay-search="">
</select></div>`);
}
});
}
form.render();
$("body").on("click", "#reloadTable", function() {
loadTable();
});
function loadTable() {
table.reloadData("messageTable", {where: getTableParams()});
}
function getTableParams() {
let params = {
holderId: storeId,
};
return $.extend(true, params, initTableSearchUtil.getSearchValue("messageTable"));
}
exports('storeMembersList', {});
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div style="padding:20px; margin:0 auto;">
<form class="layui-form" action="" id="showForm">
<div class="layui-form-item layui-col-xs12">
<span class="hr-title">保养订单信息</span><hr>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">门店<i class="red">*</i></label>
<div class="layui-input-block">
<select id="storeId" name="storeId" lay-filter="storeId" lay-search="" win-verify="required">
</select>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">用户类型<i class="red">*</i></label>
<div class="layui-input-block winui-radio">
<!-- <input type="radio" name="userType" value="1" title="匿名用户" lay-filter="userType"/>-->
<input type="radio" name="userType" value="2" title="会员" lay-filter="userType" checked="checked"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6 memberMation">
<label class="layui-form-label">会员<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="memberId" name="memberId" placeholder="请选择会员" class="layui-input" readonly="readonly"/>
<i class="fa fa-plus-circle input-icon chooseMemberBtn"></i>
</div>
</div>
<div class="layui-form-item layui-col-xs6 memberMation">
<label class="layui-form-label">车辆信息<i class="red">*</i></label>
<div class="layui-input-block">
<select id="memberCar" name="memberCar" lay-filter="memberCar" lay-search="">
</select>
</div>
</div>
<div class="layui-form-item layui-col-xs12 memberMation">
<label class="layui-form-label">套餐信息<i class="red">*</i></label>
<div class="layui-input-block">
<select id="mealId" name="mealId" lay-filter="mealId" lay-search="" win-verify="required">
</select>
</div>
</div>
<div class="layui-form-item layui-col-xs12 memberMation">
<label class="layui-form-label">套餐说明:</label>
<div class="layui-input-block ver-center" id="mealExplain">
</div>
</div>
<div class="layui-form-item layui-col-xs12 memberMation">
<label class="layui-form-label">耗材说明:</label>
<div class="layui-input-block ver-center" id="mealConsume">
</div>
</div>
<div class="layui-form-item layui-col-xs12 anonymousUserMation" style="display: none">
<label class="layui-form-label">车牌号<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="memberCarPlate" name="memberCarPlate" placeholder="请输入车牌号" class="layui-input"/>
</div>
</div>
<!--<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">耗材</label>
<div class="layui-input-block">
<div class="winui-toolbar">
<div class="winui-tool" style="text-align: left;">
<button id="addRow" class="winui-toolbtn" type="button"><i class="fa fa-plus" aria-hidden="true"></i>新增行</button>
<button id="deleteRow" class="winui-toolbtn" type="button"><i class="fa fa-trash-o" aria-hidden="true"></i>删除行</button>
</div>
</div>
<table class="layui-table">
<thead>
<tr>
<th style="width: 30px;"></th>
<th style="width: 150px;">耗材说明<i class="red">*</i></th>
<th style="width: 150px;">金额<i class="red">*</i></th>
</tr>
</thead>
<tbody id="useTable" class="insurance-table">
</tbody>
</table>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">服务费</label>
<div class="layui-input-block">
<input type="text" id="servicePrice" name="servicePrice" placeholder="请输入服务费" class="layui-input calcPrice" win-verify="money"/>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">总价</label>
<div class="layui-input-block ver-center" id="allPrice">
0 元
</div>
</div>-->
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">备注</label>
<div class="layui-input-block">
<textarea id="remark" name="remark" placeholder="请输入备注信息" maxlength="400" class="layui-textarea" style="height: 100px;"></textarea>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<div class="layui-input-block">
<button class="winui-btn" id="cancle"><language showName="com.skyeye.cancel"></language></button>
<button class="winui-btn" lay-submit lay-filter="formAddBean">保养</button>
</div>
</div>
</form>
</div>
<script type="text/x-handlebars-template" id="usetableTemplate">
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td><input type="text" class="layui-input" id="{{consumeExplain}}" win-verify="required"/></td>
<td><input type="text" class="layui-input calcPrice" id="{{price}}" win-verify="required|money"/></td>
</tr>
</script>
<script type="text/x-handlebars-template" id="selectTemplate">
{{#each rows}}
<option value="{{id}}">{{areaName}} {{name}}</option>
{{/each}}
</script>
<script type="text/x-handlebars-template" id="mealTemplate">
<option value="">全部</option>
{{#each rows}}
<option value="{{id}}" {{choose}}>{{name}} 适用区域:【{{areaName}}</option>
{{/each}}
</script>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/keepFitOrder/'}).use('keepFitOrderAdd');
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
<style>
.layui-table-cell {
height: auto;
text-overflow: inherit;
overflow: visible;
white-space: normal;
word-wrap: break-word;
}
</style>
</head>
<body>
<div class="winui-toolbar">
<div class="winui-tool">
<button id="reloadTable" class="winui-toolbtn search-table-btn-right"><i class="fa fa-refresh" aria-hidden="true"></i><language showName="com.skyeye.refreshDataBtn"></language></button>
</div>
</div>
<div style="margin: auto 10px; height: calc(100% - 50px);">
<div style="width: calc(100% - 10px); float: left;">
<div style="margin:auto 10px;">
<table id="messageTable" lay-filter="messageTable"></table>
</div>
</div>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/storeMembers/'}).use('storeMembersList');
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册