180 lines
8.5 KiB
JavaScript
180 lines
8.5 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'oa/task/index' + location.search,
|
|
add_url: 'oa/task/add',
|
|
edit_url: 'oa/task/edit',
|
|
del_url: 'oa/task/del',
|
|
multi_url: 'oa/task/multi',
|
|
import_url: 'oa/task/import',
|
|
table: 'task',
|
|
}
|
|
});
|
|
|
|
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: 'exec.nickname', title: __('ExecAdmin.nickname'), operate: 'LIKE'},
|
|
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
|
|
{field: 'title', title: __('Title'), operate: 'LIKE'},
|
|
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
|
|
{field: 'prove_desc', title: __('Prove_desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
{field: 'refuse_reason', title: __('Refuse_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
{field: 'expire_start_time', title: __('Expire_start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
{field: 'expire_end_time', title: __('Expire_end_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
{field: 'complete_time', title: __('Complete_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
|
buttons:[
|
|
{
|
|
name: 'notice',
|
|
text:"催完成",
|
|
title:"催完成",
|
|
icon: 'fa fa-bell-o',
|
|
extend: 'data-toggle="tooltip" data-container="body"',
|
|
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
|
|
url: 'oa/task/notice',
|
|
confirm: '确认发送',
|
|
refresh: true,
|
|
success: function (data, ret) {
|
|
Layer.alert("发送成功");
|
|
return false;
|
|
},
|
|
error: function (data, ret) {
|
|
Layer.alert(ret.msg);
|
|
return false;
|
|
},
|
|
visible: function (row) {
|
|
//返回true时按钮显示,返回false隐藏
|
|
if (row.status != 1) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
},
|
|
{
|
|
name: 'review',
|
|
text: "审核",
|
|
title: "审核",
|
|
classname: 'btn btn-xs btn-primary btn-dialog',
|
|
icon: 'fa fa-list',
|
|
url: 'oa/task/review',
|
|
visible:function(row){
|
|
if (row.status != 3) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
},
|
|
{
|
|
name: 'edit',
|
|
text: "修改",
|
|
icon: 'fa fa-pencil',
|
|
title: __('Edit'),
|
|
extend: 'data-toggle="tooltip" data-container="body"',
|
|
classname: 'btn btn-xs btn-info btn-editone',
|
|
},
|
|
{
|
|
name: 'del',
|
|
text: "删除",
|
|
icon: 'fa fa-trash',
|
|
title: __('Delete'),
|
|
extend: 'data-toggle="tooltip"',
|
|
classname: 'btn btn-xs btn-danger btn-delone',
|
|
},
|
|
]}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
},
|
|
add: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
review: function () {
|
|
|
|
$(document).on('click', '.btn-preview', function (e) {
|
|
e.preventDefault();
|
|
var fileType = $(this).data('filetype'); // 自动从 data-type 获取,比如 pdf, jpg, doc
|
|
var fileUrl = $(this).data('fileurl');
|
|
|
|
if (fileType === 'pdf') {
|
|
Layer.open({
|
|
type: 2,
|
|
title: '预览PDF文件',
|
|
area: ['80%', '80%'],
|
|
content: fileUrl
|
|
});
|
|
} else if (['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(fileType)) {
|
|
Layer.photos({
|
|
photos: {
|
|
"title": "图片预览",
|
|
"data": [{"src": fileUrl}]
|
|
},
|
|
anim: 5
|
|
});
|
|
} else if (['mp4', 'webm', 'ogg'].includes(fileType)) {
|
|
Layer.open({
|
|
type: 1,
|
|
title: '视频预览',
|
|
area: ['800px', '500px'],
|
|
content: `<video src="${fileUrl}" width="100%" height="100%" controls autoplay></video>`
|
|
});
|
|
} else {
|
|
window.open(fileUrl, '_blank');
|
|
}
|
|
});
|
|
|
|
// 点击通过按钮
|
|
$("#btn-approve").click(function () {
|
|
$("#c-status").val("4");
|
|
$("#review-form").submit(); // 提交表单
|
|
});
|
|
|
|
// 点击驳回按钮,弹出 Layer.prompt 收理由
|
|
$("#btn-reject").click(function () {
|
|
Layer.prompt({
|
|
title: '请输入驳回理由',
|
|
formType: 2 // 多行输入框
|
|
}, function (value, index) {
|
|
if (!value.trim()) {
|
|
Layer.msg("驳回理由不能为空");
|
|
return;
|
|
}
|
|
$("#c-status").val("5");
|
|
$("#c-refuse_reason").val(value.trim());
|
|
$("#review-form").submit(); // 提交
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|