car4s/public/assets/js/backend/user4s/visit.js
孟凡懂 4716817220
Some checks failed
continuous-integration/drone/push Build is failing
修复回访单tab
2022-06-15 02:07:00 +08:00

409 lines
21 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/visit/index' + location.search,
add_url: 'user4s/visit/add',
edit_url: 'user4s/visit/edit',
del_url: 'user4s/visit/del',
multi_url: 'user4s/visit/multi',
import_url: 'user4s/visit/import',
table: 'user4s_visit',
}
});
var table = $("#table");
// 初始化表格
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: __('回访单号') },
//{ field: 'type_id', title: __('Type_id') },
{field: 'visittype.name', title: __('Type_id'), operate: 'LIKE'},
{ field: 'user4s_id', title: __('会员ID'),visible:false,operate:false},
{ field: 'user.name', title: __('会员姓名'), operate: 'LIKE' },
{field: 'user.carno', title: __('User.carno'), operate: 'LIKE'},
//{ field: 'user.buydate', title: __('User.buydate'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false },
{field: 'user.model', title: __('User.model'), operate: false},
//{field: 'user.color', title: __('User.color'), operate: 'LIKE'},
//{field: 'user.inscom', title: __('User.inscom'), operate: 'LIKE'},
//{ field: 'user.insdate', title: __('User.insdate'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false },
//{ field: 'user.description', title: __('User.description'), operate: 'LIKE' },
{field: 'visittime', title: __('Visittime'), operate:'BETWEEN', addclass:'datetimepicker',data:'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat:'YYYY-MM-DD'},
//{field: 'admin.nickname', title: __('操作员'), operate: 'LIKE'},
{ field: 'createtime', title: __('开单时间'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"',datetimeFormat:'YYYY-MM-DD', autocomplete: false, formatter: Table.api.formatter.datetime },
{field: 'description', title: __('Description'), operate: 'LIKE',editable:true},
{ field: 'status', title: __('Status'), operate: '=',searchList: { "0": __('进行中'), "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: 'push',
text: __('填报回访记录'),
title: __('填报回访记录'),
classname: 'btn btn-xs btn-info btn-dialog',
icon: 'fa fa-cloud-upload',
url: 'user4s/visitlog/add?vid={ids}',
extend: 'data-area=\'["1000px","800px"]\'',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
if (row.status == 0) {
return true;
} else {
return false;
}
}
},
{
name: 'visitlog',
text: __('历史回访记录'),
title: function(row){
return row.user.name+'的'+row.id +'号回访记录'
},
classname: 'btn btn-xs btn-default btn-addtabs',
icon: 'fa fa-building-o',
url: 'user4s/visit/visitlog?vid={ids}',
extend: 'data-area=\'["1000px","800px"]\'',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
// if (row.status == 0) {
// return true;
// } else {
// return false;
// }
return true;
}
},
// {
// name: 'rechargelog',
// text: __('结单'),
// title: __('结单'),
// classname: 'btn btn-xs btn-danger btn-dialog',
// icon: 'fa fa-calendar-check-o',
// url: 'user4s/log/index?user4s_id={id}',
// extend: 'data-area=\'["1000px","800px"]\'',
// },
// {
// name: 'visit',
// text: __('回访单'),
// title: __('回访单'),
// classname: 'btn btn-xs btn-info btn-dialog',
// icon: 'fa fa-comments-o',
// url: 'user4s/visit/index?user4s_id={id}',
// 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
}
]
],
queryParams: function (params) {
//这里可以追加搜索条件
var filter = JSON.parse(params.filter);
var op = JSON.parse(params.op);
//这里可以动态赋值比如从URL中获取admin_id的值filter.admin_id=Fast.api.query('admin_id');
filter.status = Fast.api.query('status');
op.status = "=";
if (filter.status == null || filter.status == "") {
delete filter.status;
delete op.status;
}
filter.type_id = Fast.api.query('type_id');
op.type_id = "=";
if (filter.type_id == null || filter.type_id == "") {
delete filter.type_id;
delete op.type_id;
}
params.filter = JSON.stringify(filter);
params.op = JSON.stringify(op);
console.log(params);
return params;
},
});
// 为表格绑定事件
Table.api.bindevent(table);
// 绑定TAB事件
$('.nav-tabs a[data-toggle="tab"]', table.closest(".panel-intro")).on('shown.bs.tab', function (e) {
var that = $(this);
var options = table.bootstrapTable('getOptions');
var queryParams = options.queryParams;
options.pageNumber = 1;
options.queryParams = function (params) {
//这一行必须要存在,否则在点击下一页时会丢失搜索栏数据
params = queryParams(params);
//如果希望追加搜索条件,可使用
var filter = params.filter ? JSON.parse(params.filter) : {}; //参数
var op = params.op ? JSON.parse(params.op) : {}; //符号
//console.log(that.data("value"),'tab');
if (that.data("value")) {
filter['type_id'] = that.data("value");
op['type_id'] = '=';
}
if (that.data("value") == -99) {
delete filter['type_id'];
delete op['type_id'];
}
// 逾期状态
// if (that.data("isyuqi") == 1) {
// filter['status'] = 10;
// var mydate = new Date();
// var date = "" + mydate.getFullYear() + "-";
// date += (mydate.getMonth() + 1) + "-";
// date += mydate.getDate();
// filter['repayment_date'] = date;
// op['repayment_date'] = '<';
// }
params.filter = JSON.stringify(filter);
params.op = JSON.stringify(op);
console.log(params,'tab');
return params;
};
table.trigger("uncheckbox");
table.bootstrapTable('refresh', { pageNumber: 1 });
return false;
});
// 添加按钮事件
$(document).on('click', '.btn-add2', function () {
var ids = Table.api.selectedids(table);
var user4s_id =Fast.api.query('user4s_id');
var url = $.fn.bootstrapTable.defaults.extend.add_url;
if(user4s_id !== ''){
url = url + '?user4s_id=' + user4s_id;
}
if (url.indexOf("{ids}") !== -1) {
url = Table.api.replaceurl(url, {ids: ids.length > 0 ? ids.join(",") : 0}, table);
}
Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Add'), $(this).data() || {});
});
},
recyclebin: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
'dragsort_url': ''
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: 'user4s/visit/recyclebin' + location.search,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{
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/visit/restore',
refresh: true
},
{
name: 'Destroy',
text: __('Destroy'),
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
icon: 'fa fa-times',
url: 'user4s/visit/destroy',
refresh: true
}
],
formatter: Table.api.formatter.operate
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
$('#c-type_id').on('change', function () {
var id = $('#c-type_id').val();
$.ajax({
url: "user4s/visittype/getvtime",
type: "POST", //Use "PUT" for HTTP PUT methods
dataType: 'json',
data: {
id: id,
},
success: function (data, textStatus, jqXHR) {
console.log(data);
if (data.code == 1) {
if (data.data.visit_time != undefined && data.data.visit_time != null && data.data.visit_time != '') {
$('#c-visittime').val(data.data.visit_time);
}
}
},
})
});
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
//回访记录
visitlog: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user4s/visit/visitlog' + location.search,
table: 'user4s_visit',
}
});
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,
commonSearch: false,
//maintainSelected: true,
columns: [
[
//{ checkbox: true },
{field: 'id', title: __('回访记录号'), operate:false},
{field: 'visit_id', title: __('回访单号'), operate:false},
{ field: 'user.name', title: __('会员姓名'), operate: false },
{ field: 'user.tel', title: __('联系方式'), operate: false },
//{ field: 'user.buydate', title: __('购车时间'), operate: false},
{ field: 'user.carno', title: __('车牌号'), operate: false },
// { field: 'user.model', title: __('车型'), operate: false },
// { field: 'user.color', title: __('颜色'), operate: false },
{field: 'star_f', title: __('满意度'), operate: false},
{field: 'description', title: __('Description'), operate: false,editable:true},
{
field: 'visit_time', title: __('回访时间'), operate: 'BETWEEN', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false, formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD'
},
// {
// field: 'visit.endtime', title: __('结单时间'), operate: 'BETWEEN', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false, formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD', visible: function (row) {
// if (row.visit.status == 0) {
// return false;
// } else {
// return true;
// }
// }
// },
{
field: 'admin_id', title: __('Admin_id'), operate: false, formatter: function (value, row, index) {
return row['admin']['nickname'];
}
},
{
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [
{
name: 'renewal',
text: __('编辑'),
title: __('编辑'),
classname: 'btn btn-xs btn-success btn-dialog',
icon: 'fa fa-pencil',
url: 'user4s/visitlog/edit?ids={ids}',
extend: 'data-area=\'["1000px","800px"]\'',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
},
visible: function (row) {
if (row.visit.status == 0) {
return true;
} else {
return false;
}
//返回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);
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});