SecurityFile.vue 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. <template>
  2. <!-- 文件分类 -->
  3. <div class="planProcessAndProduct">
  4. <div class="box">
  5. <div
  6. class="box-left"
  7. :style="listTopicTree.show ? null : { width: '22px' }"
  8. >
  9. <div
  10. class="box-left-bt"
  11. style="overflow: hidden;"
  12. >
  13. <span v-show="listTopicTree.show">目录</span>
  14. <div style="float: right;height: 100%;padding-right: 4px;">
  15. <span
  16. class="el-icon-d-arrow-right"
  17. style="cursor: pointer; transition: transform 0.3s ease-out, -webkit-transform 0.3s ease-out;"
  18. :style="listTopicTree.show ? { transform: 'rotate(180deg)'} : { transform: 'rotate(0deg)'} "
  19. @click="listTopicTree.show = !listTopicTree.show;"
  20. ></span>
  21. </div>
  22. </div>
  23. <div class="box-left-tree">
  24. <el-tree
  25. v-show="listTopicTree.show"
  26. :data="listTopicTree.data"
  27. :props="listTopicTree.defaultProps"
  28. v-loading="listTopicTree.loading"
  29. >
  30. <span
  31. class="custom-tree-node"
  32. :class="{'tree-row-on': filterForm.data.workprocid === data.id}"
  33. style="width:100%; font-size:12px;"
  34. slot-scope="{ node, data }"
  35. >
  36. <p
  37. style="overflow:hidden; text-overflow:ellipsis; white-space:nowrap;"
  38. :title="node.label"
  39. @click="selectByTopicId(data)"
  40. >{{ node.label }}</p>
  41. </span>
  42. </el-tree>
  43. </div>
  44. </div>
  45. <div
  46. class="box-right"
  47. :style="listTopicTree.show ? null : { 'margin-left': '22px' }"
  48. >
  49. <div class="box-top">
  50. <el-form
  51. style="overflow: hidden;"
  52. :style="filterForm.show ? null : { height: '0px' }"
  53. class="box-top-form"
  54. size="mini"
  55. label-width="60px"
  56. >
  57. <el-row>
  58. <el-col :span="8">
  59. <el-form-item label="文件名称">
  60. <el-select
  61. filterable
  62. clearable
  63. v-model="filterForm.data.fileName"
  64. placeholder="文件名称"
  65. style="width: 100%;"
  66. >
  67. <el-option
  68. v-for="item of nameObj.uploadFile.arr"
  69. :key="item.id"
  70. :value="item.name"
  71. :label="item.name"
  72. ></el-option>
  73. </el-select>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="8">
  77. <el-form-item label="文件分类">
  78. <el-select
  79. filterable
  80. clearable
  81. v-model="filterForm.data.securityTypeid"
  82. placeholder="文件分类"
  83. style="width: 100%;"
  84. >
  85. <el-option
  86. v-for="item of nameObj.securityType.arr"
  87. :key="item.id"
  88. :value="item.id"
  89. :label="item.name"
  90. ></el-option>
  91. </el-select>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="8">
  95. <el-form-item label="文件标签">
  96. <el-select
  97. filterable
  98. clearable
  99. multiple
  100. allow-create
  101. v-model="filterForm.data.securityTag"
  102. placeholder="文件标签"
  103. style="width: 100%;"
  104. >
  105. <el-option
  106. v-for="(item,key) in nameObj.securityTag.arr"
  107. :key="key"
  108. :value="item"
  109. :label="item"
  110. ></el-option>
  111. </el-select>
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. </el-form>
  116. <div class="box-top-gjl">
  117. <el-upload
  118. class="uploadNew"
  119. name="upfile"
  120. drag
  121. action=""
  122. multiple
  123. ref="upload"
  124. :http-request="beforeUpload"
  125. :auto-upload="false"
  126. >
  127. <i class="el-icon-upload"></i>
  128. <!-- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> -->
  129. <!-- :before-upload="beforeUpload" -->
  130. </el-upload>
  131. <el-upload
  132. class="upload-demo"
  133. ref="upload1"
  134. action=""
  135. :http-request="beforeUpload"
  136. :auto-upload="false">
  137. <el-button
  138. slot="trigger"
  139. size="small"
  140. type="primary"
  141. >选取文件
  142. </el-button>
  143. </el-upload>
  144. <el-button
  145. style="margin-left: 10px;"
  146. size="small" type="success"
  147. v-privilege="activeMenu + 'UPLOAD'"
  148. @click="submitUpload"
  149. >上传到服务器
  150. </el-button>
  151. <el-button
  152. class="button"
  153. type="danger"
  154. size="mini"
  155. icon="el-icon-delete"
  156. v-privilege="activeMenu + 'DELETE'"
  157. @click="but_del_plural()"
  158. :loading="loading"
  159. >删除</el-button>
  160. <div style="float:right; text-align: right;">
  161. <el-button
  162. class="button"
  163. type="primary"
  164. size="mini"
  165. icon="el-icon-search"
  166. v-privilege="activeMenu + 'QUERY'"
  167. @click="getTableData(1)"
  168. >查询</el-button>
  169. <el-button
  170. size="mini"
  171. :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
  172. :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
  173. @click="filterForm.show = !filterForm.show;
  174. $nextTick(() => {
  175. singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
  176. }
  177. );"
  178. >{{ filterForm.show ? '收起' : '展开' }}</el-button>
  179. </div>
  180. </div>
  181. </div>
  182. <div class="box-bottom">
  183. <el-form
  184. size="mini"
  185. ref="dialog_form_arr"
  186. label-width="0px"
  187. :model="tableFormDataObj"
  188. >
  189. <el-table
  190. stripe
  191. id="singleTable"
  192. ref="singleTable"
  193. :data="tableData"
  194. v-loading="tableLoading"
  195. style="width: 100%;"
  196. :height="singleTableHeight"
  197. border
  198. size="mini"
  199. highlight-current-row
  200. @selection-change="handleSelectionChange"
  201. >
  202. <el-table-column
  203. type="selection"
  204. width="40"
  205. align="center"
  206. fixed="left"
  207. ></el-table-column>
  208. <el-table-column
  209. sortable
  210. prop="fileName"
  211. label="文件名称"
  212. width="160px"
  213. :show-overflow-tooltip="true"
  214. ></el-table-column>
  215. <el-table-column
  216. sortable
  217. prop="fileUrl"
  218. label="文件路径"
  219. width="320px"
  220. :show-overflow-tooltip="true"
  221. ></el-table-column>
  222. <el-table-column
  223. sortable
  224. prop="type"
  225. label="所属类别"
  226. width="100px"
  227. :show-overflow-tooltip="true"
  228. >
  229. <template slot-scope="scope">
  230. <span>{{ nameObj.securityType.obj[scope.row.type] ? nameObj.securityType.obj[scope.row.type] : scope.row.type }}</span>
  231. </template>
  232. </el-table-column>
  233. <el-table-column
  234. sortable
  235. prop="fileType"
  236. label="文件标签"
  237. width="320px"
  238. :show-overflow-tooltip="true"
  239. > <template slot-scope="scope">
  240. <el-tag
  241. effect="dark"
  242. :disable-transitions="true"
  243. v-for="(tag,key) in scope.row.fileType"
  244. :key="key"
  245. size="small">
  246. {{ tag }}
  247. </el-tag>
  248. </template>
  249. </el-table-column>
  250. <el-table-column
  251. sortable
  252. prop="uploadTime"
  253. label="上传时间"
  254. width="160px"
  255. :show-overflow-tooltip="true"
  256. ></el-table-column>
  257. <el-table-column
  258. sortable
  259. prop="createMan"
  260. label="上传人"
  261. width="100px"
  262. :show-overflow-tooltip="true"
  263. ></el-table-column>
  264. <el-table-column
  265. sortable
  266. prop="updateMan"
  267. label="修改人"
  268. width="100px"
  269. :show-overflow-tooltip="true"
  270. ></el-table-column>
  271. <el-table-column
  272. sortable
  273. prop="updateTime"
  274. label="修改时间"
  275. width="160px"
  276. :show-overflow-tooltip="true"
  277. ></el-table-column>
  278. <el-table-column
  279. label="操作"
  280. width="200px"
  281. fixed="right"
  282. ><template slot-scope="scope">
  283. <el-button
  284. size="small"
  285. type="primary"
  286. icon="el-icon-download"
  287. v-privilege="activeMenu + 'DOWNLOAD'"
  288. @click="downloadFile(scope.row)"
  289. >点击下载
  290. </el-button>
  291. <el-button
  292. size="small"
  293. type="primary"
  294. icon="el-icon-view"
  295. v-privilege="activeMenu + 'PREVIEW'"
  296. @click="preview(scope.row)"
  297. >预览
  298. </el-button>
  299. </template>
  300. </el-table-column>
  301. </el-table>
  302. </el-form>
  303. <el-pagination
  304. layout="total, sizes, prev, pager, next, jumper"
  305. :total="total"
  306. :page-sizes="[10, 20, 50, 100, 500, 1000]"
  307. :page-size="pageSize"
  308. :current-page.sync="pageNum"
  309. @size-change="tableSizeChange"
  310. @current-change="getTableData()"
  311. style="text-align: right;margin-top: 10px;"
  312. ></el-pagination>
  313. </div>
  314. </div>
  315. </div>
  316. <el-dialog
  317. title="文件预览"
  318. :visible.sync="dialogVisible"
  319. destroy-on-close
  320. width="90%"
  321. top="10vh">
  322. <iframe :src="previewUrl" width="100%" :height="singleTableHeight"></iframe>
  323. </el-dialog>
  324. <el-dialog
  325. :title="'计划工序与产品关联 - ' + (dialog.editorBox.type === 'add' ? '新增' : '修改')"
  326. :visible.sync="dialog.editorBox.show"
  327. width="600px"
  328. :close-on-click-modal="false"
  329. :show-close="!loading"
  330. >
  331. <div>
  332. <el-form
  333. ref="dialog_form"
  334. :model="dialog.editorBox.form.data"
  335. :rules="dialog.editorBox.form.rules"
  336. size="mini"
  337. label-width="95px"
  338. >
  339. <el-row>
  340. <el-col :span="12">
  341. <el-form-item
  342. label="产品"
  343. prop="productid"
  344. >
  345. <el-select
  346. filterable
  347. clearable
  348. style="width: 100%;"
  349. v-model="dialog.editorBox.form.data.productid"
  350. :disabled="dialog.editorBox.type !== 'add'"
  351. >
  352. <el-option
  353. v-for="(item,key) in nameObj.uploadFile.arr"
  354. :key="key"
  355. :value="item"
  356. :label="item"
  357. ></el-option>
  358. </el-select>
  359. </el-form-item>
  360. </el-col>
  361. <el-col :span="12">
  362. <el-form-item
  363. label="工序"
  364. prop="workprocid"
  365. >
  366. <el-select
  367. filterable
  368. clearable
  369. style="width: 100%;"
  370. v-model="dialog.editorBox.form.data.workprocid"
  371. disabled
  372. >
  373. <el-option
  374. v-for="item of nameObj.securityType.arr"
  375. :key="item.id"
  376. :value="item.id"
  377. :label="item.name"
  378. ></el-option>
  379. </el-select>
  380. </el-form-item>
  381. </el-col>
  382. </el-row>
  383. <el-row>
  384. <el-col :span="12">
  385. <el-form-item
  386. label="主产品"
  387. prop="isprimary"
  388. >
  389. <el-select
  390. filterable
  391. clearable
  392. style="width: 100%;"
  393. v-model="dialog.editorBox.form.data.isprimary"
  394. >
  395. <el-option
  396. value="0"
  397. label="否"
  398. ></el-option>
  399. <el-option
  400. value="1"
  401. label="是"
  402. ></el-option>
  403. </el-select>
  404. </el-form-item>
  405. </el-col>
  406. <el-col :span="12">
  407. <el-form-item
  408. label="单位"
  409. prop="unitid"
  410. >
  411. <el-select
  412. filterable
  413. clearable
  414. style="width: 100%;"
  415. v-model="dialog.editorBox.form.data.unitid"
  416. >
  417. <el-option
  418. v-for="item of nameObj.unitid.arr"
  419. :key="item.id"
  420. :value="item.id"
  421. :label="item.name"
  422. ></el-option>
  423. </el-select>
  424. </el-form-item>
  425. </el-col>
  426. </el-row>
  427. <el-row>
  428. <el-col :span="12">
  429. <el-form-item
  430. label="顺序号"
  431. prop="seqno"
  432. >
  433. <el-input
  434. clearable
  435. style="width: 100%;"
  436. v-model="dialog.editorBox.form.data.seqno"
  437. ></el-input>
  438. </el-form-item>
  439. </el-col>
  440. <el-col :span="12">
  441. <el-form-item
  442. label="使用公式编辑"
  443. prop="code"
  444. >
  445. <el-select
  446. filterable
  447. clearable
  448. style="width: 100%;"
  449. v-model="dialog.editorBox.form.data.code"
  450. >
  451. <el-option
  452. value="0"
  453. label="否"
  454. ></el-option>
  455. <el-option
  456. value="1"
  457. label="是"
  458. ></el-option>
  459. </el-select>
  460. </el-form-item>
  461. </el-col>
  462. </el-row>
  463. </el-form>
  464. </div>
  465. <span
  466. slot="footer"
  467. class="dialog-footer"
  468. >
  469. <el-button
  470. @click="dialog.editorBox.show = false"
  471. :loading="loading"
  472. >取 消</el-button>
  473. <el-button
  474. type="primary"
  475. @click="dataSave"
  476. :loading="loading"
  477. >保 存</el-button>
  478. </span>
  479. </el-dialog>
  480. <zj-formulaEditor :equationEditing="dialog.equationEditing"></zj-formulaEditor>
  481. </div>
  482. </template>
  483. <script>
  484. import formulaEditor from '@/components/zg/formulaEditor.vue';
  485. import { zCheckNumber1 } from '@/utils/validator.js';
  486. import { formatDate } from '@/utils/util.js';
  487. import store from '@/store/index.js';
  488. export default {
  489. name: 'planProcessAndProduct',
  490. components: {
  491. 'zj-formulaEditor': formulaEditor
  492. },
  493. data () {
  494. return {
  495. multipleSelection: [],
  496. tableFormDataObj: {},
  497. activeMenu: '',
  498. form: {
  499. imgSavePath: ''
  500. },
  501. filterForm: {
  502. show: true,
  503. data: {
  504. uploadFileid: '',
  505. securityTypeid: '',
  506. securityTag: '',
  507. isprimary: '',
  508. version: formatDate(new Date(), 'yyyyMM00'),
  509. fileName: ''
  510. },
  511. rules: {
  512. },
  513. file: ''
  514. },
  515. listTopicTree: {
  516. show: true,
  517. loading: false,
  518. data: [],
  519. defaultProps: {
  520. children: 'children',
  521. label: 'securityName'
  522. }
  523. },
  524. pageNum: 1,
  525. pageSize: 20,
  526. total: 0,
  527. singleTableHeight: 100,
  528. tableData: [
  529. ],
  530. nameObj: {
  531. uploadFile: {
  532. obj: {},
  533. arr: []
  534. },
  535. securityType: {
  536. obj: {},
  537. arr: []
  538. },
  539. unitid: {
  540. obj: {},
  541. arr: []
  542. },
  543. roleList: {
  544. obj: {},
  545. arr: []
  546. }, // 角色信息
  547. securityTag: {
  548. obj: {},
  549. arr: []
  550. }
  551. },
  552. loading: false,
  553. tableLoading: false,
  554. dialog: {
  555. editorBox: {
  556. show: false,
  557. type: '',
  558. form: {
  559. default: {
  560. workprocid: ''
  561. },
  562. data: {
  563. itemid: '',
  564. productid: '',
  565. workprocid: '',
  566. isprimary: '0',
  567. unitid: '',
  568. seqno: '',
  569. code: ''
  570. },
  571. rules: {
  572. productid: [
  573. { required: true, message: '该项不能为空', trigger: 'change' }
  574. ],
  575. workprocid: [
  576. { required: true, message: '该项不能为空', trigger: 'change' }
  577. ],
  578. seqno: [
  579. { validator: zCheckNumber1, trigger: 'change' }
  580. ]
  581. }
  582. }
  583. },
  584. equationEditing: {
  585. show: false,
  586. form: {
  587. data: {
  588. clock: '',
  589. code: ''
  590. }
  591. }
  592. }
  593. },
  594. store,
  595. userInfo: {}, // 用户信息
  596. qrRole: [],
  597. userRoles: [],
  598. dialogVisible: false,
  599. previewUrl: ''
  600. }
  601. },
  602. created () {
  603. this.activeMenu = window.localStorage.getItem('activeMenu');
  604. },
  605. mounted () {
  606. let that = this;
  607. window.PEDataObj = {
  608. // 将数据绑定到window上,供main页面使用
  609. vm: that,
  610. // tableArr:用于导出成Excel的表格的信息
  611. tableArr: [
  612. {
  613. name: '',
  614. id: 'singleTable'
  615. }
  616. ]
  617. };
  618. that.$nextTick(() => {
  619. // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  620. setTimeout(() => {
  621. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
  622. }, 1);
  623. });
  624. // that.getNodeData();
  625. // that.getNodeTreeData();
  626. that.getUploadFileData();
  627. that.getUnitIdData();
  628. // that.getTableData();
  629. that.getRoles();
  630. },
  631. methods: {
  632. // 计算树区域高度
  633. getRoleHeight (dom) {
  634. return window.innerHeight - dom.offsetTop;
  635. },
  636. // 获取文件类型列表
  637. getNodeData () {
  638. let that = this
  639. let url = 'pass/ems/v1/securitytypes/getIdAndName/?securityInfo=' + that.qrRole;
  640. that.axios.get(url)
  641. .then(function (res) {
  642. if (res.code === '0') {
  643. let arr = [];
  644. let obj = {};
  645. for (let item of res.data) {
  646. arr.push({
  647. id: item.id,
  648. name: item.securityName
  649. })
  650. obj[item.id] = item.securityName;
  651. }
  652. that.nameObj.securityType.arr = arr;
  653. that.nameObj.securityType.obj = obj;
  654. console.log(that.nameObj.securityType)
  655. } else {
  656. that.$message.error(res.message);
  657. }
  658. });
  659. },
  660. // 获取工序节点树(产出)
  661. getNodeTreeData () {
  662. let that = this
  663. let url = 'pass/ems/v1/securitytypes/gettree/?securityInfo=' + that.qrRole;
  664. that.listTopicTree.loading = true;
  665. that.axios.get(url)
  666. .then(function (res) {
  667. if (res.code === '0') {
  668. that.listTopicTree.data = [{
  669. id: '',
  670. securityName: '所有记录',
  671. children: res.data
  672. }];
  673. that.getTableData();
  674. } else {
  675. that.$message.error(res.message);
  676. }
  677. that.listTopicTree.loading = false;
  678. }).catch(function () {
  679. that.listTopicTree.loading = false;
  680. });
  681. },
  682. // 获取产品
  683. getUploadFileData () {
  684. let that = this
  685. let url = 'pass/ems/v1/uploadfiles/getIdAndName';
  686. that.axios.get(url)
  687. .then(function (res) {
  688. if (res.code === '0') {
  689. let arr = [];
  690. let obj = {};
  691. for (let item of res.data) {
  692. arr.push({
  693. id: item.id,
  694. name: item.fileName
  695. })
  696. obj[item.id] = item.fileName;
  697. }
  698. that.nameObj.uploadFile.arr = arr;
  699. that.nameObj.uploadFile.obj = obj;
  700. } else {
  701. that.$message.error(res.message);
  702. }
  703. });
  704. },
  705. // 获取标准计量单位
  706. getUnitIdData () {
  707. let that = this
  708. let url = 'pass/ems/v1/trmunits/getIdAndName';
  709. that.axios.get(url)
  710. .then(function (res) {
  711. if (res.code === '0') {
  712. let arr = [];
  713. let obj = {};
  714. for (let item of res.data) {
  715. arr.push({
  716. id: item.id,
  717. name: item.name
  718. })
  719. obj[item.id] = item.name;
  720. if (item.name === '吨') {
  721. that.nameObj.unitid.defaults = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : item.id;
  722. }
  723. }
  724. that.nameObj.unitid.arr = arr;
  725. that.nameObj.unitid.obj = obj;
  726. } else {
  727. that.$message.error(res.message);
  728. }
  729. });
  730. },
  731. // 获取表格中的数据
  732. getTableData (pageNum) {
  733. let that = this,
  734. params = {
  735. fileName: that.filterForm.data.fileName,
  736. type: that.filterForm.data.securityTypeid,
  737. fileType: that.filterForm.data.securityTag.toString()
  738. };
  739. that.pageNum = pageNum || that.pageNum;
  740. that.tableLoading = true;
  741. let url = 'pass/ems/v1/uploadfiles/like/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
  742. that.axios.get(url, {
  743. params: params
  744. })
  745. .then(function (res) {
  746. if (res.code === '0') {
  747. let arr = [];
  748. let map = {};
  749. let fileTypeArr = [];
  750. let fileTypeStr = '';
  751. let total = 0;
  752. for (let item of that.listTopicTree.data[0].children) {
  753. map[item.id] = true;
  754. }
  755. for (let item of res.data.list) {
  756. let result = true;
  757. fileTypeArr = [];
  758. // result = item.type.some(i => map[i]);
  759. if (that.qrRole.length > 0) {
  760. result = map.hasOwnProperty(item.type);
  761. }
  762. if (result) {
  763. if (item.fileType !== null) {
  764. fileTypeArr = item.fileType.split(';');
  765. fileTypeStr += item.fileType + ';'
  766. }
  767. total++;
  768. arr.push({
  769. ID: item.id,
  770. fileName: item.fileName,
  771. fileUrl: item.fileUrl,
  772. type: item.type,
  773. fileType: fileTypeArr,
  774. uploadTime: item.uploadTime,
  775. createMan: item.createMan,
  776. createTime: item.createTime,
  777. updateMan: item.updateMan,
  778. updateTime: item.updateTime
  779. })
  780. }
  781. }
  782. if (that.nameObj.securityTag.arr.length <= 0) {
  783. fileTypeStr = fileTypeStr.substr(0, fileTypeStr.length - 1);
  784. that.nameObj.securityTag.arr = Array.from(new Set(fileTypeStr.split(';')));
  785. }
  786. that.tableData = arr;
  787. that.total = res.data.total;
  788. } else {
  789. that.$message.error(res.message);
  790. }
  791. that.tableLoading = false;
  792. }).catch(function () {
  793. that.tableLoading = false;
  794. });
  795. },
  796. // 改变表格显示条数
  797. tableSizeChange (val) {
  798. let that = this;
  799. that.pageSize = val;
  800. that.getTableData(1);
  801. },
  802. // 重置搜索
  803. tableDataCancel () {
  804. let that = this;
  805. that.filterForm.data.workprocid = '';
  806. that.filterForm.data.productid = '';
  807. that.filterForm.data.version = '';
  808. that.getTableData(1);
  809. },
  810. // 表格中多选按钮的相关方法
  811. handleSelectionChange (val) {
  812. let that = this;
  813. let tableFormDataObj = {};
  814. for (let item of that.tableData) {
  815. item.isSelection = false;
  816. }
  817. for (let item of val) {
  818. let obj = {};
  819. let xId = item.itemid;
  820. if (that.tableFormDataObj[xId]) {
  821. tableFormDataObj[xId] = that.tableFormDataObj[xId];
  822. } else {
  823. for (let key in item) {
  824. obj[key] = item[key];
  825. }
  826. tableFormDataObj[xId] = obj;
  827. }
  828. item.isSelection = true;
  829. }
  830. that.tableFormDataObj = tableFormDataObj;
  831. that.multipleSelection = val;
  832. },
  833. but_add () {
  834. let that = this;
  835. if (!that.dialog.editorBox.form.default.workprocid) {
  836. that.$message.error('请先选择左侧的详细工序');
  837. return;
  838. }
  839. that.dialog.editorBox.form.data.itemid = '';
  840. that.dialog.editorBox.form.data.productid = '';
  841. that.dialog.editorBox.form.data.workprocid = that.dialog.editorBox.form.default.workprocid;
  842. that.dialog.editorBox.form.data.isprimary = '0';
  843. that.dialog.editorBox.form.data.unitid = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : '';
  844. that.dialog.editorBox.form.data.seqno = '';
  845. that.dialog.editorBox.form.data.code = '0';
  846. that.dialog.editorBox.type = 'add';
  847. that.dialog.editorBox.show = true;
  848. setTimeout(() => {
  849. that.$refs['dialog_form'].clearValidate();
  850. }, 100);
  851. },
  852. beforeUpload (file) {
  853. let that = this
  854. let foorData = new FormData();
  855. foorData.append('file', file.file);
  856. foorData.append('type', this.filterForm.data.securityTypeid);
  857. that.axios.post('pass/ems/v1/uploadfiles/file', foorData, {
  858. headers: {
  859. 'Content-Type': 'multipart/form-data'
  860. }
  861. }).then(function (res) {
  862. if (res.code === '0') {
  863. that.$message({
  864. message: '上传成功',
  865. type: 'success'
  866. });
  867. that.$refs.upload.clearFiles();
  868. that.$refs.upload1.clearFiles();
  869. that.getTableData(1);
  870. that.dialog.editorBox.show = false;
  871. } else {
  872. that.$message.error(res.message);
  873. }
  874. }).catch(function () {
  875. });
  876. },
  877. submitUpload () {
  878. this.$refs.upload.submit();
  879. this.$refs.upload1.submit();
  880. },
  881. handleRemove (file, fileList) {
  882. console.log(file, fileList);
  883. },
  884. handlePreview (file) {
  885. console.log(file);
  886. },
  887. // 批量修改
  888. but_edit_plural () {
  889. let that = this;
  890. if (that.multipleSelection.length > 0) {
  891. that.$refs['dialog_form_arr'].validate((valid) => {
  892. if (valid) {
  893. let SubmitData = [];
  894. for (let key in that.tableFormDataObj) {
  895. SubmitData.push({
  896. itemid: that.tableFormDataObj[key].itemid,
  897. isprimary: that.tableFormDataObj[key].isprimary,
  898. unitid: that.tableFormDataObj[key].unitid,
  899. seqno: that.tableFormDataObj[key].seqno,
  900. code: that.tableFormDataObj[key].code
  901. });
  902. }
  903. that.loading = true;
  904. that.axios.put('pass/ems/v1/trmworkprocproducts/', SubmitData)
  905. .then(function (res) {
  906. if (res.code === '0') {
  907. that.$message({
  908. message: '修改成功',
  909. type: 'success'
  910. });
  911. that.getTableData();
  912. that.dialog.editorBox.show = false;
  913. } else {
  914. that.$message.error(res.message);
  915. }
  916. that.loading = false;
  917. }).catch(function () {
  918. that.loading = false;
  919. });
  920. }
  921. });
  922. } else {
  923. this.$message.error('至少要选择一条数据');
  924. }
  925. },
  926. // 批量删除
  927. but_del_plural () {
  928. let that = this;
  929. if (that.multipleSelection.length > 0) {
  930. let ids = [];
  931. let paths = [];
  932. for (let item of that.multipleSelection) {
  933. ids.push(item.ID);
  934. paths.push(item.fileUrl);
  935. }
  936. that.$confirm('是否删除已选数据?', '提示', {
  937. confirmButtonText: '确定',
  938. cancelButtonText: '取消',
  939. state: 'warning'
  940. }).then(() => {
  941. that.axios.delete('pass/ems/v1/uploadfiles/' + ids.toString())
  942. .then(function (res) {
  943. if (res.code === '0') {
  944. that.$message({
  945. message: '删除成功',
  946. type: 'success'
  947. });
  948. that.getTableData();
  949. } else {
  950. if (res.code === '51') {
  951. }
  952. that.$message.error(res.message);
  953. }
  954. }).catch(function () {
  955. });
  956. }).catch(() => {
  957. });
  958. } else {
  959. this.$message.error('至少要选择一条数据');
  960. }
  961. },
  962. dataSave () {
  963. let that = this;
  964. let SubmitData = {
  965. itemid: that.dialog.editorBox.form.data.itemid,
  966. productid: that.dialog.editorBox.form.data.productid,
  967. workprocid: that.dialog.editorBox.form.data.workprocid,
  968. isprimary: that.dialog.editorBox.form.data.isprimary,
  969. unitid: that.dialog.editorBox.form.data.unitid,
  970. seqno: that.dialog.editorBox.form.data.seqno,
  971. code: that.dialog.editorBox.form.data.code,
  972. itemtype: 'P'
  973. };
  974. that.$refs['dialog_form'].validate((valid) => {
  975. if (valid) {
  976. if (that.dialog.editorBox.type === 'add') {
  977. that.loading = true;
  978. that.axios.post('pass/ems/v1/trmworkprocproducts/', SubmitData, {
  979. contentType: 'application/json'
  980. })
  981. .then(function (res) {
  982. if (res.code === '0') {
  983. that.$message({
  984. message: '新增成功',
  985. type: 'success'
  986. });
  987. that.getTableData();
  988. that.dialog.editorBox.show = false;
  989. } else {
  990. that.$message.error(res.message);
  991. }
  992. that.loading = false;
  993. }).catch(function () {
  994. that.loading = false;
  995. });
  996. } else {
  997. that.loading = true;
  998. that.axios.put('pass/ems/v1/trmworkprocproducts/' + SubmitData.itemid, SubmitData)
  999. .then(function (res) {
  1000. if (res.code === '0') {
  1001. that.$message({
  1002. message: '修改成功',
  1003. type: 'success'
  1004. });
  1005. that.getTableData();
  1006. that.dialog.editorBox.show = false;
  1007. } else {
  1008. that.$message.error(res.message);
  1009. }
  1010. that.loading = false;
  1011. }).catch(function () {
  1012. that.loading = false;
  1013. });
  1014. }
  1015. }
  1016. });
  1017. },
  1018. but_equationEditing (row) {
  1019. let that = this;
  1020. that.dialog.equationEditing.form.data.clock = that.filterForm.data.version;
  1021. that.dialog.equationEditing.form.data.code = row.itemid;
  1022. that.dialog.equationEditing.show = true;
  1023. },
  1024. selectByTopicId (data) {
  1025. let that = this;
  1026. that.filterForm.data.securityTypeid = data.id;
  1027. that.getTableData(1);
  1028. },
  1029. getRoles () {
  1030. let that = this;
  1031. // 获取用户信息
  1032. this.store.dispatch('getUserInfo').then((res) => {
  1033. this.userInfo = res.data;
  1034. that.axios.get('pass/v1/sysuserroles/?userId=' + res.data.userId + '&pageNum=1&pageSize=100').then(rest => {
  1035. if (rest) {
  1036. for (let i = 0; i < rest.data.list.length; i++) {
  1037. that.qrRole.push(rest.data.list[i].roleId)
  1038. }
  1039. that.userRoles = rest.data.list; // 获取用户角色关联信息
  1040. }
  1041. that.getNodeData();
  1042. that.getNodeTreeData();
  1043. })
  1044. });
  1045. // 获取角色信息
  1046. this.store.dispatch('system/rolesManage/list').then(res => {
  1047. if (res.code === '0') {
  1048. this.nameObj.roleList.arr = res.data;
  1049. for (let obj of res.data) {
  1050. this.nameObj.roleList.obj[obj.id] = {
  1051. name: obj.roleName,
  1052. id: obj.id
  1053. };
  1054. }
  1055. } else {
  1056. this.$message.error(res.message);
  1057. }
  1058. });
  1059. },
  1060. downloadFile (data) {
  1061. let that = this;
  1062. let SubmitData = {
  1063. fileName: data.fileName,
  1064. fileUrl: data.fileUrl
  1065. };
  1066. // 不带token访问方式,留底后端修改shiroconfig.java,application.properties
  1067. // let url = '/zhongsteel.pass.web/pass/ems/v1/uploadfiles/downloadFile/?fileName=' + that.tableFormDataObj[key].fileName + '&fileUrl=' + that.tableFormDataObj[key].fileUrl;
  1068. // const xhr = new XMLHttpRequest();
  1069. // xhr.open('GET', url, true);
  1070. // xhr.responseType = 'blob';
  1071. // xhr.onload = () => {
  1072. // if (xhr.status === 200) {
  1073. // var fileName = that.tableFormDataObj[key].fileName;
  1074. // // 获取文件blob数据并保存
  1075. // that.saveAs(xhr.response, fileName);
  1076. // }
  1077. // };
  1078. // xhr.send();
  1079. let urla = 'pass/ems/v1/uploadfiles/downloadFile/';
  1080. that.axios.get(urla, {
  1081. params: SubmitData,
  1082. responseType: 'blob'
  1083. }).then(function (res) {
  1084. that.saveAs(res, data.fileName);
  1085. that.$message({
  1086. message: '下载成功',
  1087. type: 'success'
  1088. });
  1089. }).catch(function () {
  1090. that.$message.error('下载失败');
  1091. })
  1092. },
  1093. // js实现文件下载而不直接打开
  1094. saveAs (data, fileName) {
  1095. let urlObject = window.URL || window.webkitURL || window;
  1096. // 将二进制流转为blob
  1097. let exportBlob = new Blob([data]);
  1098. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  1099. // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
  1100. window.navigator.msSaveBlob(exportBlob, decodeURI(fileName));
  1101. } else {
  1102. // 创建新的URL并指向File对象或者Blob对象的地址
  1103. let blobURL = urlObject.createObjectURL(exportBlob);
  1104. let saveLink = document.createElement('a');
  1105. // 兼容:某些浏览器不支持HTML5的download属性
  1106. if (typeof saveLink.download === 'undefined') {
  1107. saveLink.setAttribute('target', '_blank');
  1108. } else {
  1109. saveLink.download = fileName;
  1110. }
  1111. // 创建新的URL并指向File对象或者Blob对象的地址
  1112. saveLink.href = blobURL;
  1113. saveLink.click();
  1114. // 释放blob URL地址
  1115. urlObject.revokeObjectURL(exportBlob);
  1116. // let blob = new Blob([data])
  1117. // let fileURL = urlObject.createObjectURL(blob);
  1118. // 下载代码
  1119. // let downEle = document.createElement('a')
  1120. // let fname = `download` //下载文件的名字
  1121. // downEle.href = fileURL
  1122. // downEle.setAttribute('download', fname)
  1123. // document.body.appendChild(downEle)
  1124. // downEle.click()
  1125. // window.open(fileURL);
  1126. }
  1127. },
  1128. preview (data) {
  1129. let that = this;
  1130. let SubmitData = {
  1131. fileName: data.fileName,
  1132. fileUrl: data.fileUrl
  1133. };
  1134. let urla = 'pass/ems/v1/uploadfiles/getfile/';
  1135. let type = 'text/html';
  1136. let responseType = 'application/json';
  1137. let fileExtension = data.fileName.substring(data.fileName.lastIndexOf('.') + 1);
  1138. if (fileExtension === 'pdf') {
  1139. urla = 'pass/ems/v1/uploadfiles/downloadFile/';
  1140. type = 'application/pdf';
  1141. responseType = 'blob';
  1142. }
  1143. that.tableLoading = true;
  1144. that.axios.get(urla, {
  1145. params: SubmitData,
  1146. responseType: responseType
  1147. }).then(function (res) {
  1148. let urlObject = window.URL || window.webkitURL || window;
  1149. // 将二进制流转为blob
  1150. let blob = new Blob([res], {type: type});
  1151. if (fileExtension !== 'pdf') {
  1152. blob = new Blob([res.data], {type: type});
  1153. }
  1154. // if (typeof window.navigator.msSaveBlob !== 'undefined') {
  1155. // // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
  1156. // window.navigator.msSaveBlob(blob, decodeURI(fileName))
  1157. // } else {
  1158. // 创建新的URL并指向File对象或者Blob对象的地址
  1159. let blobURL = urlObject.createObjectURL(blob);
  1160. that.dialogVisible = true;
  1161. that.previewUrl = blobURL;
  1162. that.tableLoading = false;
  1163. // 'https://file.keking.cn/onlinePreview?url=' + encodeURIComponent(blobURL)
  1164. // http://view.officeapps.live.com/op/view.aspx?src' + blobURL;
  1165. // 创建a标签,用于跳转至下载链接
  1166. // let tempLink = document.createElement('a')
  1167. // tempLink.style.display = 'none'
  1168. // tempLink.href = blobURL;
  1169. // tempLink.setAttribute('download', decodeURI(fileName))
  1170. // 兼容:某些浏览器不支持HTML5的download属性
  1171. // if (typeof tempLink.download === 'undefined') {
  1172. // tempLink.setAttribute('target', '_blank')
  1173. // }
  1174. // // 挂载a标签
  1175. // document.body.appendChild(tempLink)
  1176. // tempLink.click()
  1177. // // 销毁a标签
  1178. // document.body.removeChild(tempLink)
  1179. // 释放blob URL地址
  1180. // urlObject.revokeObjectURL(blobURL);
  1181. setTimeout(() => {
  1182. urlObject.revokeObjectURL(blobURL);
  1183. }, 1000)
  1184. }).catch(function () {
  1185. that.tableLoading = false;
  1186. that.$message.error('预览失败');
  1187. })
  1188. }
  1189. }
  1190. }
  1191. </script>
  1192. <style lang="less">
  1193. .planProcessAndProduct {
  1194. min-width: 700px;
  1195. height: 100%;
  1196. .box {
  1197. height: 100%;
  1198. padding: 15px 15px 0 15px;
  1199. .box-left {
  1200. float: left;
  1201. width: 200px;
  1202. height: calc(100% - 3px);
  1203. overflow: auto;
  1204. .box-left-bt {
  1205. line-height: 35px;
  1206. font-size: 16px;
  1207. border-bottom: 1px solid #ccc;
  1208. }
  1209. .box-left-tree {
  1210. height: calc(100% - 50px);
  1211. overflow: auto;
  1212. padding: 7px 7px 0 0;
  1213. .tree-row-on {
  1214. color: #3279e8;
  1215. font-weight: 600;
  1216. }
  1217. }
  1218. }
  1219. .box-right {
  1220. border-left: 1px solid #ccc;
  1221. margin-left: 200px;
  1222. .box-top {
  1223. .box-top-form {
  1224. padding-left: 7px;
  1225. .el-form-item {
  1226. margin-bottom: 7px;
  1227. }
  1228. }
  1229. .box-top-gjl {
  1230. overflow: hidden;
  1231. // margin-top: -7px;
  1232. padding: 7px 0 7px 7px;
  1233. border-top: 1px solid #ccc;
  1234. // border-bottom: 1px solid #ccc;
  1235. // margin-bottom: 6px;
  1236. }
  1237. }
  1238. .box-bottom {
  1239. padding-left: 7px;
  1240. }
  1241. }
  1242. .el-table .el-table__row {
  1243. height: 35px;
  1244. }
  1245. .el-table__body .el-form-item--mini.el-form-item {
  1246. margin: 0px;
  1247. .error {
  1248. overflow: hidden;
  1249. color: #f56c6c;
  1250. font-size: 12px;
  1251. line-height: 1;
  1252. }
  1253. }
  1254. }
  1255. .color_no {
  1256. color: #7a7a7a;
  1257. }
  1258. .color_yes {
  1259. color: #1a9f17;
  1260. }
  1261. .el-upload-dragger {
  1262. width: 120px;
  1263. height: 80px;
  1264. }
  1265. .el-icon-upload:before {
  1266. content: "\E60D";
  1267. position: absolute;
  1268. top: 20%;
  1269. left: 20%;
  1270. }
  1271. .uploadNew {
  1272. position: relative;
  1273. width: 120px;
  1274. }
  1275. .uploadNew .el-upload-list {
  1276. position: absolute;
  1277. left: 320px;
  1278. top: -10px;
  1279. width: 200px;
  1280. }
  1281. .upload-demo {
  1282. float: left;
  1283. width: 85px;
  1284. position: relative;
  1285. }
  1286. .upload-demo .el-upload-list {
  1287. position: absolute;
  1288. left: 530px;
  1289. top: -100px;
  1290. width: 200px;
  1291. }
  1292. }
  1293. </style>