file_controller.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2021/10/27
  7. * @version
  8. */
  9. const auditConst = require('../const/audit');
  10. const sendToWormhole = require('stream-wormhole');
  11. const path = require('path');
  12. const advanceConst = require('../const/advance');
  13. module.exports = app => {
  14. class FileController extends app.BaseController {
  15. checkUnlock(ctx) {
  16. if (ctx.subProject.lock_file) throw '管理员锁定中,暂无法编辑分类&文件,仅可查看';
  17. }
  18. checkLock(ctx) {
  19. if (!ctx.subProject.lock_file) throw '请先锁定,再管理分类数据';
  20. }
  21. /**
  22. * 概算投资
  23. *
  24. * @param ctx
  25. * @returns {Promise<void>}
  26. */
  27. async index(ctx) {
  28. try {
  29. if (!ctx.session.sessionProject.page_show.openFile) {
  30. throw '该功能已关闭或无法查看';
  31. }
  32. const renderData = {
  33. jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.file.index),
  34. auditConst,
  35. };
  36. renderData.projectList = await ctx.service.subProject.getFileProject(ctx.session.sessionProject.id, ctx.session.sessionUser.accountId, ctx.session.sessionUser.is_admin);
  37. for (const p of renderData.projectList) {
  38. if (!p.is_folder) p.file_count = await this.service.filing.sumFileCount(p.id);
  39. }
  40. renderData.tenderList = await ctx.service.tender.getList4Select('stage');
  41. renderData.categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
  42. await this.layout('file/index.ejs', renderData, 'file/modal.ejs');
  43. } catch (err) {
  44. ctx.log(err);
  45. ctx.session.postError = err.toString();
  46. ctx.redirect(this.menu.menu.dashboard.url);
  47. }
  48. }
  49. async file(ctx) {
  50. try {
  51. const renderData = {
  52. jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.file.file),
  53. };
  54. renderData.filing = await ctx.service.filing.getValidFiling(ctx.params.id, ctx.subProject.permission.filing_type);
  55. renderData.categoryData = await ctx.service.category.getAllCategory(ctx.subProject);
  56. renderData.canFiling = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.filing.value) >= 0;
  57. renderData.canUpload = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.upload.value) >= 0;
  58. renderData.canDelete = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.delete.value) >= 0;
  59. renderData.fileReferenceList = await ctx.service.subProject.getFileReference(ctx.subProject, ctx.service.subProject.FileReferenceType.file);
  60. await this.layout('file/file.ejs', renderData, 'file/file_modal.ejs');
  61. } catch (err) {
  62. ctx.log(err);
  63. }
  64. }
  65. async getFilingTypePermission(ctx) {
  66. try {
  67. if (ctx.subProject.project_id !== this.ctx.session.sessionProject.id) throw '您无权操作该数据';
  68. const filingType = await ctx.service.subProjPermission.getFilingType(ctx.subProject.id);
  69. ctx.body = { err: 0, msg: '', data: filingType };
  70. } catch(err) {
  71. ctx.log(err);
  72. ctx.ajaxErrorBody(err, '获取授权用户数据错误');
  73. }
  74. }
  75. async saveFilingTypePermission(ctx) {
  76. try {
  77. const data = JSON.parse(ctx.request.body.data);
  78. await ctx.service.subProjPermission.saveFilingType(data);
  79. ctx.body = { err: 0, msg: '', data: '' };
  80. } catch(err) {
  81. ctx.log(err);
  82. ctx.ajaxErrorBody(err, '保存授权用户信息错误');
  83. }
  84. }
  85. async addFiling(ctx) {
  86. try {
  87. this.checkUnlock(ctx);
  88. const data = JSON.parse(ctx.request.body.data);
  89. const result = await ctx.service.filing.add(data);
  90. ctx.body = { err: 0, msg: '', data: result };
  91. } catch (err) {
  92. ctx.log(err);
  93. ctx.ajaxErrorBody(err, '新增分类失败');
  94. }
  95. }
  96. async delFiling(ctx) {
  97. try {
  98. this.checkUnlock(ctx);
  99. const data = JSON.parse(ctx.request.body.data);
  100. const result = await ctx.service.filing.del(data);
  101. ctx.body = { err: 0, msg: '', data: result };
  102. } catch (err) {
  103. ctx.log(err);
  104. ctx.ajaxErrorBody(err, '删除分类失败');
  105. }
  106. }
  107. async saveFiling(ctx) {
  108. try {
  109. this.checkUnlock(ctx);
  110. const data = JSON.parse(ctx.request.body.data);
  111. const result = await ctx.service.filing.save(data);
  112. ctx.body = { err: 0, msg: '', data: result };
  113. } catch (err) {
  114. ctx.log(err);
  115. ctx.ajaxErrorBody(err, '保存分类数据失败');
  116. }
  117. }
  118. async moveFiling(ctx) {
  119. try {
  120. this.checkUnlock(ctx);
  121. const data = JSON.parse(ctx.request.body.data);
  122. if (!data.id || !(data.tree_order >= 0)) throw '数据错误';
  123. const result = await ctx.service.filing.move(data);
  124. ctx.body = { err: 0, msg: '', data: result };
  125. } catch (err) {
  126. ctx.log(err);
  127. ctx.ajaxErrorBody(err, '移动分类失败');
  128. }
  129. }
  130. async loadFile(ctx) {
  131. try {
  132. const data = JSON.parse(ctx.request.body.data);
  133. const order = data.order.split('|');
  134. if (order.length !== 2) throw '加载文件错误';
  135. if (order[0] !== 'filename' && order[0] !== 'create_time') throw '加载文件错误';
  136. if (order[1] !== 'asc' && order[1] !== 'desc') throw '加载文件错误';
  137. const result = await ctx.service.file.getFiles({
  138. where: { filing_id: data.filing_id, is_deleted: 0 },
  139. orders: [order],
  140. limit: data.count,
  141. offset: (data.page-1)*data.count,
  142. }, order);
  143. ctx.body = { err: 0, msg: '', data: result };
  144. } catch (err) {
  145. ctx.log(err);
  146. ctx.ajaxErrorBody(err, '加载文件失败');
  147. }
  148. }
  149. async checkCanUpload(ctx) {
  150. if (ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.upload.value) < 0) {
  151. throw '您无权上传、导入、删除文件';
  152. }
  153. }
  154. async checkFiling(filing) {
  155. const child = await this.ctx.service.filing.getDataByCondition({ tree_pid: filing.id, is_deleted: 0 });
  156. if (child) throw '该分类下存在子分类,请在子分类下上传、导入文件';
  157. }
  158. async checkFiles(ctx) {
  159. try{
  160. const data = JSON.parse(ctx.request.body.data);
  161. if (!data.filing_id || !data.files) throw '缺少参数';
  162. const result = await ctx.service.file.checkFiles(data.filing_id, data.files);
  163. ctx.body = { err: 0, msg: '', data: result };
  164. } catch(error) {
  165. this.log(error);
  166. ctx.ajaxErrorBody(error, '检查附件错误');
  167. }
  168. }
  169. async uploadFile(ctx){
  170. let stream;
  171. try {
  172. await this.checkCanUpload(ctx);
  173. const parts = ctx.multipart({ autoFields: true });
  174. let index = 0;
  175. const create_time = Date.parse(new Date()) / 1000;
  176. let stream = await parts();
  177. const user = await ctx. service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
  178. const filing = await ctx.service.filing.getDataById(parts.field.filing_id);
  179. if (!filing || filing.is_deleted) throw '分类不存在,请刷新页面后重试';
  180. await this.checkFiling(filing);
  181. const uploadfiles = [];
  182. while (stream !== undefined) {
  183. if (!stream.filename) throw '未发现上传文件!';
  184. const fileInfo = path.parse(stream.filename);
  185. const filepath = `sp/file/${filing.spid}/${ctx.moment().format('YYYYMMDD')}/${create_time + '_' + index + fileInfo.ext}`;
  186. // 保存文件
  187. await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
  188. await sendToWormhole(stream);
  189. // 插入到stage_pay对应的附件列表中
  190. uploadfiles.push({
  191. filename: fileInfo.name,
  192. fileext: fileInfo.ext,
  193. filesize: Array.isArray(parts.field.size) ? parts.field.size[index] : parts.field.size,
  194. filepath,
  195. });
  196. ++index;
  197. if (Array.isArray(parts.field.size) && index < parts.field.size.length) {
  198. stream = await parts();
  199. } else {
  200. stream = undefined;
  201. }
  202. }
  203. const result = await ctx.service.file.addFiles(filing, uploadfiles, user);
  204. ctx.body = {err: 0, msg: '', data: result };
  205. } catch (error) {
  206. ctx.helper.log(error);
  207. // 失败需要消耗掉stream 以防卡死
  208. if (stream) await sendToWormhole(stream);
  209. ctx.body = this.ajaxErrorBody(error, '上传附件失败,请重试');
  210. }
  211. }
  212. async delFile(ctx) {
  213. try{
  214. const data = JSON.parse(ctx.request.body.data);
  215. if (!data.del) throw '缺少参数';
  216. const result = await ctx.service.file.delFiles(data.del);
  217. ctx.body = { err: 0, msg: '', data: result };
  218. } catch(error) {
  219. this.log(error);
  220. ctx.ajaxErrorBody(error, '删除附件失败');
  221. }
  222. }
  223. async saveFile(ctx) {
  224. try {
  225. const data = JSON.parse(ctx.request.body.data);
  226. if (!data.id) throw '缺少参数';
  227. const result = await ctx.service.file.saveFile(data.id, data.filename);
  228. ctx.body = { err: 0, msg: '', data: result };
  229. } catch (error) {
  230. this.log(error);
  231. ctx.ajaxErrorBody(error, '编辑附件失败');
  232. }
  233. }
  234. async moveFile(ctx) {
  235. try {
  236. const data = JSON.parse(ctx.request.body.data);
  237. if (!data.id || !data.filingId) throw '缺少参数';
  238. const result = await ctx.service.file.moveFile(data.id, data.filingId);
  239. ctx.body = { err: 0, msg: '', data: result };
  240. } catch (error) {
  241. this.log(error);
  242. ctx.ajaxErrorBody(error, '编辑附件失败');
  243. }
  244. }
  245. async uploadBigFile(ctx) {
  246. try {
  247. await this.checkCanUpload(ctx);
  248. const data = JSON.parse(ctx.request.body.data);
  249. if (!data.type || !data.filing_id || !data.fileInfo) throw '缺少参数';
  250. const filing = await ctx.service.filing.getDataById(data.filing_id);
  251. if (!filing || filing.is_deleted) throw '分类不存在,请刷新页面后重试';
  252. let result;
  253. const fileInfo = path.parse(data.fileInfo.filename);
  254. switch(data.type) {
  255. case 'begin':
  256. const create_time = Date.parse(new Date()) / 1000;
  257. result = {
  258. filename: `sp/file/${filing.spid}/${ctx.moment().format('YYYYMMDD')}/${create_time + '_' + fileInfo.ext}`,
  259. };
  260. result.filepath = ctx.app.config.fujianOssFolder + result.filename;
  261. // todo 写入ossToken
  262. result.oss = await ctx.helper.getOssToken(ctx.app.fujianOss);
  263. break;
  264. case 'end':
  265. const user = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
  266. const uploadFiles = [{
  267. filepath: data.filepath,
  268. filename: fileInfo.name, fileext: fileInfo.ext, filesize: data.fileInfo.filesize,
  269. }];
  270. result = await ctx.service.file.addFiles(filing, uploadFiles, user);
  271. break;
  272. }
  273. ctx.body = {err: 0, msg: '', data: result };
  274. } catch (error) {
  275. ctx.log(error);
  276. ctx.body = this.ajaxErrorBody(error, '上传附件失败,请重试');
  277. }
  278. }
  279. async loadValidRelaTender(ctx) {
  280. try {
  281. const data = JSON.parse(ctx.request.body.data);
  282. if (data.type) throw '参数错误';
  283. const accountInfo = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
  284. const userPermission = accountInfo !== undefined && accountInfo.permission !== ''
  285. ? JSON.parse(accountInfo.permission) : null;
  286. const tenderList = await ctx.service.tender.getList('', userPermission, ctx.session.sessionUser.is_admin);
  287. const rela_tender = await ctx.subProject.rela_tender.split(',');
  288. const result = tenderList.filter(x => { return rela_tender.indexOf(x.id + '') >= 0});
  289. for (const r of result) {
  290. r.advance = await ctx.service.advance.getAllDataByCondition({ columns: ['id', 'order', 'type'], where: { tid: r.id }});
  291. r.advance.forEach(a => {
  292. const type = advanceConst.typeCol.find(x => { return x.type === a.type });
  293. if (type) a.type_str = type.name;
  294. });
  295. r.stage = await ctx.service.stage.getAllDataByCondition({ columns: ['id', 'order'], where: { tid: r.id, status: auditConst.stage.status.checked } });
  296. }
  297. ctx.body = {err: 0, msg: '', data: result };
  298. } catch (error) {
  299. ctx.helper.log(error);
  300. ctx.body = this.ajaxErrorBody(error, '加载标段信息失败');
  301. }
  302. }
  303. async _loadLedgerAtt(data) {
  304. if (!data.tender_id) throw '参数错误';
  305. return await this.ctx.service.ledgerAtt.getAllDataByCondition({ where: { tid: data.tender_id }, order: [['id', 'desc']]});
  306. }
  307. async _loadStageAtt(data) {
  308. if (!data.tender_id || !data.stage) throw '参数错误';
  309. switch (data.sub_type) {
  310. case 'att':
  311. const stage = await this.ctx.service.stage.getDataById(data.stage);
  312. return await this.ctx.service.stageAtt.getAllDataByCondition({ where: { tid: data.tender_id, sid: stage.order }, order: [['id', 'desc']]});
  313. }
  314. }
  315. async _loadAdvanceAtt(data) {
  316. if (!data.stage) throw '参数错误';
  317. const self = this;
  318. const result = await this.ctx.service.advanceFile.getAllDataByCondition({ where: { vid: data.stage }, order: [['id', 'desc']]});
  319. result.forEach(x => {
  320. const info = path.parse(x.filename);
  321. x.filename = info.name;
  322. x.filesize = self.ctx.helper.sizeToBytes(x.filesize);
  323. });
  324. return result;
  325. }
  326. async loadRelaFiles(ctx) {
  327. try {
  328. const data = JSON.parse(ctx.request.body.data);
  329. if (!data.type) throw '参数错误';
  330. let files;
  331. switch(data.type) {
  332. case 'ledger':
  333. files = await this._loadLedgerAtt(data);
  334. break;
  335. case 'stage':
  336. files = await this._loadStageAtt(data);
  337. break;
  338. case 'advance':
  339. files = await this._loadAdvanceAtt(data);
  340. break;
  341. default: throw '未知文件类型';
  342. }
  343. ctx.body = {err: 0, msg: '', data: files };
  344. } catch (error) {
  345. ctx.helper.log(error);
  346. ctx.body = this.ajaxErrorBody(error, '加载附件失败,请重试');
  347. }
  348. }
  349. async relaFile(ctx) {
  350. try {
  351. const data = JSON.parse(ctx.request.body.data);
  352. if (!data.filing_id || !data.files) throw '缺少参数';
  353. const user = await ctx. service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
  354. const filing = await ctx.service.filing.getDataById(data.filing_id);
  355. if (!filing || filing.is_deleted) throw '分类不存在,请刷新页面后重试';
  356. await this.checkFiling(filing);
  357. const result = await ctx.service.file.relaFiles(filing, data.files, user);
  358. ctx.body = {err: 0, msg: '', data: result };
  359. } catch (error) {
  360. ctx.helper.log(error);
  361. ctx.body = this.ajaxErrorBody(error, '导入附件失败,请重试');
  362. }
  363. }
  364. async template(ctx) {
  365. const defaultTemplate = await ctx.service.filingTemplateList.getOriginTemplate();
  366. ctx.redirect('/file/template/' + defaultTemplate.id);
  367. }
  368. async templateDetail(ctx) {
  369. try {
  370. const renderData = {
  371. jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.file.template),
  372. };
  373. renderData.templateList = await ctx.service.filingTemplateList.getAllTemplate(ctx.session.sessionProject.id);
  374. renderData.shareTemplate = await ctx.service.filingTemplateList.getShareTemplate(ctx.session.sessionProject.id);
  375. renderData.FtType = ctx.service.filingTemplateList.FtType;
  376. renderData.template = renderData.templateList.find(x => { return x.id === ctx.params.id });
  377. if (!renderData.template) throw '查看的资料模板不存在';
  378. renderData.templateData = await ctx.service.filingTemplate.getData(renderData.template.id);
  379. await this.layout('file/template.ejs', renderData, 'file/template_modal.ejs');
  380. } catch (err) {
  381. ctx.log(err);
  382. ctx.session.postError = err.toString();
  383. ctx.redirect(this.menu.menu.dashboard.url);
  384. }
  385. }
  386. async saveTemplate(ctx) {
  387. try {
  388. const id = ctx.query.id;
  389. const name = ctx.request.body.name;
  390. const is_share = ctx.request.body.is_share ? parseInt(ctx.request.body.is_share) : undefined;
  391. const share_id = ctx.request.body.share_id;
  392. const [save, templateId] = share_id ? await ctx.service.filingTemplateList.copy(share_id) : await ctx.service.filingTemplateList.save(name, is_share, id);
  393. if (!save) throw '保存数据失败';
  394. ctx.redirect('/file/template/' + templateId);
  395. } catch(err) {
  396. ctx.log(err);
  397. ctx.session.postError = err.toString();
  398. ctx.redirect('/file/template');
  399. }
  400. }
  401. async resetTemplate(ctx) {
  402. try {
  403. const id = ctx.query.id;
  404. await ctx.service.filingTemplateList.reset(id);
  405. ctx.redirect('/file/template/' + id);
  406. } catch (err) {
  407. ctx.log(err);
  408. ctx.postError(err, '重置模板失败');
  409. ctx.redirect('/file/template');
  410. }
  411. }
  412. async delTemplate(ctx) {
  413. try {
  414. const id = ctx.query.id;
  415. await ctx.service.filingTemplateList.delete(id);
  416. console.log(ctx.request.headers.referer, id);
  417. if (ctx.request.headers.referer.indexOf(id) > 0) {
  418. ctx.redirect('/file/template');
  419. } else {
  420. ctx.redirect(ctx.request.headers.referer);
  421. }
  422. } catch (err) {
  423. ctx.log(err);
  424. ctx.postError(err, '删除模板失败');
  425. ctx.redirect('/file/template');
  426. }
  427. }
  428. async updateTemplate(ctx) {
  429. try {
  430. const data = JSON.parse(ctx.request.body.data);
  431. if (!data.updateType) throw '数据错误';
  432. let result;
  433. if (data.updateType === 'add') {
  434. result = await ctx.service.filingTemplate.add(ctx.params.id, data);
  435. } else if (data.updateType === 'del') {
  436. result = await ctx.service.filingTemplate.del(ctx.params.id, data);
  437. } else if (data.updateType === 'save') {
  438. result = await ctx.service.filingTemplate.save(data);
  439. } else if (data.updateType === 'move') {
  440. if (!data.id || !(data.tree_order >= 0)) throw '数据错误';
  441. result = await ctx.service.filingTemplate.move(ctx.params.id, data);
  442. } else if (data.updateType === 'import') {
  443. result = await ctx.service.filingTemplate.import(ctx.params.id, data.data);
  444. } else if (data.updateType === 'multi' ) {
  445. result = await ctx.service.filingTemplate.multiUpdate(ctx.params.id, data.data);
  446. }
  447. ctx.body = { err: 0, msg: '', data: result };
  448. } catch (err) {
  449. ctx.log(err);
  450. ctx.ajaxErrorBody(err, '修改失败');
  451. }
  452. }
  453. async search(ctx) {
  454. try {
  455. const limit = 1000;
  456. const data = JSON.parse(ctx.request.body.data);
  457. if (!data.filing_type || !data.keyword) throw '数据错误';
  458. const validFilingType = [];
  459. for (const f of data.filing_type) {
  460. if (ctx.subProject.permission.filing_type === 'all' || ctx.subProject.permission.filing_type.indexOf(f) >= 0) validFilingType.push(f);
  461. }
  462. const result = await ctx.service.file.search(validFilingType, data.keyword, limit);
  463. ctx.body = { err: 0, msg: '', data: { list: result, limit } };
  464. } catch(err) {
  465. ctx.log(err);
  466. ctx.ajaxErrorBody(err, '搜索文件失败');
  467. }
  468. }
  469. async manage(ctx) {
  470. try {
  471. const renderData = {
  472. jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.file.manage),
  473. };
  474. renderData.filingData = await ctx.service.filing.getValidFiling(ctx.params.id, ctx.subProject.permission.filing_type);
  475. const permissionData = await ctx.service.subProjPermission.getFilingType(ctx.subProject.id);
  476. permissionData.forEach(x => { x.filing_type = x.filing_type.split(','); });
  477. renderData.filingData.forEach(x => {
  478. if (!x.is_fixed) {
  479. x.permission_count = 0;
  480. } else {
  481. const rela = permissionData.filter(y => { return y.filing_type.indexOf(x.filing_type + '') >= 0; });
  482. x.permission_count = rela.length;
  483. }
  484. });
  485. await this.layout('file/manage.ejs', renderData, 'file/manage_modal.ejs');
  486. } catch (err) {
  487. ctx.log(err);
  488. ctx.session.postError = err.toString();
  489. ctx.redirect(this.menu.menu.dashboard.url);
  490. }
  491. }
  492. async lockFiling(ctx) {
  493. try {
  494. await ctx.service.subProject.save({ id: ctx.subProject.id, lock_file: ctx.query.lock });
  495. ctx.redirect(`/sp/${ctx.subProject.id}/fm`);
  496. } catch(err) {
  497. ctx.log(err);
  498. ctx.postError(err, '资料归集分类锁定错误');
  499. ctx.redirect(`/sp/${ctx.subProject.id}/fm`);
  500. }
  501. }
  502. async manageUpdate(ctx) {
  503. try {
  504. this.checkLock(ctx);
  505. const data = JSON.parse(ctx.request.body.data);
  506. if (!data.updateType) throw '数据错误';
  507. let result;
  508. const updateData = JSON.parse(JSON.stringify(data));
  509. delete updateData.updateType;
  510. if (data.updateType === 'add') {
  511. result = await ctx.service.filing.add(updateData);
  512. } else if (data.updateType === 'del') {
  513. result = await ctx.service.filing.del(updateData);
  514. } else if (data.updateType === 'save') {
  515. result = await ctx.service.filing.save(updateData);
  516. } else if (data.updateType === 'move') {
  517. if (!data.id || !(data.tree_order >= 0)) throw '数据错误';
  518. result = await ctx.service.filing.move(updateData);
  519. } else if (data.updateType === 'multi' ) {
  520. result = await ctx.service.filing.multiUpdate(ctx.subProject.id, data.data);
  521. }
  522. ctx.body = { err: 0, msg: '', data: result };
  523. } catch (err) {
  524. ctx.log(err);
  525. ctx.ajaxErrorBody(err, '修改失败');
  526. }
  527. }
  528. }
  529. return FileController;
  530. };