Commit 89d961a8 authored by 马超's avatar 马超

值班管理

parent 6b02685e
#calendar {width:98%;margin: 0 auto;margin-top: 1px;}
table{border-collapse: collapse;background-color:#fff6d9;}
td,th{border: 1px solid red;width:100px;}
table th {height:50px;line-height: 50px;text-align: center;font-size: 20px;}
td{height:100px;text-align:center;vertical-align:middle;}
td {vertical-align:top;position:relative;font-size: 15px;}
td div{position:absolute; left:0; top:0;font-size: 18px;}
.title {width:100%;height:60px;line-height:60px;background-color: #00B83F;color:#fff;text-align: center;font-size: 20px;}
.title label {font-size: 20px;}
#calendar-pre {
border:1px solid #fff;cursor: pointer;border-radius:50px;
width: 160px;
height: 30px;
line-height: 30px;
float: left;
margin-top: 15px;
margin-left:20%;
}
#calendar-next {border:1px solid #fff;cursor: pointer;border-radius:50px;
width: 160px;
height: 30px;
line-height: 30px;
float: right;
margin-top: 15px;
margin-right:20%;
}
\ No newline at end of file
.sc-calendar {
width: 500px;
height: 500px;
text-align: center;
font-family: "Microsoft Yahei";
color: #4A4A4A;
box-shadow: 2px 4px 5px #bdbdbd;
border-width: 1px 0 0 1px;
border-color: #E6E4E0;
border-style: solid;
float: left;
margin-right: 20px;
-moz-user-select: none;
/*火狐*/
-webkit-user-select: none;
/*webkit浏览器*/
-ms-user-select: none;
/*IE10*/
user-select: none;
-webkit-text-size-adjust: none;
font-size: 16px;
}
.sc-header {
height: 45px;
border-bottom: 0;
background-color: #00B83F;
font-size: 18px;
}
.sc-body {
height: 93%;
clear: both;
box-shadow: 2px 4px 5px #bdbdbd;
}
.sc-week {
height: 10%;
font-weight: 400;
font-size: 20px;
color: #4A4A4A;
}
.sc-days {
height: 88%;
}
.sc-item {
height: 20%;
float: left;
font-weight: 600;
color: #565555;
width: 14.285%;
padding-top: 10px;
background-color: #ffffff;
border-width: 0 0 1px 1px;
border-color: #F1EBE4;
border-style: solid;
box-sizing: border-box;
position:relative;
}
.item-nolunar {
padding-top: 20px;
}
.sc-item:nth-child(7n) .day, .sc-item:nth-child(7n+1) .day {
color: rgba(224, 8, 8, 0.74);
}
.sc-vocation {
background-color: #FFEBEC;
}
.sc-mark{
background-color: #E5FBFA;
}
.sc-vocation:before {
content: '休';
display: block;
position: absolute;
font-size: 0.7em;
width: 1.2em;
font-weight: 100;
color: white;
background-color: #E00808;
margin-top: -10px;
}
.sc-othermenth {
color: #C1C0C0 !important;
}
.sc-othermenth .day, .sc-othermenth .lunar-day {
color: #C1C0C0 !important;
}
.sc-active-day, .sc-selected {
border: 1px solid orange;
}
.sc-today {
background-color: orange;
color: white;
border: 1px solid orange;
}
.sc-item .day {
position:absolute;
left:10px;
top:0px;
}
.sc-item .zb_user {
font-size:13px;
font-weight:100;
}
.sc-today .day {
color: white !important;
}
.sc-item .lunar-day {
font-size: 10px;
font-weight: normal;
overflow: hidden;
text-overflow: ellipsis;
position:absolute;
left:10px;
top:20px;
}
.sc-festival .lunar-day {
color: #E00808;
}
/*.sc-item:last-child, .sc-item:nth-child(7n) {
border-width: 0 1px 1px 1px;
}*/
.sc-week-item {
height: 100%;
padding-top: 1%;
float: left;
width: 14.285%;
background-color: #FBEC9C;
border-width: 1px 0 1px 1px;
border-color: #ECE3B1;
border-style: solid;
box-sizing: border-box;
overflow: hidden;
text-overflow: ellipsis;
}
.sc-item-small{
font-size: 10px !important;
}
.sc-week-item:last-child {
border-width: 1px 1px 1px 1px;
}
.sc-week-item:nth-child(7n), .sc-week-item:nth-child(7n+1) {
color: rgba(224, 8, 8, 0.74)!important;
}
.sc-actions {
float: left;
width: 25%;
padding: 5px;
height: 100%;
box-sizing: border-box;
}
.sc-actions:last-child {
float: right;
}
.sc-actions-big{
width: 50%;
}
@media screen and (max-width : 500px){
.sc-actions{
width: 50%;
}
}
.sc-header select {
border-color: rgba(0, 0, 0, 0);
padding: 0.2em;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
font-family: "Microsoft Yahei";
color: #606060;
font-size: 16px ;
background-color: #00B83F;
color:#fff;
}
.sc-header input {
border-color: rgba(0, 0, 0, 0);
padding: 0.2em;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
font-family: "Microsoft Yahei";
color: #606060;
}
.sc-actions div {
color:#fff;
display: inline-block;
/*border: 1px solid #ccc;*/
vertical-align: bottom;
width: 20px;
padding-bottom: 5px;
font-size: 30px;
line-height: 0.9em;
}
.sc-return-today {
display: block;
background-color: #00B83F;
color:#fff;
border-radius: 2px;
/* border: 1px solid #ccc; */
width: 80px;
font-size: 16px;
padding: 0.3em;
margin: auto;
}
.sc-time {
display: block;
margin-top: 3px;
font-size: 16px;
color:#fff;
}
class LunarHelp {
constructor(year,month,day) {
this.lunarInfo = new Array(
0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0,
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6,
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,
0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45,
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0)
this.nStr1 = new Array('', '', '', '', '', '', '', '', '', '', '');
this.nStr2 = new Array('', '', '廿', '');
let date = new Date(parseInt(year), parseInt(month) - 1, parseInt(day))
let i, leap = 0,
temp = 0;//天数
let baseDate = new Date(1900, 0, 31);
let offset = (date - baseDate) / 86400000;
//计算年数
for (i = 1900; i < 2050 && (offset-this.lYearDays(i)) > 0; i++) {
offset -= this.lYearDays(i)
}
this.year = i
leap = this.leapMonth(i) //闰哪个月
this.isLeap = false
//计算月数
for (i = 1; i < 13 && offset > 0; i++) {
//闰月
if (leap > 0 && i == (leap + 1) && this.isLeap == false) {
--i;
temp = this.leapDays(this.year);
} else {
temp = this.monthDays(this.year, i);
}
//解除闰月
if (this.isLeap == true && i == (leap + 1)) this.isLeap = false
offset -= temp
}
//如果恰好减完了,不是闰月的话月数减1
if (offset == 0 && leap > 0 && i == leap + 1)
if (this.isLeap) {
this.isLeap = false;
} else {
this.isLeap = true;
--i;
}
if (offset < 0) {
offset += temp;
--i;
}
this.month = i
//最后剩余的就是日期
this.day = offset + 1
}
// 获取y年的总天数
lYearDays(year) {
let i, sum = 0 ;
for (i = 0x8000; i > 0x8; i >>= 1)
sum += (this.lunarInfo[year - 1900] & i) ? 30 : 29
return (sum + this.leapDays(year)) //最后在加上可能有的闰年的闰月
}
//获取闰年闰月的天数 闰大月还是小月
leapDays(year) {
if (this.leapMonth(year))
return ((this.lunarInfo[year - 1900] & 0x10000) ? 30 : 29)
else
return 0;
}
//获取闰年闰哪个月1-12 ,没闰传回 0
leapMonth(year) {
return (this.lunarInfo[year - 1900] & 0xf)
}
//获取y年m月的总天数 正常月
monthDays(year, month) {
return ((this.lunarInfo[year - 1900] & (0x10000 >> month)) ? 30 : 29)
}
//中文日期
cDay(d) {
let s;
d = Math.round(d);
switch (d) {
case 10:
s = '初十';
break;
case 20:
s = '二十';
break;
break;
case 30:
s = '三十';
break;
break;
default:
s = this.nStr2[Math.floor(d / 10)];
s += this.nStr1[d % 10];
}
return (s);
}
//中文月份
cMonth(m) {
let s;
switch (m) {
case 1:
s = '正月';
break;
case 2:
s = '二月';
break;
case 3:
s = '三月';
break;
case 4:
s = '四月';
break;
case 5:
s = '五月';
break;
case 6:
s = '六月';
break;
case 7:
s = '七月';
break;
case 8:
s = '八月';
break;
case 9:
s = '九月';
break;
case 10:
s = '十月';
break;
case 11:
s = '十一月';
break;
case 12:
s = '十二月';
break;
default:
break;
}
return (s);
}
//获得阴历日期 字符串
getLunarDay() {
return cMonth(this.month) + cDay(this.day);
}
//获得阴历日期某一天的中文
getLunarDayName() {
if (this.day == 1)
return this.cMonth(this.month);
return this.cDay(this.day);
}
//获取阴历日期的数字
getLunarDayNum() {
return {
day: Math.round(this.day),
month: this.month
};
}
}
class SimpleCalendar {
//构造函数
constructor(query, options) {
//默认配置
this._defaultOptions = {
width: '500px',
height: '500px',
language: 'CH', //语言
showLunarCalendar: true, //阴历
showHoliday: true, //休假
showFestival: true, //节日
showLunarFestival: true, //农历节日
showSolarTerm: true, //节气
showMark: true, //标记
timeRange: {
startYear: 1900,
endYear: 2049
},
timeZone: "", //时区
mark: {
'2019-6-6': 'Go'
},
theme: {
changeAble: false,
weeks: {
backgroundColor: '#FBEC9C',
fontColor: '#4A4A4A',
fontSize: '20px',
},
days: {
backgroundColor: '#ffffff',
fontColor: '#565555',
fontSize: '24px'
},
todaycolor: 'orange',
activeSelectColor: 'orange',
invalidDays: '#C1C0C0',
}
}
//容器
this.container = document.querySelector(query);
this._defaultOptions.width = this.container.style.offsetWidth;
this._defaultOptions.height = this.container.style.offsetHeight;
//this._options = Object.assign({}, this._defaultOptions, options);
//得到最终配置
this._options = this.optionAssign(this._defaultOptions, options);
this.create();
}
//用B更新A的属性 并返回结果
optionAssign(optionsA, optionsB) {
for (let key in optionsB) {
if (typeof(optionsA[key]) !== 'object')
optionsA[key] = optionsB[key];
else {
optionsA[key] = this.optionAssign(optionsA[key], optionsB[key])
}
}
return optionsA;
}
//生成日历样式
create() {
let root = this.container;
root.innerHTML = '<div class="sc-header"> </div> <div class="sc-body"> </div>';
root.style.width = this._options.width;
root.style.height = this._options.height;
root.className = 'sc-calendar';
let header = root.querySelector('.sc-header');
let scbody = root.querySelector('.sc-body');
//actions
header.innerHTML = header.innerHTML + '<div class="sc-actions">' +
' <div class="sc-yleft">' +
' &lsaquo;</div>' +
' <select class="sc-select-year" name="">' +
' </select>' +
' <div class="sc-yright">&rsaquo;</div>' +
' </div>';
header.innerHTML = header.innerHTML + '<div class="sc-actions">' +
' <div class="sc-mleft">' +
' &lsaquo;</div>' +
' <select class="sc-select-month" name="">' +
' </select>' +
' <div class="sc-mright">&rsaquo;</div>' +
'</div>';
header.innerHTML = header.innerHTML + '<div class="sc-actions"><span class="sc-return-today ">返回今天</span></div>';
header.innerHTML = header.innerHTML + '<div class="sc-actions"><span class="sc-time"></span></div>';
scbody.innerHTML = ' <div class="sc-week"> </div> <div class="sc-days"> </div>';
let week = scbody.querySelector('.sc-week');
let days = scbody.querySelector('.sc-days');
for (let i = 0; i < 7; i++) {
week.innerHTML = week.innerHTML + ' <div class="sc-week-item"></div>';
}
for (let i = 0; i < 35; i++) {
days.innerHTML = days.innerHTML + '<div class="sc-item"><div class="day"></div><div class="lunar-day"></div><div class="zb_user"></div><div class="zb_user_button"></div></div>';
}
//添加下拉框数据
this.updateSelect(this.tyear, this.tmonth);
//刷新日历
this.update();
//时间刷新
self.setInterval('SimpleCalendar.timeupdate()', 200);
}
//刷新日历
update(month = this.tmonth, year = this.tyear) {
this.updateSize()
this.updateWeek();
addData(year, month);
this.updateHoliday(year, month);
this.updateMark(year, month);
this.updateFestival(year, month);
this.updateEvent();
this.updateTheme(this._options.theme);
}
//调整大小
updateSize(width = this._options.width, height = this._options.height) {
//将大小赋值给option
this._options.width = width;
this._options.height = height;
this.container.style.width = width;
this.container.style.height = height;
//根据长度和宽度大小调整适合的样式
if (parseInt(width) < 500) {
let actions = this.arrayfrom(this.container.querySelectorAll('.sc-actions'));
actions.forEach(function(v, i) {
v.classList.add('sc-actions-big');
})
} else {
let actions = this.arrayfrom(this.container.querySelectorAll('.sc-actions'));
actions.forEach(function(v, i) {
v.classList.remove('sc-actions-big');
})
}
if (parseInt(height) < 400) {
let items = this.arrayfrom(this.container.querySelectorAll('.sc-item'));
let weeks = this.arrayfrom(this.container.querySelectorAll('.sc-week-item'));
items.forEach(function(v, i) {
v.querySelector('.day').classList.add('sc-item-small');
})
weeks.forEach(function(v, i) {
v.classList.add('sc-item-small');
})
} else {
let items = this.arrayfrom(this.container.querySelectorAll('.sc-item'));
let weeks = this.arrayfrom(this.container.querySelectorAll('.sc-week-item'));
items.forEach(function(v, i) {
v.querySelector('.day').classList.remove('sc-item-small');
})
weeks.forEach(function(v, i) {
v.classList.remove('sc-item-small');
})
}
}
//刷新下拉框 只有在初始化和设置语言后才会更新
updateSelect(year, month) {
//下拉框
let selectYear = this.container.querySelector('.sc-select-year');
let selectMonth = this.container.querySelector('.sc-select-month');
selectYear.innerHTML = '';
for (let i = this._options.timeRange.startYear; i < this._options.timeRange.endYear+1; i++) {
selectYear.innerHTML += '<option value="' + i + '">' + i + '</option>';
}
selectMonth.innerHTML = '';
for (let i = 0; i < 12; i++) {
let data = this.languageData['months_' + this._options.language];
selectMonth.innerHTML += '<option value="' + (i + 1) + '">' + data[i] + '</option>';
}
selectYear.value = year;
selectMonth.value = month;
}
//刷新星期
updateWeek() {
let weeks = this.arrayfrom(this.container.querySelectorAll('.sc-week-item'));
let data = this.languageData['days_' + this._options.language];
if (!data) {
console.error('language error!');
}
weeks.forEach(function(v, i) {
v.innerHTML = data[i];
})
}
//添加阳历阴历数据
addData1(year, month) {
let daysElement = this.arrayfrom(this.container.querySelectorAll('.sc-item'));
let day = new Date(year, month - 1, 1);
let week = day.getDay();
if (week == 0) week = 7;
//计算得到第一个格子的日期
let thispageStart = new Date(Date.parse(day) - (week - 1) * 24 * 3600 * 1000);
//对每一个格子遍历
for (let i = 0; i < 35; i++) {
daysElement[i].className = 'sc-item';
let theday = new Date(Date.parse(thispageStart) + (i-1) * 24 * 3600 * 1000);
let writeyear = theday.getFullYear();
let writeday = theday.getDate();
let writemonth = theday.getMonth() + 1;
if (writemonth != month) {
daysElement[i].classList.add('sc-othermenth');
}
daysElement[i].querySelector('.day').innerHTML = writeday;
daysElement[i].querySelector('.zb_user').innerHTML = '张三';
//判断是否添加阴历
if (this._options.showLunarCalendar) {
daysElement[i].querySelector('.lunar-day').innerHTML = (new LunarHelp(writeyear, writemonth, writeday)).getLunarDayName();
} else {
daysElement[i].querySelector('.lunar-day').innerHTML = '';
daysElement[i].classList.add('item-nolunar');
}
//添加today样式
if (this.tyear == writeyear && this.tday == writeday && this.tmonth == writemonth) {
this.selectDay = daysElement[i];
daysElement[i].classList.add("sc-today");
}
}
}
//刷新标记日期
updateMark(year, month) {
let options = this._options;
if (options.showMark) {
let daysElement = this.arrayfrom(this.container.querySelectorAll('.sc-item'));
let currentmonth = month - 1;
//取得节日数据
let data = options.mark;
if (data) {
daysElement.forEach(function(v, i) {
let day = +(v.querySelector('.day').innerHTML);
if (day == 1) currentmonth++;
if (data[year + '-' + currentmonth + '-' + day]) {
v.classList.add('sc-mark');
v.title = data[year + '-' + currentmonth + '-' + day];
} else {
v.classList.remove('sc-mark');
v.title = '';
}
});
}
}
}
//刷新节日数据
updateFestival(year, month) {
let options = this._options;
let daysElement = this.arrayfrom(this.container.querySelectorAll('.sc-item'));
let currentmonth = month - 1;
//取得节日数据
let data =this.languageData['feativals_' + this._options.language];
// console.log(data);
let lunardata = this.languageData['lunarFeatival_' + this._options.language];
// console.log(lunardata);
let solarTermdata = this.languageData['solarTerm'];
// console.log(solarTermdata);
if (!data) {
console.error('language error!');
}
// console.log(daysElement);
daysElement.forEach(function(v, i) {
// console.log(v);
let day = +(v.querySelector('.day').innerHTML);
// console.log(v.querySelector('.day').innerHTML);
if (day === 1) currentmonth++;
//24节气
if (options.showSolarTerm) {
if (solarTermdata[currentmonth + '-' + day]) {
v.querySelector('.lunar-day').innerHTML = solarTermdata[currentmonth + '-' + day];
v.classList.add('sc-festival');
}
}
//国际节日
if (options.showFestival) {
if (data[currentmonth + '-' + day]) {
v.querySelector('.lunar-day').innerHTML = data[currentmonth + '-' + day];
v.classList.add('sc-festival');
}
}
//阴历节日
if (lunardata && options.showLunarFestival) {
let lunar =(new LunarHelp(year, currentmonth, day)).getLunarDayNum();
if (lunardata[lunar.month + '-' + lunar.day]) {
v.querySelector('.lunar-day').innerHTML = lunardata[lunar.month + '-' + lunar.day];
v.classList.add('sc-festival');
}
}
});
}
//刷新假期 休假
updateHoliday(year, month) {
let options = this._options;
if (options.showHoliday) {
let daysElement = this.arrayfrom(this.container.querySelectorAll('.sc-item'));
let currentmonth = month - 1;
//取得节日数据
let data = this.languageData.vocation['data_' + year];
if (data) {
daysElement.forEach(function(v, i) {
let day = +(v.querySelector('.day').innerHTML);
if (day == 1) currentmonth++;
//国际节日
if (data.indexOf(currentmonth + '-' + day) > 0) {
v.classList.add('sc-vocation');
}
});
}
}
}
//刷新主题
updateTheme(theme) {
if (this._options.theme.changeAble) {
let daytheme = theme.days;
let weektheme = theme.weeks;
let weeks = this.arrayfrom(this.container.querySelectorAll('.sc-week-item'));
let days = this.arrayfrom(this.container.querySelectorAll('.sc-item'));
weeks.forEach(function(v, i) {
v.style.backgroundColor = weektheme.backgroundColor;
v.style.fontSize = weektheme.fontSize;
v.style.color = weektheme.fontColor;
})
days.forEach(function(v, i) {
if (!v.classList.contains('sc-today')) {
v.style.backgroundColor = daytheme.backgroundColor;
v.querySelector('.day').style.color = daytheme.fontColor;
} else {
v.style.backgroundColor = theme.todaycolor;
}
v.querySelector('.day').style.fontSize = daytheme.fontSize;
})
let Calendar = this;
//active border
days.forEach(function(v, i) {
v.onmouseover = function(e) {
this.style.borderColor = theme.activeSelectColor;
this.style.borderWidth = '1px';
}
v.onmouseout = function(e) {
this.style.borderColor = '#F1EBE4';
this.style.borderWidth = '0 0 1px 1px';
}
})
}
}
//刷新事件
updateEvent() {
let daysElement = this.arrayfrom(this.container.querySelectorAll('.sc-item'));
let container = this.container;
let calendar = this;
daysElement.forEach(function(v, i) {
v.onmouseover = function(e) {
this.classList.add('sc-active-day');
}
v.onmouseout = function(e) {
this.classList.remove('sc-active-day');
}
v.onclick = function() {
calendar.selectDay = v;
let pre = container.querySelector('.sc-selected');
if (pre) pre.classList.remove('sc-selected');
this.classList.add('sc-selected');
}
})
let selectYear = container.querySelector('.sc-select-year');
let selectMonth = container.querySelector('.sc-select-month');
selectYear.onchange = function() {
let m = selectMonth.value;
let y = this.value;
calendar.update(m, y)
}
selectMonth.onchange = function() {
let y = selectYear.value;
let m = this.value;
calendar.update(m, y)
};
/*-----------------------------------------------------click 事件------------------------------------*/
let yearadd = container.querySelector('.sc-yright');
let yearsub = container.querySelector('.sc-yleft');
let monthadd = container.querySelector('.sc-mright');
let monthsub = container.querySelector('.sc-mleft');
yearadd.onclick = function() { //点击切换年份
let currentyear = selectYear.value; //获取年份
let currentmonth = selectMonth.value;//获取月份
if (currentyear < 2099) currentyear++;
selectYear.value = currentyear;
calendar.update(currentmonth, currentyear);
};
yearsub.onclick = function() {
let currentyear = selectYear.value;
let currentmonth = selectMonth.value;
if (currentyear > 1900) currentyear--;
selectYear.value = currentyear;
calendar.update(currentmonth, currentyear);
};
monthadd.onclick = function() {
let currentmonth = selectMonth.value;
let currentyear = selectYear.value;
if (currentmonth < 12) currentmonth++;
else {
currentmonth = 1;
selectYear.value = ++currentyear;
};
selectMonth.value = currentmonth;
calendar.update(currentmonth, currentyear);
};
monthsub.onclick = function() {
let currentmonth = selectMonth.value;
let currentyear = selectYear.value;
if (currentmonth > 1) currentmonth--;
else {
currentmonth = 12;
selectYear.value = --currentyear;
}
selectMonth.value = currentmonth;
calendar.update(currentmonth, currentyear);
}
let returntoday = container.querySelector('.sc-return-today');
returntoday.onclick = function() {
selectYear.value = calendar.tyear;
selectMonth.value = calendar.tmonth;
calendar.update();
}
}
//添加标记
addMark(day, info) {
this._options.mark[day] = info;
this.update();
}
//获取用户点击的日期
getSelectedDay() {
let selectYear = this.container.querySelector('.sc-select-year').value;
let selectMonth = this.container.querySelector('.sc-select-month').value;
let selectDay = this.selectDay.querySelector('.day').innerHTML;
return new Date(selectYear, selectMonth - 1, selectDay);
}
//设置语言
setLenguage(language) {
this._options.language = language;
let selectYear = this.container.querySelector('.sc-select-year');
let selectMonth = this.container.querySelector('.sc-select-month');
this.updateSelect(selectYear.value, selectMonth.value);
this.update();
}
//设置是否显示节日
showFestival(s) {
this._options.showFestival = s;
this.update();
}
//设置是否显示假期
showHoliday(s) {
this._options.showHoliday = s;
this.update();
}
//设置是否显示节气
showSolarTerm(s) {
this._options.showSolarTerm = s;
this.update();
}
//设置是否显示阴历节日
showLunarFestival(s) {
this._options.showLunarFestival = s;
this.update();
}
//设置是否显示阴历日期
showLunarCalendar(s) {
this._options.showLunarCalendar = s;
this.update();
}
//设置是否显示标记日期
showMark(s) {
this._options.showMark = s;
this.update();
}
//将nodelist转为数组
//nodelist转数组
arrayfrom(nidelist) {
let array = [];
[].forEach.call(nidelist, function(v) {
array.push(v);
});
return array;
}
// get options() {
// console.log(this._options);
// }
}
//时间刷新函数
SimpleCalendar.timeupdate = function() {
let timespan = document.querySelectorAll('.sc-time');
let now = new Date();
let nh = now.getHours();
let nm = now.getMinutes();
let ns = now.getSeconds();
if (nh < 10) nh = '0' + nh;
if (nm < 10) nm = '0' + nm;
if (ns < 10) ns = '0' + ns;
[].forEach.call(timespan, function(v) {
v.innerHTML = '时间:' + nh + ":" + nm + ':' + ns;
})
}
//国际化,和一些节日数据,标记数据
SimpleCalendar.prototype.languageData = {
feativals_CH: {
'1-1': '元旦',
'2-14': '情人节',
'3-8': '妇女节',
'3-12': '植树节',
'4-1': '愚人节',
'4-23':'读书日',
'4-26':'知识产权',
'4-22': '地球日',
'5-1': '劳动节',
'5-4': '青年节',
'5-31': '无烟日',
'6-1': '儿童节',
'6-5': '环境日',
'6-16': '父亲节',
'7-1': '建党节',
'8-1': '建军节',
'9-10': '教师节',
'10-1': '国庆节',
'12-25': '圣诞节',
},
feativals_EN: {
'1-1': "new year’s day",
'2-14': "Saint Valentine's Day",
'3-8': 'international women’s day',
'3-12': "Arbor Day",
'4-1': "April Fool's Day",
'4-22': "Earth Day",
'5-1': "international labour day",
'5-4': "Chinese Youth Day",
'6-1': "Children's Day",
'7-1': "The party's Day",
'8-1': "the Army's Day",
'9-10': "Teachers' Day",
'10-1': 'National Day',
'12-25': 'Christmas Day',
},
lunarFeatival_CH: {
'1-1': '春节',
'2-2': '龙抬头',
'1-15': '元宵节',
'4-4': '寒食节',
'4-5': '清明节',
'5-5': '端午节',
'8-15': '中秋节',
'9-9': '重阳节',
'12-30': '除夕',
},
//节气
solarTerm: {
'2-4': '立春',
'5-6': '立夏',
'8-8': '立秋',
'11-8': '立冬',
'2-19': '雨水',
'5-21': '小满',
'8-23': '处暑',
'11-23': '小雪',
'3-6': '惊蛰',
'6-6': '芒种',
'9-8': '白露',
'12-7': '大雪',
'3-21': '春分',
'6-22': '夏至',
'9-23': '秋分',
'12-22': '冬至',
'4-5': '清明',
'7-7': '小暑',
'10-9': '寒露',
'1-6': '小寒',
'4-20': '谷雨',
'7-23': '大暑',
'10-24': '霜降',
'1-21': '大寒',
},
solarTermt: {
'2-3': '立春',
'5-5': '立夏',
'8-7': '立秋',
'11-7': '立冬',
'2-18': '雨水',
'5-20': '小满',
'8-22': '处暑',
'11-22': '小雪',
'3-5': '惊蛰',
'6-5': '芒种',
'9-7': '白露',
'12-6': '大雪',
'3-20': '春分',
'6-21': '夏至',
'9-22': '秋分',
'12-21': '冬至',
'4-4': '清明',
'7-6': '小暑',
'10-8': '寒露',
'1-5': '小寒',
'4-19': '谷雨',
'7-22': '大暑',
'10-23': '霜降',
'1-20': '大寒',
},
days_EN: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
days_CH: ["","", "", "", "", "", ""],
months_EN: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
months_CH: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
vocation: {
data_2019: ['1-1', '2-4','2-5','2-6','2-7', '2-8', '2-9', '2-10','4-5', '4-6', '4-7', '5-1', '5-2', '5-3', '5-4','6-7', '6-8', '6-9', '9-13', '9-14', '9-15', '10-1', '10-2', '10-3', '10-4', '10-5', '10-6', '10-7']
},
}
SimpleCalendar.prototype.tyear = (new Date()).getFullYear();
SimpleCalendar.prototype.tmonth = (new Date()).getMonth() + 1;
SimpleCalendar.prototype.tday = (new Date()).getDate();
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.db.Logger" %>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
Connection conn = null;
Enumeration enu = request.getParameterNames();
String action = pub.trimNull(request.getParameter("action"));
String action_msg="";
String mx_id = pub.trimNull(request.getParameter("mx_id"));
if("".equals(mx_id)){
mx_id=UUID.randomUUID().toString().trim().replaceAll("-", "");
}
String day_id = pub.trimNull(request.getParameter("day_id"));
String[] userids = request.getParameterValues("userids");
String user_names="";
if(userids!=null && userids.length>0) {
for (int i = 0; i < userids.length; i++) {
user_names+=userids[i]+",";
}
}
if(!"".equals(user_names)){
user_names=user_names.substring(0,user_names.length()-1);
}
String input_count = pub.trimNull(request.getParameter("input_count"));
if("".equals(input_count)){
input_count="1";
}
int inputSize=Integer.parseInt(input_count);
String mx_name = pub.trimNull(request.getParameter("mx_name"));
String mx_day = pub.trimNull(request.getParameter("mx_day"));
int mxDay=1;
if(!"".equals(mx_day)){
mxDay=Integer.parseInt(mx_day);
}
String add_user = pub.trimNull((String) session.getAttribute("session_login_id"));
if ("".equals(add_user)) {
System.out.println("当前没有用户信息");
}
String add_time = pub.getCurrentServerTime();
StringBuffer sql_add=new StringBuffer("insert into zb_mx (id,name,day,add_time,add_user) values (?,?,?,?,?)");
StringBuffer sql_update=new StringBuffer("update t_user_phone set update_user=?,update_time=?,");
try {
conn = com.censoft.db.DBUtil.getConnection();
List list_add= new ArrayList();
list_add.add(mx_id);
list_add.add(mx_name);
list_add.add(mx_day);
list_add.add(add_time);
list_add.add(add_user);
List list_update = new ArrayList();
conn.setAutoCommit(false);
boolean is_oper = false;
if("add".equals(action)){
action_msg="新增";
is_oper = cf.executeUpdate(conn, sql_add.toString(),list_add.toArray());
if (!is_oper) {
conn.rollback();
System.out.println("新增zb_mx表出错了" + cf.getMsg());
return;
}
for (int i = 0; i < inputSize; i++) {
String b_time = pub.trimNull(request.getParameter("b_time_"+(i+1)));
String e_time = pub.trimNull(request.getParameter("e_time_"+(i+1)));
String zb_type = pub.trimNull(request.getParameter("zb_type_"+(i+1)));
String zb_type_id=UUID.randomUUID().toString().trim().replaceAll("-", "");
is_oper = cf.executeUpdate(conn, "insert into zb_type(id,mx_id,zb_type,b_time,e_time,add_user,add_time) values (?,?,?,?,?,?,?)"
, new Object[]{zb_type_id,mx_id,zb_type,b_time,e_time,add_user,add_time});
if (!is_oper) {
System.out.println("新增zb_type表出错了" + cf.getMsg());
conn.rollback();
return;
}
for(int n=0;n<mxDay;n++){
is_oper = cf.executeUpdate(conn, "insert into zb_mx_day(mx_id,zb_type,user_name,day,add_user,add_time) values (?,?,?,?,?,?)"
, new Object[]{mx_id,zb_type_id,"",n+1,add_user,add_time});
if (!is_oper) {
System.out.println("新增zb_mx_day表出错了" + cf.getMsg());
conn.rollback();
return;
}
}
}
}else if("delete".equals(action)){
action_msg="删除";
is_oper = cf.executeUpdate(conn, "delete from zb_mx_day where mx_id=?",new Object[]{mx_id});
if (!is_oper) {
conn.rollback();
System.out.println("删除zb_mx_day表出错了" + cf.getMsg());
return;
}
is_oper = cf.executeUpdate(conn, "delete from zb_type where mx_id=?",new Object[]{mx_id});
if (!is_oper) {
conn.rollback();
System.out.println("删除zb_type表出错了" + cf.getMsg());
return;
}
is_oper = cf.executeUpdate(conn, "delete from zb_mx where id=?",new Object[]{mx_id});
if (!is_oper) {
conn.rollback();
System.out.println("删除zb_mx表出错了" + cf.getMsg());
return;
}
}else if("addUser".equals(action)){
action_msg="选择人员";
is_oper = cf.executeUpdate(conn, "update zb_mx_day set user_name=? where id=?",new Object[]{user_names,day_id});
if (!is_oper) {
conn.rollback();
System.out.println("插入人员zb_mx_day表出错了" + cf.getMsg());
return;
}
}else{
action_msg="修改";
String zb_type_ids="";
for (int i = 0; i < inputSize; i++) {
String b_time = pub.trimNull(request.getParameter("b_time_"+(i+1)));
String e_time = pub.trimNull(request.getParameter("e_time_"+(i+1)));
String zb_type = pub.trimNull(request.getParameter("zb_type_"+(i+1)));
String zb_type_id=pub.trimNull(request.getParameter("zb_type_id_"+(i+1)));
if(!"".equals(zb_type_id)){
zb_type_ids=zb_type_id+","+zb_type_ids;
is_oper = cf.executeUpdate(conn, "update zb_type set zb_type=?,b_time=?,e_time=?,update_time=?,update_user=? where id=?"
, new Object[]{zb_type,b_time,e_time,add_time,add_user,zb_type_id});
}else{
String new_id=UUID.randomUUID().toString().trim().replaceAll("-", "");
is_oper = cf.executeUpdate(conn, "insert into zb_type(id,mx_id,zb_type,b_time,e_time,add_user,add_time) values (?,?,?,?,?,?,?)"
, new Object[]{new_id,mx_id,zb_type,b_time,e_time,add_user,add_time});
if (!is_oper) {
System.out.println("修改zb_type表出错了" + cf.getMsg());
conn.rollback();
return;
}
for(int n=0;n<mxDay;n++){
is_oper = cf.executeUpdate(conn, "insert into zb_mx_day(mx_id,zb_type,user_name,day,add_user,add_time) values (?,?,?,?,?,?)"
, new Object[]{mx_id,new_id,"",n+1,add_user,add_time});
if (!is_oper) {
System.out.println("新增zb_mx_day表出错了" + cf.getMsg());
conn.rollback();
return;
}
}
}
if (!is_oper) {
System.out.println("修改zb_type表出错了" + cf.getMsg());
conn.rollback();
return;
}
}
//修改页面,删除已有行
/*if(!"".equals(zb_type_ids)){
zb_type_ids=zb_type_ids.substring(0,zb_type_ids.length()-1);
String[] field=zb_type_ids.split(",");
StringBuffer sb = new StringBuffer();
sb.append("delete from zb_type where 1=1 ");
sb.append(" and id not in (");
if(field!=null&&field.length>0){
for(int i=0;i<field.length;i++){
if(i==field.length-1){
sb.append("'" + field[i] + "'");
}else{
sb.append("'" + field[i] + "',");
}
}
}
sb.append(" )");
//System.out.println(sb.toString());
is_oper = cf.executeUpdate(conn, sb.toString(), new Object[]{});
if (!is_oper) {
conn.rollback();
System.out.println("删除多余的时间段出错了" + cf.getMsg());
return;
}
}*/
is_oper = cf.executeUpdate(conn, "update zb_mx set name=? where id=?", new Object[]{mx_name,mx_id});
if (!is_oper) {
conn.rollback();
System.out.println("修改zb_mx表出错了" + cf.getMsg());
return;
}
}
if (!is_oper) {
conn.rollback();
System.out.println("操作出错了" + cf.getMsg());
return;
}
Logger.log(conn, "值班模型",action_msg, add_user, "", request);
conn.commit();
if (!is_oper) {
conn.rollback();
out.println(cf.getMsg());
} else {
out.println("success");
}
} catch (Exception e) {
conn.rollback();
System.out.println("有异常" + e);
return;
} finally {
if (conn != null) {
conn.setAutoCommit(true);
try {
conn.close();
} catch (Exception e) {
}
}
}
%>
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2020/9/11
Time: 12:54
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.Hashtable" %>
<%@ page import="java.util.Vector" %>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
Connection conn = null;
Vector v_list = null;
Vector v_type_list = null;
String mx_id = pub.trimNull(request.getParameter("mx_id"));
String action = pub.trimNull(request.getParameter("action"));
Hashtable ht = new Hashtable();
StringBuffer sql = new StringBuffer();
StringBuffer group_sql = new StringBuffer();
int listSize=1;
try {
conn = com.censoft.db.DBUtil.getConnection();
if("update".equals(action)){
sql.append("select * from zb_mx where id=?");
v_list = cf.doQuery(conn, sql.toString(), null, new Object[]{mx_id});
}
if(!"".equals(mx_id)) {
group_sql.append("select * from zb_type where mx_id=? order by order_num asc");
v_type_list = cf.doQuery(conn, group_sql.toString(), null, new Object[]{mx_id});
if(v_type_list!=null && v_type_list.size()>0){
listSize=v_type_list.size();
}
}
if (v_list!=null&&v_list.size() > 0) {
ht = (Hashtable) v_list.get(0);
}
} catch (Exception e) {
out.println("查询用户信息异常" + e);
return;
} finally {
if (conn != null) {
try {
conn.close();
} catch (Exception e) {
}
}
}
%>
<style>
.input-three {
width: 22%
}
.input-two {
width: 32%
}
.col-sm-2{
width:14%;
}
.col-sm-3{
width:19%;
}
.btn-red{ background-color:red;border: red}
.btn-green{ background-color:green;border: green}
</style>
<div class="">
<form class="form form-horizontal" id="form-admin-add">
<input type="hidden" value="<%=action%>" name="action" id="action">
<input type="hidden" value="<%=mx_id%>" name="mx_id" id="mx_id">
<input type="hidden" id="input_count" name="input_count" value="<%=listSize%>"/>
<div id="content" class="cl pd-5 bk-gray divOverflow" style="overflow:hidden;margin-bottom: 20px;">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>模型名字&nbsp;
</label>
<div class="formControls col-xs-8 col-sm-10">
<input type="text" class="input-text" name="mx_name" id="mx_name" value="<%=pub.trimNull((String)ht.get("name"))%>" >
</div>
</div>
<div class="row cl" >
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>天数&nbsp;
</label>
<div class="formControls col-xs-8 col-sm-10">
<input <%if("update".equals(action)){%>readonly="readonly" <%}%>type="text" class="input-text" name="mx_day" id="mx_day" value="<%=pub.trimNull((String)ht.get("day"))%>" >
</div>
</div>
<div class="row cl" id="zb_type_div">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>时间段&nbsp;
</label>
</div>
<%
Hashtable ht1 = new Hashtable();
if(v_type_list != null && v_type_list.size() > 0){
for (int i = 0; i < v_type_list.size(); i++) {
ht1 = (Hashtable) v_type_list.get(i);
%>
<div class="zbType row cl" id="div_<%=pub.trimNull((String)ht.get("id"))%>">
<input type="hidden" name="zb_type_id_<%=i+1%>" value="<%=pub.trimNull((String)ht1.get("id"))%>">
<label class="form-label col-xs-4">
<input type="text" style="width:30%;" autocomplete="off" class="input-text" value="<%=pub.trimNull((String)ht1.get("zb_type"))%>" placeholder="" id = "zb_type_<%=i+1%>" name="zb_type_<%=i+1%>" >
</label>
<div class="formControls col-xs-4">
<input type="text" style="width:30%;" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="<%=pub.trimNull((String)ht1.get("b_time"))%>" placeholder="" id = "b_time_<%=i+1%>" name="b_time_<%=i+1%>" >
&nbsp;&nbsp;
<input type="text" style="width:30%;" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="<%=pub.trimNull((String)ht1.get("e_time"))%>" placeholder="" id = "e_time_<%=i+1%>" name="e_time_<%=i+1%>" >
</div>
<%
if(i==0){
%>
<a href="javascript:void (0);" onclick="addDiv();" style="font-size: 25px;">+</a>
<%}else{%>
<a href="javascript:void (0);" onclick="deleteDiv('<%=pub.trimNull((String)ht.get("id"))%>');" style="font-size: 25px;display:none;">-</a>
<%}
%>
</div>
<%
}
}else{
%>
<div class="zbType row cl" id="div_1">
<label class="form-label col-xs-4">
<input type="text" style="width:30%;" autocomplete="off" class="input-text" value="" placeholder="" id = "zb_type_1" name="zb_type_1" >
</label>
<div class="formControls col-xs-4">
<input type="text" style="width:30%;" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="" placeholder="" id = "b_time_1" name="b_time_1" >
&nbsp;&nbsp;
<input type="text" style="width:30%;" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="" placeholder="" id = "e_time_1" name="e_time_1" >
</div>
<a href="javascript:void (0);" onclick="addDiv();" style="font-size: 25px;">+</a>
</div>
<%
}
%>
</div>
</form>
</div>
<div class="cl mb-10 bk-gray " style="height: 50px;">
<div class="col-sm-3 pd-10" style="width:100%;text-align: center;">
<input class="btn btn-primary radius btn-green" type="button" onclick="javascript:saveForm();" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
</div>
</div>
<script src="<%=request.getContextPath()%>/js/Convert_Pinyin.js"></script>
<script>
var count;
var size='<%=listSize%>';
if(size==0){
count=1;
}else{
count=parseInt(size);
}
function addDiv(){
var name_count=parseInt($("#input_count").val());
$("#content").append("<div class=\"zbType row cl\" name=\""+(count+1)+"\" id=\"div_"+(count+1)+"\">\n" +
" <label class=\"form-label col-xs-4\" > " +
" <input type=\"text\" style=\"width:30%;\" autocomplete=\"off\" class=\"input-text\" value=\"\" placeholder=\"\" id = \"zb_type_"+(name_count+1)+"\" name=\"zb_type_"+(name_count+1)+"\" > :</label>\n" +
" <div class=\"formControls col-xs-4\">\n" +
" <input type=\"text\" style=\"width:30%;\" autocomplete=\"off\" class=\"input-text Wdate\" onclick=\"WdatePicker({dateFmt:'HH-mm'})\" value=\"\" placeholder=\"\" id = \"b_time_"+(name_count+1)+"\" name=\"b_time_"+(name_count+1)+"\" >\n" +
" &nbsp;至&nbsp;\n" +
" <input type=\"text\" style=\"width:30%;\" autocomplete=\"off\" class=\"input-text Wdate\" onclick=\"WdatePicker({dateFmt:'HH-mm'})\" value=\"\" placeholder=\"\" id = \"e_time_"+(name_count+1)+"\" name=\"e_time_"+(name_count+1)+"\" >\n" +
" </div>\n" +
" <a href=\"javascript:void (0);\" onclick=\"deleteDiv("+(count+1)+");\" style=\"font-size: 25px;\">-</a>"+
" </div>");
count++;
//var obj=document.getElementsByClassName("row cl").length;
var obj=$(".zbType").length;
$("#input_count").val(obj);
}
function deleteDiv(div_id){
$("#div_"+div_id).remove();
$('.zbType').each(function(index,element){
if(index!=0){
index=index+1;
//$(this).children(":first").html("号段"+index+":");
var div_index=$(this).attr("name");
$("#zb_type_"+div_index).attr("name","zb_type_"+index);
$("#b_time_"+div_index).attr("name","b_time_"+index);
$("#e_time_"+div_index).attr("name","e_time_"+index);
}
});
//var obj=document.getElementsByClassName("row cl").length;
var obj=$(".zbType").length;
$("#input_count").val(obj);
}
function LayerOpen(title, url, w, h) {
if($("#user_id").val()==''){
layer.alert("请先保存用户再添加相关人员",{icon:5,title:"提示"});
return false;
}
var abc = layer.open({
title:title,
type: 2,
content: url,
area: [w, h],
maxmin: true
});
layer.full(abc);
}
function viewDeptOrUserInfo(title, url, w, h) {
location.href=url;
}
function saveForm() {
if($("#mx_name").val()==''){
layer.alert("模型名称不能为空",{icon:5,title:"提示"});
return false;
}
$.ajax({
type: "POST",
url: "./action.jsp",
data: $('#form-admin-add').serialize(),
success: function (msg) {
if (msg.indexOf("success") >= 0) {
layer.msg('操作成功!', {icon: 1, time: 1000},
function () {
//parent.searchModel();
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
} else {
layer.msg('操作失败', {
icon: 5,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
// console.log("********************8")
});
}
}
});
}
function deleteUser(user_id,p_user_id){
layer.confirm('确认要删除吗?', function (index) {
$.ajax({
type: "POST",
url: "./action.jsp?&p_user_id="+p_user_id+"&user_id="+user_id+"&action=delete",
success: function (msg) {
if (msg.indexOf("success") >= 0) {
layer.msg('操作成功!', {icon: 1, time: 1000},
function () {
location.reload();
if(rel_user_id!=''){
window.parent.location.reload();
}
parent.searchModel();
});
} else {
layer.msg('操作失败', {
icon: 5,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
// console.log("********************8")
});
}
}
});
});
}
</script>
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2020/9/11
Time: 12:54
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
Connection conn = null;
Vector v_list = null;
String login_id = (String) session.getAttribute("session_login_id");
if ("".equals(login_id)) {
System.out.println("当前没有用户信息");
}
String page_number = pub.trimNull(request.getParameter("page_number"));
String opt = pub.trimNull(request.getParameter("opt"));
if ("".equals(page_number)) page_number = "1";
String page_size = pub.trimNull(request.getParameter("page_size"));
if ("".equals(page_size)) page_size = "20";
StringBuffer sql = new StringBuffer();
List list = new ArrayList();
sql.append("select * from zb_mx");
sql.append(" order by add_time desc");
try {
conn = com.censoft.db.DBUtil.getConnection();
v_list = cf.doPageQueryWithCount(conn, sql.toString(), page_number, page_size, null, list.toArray());
if (v_list == null) {
out.println("查询用户出错");
return;
}
} catch (Exception e) {
out.println("查询用户信息异常" + e);
return;
} finally {
if (conn != null) {
try {
conn.close();
} catch (Exception e) {
}
}
}
Hashtable ht_row = (Hashtable) v_list.get(0);
String rowCnt = pub.trimNull((String) ht_row.get("ROWCOUNT"));
String pageCnt = pub.trimNull((String) ht_row.get("PAGECOUNT"));
%>
<div style="margin-top: 10px;" id="leftMx">
<ul>
<%
if (v_list != null && v_list.size() > 0) {
for (int i = 1; i < v_list.size(); i++) {
Hashtable ht = (Hashtable) v_list.get(i);
String id = pub.trimNull((String) ht.get("id"));
String name = pub.trimNull((String) ht.get("name"));
String day = pub.trimNull((String) ht.get("day"));
%>
<li id="li_<%=id%>" style="padding-left: 30px;height:30px;line-height: 30px;cursor: pointer;" onclick="openLi('<%=id%>','<%=day%>');">
<%=name%>
</li>
<%}}%>
</ul>
</div>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
%>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/pagination.css">
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.pagination.js"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/zTree/v3/css/zTreeStyle/zTreeStyle.css"
type="text/css">
<div class="page-container">
<div class="left-tree">
<button class="btn btn-success" onclick="optMx('add');" style="text-align:center;float:left;">
新建</button>
<button class="btn btn-success" onclick="updateMx();" style="text-align:center;float:left;margin-left: 20px;">
修改</button>
<button class="btn btn-success" onclick="delMx();" style="text-align:center;float:right;">
删除</button>
<input type="hidden" name="check_mx_id" id="check_mx_id">
<input type="hidden" name="check_mx_day" id="check_mx_day">
<div id="deptinfo" class="deptinfo" style="width:100%;">
</div>
</div>
<div class="right-contant" >
<div id="datalist">
</div>
</div>
</div>
</div>
<script type="text/javascript">
searchModel();
function searchModel() {
$.ajax({
type: "post",
url: "left_list.jsp",
//data: $('#data_form_search').serialize(),
success: function (msg) {
$("#deptinfo").html(msg);
}
});
}
function searchModel1(mx_id) {
$.ajax({
type: "post",
url: "right_list.jsp?number="+Math.random()+"&mx_id="+mx_id+"&day="+$("#check_mx_day").val(),
success: function (msg) {
$("#datalist").html(msg);
$("#li_"+mx_id).css("backgroundColor","#cccccc");
}
});
}
$(document).keyup(function (event) {
if (event.keyCode == 13) {
searchModel();
}
});
function addUser() {
var url = './editUser-t.jsp?action=add&dept_id=';
var dept_id = document.getElementById("dept_id").value;
if (dept_id == '') {
layer.alert("请选择机构", {icon: 5, title: "提示"});
return false;
}
url += dept_id;
viewDeptOrUserInfo('人员信息', url, '1000', '500');
}
function optMx(type) {
var url = './edit-t.jsp?action='+type;
viewDeptOrUserInfo('新建模型', url, '1000', '500');
}
function updateMx(){
var mx_id=$("#check_mx_id").val();
if(mx_id==''){
layer.alert("请选择模型", {icon: 5, title: "提示"});
return false;
}
var url = './edit-t.jsp?action=update&mx_id='+mx_id;
viewDeptOrUserInfo('修改模型', url, '1000', '500');
}
function delMx(){
var mx_id=$("#check_mx_id").val();
if(mx_id==''){
layer.alert("请选择模型", {icon: 5, title: "提示"});
return false;
}
layer.confirm('确认要删除吗?', function (index) {
$.ajax({
type: "POST",
url: "./action.jsp?mx_id="+mx_id+"&action=delete",
success: function (msg) {
if (msg.indexOf("success") >= 0) {
layer.msg('操作成功!', {icon: 1, time: 1000},
function () {
searchModel();
window.location.reload();
});
} else {
layer.msg('操作失败', {
icon: 5,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
// console.log("********************8")
});
}
}
});
});
}
function viewDeptOrUserInfo(title, url, w, h) {
var abc = layer.open({
title: title,
type: 2,
content: url,
area: [w+'px', h+'px'],
maxmin: true,
end:function () {
searchModel();
searchModel1($("#check_mx_id").val());
}
});
//layer.full(abc);
}
function openLi(mx_id,day) {
$("#check_mx_id").val(mx_id);
$("#check_mx_day").val(day);
$("#leftMx ul li").each(function(){
$(this).css("backgroundColor","#e0e4f6");
})
$("#li_"+mx_id).css("backgroundColor","#cccccc");
searchModel1(mx_id);
}
function editUser(day_id,mx_id) {
var url = './selectUser-t.jsp?day_id='+day_id+"&mx_id="+mx_id;
var abc = layer.open({
title: '选择人员',
type: 2,
content: url,
area: ['1000px', '500px'],
maxmin: true,
end:function () {
searchModel1($("#check_mx_id").val());
}
});
}
</script>
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2020/9/11
Time: 12:54
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
Connection conn = null;
Vector v_list = null;
Vector v_list_day = null;
String login_id = (String) session.getAttribute("session_login_id");
if ("".equals(login_id)) {
System.out.println("当前没有用户信息");
}
String mx_id = pub.trimNull(request.getParameter("mx_id"));
String Mxday = pub.trimNull(request.getParameter("day"));
int divCount=8;
if(!"".equals(Mxday)){
divCount=Integer.parseInt(Mxday);
}
String divWidth=(divCount+2)*140+"px";
StringBuffer sql = new StringBuffer();
StringBuffer sql_day = new StringBuffer();
int listSize=1;
sql.append("select * from zb_type where mx_id=? order by order_num asc ");
sql_day.append("select * from zb_mx_day where mx_id=? and zb_type=? order by day asc ");
try {
conn = com.censoft.db.DBUtil.getConnection();
v_list = cf.doQuery(conn, sql.toString(), null, new Object[]{mx_id});
if (v_list != null && v_list.size()>0) {
}
%>
<div style="border: solid 1px #eee;margin-top: 20px;height:550px;width:1100px;overflow: auto;">
<%
for(int i=0;i<v_list.size();i++){
Hashtable ht = (Hashtable) v_list.get(i);
String id=pub.trimNull((String)ht.get("id"));
String zb_type=pub.trimNull((String)ht.get("zb_type"));
String b_time=pub.trimNull((String)ht.get("b_time"));
String e_time=pub.trimNull((String)ht.get("e_time"));
v_list_day = cf.doQuery(conn, sql_day.toString(), null, new Object[]{mx_id,id});
%>
<%
if(i==0){%>
<div style="width:<%=divWidth%>;height:40px;float:left;white-space: nowrap;">
<div style="width:140px;height:40px;float:left;border:0.5px solid #000;">
</div>
<%
if(v_list_day!=null && v_list_day.size()>0){
for(int n=0;n<v_list_day.size();n++){
Hashtable ht1 = (Hashtable) v_list_day.get(n);
String day=pub.trimNull((String)ht1.get("day"));
%>
<div style="width:140px;height:40px;line-height:40px;text-align:center;color:#fff;float:left;border:0.5px solid #000;background-color: #00b7ee">
<%=day%>
</div>
<% }}%>
</div>
<%}%>
<div style="width:<%=divWidth%>;height:160px;float:left;">
<div style="width:140px;height:160px;float:left;border:0.5px solid #000;text-align: center;line-height: 120px;">
<p style="height:30px;"> <%=zb_type%></p>
<p style="height:30px;">(<%=b_time%>-<%=e_time%>)</p>
</div>
<%
if(v_list_day!=null && v_list_day.size()>0){
for(int n=0;n<v_list_day.size();n++){
Hashtable ht1 = (Hashtable) v_list_day.get(n);
String day_id=pub.trimNull((String)ht1.get("id"));
String user_name=pub.trimNull((String)ht1.get("user_name"));
user_name=user_name.replace(",","</br>");
%>
<div style="text-align:center;width:140px;height:160px;float:left;border:0.5px solid #000;position: relative">
<p style="height:10px;"></p>
<%=user_name%>
<button class="btn btn-success" onclick="editUser('<%=day_id%>','<%=mx_id%>');" style="text-align:center;position:absolute; right:0; bottom:0;">
修改</button>
</div>
<%}}%>
</div>
<%}%>
</div>
<script type="text/javascript">
function deleteUser(user_id){
layer.confirm('确认要删除吗?', function (index) {
$.ajax({
type: "POST",
url: "./action.jsp?user_id="+user_id+"&action=delete",
success: function (msg) {
if (msg.indexOf("success") >= 0) {
layer.msg('操作成功!', {icon: 1, time: 1000},
function () {
searchModel();
});
} else {
layer.msg('操作失败', {
icon: 5,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
// console.log("********************8")
});
}
}
});
})
}
function optOrder(opt,user_id){
$.ajax({
type: "post",
url: "opt_order.jsp",
data:{"user_id":user_id,"opt":opt},
success: function (data) {
if (data.indexOf("success") >= 0) {
layer.msg('操作成功!', {icon: 1, time: 1000},
function () {
searchModel();
});
} else {
layer.msg('操作失败,'+data, {
icon: 5,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
// console.log("********************8")
});
}
}
});
}
</script>
<%
} catch (Exception e) {
out.println("查询用户信息异常" + e);
return;
} finally {
if (conn != null) {
try {
conn.close();
} catch (Exception e) {
}
}
}
%>
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2020/9/11
Time: 12:54
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.db.Logger" %>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
Connection conn = null;
Vector v_list = null;
Vector v_list_day = null;
String user_names ="";
String login_id = (String) session.getAttribute("session_login_id");
if ("".equals(login_id)) {
System.out.println("当前没有用户信息");
}
String page_number = pub.trimNull(request.getParameter("page_number"));
String day_id = pub.trimNull(request.getParameter("day_id"));
String mx_id = pub.trimNull(request.getParameter("mx_id"));
if ("".equals(page_number)) page_number = "1";
String page_size = pub.trimNull(request.getParameter("page_size"));
if ("".equals(page_size)) page_size = "10";
StringBuffer sql = new StringBuffer();
List list = new ArrayList();
sql.append("select * from zb_user order by id desc");
try {
conn = com.censoft.db.DBUtil.getConnection();
v_list = cf.doPageQueryWithCount(conn, sql.toString(), page_number, page_size, null, list.toArray());
if (v_list == null) {
out.println("查询用户出错");
return;
}
v_list_day = cf.doQuery(conn, "select user_name from zb_mx_day where id=?", null, new Object[]{day_id});
if (v_list_day != null && v_list_day.size()>0) {
Hashtable ht1= (Hashtable) v_list_day.get(0);
user_names = pub.trimNull((String) ht1.get("user_name"));
}
Hashtable ht_row = (Hashtable) v_list.get(0);
String rowCnt = pub.trimNull((String) ht_row.get("ROWCOUNT"));
%>
<div style="margin-top: 10px;">
<a class="btn btn-primary radius" onclick="saveGroupForm('<%=mx_id%>');" >
确定
</a>
</div>
<form action="selectUser-t.jsp" method="post" id="groupUser" name="groupUser">
<input type="hidden" name="day_id" id="day_id" value="<%=day_id%>">
<table class="table table-border table-bordered table-hover table-bg table-sort">
<thead>
<tr class="text-c">
<th width="30">序号</th>
<th width="30">
<input id="checkboxAll" type="checkbox" onclick="checkAll(this);"></input>
</th>
<th width="100">人员姓名</th>
<th width="100">联系电话</th>
<th width="100">工号</th>
</tr>
</thead>
<tbody id="groupUserInfo">
<%
Hashtable ht_1 =null;
if (v_list != null && v_list.size() > 0) {
for (int i = 1; i < v_list.size(); i++) {
Hashtable ht = (Hashtable) v_list.get(i);
String user_id = pub.trimNull((String) ht.get("id"));
String user_name = pub.trimNull((String) ht.get("user_name"));
String tel = pub.trimNull((String) ht.get("tel"));
String gh = pub.trimNull((String) ht.get("gh"));
%>
<tr class="text-c">
<td><%=i%>
</td>
<td >
<input type="checkbox" class="info" id="userids" name="userids" value="<%=user_name%>"
<%if(user_names.indexOf(user_name)>=0){%>checked="checked"<%}%>/>
</td>
<td><%=user_name%>
</td>
<td><%=tel%>
</td>
<td><%=gh%>
</td>
</tr>
<%
}
}
%>
</tbody>
</table>
</form>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/pagination.css">
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.pagination.js"></script>
<jsp:include page="/common/page_ajax.jsp" >
<jsp:param name="page_number" value="<%=page_number%>" />
<jsp:param name="rowCnt" value="<%=rowCnt%>" />
<jsp:param name="page_size" value="<%=page_size%>" />
</jsp:include>
<script type="text/javascript">
var checkAll = function (checkbox) {
$(".info").prop("checked", checkbox.checked);
}
function saveGroupForm(mx_id){
var isChecked=false;
var us = document.getElementsByName("userids");
for(var i=0;i<us.length;i++){
if(us[i].checked){
isChecked = true;
}
}
if(!isChecked){
layer.alert("请勾选用户",{icon:5,title:"提示"});
return false;
}
$.ajax({
type: "POST",
url: "./action.jsp?action=addUser",
data: $('#groupUser').serialize(),
success: function (msg) {
if (msg.indexOf("success") >= 0) {
layer.msg('操作成功!', {icon: 1, time: 1000},
function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
} else {
layer.msg('操作失败', {
icon: 5,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
// console.log("********************8")
});
}
}
});
}
</script>
<%
} catch (Exception e) {
out.println("查询用户信息异常" + e);
return;
} finally {
if (conn != null) {
try {
conn.close();
} catch (Exception e) {
}
}
}
%>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.db.Logger" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.ParseException" %>
<%!
public static String getUserNames(ConnectionFactory cf,Connection conn,int startIndex,int n){
Vector userListSize = cf.doQuery(conn,"select id from zb_user",null,new Object[]{});
StringBuffer sql=new StringBuffer("select user_name from zb_user where 1=1 and order_num in(");
List list= new ArrayList();
String user_names="";
int startIndex_2=startIndex;
for(int i=0;i<n;i++){
startIndex=startIndex+1;
if(startIndex==userListSize.size()+1){
startIndex=1;
}
if(i==n-1){
sql.append(startIndex );
}else{
sql.append(startIndex + ",");
}
}
sql.append(") order by field (order_num,");
for(int i=0;i<n;i++){
startIndex_2=startIndex_2+1;
if(startIndex_2==userListSize.size()+1){
startIndex_2=1;
}
if(i==n-1){
sql.append(startIndex_2 );
}else{
sql.append(startIndex_2 + ",");
}
}
sql.append(") ");
Vector userList = cf.doQuery(conn,sql.toString(),null,list.toArray());
if(userList!=null && userList.size()>0){
for(int i=0;i<userList.size();i++) {
Hashtable ht1 = (Hashtable) userList.get(i);
String user_name = (String) ht1.get("user_name");
user_names=user_names+user_name+",";
}
}else{
System.out.println("方法查询出错"+cf.getMsg());
}
return startIndex+"_"+user_names;
}
public static List<String> getDays(String startTime, String endTime) {
// 返回的日期集合
List<String> days = new ArrayList<String>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
Date start = dateFormat.parse(startTime);
Date end = dateFormat.parse(endTime);
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
tempEnd.add(Calendar.DATE, +1);// 日期加1(包含结束)
while (tempStart.before(tempEnd)) {
days.add(dateFormat.format(tempStart.getTime()));
tempStart.add(Calendar.DAY_OF_YEAR, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
return days;
}
public static int getUserOrder(ConnectionFactory cf,Connection conn,String username) {
int order_num =1;
if(username.indexOf(",")>0){
username=username.substring(username.lastIndexOf(",")+1,username.length());
}
Vector userList = cf.doQuery(conn,"select order_num from zb_user where user_name=?",null,new Object[]{username});
if(userList!=null && userList.size()>0){
for(int i=0;i<userList.size();i++) {
Hashtable ht1 = (Hashtable) userList.get(i);
order_num = Integer.parseInt((String) ht1.get("order_num"));
}
}
return order_num;
}
%>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
Connection conn = null;
String action = pub.trimNull(request.getParameter("action"));
String action_msg="";
String mx_id = pub.trimNull(request.getParameter("mx_id"));
String b_time = pub.trimNull(request.getParameter("b_time"));
String e_time = pub.trimNull(request.getParameter("e_time"));
String mx_day = mx_id.substring(mx_id.indexOf("_")+1,mx_id.length());
String mxId=mx_id.substring(0,mx_id.indexOf("_"));;
int mxDay=1;
if(!"".equals(mx_day)){
mxDay=Integer.parseInt(mx_day);
}
String userNames="";
List<String> list= getDays(b_time,e_time);
int selectDay=list.size();
String add_user = pub.trimNull((String) session.getAttribute("session_login_id"));
if ("".equals(add_user)) {
System.out.println("当前没有用户信息");
}
String add_time = pub.getCurrentServerTime();
StringBuffer sql_add=new StringBuffer("insert into zb_zdpb (b_time,e_time,mx_id,add_time,add_user) values (?,?,?,?,?)");
try {
conn = com.censoft.db.DBUtil.getConnection();
List list_add= new ArrayList();
list_add.add(b_time);
list_add.add(e_time);
list_add.add(mx_id);
list_add.add(add_time);
list_add.add(add_user);
conn.setAutoCommit(false);
boolean is_oper = false;
if("add".equals(action)){
action_msg="新增";
is_oper = cf.executeUpdate(conn, sql_add.toString(),list_add.toArray());
if (!is_oper) {
conn.rollback();
System.out.println("新增zb_zdpb表出错了" + cf.getMsg());
return;
}
int startIndex=0;
int index=0;
int count=1;
StringBuffer sql1=new StringBuffer("insert into zb_user_gl (year,zb_type,zb_user,order_num,add_user,add_time) values (?,?,?,?,?,?)");
Vector zb_type_list = cf.doQuery(conn,"select * from zb_type where mx_id=? order by order_num asc",null,new Object[]{mxId});
if(selectDay/mxDay>0){
for(int a=0;a<selectDay/mxDay;a++){
if(zb_type_list!=null && zb_type_list.size()>0) {
for (int i = 0; i < zb_type_list.size(); i++) {
Hashtable ht = (Hashtable) zb_type_list.get(i);
String ren_num = pub.trimNull((String) ht.get("ren_num"));
String zb_type = pub.trimNull((String) ht.get("zb_type"));
for(int n=0;n<mxDay;n++){
index=a*mxDay+n;
if(n==mxDay){
index=0;
}
userNames=getUserNames(cf,conn,startIndex,Integer.parseInt(ren_num));
if(!"".equals(userNames)){
startIndex = Integer.parseInt(userNames.substring(0,userNames.indexOf("_")));
userNames = userNames.substring(userNames.indexOf("_")+1,userNames.length()-1);
}
is_oper = cf.executeUpdate(conn, sql1.toString()
, new Object[]{list.get(index),zb_type, userNames,index+1,add_user,add_time});
if (!is_oper) {
System.out.println("新增zb_user_gl表出错了" + cf.getMsg());
conn.rollback();
return;
}
}
count++;
}
}
}
}
if(selectDay%mxDay>0) {
for (int i = 0; i < zb_type_list.size(); i++) {
Hashtable ht = (Hashtable) zb_type_list.get(i);
String ren_num = pub.trimNull((String) ht.get("ren_num"));
String zb_type = pub.trimNull((String) ht.get("zb_type"));
index=selectDay-(selectDay%mxDay);
for(int n=0;n<selectDay%mxDay;n++){
userNames=getUserNames(cf,conn,startIndex,Integer.parseInt(ren_num));
if(!"".equals(userNames)){
startIndex = Integer.parseInt(userNames.substring(0,userNames.indexOf("_")));
userNames = userNames.substring(userNames.indexOf("_")+1,userNames.length()-1);
}
is_oper = cf.executeUpdate(conn, sql1.toString()
, new Object[]{list.get(index),zb_type, userNames,index+1,add_user,add_time});
if (!is_oper) {
System.out.println("新增zb_user_gl表出错了" + cf.getMsg());
conn.rollback();
return;
}
index++;
}
}
}
}
if (!is_oper) {
conn.rollback();
System.out.println("操作出错了" + cf.getMsg());
return;
}
Logger.log(conn, "值班管理",action_msg, add_user, "", request);
conn.commit();
if (!is_oper) {
conn.rollback();
out.println(cf.getMsg());
} else {
out.println("success,"+mx_id);
}
} catch (Exception e) {
conn.rollback();
System.out.println("有异常" + e);
return;
} finally {
if (conn != null) {
conn.setAutoCommit(true);
try {
conn.close();
} catch (Exception e) {
}
}
}
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.db.Logger" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.ParseException" %>
<%!
public static String getUserNames(ConnectionFactory cf,Connection conn,int startIndex,int n){
Vector userListSize = cf.doQuery(conn,"select id from zb_user",null,new Object[]{});
StringBuffer sql=new StringBuffer("select user_name from zb_user where 1=1 and order_num in(");
List list= new ArrayList();
String user_names="";
int startIndex_2=startIndex;
for(int i=0;i<n;i++){
startIndex=startIndex+1;
if(startIndex==userListSize.size()+1){
startIndex=1;
}
if(i==n-1){
sql.append(startIndex );
}else{
sql.append(startIndex + ",");
}
}
sql.append(") order by field (order_num,");
for(int i=0;i<n;i++){
startIndex_2=startIndex_2+1;
if(startIndex_2==userListSize.size()+1){
startIndex_2=1;
}
if(i==n-1){
sql.append(startIndex_2 );
}else{
sql.append(startIndex_2 + ",");
}
}
sql.append(") ");
Vector userList = cf.doQuery(conn,sql.toString(),null,list.toArray());
if(userList!=null && userList.size()>0){
for(int i=0;i<userList.size();i++) {
Hashtable ht1 = (Hashtable) userList.get(i);
String user_name = (String) ht1.get("user_name");
user_names=user_names+user_name+",";
}
}else{
System.out.println("方法查询出错"+cf.getMsg());
}
return startIndex+"_"+user_names;
}
public static List<String> getDays(String startTime, String endTime) {
// 返回的日期集合
List<String> days = new ArrayList<String>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
Date start = dateFormat.parse(startTime);
Date end = dateFormat.parse(endTime);
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
tempEnd.add(Calendar.DATE, +1);// 日期加1(包含结束)
while (tempStart.before(tempEnd)) {
days.add(dateFormat.format(tempStart.getTime()));
tempStart.add(Calendar.DAY_OF_YEAR, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
return days;
}
public static int getUserOrder(ConnectionFactory cf,Connection conn,String username) {
int order_num =1;
if(username.indexOf(",")>0){
username=username.substring(username.lastIndexOf(",")+1,username.length());
}
Vector userList = cf.doQuery(conn,"select order_num from zb_user where user_name=?",null,new Object[]{username});
if(userList!=null && userList.size()>0){
for(int i=0;i<userList.size();i++) {
Hashtable ht1 = (Hashtable) userList.get(i);
order_num = Integer.parseInt((String) ht1.get("order_num"));
}
}
return order_num;
}
%>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
Connection conn = null;
String action = pub.trimNull(request.getParameter("action"));
String action_msg="";
String mx_id = pub.trimNull(request.getParameter("mx_id"));
String b_time = pub.trimNull(request.getParameter("b_time"));
String e_time = pub.trimNull(request.getParameter("e_time"));
String mx_day = mx_id.substring(mx_id.indexOf("_")+1,mx_id.length());
String mxId=mx_id.substring(0,mx_id.indexOf("_"));;
int mxDay=1;
if(!"".equals(mx_day)){
mxDay=Integer.parseInt(mx_day);
}
String userNames="";
List<String> list= getDays(b_time,e_time);
int selectDay=list.size();
String add_user = pub.trimNull((String) session.getAttribute("session_login_id"));
if ("".equals(add_user)) {
System.out.println("当前没有用户信息");
}
String add_time = pub.getCurrentServerTime();
StringBuffer sql_add=new StringBuffer("insert into zb_zdpb (b_time,e_time,mx_id,add_time,add_user) values (?,?,?,?,?)");
try {
conn = com.censoft.db.DBUtil.getConnection();
List list_add= new ArrayList();
list_add.add(b_time);
list_add.add(e_time);
list_add.add(mx_id);
list_add.add(add_time);
list_add.add(add_user);
conn.setAutoCommit(false);
boolean is_oper = false;
if("add".equals(action)){
action_msg="新增";
is_oper = cf.executeUpdate(conn, sql_add.toString(),list_add.toArray());
if (!is_oper) {
conn.rollback();
System.out.println("新增zb_zdpb表出错了" + cf.getMsg());
return;
}
if(mxDay==selectDay){
StringBuffer sql1=new StringBuffer("insert into zb_user_gl (year,zb_type,zb_user,order_num,add_user,add_time) values (?,?,?,?,?,?)");
StringBuffer sql2=new StringBuffer("select t1.user_name,t2.zb_type from zb_mx_day t1 join zb_type t2 on t1.zb_type=t2.id" +
" where t1.mx_id=? order by t1.id asc");
Vector mxList=cf.doQuery(conn,sql2.toString(),null,new Object[]{mxId});
if(mxList!=null && mxList.size()>0){
int n=0;
for(int i=0;i<mxList.size();i++) {
if(i%selectDay==0){
n=0;
}
Hashtable ht = (Hashtable) mxList.get(i);
String user_name = pub.trimNull((String) ht.get("user_name"));
String zb_type = pub.trimNull((String) ht.get("zb_type"));
System.out.println(n);
is_oper = cf.executeUpdate(conn, sql1.toString(),new Object[]{list.get(n),zb_type,user_name,i+1,add_user,add_time});
if (!is_oper) {
conn.rollback();
System.out.println("插入zb_user_gl表操作出错了" + cf.getMsg());
return;
}
n++;
}
}
}else if(selectDay>mxDay){
int startIndex=0;
int renNum=0;
int index=0;
StringBuffer sql1=new StringBuffer("insert into zb_user_gl (year,zb_type,zb_user,order_num,add_user,add_time) values (?,?,?,?,?,?)");
StringBuffer sql2=new StringBuffer("select t1.user_name,t2.zb_type,t2.ren_num from zb_mx_day t1 join zb_type t2 on t1.zb_type=t2.id" +
" where t1.mx_id=? order by t1.id asc");
Vector mxList=cf.doQuery(conn,sql2.toString(),null,new Object[]{mxId});
if(mxList!=null && mxList.size()>0){
for(int i=0;i<mxList.size();i++) {
Hashtable ht = (Hashtable) mxList.get(i);
String user_name = pub.trimNull((String) ht.get("user_name"));
if(i==mxDay-1){
startIndex=getUserOrder(cf,conn,user_name);
}
String zb_type = pub.trimNull((String) ht.get("zb_type"));
is_oper = cf.executeUpdate(conn, sql1.toString(),new Object[]{list.get(index),zb_type,user_name,i+1,add_user,add_time});
if (!is_oper) {
conn.rollback();
System.out.println("插入zb_user_gl表操作出错了" + cf.getMsg());
return;
}
index++;
}
}
Vector zb_type_list = cf.doQuery(conn,"select * from zb_type where mx_id=? order by order_num asc",null,new Object[]{mxId});
if((selectDay-mxDay)/mxDay>0){
for(int a=0;a<(selectDay-mxDay)/mxDay;a++){
if(zb_type_list!=null && zb_type_list.size()>0) {
for (int i = 0; i < zb_type_list.size(); i++) {
Hashtable ht = (Hashtable) zb_type_list.get(i);
String ren_num = pub.trimNull((String) ht.get("ren_num"));
String zb_type = pub.trimNull((String) ht.get("zb_type"));
for(int n=0;n<mxDay;n++){
userNames=getUserNames(cf,conn,startIndex,Integer.parseInt(ren_num));
if(!"".equals(userNames)){
startIndex = Integer.parseInt(userNames.substring(0,userNames.indexOf("_")));
userNames = userNames.substring(userNames.indexOf("_")+1,userNames.length()-1);
}
is_oper = cf.executeUpdate(conn, sql1.toString()
, new Object[]{list.get(index),zb_type, userNames,index+1,add_user,add_time});
if (!is_oper) {
System.out.println("新增zb_mx_day表出错了" + cf.getMsg());
conn.rollback();
return;
}
}
index++;
}
}
}
}
if(zb_type_list!=null && zb_type_list.size()>0) {
for (int i = 0; i < zb_type_list.size(); i++) {
Hashtable ht = (Hashtable) zb_type_list.get(i);
String ren_num = pub.trimNull((String) ht.get("ren_num"));
String zb_type = pub.trimNull((String) ht.get("zb_type"));
for(int n=0;n<selectDay%mxDay;n++){
userNames=getUserNames(cf,conn,startIndex,Integer.parseInt(ren_num));
if(!"".equals(userNames)){
startIndex = Integer.parseInt(userNames.substring(0,userNames.indexOf("_")));
userNames = userNames.substring(userNames.indexOf("_")+1,userNames.length()-1);
}
is_oper = cf.executeUpdate(conn, sql1.toString()
, new Object[]{list.get(index),zb_type, userNames,index+1,add_user,add_time});
if (!is_oper) {
System.out.println("新增zb_mx_day表出错了" + cf.getMsg());
conn.rollback();
return;
}
}
index++;
}
}
}
}
if (!is_oper) {
conn.rollback();
System.out.println("操作出错了" + cf.getMsg());
return;
}
Logger.log(conn, "值班管理",action_msg, add_user, "", request);
conn.commit();
if (!is_oper) {
conn.rollback();
out.println(cf.getMsg());
} else {
out.println("success,"+mx_id);
}
} catch (Exception e) {
conn.rollback();
System.out.println("有异常" + e);
return;
} finally {
if (conn != null) {
conn.setAutoCommit(true);
try {
conn.close();
} catch (Exception e) {
}
}
}
%>
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2020/9/11
Time: 12:54
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.Hashtable" %>
<%@ page import="java.util.Vector" %>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
Connection conn = null;
Vector v_list = null;
Vector v_type_list = null;
String mx_id = pub.trimNull(request.getParameter("mx_id"));
String action = pub.trimNull(request.getParameter("action"));
Hashtable ht = new Hashtable();
StringBuffer sql = new StringBuffer();
StringBuffer group_sql = new StringBuffer();
int listSize=1;
try {
conn = com.censoft.db.DBUtil.getConnection();
} catch (Exception e) {
out.println("查询用户信息异常" + e);
return;
} finally {
if (conn != null) {
try {
conn.close();
} catch (Exception e) {
}
}
}
%>
<style>
.input-three {
width: 22%
}
.input-two {
width: 32%
}
.col-sm-2{
width:14%;
}
.col-sm-3{
width:19%;
}
.btn-red{ background-color:red;border: red}
.btn-green{ background-color:green;border: green}
</style>
<div class="">
<form class="form form-horizontal" id="form-admin-add">
<input type="hidden" value="add" name="action" id="action">
<div id="content" class="cl pd-5 bk-gray divOverflow" style="overflow:hidden;margin-bottom: 20px;">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>开始时间&nbsp;
</label>
<div class="formControls col-xs-8 col-sm-10">
<input type="text" class="input-text Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="b_time" id="b_time" value="" >
</div>
</div>
<div class="row cl" >
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>结束时间&nbsp;
</label>
<div class="formControls col-xs-8 col-sm-10">
<input type="text" class="input-text Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="e_time" id="e_time" value="" >
</div>
</div>
<div class="row cl" >
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>选择模型&nbsp;
</label>
<div class="formControls col-xs-8 col-sm-10" id="mx_id">
<script>
$.post("./zd_view_list.jsp?name_id=mx_id&math="+Math.random(),function(data){
document.getElementById("mx_id").innerHTML=data;
}
);
</script>
</div>
</div>
</div>
</form>
</div>
<div class="cl mb-10 bk-gray " style="height: 50px;">
<div class="col-sm-3 pd-10" style="width:100%;text-align: center;">
<input class="btn btn-primary radius btn-green" type="button" onclick="javascript:saveForm();" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
</div>
</div>
<script src="<%=request.getContextPath()%>/js/Convert_Pinyin.js"></script>
<script>
function viewDeptOrUserInfo(title, url, w, h) {
location.href=url;
}
function saveForm() {
if($("#b_time").val()==''||$("#e_time").val()==''){
layer.alert("时间不能为空",{icon:5,title:"提示"});
return false;
}
$.ajax({
type: "POST",
url: "./action.jsp",
data: $('#form-admin-add').serialize(),
success: function (msg) {
if (msg.indexOf("success") >= 0) {
layer.msg('操作成功!', {icon: 1, time: 1000},
function () {
//parent.searchModel();
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
} else {
layer.msg('操作失败', {
icon: 5,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
// console.log("********************8")
});
}
}
});
}
function deleteUser(user_id,p_user_id){
layer.confirm('确认要删除吗?', function (index) {
$.ajax({
type: "POST",
url: "./action.jsp?&p_user_id="+p_user_id+"&user_id="+user_id+"&action=delete",
success: function (msg) {
if (msg.indexOf("success") >= 0) {
layer.msg('操作成功!', {icon: 1, time: 1000},
function () {
location.reload();
if(rel_user_id!=''){
window.parent.location.reload();
}
parent.searchModel();
});
} else {
layer.msg('操作失败', {
icon: 5,
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
// console.log("********************8")
});
}
}
});
});
}
</script>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/simple-calendar.css">
<script src="<%=request.getContextPath()%>/js/simple-calendar-es.js"></script>
<style>
#container{
margin: 0 auto;
float: none;
width: 95%;
height: 600px;
}
</style>
<div style="margin-top: 10px;display: none;">
<a class="btn btn-primary radius" onclick="operList();" >
导出
</a>
</div>
<div style="margin-top: 10px;text-align: right;margin-right: 40px;">
<a class="btn btn-primary radius" onclick="zdPb();" >
自动排班
</a>
<a class="btn btn-primary radius" onclick="operList();" >
周排班表
</a>
<a class="btn btn-primary radius" onclick="operList();" >
换班
</a>
</div>
<div id="container"></div>
<form method="post" id="form1" name="form1" action="export_query.jsp" >
<input type="hidden" value="" id="nowDays" name="nowDays">
<input type="hidden" value="" id="nowYear" name="nowYear">
<input type="hidden" value="" id="nowMonth" name="nowMonth">
</form>
<script>
let myCalendar = new SimpleCalendar('#container');
//刷新日历
function addData(year, month) {
var totalDays="";
var now = new Date();//当前日期
var nowDay = now.getDate();// 当天
var nowYear = now.getFullYear();// 年份
var nowMonth = now.getMonth() + 1;// 月份
let daysElement = arrayfrom(this.container.querySelectorAll('.sc-item'));
let day = new Date(year, month - 1, 1);
let week = day.getDay();
if (week == 0) week = 7;
if (week == 7) week = 0;
//计算得到第一个格子的日期
let thispageStart = new Date(Date.parse(day) - (week - 1) * 24 * 3600 * 1000);
//对每一个格子遍历
for (let i = 0; i < 35; i++) {
daysElement[i].className = 'sc-item';
let theday = new Date(Date.parse(thispageStart) + (i-1) * 24 * 3600 * 1000);
let writeyear = theday.getFullYear();
let writeday = theday.getDate();
let writemonth = theday.getMonth() + 1;
if (writemonth != month) {
daysElement[i].classList.add('sc-othermenth');
}
daysElement[i].querySelector('.day').innerHTML = writeday;
daysElement[i].querySelector('.zb_user').innerHTML = '张三</br>李四';
daysElement[i].querySelector('.zb_user_button').innerHTML = '<span onclick="editUser('+writeyear+','+writemonth+','+writeday+');" style="text-align:center;position:absolute; right:0; bottom:0;"><img src="../../images/edit.png" width="20" height="15" /></span>';
//判断是否添加阴历
if (true) {
daysElement[i].querySelector('.lunar-day').innerHTML = (new LunarHelp(writeyear, writemonth, writeday)).getLunarDayName();
} else {
daysElement[i].querySelector('.lunar-day').innerHTML = '';
daysElement[i].classList.add('item-nolunar');
}
//console.log(writeyear+"==="+writemonth+"==="+writeday);
//添加today样式
if (nowYear == writeyear && nowDay == writeday && nowMonth == writemonth) {
this.selectDay = daysElement[i];
daysElement[i].classList.add("sc-today");
}
if (year == writeyear && month == writemonth) {
totalDays+=writeday+",";
}
}
$("#nowYear").val(year);
$("#nowMonth").val(month);
$("#nowDays").val(totalDays.substring(0,totalDays.length-1));
}
function arrayfrom(nidelist) {
let array = [];
[].forEach.call(nidelist, function(v) {
array.push(v);
});
return array;
}
function editUser(year,month,day) {
}
function zdPb() {
var url = './edit-t.jsp';
viewDeptOrUserInfo('自动排班', url, '1000', '500');
}
function viewDeptOrUserInfo(title, url, w, h) {
var abc = layer.open({
title: title,
type: 2,
content: url,
area: [w+'px', h+'px'],
maxmin: true
});
//layer.full(abc);
}
</script>
<%--
Created by IntelliJ IDEA.
User: mc
Date: 2021/1/15
Time: 10:48
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub();
Connection conn = null;
Vector v_list = null;
Vector v_list_1 = null;
String zd_e_name = pub.trimNull(request.getParameter("zd_e_name"));
String value = pub.trimNull(request.getParameter("value"));
value=java.net.URLDecoder.decode(value,"UTF-8");
String name_id = pub.trimNull(request.getParameter("name_id"));
String reg_id = pub.trimNull(request.getParameter("reg_id"));
List list_s = new ArrayList();
Hashtable ht=null;
String first_name="请选择";
String col_name_all="";
try {
StringBuffer sb = new StringBuffer();
sb.append("select * from zb_mx order by add_time desc");
conn = com.censoft.db.DBUtil.getConnection();
v_list = cf.doQuery(conn, sb.toString(),null, list_s.toArray());
if (v_list == null) {
out.println("查询出错" + cf.getMsg());
return;
}
%>
<select class="input-text" name="<%=name_id%>" id="<%=name_id%>_id" >
<option value=""><%=first_name%></option>
<%
if(v_list!=null && v_list.size()>0){
for(int i=0;i<v_list.size();i++){
ht=(Hashtable)v_list.get(i);
String col_name=pub.trimNull((String)ht.get("name"));
String day=pub.trimNull((String)ht.get("day"));
String id=pub.trimNull((String)ht.get("id"));
%>
<option value="<%=id%>_<%=day%>"><%=col_name%></option>
<%
}
}
%>
</select>
<%
} catch (Exception e) {
out.println("查询异常" + e);
return;
} finally {
if (conn != null) {
try {
conn.close();
} catch (Exception e) {
}
}
}
%>
...@@ -4,6 +4,50 @@ ...@@ -4,6 +4,50 @@
<%@ page import="com.censoft.common.db.ConnectionFactory" %> <%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %> <%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.db.Logger" %> <%@ page import="com.censoft.db.Logger" %>
<%!
public static String getUserNames(ConnectionFactory cf,Connection conn,int startIndex,int n){
Vector userListSize = cf.doQuery(conn,"select id from zb_user",null,new Object[]{});
StringBuffer sql=new StringBuffer("select user_name from zb_user where 1=1 and order_num in(");
List list= new ArrayList();
String user_names="";
int startIndex_2=startIndex;
for(int i=0;i<n;i++){
startIndex=startIndex+1;
if(startIndex==userListSize.size()+1){
startIndex=1;
}
if(i==n-1){
sql.append(startIndex );
}else{
sql.append(startIndex + ",");
}
}
sql.append(") order by field (order_num,");
for(int i=0;i<n;i++){
startIndex_2=startIndex_2+1;
if(startIndex_2==userListSize.size()+1){
startIndex_2=1;
}
if(i==n-1){
sql.append(startIndex_2 );
}else{
sql.append(startIndex_2 + ",");
}
}
sql.append(") ");
Vector userList = cf.doQuery(conn,sql.toString(),null,list.toArray());
if(userList!=null && userList.size()>0){
for(int i=0;i<userList.size();i++) {
Hashtable ht1 = (Hashtable) userList.get(i);
String user_name = (String) ht1.get("user_name");
user_names=user_names+user_name+",";
}
}else{
System.out.println("方法查询出错"+cf.getMsg());
}
return startIndex+"_"+user_names;
}
%>
<% <%
ConnectionFactory cf = new ConnectionFactory(); ConnectionFactory cf = new ConnectionFactory();
Pub pub = new Pub(); Pub pub = new Pub();
...@@ -41,6 +85,7 @@ ...@@ -41,6 +85,7 @@
if ("".equals(add_user)) { if ("".equals(add_user)) {
System.out.println("当前没有用户信息"); System.out.println("当前没有用户信息");
} }
String userNames="";
String add_time = pub.getCurrentServerTime(); String add_time = pub.getCurrentServerTime();
StringBuffer sql_add=new StringBuffer("insert into zb_mx (id,name,day,add_time,add_user) values (?,?,?,?,?)"); StringBuffer sql_add=new StringBuffer("insert into zb_mx (id,name,day,add_time,add_user) values (?,?,?,?,?)");
StringBuffer sql_update=new StringBuffer("update t_user_phone set update_user=?,update_time=?,"); StringBuffer sql_update=new StringBuffer("update t_user_phone set update_user=?,update_time=?,");
...@@ -63,21 +108,29 @@ ...@@ -63,21 +108,29 @@
System.out.println("新增zb_mx表出错了" + cf.getMsg()); System.out.println("新增zb_mx表出错了" + cf.getMsg());
return; return;
} }
int startIndex=0;
for (int i = 0; i < inputSize; i++) { for (int i = 0; i < inputSize; i++) {
String b_time = pub.trimNull(request.getParameter("b_time_"+(i+1))); String b_time = pub.trimNull(request.getParameter("b_time_"+(i+1)));
String e_time = pub.trimNull(request.getParameter("e_time_"+(i+1))); String e_time = pub.trimNull(request.getParameter("e_time_"+(i+1)));
String zb_type = pub.trimNull(request.getParameter("zb_type_"+(i+1))); String zb_type = pub.trimNull(request.getParameter("zb_type_"+(i+1)));
String ren_num = pub.trimNull(request.getParameter("ren_num_"+(i+1)));
String zb_type_id=UUID.randomUUID().toString().trim().replaceAll("-", ""); String zb_type_id=UUID.randomUUID().toString().trim().replaceAll("-", "");
is_oper = cf.executeUpdate(conn, "insert into zb_type(id,mx_id,zb_type,b_time,e_time,add_user,add_time) values (?,?,?,?,?,?,?)" is_oper = cf.executeUpdate(conn, "insert into zb_type(id,mx_id,zb_type,b_time,e_time,ren_num,add_user,add_time) values (?,?,?,?,?,?,?,?)"
, new Object[]{zb_type_id,mx_id,zb_type,b_time,e_time,add_user,add_time}); , new Object[]{zb_type_id,mx_id,zb_type,b_time,e_time,ren_num,add_user,add_time});
if (!is_oper) { if (!is_oper) {
System.out.println("新增zb_type表出错了" + cf.getMsg()); System.out.println("新增zb_type表出错了" + cf.getMsg());
conn.rollback(); conn.rollback();
return; return;
} }
for(int n=0;n<mxDay;n++){ for(int n=0;n<mxDay;n++){
userNames=getUserNames(cf,conn,startIndex,Integer.parseInt(ren_num));
if(!"".equals(userNames)){
startIndex = Integer.parseInt(userNames.substring(0,userNames.indexOf("_")));
userNames = userNames.substring(userNames.indexOf("_")+1,userNames.length()-1);
}
is_oper = cf.executeUpdate(conn, "insert into zb_mx_day(mx_id,zb_type,user_name,day,add_user,add_time) values (?,?,?,?,?,?)" is_oper = cf.executeUpdate(conn, "insert into zb_mx_day(mx_id,zb_type,user_name,day,add_user,add_time) values (?,?,?,?,?,?)"
, new Object[]{mx_id,zb_type_id,"",n+1,add_user,add_time}); , new Object[]{mx_id,zb_type_id,userNames,n+1,add_user,add_time});
if (!is_oper) { if (!is_oper) {
System.out.println("新增zb_mx_day表出错了" + cf.getMsg()); System.out.println("新增zb_mx_day表出错了" + cf.getMsg());
conn.rollback(); conn.rollback();
...@@ -116,28 +169,54 @@ ...@@ -116,28 +169,54 @@
}else{ }else{
action_msg="修改"; action_msg="修改";
String zb_type_ids=""; String zb_type_ids="";
int startIndex=0;
for (int i = 0; i < inputSize; i++) { for (int i = 0; i < inputSize; i++) {
String b_time = pub.trimNull(request.getParameter("b_time_"+(i+1))); String b_time = pub.trimNull(request.getParameter("b_time_"+(i+1)));
String e_time = pub.trimNull(request.getParameter("e_time_"+(i+1))); String e_time = pub.trimNull(request.getParameter("e_time_"+(i+1)));
String zb_type = pub.trimNull(request.getParameter("zb_type_"+(i+1))); String zb_type = pub.trimNull(request.getParameter("zb_type_"+(i+1)));
String zb_type_id=pub.trimNull(request.getParameter("zb_type_id_"+(i+1))); String zb_type_id=pub.trimNull(request.getParameter("zb_type_id_"+(i+1)));
String ren_num = pub.trimNull(request.getParameter("ren_num_"+(i+1)));
if(!"".equals(zb_type_id)){ if(!"".equals(zb_type_id)){
zb_type_ids=zb_type_id+","+zb_type_ids; zb_type_ids=zb_type_id+","+zb_type_ids;
is_oper = cf.executeUpdate(conn, "update zb_type set zb_type=?,b_time=?,e_time=?,update_time=?,update_user=? where id=?" is_oper = cf.executeUpdate(conn, "update zb_type set zb_type=?,b_time=?,e_time=?,ren_num=?,update_time=?,update_user=? where id=?"
, new Object[]{zb_type,b_time,e_time,add_time,add_user,zb_type_id}); , new Object[]{zb_type,b_time,e_time,ren_num,add_time,add_user,zb_type_id});
if (!is_oper) {
System.out.println("修改zb_type表出错了" + cf.getMsg());
conn.rollback();
return;
}
for(int n=0;n<mxDay;n++){
userNames=getUserNames(cf,conn,startIndex,Integer.parseInt(ren_num));
if(!"".equals(userNames)){
startIndex = Integer.parseInt(userNames.substring(0,userNames.indexOf("_")));
userNames = userNames.substring(userNames.indexOf("_")+1,userNames.length()-1);
}
is_oper = cf.executeUpdate(conn, "update zb_mx_day set user_name=?,update_user=?,update_time=? where mx_id=? and zb_type=? and day=?"
, new Object[]{userNames,add_user,add_time,mx_id,zb_type_id,n+1});
if (!is_oper) {
System.out.println("修改b_mx_day表出错了" + cf.getMsg());
conn.rollback();
return;
}
}
}else{ }else{
String new_id=UUID.randomUUID().toString().trim().replaceAll("-", ""); String new_id=UUID.randomUUID().toString().trim().replaceAll("-", "");
is_oper = cf.executeUpdate(conn, "insert into zb_type(id,mx_id,zb_type,b_time,e_time,add_user,add_time) values (?,?,?,?,?,?,?)" is_oper = cf.executeUpdate(conn, "insert into zb_type(id,mx_id,zb_type,b_time,e_time,ren_num,add_user,add_time) values (?,?,?,?,?,?,?,?)"
, new Object[]{new_id,mx_id,zb_type,b_time,e_time,add_user,add_time}); , new Object[]{new_id,mx_id,zb_type,b_time,e_time,ren_num,add_user,add_time});
if (!is_oper) { if (!is_oper) {
System.out.println("修改zb_type表出错了" + cf.getMsg()); System.out.println("修改zb_type表出错了" + cf.getMsg());
conn.rollback(); conn.rollback();
return; return;
} }
for(int n=0;n<mxDay;n++){ for(int n=0;n<mxDay;n++){
userNames=getUserNames(cf,conn,startIndex,Integer.parseInt(ren_num));
if(!"".equals(userNames)){
startIndex = Integer.parseInt(userNames.substring(0,userNames.indexOf("_")));
userNames = userNames.substring(userNames.indexOf("_")+1,userNames.length()-1);
}
is_oper = cf.executeUpdate(conn, "insert into zb_mx_day(mx_id,zb_type,user_name,day,add_user,add_time) values (?,?,?,?,?,?)" is_oper = cf.executeUpdate(conn, "insert into zb_mx_day(mx_id,zb_type,user_name,day,add_user,add_time) values (?,?,?,?,?,?)"
, new Object[]{mx_id,new_id,"",n+1,add_user,add_time}); , new Object[]{mx_id,new_id,userNames,n+1,add_user,add_time});
if (!is_oper) { if (!is_oper) {
System.out.println("新增zb_mx_day表出错了" + cf.getMsg()); System.out.println("新增zb_mx_day表出错了" + cf.getMsg());
conn.rollback(); conn.rollback();
...@@ -151,7 +230,8 @@ ...@@ -151,7 +230,8 @@
return; return;
} }
} }
if(!"".equals(zb_type_ids)){ //修改页面,删除已有行
/*if(!"".equals(zb_type_ids)){
zb_type_ids=zb_type_ids.substring(0,zb_type_ids.length()-1); zb_type_ids=zb_type_ids.substring(0,zb_type_ids.length()-1);
String[] field=zb_type_ids.split(","); String[] field=zb_type_ids.split(",");
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
...@@ -167,14 +247,14 @@ ...@@ -167,14 +247,14 @@
} }
} }
sb.append(" )"); sb.append(" )");
System.out.println(sb.toString()); //System.out.println(sb.toString());
//is_oper = cf.executeUpdate(conn, sb.toString(), new Object[]{}); is_oper = cf.executeUpdate(conn, sb.toString(), new Object[]{});
if (!is_oper) { if (!is_oper) {
conn.rollback(); conn.rollback();
System.out.println("删除多余的时间段出错了" + cf.getMsg()); System.out.println("删除多余的时间段出错了" + cf.getMsg());
return; return;
} }
} }*/
is_oper = cf.executeUpdate(conn, "update zb_mx set name=? where id=?", new Object[]{mx_name,mx_id}); is_oper = cf.executeUpdate(conn, "update zb_mx set name=? where id=?", new Object[]{mx_name,mx_id});
if (!is_oper) { if (!is_oper) {
...@@ -194,7 +274,7 @@ ...@@ -194,7 +274,7 @@
conn.rollback(); conn.rollback();
out.println(cf.getMsg()); out.println(cf.getMsg());
} else { } else {
out.println("success"); out.println("success,"+mx_id);
} }
} catch (Exception e) { } catch (Exception e) {
conn.rollback(); conn.rollback();
......
...@@ -109,17 +109,19 @@ ...@@ -109,17 +109,19 @@
<input type="text" style="width:30%;" autocomplete="off" class="input-text" value="<%=pub.trimNull((String)ht1.get("zb_type"))%>" placeholder="" id = "zb_type_<%=i+1%>" name="zb_type_<%=i+1%>" > <input type="text" style="width:30%;" autocomplete="off" class="input-text" value="<%=pub.trimNull((String)ht1.get("zb_type"))%>" placeholder="" id = "zb_type_<%=i+1%>" name="zb_type_<%=i+1%>" >
</label> </label>
<div class="formControls col-xs-4"> <div class="formControls col-xs-6">
<input type="text" style="width:30%;" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="<%=pub.trimNull((String)ht1.get("b_time"))%>" placeholder="" id = "b_time_<%=i+1%>" name="b_time_<%=i+1%>" > <input type="text" style="width:25%;" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="<%=pub.trimNull((String)ht1.get("b_time"))%>" placeholder="" id = "b_time_<%=i+1%>" name="b_time_<%=i+1%>" >
&nbsp;&nbsp; &nbsp;&nbsp;
<input type="text" style="width:30%;" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="<%=pub.trimNull((String)ht1.get("e_time"))%>" placeholder="" id = "e_time_<%=i+1%>" name="e_time_<%=i+1%>" > <input type="text" style="width:25%;" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="<%=pub.trimNull((String)ht1.get("e_time"))%>" placeholder="" id = "e_time_<%=i+1%>" name="e_time_<%=i+1%>" >
&nbsp;&nbsp;默认人数
<input type="text" style="width:20%;" class="input-text " value="<%=pub.trimNull((String)ht1.get("ren_num"))%>" placeholder="" id = "ren_num_<%=i+1%>" name="ren_num_<%=i+1%>" >
</div> </div>
<% <%
if(i==0){ if(i==0){
%> %>
<a href="javascript:void (0);" onclick="addDiv();" style="font-size: 25px;">+</a> <a href="javascript:void (0);" onclick="addDiv();" style="font-size: 25px;">+</a>
<%}else{%> <%}else{%>
<a href="javascript:void (0);" onclick="deleteDiv('<%=pub.trimNull((String)ht.get("id"))%>');" style="font-size: 25px;">-</a> <a href="javascript:void (0);" onclick="deleteDiv('<%=pub.trimNull((String)ht.get("id"))%>');" style="font-size: 25px;display:none;">-</a>
<%} <%}
%> %>
</div> </div>
...@@ -132,10 +134,12 @@ ...@@ -132,10 +134,12 @@
<input type="text" style="width:30%;" autocomplete="off" class="input-text" value="" placeholder="" id = "zb_type_1" name="zb_type_1" > <input type="text" style="width:30%;" autocomplete="off" class="input-text" value="" placeholder="" id = "zb_type_1" name="zb_type_1" >
</label> </label>
<div class="formControls col-xs-4"> <div class="formControls col-xs-6">
<input type="text" style="width:30%;" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="" placeholder="" id = "b_time_1" name="b_time_1" > <input type="text" style="width:25%;" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="" placeholder="" id = "b_time_1" name="b_time_1" >
&nbsp;&nbsp; &nbsp;&nbsp;
<input type="text" style="width:30%;" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="" placeholder="" id = "e_time_1" name="e_time_1" > <input type="text" style="width:25%;" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'HH-mm'})" value="" placeholder="" id = "e_time_1" name="e_time_1" >
&nbsp;&nbsp;默认人数
<input type="text" style="width:20%;" class="input-text " value="" placeholder="" id = "ren_num_1" name="ren_num_1" >
</div> </div>
<a href="javascript:void (0);" onclick="addDiv();" style="font-size: 25px;">+</a> <a href="javascript:void (0);" onclick="addDiv();" style="font-size: 25px;">+</a>
</div> </div>
...@@ -165,10 +169,12 @@ ...@@ -165,10 +169,12 @@
$("#content").append("<div class=\"zbType row cl\" name=\""+(count+1)+"\" id=\"div_"+(count+1)+"\">\n" + $("#content").append("<div class=\"zbType row cl\" name=\""+(count+1)+"\" id=\"div_"+(count+1)+"\">\n" +
" <label class=\"form-label col-xs-4\" > " + " <label class=\"form-label col-xs-4\" > " +
" <input type=\"text\" style=\"width:30%;\" autocomplete=\"off\" class=\"input-text\" value=\"\" placeholder=\"\" id = \"zb_type_"+(name_count+1)+"\" name=\"zb_type_"+(name_count+1)+"\" > :</label>\n" + " <input type=\"text\" style=\"width:30%;\" autocomplete=\"off\" class=\"input-text\" value=\"\" placeholder=\"\" id = \"zb_type_"+(name_count+1)+"\" name=\"zb_type_"+(name_count+1)+"\" > :</label>\n" +
" <div class=\"formControls col-xs-4\">\n" + " <div class=\"formControls col-xs-6\">\n" +
" <input type=\"text\" style=\"width:30%;\" autocomplete=\"off\" class=\"input-text Wdate\" onclick=\"WdatePicker({dateFmt:'HH-mm'})\" value=\"\" placeholder=\"\" id = \"b_time_"+(name_count+1)+"\" name=\"b_time_"+(name_count+1)+"\" >\n" + " <input type=\"text\" style=\"width:25%;\" autocomplete=\"off\" class=\"input-text Wdate\" onclick=\"WdatePicker({dateFmt:'HH-mm'})\" value=\"\" placeholder=\"\" id = \"b_time_"+(name_count+1)+"\" name=\"b_time_"+(name_count+1)+"\" >\n" +
" &nbsp;至&nbsp;\n" + " &nbsp;至&nbsp;\n" +
" <input type=\"text\" style=\"width:30%;\" autocomplete=\"off\" class=\"input-text Wdate\" onclick=\"WdatePicker({dateFmt:'HH-mm'})\" value=\"\" placeholder=\"\" id = \"e_time_"+(name_count+1)+"\" name=\"e_time_"+(name_count+1)+"\" >\n" + " <input type=\"text\" style=\"width:25%;\" autocomplete=\"off\" class=\"input-text Wdate\" onclick=\"WdatePicker({dateFmt:'HH-mm'})\" value=\"\" placeholder=\"\" id = \"e_time_"+(name_count+1)+"\" name=\"e_time_"+(name_count+1)+"\" >\n" +
" &nbsp;&nbsp;默认人数\n" +
" <input type=\"text\" style=\"width:20%;\" class=\"input-text \" value=\"\" placeholder=\"\" id = \"ren_num_"+(name_count+1)+"\" name=\"ren_num_"+(name_count+1)+"\" >" +
" </div>\n" + " </div>\n" +
" <a href=\"javascript:void (0);\" onclick=\"deleteDiv("+(count+1)+");\" style=\"font-size: 25px;\">-</a>"+ " <a href=\"javascript:void (0);\" onclick=\"deleteDiv("+(count+1)+");\" style=\"font-size: 25px;\">-</a>"+
" </div>"); " </div>");
...@@ -221,9 +227,11 @@ ...@@ -221,9 +227,11 @@
data: $('#form-admin-add').serialize(), data: $('#form-admin-add').serialize(),
success: function (msg) { success: function (msg) {
if (msg.indexOf("success") >= 0) { if (msg.indexOf("success") >= 0) {
var mx_id = msg.substring(msg.indexOf(",")+1,msg.length);
layer.msg('操作成功!', {icon: 1, time: 1000}, layer.msg('操作成功!', {icon: 1, time: 1000},
function () { function () {
//parent.searchModel(); //parent.searchModel();
$("#check_mx_id").val(mx_id);
var index = parent.layer.getFrameIndex(window.name); var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index); parent.layer.close(index);
}); });
......
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2020/9/11
Time: 12:54
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.censoft.common.base.Pub" %> <%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %> <%@ page import="com.censoft.common.db.ConnectionFactory" %>
...@@ -20,14 +14,20 @@ ...@@ -20,14 +14,20 @@
String user_id = pub.trimNull(request.getParameter("user_id")); String user_id = pub.trimNull(request.getParameter("user_id"));
Hashtable ht = new Hashtable(); Hashtable ht = new Hashtable();
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
int order_num=1;
try { try {
conn = com.censoft.db.DBUtil.getConnection(); conn = com.censoft.db.DBUtil.getConnection();
Vector maxOrder = cf.doQuery(conn, "select max(order_num) as order_num from zb_user", null, new Object[]{});
if("update".equals(action)){ if("update".equals(action)){
sql.append("select * from zb_user where id=?"); sql.append("select * from zb_user where id=?");
v_list = cf.doQuery(conn, sql.toString(), null, new Object[]{user_id}); v_list = cf.doQuery(conn, sql.toString(), null, new Object[]{user_id});
} }
if (v_list!=null&&v_list.size() > 0) { if (v_list!=null&&v_list.size() > 0) {
ht = (Hashtable) v_list.get(0); ht = (Hashtable) v_list.get(0);
order_num = Integer.parseInt(pub.trimNull((String)ht.get("order_num")));
}else{
Hashtable ht_order = (Hashtable) maxOrder.get(0);
order_num = Integer.parseInt(pub.trimNull((String)ht_order.get("order_num")))+1;
} }
} catch (Exception e) { } catch (Exception e) {
out.println("查询用户信息异常" + e); out.println("查询用户信息异常" + e);
...@@ -92,6 +92,12 @@ ...@@ -92,6 +92,12 @@
<input type="text" name="pwd" value="<%=pub.trimNull((String)ht.get("pwd"))%>" class="input-text "> <input type="text" name="pwd" value="<%=pub.trimNull((String)ht.get("pwd"))%>" class="input-text ">
</div> </div>
</div> </div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">序号:</label>
<div class="formControls col-xs-8 col-sm-3">
<input type="text" name="order_num" value="<%=order_num%>" class="input-text ">
</div>
</div>
</div> </div>
</form> </form>
</div> </div>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
if ("".equals(page_size)) page_size = "10"; if ("".equals(page_size)) page_size = "10";
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
List list = new ArrayList(); List list = new ArrayList();
sql.append("select * from zb_user order by add_time desc "); sql.append("select * from zb_user order by order_num asc ");
try { try {
conn = com.censoft.db.DBUtil.getConnection(); conn = com.censoft.db.DBUtil.getConnection();
v_list = cf.doPageQueryWithCount(conn, sql.toString(), page_number, page_size, null, list.toArray()); v_list = cf.doPageQueryWithCount(conn, sql.toString(), page_number, page_size, null, list.toArray());
...@@ -64,10 +64,11 @@ ...@@ -64,10 +64,11 @@
String user_name = pub.trimNull((String) ht.get("user_name")); String user_name = pub.trimNull((String) ht.get("user_name"));
String tel = pub.trimNull((String) ht.get("tel")); String tel = pub.trimNull((String) ht.get("tel"));
String gh = pub.trimNull((String) ht.get("gh")); String gh = pub.trimNull((String) ht.get("gh"));
String order_num = pub.trimNull((String) ht.get("order_num"));
String edit_url="./editUser-t.jsp?action=update&user_id="+user_id; String edit_url="./editUser-t.jsp?action=update&user_id="+user_id;
%> %>
<tr <%if(i%2==0){%>id="tr_doub"<%}else{%>id="tr_single"<%}%> class="text-c"> <tr <%if(i%2==0){%>id="tr_doub"<%}else{%>id="tr_single"<%}%> class="text-c">
<td><%=i%> <td><%=order_num%>
</td> </td>
<td><%=user_name%> <td><%=user_name%>
</td> </td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment