You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/labs/Teacher/TeacherExt/wwwroot/js/update.js

309 lines
9.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//表单提交通用方法
function submit(msg, func) {
Swal.fire({
position: 'bottom',
text: msg,
confirmButtonText: '确定',
cancelButtonText: '取消',
showCancelButton: true
}).then(function (value) {
if (value.isConfirmed) {
func();
}
});
}
//////////////////////////////////////////////////////////////////
//用户操作
//提交审核
$('#submitCheckRequest').click(function () {
var form = $(this).parents('form');
var msg = '确认' + $(this).text() + '';
submit(msg, function () {
$('#CheckStatus').val('待审核');
form.submit();
});
});
//待审核时取消提交审核的申请
$('#submitCancelRequest').click(function () {
var form = $(this).parents('form');
var msg = '确认' + $(this).text() + '';
submit(msg, function () {
$('#CheckStatus').val('未提交');
form.submit();
});
});
//申请修改
$('#submitModifyRequest').click(function () {
var form = $(this).parents('form');
var msg = '确认' + $(this).text() + '';
submit(msg, function () {
$('#RequestEditStatus').val('已申请');
form.submit();
});
});
//取消申请
$('#cancelModifyRequest').click(function () {
var form = $(this).parents('form');
var msg = '确认' + $(this).text() + '';
submit(msg, function () {
$('#RequestEditStatus').val('未申请');
form.submit();
});
});
////////////////////////////////////////////////////////////////////////////////
//退回
$('#super').click(function () {
var form = $(this).parents('form');
if (form.find("input[name$='Checked']").filter(':visible').not(':checked').length === 0) {
Swal.fire({
position: 'bottom',
text: '请审核全部待审核项',
confirmButtonText: '确定'
});
return;
}
if (!$('#Comment').val()) {
Swal.fire({
position: 'bottom',
text: '请填写审核失败原因',
confirmButtonText: '确定'
});
return;
}
var msg = '确认' + $(this).text() + '';
submit(msg, function () {
$('#CheckStatus').val('审核失败');
$('#RequestEditStatus').val('未申请');
form.submit();
});
});
//审核成功
$('#admin1').click(function () {
var form = $(this).parents('form');
if (form.find("input[name$='Checked']").filter(':visible').not(':checked').length > 0) {
Swal.fire({
position: 'bottom',
text: '请审核全部待审核项',
confirmButtonText: '确定'});
return;
}
var msg = '确认' + $(this).text() + '';
submit(msg, function () {
$('#Comment').val('');
$('#CheckStatus').val('审核成功');
$('#RequestEditStatus').val('未申请');
form.submit();
});
});
//审核失败
$('#admin2').click(function () {
var form = $(this).parents('form');
if (form.find("input[name$='Checked']").filter(':visible').not(':checked').length === 0) {
Swal.fire({
position: 'bottom',
text: '请审核全部待审核项',
confirmButtonText: '确定'
});
return;
}
if (!$('#Comment').val()) {
Swal.fire({
position: 'bottom',
text: '请填写审核失败原因',
confirmButtonText: '确定'
});
return;
}
var msg = '确认' + $(this).text() + '';
submit(msg, function () {
$('#CheckStatus').val('审核失败');
$('#RequestEditStatus').val('未申请');
form.submit();
});
});
//批准修改申请
$('#admin3').click(function () {
var form = $(this).parents('form');
var msg = '确认' + $(this).text() + '';
submit(msg, function () {
$('#CheckStatus').val('未提交');
$('#RequestEditStatus').val('未申请');
form.submit();
});
});
//拒绝修改申请
$('#admin4').click(function () {
var form = $(this).parents('form');
var msg = '确认' + $(this).text() + '';
submit(msg, function () {
$('#RequestEditStatus').val('未申请');
form.submit();
});
});
/////////////////////////////////////////////////////////////
var cls = '.col-sm-6';
var ms = 500;
//是否最高职称聘任
if ($('#IsJobAsMaxTitle').val()) {
if ($('#IsJobAsMaxTitle').val() === "True") {
$("[data-my-group='JobAsMaxTitle2']").parents(cls).hide();
$("[data-my-group='JobAsMaxTitle1']").parents(cls).show();
}
else {
$("[data-my-group='JobAsMaxTitle1']").parents(cls).hide();
$("[data-my-group='JobAsMaxTitle2']").parents(cls).show();
}
}
else {
$("[data-my-group='JobAsMaxTitle1']").parents(cls).hide();
$("[data-my-group='JobAsMaxTitle2']").parents(cls).hide();
}
$('#IsJobAsMaxTitle').change(function () {
if ($(this).val() === "True") {
$("[data-my-group='JobAsMaxTitle2']").parents(cls).hide(ms);
$("[data-my-group='JobAsMaxTitle1']").parents(cls).show(ms);
}
else if ($(this).val() === "False") {
$("[data-my-group='JobAsMaxTitle1']").parents(cls).hide(ms);
$("[data-my-group='JobAsMaxTitle2']").parents(cls).show(ms);
}
else {
$("[data-my-group='JobAsMaxTitle1']").parents(cls).hide(ms);
$("[data-my-group='JobAsMaxTitle2']").parents(cls).hide(ms);
}
});
//
//是否享受学历待遇
if ($('#EducationGrade').val()) {
if ($('#EducationGrade').val() !== "") {
$("#EducationGradeDate").parents(cls).show();
}
else {
$("#EducationGradeDate").parents(cls).hide();
}
}
else {
$("#EducationGradeDate").parents(cls).hide();
}
$('#EducationGrade').change(function () {
if ($(this).val() !== "") {
$("#EducationGradeDate").parents(cls).show();
}
else {
$("#EducationGradeDate").val('').parents(cls).hide();
}
});
//
//是否在编在岗
if ($('#HasPosition').val()) {
if ($('#HasPosition').val() === "True") {
$("[data-my-group='HasPosition2']").parents(cls).hide();
$("[data-my-group^='HasPosition1']").parents(cls).show();
if ($('#IsMiddleLevel').val()) {
if ($('#IsMiddleLevel').val() === "True") {
$("[data-my-group='HasPosition12']").parents(cls).hide();
$("[data-my-group='HasPosition11']").parents(cls).show();
}
else {
$("[data-my-group='HasPosition11']").parents(cls).hide();
$("[data-my-group='HasPosition12']").parents(cls).show();
}
}
else {
$("[data-my-group='HasPosition11']").parents(cls).hide();
$("[data-my-group='HasPosition12']").parents(cls).hide();
}
}
else {
$("[data-my-group^='HasPosition1']").parents(cls).hide();
$("[data-my-group='HasPosition2']").parents(cls).show();
}
}
else {
$("[data-my-group^='HasPosition1']").parents(cls).hide();
$("[data-my-group^='HasPosition2']").parents(cls).hide();
}
$('#HasPosition').change(function () {
if ($(this).val() === "True") {
$("[data-my-group='HasPosition2']").parents(cls).hide();
$("[data-my-group='HasPosition1']").parents(cls).show();
}
else if ($(this).val() === "False") {
$("[data-my-group='HasPosition1']").parents(cls).hide();
$("[data-my-group='HasPosition2']").parents(cls).show();
}
else {
$("[data-my-group='HasPosition1']").parents(cls).hide();
$("[data-my-group='HasPosition2']").parents(cls).hide();
}
});
$('#IsMiddleLevel').change(function () {
if ($(this).val() === "True") {
$("[data-my-group='HasPosition12']").parents(cls).hide();
$("[data-my-group='HasPosition11']").parents(cls).show();
}
else if ($(this).val() === "False") {
$("[data-my-group='HasPosition11']").parents(cls).hide();
$("[data-my-group='HasPosition12']").parents(cls).show();
}
else {
$("[data-my-group='HasPosition11']").parents(cls).hide();
$("[data-my-group='HasPosition12']").parents(cls).hide();
}
});
//查询
$('#query').click(function () {
var url = $(this).attr('data-action') + '?' + $(this).parents('form').find('input,select').not('[value=""]').serialize();
window.location.href = url;
});
//导出
$('#export').click(function () {
var url = $(this).attr('data-action') + '?' + $(this).parents('form').find('input,select').not('[value=""]').serialize();
window.open(url);
});
//根据身份证计算年龄
$('#IdNumber').change(function () {
if ($(this).val()) {
var number = $(this).val();
try {
if (number.length === 15 || number.length === 18) {
var value = number.length == 15 ? ('19' + number.substr(6, 6)) : number.substr(6, 8);
var year = parseInt(value.substr(0, 4));
var month = parseInt(value.substr(4, 2));
var day = parseInt(value.substr(6, 2));
var birthday = new Date(year, month, day);
var now = new Date();
var age = now.getFullYear() - birthday.getFullYear();
$('#AgeDisplay').text(age);
return;
}
} catch (e) {
console.error(e);
}
}
$('#AgeDisplay').text();
});
//根据参加工作时间计算工龄
$('#WorkingTime').change(function () {
if ($(this).val()) {
try {
var now = new Date();
var values = $(this).val().split('-');
var year = values[0];
var month = values[1];
var day = values[2];
var years = now.getFullYear() - new Date(year, month, day).getFullYear();
$('#JobAgeYearDisplay').text(years);
var months = years * 12 + Math.abs((month - now.getMonth()));
$('#JobAgeMonthDisplay').text(months);
return;
} catch (e) {
console.error(e);
}
}
$('#JobAgeYearDisplay').text();
$('#JobAgeMonthDisplay').text();
});