pm_import.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Zhong
  6. * @date 2019/5/15
  7. * @version
  8. */
  9. //操作接口为eventListen
  10. const importView = (() => {
  11. let importXML = null;
  12. let xmlObj = null; //导入xml转化后的对象
  13. let tbcObj = null; //待确认对象
  14. //显示、隐藏提示上传文件窗口相关提示信息
  15. function showUploadAlert(success, msg){
  16. if(!success){
  17. $('#uploadAlert').removeClass('alert-success');
  18. $('#uploadAlert').addClass('alert-danger');
  19. } else{
  20. $('#uploadAlert').removeClass('alert-danger');
  21. $('#uploadAlert').addClass('alert-success');
  22. }
  23. $('#uploadAlert').text(msg);
  24. $('#uploadAlert').show();
  25. }
  26. /*
  27. * 获取单位工程数据(将所有单项工程里的单位工程放到一起,含有单项工程的一些信息)
  28. * @param {Object} xmlObj @return {Array}
  29. * */
  30. function getTenderDatas(xmlObj) {
  31. if (!xmlObj || !xmlObj.engs) {
  32. return [];
  33. }
  34. let rst = [];
  35. for (let eng of xmlObj.engs) {
  36. if (Array.isArray(eng.tenders)) {
  37. for (let tender of eng.tenders) {
  38. tender.temp = {}; //暂时存放的信息(不是从导入文件中获取的,记录当前工程已阅、选择的费用标准、计算程序)
  39. tender.engName = eng.name;
  40. }
  41. rst.push(...eng.tenders);
  42. }
  43. }
  44. return rst;
  45. }
  46. //确认界面提示信息隐藏
  47. function hideTBCInfo() {
  48. $('#tbc-engName-info').hide();
  49. $('#tbc-tenderName-info').hide();
  50. $('#tbc-engineering-info').hide();
  51. $('#tbc-calcProgram-info').hide();
  52. }
  53. //待确认界面相关
  54. class TBC {
  55. constructor(xmlObj, fileKind, valuation, taxType) {
  56. this.datas = getTenderDatas(xmlObj);
  57. this.fileKind = fileKind; //文件类型
  58. this.valuationType = 'bill'; //计价方式 暂时默认为清单计价
  59. this.valuation = valuation; //计价规则数据
  60. this.taxType = taxType; //计税方法
  61. this.engineeringList = valuation ? valuation.engineering_list : []; //工程专业库数据
  62. this.curIdx = 0; //当前单位工程数据索引
  63. this.init();
  64. }
  65. //初始化
  66. init() {
  67. this.next(this.curIdx);
  68. $('#importInterface .modal-content:eq(1) p:eq(0)').text(`该文件共有${this.datas.length}个单位工程待导入`); //信息统计信息
  69. }
  70. checkConfirmed() {
  71. //检查数据是否都确认过了
  72. let allConfirmed = this.datas.every(data => data.temp.confirmed);
  73. if (allConfirmed) {
  74. $('#import-confirm').prop('disabled', false);
  75. }
  76. }
  77. //检测当前待确认工程是否有效,有效才可确认
  78. checkValid() {
  79. let engName = $('#tbc-engName').val();
  80. if (!engName) {
  81. return $('#tbc-engName-info').show();
  82. } else {
  83. $('#tbc-engName-info').hide();
  84. }
  85. let tenderName = $('#tbc-tenderName').val();
  86. if (!tenderName) {
  87. return $('#tbc-tenderName-info').show();
  88. } else {
  89. $('#tbc-tenderName-info').hide();
  90. }
  91. let engineering = $('#tbc-engineering').val();
  92. if (!engineering) {
  93. return $('#tbc-engineering-info').show();
  94. } else {
  95. $('#tbc-engineering-info').hide();
  96. }
  97. let feeStandard = $('#tbc-feeStandard').val();
  98. if (!feeStandard) {
  99. return $('#tbc-feeStandard-info').show();
  100. } else {
  101. $('#tbc-feeStandard-info').hide();
  102. }
  103. let calcProgram = $('#tbc-calcProgram').val();
  104. if (!calcProgram) {
  105. return $('#tbc-calcProgram-info').show();
  106. } else {
  107. $('#tbc-calcProgram-info').hide();
  108. }
  109. return null;
  110. }
  111. //下一工程
  112. next(idx = null) {
  113. this.curIdx = idx !== null ? idx : this.curIdx + 1;
  114. if (this.curIdx && this.checkValid()) {
  115. this.curIdx--;
  116. return;
  117. }
  118. let curData = this.datas[this.curIdx];
  119. //显示这个工程的相关信息
  120. $('#tbc-engName').val(curData.engName || '');
  121. $('#tbc-tenderName').val(curData.name || '');
  122. $('#tbc-engineering').val(curData.engineering || '');
  123. curData.temp.confirmed = true; //增加确认信息(已读)
  124. if (this.curIdx === this.datas.length -1) { //到最后一个数据了,无法点击下一工程
  125. $('#tbc-next').prop('disabled', true);
  126. } else {
  127. $('#tbc-next').prop('disabled', false);
  128. }
  129. if (this.curIdx !== 0) { //不为第一个数据,可以点击上一工程
  130. $('#tbc-prev').prop('disabled', false);
  131. } else {
  132. $('#tbc-prev').prop('disabled', true);
  133. }
  134. //更新x/x信息
  135. $('#tbc-info').text(`${this.curIdx + 1}/${this.datas.length} 已确认`);
  136. //更新选项信息
  137. this.initFeeOpts(curData);
  138. this.checkConfirmed();
  139. }
  140. //上一工程
  141. prev(idx = null) {
  142. this.curIdx = idx !== null ? idx : this.curIdx - 1;
  143. let curData = this.datas[this.curIdx];
  144. $('#tbc-engName').val(curData.engName || '');
  145. $('#tbc-tenderName').val(curData.name || '');
  146. $('#tbc-engineering').val(curData.engineering || '');
  147. if (this.curIdx === 0) { //到第一个数据了,无法点击上一工程
  148. $('#tbc-prev').prop('disabled', true);
  149. } else {
  150. $('#tbc-prev').prop('disabled', false);
  151. }
  152. if (this.curIdx !== this.datas.length -1 ) { //不为最后一个数据了,可以点击下一工程
  153. $('#tbc-next').prop('disabled', false);
  154. } else {
  155. $('#tbc-next').prop('disabled', true);
  156. }
  157. //更新x/x信息
  158. $('#tbc-info').text(`${this.curIdx + 1}/${this.datas.length} 已确认`);
  159. //更新选项信息
  160. this.initFeeOpts(curData);
  161. this.checkConfirmed();
  162. }
  163. /*
  164. * 初始化工程的费用选项等相关信息(专业工程、费用标准、计算程序等)
  165. * 根据导入文件提取的专业工程等数据确定,需要我们软件有对应的工程专业数据,否则下拉选择为空
  166. * @param {Object}tenderData(当前确认单位工程数据) {Array}engineeringList(当前计价规则下的工程专业数据)
  167. * @return {void}
  168. * */
  169. initFeeOpts(tenderData) {
  170. $('#tbc-engineering').empty(); //清空工程专业选项
  171. $('#tbc-feeStandard').empty(); //清空费用标准选项
  172. $('#tbc-calcProgram').empty(); //清空计算程序选项
  173. let engineerings = [];
  174. if (tenderData.temp.engineering) {
  175. engineerings = this.engineeringList.filter(data => data.lib.name === tenderData.temp.engineering);
  176. } else {
  177. engineerings = this.engineeringList.filter(data => data.lib.name === tenderData.engineering);
  178. tenderData.temp.engineering = tenderData.engineering;
  179. }
  180. //文件里的工程专业跟软件里的对应不上,取第一个
  181. if (!engineerings.length) {
  182. let firstEngineering = this.engineeringList[0];
  183. engineerings = this.engineeringList.filter(data => data.lib.name === firstEngineering.lib.name);
  184. tenderData.temp.engineering = engineerings[0] ? engineerings[0].lib.name : tenderData.engineering;
  185. }
  186. if (!engineerings.length) {
  187. return;
  188. }
  189. //工程专业名称去重
  190. let engineeringNames = [...new Set(this.engineeringList.map(data => data.lib.name))];
  191. let engineeringHtml = engineeringNames.map(name =>
  192. `<option ${tenderData.temp.engineering === name ? 'selected' : ''} value="${name}">${name}</option>`);
  193. $('#tbc-engineering').html(engineeringHtml);
  194. //$('#tbc-engineering').html(`<option selected value="${tenderData.engineering}">${tenderData.engineering}</option>`);
  195. //费用标准,若当前工程有费用标准数据(该数据本身没有费用标准数据,选择过了,就会记录),则选中该费用标准
  196. let feeOptsHtml = engineerings.map(data =>
  197. `<option ${tenderData.temp.feeStandard === data.lib.feeName ? 'selected' : ''} value="${data.lib.feeName}">${data.lib.feeName}</option>`).join('');
  198. $('#tbc-feeStandard').html(feeOptsHtml);
  199. //记录选中的费用标准
  200. tenderData.temp.feeStandard = $('#tbc-feeStandard').val();
  201. //根据工程专业及费用标准确定的当前选中的工程专业库
  202. let curEngineering = engineerings.find(data => data.lib.feeName === tenderData.temp.feeStandard) || engineerings[0];
  203. //根据计税方法过滤出来的计税组合
  204. let taxDatas = curEngineering.lib.tax_group.filter(data => data.taxType == this.taxType);
  205. //计算程序,若当前工程有计算程序(该数据本身没有计算程序数据,选择过了,就会记录),则选中该计算程序
  206. let calcOptsHtml = taxDatas.map(data =>
  207. `<option ${tenderData.temp.calcProgram === data.program_lib.name ? 'selected' : ''} value="${data.program_lib.name}">${data.program_lib.name}</option>`);
  208. $('#tbc-calcProgram').html(calcOptsHtml);
  209. tenderData.temp.calcProgram = $('#tbc-calcProgram').val();
  210. }
  211. }
  212. /*
  213. * 根据条件获取计税组合数据
  214. * @param {Object}query ({engineeringName, feeName, taxType, calcProgram}) {Array}engineeringList(当前计价规则下的所有工程专业数据)
  215. * @return {Object}
  216. * */
  217. function getTaxData(query, engineeringList) {
  218. //工程专业名称 + 费用标准名称 确定一个工程专业数据
  219. let engineering = engineeringList.find(data => query.engineeringName === data.lib.name &&
  220. query.feeStandard === data.lib.feeName);
  221. if (!engineering || !Array.isArray(engineering.lib.tax_group)) {
  222. return null;
  223. }
  224. return engineering.lib.tax_group.find(data => query.taxType == data.taxType &&
  225. query.calcProgram === data.program_lib.name);
  226. }
  227. //获取单位工程项目属性的一些数据(新建单位工程需要,前端能获取到的一些数据,还有一些数据需要后端获取: rootProjectID, projectFeature..)
  228. /*
  229. * @param {Object}tbcObj(TBC实例) {Object}curData(单位工程数据)
  230. * @return {Object}
  231. * */
  232. function getProperty(tbcObj, curData) {
  233. if (!tbcObj) {
  234. throw '存在无效数据,无法生成项目。';
  235. }
  236. //计税数据
  237. let query = {
  238. engineeringName: curData.temp.engineering || curData.engineering,
  239. feeStandard: curData.temp.feeStandard,
  240. taxType: tbcObj.taxType, //取导入时选择的计税方法,不读取文件中的计税方法
  241. calcProgram: curData.temp.calcProgram
  242. };
  243. let taxData = getTaxData(query, tbcObj.engineeringList);
  244. if (!taxData) {
  245. throw '无效计税数据,无法生成项目。';
  246. }
  247. //当前工程专业数据
  248. let curEngineering = tbcObj.engineeringList.find(data => query.engineeringName === data.lib.name &&
  249. query.feeStandard === data.lib.feeName);
  250. return {
  251. region: '全省', //地区
  252. valuationType: tbcObj.valuationType, //计价方式
  253. valuation: tbcObj.valuation.id, //计价规则
  254. valuationName: tbcObj.valuation.name,
  255. engineering_id: curEngineering.engineering_id, //工程专业
  256. engineeringName: curEngineering.lib.name,
  257. taxType: parseInt(tbcObj.taxType), //计税方法
  258. isInstall: !!curEngineering.lib.isInstall, //是安装工程?
  259. feeStandardName: curEngineering.lib.feeName, //费用标准
  260. engineering: curEngineering.lib.engineering, //定额取费专业
  261. projectEngineering: curEngineering.lib.projectEngineering, //单位工程取费专业
  262. featureLibID: curEngineering.lib.feature_lib[0] ? curEngineering.lib.feature_lib[0].id : '', //工程特征
  263. indexName: curEngineering.lib.indexName, // 指标名称
  264. engineerInfoLibID: curEngineering.lib.engineer_info_lib[0] ? curEngineering.lib.engineer_info_lib[0].id : '', // 工程信息指标
  265. engineerFeatureLibID: curEngineering.lib.engineer_feature_lib[0] ? curEngineering.lib.engineer_feature_lib[0].id : '', //工程特征指标
  266. economicLibID: curEngineering.lib.economic_lib[0] ? curEngineering.lib.economic_lib[0].id : '', // 主要经济指标
  267. mainQuantityLibID: curEngineering.lib.main_quantity_lib[0] ? curEngineering.lib.main_quantity_lib[0].id : '', // 主要工程量指标
  268. materialLibID: curEngineering.lib.material_lib[0] ? curEngineering.lib.material_lib[0].id : '', // 主要工料指标
  269. calcProgram: {name: taxData.program_lib.name, id: taxData.program_lib.id}, //计算程序
  270. colLibID: taxData.col_lib.id, //列设置
  271. templateLibID: taxData.template_lib.id, //清单模板
  272. unitPriceFile: {name: curData.name, id: ''}, //新建单价文件
  273. feeFile: {name: curData.name, id: `newFeeRate@@${taxData.fee_lib.id}`} //新建费率文件
  274. };
  275. }
  276. function eventListen() {
  277. //选择文件
  278. $('#customFile').change(async function() {
  279. let file = $(this)[0].files[0];
  280. $('#import-confirm').prop('disabled', true); //确认导入无效
  281. $('.custom-file-label').text(`${file ? file.name : ''}`); //设置选择框文本
  282. $('#uploadAlert').hide();
  283. $('.selFile').hide();
  284. hideTBCInfo();
  285. if (file) {
  286. let reg = /(xml|XML|qtf|QTF)$/;
  287. if(file.name && !reg.test(file.name)){
  288. $('.selFile').hide();
  289. showUploadAlert(false, '请选择xml或qtf文件。');
  290. return;
  291. }
  292. $.bootstrapLoading.start();
  293. $('#loadingPage').css('z-index', '2000');
  294. //转换数据
  295. importXML = new ImportXML();
  296. try {
  297. xmlObj = await importXML.extractData(file, false);
  298. $('.selFile input:eq(0)').val(xmlObj && xmlObj.name ? xmlObj.name : '');
  299. $('.selFile input[name="fileKind-import"]:eq(0)').prop('checked', true); //文件类型恢复成投标
  300. $('#import-taxType').val('1'); //计税方法显示回默认的一般计税法
  301. $('.selFile').show(); //显示建设项目、计价规则
  302. } catch (err) {
  303. console.log(err);
  304. showUploadAlert(false, err);
  305. $(this).val('');
  306. }
  307. $.bootstrapLoading.end();
  308. }
  309. });
  310. //下一步
  311. $('#import-next').click(function () {
  312. let file = $('#customFile')[0].files[0];
  313. if (!file) {
  314. showUploadAlert(false, '请选择导入文件。');
  315. return;
  316. }
  317. if (!xmlObj) {
  318. showUploadAlert(false, '不存在有效数据。');
  319. return;
  320. }
  321. let projectName = $('.selFile input:eq(0)').val();
  322. if (!projectName) {
  323. showUploadAlert(false, '不存在有效建设项目。');
  324. return;
  325. }
  326. //文件类型
  327. let fileKind = $('.selFile input[name="fileKind-import"]:checked').val();
  328. if (!fileKind) {
  329. showUploadAlert(false, '不存在有效文件类型。');
  330. }
  331. //计价规则
  332. let valuation = $('#import-valuation').val();
  333. if (!valuation) {
  334. showUploadAlert(false, '不存在有效计价规则。');
  335. return;
  336. }
  337. //计税方法
  338. let taxType = $('#import-taxType').val();
  339. if (!taxType) {
  340. showUploadAlert(false, '不存在有效计税方法。');
  341. return;
  342. }
  343. if (!xmlObj.engs.length) {
  344. showUploadAlert(false, '不存在单项工程数据。');
  345. return;
  346. }
  347. if (!getTenderDatas(xmlObj).length) {
  348. showUploadAlert(false, '不存在单位工程数据。');
  349. return;
  350. }
  351. $('#importInterface .modal-content:eq(0)').hide(); //隐藏第一步内容
  352. $('#importInterface .modal-content:eq(1)').show(); //显示第二步内容
  353. //console.log(getTenderDatas(xmlObj));
  354. //console.log(xmlObj);
  355. let selValuation = billValuation.find(data => data.id === valuation);
  356. tbcObj = new TBC(xmlObj, fileKind, selValuation, taxType);
  357. });
  358. //上一步
  359. $('#import-prev').click(function () {
  360. $('#importInterface .modal-content:eq(0)').show(); //显示第一步内容
  361. $('#importInterface .modal-content:eq(1)').hide(); //隐藏第二步内容
  362. hideTBCInfo();
  363. $('#import-confirm').prop('disabled', true); //确认导入无效
  364. //清空确认字段
  365. if (tbcObj) {
  366. for (let data of tbcObj.datas) {
  367. delete data.temp.confirmed;
  368. }
  369. }
  370. });
  371. //变换专业工程
  372. $('#tbc-engineering').change(function () {
  373. let curData = tbcObj ? tbcObj.datas[tbcObj.curIdx] : null;
  374. if (!curData) {
  375. return;
  376. }
  377. curData.temp.engineering = $(this).val();
  378. tbcObj.initFeeOpts(curData);
  379. });
  380. //变换费用标准
  381. $('#tbc-feeStandard').change(function () {
  382. let curData = tbcObj ? tbcObj.datas[tbcObj.curIdx] : null;
  383. if (!curData) {
  384. return;
  385. }
  386. curData.temp.feeStandard = $(this).val();
  387. tbcObj.initFeeOpts(curData);
  388. });
  389. //变换计算程序
  390. $('#tbc-calcProgram').change(function () {
  391. let curData = tbcObj ? tbcObj.datas[tbcObj.curIdx] : null;
  392. if (!curData) {
  393. return;
  394. }
  395. curData.temp.calcProgram = $(this).val();
  396. tbcObj.initFeeOpts(curData);
  397. });
  398. //待确认-下一工程
  399. $('#tbc-next').click(function () {
  400. tbcObj.next();
  401. });
  402. //待确认-上一工程
  403. $('#tbc-prev').click(function () {
  404. tbcObj.prev();
  405. hideTBCInfo();
  406. });
  407. //确认导入
  408. $('#import-confirm').click(async function () {
  409. if (STATE.importing) {
  410. return;
  411. }
  412. STATE.importing = true;
  413. if (tbcObj && tbcObj.checkValid()) {
  414. return;
  415. }
  416. let pr = new SCComponent.InitProgressBar();
  417. try {
  418. //建设项目设置选择的文件类型和选择的计税方法
  419. xmlObj.property.fileKind = tbcObj.fileKind;
  420. xmlObj.property.taxType = tbcObj.taxType;
  421. //确定使用的计税组合
  422. tbcObj.datas.map(data => {
  423. data.property = getProperty(tbcObj, data);
  424. //默认定额库
  425. let curEngineering = tbcObj.engineeringList.find(enData => data.temp.engineering === enData.lib.name &&
  426. data.temp.feeStandard === enData.lib.feeName);
  427. let defaultLib = curEngineering.lib.ration_lib.find(data => data.isDefault) || curEngineering.lib.ration_lib[0];
  428. data.defaultRationLib = parseInt(defaultLib.id);
  429. //此费用定额下可用的定额库id,人材机库id
  430. data.rationLibIDs = curEngineering.lib.ration_lib.map(data => parseInt(data.id));
  431. data.gljLibIDs = curEngineering.lib.glj_lib.map(data => parseInt(data.id));
  432. });
  433. //确定生成建设项目的父、前、后节点ID
  434. let {parentProjectID, preProjectID, nextProjectID} = projTreeObj.getRelProjectID(projTreeObj.tree.selected);
  435. xmlObj.ParentID = parentProjectID;
  436. xmlObj.preID = preProjectID;
  437. xmlObj.NextSiblingID = nextProjectID;
  438. //确定建设项目的名称(不允许重复)
  439. let sameDepthProjs = getProjs(projTreeObj.tree.selected);
  440. if (sameDepthProjs.find(node => node.data.name === xmlObj.name)) {
  441. xmlObj.name += `(${moment(Date.now()).format('YYYY-MM-DD HH:mm:ss')})`;
  442. }
  443. $('#importInterface').modal('hide');
  444. //TEST======================
  445. /*let importData = await importXML.transformData(xmlObj);
  446. console.log(importData);*/
  447. //TEST======================
  448. pr.start('导入文件', '正在生成文件,请稍候……');
  449. let importData = await importXML.transformData(xmlObj);
  450. let blob = new Blob([JSON.stringify(importData)], {type: 'text/plain;charset=utf-8'});
  451. let formData = new FormData();
  452. formData.append('file', blob);
  453. $.ajax({
  454. url: '/pm/import/importInterface',
  455. type: 'POST',
  456. data: formData,
  457. cache: false,
  458. contentType: false,
  459. processData: false,
  460. timeout: 1000 * 60 * 3, //3分钟
  461. success: function(response){
  462. if (response.data && Array.isArray(response.data)) {
  463. doAfterImport(response.data);
  464. }
  465. pr.end();
  466. setTimeout(function () {
  467. STATE.importing = false;
  468. }, 500);
  469. },
  470. error: function(jqXHR){
  471. pr.end();
  472. throw `与服务器通信发生错误${jqXHR.status} ${jqXHR.statusText}`;
  473. }
  474. });
  475. } catch (err) {
  476. setTimeout(function () {
  477. STATE.importing = false;
  478. }, 500);
  479. pr.end();
  480. console.log(err);
  481. alert(err);
  482. }
  483. });
  484. // 导入窗口激活
  485. $('#importInterface').on('show.bs.modal', function () {
  486. // 恢复计价规则下拉
  487. setValuationSels($('#import-valuation'), billValuation);
  488. });
  489. //导入窗口消失后
  490. $('#importInterface').on('hidden.bs.modal', function () {
  491. importXML = null;
  492. xmlObj = null; //重置数据
  493. tbcObj = null;
  494. $('#importInterface .modal-content:eq(0)').show(); //显示第一步内容
  495. $('#importInterface .modal-content:eq(1)').hide(); //隐藏第二步内容
  496. $('#customFile').val(''); //清除选择
  497. $('.custom-file-label').text(''); //设置选择框文本
  498. $('#uploadAlert').hide(); //隐藏提示
  499. $('.selFile').hide(); //隐藏建设项目及计价规则
  500. $('#import-confirm').prop('disabled', true); //确认导入无效
  501. $('.selFile input[name="fileKind-import"]:eq(0)').prop('checked', true); //文件类型恢复成投标
  502. $('#import-taxType').val('1'); //显示回一般计税
  503. hideTBCInfo();
  504. });
  505. }
  506. //projectDatas在后端已经按照顺序排过了: project eng1 tender1-1 tender1-2 eng2 tender2-1 tender2-2
  507. function doAfterImport(projectDatas) {
  508. //插入节点
  509. let lastNode;
  510. for (let data of projectDatas) {
  511. data.feeStandardName = data.property && data.property.feeStandardName || ''; //工程专业列显示用
  512. let parent = projTreeObj.tree.items.find(node => node.data.ID === data.ParentID),
  513. next = projTreeObj.tree.items.find(node => node.data.ID === data.NextSiblingID);
  514. lastNode = projTreeObj.insert(data, parent, next);
  515. }
  516. if(lastNode) {
  517. projTreeObj.workBook.getSheet(0).showRow(lastNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
  518. }
  519. }
  520. return {eventListen};
  521. })();