change_information_set.js 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  1. 'use strict';
  2. /**
  3. * 变更令详细页js
  4. *
  5. * @author EllisRan.
  6. * @date 2018/11/22
  7. * @version
  8. */
  9. // 编号排序,多重判断
  10. function sortByCode(a, b) {
  11. let code1 = a.code.split('-');
  12. let code2 = b.code.split('-');
  13. let code1length = code1.length;
  14. let code2length = code2.length;
  15. for (let i = 0; i < code1length; i ++) {
  16. if (i+1 <= code2length) {
  17. if (code1[i] != code2[i]) {
  18. if (/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
  19. return parseInt(code1[i]) - parseInt(code2[i]);
  20. } else if (!/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
  21. return 1;
  22. } else if (/^\d+$/.test(code1[i]) && !/^\d+$/.test(code2[i])) {
  23. return -1;
  24. } else {
  25. const str1length = code1[i].length;
  26. const str2length = code2[i].length;
  27. for (let j = 0; j < str1length; j++) {
  28. if (j+1 <= str2length) {
  29. if (code1[i].charAt(j) != code2[i].charAt(j)) {
  30. return code1[i].charAt(j).charCodeAt() - code2[i].charAt(j).charCodeAt();
  31. } else if (j+1 == str1length && code1[i].charAt(j) == code2[i].charAt(j)) {
  32. if (str1length == str2length) {
  33. return 0;
  34. } else {
  35. return str1length - str2length;
  36. }
  37. }
  38. } else {
  39. if (j+1 >= str1length) {
  40. return 1;
  41. } else {
  42. return -1;
  43. }
  44. }
  45. }
  46. }
  47. } else if (i+1 == code1length && code1[i] == code2[i]) {
  48. if (code1length == code2length) {
  49. return 0;
  50. } else {
  51. return code1length - code2length;
  52. }
  53. }
  54. } else {
  55. if (i+1 >= code1length) {
  56. return 1;
  57. } else {
  58. return -1;
  59. }
  60. }
  61. }
  62. }
  63. $.event.special.valuechange = {
  64. teardown: function (namespaces) {
  65. $(this).unbind('.valuechange');
  66. },
  67. handler: function (e) {
  68. $.event.special.valuechange.triggerChanged($(this));
  69. },
  70. add: function (obj) {
  71. $(this).on('keyup.valuechange cut.valuechange paste.valuechange input.valuechange', obj.selector, $.event.special.valuechange.handler)
  72. },
  73. triggerChanged: function (element) {
  74. var current = element[0].contentEditable === 'true' ? element.html() : element.val()
  75. , previous = typeof element.data('previous') === 'undefined' ? element[0].defaultValue : element.data('previous');
  76. if (current !== previous) {
  77. element.trigger('valuechange', [element.data('previous')]);
  78. element.data('previous', current);
  79. }
  80. }
  81. };
  82. function getPasteHint (str, row = '') {
  83. let returnObj = str;
  84. if (row) {
  85. returnObj.msg = '清单第' + (row+1) + '行' + str.msg;
  86. }
  87. return returnObj;
  88. }
  89. let searchCodeList = [];
  90. $(document).ready(() => {
  91. const changeSpreadSetting = {
  92. cols: [
  93. {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit2'},
  94. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit2'},
  95. {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
  96. {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: false},
  97. {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit2', cellType: 'unit', comboItems: changeUnits, comboEdit: true},
  98. {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit2', getValue: 'getValue.unit_price'},
  99. {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.oamount'},
  100. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.oa_tp'},
  101. {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', readOnly: false, getValue: 'getValue.camount'},
  102. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.ca_tp'},
  103. {title: '操作', colSpan: '1', rowSpan: '2', field: 'del_list', hAlign: 1, width: 40, readOnly: true, cellType: 'mouseTouch', getValue: 'getValue.del_list'},
  104. ],
  105. emptyRows: 0,
  106. headRows: 2,
  107. headRowHeight: [25, 25],
  108. defaultRowHeight: 21,
  109. headerFont: '12px 微软雅黑',
  110. font: '12px 微软雅黑',
  111. readOnly: readOnly,
  112. rowHeader:[
  113. {
  114. rowHeaderType: 'circle',
  115. setting: {
  116. size: 5,
  117. indent: 16,
  118. getColor: function (index, data) {
  119. if (!data) return;
  120. if (_.findIndex(changeLedgerList, { id: data.gcl_id }) !== -1 || _.findIndex(changePosList, { id: data.mx_id }) !== -1) {
  121. return '#dc3545';
  122. }
  123. if(data.lid != 0) return;
  124. return '#007bff';
  125. }
  126. },
  127. },
  128. ],
  129. localCache: {
  130. key: 'changes-spread',
  131. colWidth: true,
  132. }
  133. };
  134. const changeCol = {
  135. getValue: {
  136. unit_price: function(data) {
  137. return ZhCalc.round(data.unit_price, unitPriceUnit);
  138. },
  139. oa_tp: function (data) {
  140. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount, findDecimal(data.unit))), totalPriceUnit);
  141. },
  142. ca_tp: function (data) {
  143. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
  144. },
  145. oamount: function (data) {
  146. return ZhCalc.round(data.oamount, findDecimal(data.unit));
  147. },
  148. camount: function (data) {
  149. return ZhCalc.round(data.camount, findDecimal(data.unit));
  150. },
  151. del_list: function (data) {
  152. return !_.find(changeUsedData, { cbid: data.id }) ? '移除' : '';
  153. }
  154. },
  155. readOnly: {
  156. isEdit: function (data) {
  157. return !readOnly && data.lid != 0;
  158. },
  159. isEdit2: function (data) {
  160. return !readOnly && (data.lid != 0 || (data.lid == 0 && _.findIndex(changeUsedData, { cbid: data.id }) !== -1));
  161. },
  162. },
  163. };
  164. const changeSpreadObj = {
  165. makeSjsFooter: function () {
  166. // 增加汇总行并设为锁定禁止编辑状态
  167. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
  168. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
  169. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  170. changeSpreadObj.countSum();
  171. },
  172. countSum: function() {
  173. const rowCount = changeSpreadSheet.getRowCount();
  174. let oSum = 0,
  175. cSum = 0;
  176. for(var i = 0; i < rowCount - 1; i++){
  177. oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
  178. cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
  179. }
  180. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
  181. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : null);
  182. },
  183. add: function () {
  184. postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
  185. if (result) {
  186. changeList.push(result);
  187. changeSpreadSheet.addRows(changeList.length - 1, 1);
  188. SpreadJsObj.reLoadRowData(changeSpreadSheet, changeList.length - 1);
  189. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  190. changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
  191. changeSpreadObj.resetXmjSpread();
  192. }
  193. });
  194. },
  195. batchAdd: function(num) {
  196. postData(window.location.pathname + '/save', {type: 'batchadd', num}, function (result) {
  197. if (result) {
  198. changeList = _.concat(changeList, result);
  199. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  200. changeSpreadObj.makeSjsFooter();
  201. changeSpreadObj.resetXmjSpread();
  202. }
  203. });
  204. },
  205. del: function () {
  206. const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  207. const index = changeList.indexOf(select);
  208. if (index > -1 && !_.find(changeUsedData, { cbid: select.id })) {
  209. postData(window.location.pathname + '/save', {type: 'del', id: select.id}, function (result) {
  210. changeList.splice(index, 1);
  211. changeSpreadSheet.deleteRows(index, 1);
  212. const sel = changeSpreadSheet.getSelections();
  213. changeSpreadSheet.setSelection(0, 0, 1, 1);
  214. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  215. if (select.lid != 0) {
  216. tableDataRemake(changeListData);
  217. }
  218. changeSpreadObj.countSum();
  219. });
  220. }
  221. },
  222. resetXmjSpread: function(data = null) {
  223. const xmj = [];
  224. if (data && data.lid != 0 && data.xmj_code !== '' && data.xmj_code !== null) {
  225. const newData = JSON.parse(JSON.stringify(data));
  226. if (newData.bwmx === newData.xmj_jldy) {
  227. newData.bwmx = '';
  228. }
  229. xmj.push(newData);
  230. }
  231. SpreadJsObj.loadSheetData(xmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, xmj);
  232. },
  233. selectionChanged: function (e, info) {
  234. const sel = info.sheet.getSelections()[0];
  235. const col = info.sheet.zh_setting.cols[sel.col];
  236. const data = SpreadJsObj.getSelectObject(info.sheet);
  237. if (col && col.field === 'del_list' && !_.find(changeUsedData, { cbid: data.id })) {
  238. changeSpreadObj.del();
  239. }
  240. changeSpreadObj.resetXmjSpread(data);
  241. },
  242. deletePress: function (sheet) {
  243. return;
  244. },
  245. editEnded: function (e, info) {
  246. if (info.sheet.zh_setting) {
  247. const select = SpreadJsObj.getSelectObject(info.sheet);
  248. const col = info.sheet.zh_setting.cols[info.col];
  249. if (col.field === 'del_list') {
  250. return;
  251. }
  252. // 未改变值则不提交
  253. let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
  254. const orgValue = select[col.field];
  255. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  256. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  257. return;
  258. }
  259. // 判断部分值是否输入的是数字判断和数据计算
  260. if (col.type === 'Number') {
  261. if (isNaN(validText)) {
  262. toastr.error('不能输入其它非数字类型字符');
  263. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  264. return;
  265. }
  266. if (col.field === 'unit_price') {
  267. validText = ZhCalc.round(validText, unitPriceUnit);
  268. } else {
  269. validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  270. }
  271. }
  272. if (col.field === 'unit') {
  273. select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
  274. select.oamount = ZhCalc.round(select.oamount, findDecimal(validText)) || 0;
  275. }
  276. if(col.field === 'camount') {
  277. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  278. const usedInfo = _.find(changeUsedData, { cbid: select.id });
  279. if (usedInfo && usedInfo.used_qty >= 0 && validText < usedInfo.used_qty) {
  280. toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
  281. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  282. return;
  283. } else if (usedInfo && usedInfo.used_qty < 0 && validText > usedInfo.used_qty) {
  284. toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.used_qty);
  285. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  286. return;
  287. }
  288. select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  289. }
  290. select[col.field] = validText;
  291. console.log(select);
  292. delete select.waitingLoading;
  293. // 更新至服务器
  294. postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
  295. changeList.splice(info.row, 1, select);
  296. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  297. changeSpreadObj.countSum();
  298. }, function () {
  299. select[col.field] = orgValue;
  300. if(col.field === 'camount') {
  301. select.spamount = orgValue;
  302. }
  303. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  304. });
  305. }
  306. },
  307. clipboardPasted(e, info) {
  308. const hint = {
  309. cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
  310. numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
  311. };
  312. const range = info.cellRange;
  313. const sortData = info.sheet.zh_data || [];
  314. if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
  315. toastMessageUniq(hint.cellError);
  316. // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
  317. SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
  318. SpreadJsObj.reLoadSheetData(changeSpreadSheet);
  319. changeSpreadObj.makeSjsFooter();
  320. return;
  321. }
  322. if (sortData.length > 0 && range.col + range.colCount > 10) {
  323. toastMessageUniq(hint.cellError);
  324. SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
  325. SpreadJsObj.reLoadSheetData(changeSpreadSheet);
  326. changeSpreadObj.makeSjsFooter();
  327. return;
  328. }
  329. const data = [];
  330. // const rowData = [];
  331. for (let iRow = 0; iRow < range.rowCount; iRow++) {
  332. let bPaste = true;
  333. const curRow = range.row + iRow;
  334. // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
  335. const cLData = { id: sortData[curRow].id };
  336. const hintRow = range.rowCount > 1 ? curRow : '';
  337. let sameCol = 0;
  338. for (let iCol = 0; iCol < range.colCount; iCol++) {
  339. const curCol = range.col + iCol;
  340. const colSetting = info.sheet.zh_setting.cols[curCol];
  341. if (!colSetting) continue;
  342. let validText = info.sheet.getText(curRow, curCol);
  343. validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
  344. const orgValue = sortData[curRow][colSetting.field];
  345. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  346. sameCol++;
  347. if (range.colCount === sameCol) {
  348. bPaste = false;
  349. }
  350. continue;
  351. }
  352. if (colSetting.type === 'Number') {
  353. if (isNaN(validText)) {
  354. toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
  355. bPaste = false;
  356. continue;
  357. }
  358. if (colSetting.field === 'unit_price') {
  359. validText = ZhCalc.round(validText, unitPriceUnit);
  360. } else {
  361. validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
  362. }
  363. if(colSetting.field === 'camount') {
  364. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  365. const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
  366. if (usedInfo && usedInfo.used_qty >= 0 && validText < usedInfo.used_qty) {
  367. toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
  368. bPaste = false;
  369. continue;
  370. } else if (usedInfo && usedInfo.used_qty < 0 && validText > usedInfo.used_qty) {
  371. toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.used_qty);
  372. bPaste = false;
  373. continue;
  374. }
  375. }
  376. }
  377. let unitdecimal = validText;
  378. if (colSetting.field === 'unit') {
  379. //粘贴内容要为下拉列表里所有的单位,不然为空
  380. if (changeUnits.indexOf(validText) === -1) {
  381. unitdecimal = '';
  382. }
  383. cLData.camount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
  384. cLData.oamount = ZhCalc.round(sortData[curRow].oamount, findDecimal(unitdecimal)) || 0;
  385. }
  386. cLData[colSetting.field] = validText;
  387. sortData[curRow][colSetting.field] = validText;
  388. cLData.spamount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
  389. }
  390. if (bPaste) {
  391. data.push(cLData);
  392. // rowData.push(curRow);
  393. } else {
  394. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  395. }
  396. }
  397. if (data.length === 0) {
  398. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  399. return;
  400. }
  401. console.log(data);
  402. // 更新至服务器
  403. postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
  404. changeList = result;
  405. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  406. changeSpreadObj.makeSjsFooter();
  407. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  408. }, function () {
  409. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  410. return;
  411. });
  412. },
  413. valueChanged(e, info) {
  414. // 防止ctrl+z撤销数据
  415. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  416. }
  417. };
  418. const preUrl = window.location.pathname.split('/').slice(0, 4).join('/');
  419. let changeListData;
  420. let gclGatherData;
  421. postData(preUrl + '/defaultBills', {}, function (result) {
  422. gclGatherModel.loadLedgerData(result.bills);
  423. gclGatherModel.loadPosData(result.pos);
  424. gclGatherData = gclGatherModel.gatherGclData();
  425. gclGatherData = _.filter(gclGatherData, function (item) {
  426. return item.leafXmjs && item.leafXmjs.length !== 0;
  427. });
  428. for (const ggd in gclGatherData) {
  429. if (gclGatherData[ggd].leafXmjs && gclGatherData[ggd].leafXmjs.length === 0) {
  430. gclGatherData.splice(ggd, 1);
  431. }
  432. gclGatherData[ggd].code = gclGatherData[ggd].b_code;
  433. let hadcid = 0;
  434. for (const xmj of gclGatherData[ggd].leafXmjs) {
  435. if (_.findIndex(changeLedgerList, { id: xmj.gcl_id }) !== -1 || _.findIndex(changePosList, { id: xmj.mx_id, lid: xmj.gcl_id }) !== -1) {
  436. xmj.cid = 1;
  437. hadcid = 1;
  438. }
  439. }
  440. if (hadcid !== 0) gclGatherData[ggd].cid = 1;
  441. }
  442. // 数组去重
  443. const dealBillList = result.dealBills;
  444. for (const db of gclGatherData) {
  445. const exist_index = dealBillList.findIndex(function (item) {
  446. return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
  447. });
  448. if (exist_index !== -1) {
  449. dealBillList.splice(exist_index, 1);
  450. }
  451. }
  452. changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
  453. console.log(changeListData);
  454. // 先加载台账数据
  455. let listHtml = '';
  456. let list_index = 1;
  457. let gcl_index = 0;
  458. for (const gcl of changeListData) {
  459. const unit = gcl.unit !== undefined && gcl.unit !== null ? gcl.unit : '';
  460. const quantity = gcl.quantity !== 0 && gcl.quantity !== null && gcl.quantity !== undefined ? (unit !== '' ? ZhCalc.round(gcl.quantity, findDecimal(gcl.unit)) : gcl.quantity) : 0;
  461. const unit_price = gcl.unit_price !== null && gcl.unit_price !== undefined ? gcl.unit_price : 0;
  462. let gclhtml = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? ' data-gcl="' + gcl_index + '"' : '';
  463. gcl_index = gclhtml !== '' ? ++gcl_index : gcl_index;
  464. const lid = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? (gcl.leafXmjs.length !== 0 ? gcl.leafXmjs[0].gcl_id : false) : gcl.id;
  465. if (lid) {
  466. listHtml += '<tr data-lid="' + lid + '"' + gclhtml + ' data-index="' + list_index + '" data-bwmx="">' +
  467. '<td class="text-center">' + list_index + (gcl.cid ? '<i class="text-danger" style="font-weight: 900">*</i>' : '') + '</td>' +
  468. '<td>' + gcl.code + '</td>' +
  469. '<td class="text-left">' + gcl.name + '</td>' +
  470. '<td class="text-center">' + unit + '</td>' +
  471. '<td class="text-right">' + (ZhCalc.round(unit_price, unitPriceUnit) ? ZhCalc.round(unit_price, unitPriceUnit) : 0) + '</td>' +
  472. '<td class="text-right">' + quantity + '</td>' +
  473. '</tr>';
  474. list_index++;
  475. }
  476. }
  477. $('#table-list-select').html(listHtml);
  478. tableDataRemake(changeListData);
  479. SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
  480. SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
  481. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  482. // changeSpreadSheet.options.protectionOptions = {
  483. // allowSort: true,
  484. // allowFilter: true
  485. // };
  486. // var option = changeSpreadSheet.options.protectionOptions;
  487. // changeSpreadSheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, 0, -1, changeSpreadSetting.cols.length)));
  488. // // changeSpreadSheet.rowFilter(new GC.Spread.Sheets.Filter.HideRowFilter(new GC.Spread.Sheets.Range(-1, 0, -1, 3)));
  489. // const filter = changeSpreadSheet.rowFilter();
  490. // filter.filterButtonVisible(false);
  491. // filter.filterButtonVisible(0, true);
  492. // filter.filterButtonVisible(2, true);
  493. // filter.filterDialogVisibleInfo({
  494. // sortByValue: true, //SortByValue item is visible.
  495. // sortByColor: false, //SortByColor item is visible.
  496. // filterByColor: false, //FilterByColor item is visible.
  497. // filterByValue: false, //FilterByValue item is visible.
  498. // listFilterArea: false //ListFilterArea item is visible.
  499. // });
  500. // function compareList(obj1, obj2) {
  501. // console.log(obj1, obj2);
  502. // var list = ["", '204-1-b', '合计'];
  503. // var index1 = list.indexOf(obj1), index2 = list.indexOf(obj2);
  504. // if (index1 > index2) {
  505. // return 1;
  506. // } else if (index1 < index2) {
  507. // return -1;
  508. // } else {
  509. // return 0;
  510. // }
  511. // }
  512. // changeSpreadSheet.sortRange(0, 0, changeSpreadSetting.cols.length, 1, true, [{index: 0, ascending: true, compareFunction: compareList}]);
  513. // changeSpreadSheet.bind(GC.Spread.Sheets.Events.RangeSorting, function (e, info) {
  514. // info.compareFunction = compareList;
  515. // });
  516. // filter.sortColumn(0, true);
  517. changeSpreadObj.makeSjsFooter();
  518. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  519. });
  520. if (!readOnly) {
  521. $('#add-white-btn').click(changeSpreadObj.add);
  522. changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
  523. changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
  524. changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
  525. changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
  526. SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
  527. changeSpreadSheet.getCell(-1, 10).foreColor('#dc3545');
  528. let batchInsertObj;
  529. $.contextMenu.types.batchInsert = function (item, opt, root) {
  530. const self = this;
  531. if ($.isFunction(item.icon)) {
  532. item._icon = item.icon.call(this, this, $t, key, item);
  533. } else {
  534. if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
  535. // to enable font awesome
  536. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
  537. } else {
  538. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
  539. }
  540. }
  541. this.addClass(item._icon);
  542. const $obj = $('<div>' + item.name + '<input class="text-right ml-1 mr-1" type="tel" max="100" min="1" value="' + item.value + '" style="width: 30px; height: 18px; padding-right: 4px;">行</div>')
  543. .appendTo(this);
  544. const $input = $obj.find('input');
  545. const event = () => {
  546. if (self.hasClass('context-menu-disabled')) return;
  547. item.batchInsert($input[0], root);
  548. };
  549. $obj.on('click', event).keypress(function (e) {if (e.keyCode === 13) { event(); }});
  550. $input.click((e) => {e.stopPropagation();})
  551. .keyup((e) => {if (e.keyCode === 13) item.batchInsert($input[0], root);})
  552. .on('input', function () {this.value = this.value.replace(/[^\d]/g, '');});
  553. };
  554. // 右键菜单
  555. $.contextMenu({
  556. selector: '#change-spread',
  557. build: function ($trigger, e) {
  558. const target = SpreadJsObj.safeRightClickSelection($trigger, e, changeSpread);
  559. return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  560. },
  561. items: {
  562. 'createList': {
  563. name: '添加台账清单',
  564. icon: 'fa-sign-in',
  565. callback: function (key, opt) {
  566. $('#addlist').modal('show');
  567. },
  568. },
  569. 'createAdd': {
  570. name: '添加空白清单',
  571. icon: 'fa-sign-in',
  572. callback: function (key, opt) {
  573. changeSpreadObj.add(changeSpreadSheet);
  574. },
  575. },
  576. 'batchInsert': {
  577. name: '批量添加空白清单',
  578. type: 'batchInsert',
  579. value: '2',
  580. icon: 'fa-sign-in',
  581. batchInsert: function (obj, root) {
  582. if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
  583. obj.value = obj.max;
  584. toastr.warning('批量添加不可多于' + obj.max);
  585. } else if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
  586. obj.value = obj.min;
  587. toastr.warning('批量添加不可少于' + obj.min);
  588. } else {
  589. // treeOperationObj.addNode(ledgerSpread.getActiveSheet(), parseInt(obj.value));
  590. changeSpreadObj.batchAdd(obj.value);
  591. root.$menu.trigger('contextmenu:hide');
  592. }
  593. },
  594. },
  595. 'delete': {
  596. name: '删除',
  597. icon: 'fa-remove',
  598. callback: function (key, opt) {
  599. changeSpreadObj.del(changeSpreadSheet);
  600. },
  601. disabled: function (key, opt) {
  602. const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  603. const sel = changeSpreadSheet.getSelections()[0];
  604. changeSpreadObj.resetXmjSpread(select);
  605. // console.log(select, sel);
  606. if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1 && !_.find(changeUsedData, { cbid: select.id })) {
  607. return false;
  608. } else {
  609. return true;
  610. }
  611. }
  612. },
  613. }
  614. });
  615. }
  616. // 清单选中和移除
  617. $('body').on('click', '#table-list-select tr', function () {
  618. searchCodeList = [];
  619. $('#table-list-select tr').removeClass('table-warning');
  620. $(this).addClass('table-warning');
  621. const isCheck = $(this).hasClass('table-success') ? true : false;
  622. const data_bwmx = $(this).attr('data-bwmx').split('$#$');
  623. const isDeal = $(this).data('gcl') !== undefined ? true : false;
  624. let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="" mx_id=""><td class="text-center">1</td><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox"></td></tr>';
  625. if (isDeal) {
  626. const lid = $(this).data('lid');
  627. let gcl = _.find(gclGatherData, function (item) {
  628. return item.leafXmjs && item.leafXmjs[0].gcl_id === lid;
  629. });
  630. if (!gcl) {
  631. gcl = gclGatherData[$(this).data('gcl')];
  632. }
  633. codeHtml = '';
  634. for (const [index, leaf] of gcl.leafXmjs.entries()) {
  635. const quantity = leaf.quantity !== undefined && leaf.quantity !== null ? leaf.quantity : 0;
  636. const gcl_id = leaf.gcl_id ? leaf.gcl_id : '';
  637. const mx_id = leaf.mx_id ? leaf.mx_id : '';
  638. const bwmx = leaf.bwmx !== undefined ? leaf.bwmx : (gcl.leafXmjs.length > 1 && gcl.name ? gcl.name : undefined);
  639. const isChecked = data_bwmx.indexOf(
  640. leaf.code + '!_!' + (leaf.jldy ? leaf.jldy : '') + '!_!' +
  641. (leaf.dwgc ? leaf.dwgc : '') + '!_!' + (leaf.fbgc ? leaf.fbgc : '') + '!_!' + (leaf.fxgc ? leaf.fxgc : '')
  642. + '!_!' + (leaf.gcl_id ? leaf.gcl_id : '0') + '!_!' + (leaf.mx_id ? leaf.mx_id : '') + '!_!' +
  643. (bwmx !== undefined ? bwmx : leaf.jldy ? leaf.jldy : '') + '*;*' + quantity) !== -1 && isCheck ?
  644. 'checked' : '';
  645. const existGcl = _.find(changeList, {gcl_id: leaf.gcl_id, bwmx: (bwmx ? bwmx : leaf.jldy ? leaf.jldy : ''), oamount: leaf.quantity});
  646. const isUsed = existGcl ? _.find(changeUsedData, { cbid: existGcl.id }) : null;
  647. const isDisabled = isUsed ? 'disabled ' : '';
  648. codeHtml += '<tr quantity="' + quantity + '" gcl_id="' + gcl_id + '" mx_id="' + mx_id + '">' +
  649. '<td class="text-center">' + (index+1) + (leaf.cid ? '<i class="text-danger" style="font-weight: 900">*</i>' : '') + '</td>' +
  650. '<td>' + leaf.code + '</td>' +
  651. '<td>' + (leaf.jldy ? leaf.jldy: '') + '</td>' +
  652. '<td>' + (leaf.dwgc ? leaf.dwgc : '') + '</td>' +
  653. '<td>' + (leaf.fbgc ? leaf.fbgc : '') + '</td>' +
  654. '<td>' + (leaf.fxgc ? leaf.fxgc : '') + '</td>' +
  655. '<td>' + (bwmx !== undefined ? bwmx : '') + '</td>' +
  656. '<td class="text-right">' + (ZhCalc.round(quantity, findDecimal(gcl.unit)) ? ZhCalc.round(quantity, findDecimal(gcl.unit)) : 0) + '</td>' +
  657. '<td class="text-center"><input type="checkbox" ' + isDisabled + isChecked +
  658. '></td></tr>';
  659. searchCodeList.push(leaf.code + '|!|' + (leaf.jldy ? leaf.jldy: '') + '|!|' + (bwmx !== undefined ? bwmx : ''));
  660. }
  661. } else if (!isDeal && isCheck) {
  662. codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="" mx_id=""><td class="text-center">1</td><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox" checked></td></tr>';
  663. }
  664. $('#code-list').attr('data-index', parseInt($(this).children('td').eq(0).text()));
  665. $('#code-input').val('');
  666. $('#code-input').siblings('a').hide();
  667. $('#code-list').html(codeHtml);
  668. checkSelectAll();
  669. });
  670. // 右边项目节选择
  671. $('body').on('click', '#code-list input', function () {
  672. let index = $('#code-list').attr('data-index');
  673. if ($(this).is(':checked')) {
  674. // 去除其它可能已选的checked
  675. // $('#code-list input').prop('checked', false);
  676. $(this).prop('checked', true);
  677. // 左边表单传值并添加class
  678. $('#table-list-select tr[data-index="' + index + '"]').addClass('table-success');
  679. // 去除部分data-detail值
  680. let data_bwmx = [];
  681. $('#code-list input:checked').each(function () {
  682. const tr = $(this).parents('tr');
  683. const length = tr.children('td').length;
  684. const gcl_id = tr.attr('gcl_id');
  685. const mx_id = tr.attr('mx_id');
  686. const bwmx = length === 9 ?
  687. tr.children('td').eq(1).text() + '!_!' +
  688. tr.children('td').eq(2).text() + '!_!' +
  689. tr.children('td').eq(3).text() + '!_!' +
  690. tr.children('td').eq(4).text() + '!_!' +
  691. tr.children('td').eq(5).text() + '!_!' + gcl_id + '!_!' + mx_id + '!_!' +
  692. (tr.children('td').eq(6).text() !== '' ? tr.children('td').eq(6).text() : tr.children('td').eq(2).text()) : '0';
  693. const quantity = tr.attr('quantity');
  694. const de_qu = bwmx + '*;*' + quantity;
  695. data_bwmx.push(de_qu);
  696. });
  697. data_bwmx = data_bwmx.join('$#$');
  698. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
  699. } else {
  700. // 判断还有无选中项目节编号
  701. if ($('#code-list input').is(':checked')) {
  702. // 去除部分data-detail值
  703. let data_bwmx = [];
  704. $('#code-list input:checked').each(function () {
  705. const tr = $(this).parents('tr');
  706. const length = tr.children('td').length;
  707. const gcl_id = tr.attr('gcl_id');
  708. const mx_id = tr.attr('mx_id');
  709. const bwmx = length === 9 ?
  710. tr.children('td').eq(1).text() + '!_!' +
  711. tr.children('td').eq(2).text() + '!_!' +
  712. tr.children('td').eq(3).text() + '!_!' +
  713. tr.children('td').eq(4).text() + '!_!' +
  714. tr.children('td').eq(5).text() + '!_!' + gcl_id + '!_!' + mx_id + '!_!' +
  715. (tr.children('td').eq(6).text() !== '' ? tr.children('td').eq(6).text() : tr.children('td').eq(2).text()) : '0';
  716. const quantity = tr.attr('quantity');
  717. const de_qu = bwmx + '*;*' + quantity;
  718. data_bwmx.push(de_qu);
  719. });
  720. data_bwmx = data_bwmx.join('$#$');
  721. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
  722. } else {
  723. $('#table-list-select tr[data-index="' + index + '"]').removeClass('table-success');
  724. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', '');
  725. }
  726. }
  727. checkSelectAll();
  728. });
  729. // 添加空白清单or签约清单
  730. $('.add-list-btn').on('click', function () {
  731. const newLedgerList = remakeChangeSpread();
  732. // 更新至服务器
  733. postData(window.location.pathname + '/save', { type:'ledger_list', updateData: newLedgerList }, function (result) {
  734. changeList = result.changeList;
  735. changeUsedData = result.usedList;
  736. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  737. changeSpreadObj.makeSjsFooter();
  738. const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
  739. changeSpreadObj.resetXmjSpread(select);
  740. $('#addlist').modal('hide');
  741. }, function () {
  742. $('#addlist').modal('hide');
  743. });
  744. });
  745. // 选中input所有值
  746. $('body').on('focus', ".clist input", function() {
  747. $(this).select();
  748. });
  749. // 取消选中清单
  750. $('#cancel-list-btn').click(function () {
  751. // $('#table-list-select tr').removeClass('table-success');
  752. // $('#table-list-select tr').attr('data-bwmx', '');
  753. // $('#code-list').html('');
  754. tableDataRemake(changeListData);
  755. });
  756. // 自动编号
  757. $('.reduction-code').click(function () {
  758. const code = $(this).attr('data-code');
  759. $('input[name="code"]').val(code);
  760. });
  761. $('#select-list').change(function () {
  762. const select = parseInt($(this).val());
  763. let showListData = changeListData;
  764. const value = $('#list-input').val();
  765. if (select === 1) {
  766. if (value !== '') {
  767. $('#list-input').siblings('a').show();
  768. showListData = _.filter(changeListData, function (c) {
  769. return ((c.code && c.code.indexOf(value) !== -1) || (c.name && c.name.indexOf(value) !== -1)) && c.cid;
  770. });
  771. } else {
  772. $('#list-input').siblings('a').hide();
  773. showListData = _.filter(changeListData, function (c) {
  774. return c.cid;
  775. });
  776. }
  777. } else {
  778. if (value !== '') {
  779. $('#list-input').siblings('a').show();
  780. showListData = _.filter(changeListData, function (c) {
  781. return (c.code && c.code.indexOf(value) !== -1) || (c.name && c.name.indexOf(value) !== -1);
  782. });
  783. } else {
  784. $('#list-input').siblings('a').hide();
  785. }
  786. }
  787. makeListTable(changeListData, showListData);
  788. $('#table-list-select tr').removeClass('table-warning');
  789. $('#code-input').val('');
  790. $('#code-input').siblings('a').hide();
  791. $('#code-list').html('');
  792. $('#code-select-all').prop('checked', false);
  793. });
  794. // 回车提交
  795. $('#list-input').on('keypress', function () {
  796. if(window.event.keyCode === 13) {
  797. $(this).blur();
  798. }
  799. });
  800. $('#list-input').on('blur', function () {
  801. const select = parseInt($('#select-list').val());
  802. const value = $(this).val();
  803. let showListData = changeListData;
  804. if (select === 1 && value !== '') {
  805. $(this).siblings('a').show();
  806. showListData = _.filter(changeListData, function (c) {
  807. return ((c.code && c.code.indexOf(value) !== -1) || (c.name && c.name.indexOf(value) !== -1)) && c.cid;
  808. });
  809. } else if (select === 1 && value === '') {
  810. $(this).siblings('a').hide();
  811. showListData = _.filter(changeListData, function (c) {
  812. return c.cid;
  813. });
  814. } else if (value !== '') {
  815. $(this).siblings('a').show();
  816. showListData = _.filter(changeListData, function (c) {
  817. return (c.code && c.code.indexOf(value) !== -1) || (c.name && c.name.indexOf(value) !== -1);
  818. });
  819. } else {
  820. $(this).siblings('a').hide();
  821. }
  822. makeListTable(changeListData, showListData);
  823. $('#table-list-select tr').removeClass('table-warning');
  824. $('#code-input').val('');
  825. $('#code-input').siblings('a').hide();
  826. $('#code-list').html('');
  827. $('#code-select-all').prop('checked', false);
  828. });
  829. // 回车提交
  830. $('#code-input').on('keypress', function () {
  831. if(window.event.keyCode === 13) {
  832. $(this).blur();
  833. }
  834. });
  835. $('#code-input').on('blur', function () {
  836. const value = $(this).val();
  837. if (value !== '') {
  838. $(this).siblings('a').show();
  839. } else {
  840. $(this).siblings('a').hide();
  841. }
  842. makeCodeTable($(this).val());
  843. checkSelectAll();
  844. });
  845. $('.remove-btn').on('click', function () {
  846. $(this).hide();
  847. $(this).siblings('input').val('');
  848. if ($(this).data('btn') === 'list') {
  849. const select = parseInt($('#select-list').val());
  850. let showListData = changeListData;
  851. if (select === 1) {
  852. showListData = _.filter(changeListData, function (c) {
  853. return c.cid;
  854. });
  855. }
  856. makeListTable(changeListData, showListData);
  857. $('#table-list-select tr').removeClass('table-warning');
  858. $('#code-list').html('');
  859. } else {
  860. makeCodeTable();
  861. }
  862. checkSelectAll();
  863. });
  864. // 全选及取消
  865. $('#code-select-all').click(function () {
  866. // 全选checkbox
  867. let index = $('#code-list').attr('data-index');
  868. if (index) {
  869. if ($(this).is(':checked')){
  870. $('#code-list tr').each(function () {
  871. if ($(this).css('display') !== 'none') {
  872. $(this).find('input').prop('checked', true);
  873. }
  874. })
  875. } else {
  876. $('#code-list tr').each(function () {
  877. if ($(this).css('display') !== 'none' && $(this).find('input').prop('disabled') !== true) {
  878. $(this).find('input').prop('checked', false);
  879. }
  880. });
  881. }
  882. // 判断还有无选中项目节编号
  883. if ($('#code-list input').is(':checked')) {
  884. // 去除部分data-detail值
  885. let data_bwmx = [];
  886. $('#code-list input:checked').each(function () {
  887. const tr = $(this).parents('tr');
  888. const length = tr.children('td').length;
  889. const gcl_id = tr.attr('gcl_id');
  890. const mx_id = tr.attr('mx_id');
  891. const bwmx = length === 9 ?
  892. tr.children('td').eq(1).text() + '!_!' +
  893. tr.children('td').eq(2).text() + '!_!' +
  894. tr.children('td').eq(3).text() + '!_!' +
  895. tr.children('td').eq(4).text() + '!_!' +
  896. tr.children('td').eq(5).text() + '!_!' + gcl_id + '!_!' + mx_id + '!_!' +
  897. (tr.children('td').eq(6).text() !== '' ? tr.children('td').eq(6).text() : tr.children('td').eq(2).text()) : '0';
  898. const quantity = tr.attr('quantity');
  899. const de_qu = bwmx + '*;*' + quantity;
  900. data_bwmx.push(de_qu);
  901. });
  902. data_bwmx = data_bwmx.join('$#$');
  903. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
  904. $('#table-list-select tr[data-index="' + index + '"]').addClass('table-success');
  905. } else {
  906. $('#table-list-select tr[data-index="' + index + '"]').removeClass('table-success');
  907. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', '');
  908. }
  909. }
  910. });
  911. // 记录变更信息操作
  912. $('body').on('valuechange', '#change_form input[type="text"]', function (e, previous) {
  913. changeInfo[$(this).attr('name')] = $(this).val();
  914. judgeChange();
  915. });
  916. $('body').on('valuechange', '#change_form textarea', function (e, previous) {
  917. changeInfo[$(this).attr('name')] = $(this).val().replace(/[\r\n]/g, '<br><br>');
  918. judgeChange();
  919. });
  920. $('body').on('change', '#change_form select', function (e, previous) {
  921. changeInfo[$(this).attr('name')] = $(this).val();
  922. judgeChange();
  923. });
  924. $('body').on('click', '#change_form input[type="radio"]', function (e, previous) {
  925. changeInfo[$(this).attr('name')] = $(this).val();
  926. judgeChange();
  927. });
  928. $('body').on('click', '#change_form input[type="checkbox"]', function (e, previous) {
  929. const typecheck = [];
  930. $.each($('#change_form input[name="type[]"]:checked'), function () {
  931. typecheck.push($(this).val());
  932. });
  933. changeInfo.type = typecheck.join(',');
  934. judgeChange();
  935. });
  936. // 保存修改ajax提交(不刷新页面)
  937. $('.save_change_btn').on('click', function () {
  938. // 保存修改modal
  939. if ($('input[name="code"]').val() === '') {
  940. toastr.error('申请编号不能为空!');
  941. return;
  942. }
  943. if ($('input[name="name"]').val() === '') {
  944. toastr.error('变更工程名称不能为空!');
  945. return;
  946. }
  947. // 换行更改并提交
  948. changeInfo.content = changeInfo.content.replace(/<br><br>/g, '\r\n');
  949. changeInfo.basis = changeInfo.basis.replace(/<br><br>/g, '\r\n');
  950. changeInfo.expr = changeInfo.expr.replace(/<br><br>/g, '\r\n');
  951. changeInfo.memo = changeInfo.memo.replace(/<br><br>/g, '\r\n');
  952. // 后改为br
  953. // 更新至服务器
  954. postData(window.location.pathname + '/save', { type:'info', updateData: changeInfo }, function (result) {
  955. $('.reduction-code').attr('data-code', $('input[name="code"]').val());
  956. toastr.success(result);
  957. $('#show-save-btn').hide();
  958. $('#sp-btn').show();
  959. $('.title-main').removeClass('bg-warning');
  960. changeInfo.content = changeInfo.content.replace(/[\r\n]/g, '<br>');
  961. changeInfo.basis = changeInfo.basis.replace(/[\r\n]/g, '<br>');
  962. changeInfo.expr = changeInfo.expr.replace(/[\r\n]/g, '<br>');
  963. changeInfo.memo = changeInfo.memo.replace(/[\r\n]/g, '<br>');
  964. back_changeInfo = Object.assign({}, changeInfo);
  965. });
  966. return false;
  967. });
  968. $('#cancel_change').on('click', function () {
  969. $('#show-save-btn').hide();
  970. $('#sp-btn').show();
  971. $('.title-main').removeClass('bg-warning');
  972. if (!isObjEqual(changeInfo, back_changeInfo)) {
  973. changeFormRemake();
  974. }
  975. toastr.success('已还原到上次保存状态');
  976. });
  977. });
  978. function checkSelectAll() {
  979. let check = $('#code-list tr').length > 0 ? true : false;
  980. const codeNum = $('#code-list tr').length;
  981. let i = 0;
  982. $('#code-list tr').each(function () {
  983. if ($(this).css('display') !== 'none' && !$(this).find('input').is(':checked')) {
  984. check = false;
  985. return;
  986. }
  987. else if ($(this).css('display') === 'none') {
  988. i++;
  989. }
  990. });
  991. if (check && i === codeNum) {
  992. check = false;
  993. }
  994. $('#code-select-all').prop('checked', check);
  995. }
  996. function checkChangeFrom() {
  997. let returnFlag = false;
  998. // 表单判断
  999. if ($('input[name="code"]').val() === '') {
  1000. toastr.error('申请编号不能为空!');
  1001. returnFlag = true;
  1002. }
  1003. if ($('input[name="name"]').val() === '') {
  1004. toastr.error('变更工程名称不能为空!');
  1005. returnFlag = true;
  1006. }
  1007. if ($('textarea[name="content"]').val() === '') {
  1008. toastr.error('工程变更理由及内容不能为空!');
  1009. returnFlag = true;
  1010. }
  1011. if (changeList.length === 0) {
  1012. toastr.error('请添加变更清单!');
  1013. returnFlag = true;
  1014. } else {
  1015. for (const [i,cl] of changeList.entries()) {
  1016. if (cl.code === '' || cl.name === '' || cl.oamount === '') {
  1017. toastr.error('变更清单第' + (i+1) + '行未完整填写数据(变更部位、变更详情、单位、单价可空)');
  1018. returnFlag = true;
  1019. }
  1020. }
  1021. }
  1022. if(!checkAuditorFrom ()) {
  1023. returnFlag = true;
  1024. }
  1025. if (returnFlag) {
  1026. return false;
  1027. }
  1028. }
  1029. // 检查上报情况
  1030. function checkAuditorFrom () {
  1031. if ($('#auditList li').length === 0) {
  1032. if(shenpi_status === shenpiConst.sp_status.gdspl) {
  1033. toastr.error('请联系管理员添加审批人');
  1034. } else {
  1035. toastr.error('请先选择审批人,再上报数据');
  1036. }
  1037. return false;
  1038. }
  1039. return true;
  1040. }
  1041. function tableDataRemake(changeListData) {
  1042. $('#table-list-select tr').removeClass('table-warning');
  1043. $('#table-list-select tr').removeClass('table-success');
  1044. $('#table-list-select tr').attr('data-bwmx', '');
  1045. $('#code-list').html('');
  1046. $('#code-list').attr('data-index', '');
  1047. $('#code-input').val('');
  1048. $('#code-select-all').prop('checked', false);
  1049. $('#code-input').siblings('a').hide();
  1050. // 根据已添加的清单显示
  1051. if (changeList.length > 0 && changeList[0]) {
  1052. const removeList = [];
  1053. const updateList = [];
  1054. const updateGclIdList = [];
  1055. for (const [index,clinfo] of changeList.entries()) {
  1056. if (clinfo.lid != 0) {
  1057. let listinfo = changeListData.find(function (item) {
  1058. return (item.id !== undefined && item.id == clinfo.lid) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && item.leafXmjs[0].gcl_id == clinfo.lid);
  1059. });
  1060. let info = '';
  1061. if (listinfo === undefined || (clinfo.lid && clinfo.gcl_id && clinfo.lid !== clinfo.gcl_id)) {
  1062. // 有可能这部分台账发生变化,此时要更新清单lid信息,防止数据丢失
  1063. const newlistinfo = changeListData.find(function (item) {
  1064. return (item.id !== undefined && item.id == clinfo.gcl_id) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && _.find(item.leafXmjs, {gcl_id: clinfo.gcl_id }));
  1065. });
  1066. if (listinfo === undefined && newlistinfo || (listinfo && newlistinfo && !isObjEqual(listinfo, newlistinfo))) {
  1067. listinfo = newlistinfo;
  1068. updateList.push({id: clinfo.id, lid: newlistinfo.leafXmjs[0].gcl_id});
  1069. // 更新lid
  1070. changeList[index].lid = newlistinfo.leafXmjs[0].gcl_id;
  1071. }
  1072. }
  1073. if (listinfo === undefined) {
  1074. // 针对旧数据获取清单信息
  1075. listinfo = changeListData[clinfo.lid - 1];
  1076. if (listinfo === undefined) {
  1077. toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
  1078. // changeList.splice(index, 1);
  1079. removeList.push(clinfo);
  1080. continue;
  1081. }
  1082. $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').addClass('table-success');
  1083. let pushbwmx = '0*;*0';
  1084. if (listinfo.leafXmjs !== undefined) {
  1085. const leafInfo = listinfo.leafXmjs.find(function (item) {
  1086. const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
  1087. if (flag && item.code === clinfo.xmj_code) {
  1088. return flag && item.code === clinfo.xmj_code;
  1089. }
  1090. return flag;
  1091. });
  1092. if (leafInfo) {
  1093. info = leafInfo;
  1094. pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' +
  1095. (leafInfo.dwgc ? leafInfo.dwgc : '') + '!_!' +
  1096. (leafInfo.fbgc ? leafInfo.fbgc : '') + '!_!' +
  1097. (leafInfo.fxgc ? leafInfo.fxgc : '') + '!_!' +
  1098. (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' +
  1099. (leafInfo.mx_id ? leafInfo.mx_id : '') + '!_!' +
  1100. (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (listinfo.leafXmjs.length > 1 && listinfo.name ? listinfo.name : (leafInfo.jldy !== undefined ? leafInfo.jldy : ''))) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
  1101. } else {
  1102. toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
  1103. // changeList.splice(index, 1);
  1104. removeList.push(clinfo);
  1105. continue;
  1106. }
  1107. } else {
  1108. pushbwmx = '0*;*' + (listinfo.quantity !== null ? listinfo.quantity : 0);
  1109. }
  1110. const bwmx = $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx');
  1111. if (bwmx) {
  1112. const bwmxArray = bwmx.split('$#$');
  1113. bwmxArray.push(pushbwmx);
  1114. $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
  1115. } else {
  1116. $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
  1117. }
  1118. } else {
  1119. $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').addClass('table-success');
  1120. let pushbwmx = '0*;*0';
  1121. if (listinfo.leafXmjs !== undefined) {
  1122. const leafInfo = listinfo.leafXmjs.find(function (item) {
  1123. const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
  1124. if (flag && item.code === clinfo.xmj_code) {
  1125. return flag && item.code === clinfo.xmj_code;
  1126. }
  1127. return flag;
  1128. });
  1129. if (leafInfo) {
  1130. info = leafInfo;
  1131. pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' +
  1132. (leafInfo.dwgc ? leafInfo.dwgc : '') + '!_!' +
  1133. (leafInfo.fbgc ? leafInfo.fbgc : '') + '!_!' +
  1134. (leafInfo.fxgc ? leafInfo.fxgc : '') + '!_!' +
  1135. (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' +
  1136. (leafInfo.mx_id ? leafInfo.mx_id : '') + '!_!' +
  1137. (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (listinfo.leafXmjs.length > 1 && listinfo.name ? listinfo.name : (leafInfo.jldy !== undefined ? leafInfo.jldy : ''))) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
  1138. } else {
  1139. // console.log(clinfo, listinfo.leafXmjs);
  1140. toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
  1141. // changeList.splice(index, 1);
  1142. removeList.push(clinfo);
  1143. continue;
  1144. }
  1145. } else {
  1146. pushbwmx = '0*;*' + (listinfo.quantity !== null ? listinfo.quantity : 0);
  1147. }
  1148. const bwmx = $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx');
  1149. if (bwmx) {
  1150. const bwmxArray = bwmx.split('$#$');
  1151. bwmxArray.push(pushbwmx);
  1152. $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
  1153. } else {
  1154. $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
  1155. }
  1156. }
  1157. if (info && _.findIndex(changeLedgerList, { id: clinfo.gcl_id }) !== -1) {
  1158. // 可能因为升降级关系:细目,分部分项等会发生变化,更新清单
  1159. const updateInfo = {};
  1160. if (info.code !== clinfo.xmj_code) {
  1161. updateInfo.xmj_code = info.code;
  1162. changeList[index].xmj_code = info.code;
  1163. }
  1164. if (info.jldy !== clinfo.xmj_jldy) {
  1165. updateInfo.xmj_jldy = info.jldy;
  1166. changeList[index].xmj_jldy = info.jldy;
  1167. }
  1168. if (info.dwgc !== clinfo.xmj_dwgc) {
  1169. updateInfo.xmj_dwgc = info.dwgc;
  1170. changeList[index].xmj_dwgc = info.dwgc;
  1171. }
  1172. if (info.fbgc !== clinfo.xmj_fbgc) {
  1173. updateInfo.xmj_fbgc = info.fbgc;
  1174. changeList[index].xmj_fbgc = info.fbgc;
  1175. }
  1176. if (info.fxgc !== clinfo.xmj_fxgc) {
  1177. updateInfo.xmj_fxgc = info.fxgc;
  1178. changeList[index].xmj_fxgc = info.fxgc;
  1179. }
  1180. if (!_.isEmpty(updateInfo) && _.indexOf(updateGclIdList, clinfo.gcl_id) === -1) {
  1181. updateGclIdList.push(clinfo.gcl_id);
  1182. // updateInfo.gcl_id = info.id;
  1183. updateList.push({ row: updateInfo, where: { tid: tenderId, gcl_id: clinfo.gcl_id } });
  1184. }
  1185. }
  1186. }
  1187. }
  1188. if(updateList.length > 0) {
  1189. // console.log(updateList);
  1190. postData(window.location.pathname + '/save', { type:'update_list', updateData: updateList }, function (result) {
  1191. }, function () {
  1192. });
  1193. }
  1194. if(removeList.length > 0) {
  1195. _.pullAll(changeList, removeList);
  1196. postData(window.location.pathname + '/save', { type:'remove_list', updateData: removeList }, function (result) {
  1197. }, function () {
  1198. });
  1199. }
  1200. }
  1201. }
  1202. // 清单搜索隐藏清单table部分值
  1203. function makeListTable(changeListData, showListData = changeListData) {
  1204. // 先加载台账数据
  1205. let listHtml = '';
  1206. let list_index = 1;
  1207. let gcl_index = 0;
  1208. for (const [index,gcl] of changeListData.entries()) {
  1209. const isShow = _.find(showListData, gcl);
  1210. $('#table-list-select tr').eq(index).css('display', (isShow ? 'table-row' : 'none'));
  1211. }
  1212. }
  1213. // 项目节搜索隐藏code-table部分值
  1214. function makeCodeTable(search = '') {
  1215. if (search === '') {
  1216. $('#code-list tr').css('display', 'table-row');
  1217. return;
  1218. }
  1219. $('#code-list tr').css('display', 'none');
  1220. if (searchCodeList.length > 0) {
  1221. for (const [index,list] of searchCodeList.entries()) {
  1222. if (list.indexOf(search) !== -1) {
  1223. $('#code-list tr').eq(index).css('display', 'table-row');
  1224. }
  1225. }
  1226. } else {
  1227. for(let i = 0; i < $('#code-list tr').length; i++) {
  1228. const length = $('#code-list tr').eq(i).children('td').length;
  1229. if (length === 9) {
  1230. const code = $('#code-list tr').eq(i).children('td').eq(1).text();
  1231. const name = $('#code-list tr').eq(i).children('td').eq(2).text();
  1232. const jldy = $('#code-list tr').eq(i).children('td').eq(6).text();
  1233. const isShow = code.indexOf(search) !== -1 || name.indexOf(search) !== -1 || jldy.indexOf(search) !== -1;
  1234. if (isShow) {
  1235. $('#code-list tr').eq(i).css('display', 'table-row');
  1236. }
  1237. // $('#code-list tr').eq(i).css('display', (isShow ? 'table-row' : 'none'));
  1238. } else {
  1239. return;
  1240. }
  1241. }
  1242. }
  1243. }
  1244. function remakeChangeSpread() {
  1245. const newTableList = [];
  1246. // 获取选中的签约清单判断并插入到原有清单中
  1247. $('#table-list-select .table-success').each(function(){
  1248. let code = $(this).children('td').eq(1).text();
  1249. let name = $(this).children('td').eq(2).text();
  1250. let unit = $(this).children('td').eq(3).text();
  1251. let price = $(this).children('td').eq(4).text();
  1252. // let oamount = $(this).children('td').eq(5).text();
  1253. // 根据单位获取数量的位数,并得出
  1254. // let numdecimal = findDecimal(unit);
  1255. // let scnum = makedecimalzero(numdecimal);
  1256. let scnum = 0;
  1257. // let detail = $(this).attr('data-detail') != 0 ? $(this).attr('data-detail').split('_')[1] : '';
  1258. let lid = $(this).data('lid');
  1259. let lindex = $(this).data('index');
  1260. // 原清单和数量改变
  1261. let data_bwmx = $(this).attr('data-bwmx').split('$#$');
  1262. for (const b of data_bwmx) {
  1263. const oamount = b.split('*;*')[1] != '' ? b.split('*;*')[1] : 0;
  1264. let bwmx = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[7] : '';
  1265. let xmj_code = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[0] : '';
  1266. let xmj_jldy = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[1] : '';
  1267. let xmj_dwgc = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[2] : '';
  1268. let xmj_fbgc = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[3] : '';
  1269. let xmj_fxgc = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[4] : '';
  1270. let gcl_id = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[5] : '';
  1271. let mx_id = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[6] : '';
  1272. let trlist = {
  1273. code,
  1274. name,
  1275. bwmx,
  1276. unit,
  1277. unit_price: price,
  1278. oamount,
  1279. camount: scnum,
  1280. detail: '',
  1281. lid,
  1282. xmj_code,
  1283. xmj_jldy,
  1284. xmj_dwgc,
  1285. xmj_fbgc,
  1286. xmj_fxgc,
  1287. gcl_id,
  1288. mx_id,
  1289. };
  1290. const radionInfo = changeList.find(function (info) {
  1291. return info.code === code && (info.lid == lid || parseInt(info.lid) === parseInt(lindex)) && gcl_id == info.gcl_id && (info.bwmx === bwmx || info.bwmx === xmj_jldy) && parseInt(info.oamount) === parseInt(oamount);
  1292. });
  1293. if (radionInfo) {
  1294. trlist.camount = radionInfo.camount;
  1295. trlist.detail = radionInfo.detail;
  1296. }
  1297. newTableList.push(trlist);
  1298. }
  1299. });
  1300. // const changeWhiteList = _.filter(changeList, function (item) {
  1301. // return item.lid == 0;
  1302. // });
  1303. // console.log(newTableList);
  1304. // changeList = newTableList.concat(changeWhiteList);
  1305. return newTableList;
  1306. }
  1307. //判断元素是否在数组中,相当于php的in_array();
  1308. function in_array(arr, obj) {
  1309. let i = arr.length;
  1310. while (i--) {
  1311. if (arr[i] == obj) {
  1312. return true;
  1313. }
  1314. }
  1315. return false;
  1316. }
  1317. function isObjEqual(o1,o2){
  1318. var props1 = Object.getOwnPropertyNames(o1);
  1319. var props2 = Object.getOwnPropertyNames(o2);
  1320. if (props1.length != props2.length) {
  1321. return false;
  1322. }
  1323. for (var i = 0,max = props1.length; i < max; i++) {
  1324. var propName = props1[i];
  1325. if (o1[propName] !== o2[propName]) {
  1326. return false;
  1327. }
  1328. }
  1329. return true;
  1330. }
  1331. // 判断是否有更改过
  1332. function judgeChange() {
  1333. let change = false;
  1334. if (!isObjEqual(changeInfo, back_changeInfo)) {
  1335. change = true;
  1336. }
  1337. if (change) {
  1338. $('#show-save-btn').show();
  1339. $('#sp-btn').hide();
  1340. $('.title-main').addClass('bg-warning');
  1341. } else {
  1342. $('#show-save-btn').hide();
  1343. $('#sp-btn').show();
  1344. $('.title-main').removeClass('bg-warning');
  1345. }
  1346. }
  1347. function changeFormRemake() {
  1348. changeInfo = Object.assign({}, back_changeInfo);
  1349. $('#change_form input[name="code"]').val(changeInfo.code);
  1350. $('#change_form input[name="name"]').val(changeInfo.name);
  1351. $('#change_form input[name="peg"]').val(changeInfo.peg);
  1352. $('#change_form input[name="org_name"]').val(changeInfo.org_name);
  1353. $('#change_form input[name="org_code"]').val(changeInfo.org_code);
  1354. $('#change_form input[name="new_name"]').val(changeInfo.new_name);
  1355. $('#change_form input[name="new_code"]').val(changeInfo.new_code);
  1356. $('#change_form textarea[name="content"]').val(changeInfo.content.replace(/<br><br>/g, '\r\n'));
  1357. $('#change_form textarea[name="basis"]').val(changeInfo.basis.replace(/<br><br>/g, '\r\n'));
  1358. $('#change_form textarea[name="expr"]').val(changeInfo.expr.replace(/<br><br>/g, '\r\n'));
  1359. $('#change_form textarea[name="memo"]').val(changeInfo.memo.replace(/<br><br>/g, '\r\n'));
  1360. $('#change_form select[name="type"]').val(changeInfo.type);
  1361. $('#change_form select[name="class"]').val(changeInfo.class);
  1362. $('#change_form select[name="quality"]').val(changeInfo.quality);
  1363. $('#change_form select[name="company"]').val(changeInfo.company);
  1364. $('#change_form input[name="charge"][value="'+ changeInfo.charge +'"]').prop('checked', true);
  1365. $('#change_form input[name="type[]"]').prop('checked', false);
  1366. const typecheck = changeInfo.type.split(',');
  1367. for (const type of typecheck) {
  1368. $('#change_form input[name="type[]"][value="'+ type +'"]').prop('checked', true);
  1369. }
  1370. }