<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8">
|
<title>Customer Info List</title>
|
<meta name="renderer" content="webkit">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
</head>
|
<body>
|
<div class="layui-fluid" style="padding-bottom: 0;">
|
<div class="layui-card">
|
<div class="layui-form layui-card-header layuiadmin-card-header-auto">
|
<div class="layui-form-item">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 106px;">Customer Code</label>
|
<div class="layui-input-inline">
|
<input type="text" id="CustomerCode" name="CustomerCode" placeholder="Customer Code" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 106px;">Customer Name</label>
|
<div class="layui-input-inline">
|
<input type="text" id="CustomerName" name="CustomerName" placeholder="Customer Name" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 106px;">Linkman</label>
|
<div class="layui-input-inline">
|
<input type="text" id="Linkman" name="Linkman" placeholder="Linkman" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 106px;">Customer Phone</label>
|
<div class="layui-input-inline">
|
<input type="text" id="Phone" name="Phone" placeholder="Customer Phone" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 106px;">Customer Type</label>
|
<div class="layui-input-inline" style="">
|
<select name="CustomerType" id="CustomerType" lay-filter="DepartmentManager" lay-search>
|
<option value="">please select</option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<button class="layui-btn layui-btn-sm layuiadmin-btn-list"
|
lay-submit lay-filter="LAY-app-contlist-search">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>Search
|
</button>
|
</div>
|
</div>
|
</div>
|
|
<div class="layui-card-body">
|
<div style="padding-bottom: 10px;">
|
<button class="layui-btn layui-btn-sm layuiadmin-btn-list" data-type="add">
|
<i class="layui-icon"></i>Add
|
</button>
|
<button class="layui-btn layui-btn-sm layuiadmin-btn-list layui-btn-danger" data-type="batchdel">
|
<i class="layui-icon"></i>Del
|
</button>
|
</div>
|
<table id="LAY-app-content-list" lay-filter="LAY-app-content-list"></table>
|
<script type="text/html" id="table-content-list">
|
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">
|
<i class="layui-icon layui-icon-edit"></i>Edit
|
</a>
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">
|
<i class="layui-icon layui-icon-delete"></i>Del
|
</a>
|
</script>
|
</div>
|
</div>
|
</div>
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../js/public.js"></script>
|
<script src="../../../js/jquery-3.5.1.min.js"></script>
|
<script>
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index' //主入口模块
|
}).use(['index', 'table', 'laypage', 'layer'], function() {
|
var table = layui.table,
|
form = layui.form,
|
laypage = layui.laypage,
|
layer = layui.layer;
|
//
|
sendData(IP + "/Base/GetCustomerTypeList", {}, 'post', function(res) {
|
var html = '';
|
console.log(res);
|
if (res.code == 1) { //成功
|
var list = res.data;
|
for (var i = 0; i < list.length; i++) {
|
html += '<option value = "' + list[i].Code + '">' + list[i].TypeName + '</option>';
|
}
|
$("#CustomerType").append(html);
|
form.render('select');
|
} else { //不成功
|
layer.msg('Get Customer Type List is Err!', {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
refreshTable();
|
function setLanguage(){
|
var lg = localStorage.getItem('SystemLanguage');
|
if(lg != "en"){
|
return;
|
}
|
}
|
function refreshTable() {
|
var code = $("#CustomerCode").val();
|
var name = $("#CustomerName").val();
|
var linkman = $("#Linkman").val();
|
var phone = $("#Phone").val();
|
var typeId = $("#CustomerType").val();
|
var param = {
|
customerCode: code,
|
customerName: name,
|
customerLinkman: linkman,
|
customerPhone: phone,
|
customerTypeId: typeId
|
};
|
var url = IP + "/Base/GetCustomerList";
|
table.render({
|
elem: '#LAY-app-content-list',
|
url: url,
|
method: 'POST',
|
height: 'full-182',
|
id: 'LAY-app-content-list',
|
where: param,
|
contentType:'application/json',
|
page: true,
|
limit: pageCnt,
|
limits: pageLimits,
|
cellMinWidth: 80, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
|
even: true,
|
done: function(res, curr, count){
|
},
|
cols: [
|
[{
|
field: 'Id',
|
title: 'Id',
|
type: 'checkbox',
|
width: 60,
|
sort: true,
|
fixed: 'left'
|
}, {
|
field: 'CustomerCode',
|
title: 'Customer Code',
|
width: 135,
|
fixed: 'left'
|
}, {
|
field: 'CustomerName',
|
title: 'Customer Name',
|
width: 200,
|
}, {
|
field: 'CustomerAddress',
|
title: 'Address',
|
width: 250
|
}, {
|
field: 'CustomerLinkman',
|
title: 'Linkman',
|
width: 120,
|
}, {
|
field: 'CustomerPhone',
|
title: 'Customer Phone',
|
width: 180
|
}, {
|
field: 'CustomerType',
|
title: 'Customer Type',
|
width: 135
|
}, {
|
field: 'CustomerRemark',
|
title: 'Remark',
|
width: 90
|
}, {
|
field: 'CreateUser',
|
title: 'Create User',
|
width: 110
|
},{
|
field: 'CreateTime',
|
title: 'Create Time',
|
templet: function(d) {
|
return formatDate(d.CreateTime);
|
},
|
width: 120
|
},{
|
field: 'UpdateUser',
|
title: 'Update User',
|
width: 110
|
},{
|
field: 'UpdateTime',
|
title: 'Update Time',
|
templet: function(d) {
|
return formatDate(d.UpdateTime);
|
},
|
width: 120
|
},{
|
title: 'Operation',
|
fixed: 'right',
|
width: 178,
|
align: 'center',
|
toolbar: '#table-content-list'
|
}]
|
],
|
});
|
}
|
//监听搜索
|
form.on('submit(LAY-app-contlist-search)', function(data) {
|
var msg = data.field.Msg;
|
var typeId = data.field.CustomerType;
|
refreshTable();
|
});
|
active = {
|
batchdel: function() {
|
var checkStatus = table.checkStatus('LAY-app-content-list'),
|
checkData = checkStatus.data; //得到选中的数据
|
|
if (checkData.length === 0) {
|
return layer.msg('Select the data!');
|
}
|
|
layer.confirm('You sure to delete?', function(index) {
|
console.log(checkData);
|
var msg = "";
|
for (var i = 0; i < checkData.length; i++) {
|
msg += checkData[i].Id + ',';
|
}
|
msg += '0';
|
var param = {
|
msg: msg,
|
};
|
sendData(IP + "/Base/DelCustomer", param, 'post', function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable();
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
});
|
},
|
add: function() {
|
layer.open({
|
type: 2,
|
title: 'Add customer data',
|
content: 'customerlistform.html',
|
maxmin: true,
|
area: ['700px', '600px'],
|
btn: ['Confirm', 'Cancel'],
|
yes: function(index, layero){
|
var iframeWindow = window['layui-layer-iframe'+ index]
|
,submitID = 'layuiadmin-app-form-submit'
|
,submit = layero.find('iframe').contents().find('#'+ submitID);
|
//监听提交
|
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
|
var field = data.field; //获取提交的字段
|
console.log(field);
|
//提交 Ajax 成功后,静态更新表格中的数据
|
var param = {
|
Id: "0",
|
CustomerCode: field.CustomerCode,
|
CustomerName: field.CustomerName,
|
CustomerAddress: field.CustomerAddress,
|
CustomerLinkman: field.CustomerLinkman,
|
CustomerPhone: field.CustomerPhone,
|
CustomerTypeId: field.CustomerType,
|
CustomerRemark: field.CustomerRemark
|
};
|
sendData(IP + "/Base/AddCustomer", param, 'post', function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable();
|
// table.reload('LAY-app-content-list'); //数据刷新
|
layer.close(index); //关闭弹层
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
//$.ajax({});
|
});
|
submit.trigger('click');
|
}
|
});
|
}
|
};
|
$('.layui-btn.layuiadmin-btn-list').on('click', function() {
|
var type = $(this).data('type');
|
active[type] ? active[type].call(this) : '';
|
});
|
var cusid = "0";
|
table.on('tool(LAY-app-content-list)', function(obj) {
|
var data = obj.data;
|
if (obj.event === 'del') {
|
layer.confirm('Identify delete the selected customer?', function(index) {
|
// console.log(data);
|
cusid = data.Id;
|
var param = {
|
msg: cusid,
|
};
|
sendData(IP + "/Base/DelCustomer", param, 'post', function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg(res.msg, {
|
icon: 1,
|
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable();
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
});
|
} else if (obj.event === 'edit') {
|
cusid = data.Id;
|
layer.open({
|
type: 2,
|
title: 'Edit the customer',
|
content: 'customerlistform.html?id=' + cusid,
|
maxmin: true,
|
area: ['700px', '600px'],
|
btn: ['Confirm', 'Cancel'],
|
yes: function(index, layero){
|
var iframeWindow = window['layui-layer-iframe'+ index]
|
,submitID = 'layuiadmin-app-form-edit'
|
,submit = layero.find('iframe').contents().find('#'+ submitID);
|
//监听提交
|
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
|
var field = data.field; //获取提交的字段
|
console.log(field);
|
//提交 Ajax 成功后,静态更新表格中的数据
|
var param = {
|
Id: cusId,
|
CustomerCode: field.CustomerCode,
|
CustomerName: field.CustomerName,
|
CustomerAddress: field.CustomerAddress,
|
CustomerLinkman: field.CustomerLinkman,
|
CustomerPhone: field.CustomerPhone,
|
CustomerTypeId: field.CustomerType,
|
CustomerRemark: field.CustomerRemark
|
};
|
sendData(IP + "/Base/AddCustomer", param, 'post', function(res) {
|
console.log(res);
|
if (res.code == 1) { //成功
|
layer.msg("Success!", {
|
icon: 1,
|
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {
|
refreshTable();
|
layer.close(index); //关闭弹层
|
});
|
} else { //不成功
|
layer.msg(res.msg, {
|
icon: 2,
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
}, function() {});
|
}
|
});
|
//$.ajax({});
|
});
|
submit.trigger('click');
|
}
|
});
|
}
|
});
|
});
|
</script>
|
</body>
|
</html>
|