se_bonus.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. 'use strict';
  2. /**
  3. * 奖罚金
  4. *
  5. * @author Mai
  6. * @date 2020/2/12
  7. * @version
  8. */
  9. const isPre = function (data) {
  10. return data && data.sid !== stageId;
  11. };
  12. $(document).ready(() => {
  13. autoFlashHeight();
  14. let datepicker;
  15. const spreadSetting = {
  16. cols: [
  17. {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 235, formatter: '@', readOnly: isPre, },
  18. {title: '类型', colSpan: '1', rowSpan: '1', field: 'b_type', hAlign: 0, width: 40, formatter: '@', readOnly: isPre, },
  19. {title: '金额', colSpan: '1', rowSpan: '1', field: 'tp', hAlign: 2, width: 100, type: 'Number', readOnly: isPre, },
  20. {
  21. title: '时间', colSpan: '1', rowSpan: '1', field: 'real_time', hAlign: 2, width: 150, readOnly: true,
  22. formatter: 'yyyy-MM-dd', cellType: 'activeImageBtn', normalImg: '#ellipsis-icon', indent: 5,
  23. showImage: function (data) {
  24. return data !== undefined && data !== null;
  25. },
  26. },
  27. {title: '编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 150, formatter: '@', readOnly: isPre, },
  28. {title: '发文单位', colSpan: '1', rowSpan: '1', field: 'doc_co', hAlign: 0, width: 150, formatter: '@', readOnly: isPre},
  29. {
  30. title: '依据材料证明', colSpan: '1', rowSpan: '1', field: 'proof_file', hAlign: 1, width: 80, formatter: '@',
  31. readOnly: true, cellType: 'imageBtn', normalImg: '#rela-file-icon', hoverImg: '#rela-file-hover',
  32. getValue: function (data) {
  33. return data.proof_file ? data.proof_file.length : 0;
  34. },
  35. showImage: function (data) {
  36. return data !== undefined && data !== null;
  37. },
  38. },
  39. // {title: '依据材料证明', colSpan: '1', rowSpan: '1', field: 'proof', hAlign: 0, width: 150, formatter: '@', readOnly: isPre},
  40. {
  41. title: '计量期', colSpan: '1', rowSpan: '1', field: 'sorder', hAlign: 1, width: 100, formatter: '@',
  42. getValue: function (data) {
  43. return '第' + data.sorder + '期';
  44. }, readOnly: true,
  45. },
  46. {title: '备注', colSpan: '1', rowSpan: '1', field: 'memo', hAlign: 0, width: 180, formatter: '@', cellType: 'ellipsisAutoTip', readOnly: isPre, }
  47. ],
  48. emptyRows: readOnly ? 0 : 3,
  49. headRows: 1,
  50. headRowHeight: [32],
  51. defaultRowHeight: 21,
  52. headerFont: '12px 微软雅黑',
  53. font: '12px 微软雅黑',
  54. readOnly: readOnly,
  55. localCache: {
  56. key: 'stage-extra-bonus',
  57. colWidth: true,
  58. },
  59. imageClick: function (data, hitinfo) {
  60. if (!data) return;
  61. const setting = hitinfo.sheet.zh_setting;
  62. if (!setting) return;
  63. const col = setting.cols[hitinfo.col];
  64. if (!col) return;
  65. if (col.field === 'proof_file') {
  66. fileObj.canUpload(data);
  67. fileObj.generateFilesHtml(data);
  68. $('#file').modal('show');
  69. }
  70. if (col.field === 'real_time' && !readOnly) {
  71. const pos = SpreadJsObj.getObjPos(hitinfo.sheet.getParent().qo);
  72. if (!datepicker) {
  73. datepicker = $('.datepicker-here').datepicker({
  74. language: 'zh',
  75. dateFormat: 'yyyy-MM-dd',
  76. autoClose: true,
  77. onSelect: function (formattedDate, date, inst) {
  78. if (!inst.visible) return;
  79. const sels = hitinfo.sheet.getSelections();
  80. if (!sels || !sels[0]) return;
  81. const node = SpreadJsObj.getSelectObject(hitinfo.sheet);
  82. const uData = { update: {id: node.id, real_time: date} };
  83. postData(window.location.pathname + '/update', uData, function (result) {
  84. bonusObj.loadUpdateData(result);
  85. SpreadJsObj.reLoadRowData(hitinfo.sheet, sels[0].row);
  86. }, function () {
  87. SpreadJsObj.reLoadRowData(hitinfo.sheet, sels[0].row);
  88. });
  89. }
  90. }).data('datepicker');
  91. }
  92. const value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
  93. if (value) {
  94. datepicker.selectDate(new Date(value));
  95. } else {
  96. datepicker.clear();
  97. }
  98. datepicker.show();
  99. if (hitinfo.cellRect.y + pos.y + 272 > $('.main-panel').height()) {
  100. datepicker.update({
  101. position: 'top left',
  102. })
  103. } else {
  104. datepicker.update({
  105. position: 'bottom left',
  106. })
  107. }
  108. $('#datepickers-container').css('top', hitinfo.cellRect.y + pos.y).css('left', hitinfo.cellRect.x + pos.x);
  109. }
  110. }
  111. };
  112. const bonusSpread = SpreadJsObj.createNewSpread($('#bonus-spread')[0]);
  113. const bonusSheet = bonusSpread.getActiveSheet();
  114. spreadSetting.readOnly = readOnly;
  115. if (thousandth) sjsSettingObj.setTpThousandthFormat(spreadSetting);
  116. SpreadJsObj.initSheet(bonusSheet, spreadSetting);
  117. $.subMenu({
  118. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  119. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  120. key: 'menu.1.0.0',
  121. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  122. callback: function (info) {
  123. if (info.mini) {
  124. $('.panel-title').addClass('fluid');
  125. $('#sub-menu').removeClass('panel-sidebar');
  126. } else {
  127. $('.panel-title').removeClass('fluid');
  128. $('#sub-menu').addClass('panel-sidebar');
  129. }
  130. autoFlashHeight();
  131. bonusSpread.refresh();
  132. }
  133. });
  134. const fileObj = {
  135. generateFilesHtml(data) {
  136. const id = data.id, files = data.proof_file;
  137. let html = [];
  138. if (files !== null && files !== undefined) {
  139. for (const [i, f] of files.entries()) {
  140. html.push('<tr>');
  141. if (f.viewpath) {
  142. html.push(`<td style="width: 200px"><a href="${f.viewpath}" target="_blank">${f.filename}${f.fileext}</a></td>`);
  143. //html.push(`<td style="width: 200px"><a href="download/file?b_id=${id}&index=${i}&view=1" target="_blank">${f.filename}${f.fileext}</a></td>`);
  144. } else {
  145. html.push(`<td style="width: 200px"><a href="download/file?b_id=${id}&index=${i}" title="下载">${f.filename}${f.fileext}</a></td>`);
  146. }
  147. html.push('<td>', f.username, '</td>');
  148. html.push('<td>', f.in_time, '</td>');
  149. html.push('<td>');
  150. // 下载
  151. html.push('<a href="download/file?b_id=' + id + '&index=' + i + '" title="下载"><i class="fa fa-download "></i></a>');
  152. // 删除
  153. if (f.uid === userID && ((!isPre(data) && !stageChecked) || f.renew)) {
  154. html.push('<a class="delete-att text-danger ml-1" href="javascript:void(0);" data-id ="' + id + '"file-index="' + i + '" title="删除"><i class="fa fa-remove "></i></a>');
  155. }
  156. html.push('</td>');
  157. html.push('</tr>');
  158. }
  159. }
  160. $('#file-list').html(html.join(''));
  161. },
  162. uploadFile() {
  163. const files = this.files;
  164. const select = SpreadJsObj.getSelectObject(bonusSheet);
  165. const formData = new FormData();
  166. formData.append('bonus_id', select.id);
  167. for (const file of files) {
  168. if (file === undefined) {
  169. toastr.error('未选择上传文件。');
  170. return false;
  171. }
  172. if (file.size > 30 * 1024 * 1024) {
  173. toastr.error('上传文件大小超过30MB。');
  174. return false;
  175. }
  176. const fileext = '.' + file.name.toLowerCase().split('.').splice(-1)[0];
  177. if (whiteList.indexOf(fileext) === -1) {
  178. toastr.error('仅支持office文档、图片、压缩包格式,请勿上传' + fileext + '格式文件。');
  179. return false;
  180. }
  181. formData.append('size', file.size);
  182. formData.append('file[]', file);
  183. }
  184. postDataWithFile('upload/file', formData, function (data) {
  185. select.proof_file = data;
  186. fileObj.generateFilesHtml(select);
  187. SpreadJsObj.reLoadNodesData(bonusSheet, [select]);
  188. });
  189. $(this).val('');
  190. },
  191. deleteFile() {
  192. const data = {
  193. b_id: $(this).attr('data-id'),
  194. index: parseInt($(this).attr('file-index')),
  195. };
  196. postData('delete/file', data, function (data) {
  197. const select = SpreadJsObj.getSelectObject(bonusSheet);
  198. select.proof_file = data;
  199. fileObj.generateFilesHtml(select);
  200. SpreadJsObj.reLoadNodesData(bonusSheet, [select]);
  201. });
  202. },
  203. canUpload(data) {
  204. // if (data.sid === stageId) {
  205. // $('#upload-file-panel').show();
  206. // } else {
  207. // $('#upload-file-panel').hide();
  208. // }
  209. }
  210. };
  211. class Bonus {
  212. constructor () {
  213. this.data = [];
  214. this.displayData = [];
  215. this._curOnlyKey = 'se_bonus_' + window.location.pathname.split('/')[2];
  216. const cache = getLocalCache(this._curOnlyKey);
  217. this._curOnly = cache && cache === 'true' ? true : false;
  218. }
  219. resortData() {
  220. this.data.sort(function (a, b) {
  221. return a.sorder !== b.sorder ? a.sorder - b.sorder : a.order - b.order;
  222. });
  223. }
  224. refreshDisplay() {
  225. this.displayData.length = 0;
  226. for (const d of this.data) {
  227. if (!this._curOnly || d.sid === stageId) this.displayData.push(d);
  228. }
  229. }
  230. loadDatas(datas) {
  231. this.data = datas;
  232. this.resortData();
  233. this.refreshDisplay();
  234. }
  235. loadUpdateData(updateData) {
  236. if (updateData.add) {
  237. for (const a of updateData.add) {
  238. this.data.push(a);
  239. this.displayData.push(a);
  240. }
  241. }
  242. if (updateData.update) {
  243. for (const u of updateData.update) {
  244. const d = this.data.find(function (x) {
  245. return u.id === x.id;
  246. });
  247. if (d) {
  248. _.assign(d, u);
  249. } else {
  250. this.data.push(d);
  251. this.displayData.push(d);
  252. }
  253. }
  254. }
  255. if (updateData.del) {
  256. _.remove(this.data, function (d) {
  257. return updateData.del.indexOf(d.id) >= 0;
  258. });
  259. _.remove(this.displayData, function (d) {
  260. return updateData.del.indexOf(d.id) >= 0;
  261. });
  262. }
  263. this.resortData();
  264. this.refreshDisplay();
  265. }
  266. getCurStageNewOrder() {
  267. const cur = this.data.filter(function (x) {
  268. return x.sid === stageId;
  269. });
  270. return cur && cur.length > 0 ? cur.length + 1 : 1;
  271. }
  272. checkCurFirst(bonusData) {
  273. const cur = this.data.filter(function (x) {
  274. return x.sid === stageId;
  275. });
  276. return cur.indexOf(bonusData) === 0;
  277. }
  278. checkCurLast(bonusData) {
  279. const cur = this.data.filter(function (x) {
  280. return x.sid === stageId;
  281. });
  282. return cur.indexOf(bonusData) === cur.length - 1;
  283. }
  284. sum () {
  285. const result = [];
  286. const sum = { name: '合计', positive_tp: 0, negative_tp: 0 };
  287. const other = { name: '未分类', positive_tp: 0, negative_tp: 0 };
  288. for (const d of this.displayData) {
  289. if (d.b_type) {
  290. let type = result.find(x => { return d.b_type === x.name; });
  291. if (!type) {
  292. type = { name: d.b_type, positive_tp: 0, negative_tp: 0 };
  293. result.push(type);
  294. }
  295. if (d.tp >= 0) {
  296. type.positive_tp = ZhCalc.add(type.positive_tp, d.tp);
  297. } else {
  298. type.negative_tp = ZhCalc.add(type.negative_tp, d.tp);
  299. }
  300. } else {
  301. other.show = true;
  302. if (d.tp >= 0) {
  303. other.positive_tp = ZhCalc.add(other.positive_tp, d.tp);
  304. } else {
  305. other.negative_tp = ZhCalc.add(other.negative_tp, d.tp);
  306. }
  307. }
  308. if (d.tp >= 0) {
  309. sum.positive_tp = ZhCalc.add(sum.positive_tp, d.tp);
  310. } else {
  311. sum.negative_tp = ZhCalc.add(sum.negative_tp, d.tp);
  312. }
  313. }
  314. if (other.show) result.push(other);
  315. result.push(sum);
  316. result.forEach(x => { x.tp = ZhCalc.add(x.positive_tp, x.negative_tp); });
  317. return result;
  318. }
  319. set curOnly(b) {
  320. this._curOnly = b;
  321. setLocalCache(this._curOnlyKey, this._curOnly);
  322. this.refreshDisplay();
  323. }
  324. get curOnly() {
  325. return this._curOnly;
  326. }
  327. }
  328. const bonusObj = new Bonus();
  329. const refreshSum = function () {
  330. const sum = bonusObj.sum();
  331. const html = [];
  332. for (const s of sum) {
  333. html.push(`<tr><td>${s.name}</td><td class="text-right">${s.positive_tp || ''}</td><td class="text-right">${s.negative_tp || ''}</td><td class="text-right">${s.tp || ''}</td></tr>`);
  334. }
  335. $('#sum').html(html.join(' '));
  336. };
  337. postData(window.location.pathname + '/load', null, function (result) {
  338. bonusObj.loadDatas(result);
  339. SpreadJsObj.loadSheetData(bonusSheet, SpreadJsObj.DataType.Data, bonusObj.displayData);
  340. refreshSum();
  341. $('#cur-only')[0].checked = bonusObj.curOnly;
  342. });
  343. if (!readOnly) {
  344. const bonusOprObj = {
  345. /**
  346. * 删除按钮响应事件
  347. * @param sheet
  348. */
  349. deletePress: function (sheet) {
  350. if (!sheet.zh_setting || readOnly) return;
  351. const sortData = sheet.zh_data;
  352. const datas = [];
  353. const sels = sheet.getSelections();
  354. if (!sels || !sels[0]) return;
  355. const hint = {
  356. name: {type: 'warning', msg: '名称不能为空,如需删除甲供材料请使用右键删除'},
  357. };
  358. for (let iRow = sels[0].row; iRow < sels[0].row + sels[0].rowCount; iRow++) {
  359. let bDel = false;
  360. const node = sortData[iRow];
  361. if (node) {
  362. const data = {id: node.id};
  363. for (let iCol = sels[0].col; iCol < sels[0].col + sels[0].colCount; iCol++) {
  364. const colSetting = sheet.zh_setting.cols[iCol];
  365. if (colSetting.field === 'name') {
  366. toastMessageUniq(hint.name);
  367. return;
  368. }
  369. const style = sheet.getStyle(iRow, iCol);
  370. if (!style.locked) {
  371. const colSetting = sheet.zh_setting.cols[iCol];
  372. data[colSetting.field] = null;
  373. bDel = true;
  374. }
  375. }
  376. if (bDel) {
  377. datas.push(data);
  378. }
  379. }
  380. }
  381. if (datas.length > 0) {
  382. postData(window.location.pathname + '/update', {update: datas}, function (result) {
  383. bonusObj.loadUpdateData(result);
  384. SpreadJsObj.reLoadSheetData(bonusSheet);
  385. refreshSum();
  386. }, function () {
  387. SpreadJsObj.reLoadSheetData(bonusSheet);
  388. });
  389. }
  390. },
  391. delete: function () {
  392. const sheet = bonusSheet;
  393. if (!sheet.zh_setting || readOnly) return;
  394. const sortData = sheet.zh_data;
  395. const datas = [];
  396. const sels = sheet.getSelections();
  397. if (!sels || !sels[0]) return;
  398. const hint = {
  399. isOld: {type: 'warning', msg: '本项为往期数据,不可删除'},
  400. invalidDel: {type: 'warning', msg: '本项不是您新增的,只有原报和新增人可删除'},
  401. };
  402. for (let iRow = sels[0].row, iLen = sels[0].row + sels[0].rowCount; iRow < iLen; iRow++) {
  403. const node = sortData[iRow];
  404. if (node.sid !== stageId) {
  405. toastMessageUniq(hint.isOld);
  406. continue;
  407. } else {
  408. if (node.uid !== userID && stageUserId !== userID) {
  409. toastMessageUniq(hint.invalidDel);
  410. continue;
  411. }
  412. datas.push(node.id);
  413. }
  414. }
  415. if (datas.length > 0) {
  416. postData(window.location.pathname + '/update', {del: datas}, function (result) {
  417. bonusObj.loadUpdateData(result);
  418. SpreadJsObj.reLoadSheetData(sheet);
  419. refreshSum();
  420. }, function () {
  421. SpreadJsObj.reLoadSheetData(sheet);
  422. });
  423. }
  424. },
  425. editEnded: function (e, info) {
  426. if (!info.sheet.zh_setting || !info.sheet.zh_data) return;
  427. const node = info.sheet.zh_data[info.row];
  428. const col = info.sheet.zh_setting.cols[info.col];
  429. const data = {};
  430. if (node) {
  431. data.update = {};
  432. data.update.id = node.id;
  433. const oldValue = node ? node[col.field] : null;
  434. const newValue = trimInvalidChar(info.editingText);
  435. if (oldValue == info.editingText || ((!oldValue || oldValue === '') && (newValue === ''))) {
  436. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  437. return;
  438. }
  439. data.update[col.field] = newValue;
  440. } else {
  441. if (col.field !== 'name') {
  442. toastr.warning('新增奖罚金,请先输入名称');
  443. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  444. return;
  445. }
  446. data.add = {};
  447. data.add.order = bonusObj.getCurStageNewOrder();
  448. data.add.name = trimInvalidChar(info.editingText);
  449. }
  450. postData(window.location.pathname + '/update', data, function (result) {
  451. bonusObj.loadUpdateData(result);
  452. SpreadJsObj.reLoadSheetData(info.sheet);
  453. refreshSum();
  454. }, function () {
  455. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  456. });
  457. },
  458. clipboardPasting(e, info) {
  459. const setting = info.sheet.zh_setting, sortData = info.sheet.zh_data;
  460. info.cancel = true;
  461. if (!setting || !sortData) return;
  462. const pasteData = info.pasteData.html
  463. ? SpreadJsObj.analysisPasteHtml(info.pasteData.html)
  464. : (info.pasteData.text === ''
  465. ? SpreadJsObj.Clipboard.getAnalysisPasteText()
  466. : SpreadJsObj.analysisPasteText(info.pasteData.text));
  467. const hint = {
  468. name: {type: 'warning', msg: '奖罚金名称不可为空,已过滤'},
  469. tp: {type: 'warning', msg: '输入的 金额 非法,已过滤'},
  470. };
  471. const uDatas = [], iDatas = [], maxOrder = bonusObj.getCurStageNewOrder();
  472. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
  473. const curRow = info.cellRange.row + iRow;
  474. const node = sortData[curRow];
  475. let bPaste = false;
  476. const data = {};
  477. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  478. const curCol = info.cellRange.col + iCol;
  479. const colSetting = setting.cols[curCol];
  480. const value = trimInvalidChar(pasteData[iRow][iCol]);
  481. if (colSetting.field === 'name' && (!value || value === '')) {
  482. toastMessageUniq(hint.name);
  483. break;
  484. }
  485. if (colSetting.type === 'Number') {
  486. const num = _.toNumber(value);
  487. if (num) {
  488. data[colSetting.field] = num;
  489. bPaste = true;
  490. }
  491. } else {
  492. data[colSetting.field] = value;
  493. bPaste = true;
  494. }
  495. }
  496. if (bPaste) {
  497. if (node) {
  498. data.id = node.id;
  499. uDatas.push(data);
  500. } else {
  501. data.order = maxOrder + iRow;
  502. iDatas.push(data);
  503. }
  504. }
  505. }
  506. const updateData = {};
  507. if (uDatas.length > 0) updateData.update = uDatas;
  508. if (iDatas.length > 0) updateData.add = iDatas;
  509. if (uDatas.length > 0 || iDatas.length > 0) {
  510. postData(window.location.pathname + '/update', updateData, function (result) {
  511. bonusObj.loadUpdateData(result);
  512. SpreadJsObj.reLoadSheetData(info.sheet);
  513. refreshSum();
  514. });
  515. } else {
  516. SpreadJsObj.reLoadSheetData(info.sheet);
  517. }
  518. },
  519. upMove: function () {
  520. const sheet = bonusSheet;
  521. const sels = sheet.getSelections(), sortData = sheet.zh_data;
  522. const node = sortData[sels[0].row];
  523. const preNode = sortData[sels[0].row - 1];
  524. const data = [
  525. {id: node.id, order: preNode.order},
  526. {id: preNode.id, order: node.order}
  527. ];
  528. postData(window.location.pathname + '/update', {update: data}, function (result) {
  529. bonusObj.loadUpdateData(result);
  530. SpreadJsObj.reLoadRowsData(sheet, [sels[0].row, sels[0].row - 1]);
  531. sheet.setSelection(sels[0].row - 1, sels[0].col, sels[0].rowCount, sels[0].colCount);
  532. });
  533. },
  534. downMove: function () {
  535. const sheet = bonusSheet;
  536. const sels = sheet.getSelections(), sortData = sheet.zh_data;
  537. const node = sortData[sels[0].row];
  538. const nextNode = sortData[sels[0].row + 1];
  539. const data = [
  540. {id: node.id, order: nextNode.order},
  541. {id: nextNode.id, order: node.order}
  542. ];
  543. postData(window.location.pathname + '/update', {update: data}, function (result) {
  544. bonusObj.loadUpdateData(result);
  545. SpreadJsObj.reLoadRowsData(sheet, [sels[0].row, sels[0].row + 1]);
  546. sheet.setSelection(sels[0].row + 1, sels[0].col, sels[0].rowCount, sels[0].colCount);
  547. });
  548. }
  549. };
  550. bonusSheet.bind(spreadNS.Events.EditEnded, bonusOprObj.editEnded);
  551. bonusSheet.bind(spreadNS.Events.ClipboardPasting, bonusOprObj.clipboardPasting);
  552. SpreadJsObj.addDeleteBind(bonusSpread, bonusOprObj.deletePress);
  553. $.contextMenu({
  554. selector: '#bonus-spread',
  555. build: function ($trigger, e) {
  556. const target = SpreadJsObj.safeRightClickSelection($trigger, e, bonusSpread);
  557. return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
  558. },
  559. items: {
  560. del: {
  561. name: '删除',
  562. icon: 'fa-remove',
  563. callback: function (key, opt) {
  564. bonusOprObj.delete();
  565. },
  566. disabled: function (key, opt) {
  567. const sels = bonusSheet.getSelections();
  568. if (!sels || !sels[0]) return true;
  569. const row = sels[0].row;
  570. const node = bonusObj.data[row];
  571. return node === undefined || node === null || node.sid !== stageId;
  572. },
  573. visible: function (key, opt) {
  574. return !readOnly;
  575. }
  576. },
  577. sprDel: '------------',
  578. upMove: {
  579. name: '上移',
  580. icon: 'fa-arrow-up',
  581. callback: function (key, opt) {
  582. bonusOprObj.upMove();
  583. },
  584. disabled: function (key, opt) {
  585. const sels = bonusSheet.getSelections();
  586. if (!sels || !sels[0] || sels[0].row === 0) return true;
  587. const row = sels[0].row;
  588. const node = bonusObj.data[row];
  589. return node === undefined || node === null || node.sid !== stageId || bonusObj.checkCurFirst(node);
  590. },
  591. visible: function (key, opt) {
  592. return !readOnly;
  593. }
  594. },
  595. downMove: {
  596. name: '下移',
  597. icon: 'fa-arrow-down',
  598. callback: function (key, opt) {
  599. bonusOprObj.downMove();
  600. },
  601. disabled: function (key, opt) {
  602. const sels = bonusSheet.getSelections();
  603. if (!sels || !sels[0] || sels[0].row >= bonusObj.data.length - 1) return true;
  604. const row = sels[0].row;
  605. const node = bonusObj.data[row];
  606. return node === undefined || node === null || node.sid !== stageId || bonusObj.checkCurLast(node);
  607. },
  608. visible: function (key, opt) {
  609. return !readOnly;
  610. }
  611. }
  612. },
  613. });
  614. }
  615. $('#exportExcel').click(function () {
  616. SpreadExcelObj.exportSimpleXlsxSheet(spreadSetting, bonusObj.data, $('.sidebar-title').attr('data-original-title') + "-奖罚金.xlsx");
  617. });
  618. $('#upload-file').change(fileObj.uploadFile);
  619. $('body').on('click', '.delete-att', fileObj.deleteFile);
  620. $('#cur-only').change(function (){
  621. bonusObj.curOnly = this.checked;
  622. SpreadJsObj.reLoadSheetData(bonusSheet, true);
  623. refreshSum();
  624. })
  625. });