car4s/public/assets/js/backend/user4s/user.js
heibai 3578ee1b48
All checks were successful
continuous-integration/drone/push Build is passing
客户档案列表显示车架号
2022-06-22 09:34:21 +08:00

580 lines
28 KiB
JavaScript
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.

define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function ($, undefined, Backend, Table, Form, undefined) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user4s/user/index' + location.search,
add_url: 'user4s/user/add',
edit_url: 'user4s/user/edit',
del_url: 'user4s/user/del',
multi_url: 'user4s/user/multi',
import_url: 'user4s/user/import',
table: 'user4s_user',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
showToggle: false,
//maintainSelected: true,
// queryParams:function(params){
// var filter, op, tableId = Fast.api.query('tables_id');
// if(tableId){
// filter = JSON.parse(params.filter);
// op = JSON.parse(params.op);
// filter.tables_id = tableId;
// op.tables_id = '=';
// params.filter = JSON.stringify(filter);
// params.op = JSON.stringify(op);
// }
// return params;
// },
// queryParams: function (params) {
// console.log(params);
// console.log(Fast.api.query('status'));
// //这里可以追加搜索条件
// var filter = JSON.parse(params.filter);
// var op = JSON.parse(params.op);
// //这里可以动态赋值比如从URL中获取admin_id的值filter.admin_id=Fast.api.query('admin_id');
// //filter.admin_id = 1;
// //op.admin_id = "=";
// params.filter = JSON.stringify(filter);
// params.op = JSON.stringify(op);
// return params;
// },
columns: [
[
{ checkbox: true },
{field: 'id', title: __('会员ID'), operate:false},
{ field: 'name', title: __('Name'), operate: 'LIKE',editable:true },
{ field: 'tel', title: __('Tel'), operate: 'LIKE' ,editable:true},
{ field: 'cardid', title: __('身份证号'), operate: '=',visible:false },
{ field: 'frameno', title: __('车架号'), operate: '=',visible:false},
// {
// field: 'category_id', title: __('Category_id'), searchList: $.getJSON("user4s/category/searchlist"), formatter: function (value, row, index) {
// return row['category']['name'];
// }
// },
// {
// field: 'level_id', title: __('Level_id'), searchList: $.getJSON("user4s/level/searchlist"), formatter: function (value, row, index) {
// return row['level']['name'];
// }
// },
{ field: 'category.name', title: __('Category_id'), searchList: $.getJSON("user4s/category/searchlist") },
{ field: 'level.name', title: __('Level_id'), searchList: $.getJSON("user4s/level/searchlist") },
{ field: 'balance', title: __('Balance'), operate: false},
{ field: 'integral', title: __('Integral'), operate: false },
//{field: 'city', title: __('City'), operate: 'LIKE'},
{ field: 'buydate', title: __('Buydate'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
{ field: 'carno', title: __('Carno'), operate: false ,editable:true},
{ field: 'model', title: __('Model'), operate: false ,editable:true},
{ field: 'color', title: __('Color'), operate: false ,editable:true},
{ field: 'inscom', title: __('保险公司'), operate: false, visible: false },
{field: 'instype', title: __('保险类型'), operate: false,visible:false},
{ field: 'insdate', title: __('Insdate'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
//{field: 'tags', title: __('Tags'), operate: 'LIKE', formatter: Table.api.formatter.flag},
//{field: 'description', title: __('Description'), operate:false},
{
field: 'admin_id', title: __('Admin_id'), operate: false,visible:false, formatter: function (value, row, index) {
return row['fuzheren'];
}
},
//{ field: 'createtime', title: __('Createtime'), operate: false, addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime,datetimeFormat:'YYYY-MM-DD'},
//{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{ field: 'status', title: __('Status'), operate: false,searchList: { "0": __('Status 0'), "1": __('Status 1') }, formatter: Table.api.formatter.status },
//{ field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate },
{
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [
{
name: 'recharge',
text: __('充值消费'),
title: __('充值消费'),
classname: 'btn btn-xs btn-danger btn-dialog',
icon: 'fa fa-cny',
url: 'user4s/user/recharge',
extend: 'data-area=\'["1000px","800px"]\'',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
return true;
}
},
{
name: 'rechargelog',
text: __('消费记录'),
title: __('消费记录'),
classname: 'btn btn-xs btn-warning btn-dialog',
icon: 'fa fa-calendar-check-o',
url: 'user4s/log/index?user4s_id={id}',
extend: 'data-area=\'["1000px","800px"]\'',
},
{
name: 'visit',
text: __('回访单'),
title: function(row){
return row.name +'-的回访单'
},
classname: 'btn btn-xs btn-info btn-addtabs',
icon: 'fa fa-comments-o fa-fw',
url: 'user4s/visit/index?user4s_id={id}&status=0',
extend: 'data-area=\'["1000px","800px"]\'',
},
// {
// name: 'addtabs',
// text: __('日志'),
// title: __('订单任务日志'),
// classname: 'btn btn-xs btn-info btn-addtabs',
// icon: 'fa fa-list-ol',
// url: 'soft_log/?ids={row.id}&ref=addtabs'
// }
],
formatter: Table.api.formatter.operate
}
]
],
});
// 为表格绑定事件
Table.api.bindevent(table);
//当表格数据加载完成时
// //点击跳转
// $(document).on("click", ".jump", function () {
// var url = $(this).attr('data-url');
// window.open(url);
// });
// table.on('Table.api.events.operate', function (e, data) {
// //这里可以获取从服务端获取的JSON数据
// console.log(data);
// console.log(e);
// });
},
recyclebin: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
'dragsort_url': ''
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: 'user4s/user/recyclebin' + location.search,
pk: 'id',
sortName: 'id',
columns: [
[
{ checkbox: true },
{ field: 'id', title: __('Id') },
{ field: 'name', title: __('Name'), align: 'left' },
{
field: 'deletetime',
title: __('Deletetime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'operate',
width: '130px',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'Restore',
text: __('Restore'),
classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
icon: 'fa fa-rotate-left',
url: 'user4s/user/restore',
refresh: true
},
{
name: 'Destroy',
text: __('Destroy'),
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
icon: 'fa fa-times',
url: 'user4s/user/destroy',
refresh: true
}
],
formatter: Table.api.formatter.operate
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
$('#c-balance').on('change', function () {
var balance = $(this).val();
$.ajax({
url: "user4s/level/calculate",
type: "POST", //Use "PUT" for HTTP PUT methods
dataType: 'json',
data: {
balance: balance,
},
success: function (data, textStatus, jqXHR) {
console.log(data);
if (data.code == 1) {
if (data.data.integral > 0) {
$('#c-integral').val(data.data.integral);
}
if (data.data.level_id > 0) {
$('#c-level_id').val(data.data.level_id);
$('#c-level_id').selectPageRefresh();
}
}
},
})
});
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
recharge: function () {
$('#c-balance').on('change', function () {
var start = $('#start-balance').val();
var balance = $(this).val();
if (parseFloat(balance) > 0) {
$('#c-description').val("系统后台充值余额" + balance + "元");
}
if (parseFloat(balance) < 0) {
$('#c-description').val("系统后台手动扣除余额" + balance + "元");
}
$.ajax({
url: "user4s/level/calculate",
type: "POST", //Use "PUT" for HTTP PUT methods
dataType: 'json',
data: {
start:parseFloat(start),
balance: parseFloat(balance),
},
success: function (data, textStatus, jqXHR) {
console.log(data);
if (data.code == 1) {
if (data.data.integral > -1) {
$('#c-integral').val(data.data.integral);
}
if (data.data.level_id > 0) {
$('#c-level_id').val(data.data.level_id);
$('#c-level_id').selectPageRefresh();
}
}
},
})
});
Controller.api.bindevent();
},
expireins: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user4s/user/expireins' + location.search,
table: 'user4s_user',
}
});
var table = $("#table");
//当表格数据加载完成时
table.on('load-success.bs.table', function (e, data) {
//这里可以获取从服务端获取的JSON数据
console.log(data);
//这里我们手动设置底部的值
$("#start_date").text(data.extend.start_date);
$("#end_date").text(data.extend.end_date);
});
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
showToggle: false,
//maintainSelected: true,
columns: [
[
{ checkbox: true },
//{field: 'id', title: __('Id'), operate:false},
{ field: 'name', title: __('Name'), operate: 'LIKE' },
{ field: 'tel', title: __('Tel'), operate: 'LIKE' },
//{ field: 'balance', title: __('Balance'), operate: false},
//{ field: 'integral', title: __('Integral'), operate: false },
{ field: 'buydate', title: __('Buydate'), operate: false},
{ field: 'carno', title: __('Carno'), operate: 'LIKE' },
{ field: 'frameno', title: __('车架号'), operate: 'LIKE' },
{ field: 'model', title: __('Model'), operate: false },
{ field: 'color', title: __('Color'), operate: false },
{ field: 'inscom', title: __('Inscom'), operate: 'LIKE' },
{field: 'instype', title: __('Instype'), operate: 'LIKE'},
{ field: 'insdate', title: __('Insdate'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
{
field: 'admin_id', title: __('Admin_id'), operate: false, formatter: function (value, row, index) {
return row['fuzheren'];
}
},
{
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [
{
name: 'renewal',
text: __('续保'),
title: __('续保'),
classname: 'btn btn-xs btn-danger btn-dialog',
icon: 'fa fa-dashboard',
url: 'user4s/user/renewal',
extend: 'data-area=\'["1000px","800px"]\'',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
return true;
}
},
{
name: 'inslog',
text: __('续保记录'),
title: __('续保记录'),
classname: 'btn btn-xs btn-warning btn-dialog',
icon: 'fa fa-calendar-check-o',
url: 'user4s/inslog/index?user4s_id={id}',
extend: 'data-area=\'["1000px","800px"]\'',
},
],
formatter: Table.api.formatter.operate
}
]
],
});
// 为表格绑定事件
Table.api.bindevent(table);
},
renewal: function () {
Controller.api.bindevent();
},
birthday: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user4s/user/birthday' + location.search,
table: 'user4s_user',
}
});
var table = $("#table");
//当表格数据加载完成时
table.on('load-success.bs.table', function (e, data) {
//这里可以获取从服务端获取的JSON数据
console.log(data);
//这里我们手动设置底部的值
$("#start_date").text(data.extend.start_date);
});
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
showToggle: false,
//maintainSelected: true,
columns: [
[
{ checkbox: true },
//{field: 'id', title: __('Id'), operate:false},
{ field: 'name', title: __('Name'), operate: 'LIKE' },
{ field: 'tel', title: __('Tel'), operate: 'LIKE' },
{ field: 'birthday', title: __('生日'), operate: false},
{ field: 'cardid', title: __('Cardid'), operate: false },
{ field: 'buydate', title: __('Buydate'), operate: false},
{ field: 'carno', title: __('Carno'), operate: 'LIKE' },
{ field: 'model', title: __('Model'), operate: false },
{ field: 'color', title: __('Color'), operate: false },
{ field: 'inscom', title: __('Inscom'), operate: 'LIKE' },
{field: 'instype', title: __('Instype'), operate: 'LIKE'},
{ field: 'insdate', title: __('Insdate'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
{
field: 'admin_id', title: __('Admin_id'), operate: false, formatter: function (value, row, index) {
return row['fuzheren'];
}
},
// {
// field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
// buttons: [
// {
// name: 'renewal',
// text: __('续保'),
// title: __('续保'),
// classname: 'btn btn-xs btn-danger btn-dialog',
// icon: 'fa fa-dashboard',
// url: 'user4s/user/renewal',
// extend: 'data-area=\'["1000px","800px"]\'',
// callback: function (data) {
// Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
// },
// visible: function (row) {
// //返回true时按钮显示,返回false隐藏
// return true;
// }
// },
// {
// name: 'inslog',
// text: __('续保记录'),
// title: __('续保记录'),
// classname: 'btn btn-xs btn-warning btn-dialog',
// icon: 'fa fa-calendar-check-o',
// url: 'user4s/inslog/index?user4s_id={id}',
// extend: 'data-area=\'["1000px","800px"]\'',
// },
// ],
// formatter: Table.api.formatter.operate
// }
]
],
});
// 为表格绑定事件
Table.api.bindevent(table);
},
excel: function() {
function reset() {
$("#step").val(0);
$("#import").addClass("disabled");
if ($("#c-row").val() && $("#selecthead_type select").val() && $("#selectable select").val() && $("#c-rowpath").val()) {
Toastr.success('开始预览结果');
// $("#submit").trigger("click");
Fast.api.ajax({
url: 'import/log/preview',
data: $("form[role=form]").serialize(),
dataType: 'json',
}, function(data) {
console.log(data)
let columns = data.field
let xlsdata = data.data
let tableField = data.fieldArr
var select = ""
if (xlsdata.length) {
$("#step").val(1);
$("#import").removeClass("disabled");
// Toastr.success("与狼");
}
$.each(tableField, function(i, item) {
select += "<option class=>" + i + "</option>"
});
html = "<tr>"
$.each(columns, function(i, item) {
html += "<th class=" + item.class + ">" + item.field + "</th>"
});
html += "</tr>"
html += "<tr>"
$.each(columns, function(i, item) {
if (item.class != "success") html += "<td><select id=setop class='form-control' name=row[set][" + i + "]><option class=>请选择</option>" + select + "</select></td>"
else html += "<td class=success></td>"
});
html += "</tr>"
$.each(xlsdata, function(i, item) {
html += "<tr>"
$.each(columns, function(i, f) {
html += "<td class=" + f.class + ">" + item[f.field] + "</td>"
});
html += "</tr>"
});
$("#tableset").html(html)
}, function() {
return false;
});
}
}
$("#selectable select").on("change", function() {
$("#c-newtable").val('')
reset()
})
$("#c-newtable").on("change", function() {
$("#selectable select").val("");
reset()
})
$("#c-row").on("change", function() {
reset()
})
$("#c-rowpath").on("change", function() {
reset()
})
$("#selecthead_type select").on("change", function() {
reset()
})
$("#import").on("click", function() {
$("#submit").trigger("click");
})
Controller.api.bindevent();
},
api: {
bindevent: function (table) {
Form.api.bindevent($("form[role=form]"));
},
events: {
operate: {
'click .btn-delone': function (e, value, row, index) {
e.stopPropagation();
e.preventDefault();
var that = this;
var top = $(that).offset().top - $(window).scrollTop();
var left = $(that).offset().left - $(window).scrollLeft() - 260;
if (top + 154 > $(window).height()) {
top = top - 154;
}
if ($(window).width() < 480) {
top = left = undefined;
}
Layer.confirm(
__('22222222222222222?'),
{icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true, btn: [__('OK'), __('Cancel')]},
function (index) {
var table = $(that).closest('table');
var options = table.bootstrapTable('getOptions');
Table.api.multi("del", row[options.pk], table, that);
Layer.close(index);
}
);
}
}
}
}
};
return Controller;
});