cập nhật tính năng quản trị phòng ban

This commit is contained in:
2020-10-07 17:29:30 +07:00
parent 586be80cf6
commit 2d15fc1c14
22 changed files with 1041 additions and 72 deletions

View File

@@ -228,4 +228,30 @@ table > tbody > tr.success >td>a {
}
.box-header{
border-bottom: 1px solid #cecece;
}
.skin-blue .main-header .logo{
background-color: #3c8dbc !important;
}
.content{
padding: 0 !important;
}
.content-header{
padding: 0 !important;
}
.action-button{
padding: 10px;
margin: 0;
cursor: pointer;
font-weight: inherit;
}
.action-button:hover{
font-weight: bold;
background: #b2d7ec;
border: 1px solid #3c8dbc;
}
.modal-header{
padding: 10px;
background: #b2d7ec;
}

View File

@@ -218,25 +218,8 @@ common.form = function (e, obj) {
success: function (data) {
common.modalBlock(false);
common.modalOpen(data.form, false, data.title);
if (obj === 'user')
$('#role').select2({tags: true, tokenSeparators: [',']});
if (obj === 'gia_han_the')
$('#GiaHan').datetimepicker({
locale: 'vi',
ignoreReadonly: true,
format: 'DD/MM/YYYY'
});
if (obj === 'cau_hinh_chi_phi') {
common.dateTimePickerHour("from");
common.dateTimePickerHour("to");
$('.time').datetimepicker({
locale: 'vi',
ignoreReadonly: true,
format: 'HH:mm'
});
}
if (obj === 'department')
$('#Pid').select2();
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
@@ -244,6 +227,18 @@ common.form = function (e, obj) {
}
});
};
common.checkboxInit = function (id) {
$('.checkbox-' + id).iCheck({
checkboxClass: 'icheckbox_flat-blue'
});
$('#checkall-' + id).on('ifChanged', function (event) {
if (event.target.checked) {
$('.checkbox-' + id).iCheck('check');
} else {
$('.checkbox-' + id).iCheck('uncheck');
}
});
};
/**
* =========================
*/

200
web/js/department.js Normal file
View File

@@ -0,0 +1,200 @@
$(function () {
common.checkboxInit("department");
btnUpload($("input[name='upload_file_url']").val(), "", '.xls,.xlsx', 3500);
});
function validate() {
var error = 0;
var Name = $("input[name='Name']").val();
if (Name === "") {
common.error("name", "Tên phòng ban không được để trống");
error++;
} else {
common.success("name");
}
var Code = $("input[name='Code']").val();
if (Code === "") {
common.error("code", "Mã phòng ban không được để trống");
error++;
} else {
common.success("code");
}
return error == 0 ? true : false;
}
function save(e) {
if (validate()) {
common.modalBlock(true);
$.ajax({
url: $(e).attr('data-href'),
type: 'POST',
data: {
Name: $("input[name='Name']").val(),
Code: $("input[name='Code']").val(),
Pid: $("select[name='Pid']").val()
},
success: function (data) {
common.modalBlock(false);
if (data.status) {
notification.success("Đã lưu thông tin", 1000);
$.pjax.reload({container: '#department-list'});
$("#department-list").on('pjax:success', function () {
common.checkboxInit("department");
});
$("#myModal").modal("hide");
} else {
if (data.type === "code") {
common.error("code", "Mã phòng ban đã tồn tại");
} else {
notification.danger("Có lỗi xảy ra, không lưu được dữ liệu!", 1000);
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
}
function _form(e) {
var lists = [];
$.each($("input[name='checkbox-department']:checked"), function () {
lists.push($(this).val());
});
if (lists.length == 0) {
alert("Vui lòng lựa chọn đối tượng để thay đổi!");
return;
}
if (lists.length > 1) {
alert("Tác vụ này không thể lựa chọn nhiều hơn một đối tượng!");
return;
}
common.modalBlock(true);
$.ajax({
url: $(e).attr('data-href') + "?id=" + lists[0],
type: 'POST',
success: function (data) {
common.modalBlock(false);
common.modalOpen(data.form, false, data.title);
$('#Pid').select2();
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
function _delete(e) {
var lists = [];
$.each($("input[name='checkbox-department']:checked"), function () {
lists.push($(this).val());
});
if (lists.length == 0) {
alert("Vui lòng lựa chọn đối tượng để xóa!");
return;
}
if (lists.length == 1 && lists[0] === "1") {
alert("Danh mục gốc không thể xóa!");
return;
}
if (confirm("Bạn có chắc chắn muốn xóa các đối tượng đã lựa chọn không?")) {
common.modalBlock(true);
$.ajax({
url: $(e).attr('data-href'),
type: 'POST',
data: {
lists: lists
},
success: function (data) {
common.modalBlock(false);
notification.danger("Đã xóa dữ liệu", 1000);
$.pjax.reload({container: '#department-list'});
$("#department-list").on('pjax:success', function () {
common.checkboxInit("department");
});
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
}
function _export(e) {
window.location = $(e).attr("data-href");
}
function btnUpload(mUrl, className, extension, fileSize) {
var fData = {
UploadFile: true,
Name: className
};
fData[common.csrfParam] = common.csrf;
new afuButton({
uploadURI: mUrl,
formData: fData,
wrap: {
tagName: 'div',
classes: ''
},
fileExtension: extension,
fileSizeLimit: fileSize,
classes: 'btn btn-default file-paperclip-' + className,
fakeInputContent: '<span class=\'fa fa-upload\'></span> Nhập dữ liệu',
onUploaded: function (data) {
data = JSON.parse(data);
common.modalOpen(data.form, true, data.title);
common.uploadBlock(false);
common.checkboxInit("department-import");
}
}).addInstance('file' + className);
$(".file-paperclip-" + className).closest("div").attr("style", "display:inline-block;");
}
function _import(e) {
var lists = [];
$.each($("input[name='checkbox-department-import']:checked"), function () {
lists.push($(this).val());
});
if (lists.length == 0) {
alert("Vui lòng lựa chọn đối tượng để nhập!");
return;
}
common.modalBlock(true);
$.ajax({
url: $(e).attr('data-href'),
type: 'POST',
data: {
lists: lists
},
success: function (data) {
common.modalBlock(false);
window.location.reload(true);
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
function _logs(e) {
common.modalBlock(true);
$.ajax({
url: $(e).attr('data-href'),
type: 'POST',
success: function (data) {
common.modalBlock(false);
common.modalOpen(data.form, true, data.title);
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}