SecurityFilePic.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  1. <template>
  2. <!-- 文件分类 -->
  3. <div class="ListOfDocument">
  4. <div class="box">
  5. <div class="icore-graphical-index" :style="'width: 100%;height:'+chart.height">
  6. <div class="icore-graphical-area" ref="graphical-area"></div>
  7. </div>
  8. </div>
  9. <el-dialog
  10. title="文件预览"
  11. :visible.sync="dialogVisible"
  12. destroy-on-close
  13. width="90%"
  14. top="10vh">
  15. <el-button
  16. size="small"
  17. type="primary"
  18. icon="el-icon-download"
  19. v-privilege="activeMenu + 'DOWNLOAD'"
  20. @click="downloadFile(chart.fileData)"
  21. :loading="loading"
  22. style="position: absolute; right: 100px; top: 20px;"
  23. >点击保存
  24. </el-button>
  25. <iframe :src="previewUrl" width="100%" :height="singleTableHeight"></iframe>
  26. </el-dialog>
  27. <zj-formulaEditor :equationEditing="dialog.equationEditing"></zj-formulaEditor>
  28. </div>
  29. </template>
  30. <script>
  31. import formulaEditor from '~/components/zg/formulaEditor.vue';
  32. import { zCheckNumber1 } from '~/utils/validator.js';
  33. import { formatDate } from '@/utils/util.js';
  34. import store from '@/store/index.js';
  35. export default {
  36. name: 'ListOfDocument',
  37. components: {
  38. 'zj-formulaEditor': formulaEditor
  39. },
  40. props: {
  41. width: {
  42. type: [Number, String],
  43. default: '100%'
  44. },
  45. height: {
  46. type: [Number, String],
  47. default: '100%'
  48. }
  49. },
  50. data () {
  51. return {
  52. multipleSelection: [],
  53. tableFormDataObj: {},
  54. activeMenu: '',
  55. form: {
  56. imgSavePath: ''
  57. },
  58. filterForm: {
  59. show: true,
  60. data: {
  61. uploadFileid: '',
  62. securityTypeid: '',
  63. securityTag: '',
  64. isprimary: '',
  65. version: formatDate(new Date(), 'yyyyMM00'),
  66. fileName: '',
  67. pattern: 'table'
  68. },
  69. rules: {
  70. },
  71. file: ''
  72. },
  73. listTopicTree: {
  74. show: true,
  75. loading: false,
  76. data: [],
  77. defaultProps: {
  78. children: 'children',
  79. label: 'securityName'
  80. }
  81. },
  82. pageNum: 1,
  83. pageSize: 20,
  84. total: 0,
  85. singleTableHeight: '720px',
  86. tableData: [
  87. ],
  88. nameObj: {
  89. uploadFile: {
  90. obj: {},
  91. arr: []
  92. },
  93. securityType: {
  94. obj: {},
  95. arr: []
  96. },
  97. unitid: {
  98. obj: {},
  99. arr: []
  100. },
  101. roleList: {
  102. obj: {},
  103. arr: []
  104. }, // 角色信息
  105. securityTag: {
  106. obj: {},
  107. arr: []
  108. },
  109. pattern: {
  110. obj: {
  111. 'graphical': '图例',
  112. 'table': '表格'
  113. },
  114. arr: [
  115. {
  116. id: 'graphical',
  117. name: '图例'
  118. },
  119. {
  120. id: 'table',
  121. name: '表格'
  122. }
  123. ]
  124. }
  125. },
  126. loading: false,
  127. tableLoading: false,
  128. dialog: {
  129. editorBox: {
  130. show: false,
  131. fileType: '',
  132. form: {
  133. default: {
  134. workprocid: ''
  135. },
  136. data: {
  137. itemid: '',
  138. productid: '',
  139. workprocid: '',
  140. isprimary: '0',
  141. unitid: '',
  142. seqno: '',
  143. code: '',
  144. fileType: ''
  145. },
  146. rules: {
  147. productid: [
  148. { required: true, message: '该项不能为空', trigger: 'change' }
  149. ],
  150. workprocid: [
  151. { required: true, message: '该项不能为空', trigger: 'change' }
  152. ],
  153. seqno: [
  154. { validator: zCheckNumber1, trigger: 'change' }
  155. ]
  156. }
  157. }
  158. },
  159. equationEditing: {
  160. show: false,
  161. form: {
  162. data: {
  163. clock: '',
  164. code: ''
  165. }
  166. }
  167. }
  168. },
  169. store,
  170. userInfo: {}, // 用户信息
  171. qrRole: [],
  172. userRoles: [],
  173. dialogVisible: false,
  174. previewUrl: '',
  175. chart: {
  176. height: '1024px',
  177. show: false,
  178. fileData: {
  179. fileName: '',
  180. fileUrl: ''
  181. },
  182. option: {
  183. title: {
  184. text: ''
  185. },
  186. tooltip: {
  187. trigger: 'item',
  188. triggerOn: 'mousemove'
  189. },
  190. toolbox: {
  191. feature: {
  192. saveAsImage: {}
  193. }
  194. },
  195. series: [
  196. {
  197. type: 'tree',
  198. data: [],
  199. top: '2%',
  200. left: '25%',
  201. bottom: '1%',
  202. right: '20%',
  203. symbolSize: 8,
  204. nodePadding: 50,
  205. label: {
  206. position: 'left',
  207. verticalAlign: 'bottom',
  208. align: 'right',
  209. fontSize: 14
  210. },
  211. leaves: {
  212. label: {
  213. position: 'right',
  214. verticalAlign: 'middle',
  215. align: 'left'
  216. }
  217. },
  218. emphasis: {
  219. focus: 'descendant'
  220. },
  221. initialTreeDepth: 2,
  222. expandAndCollapse: true,
  223. animationDuration: 550,
  224. animationDurationUpdate: 750,
  225. roam: true
  226. }
  227. ]
  228. }
  229. }
  230. }
  231. },
  232. created () {
  233. this.activeMenu = window.localStorage.getItem('activeMenu');
  234. },
  235. computed: {
  236. indiviadualStyle: function() {
  237. return (
  238. "width:" +
  239. (typeof this.width === "string" &&
  240. this.width.indexOf("%") !== -1
  241. ? this.width
  242. : parseFloat(this.width) + "px") +
  243. ";height:" +
  244. (typeof this.height === "string" &&
  245. this.height.indexOf("%") !== -1
  246. ? this.height
  247. : parseFloat(this.height) + "px")
  248. );
  249. }
  250. },
  251. mounted () {
  252. let that = this;
  253. window.PEDataObj = {
  254. // 将数据绑定到window上,供main页面使用
  255. vm: that,
  256. // tableArr:用于导出成Excel的表格的信息
  257. tableArr: [
  258. {
  259. name: '',
  260. id: 'singleTable'
  261. }
  262. ]
  263. };
  264. // that.$nextTick(() => {
  265. // // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  266. // setTimeout(() => {
  267. // that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
  268. // }, 1);
  269. // });
  270. // // that.getNodeData();
  271. // // that.getNodeTreeData();
  272. // that.getUploadFileData();
  273. // that.getUnitIdData();
  274. // // that.getTableData();
  275. // that.getRoles();
  276. that.getFileTreeData();
  277. },
  278. methods: {
  279. // 计算树区域高度
  280. getRoleHeight (dom) {
  281. return window.innerHeight - dom.offsetTop;
  282. },
  283. // 获取文件类型列表
  284. getNodeData () {
  285. let that = this
  286. let url = 'pass/ems/v1/securitytypes/getIdAndName/?securityInfo=' + that.qrRole;
  287. that.axios.get(url)
  288. .then(function (res) {
  289. if (res.code === '0') {
  290. let arr = [];
  291. let obj = {};
  292. for (let item of res.data) {
  293. arr.push({
  294. id: item.id,
  295. name: item.securityName
  296. })
  297. obj[item.id] = item.securityName;
  298. }
  299. that.nameObj.securityType.arr = arr;
  300. that.nameObj.securityType.obj = obj;
  301. console.log(that.nameObj.securityType)
  302. } else {
  303. that.$message.error(res.message);
  304. }
  305. });
  306. },
  307. // 获取工序节点树(产出)
  308. getNodeTreeData () {
  309. let that = this
  310. let url = 'pass/ems/v1/securitytypes/gettree/?securityInfo=' + that.qrRole;
  311. that.listTopicTree.loading = true;
  312. that.axios.get(url)
  313. .then(function (res) {
  314. if (res.code === '0') {
  315. that.listTopicTree.data = [{
  316. id: '',
  317. securityName: '所有记录',
  318. children: res.data
  319. }];
  320. that.getTableData();
  321. } else {
  322. that.$message.error(res.message);
  323. }
  324. that.listTopicTree.loading = false;
  325. }).catch(function () {
  326. that.listTopicTree.loading = false;
  327. });
  328. },
  329. // 获取产品
  330. getUploadFileData () {
  331. let that = this
  332. let url = 'pass/ems/v1/uploadfiles/getIdAndName';
  333. that.axios.get(url)
  334. .then(function (res) {
  335. if (res.code === '0') {
  336. let arr = [];
  337. let obj = {};
  338. for (let item of res.data) {
  339. arr.push({
  340. id: item.id,
  341. name: item.fileName
  342. })
  343. obj[item.id] = item.fileName;
  344. }
  345. that.nameObj.uploadFile.arr = arr;
  346. that.nameObj.uploadFile.obj = obj;
  347. } else {
  348. that.$message.error(res.message);
  349. }
  350. });
  351. },
  352. // 获取标准计量单位
  353. getUnitIdData () {
  354. let that = this
  355. let url = 'pass/ems/v1/trmunits/getIdAndName';
  356. that.axios.get(url)
  357. .then(function (res) {
  358. if (res.code === '0') {
  359. let arr = [];
  360. let obj = {};
  361. for (let item of res.data) {
  362. arr.push({
  363. id: item.id,
  364. name: item.name
  365. })
  366. obj[item.id] = item.name;
  367. if (item.name === '吨') {
  368. that.nameObj.unitid.defaults = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : item.id;
  369. }
  370. }
  371. that.nameObj.unitid.arr = arr;
  372. that.nameObj.unitid.obj = obj;
  373. } else {
  374. that.$message.error(res.message);
  375. }
  376. });
  377. },
  378. // 获取表格中的数据
  379. getTableData (pageNum) {
  380. let that = this,
  381. params = {
  382. fileName: that.filterForm.data.fileName,
  383. type: that.filterForm.data.securityTypeid,
  384. fileType: that.filterForm.data.securityTag.toString()
  385. };
  386. that.pageNum = pageNum || that.pageNum;
  387. that.tableLoading = true;
  388. let url = 'pass/ems/v1/uploadfiles/like/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize + '&securityInfo=' + that.qrRole;
  389. that.axios.get(url, {
  390. params: params
  391. })
  392. .then(function (res) {
  393. if (res.code === '0') {
  394. let arr = [];
  395. let map = {};
  396. let fileTypeArr = [];
  397. let fileTypeStr = '';
  398. let total = 0;
  399. for (let item of that.listTopicTree.data[0].children) {
  400. map[item.id] = true;
  401. }
  402. for (let item of res.data.list) {
  403. let result = true;
  404. fileTypeArr = [];
  405. // // result = item.type.some(i => map[i]);
  406. // if (that.qrRole.length > 0) {
  407. // result = map.hasOwnProperty(item.type);
  408. // }
  409. // if (result) {
  410. if (item.fileType !== null) {
  411. fileTypeArr = item.fileType.split(';');
  412. fileTypeStr += item.fileType + ';'
  413. }
  414. total++;
  415. arr.push({
  416. ID: item.id,
  417. fileName: item.fileName,
  418. fileUrl: item.fileUrl,
  419. type: item.type,
  420. fileType: fileTypeArr,
  421. uploadTime: item.uploadTime,
  422. createMan: item.createMan,
  423. createTime: item.createTime,
  424. updateMan: item.updateMan,
  425. updateTime: item.updateTime,
  426. showInput: false,
  427. inputValue: ''
  428. })
  429. // }
  430. }
  431. if (that.nameObj.securityTag.arr.length <= 0) {
  432. fileTypeStr = fileTypeStr.substr(0, fileTypeStr.length - 1);
  433. that.nameObj.securityTag.arr = Array.from(new Set(fileTypeStr.split(';')));
  434. }
  435. that.tableData = arr;
  436. that.total = res.data.total;
  437. } else {
  438. that.$message.error(res.message);
  439. }
  440. that.getFileTreeData ();
  441. that.tableLoading = false;
  442. }).catch(function () {
  443. that.tableLoading = false;
  444. });
  445. },
  446. // 改变表格显示条数
  447. tableSizeChange (val) {
  448. let that = this;
  449. that.pageSize = val;
  450. that.getTableData(1);
  451. },
  452. // 重置搜索
  453. tableDataCancel () {
  454. let that = this;
  455. that.filterForm.data.workprocid = '';
  456. that.filterForm.data.productid = '';
  457. that.filterForm.data.version = '';
  458. that.getTableData(1);
  459. },
  460. // 表格中多选按钮的相关方法
  461. handleSelectionChange (val) {
  462. let that = this;
  463. let tableFormDataObj = {};
  464. for (let item of that.tableData) {
  465. item.isSelection = false;
  466. }
  467. for (let item of val) {
  468. let obj = {};
  469. let xId = item.ID;
  470. if (that.tableFormDataObj[xId]) {
  471. tableFormDataObj[xId] = that.tableFormDataObj[xId];
  472. } else {
  473. for (let key in item) {
  474. obj[key] = item[key];
  475. }
  476. tableFormDataObj[xId] = obj;
  477. }
  478. item.isSelection = true;
  479. }
  480. that.tableFormDataObj = JSON.parse(JSON.stringify(tableFormDataObj));
  481. that.multipleSelection = val;
  482. },
  483. but_add () {
  484. let that = this;
  485. if (!that.dialog.editorBox.form.default.workprocid) {
  486. that.$message.error('请先选择左侧的详细工序');
  487. return;
  488. }
  489. that.dialog.editorBox.form.data.itemid = '';
  490. that.dialog.editorBox.form.data.productid = '';
  491. that.dialog.editorBox.form.data.workprocid = that.dialog.editorBox.form.default.workprocid;
  492. that.dialog.editorBox.form.data.isprimary = '0';
  493. that.dialog.editorBox.form.data.unitid = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : '';
  494. that.dialog.editorBox.form.data.seqno = '';
  495. that.dialog.editorBox.form.data.code = '0';
  496. that.dialog.editorBox.type = 'add';
  497. that.dialog.editorBox.show = true;
  498. setTimeout(() => {
  499. that.$refs['dialog_form'].clearValidate();
  500. }, 100);
  501. },
  502. beforeUpload (file) {
  503. let that = this;
  504. that.tableLoading = true;
  505. that.loading = true;
  506. let foorData = new FormData();
  507. foorData.append('file', file.file);
  508. foorData.append('type', this.filterForm.data.securityTypeid);
  509. that.axios.post('pass/ems/v1/uploadfiles/file', foorData, {
  510. headers: {
  511. 'Content-Type': 'multipart/form-data'
  512. }
  513. }).then(function (res) {
  514. if (res.code === '0') {
  515. that.$message({
  516. message: '上传成功',
  517. type: 'success'
  518. });
  519. that.$refs.upload.clearFiles();
  520. that.$refs.upload1.clearFiles();
  521. that.getTableData(1);
  522. that.dialog.editorBox.show = false;
  523. } else {
  524. that.$message.error(res.message);
  525. }
  526. that.tableLoading = false;
  527. that.loading = false;
  528. }).catch(function () {
  529. that.$message({
  530. message: '上传失败,FTP服务器可能已断开连接',
  531. type: 'success'
  532. });
  533. that.tableLoading = false;
  534. that.loading = false;
  535. });
  536. },
  537. submitUpload () {
  538. let that = this;
  539. this.$refs.upload.submit();
  540. this.$refs.upload1.submit();
  541. },
  542. handleRemove (file, fileList) {
  543. console.log(file, fileList);
  544. },
  545. // 行内标签删除
  546. rowhandleClose (tag, row) {
  547. let that = this;
  548. that.tableFormDataObj[row.ID].fileType.splice(that.tableFormDataObj[row.ID].fileType.indexOf(tag), 1);
  549. },
  550. // 行内标签新增
  551. rowhandleInputConfirm (row) {
  552. let that = this;
  553. let inputValue = that.tableFormDataObj[row.ID].inputValue;
  554. if (inputValue) {
  555. that.tableFormDataObj[row.ID].fileType.push(inputValue);
  556. }
  557. that.tableFormDataObj[row.ID].showInput = false;
  558. that.tableFormDataObj[row.ID].inputValue = '';
  559. },
  560. // 行内input获取焦点
  561. rowshowInput (row) {
  562. let that = this;
  563. that.tableFormDataObj[row.ID].showInput = true;
  564. let id = row.ID + '-saveTagInput';
  565. setTimeout(function(){
  566. that.$nextTick(() => {
  567. // that.$refs[id].$refs.input.focus();
  568. that.$refs[id].focus();
  569. });
  570. },50)
  571. },
  572. handlePreview (file) {
  573. console.log(file);
  574. },
  575. // 批量修改
  576. but_edit_plural () {
  577. let that = this;
  578. if (that.multipleSelection.length > 0) {
  579. that.$refs['dialog_form_arr'].validate((valid) => {
  580. if (valid) {
  581. let SubmitData = [];
  582. for (let key in that.tableFormDataObj) {
  583. let fileTypes = '';
  584. for (let item in that.tableFormDataObj[key].fileType) {
  585. if (Number(item) === that.tableFormDataObj[key].fileType.length - 1) {
  586. fileTypes += that.tableFormDataObj[key].fileType[item];
  587. } else {
  588. fileTypes += that.tableFormDataObj[key].fileType[item] + ';';
  589. }
  590. }
  591. SubmitData.push({
  592. Id: that.tableFormDataObj[key].ID,
  593. fileType: fileTypes,
  594. seqno: that.tableFormDataObj[key].seqno
  595. });
  596. }
  597. that.loading = true;
  598. that.axios.put('pass/ems/v1/uploadfiles/batchupdate', SubmitData)
  599. .then(function (res) {
  600. if (res.code === '0') {
  601. that.$message({
  602. message: '修改成功',
  603. type: 'success'
  604. });
  605. that.getTableData();
  606. that.dialog.editorBox.show = false;
  607. } else {
  608. that.$message.error(res.message);
  609. }
  610. that.loading = false;
  611. }).catch(function () {
  612. that.loading = false;
  613. });
  614. }
  615. });
  616. } else {
  617. this.$message.error('至少要选择一条数据');
  618. }
  619. },
  620. // 批量删除
  621. but_del_plural () {
  622. let that = this;
  623. that.loading = true;
  624. if (that.multipleSelection.length > 0) {
  625. let ids = [];
  626. let paths = [];
  627. for (let item of that.multipleSelection) {
  628. ids.push(item.ID);
  629. paths.push(item.fileUrl);
  630. }
  631. that.$confirm('是否删除已选数据?', '提示', {
  632. confirmButtonText: '确定',
  633. cancelButtonText: '取消',
  634. state: 'warning'
  635. }).then(() => {
  636. that.axios.delete('pass/ems/v1/uploadfiles/' + ids.toString())
  637. .then(function (res) {
  638. if (res.code === '0') {
  639. that.$message({
  640. message: '删除成功',
  641. type: 'success'
  642. });
  643. that.getTableData();
  644. that.loading = false;
  645. } else {
  646. if (res.code === '51') {
  647. }
  648. that.$message.error(res.message);
  649. }
  650. that.loading = false;
  651. }).catch(function () {
  652. that.loading = false;
  653. });
  654. }).catch(() => {
  655. that.loading = false;
  656. });
  657. } else {
  658. this.$message.error('至少要选择一条数据');
  659. that.loading = false;
  660. }
  661. },
  662. dataSave () {
  663. let that = this;
  664. let SubmitData = {
  665. itemid: that.dialog.editorBox.form.data.itemid,
  666. productid: that.dialog.editorBox.form.data.productid,
  667. workprocid: that.dialog.editorBox.form.data.workprocid,
  668. isprimary: that.dialog.editorBox.form.data.isprimary,
  669. unitid: that.dialog.editorBox.form.data.unitid,
  670. seqno: that.dialog.editorBox.form.data.seqno,
  671. code: that.dialog.editorBox.form.data.code,
  672. itemtype: 'P'
  673. };
  674. that.$refs['dialog_form'].validate((valid) => {
  675. if (valid) {
  676. if (that.dialog.editorBox.type === 'add') {
  677. that.loading = true;
  678. that.axios.post('pass/ems/v1/trmworkprocproducts/', SubmitData, {
  679. contentType: 'application/json'
  680. })
  681. .then(function (res) {
  682. if (res.code === '0') {
  683. that.$message({
  684. message: '新增成功',
  685. type: 'success'
  686. });
  687. that.getTableData();
  688. that.dialog.editorBox.show = false;
  689. } else {
  690. that.$message.error(res.message);
  691. }
  692. that.loading = false;
  693. }).catch(function () {
  694. that.loading = false;
  695. });
  696. } else {
  697. that.loading = true;
  698. that.axios.put('pass/ems/v1/trmworkprocproducts/' + SubmitData.itemid, SubmitData)
  699. .then(function (res) {
  700. if (res.code === '0') {
  701. that.$message({
  702. message: '修改成功',
  703. type: 'success'
  704. });
  705. that.getTableData();
  706. that.dialog.editorBox.show = false;
  707. } else {
  708. that.$message.error(res.message);
  709. }
  710. that.loading = false;
  711. }).catch(function () {
  712. that.loading = false;
  713. });
  714. }
  715. }
  716. });
  717. },
  718. but_equationEditing (row) {
  719. let that = this;
  720. that.dialog.equationEditing.form.data.clock = that.filterForm.data.version;
  721. that.dialog.equationEditing.form.data.code = row.itemid;
  722. that.dialog.equationEditing.show = true;
  723. },
  724. selectByTopicId (data) {
  725. let that = this;
  726. that.filterForm.data.securityTypeid = data.id;
  727. that.getTableData(1);
  728. },
  729. getRoles () {
  730. let that = this;
  731. // 获取用户信息
  732. this.store.dispatch('getUserInfo').then((res) => {
  733. this.userInfo = res.data;
  734. that.axios.get('pass/v1/sysuserroles/?userId=' + res.data.userId + '&pageNum=1&pageSize=100').then(rest => {
  735. if (rest) {
  736. for (let i = 0; i < rest.data.list.length; i++) {
  737. that.qrRole.push(rest.data.list[i].roleId)
  738. }
  739. that.userRoles = rest.data.list; // 获取用户角色关联信息
  740. }
  741. that.getNodeData();
  742. that.getNodeTreeData();
  743. })
  744. });
  745. // 获取角色信息
  746. this.store.dispatch('system/rolesManage/list').then(res => {
  747. if (res.code === '0') {
  748. this.nameObj.roleList.arr = res.data;
  749. for (let obj of res.data) {
  750. this.nameObj.roleList.obj[obj.id] = {
  751. name: obj.roleName,
  752. id: obj.id
  753. };
  754. }
  755. } else {
  756. this.$message.error(res.message);
  757. }
  758. });
  759. },
  760. downloadFile (data) {
  761. let that = this;
  762. let SubmitData = {
  763. fileName: data.fileName,
  764. fileUrl: data.fileUrl
  765. };
  766. // 不带token访问方式,留底后端修改shiroconfig.java,application.properties
  767. // let url = '/icore.icp.web/pass/ems/v1/uploadfiles/downloadFile/?fileName=' + that.tableFormDataObj[key].fileName + '&fileUrl=' + that.tableFormDataObj[key].fileUrl;
  768. // const xhr = new XMLHttpRequest();
  769. // xhr.open('GET', url, true);
  770. // xhr.responseType = 'blob';
  771. // xhr.onload = () => {
  772. // if (xhr.status === 200) {
  773. // var fileName = that.tableFormDataObj[key].fileName;
  774. // // 获取文件blob数据并保存
  775. // that.saveAs(xhr.response, fileName);
  776. // }
  777. // };
  778. // xhr.send();
  779. that.loading = true;
  780. let urla = 'pass/ems/v1/uploadfiles/downloadFile/';
  781. that.axios.get(urla, {
  782. params: SubmitData,
  783. responseType: 'blob'
  784. }).then(function (res) {
  785. that.saveAs(res, data.fileName);
  786. that.$message({
  787. message: '下载成功',
  788. type: 'success'
  789. });
  790. that.loading = false;
  791. }).catch(function () {
  792. that.$message.error('下载失败');
  793. that.loading = false;
  794. })
  795. },
  796. // js实现文件下载而不直接打开
  797. saveAs (data, fileName) {
  798. this.loading = true;
  799. let urlObject = window.URL || window.webkitURL || window;
  800. // 将二进制流转为blob
  801. let exportBlob = new Blob([data]);
  802. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  803. // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
  804. window.navigator.msSaveBlob(exportBlob, decodeURI(fileName));
  805. this.loading = false;
  806. } else {
  807. // 创建新的URL并指向File对象或者Blob对象的地址
  808. let blobURL = urlObject.createObjectURL(exportBlob);
  809. let saveLink = document.createElement('a');
  810. // 兼容:某些浏览器不支持HTML5的download属性
  811. if (typeof saveLink.download === 'undefined') {
  812. saveLink.setAttribute('target', '_blank');
  813. } else {
  814. saveLink.download = fileName;
  815. }
  816. // 创建新的URL并指向File对象或者Blob对象的地址
  817. saveLink.href = blobURL;
  818. saveLink.click();
  819. // 释放blob URL地址
  820. urlObject.revokeObjectURL(exportBlob);
  821. this.loading = false;
  822. // let blob = new Blob([data])
  823. // let fileURL = urlObject.createObjectURL(blob);
  824. // 下载代码
  825. // let downEle = document.createElement('a')
  826. // let fname = `download` //下载文件的名字
  827. // downEle.href = fileURL
  828. // downEle.setAttribute('download', fname)
  829. // document.body.appendChild(downEle)
  830. // downEle.click()
  831. // window.open(fileURL);
  832. }
  833. },
  834. preview (data) {
  835. let that = this;
  836. that.loading = true;
  837. that.chart.fileData = data;
  838. let SubmitData = {
  839. fileName: data.fileName,
  840. fileUrl: data.fileUrl
  841. };
  842. let urla = 'pass/ems/v1/uploadfiles/getfile/';
  843. let type = 'text/html';
  844. let responseType = 'application/json';
  845. let fileExtension = data.fileName.substring(data.fileName.lastIndexOf('.') + 1);
  846. if (fileExtension === 'pdf') {
  847. urla = 'pass/ems/v1/uploadfiles/downloadFile/';
  848. type = 'application/pdf';
  849. responseType = 'blob';
  850. }
  851. that.tableLoading = true;
  852. that.axios.get(urla, {
  853. params: SubmitData,
  854. responseType: responseType
  855. }).then(function (res) {
  856. console.log('111');
  857. let urlObject = window.URL || window.webkitURL || window;
  858. // 将二进制流转为blob
  859. let blob = new Blob([res], {type: type});
  860. if (fileExtension !== 'pdf') {
  861. blob = new Blob([res.data], {type: type});
  862. }
  863. // if (typeof window.navigator.msSaveBlob !== 'undefined') {
  864. // // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
  865. // window.navigator.msSaveBlob(blob, decodeURI(fileName))
  866. // } else {
  867. // 创建新的URL并指向File对象或者Blob对象的地址
  868. let blobURL = urlObject.createObjectURL(blob);
  869. that.dialogVisible = true;
  870. that.previewUrl = blobURL;
  871. that.tableLoading = false;
  872. that.loading = false;
  873. // 'https://file.keking.cn/onlinePreview?url=' + encodeURIComponent(blobURL)
  874. // http://view.officeapps.live.com/op/view.aspx?src' + blobURL;
  875. // 创建a标签,用于跳转至下载链接
  876. // let tempLink = document.createElement('a')
  877. // tempLink.style.display = 'none'
  878. // tempLink.href = blobURL;
  879. // tempLink.setAttribute('download', decodeURI(fileName))
  880. // 兼容:某些浏览器不支持HTML5的download属性
  881. // if (typeof tempLink.download === 'undefined') {
  882. // tempLink.setAttribute('target', '_blank')
  883. // }
  884. // // 挂载a标签
  885. // document.body.appendChild(tempLink)
  886. // tempLink.click()
  887. // // 销毁a标签
  888. // document.body.removeChild(tempLink)
  889. // 释放blob URL地址
  890. // urlObject.revokeObjectURL(blobURL);
  891. setTimeout(() => {
  892. urlObject.revokeObjectURL(blobURL);
  893. }, 1000)
  894. }).catch(function () {
  895. that.tableLoading = false;
  896. that.$message.error('预览失败');
  897. that.loading = false;
  898. })
  899. },
  900. selectTrigger(val) {
  901. let that = this;
  902. if (val === 'graphical') {
  903. that.listTopicTree.show = false;
  904. that.chart.show = true;
  905. that.loading = true;
  906. setTimeout(() => {
  907. that.setGraphical();
  908. }, 1000)
  909. console.log(val);
  910. } else {
  911. that.chart.show = false;
  912. that.listTopicTree.show = true;
  913. console.log(val);
  914. }
  915. },
  916. getFileTreeData () {
  917. let that = this,
  918. params = {
  919. fileName: that.filterForm.data.fileName,
  920. type: that.filterForm.data.securityTypeid,
  921. fileType: that.filterForm.data.securityTag.toString()
  922. };
  923. that.tableLoading = true;
  924. let url = 'pass/ems/v1/uploadfiles/getFileTree/?securityInfo=' + that.qrRole;
  925. that.axios.get(url, {
  926. params: params
  927. })
  928. .then(function (res) {
  929. if (res.code === '0') {
  930. let arr = [];
  931. // that.chart.height = res.data.length * 100 + 'px';
  932. arr = that.treeDataUtil(res.data);
  933. arr[0].label = {
  934. position: 'top',
  935. verticalAlign: 'bottom',
  936. align: 'right',
  937. fontSize: 20,
  938. fontWeight: 800
  939. };
  940. that.chart.option.series[0].data = arr;
  941. that.setGraphical();
  942. } else {
  943. that.$message.error(res.message);
  944. }
  945. that.tableLoading = false;
  946. }).catch(function () {
  947. that.tableLoading = false;
  948. });
  949. },
  950. treeDataUtil (treeData) {
  951. let that = this;
  952. let data = [];
  953. let children = [];
  954. let children1 = [];
  955. let i = 0;
  956. let name = '';
  957. for (let item of treeData) {
  958. i++;
  959. if(item.fileName === null) {
  960. if (item.children !== null){
  961. children = that.treeDataUtil(item.children);
  962. };
  963. data.push({
  964. name: item.createMan,
  965. children: children,
  966. });
  967. children = [];
  968. } else {
  969. if(name === '' || i === 1){
  970. name = item.createMan;
  971. } else if(name !== item.createMan) {
  972. data.push({
  973. name: name,
  974. children: children1,
  975. });
  976. children1 = [];
  977. name = item.createMan;
  978. }
  979. children1.push({
  980. name: item.fileName,
  981. value: item.fileUrl,
  982. });
  983. }
  984. if ( i=== treeData.length && children1.length !== 0 ) {
  985. data.push({
  986. name: name,
  987. children: children1,
  988. });
  989. }
  990. }
  991. return data;
  992. },
  993. /**
  994. * 根据参数生成不同类型的图形化控件
  995. */
  996. setGraphical: function() {
  997. let that = this;
  998. // 引入 ECharts 主模块
  999. let echarts = require("echarts");
  1000. require("echarts-gl");
  1001. // 基于准备好的dom,初始化echarts实例
  1002. let myChart = echarts.init(this.$refs["graphical-area"]);
  1003. myChart.showLoading();
  1004. // 绘制图表
  1005. myChart.setOption(that.chart.option);
  1006. // 设置树图的点击事件
  1007. myChart.on("click", function(param) {
  1008. // 老版本不支持
  1009. // if(param.event.target.culling === true){
  1010. // return
  1011. // } else if(param.event.target.culling === false){
  1012. // let args = {
  1013. // fileName: param.data.name,
  1014. // fileUrl: param.data.value
  1015. // } //当前节点及其子节点的值
  1016. // let level = param.data.level; //当前节点的层级 eg:"1-1-0",可以通过level判断当前的层级,从而进行不同的操作
  1017. // that.preview (args);
  1018. // }
  1019. if(param.data.value){
  1020. let args = {
  1021. fileName: param.data.name,
  1022. fileUrl: param.data.value
  1023. } //当前节点及其子节点的值
  1024. let level = param.data.level; //当前节点的层级 eg:"1-1-0",可以通过level判断当前的层级,从而进行不同的操作
  1025. that.preview (args);
  1026. }
  1027. });
  1028. myChart.hideLoading();
  1029. that.loading = false;
  1030. }
  1031. }
  1032. }
  1033. </script>
  1034. <style lang="less">
  1035. .ListOfDocument {
  1036. padding: 0;
  1037. margin: 0;
  1038. min-width: 700px;
  1039. height: 1024px;
  1040. .box {
  1041. height: 1030px;
  1042. padding: 15px 15px 0 15px;
  1043. background: url(../../../../assets/img/img/filebg.png) center bottom no-repeat;
  1044. background-size: 100% 100%;
  1045. margin: 0px;
  1046. .error {
  1047. overflow: hidden;
  1048. color: #f56c6c;
  1049. font-size: 12px;
  1050. line-height: 1;
  1051. }
  1052. }
  1053. .color_no {
  1054. color: #7a7a7a;
  1055. }
  1056. .color_yes {
  1057. color: #1a9f17;
  1058. }
  1059. .el-upload-dragger {
  1060. width: 120px;
  1061. height: 80px;
  1062. }
  1063. .el-icon-upload:before {
  1064. content: "\E60D";
  1065. position: absolute;
  1066. top: 20%;
  1067. left: 20%;
  1068. }
  1069. .uploadNew {
  1070. position: relative;
  1071. width: 120px;
  1072. }
  1073. .uploadNew .el-upload-list {
  1074. position: absolute;
  1075. left: 320px;
  1076. top: -10px;
  1077. width: 200px;
  1078. }
  1079. .upload-demo {
  1080. float: left;
  1081. width: 85px;
  1082. position: relative;
  1083. }
  1084. .upload-demo .el-upload-list {
  1085. position: absolute;
  1086. left: 530px;
  1087. top: -100px;
  1088. width: 200px;
  1089. }
  1090. .icore-graphical-index {
  1091. display: inline-block;
  1092. height: inherit;
  1093. width: inherit;
  1094. .icore-graphical-area {
  1095. height: 100%;
  1096. width: 100%;
  1097. }
  1098. }
  1099. }
  1100. </style>