新增信誉值
This commit is contained in:
@@ -54,51 +54,87 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
||||
aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h4 class="modal-title" id="modalLabel">代充信息</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
<input type="hidden" name="id" id="id" />
|
||||
<div class="form-group">
|
||||
<label for="erbanNo" class="col-sm-3 control-label">Peko ID:</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" id="erbanNo">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">代充地区</label>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" id="save">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="modal fade"
|
||||
id="editModal"
|
||||
tabindex="-1"
|
||||
role="dialog"
|
||||
aria-labelledby="modalLabel"
|
||||
>
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button
|
||||
type="button"
|
||||
class="close"
|
||||
data-dismiss="modal"
|
||||
aria-label="Close"
|
||||
>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h4 class="modal-title" id="modalLabel">代充信息</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
<input type="hidden" name="id" id="id" />
|
||||
<div class="form-group">
|
||||
<label for="erbanNo" class="col-sm-3 control-label"
|
||||
>Peko ID:</label
|
||||
>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" id="erbanNo" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="starLevel" class="col-sm-3 control-label"
|
||||
>信誉值:</label
|
||||
>
|
||||
<div class="col-sm-9">
|
||||
<select name="starLevel" id="starLevel">
|
||||
<option value="">-- 请选择 --</option>
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">代充地区</label>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">
|
||||
取消
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" id="save">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="tipModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">提示信息</h4>
|
||||
</div>
|
||||
<div class="modal-body" id="tipMsg"></div>
|
||||
</div>
|
||||
<div
|
||||
class="modal fade"
|
||||
id="tipModal"
|
||||
tabindex="-1"
|
||||
role="dialog"
|
||||
aria-labelledby="modalLabel"
|
||||
>
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">提示信息</h4>
|
||||
</div>
|
||||
<div class="modal-body" id="tipMsg"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TableHelper from '@/utils/bootstrap-table-helper';
|
||||
import TableHelper from "@/utils/bootstrap-table-helper";
|
||||
|
||||
var partitionArray;
|
||||
var regionArray;
|
||||
@@ -325,171 +361,193 @@ export default {
|
||||
return array;
|
||||
}
|
||||
|
||||
//新增
|
||||
$('#btnAdd').on('click', function () {
|
||||
$("#id").val('');
|
||||
$("#erbanNo").val('');
|
||||
showRegion();
|
||||
$("#editModal").modal('show');
|
||||
});
|
||||
//新增
|
||||
$("#btnAdd").on("click", function () {
|
||||
$("#id").val("");
|
||||
$("#erbanNo").val("");
|
||||
$("#starLevel").val("");
|
||||
showRegion();
|
||||
$("#editModal").modal("show");
|
||||
});
|
||||
|
||||
// 查询刷新
|
||||
$('#btnSearch').on('click', function () {
|
||||
TableHelper.doRefresh('#table');
|
||||
});
|
||||
// 查询刷新
|
||||
$("#btnSearch").on("click", function () {
|
||||
TableHelper.doRefresh("#table");
|
||||
});
|
||||
|
||||
//展示地区
|
||||
function showRegion() {
|
||||
if (!regionArray) {
|
||||
return;
|
||||
}
|
||||
var $form = $('#editModal .modal-body .form-horizontal');
|
||||
for (let i = 0, len = regionArray.length; i < len; i++) {
|
||||
$('#region' + i).remove();
|
||||
var region = regionArray[i];
|
||||
var name = region.name;
|
||||
var type = region.type;
|
||||
var $formGroup = $('<div/>');
|
||||
$formGroup.attr('id', 'region' + i);
|
||||
$formGroup.attr('class', 'form-group');
|
||||
var $label = $('<label/>');
|
||||
$label.attr('class', 'col-sm-3 control-label');
|
||||
$label.html('<input type="checkbox" name="type" value="' + type + '" onclick=\"editSeqText(this);\"/> ' + name);
|
||||
$formGroup.append($label);
|
||||
var $div = $('<div/>');
|
||||
$div.attr('class', 'col-sm-9');
|
||||
$div.html('<input type="text" readonly class="form-control" id="seq' + type + '" value="0"/>');
|
||||
$formGroup.append($div);
|
||||
$form.append($formGroup);
|
||||
}
|
||||
}
|
||||
|
||||
//保存
|
||||
$("#save").click(function () {
|
||||
const msg = '确定要保存吗?';
|
||||
if (confirm(msg)) {
|
||||
var id = $('#id').val();
|
||||
const typeArray = $("input:checkbox[name='type']:checked").serializeArray();
|
||||
if (!typeArray) {
|
||||
$("#tipMsg").text("代充地区不能为空");
|
||||
$("#tipModal").modal('show');
|
||||
return;
|
||||
}
|
||||
var userRegionArray = [];
|
||||
for (let i = 0; i < regionArray.length; i++) {
|
||||
var region = regionArray[i];
|
||||
var name = region.name;
|
||||
var seq = 0;
|
||||
var isCheck = false;
|
||||
for (let j = 0; j < typeArray.length; j++) {
|
||||
console.log(typeArray[j]);
|
||||
if (typeArray[j] && region.type == typeArray[j].value) {
|
||||
seq = $('#seq' + region.type).val();
|
||||
isCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var userRegion = {
|
||||
type: region.type,
|
||||
name: region.name,
|
||||
isCheck: isCheck,
|
||||
seq: seq
|
||||
};
|
||||
userRegionArray.push(userRegion);
|
||||
}
|
||||
var data = {
|
||||
erbanNo: $('#erbanNo').val(),
|
||||
userRegions: JSON.stringify(userRegionArray)
|
||||
};
|
||||
if (id) {
|
||||
data.id = id;
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/admin/recharge/user/save",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if (json.success == 'true' || json.code == 200) {
|
||||
$("#tipMsg").text("保存成功");
|
||||
$("#tipModal").modal('show');
|
||||
TableHelper.doRefresh("#table");
|
||||
$("#editModal").modal('hide');
|
||||
} else {
|
||||
$("#tipMsg").text("保存失败." + json.message);
|
||||
$("#tipModal").modal('show');
|
||||
$("#editModal").modal('hide');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//编辑
|
||||
$('#table').on('click', '.opt-edit', function () {
|
||||
const currentData = $('#table').bootstrapTable('getData')[$(this).data('index')];
|
||||
showRegion();
|
||||
var id = currentData.id;
|
||||
var erbanNo = currentData.erbanNo;
|
||||
var userRegions = currentData.userRegions;
|
||||
$("#erbanNo").val(erbanNo);
|
||||
$("#id").val(id);
|
||||
if (regionArray) {
|
||||
for (let i = 0; i < regionArray.length; i++) {
|
||||
var region = regionArray[i];
|
||||
var seq = 0;
|
||||
var isCheck = false;
|
||||
for (let j = 0; j < userRegions.length; j++) {
|
||||
var userRegion = userRegions[j];
|
||||
if (region.type == userRegion.type) {
|
||||
seq = userRegion.seq;
|
||||
isCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isCheck) {
|
||||
$('input:checkbox[value="' + region.type + '"]').prop('checked', true);
|
||||
$('#seq' + region.type).removeAttr('readonly');
|
||||
$('#seq' + region.type).val(seq);
|
||||
} else {
|
||||
$("input:checkbox[value='" + region.type + "']").prop('checked', false);
|
||||
$('#seq' + region.type).attr('readonly', 'true');
|
||||
$('#seq' + region.type).val(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
$("#editModal").modal('show');
|
||||
});
|
||||
|
||||
//删除
|
||||
$('#table').on('click', '.opt-del', function () {
|
||||
const currentData = $('#table').bootstrapTable('getData')[$(this).data('index')];
|
||||
var id = currentData.id;
|
||||
const msg = '确定要删除吗?';
|
||||
if (confirm(msg)) {
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/admin/recharge/user/del?id=" + id,
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if (json.success == 'true' || json.code == 200) {
|
||||
$("#tipMsg").text("删除成功");
|
||||
$("#tipModal").modal('show');
|
||||
TableHelper.doRefresh("#table");
|
||||
$("#editModal").modal('hide');
|
||||
} else {
|
||||
$("#tipMsg").text("删除失败." + json.message);
|
||||
$("#tipModal").modal('show');
|
||||
$("#editModal").modal('hide');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
//展示地区
|
||||
function showRegion() {
|
||||
if (!regionArray) {
|
||||
return;
|
||||
}
|
||||
var $form = $("#editModal .modal-body .form-horizontal");
|
||||
for (let i = 0, len = regionArray.length; i < len; i++) {
|
||||
$("#region" + i).remove();
|
||||
var region = regionArray[i];
|
||||
var name = region.name;
|
||||
var type = region.type;
|
||||
var $formGroup = $("<div/>");
|
||||
$formGroup.attr("id", "region" + i);
|
||||
$formGroup.attr("class", "form-group");
|
||||
var $label = $("<label/>");
|
||||
$label.attr("class", "col-sm-3 control-label");
|
||||
$label.html(
|
||||
'<input type="checkbox" name="type" value="' +
|
||||
type +
|
||||
'" onclick="editSeqText(this);"/> ' +
|
||||
name
|
||||
);
|
||||
$formGroup.append($label);
|
||||
var $div = $("<div/>");
|
||||
$div.attr("class", "col-sm-9");
|
||||
$div.html(
|
||||
'<input type="text" readonly class="form-control" id="seq' +
|
||||
type +
|
||||
'" value="0"/>'
|
||||
);
|
||||
$formGroup.append($div);
|
||||
$form.append($formGroup);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//保存
|
||||
$("#save").click(function () {
|
||||
const msg = "确定要保存吗?";
|
||||
if (confirm(msg)) {
|
||||
var id = $("#id").val();
|
||||
const typeArray = $(
|
||||
"input:checkbox[name='type']:checked"
|
||||
).serializeArray();
|
||||
if (!typeArray) {
|
||||
$("#tipMsg").text("代充地区不能为空");
|
||||
$("#tipModal").modal("show");
|
||||
return;
|
||||
}
|
||||
var userRegionArray = [];
|
||||
for (let i = 0; i < regionArray.length; i++) {
|
||||
var region = regionArray[i];
|
||||
var name = region.name;
|
||||
var seq = 0;
|
||||
var isCheck = false;
|
||||
for (let j = 0; j < typeArray.length; j++) {
|
||||
console.log(typeArray[j]);
|
||||
if (typeArray[j] && region.type == typeArray[j].value) {
|
||||
seq = $("#seq" + region.type).val();
|
||||
isCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var userRegion = {
|
||||
type: region.type,
|
||||
name: region.name,
|
||||
isCheck: isCheck,
|
||||
seq: seq,
|
||||
};
|
||||
userRegionArray.push(userRegion);
|
||||
}
|
||||
var data = {
|
||||
erbanNo: $("#erbanNo").val(),
|
||||
starLevel: $("#starLevel").val(),
|
||||
userRegions: JSON.stringify(userRegionArray),
|
||||
};
|
||||
if (id) {
|
||||
data.id = id;
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/admin/recharge/user/save",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if (json.success == "true" || json.code == 200) {
|
||||
$("#tipMsg").text("保存成功");
|
||||
$("#tipModal").modal("show");
|
||||
TableHelper.doRefresh("#table");
|
||||
$("#editModal").modal("hide");
|
||||
} else {
|
||||
$("#tipMsg").text("保存失败." + json.message);
|
||||
$("#tipModal").modal("show");
|
||||
$("#editModal").modal("hide");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//编辑
|
||||
$("#table").on("click", ".opt-edit", function () {
|
||||
const currentData =
|
||||
$("#table").bootstrapTable("getData")[$(this).data("index")];
|
||||
showRegion();
|
||||
var id = currentData.id;
|
||||
var erbanNo = currentData.erbanNo;
|
||||
var starLevel = currentData.starLevel;
|
||||
var userRegions = currentData.userRegions;
|
||||
$("#erbanNo").val(erbanNo);
|
||||
$("#starLevel").val(starLevel);
|
||||
$("#id").val(id);
|
||||
if (regionArray) {
|
||||
for (let i = 0; i < regionArray.length; i++) {
|
||||
var region = regionArray[i];
|
||||
var seq = 0;
|
||||
var isCheck = false;
|
||||
for (let j = 0; j < userRegions.length; j++) {
|
||||
var userRegion = userRegions[j];
|
||||
if (region.type == userRegion.type) {
|
||||
seq = userRegion.seq;
|
||||
isCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isCheck) {
|
||||
$('input:checkbox[value="' + region.type + '"]').prop(
|
||||
"checked",
|
||||
true
|
||||
);
|
||||
$("#seq" + region.type).removeAttr("readonly");
|
||||
$("#seq" + region.type).val(seq);
|
||||
} else {
|
||||
$("input:checkbox[value='" + region.type + "']").prop(
|
||||
"checked",
|
||||
false
|
||||
);
|
||||
$("#seq" + region.type).attr("readonly", "true");
|
||||
$("#seq" + region.type).val(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
$("#editModal").modal("show");
|
||||
});
|
||||
|
||||
//删除
|
||||
$("#table").on("click", ".opt-del", function () {
|
||||
const currentData =
|
||||
$("#table").bootstrapTable("getData")[$(this).data("index")];
|
||||
var id = currentData.id;
|
||||
const msg = "确定要删除吗?";
|
||||
if (confirm(msg)) {
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/admin/recharge/user/del?id=" + id,
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if (json.success == "true" || json.code == 200) {
|
||||
$("#tipMsg").text("删除成功");
|
||||
$("#tipModal").modal("show");
|
||||
TableHelper.doRefresh("#table");
|
||||
$("#editModal").modal("hide");
|
||||
} else {
|
||||
$("#tipMsg").text("删除失败." + json.message);
|
||||
$("#tipModal").modal("show");
|
||||
$("#editModal").modal("hide");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user