Files
fast_response/admin/public/assets/js/backend/firmcustomer.js
2025-03-22 22:46:52 +08:00

128 lines
5.8 KiB
JavaScript

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'firmcustomer/index' + location.search,
add_url: 'firmcustomer/add',
edit_url: 'firmcustomer/edit',
del_url: 'firmcustomer/del',
multi_url: 'firmcustomer/multi',
import_url: 'firmcustomer/import',
table: 'firmcustomer',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'customer_name', title: __('Customer_name'), operate: 'LIKE'},
{field: 'age', title: __('Age')},
{field: 'phone', title: __('Phone'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'rel_wx', title: __('Rel_wx'), operate: 'LIKE'},
{field: 'rel_group', title: __('Rel_group'), operate: 'LIKE'},
{field: 'firmtags_ids', title: __('Firmtags_ids'), operate: 'LIKE'},
{field: 'headimage', title: __('Headimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'remark', title: __('Remark'), operate: 'LIKE'},
{field: 'responsible_pm', title: __('Responsible_pm'), operate: 'LIKE'},
{field: 'status', title: __('Status'), searchList: {"yes":__('Status yes'),"no":__('Status no')}, formatter: Table.api.formatter.status},
{field: 'firmstoreprojectstwo.name', title: __('Firmstoreprojectstwo.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'firmcustomerorigin.name', title: __('Firmcustomerorigin.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'firmemployee.name', title: __('Firmemployee.name'), operate: 'LIKE'},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
//当表格数据加载完成时
table.on('load-success.bs.table', function (e, data) {
//这里可以获取从服务端获取的JSON数据
// console.log(data);
//这里我们手动设置底部的值
// $("#money").text(data.extend.money);
// $("#price").text(data.extend.price);
//
let load_index = layer.load(1);
$.post('Gewechatfriends/getFriendList',{},function (res) {
layer.close(load_index);
},'json');
// $("#c-rel_wx").data("eSelect", function(data){
// //后续操作
// console.log(data);
//
// });
// $(document).on("change", "#c-rel_wx", function(data){
// //变更后的回调事件
// // $('input[name="c-rel_wx"]').attr('wx_id');
// console.log(data);
// });
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
//设置下拉框后的值
$(document).on("change", "#c-rel_wx", function(data){
//变更后的回调事件
// console.log(data.currentTarget.defaultValue);
$('#c-rel_wx').attr('data-wx_id',data.currentTarget.defaultValue);
});
$('.firmcustomer-sync-info').on('click',function (e){
//读取下拉框的值
let wx_id = $('#c-rel_wx').attr('data-wx_id');
console.log(wx_id);
// console.log(e);
let load_index = layer.load(1);
$.post('Gewechatfriends/getFriendDetail',{wx_id:wx_id},function (res) {
layer.close(load_index);
//回显
$('#c-headimage').val(res.data.smallHeadImgUrl);
},'json');
});
// $(document).on("click", ".tag_add_url", function(data){
// //变更后的回调事件
// let url = 'firmtags/add';
// $.get(url,{firm_customer_req:'firm_customer_req'},function (res) {
// layer.open({
// title: '在线调试',
// area: ['80%', '80%'],
// content: res.html
// });
//
// },'json');
// });
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});