init Area full CRUD
This commit is contained in:
@@ -6,7 +6,7 @@ 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");
|
||||
common.error("name", "Tên khu vực không được để trống");
|
||||
error++;
|
||||
} else {
|
||||
common.success("name");
|
||||
@@ -14,7 +14,7 @@ function validate() {
|
||||
|
||||
var Code = $("input[name='Code']").val();
|
||||
if (Code === "") {
|
||||
common.error("code", "Mã phòng ban không được để trống");
|
||||
common.error("code", "Mã khu vực không được để trống");
|
||||
error++;
|
||||
} else {
|
||||
common.success("code");
|
||||
@@ -31,20 +31,21 @@ function save(e) {
|
||||
data: {
|
||||
Name: $("input[name='Name']").val(),
|
||||
Code: $("input[name='Code']").val(),
|
||||
Pid: $("select[name='Pid']").val()
|
||||
Pid: $("select[name='Pid']").val(),
|
||||
Description: $("textarea[name='Description']").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");
|
||||
$.pjax.reload({container: '#area-list'});
|
||||
$("#area-list").on('pjax:success', function () {
|
||||
common.checkboxInit("area");
|
||||
});
|
||||
$("#myModal").modal("hide");
|
||||
} else {
|
||||
if (data.type === "code") {
|
||||
common.error("code", "Mã phòng ban đã tồn tại");
|
||||
common.error("code", "Mã khu vực đã tồn tại");
|
||||
} else {
|
||||
notification.danger("Có lỗi xảy ra, không lưu được dữ liệu!", 1000);
|
||||
}
|
||||
@@ -60,7 +61,7 @@ function save(e) {
|
||||
|
||||
function _form(e) {
|
||||
var lists = [];
|
||||
$.each($("input[name='checkbox-department']:checked"), function () {
|
||||
$.each($("input[name='checkbox-area']:checked"), function () {
|
||||
lists.push($(this).val());
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
@@ -89,7 +90,7 @@ function _form(e) {
|
||||
|
||||
function _delete(e) {
|
||||
var lists = [];
|
||||
$.each($("input[name='checkbox-department']:checked"), function () {
|
||||
$.each($("input[name='checkbox-area']:checked"), function () {
|
||||
lists.push($(this).val());
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
@@ -111,9 +112,9 @@ function _delete(e) {
|
||||
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");
|
||||
$.pjax.reload({container: '#area-list'});
|
||||
$("#area-list").on('pjax:success', function () {
|
||||
common.checkboxInit("area");
|
||||
});
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
@@ -128,60 +129,6 @@ 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({
|
||||
|
||||
Reference in New Issue
Block a user