define(['jquery', 'bootstrap', 'frontend', 'form', 'template'], function ($, undefined, Frontend, Form, Template) {
var validatoroptions = {
invalid: function (form, errors) {
$.each(errors, function (i, j) {
Layer.msg(j);
});
}
};
var Controller = {
login: function () {
//本地验证未通过时提示
$("#login-form").data("validator-options", validatoroptions);
//为表单绑定事件
Form.api.bindevent($("#login-form"), function (data, ret) {
setTimeout(function () {
location.href = ret.url ? ret.url : "/";
}, 1000);
});
// 获取用户名和密码输入框
const usernameInput = $("#account");
const passwordInput = $("#password");
const keeploginCheck = $('#keeplogin');
// 获取记住密码复选框
const keepLoginCheckbox = $("input[name='keeplogin']");
// 表单提交时判断记住密码复选框是否被选中
$("#login-form").submit(function(event) {
if (keepLoginCheckbox.is(":checked")) {
// 将用户名和密码存储在 localStorage 中
localStorage.setItem("username", usernameInput.val());
localStorage.setItem("password", passwordInput.val());
localStorage.setItem("keeplogin", keepLoginCheckbox.is(":checked"));
}
});
// 下次用户访问时,如果 localStorage 中存在用户名和密码,则自动填充到登录表单中
$(document).ready(function() {
if (localStorage.getItem("username") && localStorage.getItem("password")) {
usernameInput.val(localStorage.getItem("username"));
passwordInput.val(localStorage.getItem("password"));
keeploginCheck.attr('checked', localStorage.getItem("keeplogin"))
}
});
//忘记密码
$(document).on("click", ".btn-forgot", function () {
var id = "resetpwdtpl";
var content = Template(id, {});
Layer.open({
type: 1,
title: 'Reset password',
area: ["450px", "355px"],
content: content,
success: function (layero) {
var rule = $("#resetpwd-form input[name='captcha']").data("rule");
Form.api.bindevent($("#resetpwd-form", layero), function (data) {
Layer.closeAll();
});
$(layero).on("change", "input[name=type]", function () {
var type = $(this).val();
$("div.form-group[data-type]").addClass("hide");
$("div.form-group[data-type='" + type + "']").removeClass("hide");
$('#resetpwd-form').validator("setField", {
captcha: rule.replace(/remote\((.*)\)/, "remote(" + $(this).data("check-url") + ", event=resetpwd, " + type + ":#" + type + ")")
});
$(".btn-captcha").data("url", $(this).data("send-url")).data("type", type);
});
}
});
});
},
register: function () {
$(document).ready(function () {
$('.submit-button').prop('type', 'button');
});
$('.submit-button').click(function () {
if ($(this).prop('type') == 'button') {
$('.privacy_text').show();
}
});
$(document).on('click', '#privacy_checkbox', function () {
if (!$(this).prop('checked')) {
$('.privacy_text').show();
$('.submit-button').prop('type', 'button');
} else {
$('.privacy_text').hide();
$('.submit-button').prop('type', 'submit');
}
});
//本地验证未通过时提示
$("#register-form").data("validator-options", validatoroptions);
//为表单绑定事件
Form.api.bindevent($("#register-form"), function (data, ret) {
setTimeout(function () {
location.href = ret.url ? ret.url : "/";
}, 6000);
}, function (data) {
$("input[name=captcha]").next(".input-group-btn").find("img").trigger("click");
});
},
changepwd: function () {
//本地验证未通过时提示
$("#changepwd-form").data("validator-options", validatoroptions);
//为表单绑定事件
Form.api.bindevent($("#changepwd-form"), function (data, ret) {
setTimeout(function () {
location.href = ret.url ? ret.url : "/";
}, 1000);
});
},
profile: function () {
// 给上传按钮添加上传成功事件
$("#faupload-avatar").data("upload-success", function (data) {
var url = Fast.api.cdnurl(data.url);
$(".profile-user-img").prop("src", url);
Toastr.success('Uploaded successful');
});
Form.api.bindevent($("#profile-form"));
$(document).on("click", ".btn-change", function () {
var that = this;
var id = $(this).data("type") + "tpl";
var content = Template(id, {});
Layer.open({
type: 1,
title: "修改",
area: ["400px", "250px"],
content: content,
success: function (layero) {
var form = $("form", layero);
Form.api.bindevent(form, function (data) {
location.reload();
Layer.closeAll();
});
}
});
});
},
attachment: function () {
require(['table'], function (Table) {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user/attachment',
}
});
var urlArr = [];
var multiple = Fast.api.query('multiple');
multiple = multiple == 'true' ? true : false;
var table = $("#table");
table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function (e, row) {
if (e.type == 'check' || e.type == 'uncheck') {
row = [row];
} else {
urlArr = [];
}
$.each(row, function (i, j) {
if (e.type.indexOf("uncheck") > -1) {
var index = urlArr.indexOf(j.url);
if (index > -1) {
urlArr.splice(index, 1);
}
} else {
urlArr.indexOf(j.url) == -1 && urlArr.push(j.url);
}
});
});
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
sortName: 'id',
showToggle: false,
showExport: false,
fixedColumns: true,
fixedRightNumber: 1,
columns: [
[
{field: 'state', checkbox: multiple, visible: multiple, operate: false},
{field: 'id', title: __('Id'), operate: false},
{
field: 'url', title: __('Preview'), formatter: function (value, row, index) {
var html = '';
if (row.mimetype.indexOf("image") > -1) {
html = '';
} else {
html = '';
}
return '
' + html + '
';
}
},
{
field: 'filename', title: __('Filename'), formatter: function (value, row, index) {
return '' + Table.api.formatter.search.call(this, value, row, index) + '
';
}, operate: 'like'
},
{field: 'imagewidth', title: __('Imagewidth'), operate: false},
{field: 'imageheight', title: __('Imageheight'), operate: false},
{field: 'mimetype', title: __('Mimetype'), formatter: Table.api.formatter.search},
{
field: 'createtime',
title: __('Createtime'),
width: 120,
formatter: Table.api.formatter.datetime,
datetimeFormat: 'YYYY-MM-DD',
operate: 'RANGE',
addclass: 'datetimerange',
sortable: true
},
{
field: 'operate', title: __('Operate'), width: 85, events: {
'click .btn-chooseone': function (e, value, row, index) {
Fast.api.close({url: row.url, multiple: multiple});
},
}, formatter: function () {
return ' ' + __('Choose') + '';
}
}
]
]
});
// 选中多个
$(document).on("click", ".btn-choose-multi", function () {
Fast.api.close({url: urlArr.join(","), multiple: multiple});
});
// 为表格绑定事件
Table.api.bindevent(table);
require(['upload'], function (Upload) {
Upload.api.upload($("#toolbar .faupload"), function () {
$(".btn-refresh").trigger("click");
});
});
});
},
inbox: function () {
$(document).ready(function () {
$(document).on('click', '#read-button', function () {
let email_id = $(this).attr('data-id');
$.ajax({
url: '/api/user/read_email', // 后台处理数据请求的接口地址
type: 'POST',
dataType: 'json',
data: {
email_id: email_id,
},
success: function (res) {
if (res.code === 1) {
layer.msg(res.msg, {
icon: 1,
time: 2000,
}, function () {
location.reload();
});
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
});
});
},
unread: function () {
$(document).ready(function () {
$(document).on('click', '#read-button', function () {
let email_id = $(this).attr('data-id');
$.ajax({
url: '/api/user/read_email', // 后台处理数据请求的接口地址
type: 'POST',
dataType: 'json',
data: {
email_id: email_id,
},
success: function (res) {
if (res.code === 1) {
layer.msg(res.msg, {
icon: 1,
time: 2000,
}, function () {
location.reload();
});
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
});
});
},
submit_manuscript: function () {
// 初始化分页参数
var currentPage = 1;
var pageSize = 10;
var index = 0;
var is_next = false;
var button_next = false;
var manuscript_id = $("#c-manuscript_id").val();
var custom_mousemove_x = 490;
var custom_mousemove_y = 350;
$(document).ready(function () {
// 下一步按钮
$('.next-button').on('click', function () {
// 陈述内容可点击下一步按钮
if ($('.statement-content').css('display') == 'block') {
is_next = true;
}
// 推荐内容可点击下一步按钮
if ($('.recommended-content').css('display') == 'block') {
is_next = true;
}
// 判断当前页面的必填项是否都填写
if (index == 0) {
$("#c-manuscript-zip").trigger("validate");
let manuscript_zip = $("#c-manuscript-zip").isValid();
if (!manuscript_zip) {
return true;
}
}
// 手稿信息
if (index == 1) {
// $("#c-image").trigger("validate");
$('#c-journal').trigger("validate");
$('#c-article-type').trigger("validate");
$('#c-title').trigger("validate");
$('#c-abstract').trigger("validate");
$("#c-keywords").trigger("validate");
// let image = $("#c-image").isValid();
let journal = $('#c-journal').isValid();
let article_type = $('#c-article-type').isValid();
let title = $('#c-title').isValid();
let abstract = $("#c-abstract").isValid();
let keywords = $('#c-keywords').isValid();
// if (!image) {
// return true;
// }
if (!journal) {
return true;
}
if (!article_type) {
return true;
}
if (!title) {
return true;
}
if (!abstract) {
return true;
}
if (!keywords) {
return true;
}
// if (!number_page) {
// return true;
// }
is_next = true;
}
// 作者信息
if (index == 2) {
;
for (let i = 0; i < $('.add-author-item').length; i++) {
$("[name='row[author][" + i + "][email]']").trigger("validate");
$("[name='row[author][" + i + "][first_name]']").trigger("validate");
$("[name='row[author][" + i + "][author_affiliation]']").trigger("validate");
$("[name='row[author][" + i + "][author_country]']").trigger("validate");
let email = $("[name='row[author][" + i + "][email]']").isValid();
let first_name = $("[name='row[author][" + i + "][first_name]']").isValid();
let author_affiliation = $("[name='row[author][" + i + "][author_affiliation]']").isValid();
let author_country = $("[name='row[author][" + i + "][author_country]']").isValid();
if (!email) {
return true;
}
if (!first_name) {
return true;
}
if (!author_affiliation) {
return true;
}
if (!author_country) {
return true;
}
}
is_next = true;
}
if (is_next || index == 0) {
index++;
$("ul.nav-justified li").removeClass("active");
$("ul.nav-justified .nav-item .nav-content .nav-li-desc").removeClass("finish");
$("ul.nav-justified li:eq(" + index + ")").addClass("active");
$("ul.nav-justified .nav-item:eq(" + index + ") .nav-content .nav-li-desc").addClass('finish');
if (index == 5) {
button_next = true;
// 如果是最后一页操作时显示提交按钮,隐藏下一步按钮
$('.next-button').css('display', 'none');
$('.submit-button').css('display', 'block');
$(".manuscript-content").show();
$(".journal-content").show();
$(".add-author-content").show();
$('.recommended-button').hide();
$('.become-review').show();
// 最后一步设置鼠标移动时div的x与y轴的减少距离
custom_mousemove_x = 500;
custom_mousemove_y = 2000;
} else if (index == 4) {
$('.recommended-button').show();
$(".form-item").hide();
$('.become-review').hide();
$(".form-item:eq(" + index + ")").show();
} else if (index == 2) {
$(".author-button").show();
$(".form-item").hide();
$('.become-review').hide();
$(".form-item:eq(" + index + ")").show();
$(".recommended-button").hide();
} else {
$('.recommended-button').hide();
$(".author-item").hide();
$('.author-button').hide();
$(".form-item").hide();
$('.become-review').hide();
$(".form-item:eq(" + index + ")").show();
}
is_next = false;
}
});
// 隐藏所有表单内容
$(".form-item").hide();
// 显示第一个表单内容
$(".form-item:first").show();
// 点击步骤条切换表单
$("ul.nav-justified .nav-item").click(function () {
if (manuscript_id) {
let li_index = $(this).index();
$("ul.nav-justified li").removeClass("active");
$("ul.nav-justified .nav-item .nav-content .nav-li-desc").removeClass("finish");
$("ul.nav-justified li:eq(" + li_index + ")").addClass("active");
$("ul.nav-justified .nav-item:eq(" + li_index + ") .nav-content .nav-li-desc").addClass('finish');
index = li_index;
if (li_index == 5) {
$('.next-button').css('display', 'none');
$('.submit-button').css('display', 'block');
$(".manuscript-content").show();
$(".journal-content").show();
$(".add-author-content").show();
$('.recommended-button').hide();
$('.become-review').show();
// 最后一步设置鼠标移动时div的x与y轴的减少距离
custom_mousemove_x = 500;
custom_mousemove_y = 2000;
} else if (li_index == 4) {
$('.recommended-button').show();
$(".form-item").hide();
$(".form-item:eq(" + li_index + ")").show();
$(".author-button").hide();
} else if (li_index == 2) {
$(".author-button").show();
$(".form-item").hide();
$(".form-item:eq(" + li_index + ")").show();
$('.recommended-button').hide();
} else {
$('.recommended-button').hide();
$(".author-item").hide();
$('.author-button').hide();
$(".form-item").hide();
$(".form-item:eq(" + li_index + ")").show();
}
if (li_index != 5) {
$('.next-button').css('display', 'block');
$('.submit-button').css('display', 'none');
$('.become-review').hide();
}
} else {
if (button_next) {
index = 5;
}
if ($(this).index() <= index) {
let li_index = $(this).index();
$("ul.nav-justified li").removeClass("active");
$("ul.nav-justified .nav-item .nav-content .nav-li-desc").removeClass("finish");
$("ul.nav-justified li:eq(" + li_index + ")").addClass("active");
$("ul.nav-justified .nav-item:eq(" + li_index + ") .nav-content .nav-li-desc").addClass('finish');
index = li_index;
if (li_index == 5) {
$('.next-button').css('display', 'none');
$('.submit-button').css('display', 'block');
$(".manuscript-content").show();
$(".journal-content").show();
$(".add-author-content").show();
$('.recommended-button').hide();
$('.become-review').show();
// 最后一步设置鼠标移动时div的x与y轴的减少距离
custom_mousemove_x = 500;
custom_mousemove_y = 2000;
} else if (li_index == 4) {
$('.recommended-button').show();
$(".form-item").hide();
$(".form-item:eq(" + li_index + ")").show();
$(".author-button").hide();
} else if (li_index == 2) {
$(".author-button").show();
$(".form-item").hide();
$(".form-item:eq(" + li_index + ")").show();
$('.recommended-button').hide();
} else {
$('.recommended-button').hide();
$(".author-item").hide();
$('.author-button').hide();
$(".form-item").hide();
$(".form-item:eq(" + li_index + ")").show();
}
if (li_index != 5) {
$('.next-button').css('display', 'block');
$('.submit-button').css('display', 'none');
$('.become-review').hide();
}
}
}
});
// 删除对应作者信息
$(document).on('click', '.author-delete-button', function () {
let author_content_length = $('.add-author-content').children('.add-author-item').length;
if (author_content_length > 1) {
$(this).parent().parent().parent().remove();
// 删除后更新 input 的 name 值
updateInputNames();
}
});
// 审稿人列表按钮
$(document).on('click', '.reviewer-list-button', function () {
let selected_id = [];
$('.recommended-del').each(function () {
let id = $(this).data('id');
selected_id.push(id);
})
// 清空表格内容和分页区域
$('#modal-table tbody').html('');
$('#modal-pagination').html('');
// 发送 Ajax 请求获取数据并填充表格和分页
$.ajax({
url: 'user/getReviewerList', // 后台处理数据请求的接口地址
type: 'GET',
dataType: 'json',
data: {
page: currentPage,
limit: pageSize
},
success: function (data) {
if (data.code === 1) {
var tableData = data.data.data;
for (var i = 0; i < tableData.length; i++) {
var rowData = tableData[i];
let is_disabled = '';
if (selected_id.includes(rowData.id)) {
is_disabled = 'disabled';
}
var rowHtml = '' +
' | ' +
'' + rowData.user.nickname + ' | ' +
'' + rowData.user.email + ' | ' +
'' + rowData.user.first_name + ' | ' +
'' + rowData.user.last_name + ' | ' +
'' + rowData.affiliation + ' | ' +
'' + rowData.field + ' | ' +
'
';
$('#modal-table tbody').append(rowHtml);
}
// 计算总页数
var totalPage = Math.ceil(data.data.total / pageSize);
// 动态生成分页按钮,使用省略号表示更多页码
var pageHtml = '';
if (totalPage <= 7) { // 当总页数小于等于7时,显示所有页码按钮
for (var i = 1; i <= totalPage; i++) {
if (i === currentPage) {
pageHtml += '';
} else {
pageHtml += '';
}
}
} else { // 当总页数大于7时,进行分段显示
if (currentPage <= 4) {
pageHtml += generatePagination(1, 5);
pageHtml += '...';
pageHtml += '';
} else if (currentPage >= totalPage - 3) {
pageHtml += '';
pageHtml += '...';
pageHtml += generatePagination(totalPage - 4, totalPage);
} else {
pageHtml += '';
pageHtml += '...';
//只需要更改这一行的逻辑即可
var startPage = currentPage - 2;
var endPage = currentPage + 2;
pageHtml += generatePagination(startPage, endPage);
//只需要更改这一行的逻辑即可
}
}
$('#modal-pagination').html(pageHtml);
// 绑定分页按钮点击事件
$('.pagination-link').click(function (e) {
$('.pagination-link').removeClass('active');
$(this).addClass('active');
e.preventDefault();
var page = parseInt($(this).text());
currentPage = page;
// 发送 Ajax 请求获取对应页的数据并填充表格
$.ajax({
url: 'user/getReviewerList',
type: 'GET',
dataType: 'json',
data: {
page: currentPage,
limit: pageSize
},
success: function (data) {
if (data.code === 1) {
var tableData = data.data.data;
$('#modal-table tbody').html('');
for (var i = 0; i < tableData.length; i++) {
var rowData = tableData[i];
let is_disabled = '';
if (selected_id.includes(rowData.id)) {
is_disabled = 'disabled';
}
var rowHtml = '' +
' | ' +
'' + rowData.user.nickname + ' | ' +
'' + rowData.user.email + ' | ' +
'' + rowData.user.first_name + ' | ' +
'' + rowData.user.last_name + ' | ' +
'' + rowData.affiliation + ' | ' +
'' + rowData.field + ' | ' +
'
';
$('#modal-table tbody').append(rowHtml);
}
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
});
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
});
// 选择审稿人后确定选择
$(document).on('click', '.add-review-button', function () {
let tr_length = $('#recommended-table tbody tr').length;
var selectedValues = [];
// 使用 jQuery 的 each 函数遍历所有 name 为 option 的复选框
$('input[type=checkbox]:checked').each(function () {
let obj = {};
obj['id'] = $(this).data('id');
obj['name'] = $(this).data('name');
obj['email'] = $(this).data('email');
obj['first_name'] = $(this).data('first');
obj['last_name'] = $(this).data('last');
obj['affiliation'] = $(this).data('affiliation');
obj['field'] = $(this).data('field');
selectedValues.push(obj); // 将选中的值添加到数组中
});
for (var i = 0; i < selectedValues.length; i++) {
var rowData = selectedValues[i];
if (selectedValues.length > 1) {
if (i > 0) {
tr_length++;
}
}
let html = '\n' +
' \n' +
' \n' +
' \n' +
' \n' +
' ';
var rowHtml = '' +
'' + rowData.name + ' | ' +
'' + rowData.email + ' | ' +
'' + rowData.first_name + ' | ' +
'' + rowData.last_name + ' | ' +
'' + rowData.affiliation + ' | ' +
'' + rowData.field + ' | ' +
'删除 | ' +
'
';
$('#recommended-table tbody').append(rowHtml);
$('.reviewer-hidden-content').append(html);
}
$('#myModal').modal('hide');
});
// 自定义添加审稿人按钮
$(document).on('click', '.add-reviewer-button', function () {
let input_index = $('.custom-reviewer-content').children('.custom-reviewer-item').length;
let str = '\n' +
'
\n' +
'
\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'
';
$('.custom-reviewer-content').append(str);
updateReviewerInputNames();
});
// 排序input 的 name 值
var updateReviewerInputNames = function () {
// 遍历所有的div元素
$(".custom-reviewer-item").each(function (index) {
var name_input = $(this).find('input[id="c-add-review-name"]');
var email_input = $(this).find('input[id="c-add-review-email"]');
var first_name_input = $(this).find('input[id="c-add-review-first-name"]');
var last_name_input = $(this).find('input[id="c-add-review-last-name"]');
var affiliation_input = $(this).find('input[id="c-add-review-affiliation"]');
var field_input = $(this).find('input[id="c-add-review-field"]');
name_input.attr('name', "row[reviewer][" + index + "][reviewer-name]");
email_input.attr('name', "row[reviewer][" + index + "][reviewer-email]");
first_name_input.attr('name', "row[reviewer][" + index + "][reviewer-first-name]");
last_name_input.attr('name', "row[reviewer][" + index + "][reviewer-last-name]");
affiliation_input.attr('name', "row[reviewer][" + index + "][reviewer-affiliation]");
field_input.attr('name', "row[reviewer][" + index + "][reviewer-field]");
});
};
// 删除对应的审稿人信息
$(document).on('click', '.reviewer-delete-button', function () {
let reviewer_content_length = $('.custom-reviewer-content').children('.custom-reviewer-item').length;
if (reviewer_content_length > 1) {
$(this).parent().parent().remove();
// 删除后更新 input 的 name 值
updateReviewerInputNames();
}
});
// 自定义审稿人信息提交按钮操作
$(document).on('click', '.add-reviewer-submit', function () {
let tr_length = $('#recommended-table tbody tr').length;
let key = $(".custom-reviewer-item").length;
let addReviewerInputValue = [];
for (let i = 0; i < key; i++) {
let obj = {};
if ($(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-name]']").val() == '') {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-name]']").css('border', '1px solid red');
return false;
} else {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-name]']").css('border', 'none');
}
if ($(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-email]']").val() == '') {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-email]']").css('border', '1px solid red');
return false
} else {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-email]']").css('border', 'none');
}
if ($(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-first-name]']").val() == '') {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-first-name]']").css('border', '1px solid red');
return false;
} else {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-first-name]']").css('border', 'none');
}
if ($(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-last-name]']").val() == '') {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-last-name]']").css('border', '1px solid red');
return false;
} else {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-last-name]']").css('border', 'none');
}
if ($(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-affiliation]']").val() == '') {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-affiliation]']").css('border', '1px solid red');
return false;
} else {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-affiliation]']").css('border', 'none');
}
if ($(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-field]']").val() == '') {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-field]']").css('border', '1px solid red');
return false;
} else {
$(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-field]']").css('border', 'none');
}
obj['name'] = $(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-name]']").val();
obj['email'] = $(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-email]']").val();
obj['first_name'] = $(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-first-name]']").val();
obj['last_name'] = $(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-last-name]']").val();
obj['affiliation'] = $(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-affiliation]']").val();
obj['field'] = $(this).parent().parent().find("input[name='row[reviewer][" + i + "][reviewer-field]']").val();
addReviewerInputValue.push(obj);
}
for (var i = 0; i < addReviewerInputValue.length; i++) {
var rowData = addReviewerInputValue[i];
if (addReviewerInputValue.length > 1) {
if (i > 0) {
tr_length++;
}
}
let html = '\n' +
' \n' +
' \n' +
' \n' +
' \n' +
' ';
var rowHtml = '' +
'' + rowData.name + ' | ' +
'' + rowData.email + ' | ' +
'' + rowData.first_name + ' | ' +
'' + rowData.last_name + ' | ' +
'' + rowData.affiliation + ' | ' +
'' + rowData.field + ' | ' +
'删除 | ' +
'
';
$('#recommended-table tbody').append(rowHtml);
$('.reviewer-hidden-content').append(html);
}
// 清空已填内容
$('.custom-reviewer-content').html('');
$('.custom-reviewer-content').append('\n' +
'
\n' +
'
\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'
');
$('#addReviewModal').modal('hide');
});
// 删除已选中的审稿人
$(document).on('click', '.recommended-del', function () {
let index = $(this).data('index');
$('.reviewer-hidden-content').find('input[name="row[reviewer]\\[' + index + '\\]\\[reviewer-name\\]"]').remove();
$('.reviewer-hidden-content').find('input[name="row[reviewer]\\[' + index + '\\]\\[reviewer-email\\]"]').remove();
$('.reviewer-hidden-content').find('input[name="row[reviewer]\\[' + index + '\\]\\[reviewer-first-name\\]"]').remove();
$('.reviewer-hidden-content').find('input[name="row[reviewer]\\[' + index + '\\]\\[reviewer-last-name\\]"]').remove();
$('.reviewer-hidden-content').find('input[name="row[reviewer]\\[' + index + '\\]\\[reviewer-affiliation\\]"]').remove();
$('.reviewer-hidden-content').find('input[name="row[reviewer]\\[' + index + '\\]\\[reviewer-field\\]"]').remove();
$(this).parent().remove();
// 重新排列键值
});
// 辅助函数:生成指定起始页码和结束页码的分页按钮HTML代码
function generatePagination(startPage, endPage) {
var pageHtml = '';
for (var i = startPage; i <= endPage; i++) {
if (i === currentPage) {
pageHtml += '';
} else {
pageHtml += '';
}
}
return pageHtml;
}
let copyright_files_value = $("input[name='row[is_copyright]']:checked").val();
if (copyright_files_value == 'normal') {
$('.copyright_files').show();
} else {
$('.copyright_files').hide();
}
let is_funding_value = $("input[name='row[is_funding]']:checked").val();
if (is_funding_value == 'normal') {
$('.funding_content').show();
} else {
$('.funding_content').hide();
}
let is_interest_value = $("input[name='row[is_interest]']:checked").val();
if (is_interest_value == 'normal') {
$('.interest_content').show();
} else {
$('.interest_content').hide();
}
let is_become_review = $("input[name='row[is_become_review]']:checked").val();
if (is_become_review == 'normal') {
$('.field_content').show();
} else {
$('.field_content').hide();
}
});
// 添加作者
$('.author-button').click(function () {
let input_index = $('.add-author-content').children('.add-author-item').length;
// let input_index = author_content_length - 1;
// 克隆作者信息
let str = `
Author ${input_index + 1}
`;
$('.add-author-content').append(str);
// 更新 name 值为按顺序增加的索引值
updateInputNames();
});
// 排序input 的 name 值
function updateInputNames() {
// 遍历所有的div元素
$(".add-author-item").each(function (index) {
var email_input = $(this).find('input[id="c-email"]');
var first_name_input = $(this).find('input[id="c-first-name"]');
var middle_name_input = $(this).find('input[id="c-middle-name"]');
var last_name_input = $(this).find('input[id="c-last-name"]');
var author_affiliation_input = $(this).find('input[id="c-author-affiliation"]');
var display_email_yes_radio = $(this).find('input[id="c-display-e-mail-yes"]');
var display_email_no_radio = $(this).find('input[id="c-display-e-mail-no"]');
var correspondsing_author_yes_radio = $(this).find('input[id="c-correspondsing-author-yes"]');
var correspondsing_author_no_radio = $(this).find('input[id="c-correspondsing-author-no"]');
var select = $(this).find("select");
email_input.attr('name', "row[author][" + index + "][email]");
first_name_input.attr('name', "row[author][" + index + "][first_name]");
middle_name_input.attr('name', "row[author][" + index + "][middle_name]");
last_name_input.attr('name', "row[author][" + index + "][last_name]");
author_affiliation_input.attr('name', "row[author][" + index + "][author_affiliation]");
display_email_yes_radio.attr('name', "row[author][" + index + "][display_email]");
display_email_no_radio.attr('name', "row[author][" + index + "][display_email]");
if (display_email_yes_radio[0].checked) {
display_email_yes_radio.prop('checked', 'checked');
}
if (display_email_no_radio[0].checked) {
display_email_no_radio.prop('checked', 'checked');
}
if (correspondsing_author_yes_radio[0].checked) {
correspondsing_author_yes_radio.prop('checked', 'checked');
}
if (correspondsing_author_no_radio[0].checked) {
correspondsing_author_no_radio.prop('checked', 'checked');
}
correspondsing_author_yes_radio.attr('name', "row[author][" + index + "][correspondsing_author]");
correspondsing_author_no_radio.attr('name', "row[author][" + index + "][correspondsing_author]");
$(this).find('.author-sort-number-text').html('Author' + (index + 1));
select.attr('name', "row[author][" + index + "][author_country]");
});
}
$.fn.serializeObject = function () {
var obj = {};
var arrayTmp = this.serializeArray();
$.each(arrayTmp, function () {
if (obj[this.name]) {
if (!obj[this.name].push) {
obj[this.name] = [obj[this.name]];
}
obj[this.name].push(this.value || '');
} else {
obj[this.name] = this.value || '';
}
});
return obj;
};
// 实时保存
$(document).on('mouseup', function () {
let values = $('#submit-manuscript-form').serializeObject();
if (index != 2) {
$.ajax({
url: '/api/user/incomplete_submit',
type: 'POST',
dataType: 'json',
data: values,
success: function (res) {
// 如果保存了就代表接下来都是修改,所以记录返回的id
if (res.code == 1) {
$('#c-manuscript_id').val(res.data);
}
},
error: function (xhr, status, error) {
top.window.Toastr.error('Save failed');
}
});
}
})
// 单选框选择显示对应input
$(document).on('click', '.radio-inline', function () {
let copyright_files_value = $("input[name='row[is_copyright]']:checked").val();
if (copyright_files_value === 'normal') {
$('.copyright_files').show();
} else {
$('.copyright_files').hide();
}
let is_funding_value = $("input[name='row[is_funding]']:checked").val();
if (is_funding_value === 'normal') {
$('.funding_content').show();
} else {
$('.funding_content').hide();
}
let is_interest_value = $("input[name='row[is_interest]']:checked").val();
if (is_interest_value === 'normal') {
$('.interest_content').show();
} else {
$('.interest_content').hide();
}
let is_become_review = $("input[name='row[is_become_review]']:checked").val();
if (is_become_review === 'normal') {
$('.field_content').show();
} else {
$('.field_content').hide();
}
});
// 折叠作者文本
$(document).on('click', '.author-content-button-item', function () {
var content = $(this).parent('.add-author-item')[0];
content.style.height = content.offsetHeight === 520 ? 42 + 'px' : 520 + 'px';
// 改为图片向上
if (content.style.height === '42px') {
$(this).children('.author-sort-number').children('.fa').attr('class', 'fa fa-angle-up');
// 设置拖动class
$(this).parent('.add-author-item').addClass('sort-author-item');
}
// 改为图片向下
if (content.style.height === '520px') {
$(this).children('.author-sort-number').children('.fa').attr('class', 'fa fa-angle-down');
$(this).parent('.add-author-item').removeClass('sort-author-item');
}
});
//flag用于判断鼠标状态点击后是否松开
let flag = false;
//移动的对象代码
let str = ''
//移动对象本身宽度
let obj_width = 0;
//移动对象本身高度
let obj_height = 0;
//移动对象
let obj_target = ''
//移动对象同等级下标 判断比较对象是在当前移动对象上面还是下面
let obj_index = 0;
//监听拖拽对象鼠标点击事件
$(document).on('mousedown', '.author-sort-button', function () {
// 存值
obj_target = $(this).parent().parent().parent()[0];
str = obj_target.outerHTML;
obj_width = $(obj_target).width()
obj_height = $(obj_target).height()
obj_index = $(obj_target).index()
//复制拖拽对象进入隐藏的box2并设置透明度(视觉效果好一些),移动到当前位置
$('#box2').html(str)
$('#box2').fadeTo(1, 0.5);
//obj_height除以二和obj_width除以二是为了让鼠标在复制对象的中间,视觉效果好一些
$('#box2').offset({top: event.pageY - (obj_height / 2), left: event.pageX - (obj_width / 2)});
setTimeout(function () {
$('#box2').show();
}, 100)
//点击标识修改为true
flag = true;
});
//监听页面鼠标释放事件
$(document).mouseup(function (event) {
//清空box2
$("#box2").html('');
//点击标识修改为false
flag = false;
updateInputNames();
});
//监听页面鼠标移动事件
$(document).mousemove(function (event) {
if (flag) {
//复制对象跟随鼠标移动
$("#box2").offset({top: event.pageY - (obj_height / 2), left: event.pageX - (obj_width / 2)});
//循环要排序的对象
$("#box .add-author-item").each(function (k, v) {
//判断在移动对象上面的数据,判断鼠标所在距离顶部位置小于上面对象距顶部位置的位置+上面对象的高度时则移动
if (k < obj_index && event.pageY <= $(this).offset().top + $(this).height()) {
$(this).before(obj_target)
obj_index = $(obj_target).index()
return false;
}
//判断在移动对象下面的数据,判断鼠标所在距离顶部位置大于下面对象的距顶部位置则移动
if (k > obj_index && event.pageY >= $(this).offset().top) {
$(this).after(obj_target)
obj_index = $(obj_target).index();
return false;
}
});
}
});
// 阻止鼠标选中文本
$(document).bind("selectstart",function(){return false;});
Form.api.bindevent($("#submit-manuscript-form"), function () {
setTimeout(function () {
location.href = '/index/user/display_submitted';
}, 2000);
});
},
invite_reviewers: function () {
// updateHidden();
// 全选
$('#reviewer-table').on('click', '.chk', function () {
var checkedStatus = this.checked;
$('#reviewer-table .son-chk').prop('checked', checkedStatus);
updateHidden()
});
$('#reviewer-table').on('click', '.son-chk', function () {
updateHidden();
})
function updateHidden() {
var checkedVals = [];
$('.son-chk:checked').each(function () {
let obj = {};
obj['id'] = $(this).data('id');
obj['user_id'] = $(this).data('user-id');
obj['name'] = $(this).data('name');
obj['education'] = $(this).data('education');
obj['affiliation'] = $(this).data('affiliation');
obj['field'] = $(this).data('field');
checkedVals.push(obj);
});
$('#submit-invite-reviewers-form .reviewer-content').empty();
console.log(checkedVals);
$.each(checkedVals, function (i, val) {
var str = '\n' +
'\n' +
' \n' +
' \n' +
' \n' +
' ';
' ';
$('#submit-invite-reviewers-form .reviewer-content').append(str);
});
}
// 点击按钮后获取选择
Form.api.bindevent($("#submit-invite-reviewers-form"), function () {
// 清理缓存
localStorage.removeItem('selectedTableVals');
setTimeout(function () {
location.href = '/index/user/editing_manuscripts';
}, 2000);
});
},
handing_suggestions: function () {
Form.api.bindevent($("#submit-comments-form"), function () {
setTimeout(function () {
location.href = '/index/user/show_reviewed_manuscripts';
}, 2000);
});
},
display_submitted: function () {
// 初始化分页参数
var currentPage = 1;
var pageSize = 10;
$('#c-search').on("keyup", function (e) {
if (e.keyCode === 13) {
let keyword = $(this).val();
// 点击回车后进行搜索
$.ajax({
url: 'user/display_submitted',
type: 'GET',
dataType: 'json',
data: {
page: currentPage,
limit: pageSize,
keyword: keyword,
},
success: function (res) {
if (res.code === 1) {
$('.article-list').html('');
var tableData = res.data.data;
for (var i = 0; i < tableData.length; i++) {
let rowData = tableData[i];
let edit_str = '';
let comments_str = '';
let view_comments_str = '';
if (rowData.is_edit) {
edit_str = '\n';
}
if (rowData.is_comments) {
comments_str = '';
}
if (rowData.is_view_comments) {
view_comments_str = '';
}
let html = '\n' +
' \n' +
' ';
$('.article-list').append(html);
}
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
}
});
},
editing_manuscripts: function () {
// 初始化分页参数
var currentPage = 1;
var pageSize = 10;
var status = $('#editor_manuscripts_status').val();
$('#c-search').on("keyup", function (e) {
if (e.keyCode === 13) {
let keyword = $(this).val();
// 点击回车后进行搜索
$.ajax({
url: 'user/editing_manuscripts',
type: 'GET',
dataType: 'json',
data: {
page: currentPage,
limit: pageSize,
keyword: keyword,
status: status,
},
success: function (res) {
if (res.code === 1) {
if (res.data.total > 0) {
$('.article-list').html('');
var tableData = res.data.data;
for (var i = 0; i < tableData.length; i++) {
let rowData = tableData[i];
let str = '';
if (rowData.is_chief) {
str = ``;
}
let html = `
`;
$('.article-list').append(html);
}
}
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
}
});
},
show_reviewed_manuscripts: function () {
// 初始化分页参数
var currentPage = 1;
var pageSize = 10;
var status = $('#reviewed_manuscripts_status').val();
$('#c-search').on("keyup", function (e) {
if (e.keyCode === 13) {
let keyword = $(this).val();
// 点击回车后进行搜索
$.ajax({
url: 'user/show_reviewed_manuscripts',
type: 'GET',
dataType: 'json',
data: {
status: status,
page: currentPage,
limit: pageSize,
keyword: keyword,
},
success: function (res) {
if (res.code === 1) {
$('.article-list').html('');
var tableData = res.data.data;
for (var i = 0; i < tableData.length; i++) {
let rowData = tableData[i];
let html = '\n' +
' \n' +
' ';
$('.article-list').append(html);
}
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
}
});
},
invitation_letter: function () {
// 初始化分页参数
var currentPage = 1;
var pageSize = 10;
var status = $('#manuscript_invite_status').val();
$('#c-search').on("keyup", function (e) {
if (e.keyCode === 13) {
let keyword = $(this).val();
// 点击回车后进行搜索
$.ajax({
url: 'user/invitation_letter',
type: 'GET',
dataType: 'json',
data: {
status: status,
page: currentPage,
limit: pageSize,
keyword: keyword,
},
success: function (res) {
if (res.code === 1) {
$('.article-list').html('');
var tableData = res.data.data;
for (var i = 0; i < tableData.length; i++) {
let rowData = tableData[i];
let html = '\n' +
' \n' +
' ';
$('.article-list').append(html);
}
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
}
});
// 接受/拒绝操作
$(document).on('click', '.invite-letter', function () {
let id = $(this).attr('data-id');
let status = $(this).attr('data-status');
$.ajax({
url: '/index/user/invitation_letter_operate',
type: 'POST',
dataType: 'json',
data: {
id: id,
status: status,
},
success: function (res) {
if (res.code === 1) {
Toastr.success(res.msg);
setTimeout(function () {
location.reload();
}, 2000);
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
});
},
special_issue: function () {
// 自定义添加作者按钮
$(document).on('click', '.add-editor-button', function () {
let input_index = $('.custom-editor-content').children('.custom-editor-item').length;
let str = '\n' +
'
\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'
';
$('.custom-editor-content').append(str);
updateEditorInputNames();
});
// 排序input 的 name 值
var updateEditorInputNames = function () {
// 遍历所有的div元素
$(".custom-editor-item").each(function (index) {
var email_input = $(this).find('input[id="c-add-editor-email"]');
var first_name_input = $(this).find('input[id="c-add-editor-first-name"]');
var last_name_input = $(this).find('input[id="c-add-editor-last-name"]');
var affiliation_input = $(this).find('input[id="c-add-editor-affiliation"]');
var record_link_input = $(this).find('input[id="c-add-editor-record_link"]');
email_input.attr('name', "row[editor][" + index + "][email]");
first_name_input.attr('name', "row[editor][" + index + "][first_name]");
last_name_input.attr('name', "row[editor][" + index + "][last_name]");
affiliation_input.attr('name', "row[editor][" + index + "][affiliation]");
record_link_input.attr('name', "row[editor][" + index + "][record_link]");
});
};
// 删除对应的作者信息
$(document).on('click', '.editor-delete-button', function () {
let editor_content_length = $('.custom-editor-content').children('.custom-editor-item').length;
if (editor_content_length > 1) {
$(this).parent().parent().remove();
// 删除后更新 input 的 name 值
updateEditorInputNames();
}
});
// 自定义作者信息提交按钮操作
$(document).on('click', '.add-editor-submit', function () {
let tr_length = $('#recommended-table tbody tr').length;
let key = $(".custom-editor-item").length;
let addEditorInputValue = [];
for (let i = 0; i < key; i++) {
let obj = {};
obj['email'] = $(this).parent().parent().find("input[name='row[editor][" + i + "][email]']").val();
obj['first_name'] = $(this).parent().parent().find("input[name='row[editor][" + i + "][first_name]']").val();
obj['last_name'] = $(this).parent().parent().find("input[name='row[editor][" + i + "][last_name]']").val();
obj['affiliation'] = $(this).parent().parent().find("input[name='row[editor][" + i + "][affiliation]']").val();
obj['record_link'] = $(this).parent().parent().find("input[name='row[editor][" + i + "][record_link]']").val();
addEditorInputValue.push(obj);
}
for (var i = 0; i < addEditorInputValue.length; i++) {
var rowData = addEditorInputValue[i];
if (addEditorInputValue.length > 1) {
if (i > 0) {
tr_length++;
}
}
let html = ' \n' +
' \n' +
' \n' +
' \n' +
' ';
var rowHtml = '' +
'' + rowData.email + ' | ' +
'' + rowData.first_name + ' | ' +
'' + rowData.last_name + ' | ' +
'' + rowData.affiliation + ' | ' +
'' + rowData.record_link + ' | ' +
'删除 | ' +
'
';
$('#recommended-table tbody').append(rowHtml);
$('.editor-hidden-content').append(html);
}
// 清空已填内容
$('.custom-editor-content').html('');
$('.custom-editor-content').append('\n' +
'
\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'\n' +
'
\n' +
'
');
$('#addEditorModal').modal('hide');
});
// 删除已选中的作者
$(document).on('click', '.recommended-del', function () {
let index = $(this).data('index');
$('.editor-hidden-content').find('input[name="row[editor]\\[' + index + '\\]\\[email\\]"]').remove();
$('.editor-hidden-content').find('input[name="row[editor]\\[' + index + '\\]\\[first_name\\]"]').remove();
$('.editor-hidden-content').find('input[name="row[editor]\\[' + index + '\\]\\[last_name\\]"]').remove();
$('.editor-hidden-content').find('input[name="row[editor]\\[' + index + '\\]\\[affiliation\\]"]').remove();
$('.editor-hidden-content').find('input[name="row[editor]\\[' + index + '\\]\\[record_link\\]"]').remove();
$(this).parent().remove();
// 重新排列键值
});
// 辅助函数:生成指定起始页码和结束页码的分页按钮HTML代码
function generatePagination(startPage, endPage) {
var pageHtml = '';
for (var i = startPage; i <= endPage; i++) {
if (i === currentPage) {
pageHtml += '';
} else {
pageHtml += '';
}
}
return pageHtml;
}
Form.api.bindevent($("#submit-issue-form"), function () {
setTimeout(function () {
location.href = '/index/user/special_issue_list'
}, 2000);
});
},
article_details: function () {
// 意见转呈给作者
$(document).on('click', '#send-button', function () {
let comment_id = $(this).attr('data-id');
Layer.confirm("Are you sure you want to forward it to the author?", {
title: "Tips",
icon: 0,
btn: ["Confirm", "Cancel"]
}, function () {
$.ajax({
url: 'user/send_author_comments',
type: 'POST',
dataType: 'json',
data: {
comment_id: comment_id
},
success: function (res) {
console.log(res);
if (res.code === 1) {
Toastr.success(res.msg);
setTimeout(function () {
location.reload();
}, 2000);
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
});
});
// 点击tab切换表格
$(document).on('click', '.breadcrumb-item', function () {
let status = $(this).children().attr('data-value');
let manuscript_id = $(this).children().attr('data-id');
let user_id = $(this).children().attr('data-user');
$.ajax({
url: '/api/user/get_article_detail_table',
type: 'POST',
dataType: 'json',
data: {
status: status,
manuscript_id: manuscript_id,
},
success: function (res) {
if (res.code === 1) {
// 邀请的审稿人信息
let result = res.data;
if (status == 'reviewer_details') {
$('.reviewer_suggestion').hide();
$('.review_report').hide();
$('.author_report').hide();
$('.reviewer_details').show();
let data = result.reviewer;
let str = '';
for (let i = 0; i < data.length; i++) {
str += '\n' +
' '+ data[i].nickname +' | \n' +
' '+ data[i].invited_time +' | \n' +
' '+ data[i].reply_time +' | \n' +
' '+ data[i].submission_time +' | \n' +
' '+ data[i].status +' | \n' +
'
';
}
$('.reviewer_details_content').html(str);
}
// 审稿人信息
if (status == 'reviewer_suggestion') {
$('.reviewer_suggestion').show();
$('.review_report').hide();
$('.author_report').hide();
$('.reviewer_details').hide();
let data = result.reviewer;
let str = '';
for (let i = 0; i < data.length; i++) {
str += '\n' +
' '+ data[i].nickname +' | \n' +
' '+ data[i].affiliation +' | \n' +
' '+ data[i].comment_num +' | \n' +
'
';
}
$('.reviewer_suggestion_content').html(str);
}
// 审稿人意见信息
if (status == 'review_report') {
$('.reviewer_suggestion').hide();
$('.review_report').show();
$('.author_report').hide();
$('.reviewer_details').hide();
let data = result.reviewer;
let str = '';
let is_button = '';
for (let i = 0; i < data.length; i++) {
if (data.user_id != user_id) {
if (data[i].is_send == 'hidden') {
is_button = 'SEND'
}
}
str += '\n' +
' '+ data[i].nickname +' | \n' +
' '+ data[i].recommendation +' | \n' +
' '+ data[i].comment +' | \n' +
' '+ data[i].createtime +' | \n' +
' \n' +
' '+ is_button +' \n' +
' | \n' +
'
';
}
$('.review_report_content').html(str);
}
// 作者回复意见
if (status == 'author_report') {
$('.reviewer_suggestion').hide();
$('.review_report').hide();
$('.author_report').show();
$('.reviewer_details').hide();
let data = result.author;
let str = '';
for (let i = 0; i < data.length; i++) {
str += '\n' +
' '+ data[i].nickname +' | \n' +
' '+ data[i].comment +' | \n' +
' '+ data[i].createtime +' | \n' +
'
';
}
$('.author_report_content').html(str);
}
} else {
Toastr.error(res.msg);
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
})
$(document).ready(function () {
$('.reviewer_details').show();
});
setTimeout(function () {
$('.btn-delete').remove();
$('.input-group-addon').remove();
}, 300);
Form.api.bindevent($("#article-details-form"), function () {
setTimeout(function () {
location.href = window.history.go(-1);
}, 2000);
});
},
conduct_review: function () {
Form.api.bindevent($("#submit-comments-form"), function () {
setTimeout(function () {
location.href = '/index/user/show_reviewed_manuscripts';
}, 2000);
});
},
submit_conference: function () {
Form.api.bindevent($("#conference-form"), function () {
setTimeout(function () {
location.href = '/p/conference';
}, 2000);
}, function (data) {
$("input[name=captcha]").next(".input-group-addon").find("img").trigger("click");
});
},
conference_participate: function () {
Form.api.bindevent($("#conference-participate-form"), function () {
setTimeout(function () {
location.href = window.history.go(-1);
}, 2000);
});
},
reviewer_information: function () {
//为表单绑定事件
Form.api.bindevent($("#reviewer-information-form"), function (data, ret) {
}, function (data) {
});
},
become_an_editor: function () {
let is_radio_checked = false;
// 点击单选框时触发事件
$("input[type='radio']").on("click", function () {
// 判断单选框是否更改
var isChecked = $("input[type='radio']").is(":checked");
if (isChecked) {
is_radio_checked = true;
}
});
// 获取表单内所有单选框
var radios = $("input[type='radio']");
// 遍历单选框
for (let i = 0; i < radios.length; i++) {
if ($(radios[i]).is(":checked")) {
is_radio_checked = true;
}
}
// 如果更改了单选框的值则需要提示
$('#submit-button').click(function () {
if (is_radio_checked) {
Layer.confirm("If you have selected a character, the corresponding character attributes will be lost. Do you want to continue?", {
title: "Tips",
icon: 0,
btn: ["Continue", "Cancel"]
}, function () {
is_radio_checked = false;
$('#submit-button').click();
});
return false;
}
})
//为表单绑定事件
Form.api.bindevent($("#become-an-editor-form"), function (data, ret) {
setTimeout(function () {
// location.reload();
}, 2000);
}, function (data) {
// $("input[name=captcha]").next(".input-group-btn").find("img").trigger("click");
});
},
review_comments: function () {
//为表单绑定事件
Form.api.bindevent($("#review-comments-form"), function (data, ret) {
setTimeout(function () {
location.href = '/index/user/display_submitted';
}, 2000);
}, function (data) {
});
},
// 发送邮件
send_email: function () {
$('#submit-button').prop('disabled', true);
let mail_smtp_host = $('input[name="mail_smtp_host"]').val();
let mail_smtp_port = $('input[name="mail_smtp_port"]').val();
let mail_smtp_user = $('input[name="mail_smtp_user"]').val();
let mail_smtp_pass = $('input[name="mail_smtp_pass"]').val();
if (!mail_smtp_host && !mail_smtp_port && !mail_smtp_user && !mail_smtp_pass) {
Layer.confirm("You have not filled in the email configuration yet, which may cause sending the specified email to fail", {
title: "Tips",
icon: 0,
btn: ["Go to fill out", "Ignore/Cancel"]
}, function () {
location.href = '/index/user/profile';
});
} else {
$('#submit-button').prop('disabled', false);
}
//为表单绑定事件
Form.api.bindevent($("#send-email-form"), function (data, ret) {
setTimeout(function () {
location.href = '/index/user/inbox';
}, 2000);
}, function (data) {
});
},
// 邀请编辑
invite_editor: function () {
//为表单绑定事件
Form.api.bindevent($("#invite-editor-form"), function (data, ret) {
setTimeout(function () {
location.href = '/index/user/editing_manuscripts';
}, 2000);
}, function (data) {
});
},
special_issue_list: function () {
// 初始化分页参数
var currentPage = 1;
var pageSize = 10;
$('#c-search').on("keyup", function (e) {
if (e.keyCode === 13) {
let keyword = $(this).val();
// 点击回车后进行搜索
$.ajax({
url: 'user/special_issue_list',
type: 'GET',
dataType: 'json',
data: {
page: currentPage,
limit: pageSize,
keyword: keyword,
},
success: function (res) {
if (res.code === 1) {
$('.article-list').html('');
var tableData = res.data.data;
for (var i = 0; i < tableData.length; i++) {
let rowData = tableData[i];
let html = '\n' +
' \n' +
' ';
$('.article-list').append(html);
}
}
},
error: function (xhr, status, error) {
console.error(error);
}
});
}
});
},
};
return Controller;
});