|
|
@@ -187,6 +187,32 @@ $(document).ready(function() {
|
|
|
spread.options.showHorizontalScrollbar = false;
|
|
|
SpreadJsObj.initSheet(spread.getActiveSheet(), spreadSetting);
|
|
|
|
|
|
+ function checkSheetData(sheet) {
|
|
|
+ let hint = '';
|
|
|
+ for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
|
|
|
+ const cell = sheet.getCell(iRow, 1);
|
|
|
+ const defaultStype = sheet.getDefaultStyle();
|
|
|
+ if (cell.text().length > 50) {
|
|
|
+ cell.backColor('#f8d7da');
|
|
|
+ hint = '章节名称的长度超出范围,请重新输入';
|
|
|
+ } else {
|
|
|
+ cell.backColor(defaultStype.backColor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hint === '') {
|
|
|
+ $('#hint-6').hide();
|
|
|
+ } else {
|
|
|
+ $('#hint-6').html('<i class="fa fa-smile-o mr-2"></i>' + hint).show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ spread.bind(spreadNS.Events.EditEnding, function (e, info) {
|
|
|
+ checkSheetData(info.sheet);
|
|
|
+ });
|
|
|
+ spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
|
|
|
+ checkSheetData(info.sheet);
|
|
|
+ });
|
|
|
+
|
|
|
function loadChapterProperty() {
|
|
|
SpreadJsObj.loadSheetData(spread.getActiveSheet(), SpreadJsObj.DataType.Data, property.chapter);
|
|
|
}
|
|
|
@@ -203,6 +229,11 @@ $(document).ready(function() {
|
|
|
for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
|
|
|
const col = spreadSetting.cols[iCol];
|
|
|
data[col.field] = sheet.getText(iRow, iCol);
|
|
|
+ if (col.field === 'name') {
|
|
|
+ if (data.name.length > 50) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
result.push(data);
|
|
|
}
|
|
|
@@ -455,17 +486,16 @@ $(document).ready(function() {
|
|
|
$('#cancel-6').click(() => {
|
|
|
chapterObj.loadChapterProperty();
|
|
|
chapterObj.setReadOnly(true);
|
|
|
+ $('#hint-6').hide();
|
|
|
$('#post-6').parent().hide();
|
|
|
$('#edit-6').parent().show();
|
|
|
});
|
|
|
// 提交
|
|
|
$('#post-6').click(() => {
|
|
|
- const prop = {
|
|
|
- chapter: chapterObj.getNewChapterData(),
|
|
|
- };
|
|
|
+ const chapter = chapterObj.getNewChapterData();
|
|
|
+ if (!chapter) { return; }
|
|
|
const tenderId = window.location.pathname.split('/')[2];
|
|
|
- console.log(prop);
|
|
|
- postData('/tender/' + tenderId + '/save', prop, function (data) {
|
|
|
+ postData('/tender/' + tenderId + '/save', { chapter: chapter }, function (data) {
|
|
|
chapterObj.setReadOnly(true);
|
|
|
property.chapter = data.chapter;
|
|
|
$('#post-6').parent().hide();
|