allocatr/public/assets/js/backend/salary/detail.js
2025-05-29 14:48:47 +08:00

137 lines
5.1 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'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'salary/detail/index' + location.search,
add_url: 'salary/detail/add',
edit_url: 'salary/detail/edit',
del_url: 'salary/detail/del',
multi_url: 'salary/detail/multi',
import_url: 'salary/detail/import',
table: 'salary_detail',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'admin_id', title: __('Admin_id')},
{field: 'target_admin_id', title: __('Target_admin_id')},
{field: 'item_id', title: __('Item_id')},
{field: 'item_value', title: __('Item_value'), operate:'BETWEEN'},
{field: 'salary_month', title: __('Salary_month'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
custom_index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'salary/detail/custom_index' + location.search,
// add_url: 'oa/schedule/add',
// editable: 'oa/schedule/editable',
// del_url: 'oa/schedule/del',
// multi_url: 'oa/schedule/multi',
// import_url: 'oa/schedule/import',
table: 'salary',
}
});
var table = $("#table");
var defaultColumnArr = [];
defaultColumnArr.push({
"title":"用户名",
"field":"name",
},{
"title":"用户id",
"field":"admin_id",
"visible":false
});
// 获取后端传入的字段定义JSON 字符串)
var columnJson = $('#salaryitem').val();
var rawColumns = JSON.parse(columnJson);
rawColumns.forEach(function (item) {
// 可以加入格式化、样式控制等逻辑
defaultColumnArr.push({
field: item.id,
title: item.name,
});
});
defaultColumnArr.push({
field: 'operate',
title: __('Operate'),
table: table,
buttons: [
{
name: 'custom_edit',
text: '编辑',
title: '编辑薪资',
classname: 'btn btn-xs btn-success btn-dialog',
icon: 'fa fa-edit',
url: function (row) {
// 注意这里拼接 admin_id 和 month
return 'salary/detail/custom_edit?target_admin_id=' + row.admin_id + '&month=' + row.month;
},
extend: 'data-area=\'["800px", "600px"]\'',
}
],
events: Table.api.events.operate,
formatter: Table.api.formatter.operate
});
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
columns: defaultColumnArr,
searchFormVisible: true,
searchFormTemplate: 'customformtpl',
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
custom_add: function () {
Controller.api.bindevent();
},
custom_edit: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});