TG.WXCRM.V4/WEB/Views/Res/DeptRule/Index.cshtml

89 lines
2.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@using WX.CRM.IBLL.Res
@{
ViewBag.Title = "档位设置";
Layout = "~/Views/Shared/_content.cshtml";
}
<div class="layui-container">
<div class="layui-form">
<div id="divform" class="layui-inline">
@{
var depts = ViewBag.DeptList as List<DeptRuleView>;
foreach (var dept in depts)
{
<div id="divsubform1" class="divsubform">
@dept.DEPTNAME
<div class="layui-inline">
<input class="layui-input" id="@dept.DEPTID" name="rate" value="@dept.RATE" deptName="@dept.DEPTNAME" />
</div>
</div>
}
}
</div>
<div>
<button type="button" class="layui-btn" lay-submit="" lay-filter="save">保存</button>
</div>
</div>
</div>
<script type="text/javascript">
layui.use(['form', 'layer'], function () {
var form = layui.form;
var layer = layui.layer;
var $ = layui.jquery;
form.on('submit(save)', function (data) {
var obj = [];
var total = 0;
$("#divform input[name='rate']").each(function (i, j) {
var rate = $(j).val();
if (rate != '') {
if (isNumber(rate)) {
total += parseFloat(rate);
obj.push({ "DEPTID": $(j).attr("id"), "DEPTNAME": $(j).attr("deptName"), "RATE": rate });
}
else {
layer.msg('请输入数字!');
return;
}
}
});
//console.log(obj);
//console.log(total);
//if (total != 100) {
// layer.msg('比例不正确!');
// return;
//}
//console.log(JSON.stringify(obj));
$.post('/DeptRule/Save', { dto: JSON.stringify(obj) }, function (msg) {
//console.log(msg);
if (msg.result) {
layer.msg('操作成功!');
}
else {
if (msg.msg == "rateError") {
layer.msg('比例不正确!');
}
else {
layer.msg('操作失败,请重新再试!');
}
}
});
return false;
});
});
function isNumber(value) {
var patrn = /^(-)?\d+(\.\d+)?$/;
if (patrn.exec(value) == null || value == "") {
return false
} else {
return true
}
}
</script>