material_exponent.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. const is_numeric = (value) => {
  2. if (typeof(value) === 'object') {
  3. return false;
  4. } else {
  5. return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
  6. }
  7. };
  8. function getPasteHint (str, row = '') {
  9. let returnObj = str;
  10. if (row) {
  11. returnObj.msg = '指数清单第' + (row+1) + '行' + str.msg;
  12. }
  13. return returnObj;
  14. }
  15. function resetExTpTable() {
  16. const rate = $('#changeRate').val();
  17. const bqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), 2);
  18. const jzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, bqhs), 2);
  19. $('#tp_set').find('td').eq(3).text(ZhCalc.round(ex_tp, 2));
  20. $('#tp_set').find('td').eq(4).text(ZhCalc.round(ZhCalc.add(ex_pre_tp, ex_tp), 2));
  21. $('#rate_set').find('td').eq(3).text(bqhs !== 0 ? bqhs : '');
  22. $('#rate_set').find('td').eq(4).text(jzbqhs !== 0 ? jzbqhs : '');
  23. $('#ex_expr').html(ex_expr);
  24. $('#ex_expr').attr('title', '本期价差:' + ex_expr);
  25. }
  26. $(document).ready(() => {
  27. autoFlashHeight();
  28. const materialExponentSpread = SpreadJsObj.createNewSpread($('#material-exponent-spread')[0]);
  29. const materialExponentSpreadSetting = {
  30. cols: [
  31. {title: '类型', colSpan: '1', rowSpan: '2', field: 'type', hAlign: 1, width: 60, formatter: '@', readOnly: true,cellType: 'customizeCombo', comboItems: materialType.ex_type, cellTypeKey: 1},
  32. {title: '符号', colSpan: '1', rowSpan: '2', field: 'symbol', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
  33. {title: '符号说明', colSpan: '1', rowSpan: '2', field: 'symbol_desc', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
  34. {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
  35. {title: '加权系数', colSpan: '1', rowSpan: '2', field: 'weight_num', hAlign: 2, width: 120, formatter: '@', readOnly: 'readOnly.isConstant'},
  36. {title: '基本价格指数', colSpan: '1', rowSpan: '2', field: 'basic_price', hAlign: 2, width: 120, readOnly: 'readOnly.isEdit'},
  37. {title: '基准时间', colSpan: '1', rowSpan: '2', field: 'basic_times', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit'},
  38. {title: '现行价格指数', colSpan: '1', rowSpan: '2', field: 'm_price', hAlign: 2, width: 120, type: 'Number', readOnly: 'readOnly.remark'},
  39. {title: '计算值', colSpan: '1', rowSpan: '2', field: 'calc_num', hAlign: 2, width: 80, formatter: '@', readOnly: true},
  40. {title: '备注', colSpan: '1', rowSpan: '2', field: 'remark', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.remark'},
  41. {title: '是否汇总', colSpan: '1', rowSpan: '2', field: 'is_summary', hAlign: 1, width: 60, cellType: 'checkbox', readOnly: 'readOnly.isEdit'},
  42. ],
  43. emptyRows: 0,
  44. headRows: 2,
  45. headRowHeight: [25, 25],
  46. defaultRowHeight: 21,
  47. headerFont: '12px 微软雅黑',
  48. font: '12px 微软雅黑',
  49. readOnly: readOnly,
  50. };
  51. const materialExponentBase = {
  52. isUsed: function (data) {
  53. if (data.type === 2) {
  54. return data.mid === materialID || data.basic_price === null;
  55. } else {
  56. return false;
  57. }
  58. },
  59. isEdit: function (data) {
  60. return data.mid === materialID && data.type === 2;
  61. },
  62. isConstant: function (data) {
  63. return (materialOrder === 1 && data.type === 1) || (data.mid === materialID && data.type === 2);
  64. }
  65. };
  66. const materialExponentCol = {
  67. getValue: {
  68. calc_num : function (data) {
  69. const calc_num = data.basic_price > 0 ? ZhCalc.mul(data.weight_num, ZhCalc.div(data.m_price, data.basic_price)) : 0;
  70. return calc_num > 0 ? ZhCalc.round(calc_num, 3) : 0;
  71. },
  72. },
  73. readOnly: {
  74. isEdit: function (data) {
  75. return !(!readOnly && materialExponentBase.isEdit(data));
  76. },
  77. isUsed: function (data) {
  78. return !(!readOnly && materialExponentBase.isUsed(data));
  79. },
  80. remark: function (data) {
  81. return !(!readOnly && data.type === 2);
  82. },
  83. isConstant: function (data) {
  84. // return !(!readOnly && materialExponentBase.isConstant(data));
  85. return readOnly;
  86. }
  87. },
  88. };
  89. SpreadJsObj.initSpreadSettingEvents(materialExponentSpreadSetting, materialExponentCol);
  90. SpreadJsObj.initSheet(materialExponentSpread.getActiveSheet(), materialExponentSpreadSetting);
  91. SpreadJsObj.loadSheetData(materialExponentSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialExponentData);
  92. const materialExponentSpreadObj = {
  93. refreshActn: function (rowCount = 1) {
  94. const setObjEnable = function (obj, enable) {
  95. if (enable) {
  96. obj.removeClass('disabled');
  97. } else {
  98. obj.addClass('disabled');
  99. }
  100. };
  101. const sheet = materialExponentSpread.getActiveSheet();
  102. const select = SpreadJsObj.getSelectObject(sheet);
  103. // 还需判断是否已被调差清单调用
  104. setObjEnable($('#del'), !readOnly && select && materialExponentBase.isUsed(select) && rowCount === 1);
  105. },
  106. add: function () {
  107. const sheet = materialExponentSpread.getActiveSheet();
  108. postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
  109. if (result) {
  110. materialExponentData.push(result);
  111. sheet.addRows(materialExponentData.length - 1, 1);
  112. SpreadJsObj.reLoadRowData(sheet, materialExponentData.length - 1);
  113. sheet.setSelection(materialExponentData.length - 1, 0, 1, 1);
  114. materialExponentSpreadObj.refreshActn();
  115. }
  116. });
  117. },
  118. del: function () {
  119. const sheet = materialExponentSpread.getActiveSheet();
  120. const select = SpreadJsObj.getSelectObject(sheet);
  121. postData(window.location.pathname + '/save', {type: 'del', id: select.id}, function (result) {
  122. ex_tp = result.ex_tp;
  123. ex_expr = result.ex_expr;
  124. resetExTpTable();
  125. const index = materialExponentData.indexOf(select);
  126. materialExponentData.splice(index, 1);
  127. sheet.deleteRows(index, 1);
  128. const sel = sheet.getSelections();
  129. sheet.setSelection(index > 0 ? index - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
  130. materialExponentSpreadObj.refreshActn();
  131. });
  132. },
  133. selectionChanged: function (e, info) {
  134. const sel = info.sheet.getSelections()[0];
  135. const col = info.sheet.zh_setting.cols[sel.col];
  136. materialExponentSpreadObj.refreshActn(sel.rowCount);
  137. const data = SpreadJsObj.getSelectObject(info.sheet);
  138. materialExponentSpreadObj.setReadOnly(true);
  139. },
  140. editEnded: function (e, info) {
  141. if (info.sheet.zh_setting) {
  142. const select = SpreadJsObj.getSelectObject(info.sheet);
  143. const col = info.sheet.zh_setting.cols[info.col];
  144. if (col.field === 'is_summary') {
  145. return;
  146. }
  147. // 未改变值则不提交
  148. const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
  149. const orgValue = select[col.field];
  150. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  151. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  152. return;
  153. }
  154. // 判断部分值是否输入的是数字判断和数据计算
  155. if (col.field === 'basic_price' || col.field === 'm_price') {
  156. if (isNaN(validText)) {
  157. toastr.error('不能输入其它非数字类型字符');
  158. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  159. return;
  160. }
  161. const num = parseFloat(validText);
  162. if (validText !== null && (num < 0 || !/^(\d{1,10}|\d{1,7}\.\d{1,3})?$/.test(num))) {
  163. toastr.error('请输入10位以内有效数字并且小于3位小数的浮点数');
  164. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  165. return;
  166. }
  167. }
  168. if (col.field === 'weight_num') {
  169. if (isNaN(validText)) {
  170. toastr.error('不能输入其它非数字类型字符');
  171. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  172. return;
  173. }
  174. const num = parseFloat(validText);
  175. if (validText !== null && (num < 0 || num >= 1 || !/^\d+(\.\d{1,3})?$/.test(num))) {
  176. toastr.error('请输入0~1范围内并且小于3位小数的浮点数');
  177. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  178. return;
  179. }
  180. const total_weight = ZhCalc.add(ZhCalc.sub(_.sumBy(materialExponentData, 'weight_num'), parseFloat(orgValue)), num);
  181. if (total_weight > 1) {
  182. toastr.error('加权系数总和不能大于1');
  183. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  184. return;
  185. }
  186. }
  187. select[col.field] = validText;
  188. select.calc_num = materialExponentCol.getValue.calc_num(select);
  189. // console.log(select);
  190. // 更新至服务器
  191. postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
  192. ex_tp = result.ex_tp;
  193. ex_expr = result.ex_expr;
  194. resetExTpTable();
  195. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  196. materialExponentData.splice(info.row, 1, select);
  197. }, function () {
  198. select[col.field] = orgValue;
  199. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  200. });
  201. }
  202. },
  203. buttonClicked: function (e, info) {
  204. if (info.sheet.zh_setting) {
  205. const select = SpreadJsObj.getSelectObject(info.sheet);
  206. const col = info.sheet.zh_setting.cols[info.col];
  207. if (col.field === 'weight_num') {
  208. if(materialExponentCol.readOnly.isConstant(select)) {
  209. return;
  210. }
  211. } else {
  212. if(materialExponentCol.readOnly.isEdit(select)) {
  213. return
  214. }
  215. }
  216. if (col.field === 'is_summary') {
  217. if (info.sheet.isEditing()) {
  218. info.sheet.endEdit(true);
  219. }
  220. select.is_summary = info.sheet.getValue(info.row, info.col) ? 1 : 0;
  221. // 更新至服务器
  222. postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
  223. ex_tp = result.ex_tp;
  224. ex_expr = result.ex_expr;
  225. resetExTpTable();
  226. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  227. }, function () {
  228. select.is_summary = info.sheet.getValue(info.row, info.col) ? 0 : 1;
  229. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  230. });
  231. }
  232. }
  233. },
  234. deletePress: function (sheet) {
  235. if (sheet.zh_setting && sheet.zh_data) {
  236. const sel = sheet.getSelections()[0];
  237. if (!sel) return;
  238. const sortData = sheet.zh_data || [];
  239. const data = [];
  240. for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
  241. // let bPaste = true;
  242. const exData = sortData[iRow];
  243. const materialExData = { id: sortData[iRow].id };
  244. for (let iCol = 0; iCol < sel.colCount; iCol++) {
  245. const curCol = sel.col + iCol;
  246. const colSetting = sheet.zh_setting.cols[curCol];
  247. if (!colSetting) continue;
  248. const orgValue = sortData[iRow][colSetting.field];
  249. if(orgValue === null) {
  250. // bPaste = false;
  251. continue;
  252. }
  253. if (exData.type === materialType.ex_type[0].value && colSetting.field !== 'weight_num') {
  254. // bPaste = false;
  255. continue;
  256. }
  257. if (colSetting.field === 'type' || colSetting.field === 'calc_num' || colSetting.field === 'is_summary'){
  258. // bPaste = false;
  259. continue;
  260. }
  261. materialExData[colSetting.field] = null;
  262. sortData[iRow][colSetting.field] = null;
  263. }
  264. if (exData.type !== materialType.ex_type[0].value) materialExData.calc_num = materialExponentCol.getValue.calc_num(sortData[iRow]);
  265. const arr = Object.keys(materialExData);
  266. if (arr.length !== 1) {
  267. data.push(materialExData);
  268. }
  269. }
  270. if (data.length === 0) {
  271. SpreadJsObj.reLoadSheetData(sheet);
  272. return;
  273. }
  274. // console.log(data);
  275. // 更新至服务器
  276. postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
  277. materialExponentData = result.info;
  278. SpreadJsObj.loadSheetData(materialExponentSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialExponentData);
  279. ex_tp = result.ex_tp;
  280. ex_expr = result.ex_expr;
  281. resetExTpTable();
  282. }, function () {
  283. SpreadJsObj.reLoadSheetData(sheet);
  284. return;
  285. });
  286. }
  287. },
  288. clipboardPasted(e, info) {
  289. const hint = {
  290. cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
  291. numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
  292. numberCan: {type: 'error', msg: '请粘贴10位以内有效数字并且小于3位小数的浮点数'},
  293. numberCan2: {type: 'error', msg: '请粘贴0~1范围内并且小于3位小数的浮点数'},
  294. weightNumberCan: {type: 'error', msg: '粘贴的加权系数总和不能大于1'},
  295. };
  296. const range = info.cellRange;
  297. const sortData = info.sheet.zh_data || [];
  298. if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
  299. toastMessageUniq(hint.cellError);
  300. // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
  301. SpreadJsObj.reLoadSheetHeader(materialExponentSpread.getActiveSheet());
  302. SpreadJsObj.reLoadSheetData(materialExponentSpread.getActiveSheet());
  303. return;
  304. }
  305. if (sortData.length > 0 && range.col + range.colCount > 10) {
  306. toastMessageUniq(hint.cellError);
  307. SpreadJsObj.reLoadSheetHeader(materialExponentSpread.getActiveSheet());
  308. SpreadJsObj.reLoadSheetData(materialExponentSpread.getActiveSheet());
  309. return;
  310. }
  311. const data = [];
  312. // const rowData = [];
  313. for (let iRow = 0; iRow < range.rowCount; iRow++) {
  314. let bPaste = true;
  315. const curRow = range.row + iRow;
  316. // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
  317. const materialExData = { id: sortData[curRow].id };
  318. const hintRow = range.rowCount > 1 ? curRow : '';
  319. let sameCol = 0;
  320. for (let iCol = 0; iCol < range.colCount; iCol++) {
  321. const curCol = range.col + iCol;
  322. const colSetting = info.sheet.zh_setting.cols[curCol];
  323. if (!colSetting) continue;
  324. let validText = info.sheet.getText(curRow, curCol);
  325. validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
  326. const orgValue = sortData[curRow][colSetting.field];
  327. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  328. sameCol++;
  329. if (range.colCount === sameCol) {
  330. bPaste = false;
  331. }
  332. continue;
  333. }
  334. if (colSetting.field === 'basic_price' || colSetting.field === 'm_price') {
  335. if (isNaN(validText)) {
  336. toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
  337. bPaste = false;
  338. continue;
  339. }
  340. const num = parseFloat(validText);
  341. if (validText !== null && (num < 0 || !/^(\d{1,10}|\d{1,7}\.\d{1,3})?$/.test(num))) {
  342. toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
  343. bPaste = false;
  344. continue;
  345. }
  346. }
  347. if (colSetting.field === 'weight_num') {
  348. if (isNaN(validText)) {
  349. toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
  350. bPaste = false;
  351. continue;
  352. }
  353. const num = parseFloat(validText);
  354. if (validText !== null && (num < 0 || num >= 1 || !/^\d+(\.\d{1,3})?$/.test(num))) {
  355. toastMessageUniq(getPasteHint(hint.numberCan2, hintRow));
  356. bPaste = false;
  357. continue;
  358. }
  359. const total_weight = ZhCalc.add(ZhCalc.sub(_.sumBy(materialExponentData, 'weight_num'), parseFloat(orgValue)), num);
  360. if (total_weight > 1) {
  361. toastMessageUniq(getPasteHint(hint.weightNumberCan, hintRow));
  362. bPaste = false;
  363. continue;
  364. }
  365. }
  366. materialExData[colSetting.field] = validText;
  367. sortData[curRow][colSetting.field] = validText;
  368. }
  369. if (bPaste) {
  370. materialExData.calc_num = materialExponentCol.getValue.calc_num(sortData[curRow]);
  371. data.push(materialExData);
  372. // rowData.push(curRow);
  373. } else {
  374. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  375. }
  376. }
  377. if (data.length === 0) {
  378. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  379. return;
  380. }
  381. // console.log(data);
  382. // 更新至服务器
  383. postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
  384. materialExponentData = result.info;
  385. SpreadJsObj.loadSheetData(materialExponentSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialExponentData);
  386. ex_tp = result.ex_tp;
  387. ex_expr = result.ex_expr;
  388. resetExTpTable();
  389. }, function () {
  390. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  391. return;
  392. });
  393. },
  394. setReadOnly: function(readOnly) {
  395. // SpreadJsObj.resetFieldReadOnly(materialSpread.getActiveSheet(), 'msg_spread', 'm_spread', 'm_tp', 'pre_tp', readOnly);
  396. }
  397. };
  398. materialExponentSpreadObj.refreshActn();
  399. materialExponentSpread.bind(spreadNS.Events.SelectionChanged, materialExponentSpreadObj.selectionChanged);
  400. materialExponentSpread.bind(spreadNS.Events.ClipboardPasted, materialExponentSpreadObj.clipboardPasted);
  401. SpreadJsObj.addDeleteBind(materialExponentSpread, materialExponentSpreadObj.deletePress);
  402. if (!readOnly) {
  403. $('#add').click(materialExponentSpreadObj.add);
  404. $('#del').click(materialExponentSpreadObj.del);
  405. materialExponentSpread.bind(spreadNS.Events.EditEnded, materialExponentSpreadObj.editEnded);
  406. materialExponentSpread.bind(spreadNS.Events.ButtonClicked, materialExponentSpreadObj.buttonClicked);
  407. // 右键菜单
  408. $.contextMenu({
  409. selector: '#material-exponent-spread',
  410. build: function ($trigger, e) {
  411. const target = SpreadJsObj.safeRightClickSelection($trigger, e, materialExponentSpread);
  412. return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  413. },
  414. items: {
  415. 'create': {
  416. name: '新增',
  417. icon: 'fa-sign-in',
  418. callback: function (key, opt) {
  419. materialExponentSpreadObj.add(materialExponentSpread.getActiveSheet());
  420. },
  421. },
  422. 'delete': {
  423. name: '删除',
  424. icon: 'fa-remove',
  425. callback: function (key, opt) {
  426. materialExponentSpreadObj.del(materialExponentSpread.getActiveSheet());
  427. },
  428. disabled: function (key, opt) {
  429. const sheet = materialExponentSpread.getActiveSheet();
  430. const select = SpreadJsObj.getSelectObject(sheet);
  431. const sel = sheet.getSelections()[0];
  432. materialExponentSpreadObj.refreshActn(sel.rowCount);
  433. if (!readOnly && select && materialExponentBase.isUsed(select) && sel.rowCount === 1) {
  434. return false;
  435. } else {
  436. return true;
  437. }
  438. }
  439. },
  440. }
  441. });
  442. // 调差基数选中
  443. $('.calc_select').on('click', function () {
  444. // 如果是选中则清除其余2个的选中
  445. const code = $(this).val();
  446. for (const calc of ex_calc) {
  447. calc.select = $(this).is(':checked') && code === calc.code ? true : false;
  448. if (!calc.select) {
  449. $('.calc_select[value="'+ calc.code +'"]').prop('checked', false);
  450. }
  451. }
  452. postData(window.location.pathname + '/save', { type:'ex_calc', updateData: ex_calc }, function (result) {
  453. ex_tp = result.ex_tp;
  454. ex_expr = result.ex_expr;
  455. resetExTpTable();
  456. });
  457. });
  458. $('#changeRate').change(function () {
  459. const rate = parseInt($(this).val());
  460. postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
  461. const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), 2);
  462. const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), 2);
  463. const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), 2);
  464. const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), 2);
  465. $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
  466. $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
  467. $('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
  468. $('#rate_set').find('td').eq(4).text(exjzbqhs !== 0 ? exjzbqhs : '');
  469. });
  470. });
  471. }
  472. $.divResizer({
  473. select: '#right-spr',
  474. callback: function () {
  475. materialExponentSpread.refresh();
  476. const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
  477. setLocalCache('material_exponent_' + materialID, width);
  478. }
  479. });
  480. // 展开收起月信息价并浏览器记住本期展开收起
  481. $('a', '.right-nav').bind('click', function () {
  482. //const main = $('#main-view'), tool = $('#tools-view');
  483. const tab = $(this), tabPanel = $(tab.attr('content'));
  484. if (!tab.hasClass('active')) {
  485. $('a', '.side-menu').removeClass('active');
  486. $('.tab-content .tab-select-show').removeClass('active');
  487. tab.addClass('active');
  488. tabPanel.addClass('active');
  489. showSideTools(tab.hasClass('active'));
  490. if (tab.attr('content') === '#base-tab') {
  491. const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
  492. setLocalCache('material_exponent_' + materialID, width);
  493. }
  494. } else {
  495. removeLocalCache('material_exponent_' + materialID);
  496. tab.removeClass('active');
  497. tabPanel.removeClass('active');
  498. showSideTools(tab.hasClass('active'));
  499. }
  500. materialExponentSpread.refresh();
  501. });
  502. // 根据浏览器记录展开收起
  503. if (getLocalCache('material_exponent_' + materialID)) {
  504. const tab = $('.right-nav a[content="#base-tab"]'), tabPanel = $(tab.attr('content'));
  505. $('a', '.side-menu').removeClass('active');
  506. $('.tab-content .tab-select-show').removeClass('active');
  507. tab.addClass('active');
  508. tabPanel.addClass('active');
  509. $('#right-view').width(getLocalCache('material_exponent_' + materialID) + '%');
  510. showSideTools(tab.hasClass('active'));
  511. materialExponentSpread.refresh();
  512. }
  513. });