archivetree1.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  1. <template>
  2. <basic-container
  3. ref="container"
  4. style="height:100%;"
  5. >
  6. <el-row
  7. :gutter="20"
  8. :style="{'height':heights-80+'px','overflow': 'hidden'}"
  9. >
  10. <el-col
  11. :span="12"
  12. class='marleft20'
  13. >
  14. <div>
  15. <h2>归档目录树</h2>
  16. <el-input
  17. placeholder="输入关键字进行过滤"
  18. clearable
  19. v-model="filterText"
  20. >
  21. </el-input>
  22. <div class="scrollClass" style="height:658px ;">
  23. <el-scrollbar style="height:100%">
  24. <el-tree
  25. v-show="!filterText"
  26. ref="trees1"
  27. :props="props"
  28. :load="loadNode"
  29. node-key="id"
  30. lazy
  31. >
  32. <span
  33. class=" flexStar"
  34. slot-scope="{ node, data }"
  35. @mouseover="mouseOver(data)"
  36. @mouseleave="mouseLeave(data)"
  37. style="box-sizing: border-box;width:100%;"
  38. >
  39. <span>{{ data.title }}</span>
  40. <!--知识点过长处理,鼠标悬浮文字弹框显示全部内容-->
  41. <!-- <span class="custom-tree-node">
  42. <el-tooltip class="item" effect="light" :content="data.title" placement="top-start">
  43. <span > {{ data.title | ellipsis(25) }} </span>
  44. </el-tooltip>
  45. <div>
  46. </div>
  47. </span> -->
  48. <span
  49. class="marleft10"
  50. v-show="data.moreShow"
  51. >
  52. <i
  53. @click.stop='addtree(data,node)'
  54. class="el-icon-circle-plus-outline"
  55. style="fontSize:18px;"
  56. v-if="data.isStorageNode!=1"
  57. ></i>
  58. <i
  59. @click.stop='edittree(data,node)'
  60. class="el-icon-edit-outline marleft5"
  61. style="fontSize:18px;"
  62. v-if="node.level!=1"
  63. ></i>
  64. <i
  65. @click.stop='deletetree(node)'
  66. class="el-icon-delete marleft5"
  67. style="fontSize:18px;"
  68. v-if="node.level!=1"
  69. ></i>
  70. <i
  71. @click.stop='paixuMD(data)'
  72. class="el-icon-sort marleft5"
  73. style="fontSize:18px;"
  74. v-if="node.level!=1"
  75. ></i>
  76. </span>
  77. </span>
  78. </el-tree>
  79. </el-scrollbar>
  80. </div>
  81. <el-tree
  82. v-show="filterText"
  83. :default-expanded-keys='defaultExpanded'
  84. :props="props"
  85. :data="data"
  86. node-key="id"
  87. ref="trees2"
  88. :default-expand-all="true"
  89. :filter-node-method="filterNode"
  90. >
  91. <span
  92. class=" flexStar"
  93. slot-scope="{ node, data }"
  94. @mouseover="mouseOver(data)"
  95. @mouseleave="mouseLeave(data)"
  96. style="box-sizing: border-box;width:100%;"
  97. >
  98. <span>{{ data.title }}</span>
  99. <span
  100. class="marleft10"
  101. v-show="data.moreShow"
  102. >
  103. <i
  104. @click.stop='addtree(data,node)'
  105. class="el-icon-circle-plus-outline"
  106. style="fontSize:18px;"
  107. v-if="data.isStorageNode!=1"
  108. ></i>
  109. <i
  110. @click.stop='edittree(data,node)'
  111. class="el-icon-edit-outline marleft5"
  112. style="fontSize:18px;"
  113. v-if="node.level!=1"
  114. ></i>
  115. <i
  116. @click.stop='deletetree(node)'
  117. class="el-icon-delete marleft5"
  118. style="fontSize:18px;"
  119. v-if="node.level!=1"
  120. ></i>
  121. <i
  122. @click.stop='paixuMD(data)'
  123. class="el-icon-sort marleft5"
  124. style="fontSize:18px;"
  125. v-if="node.level!=1"
  126. ></i>
  127. </span>
  128. </span>
  129. </el-tree>
  130. </div>
  131. </el-col>
  132. <el-col
  133. :span="9"
  134. style="padding-top:30px;"
  135. >
  136. <h3>上传文件入口显示配置</h3>
  137. <div
  138. class="peizhi"
  139. :style="{'height':heights-210+'px','overflow': 'hidden'}"
  140. >
  141. <div class="flexEnd">
  142. <i
  143. @click="rightPushTree"
  144. class="el-icon-plus"
  145. style="backgroundColor:#2A97DF;color:#fff;fontSize:20px;cursor: pointer;"
  146. ></i>
  147. </div>
  148. <el-tree
  149. :props="Rightprops"
  150. :data="rightData"
  151. node-key="id"
  152. accordion
  153. ref="tree"
  154. class="filter-tree"
  155. >
  156. </el-tree>
  157. </div>
  158. </el-col>
  159. </el-row>
  160. <!-- 新增编辑 -->
  161. <el-dialog
  162. :title="form.id?'编辑':'新增'"
  163. :visible.sync="treeTap"
  164. width="700px"
  165. :modal-append-to-body="false"
  166. @close="treeClose"
  167. >
  168. <div>
  169. <el-form
  170. ref="form"
  171. :model="form"
  172. label-width="120px"
  173. :rules="rules"
  174. >
  175. <el-form-item
  176. label="节点名称"
  177. prop="nodeName"
  178. >
  179. <el-input
  180. v-model="form.nodeName"
  181. style="width:400px;"
  182. ></el-input>
  183. </el-form-item>
  184. <el-form-item
  185. label="岗位类型"
  186. prop="postType"
  187. >
  188. <el-select
  189. v-model="form.postType"
  190. placeholder="请选择岗位"
  191. style="width:400px;"
  192. >
  193. <el-option
  194. v-for="item in JobTypeList"
  195. :key="item.id"
  196. :label="item.title"
  197. :value="item.id"
  198. ></el-option>
  199. </el-select>
  200. </el-form-item>
  201. <el-form-item
  202. label="节点类型"
  203. prop="nodeType"
  204. >
  205. <el-select
  206. :disabled='form.id!=""'
  207. v-model="form.nodeType"
  208. placeholder="请选择节点"
  209. style="width:400px;"
  210. >
  211. <el-option
  212. v-for="item in nodeTypeList"
  213. :key="item.value"
  214. :label="item.label"
  215. :value="item.value"
  216. ></el-option>
  217. </el-select>
  218. </el-form-item>
  219. <template v-if="form.nodeType==2">
  220. <el-form-item
  221. label="是否存储节点"
  222. prop="isStorageNode"
  223. >
  224. <el-select
  225. :disabled='form.id!=""'
  226. v-model="form.isStorageNode"
  227. style="width:400px;"
  228. >
  229. <el-option
  230. v-for="item in storageNodeList"
  231. :key="item.value"
  232. :label="item.label"
  233. :value="item.value"
  234. ></el-option>
  235. </el-select>
  236. </el-form-item>
  237. <template v-if="form.isStorageNode==1">
  238. <el-form-item
  239. label="是否竣工图"
  240. prop="isBuiltDrawing"
  241. >
  242. <el-select
  243. v-model="form.isBuiltDrawing"
  244. style="width:400px;"
  245. >
  246. <el-option
  247. v-for="item in builtDrawingList"
  248. :key="item.value"
  249. :label="item.label"
  250. :value="item.value"
  251. ></el-option>
  252. </el-select>
  253. </el-form-item>
  254. <el-form-item
  255. label="是否接口节点"
  256. prop="isInterfaceNode"
  257. >
  258. <el-select
  259. v-model="form.isInterfaceNode"
  260. style="width:400px;"
  261. >
  262. <el-option
  263. v-for="item in interfaceNodeList"
  264. :key="item.value"
  265. :label="item.label"
  266. :value="item.value"
  267. ></el-option>
  268. </el-select>
  269. </el-form-item>
  270. <template v-if="form.isInterfaceNode==1">
  271. <el-form-item label="选择接口类型">
  272. <el-select
  273. v-model="form.interfaceType"
  274. style="width:400px;"
  275. >
  276. <el-option
  277. v-for="item in interfaceTypeList"
  278. :key="item.value"
  279. :label="item.label"
  280. :value="item.value"
  281. ></el-option>
  282. </el-select>
  283. </el-form-item>
  284. </template>
  285. </template>
  286. </template>
  287. <!-- 数字化文件上传 -->
  288. <template v-if="form.nodeType==1">
  289. <el-form-item
  290. label="关联类型"
  291. prop="associationType"
  292. >
  293. <el-select
  294. v-model="form.associationType"
  295. style="width:400px;"
  296. placeholder="请选择"
  297. >
  298. <el-option
  299. v-for="item in associationTypeList"
  300. :key="item.value"
  301. :label="item.label"
  302. :value="item.value"
  303. ></el-option>
  304. </el-select>
  305. </el-form-item>
  306. <template v-if="form.associationType==1">
  307. <el-form-item
  308. label="业内资料类型"
  309. prop="majorDataType"
  310. >
  311. <el-checkbox-group v-model="form.majorDataType">
  312. <el-checkbox
  313. v-for="item in majorDataTypeList"
  314. :key="item.dictKey"
  315. :label="item.dictKey"
  316. name="type"
  317. >{{item.dictValue}}</el-checkbox>
  318. </el-checkbox-group>
  319. </el-form-item>
  320. <el-form-item
  321. label="显示层级"
  322. prop="displayHierarchy"
  323. >
  324. <el-select
  325. v-model="form.displayHierarchy"
  326. style="width:400px;"
  327. placeholder="请选择"
  328. >
  329. <el-option
  330. v-for="item in displayHierarchyList"
  331. :key="item.dictKey"
  332. :label="item.dictValue"
  333. :value="item.dictKey"
  334. ></el-option>
  335. </el-select>
  336. </el-form-item>
  337. </template>
  338. </template>
  339. </el-form>
  340. </div>
  341. <span
  342. slot="footer"
  343. class="dialog-footer"
  344. >
  345. <el-button @click="treeTap=false">取 消</el-button>
  346. <el-button
  347. type="primary"
  348. @click="saveTree"
  349. >保 存</el-button>
  350. </span>
  351. </el-dialog>
  352. <!-- 右侧树 -->
  353. <el-dialog
  354. title="上传文件入口显示配置"
  355. :visible.sync="pushfileTap"
  356. :modal-append-to-body='false'
  357. width="800px"
  358. @close="pushFileClose"
  359. >
  360. <div>
  361. <el-tree
  362. :props="dialogProps"
  363. show-checkbox
  364. :data="dialogData"
  365. node-key="id"
  366. accordion
  367. ref="trees"
  368. class="filter-tree"
  369. >
  370. </el-tree>
  371. </div>
  372. <span
  373. slot="footer"
  374. class="dialog-footer"
  375. >
  376. <el-button @click="pushfileTap = false">取 消</el-button>
  377. <el-button
  378. type="primary"
  379. @click="saveFile"
  380. >确 定</el-button>
  381. </span>
  382. </el-dialog>
  383. <!-- wbs树排序弹框 -->
  384. <el-dialog
  385. title="调整排序"
  386. :visible="sortTag"
  387. width="50%"
  388. append-to-body
  389. >
  390. <ManualSorting
  391. v-if="sortTag2"
  392. @bianhua='bianhua()'
  393. :sort='sort'
  394. />
  395. <span
  396. slot="footer"
  397. class="dialog-footer"
  398. >
  399. <el-button @click="sortTag=false,sortTag2=false">取 消</el-button>
  400. <el-button
  401. type="primary"
  402. @click="editSort()"
  403. >确 定</el-button>
  404. </span>
  405. </el-dialog>
  406. </basic-container>
  407. </template>
  408. <script>
  409. import ManualSorting from '@/components/WbsTree/ManualSorting'
  410. import { archiveTreeInit, lazyTree, dictionary, remove, archiveTreeSave, archiveTreeUpdate, archiveTreeDetail, archiveTreetree, submitDisplayConfigTree, getSameGradeNode, submitArchiveTreeSort } from "@/api/manager/archivetree";
  411. import { getToken } from '@/util/auth';
  412. import { roletree } from "@/api/system/role.js";
  413. export default {
  414. components: {
  415. ManualSorting,
  416. },
  417. data () {
  418. return {
  419. //#region 左侧树
  420. defaultExpanded: [],//默认选中的节点
  421. filterText: '',//筛选条件
  422. treeNode: {},
  423. nodeNames: '',
  424. token: '',
  425. props: {
  426. label: 'title',
  427. children: 'children',
  428. isLeaf: 'hasChildren'
  429. },
  430. data: [],//树节点枚举值
  431. //#endregion
  432. //#region 新增编辑节点弹框
  433. treeTap: false,
  434. form: {
  435. id: '',//新增还是编辑
  436. parentId: '', //上级节点id
  437. nodeName: "", //节点名称
  438. nodeType: '', // 节点类型 2 = 数字化上传文件
  439. postType: '', //岗位类型
  440. isStorageNode: '', //是否为存储节点
  441. isBuiltDrawing: '', //竣工图
  442. isInterfaceNode: '', //是否接口节点
  443. interfaceType: '', //选择接口类型
  444. associationType: '', //关联类型
  445. majorDataType: [], //内业资料类型
  446. displayHierarchy: '' //显示层级
  447. },
  448. rules: {
  449. nodeName: [{ required: true, message: '请输入节点名称', trigger: 'blur' }],
  450. postType: [{ required: true, message: '请选择岗位类型', trigger: 'change' }],
  451. nodeType: [{ required: true, message: '请选择节点类型', trigger: 'change' }],
  452. isStorageNode: [{ required: true, message: '请选择存储节点', trigger: 'change' }],
  453. isBuiltDrawing: [{ required: true, message: '请选择竣工图', trigger: 'change' }],
  454. isInterfaceNode: [{ required: true, message: '请选择接口节点', trigger: 'change' }],
  455. interfaceType: [{ required: true, message: '请选择接口类型', trigger: 'change' }],
  456. associationType: [{ required: true, message: '请选择关联类型', trigger: 'change' }],
  457. majorDataType: [{ required: true, message: '请选择业内资料类型', trigger: 'change' }],
  458. displayHierarchy: [{ required: true, message: '请选择显示层级', trigger: 'change' }],
  459. },
  460. JobTypeList: [],//岗位类型枚举
  461. nodeTypeList: [
  462. {
  463. label: '关联电子原生文件',
  464. value: 1
  465. }, {
  466. label: '数字化上传文件',
  467. value: 2
  468. },
  469. ],//节点类型枚举
  470. storageNodeList: [{
  471. label: '是',
  472. value: 1
  473. }, {
  474. label: '否',
  475. value: 2
  476. },],//存储节点枚举
  477. builtDrawingList: [{
  478. label: '是',
  479. value: 1
  480. }, {
  481. label: '否',
  482. value: 2
  483. },],//竣工图枚举
  484. interfaceNodeList: [{
  485. label: '是',
  486. value: 1
  487. }, {
  488. label: '否',
  489. value: 2
  490. },],//接口节点枚举
  491. interfaceTypeList: [
  492. {
  493. label: '试验接口',
  494. value: 1
  495. }, {
  496. label: '计量接口',
  497. value: 2
  498. },
  499. ],//选择接口类型枚举
  500. associationTypeList: [{
  501. label: '质检资料',
  502. value: 1
  503. },
  504. {
  505. label: '试验资料',
  506. value: 2
  507. },
  508. {
  509. label: '影像资料',
  510. value: 3
  511. },
  512. {
  513. label: '台账资料',
  514. value: 4
  515. }],//
  516. majorDataTypeList: [],//
  517. displayHierarchyList: [],//
  518. //#endregion
  519. //#region 右侧树节点
  520. pushfileTap: false,//开关
  521. Rightprops: {
  522. label: 'title'
  523. },
  524. rightData: [],
  525. //#endregion
  526. //#region 右侧树弹框
  527. dialogProps: {
  528. label: 'title'
  529. },
  530. dialogData: [],
  531. checkXuan: [],
  532. //#endregion
  533. heights: '',
  534. sortTag2: false,
  535. sortTag: false,
  536. sort: [],
  537. }
  538. },
  539. methods: {
  540. paixuMD (data) {
  541. this.sortTag = true
  542. this.sortTag2 = true
  543. this.curTreeData = data;
  544. this.findWbsTreeSameLevel(data.id)
  545. },
  546. async findWbsTreeSameLevel (parentId) {//查询当前节点的同级节点
  547. const { data: res } = await getSameGradeNode({ id: parentId })
  548. //console.log(res);
  549. if (res.code === 200) {
  550. this.sort = res.data
  551. }
  552. },
  553. bianhua () {
  554. this.sortTag2 = false
  555. this.$nextTick(() => {
  556. this.sortTag2 = true
  557. })
  558. },
  559. editSort () {//修改排序
  560. let sortArr = this.sort, newArr = []
  561. for (let i = 0; i < sortArr.length; i++) {
  562. newArr.push({
  563. id: sortArr[i].id,
  564. nodeName: sortArr[i].nodeName
  565. })
  566. }
  567. this.wbsTreeSort(newArr)
  568. },
  569. async wbsTreeSort (newArr) {//修改排序
  570. const { data: res } = await submitArchiveTreeSort(newArr)
  571. //console.log(res);
  572. if (res.code == 200) {
  573. this.sortTag = false
  574. this.sortTag2 = false
  575. //刷新页面
  576. window.location.reload()
  577. }
  578. },
  579. //#region 左侧树方法
  580. async loadNode (node, resolve) {
  581. console.log(node);
  582. if (node.level === 0) {
  583. let ks = await this.lazyTree(0)
  584. if (ks.length) {
  585. resolve(ks)
  586. } else {
  587. this.archiveTreeInit()
  588. }
  589. } else {
  590. resolve(await this.lazyTree(node.data.id))
  591. }
  592. },
  593. async archiveTreeInit () {//添加根节点
  594. const { data: res } = await archiveTreeInit()
  595. console.log(res);
  596. if (res.code == 200 && res.msg == '操作成功') {
  597. res.data.forEach(val => {
  598. val.hasChildren = !val.hasChildren
  599. });
  600. return res.data
  601. } else if (res.code == 200 && res.msg == "未查询到信息") {
  602. return []
  603. }
  604. },
  605. async lazyTree (parentId) {//树节点懒加载
  606. const { data: res } = await lazyTree({
  607. parentId,
  608. token: this.token
  609. })
  610. console.log(res);
  611. if (res.code == 200 && res.msg == '操作成功') {
  612. res.data.forEach(val => {
  613. val.hasChildren = !val.hasChildren
  614. });
  615. return res.data
  616. } else if (res.code == 200 && res.msg == "未查询到信息") {
  617. return []
  618. }
  619. },
  620. mouseLeave (data) {
  621. if (data.moreShow) {
  622. this.$set(data, 'moreShow', false)
  623. }
  624. },
  625. mouseOver (data) {
  626. if (!data.moreShow) {
  627. this.$set(data, 'moreShow', true)
  628. }
  629. },
  630. addtree (data, node) {//添加树
  631. console.log(data);
  632. if (this.JobTypeList.length == 0) {
  633. this.roletree()
  634. }
  635. if (this.majorDataTypeList.length == 0) {
  636. this.major_data_type()//内业资料类型
  637. }
  638. if (this.displayHierarchyList.length == 0) {
  639. this.display_hierarchy()//显示层级
  640. }
  641. this.form.postType = data.postType
  642. this.form.id = ''
  643. this.form.parentId = data.id
  644. if (this.filterText) {
  645. this.defaultExpanded = [data.id]
  646. }
  647. this.treeTap = true
  648. },
  649. async edittree (data) {//编辑树
  650. if (this.JobTypeList.length == 0) {
  651. this.roletree()
  652. }
  653. if (this.majorDataTypeList.length == 0) {
  654. this.major_data_type()//内业资料类型
  655. }
  656. if (this.displayHierarchyList.length == 0) {
  657. this.display_hierarchy()//显示层级
  658. }
  659. await this.archiveTreeDetail(data)
  660. this.form.id = data.id
  661. this.form.parentId = ''
  662. this.treeNode = data
  663. this.treeTap = true
  664. },
  665. deletetree (node) {//删除树
  666. console.log(node);
  667. let _that = this
  668. this.$confirm('是否删除此数据', '提示', {
  669. distinguishCancelAndClose: true,
  670. confirmButtonText: '确认',
  671. cancelButtonText: '取消'
  672. })
  673. .then(() => {
  674. this.remove(node.data.id).then(()=>{
  675. _that.$refs.trees1.remove(node) //删除界面上的节点
  676. }).catch(()=>{
  677. })
  678. })
  679. .catch(() => {
  680. });
  681. },
  682. async remove (id) {//删除接口
  683. const { data: res } = await remove({ id })
  684. console.log(res);
  685. if (res.code == 200) {
  686. this.$message({
  687. type: 'success',
  688. message: '删除成功'
  689. })
  690. }
  691. },
  692. async archiveTreeDetail (data) {//详情接口
  693. console.log(data);
  694. const { data: res } = await archiveTreeDetail({ id: data.id })
  695. console.log(res);
  696. if (res.code == 200) {
  697. this.form.nodeName = res.data.fullName //节点名称
  698. this.form.nodeType = res.data.nodeType // 节点类型 2 = 数字化上传文件
  699. this.form.postType = res.data.postType //岗位类型
  700. this.form.isStorageNode = res.data.isStorageNode //是否为存储节点
  701. this.form.isBuiltDrawing = res.data.isBuiltDrawing //竣工图
  702. this.form.isInterfaceNode = res.data.isInterfaceNode //是否接口节点
  703. this.form.interfaceType = res.data.interfaceType //选择接口类型
  704. this.form.associationType = res.data.associationType //关联类型
  705. this.form.majorDataType = res.data.majorDataType //内业资料类型
  706. this.form.displayHierarchy = res.data.displayHierarchy //显示层级
  707. }
  708. },
  709. async archiveTreetree4 () {//全加载左侧树
  710. const { data: res } = await archiveTreetree({
  711. token: this.token
  712. })
  713. console.log(res);
  714. if (res.code == 200 && res.msg == "操作成功") {
  715. this.data = res.data
  716. }
  717. },
  718. filterNode (value,data,node) {//筛选条件
  719. // 如果什么都没填就直接返回
  720. if(!value){
  721. return true;
  722. }
  723. let _array = [];//这里使用数组存储 只是为了存储值。
  724. this.getReturnNode(node,_array,value);
  725. let result = false;
  726. _array.forEach((item)=>{
  727. result = result || item;
  728. });
  729. return result;
  730. },
  731. //判断节点是否匹配
  732. getReturnNode(node,_array,value){
  733. let isPass = node.data && node.data.title && node.data.title.indexOf(value) !== -1;
  734. isPass?_array.push(isPass):'';
  735. //判断节点是否是父节点
  736. if(!isPass && node.level!=1 && node.parent){
  737. this.getReturnNode(node.parent,_array,value);
  738. }
  739. },
  740. //#endregion
  741. //#region 新增编辑节点弹框
  742. treeClose () {//弹框关闭事件
  743. this.form = {
  744. parentId: '', //上级节点id
  745. nodeName: "", //节点名称
  746. nodeType: '', // 节点类型 2 = 数字化上传文件
  747. postType: '', //岗位类型
  748. isStorageNode: '', //是否为存储节点
  749. isBuiltDrawing: '', //竣工图
  750. isInterfaceNode: '', //是否接口节点
  751. interfaceType: '', //选择接口类型
  752. associationType: '', //关联类型
  753. majorDataType: [], //内业资料类型
  754. displayHierarchy: '' //显示层级
  755. }
  756. this.$refs.form.resetFields();
  757. this.form.id = ''
  758. this.treeTap = false
  759. },
  760. async roletree () {//岗位类型枚举
  761. const { data: res } = await roletree()
  762. console.log(res);
  763. if (res.code == 200) {
  764. this.JobTypeList = res.data
  765. }
  766. },
  767. async major_data_type () {//内业资料类型
  768. const { data: res } = await dictionary({ code: 'major_data_type' })
  769. console.log(res);
  770. if (res.code == 200) {
  771. this.majorDataTypeList = res.data
  772. }
  773. },
  774. async display_hierarchy () {//显示层级
  775. const { data: res } = await dictionary({ code: 'display_hierarchy' })
  776. console.log(res);
  777. if (res.code == 200) {
  778. this.displayHierarchyList = res.data
  779. }
  780. },
  781. saveTree () {//保存按钮
  782. this.$refs.form.validate(val => {
  783. if (val) {
  784. if (this.form.nodeType == 2) {
  785. if (this.form.isStorageNode == 1) {
  786. if (this.form.isInterfaceNode == 1) {
  787. this.baocun({
  788. id: this.form.id,
  789. parentId: this.form.parentId, //上级节点id
  790. nodeName: this.form.nodeName, //节点名称
  791. nodeType: this.form.nodeType, // 节点类型
  792. postType: this.form.postType, //岗位类型
  793. isStorageNode: this.form.isStorageNode, //是否为存储节点
  794. isBuiltDrawing: this.form.isBuiltDrawing, //竣工图
  795. isInterfaceNode: this.form.isInterfaceNode, //是否接口节点
  796. interfaceType: this.form.interfaceType, //选择接口类型
  797. })
  798. } else {
  799. this.baocun({
  800. id: this.form.id,
  801. parentId: this.form.parentId, //上级节点id
  802. nodeName: this.form.nodeName, //节点名称
  803. nodeType: this.form.nodeType, // 节点类型
  804. postType: this.form.postType, //岗位类型
  805. isStorageNode: this.form.isStorageNode, //是否为存储节点
  806. isBuiltDrawing: this.form.isBuiltDrawing, //竣工图
  807. isInterfaceNode: this.form.isInterfaceNode, //是否接口节点
  808. })
  809. }
  810. } else {
  811. this.baocun({
  812. id: this.form.id,
  813. parentId: this.form.parentId, //上级节点id
  814. nodeName: this.form.nodeName, //节点名称
  815. nodeType: this.form.nodeType, // 节点类型
  816. postType: this.form.postType, //岗位类型
  817. isStorageNode: this.form.isStorageNode, //是否为存储节点
  818. })
  819. }
  820. } else if (this.form.nodeType == 1) {
  821. if (this.form.associationType == 1) {
  822. this.baocun({
  823. id: this.form.id,
  824. parentId: this.form.parentId, //上级节点id
  825. nodeName: this.form.nodeName, //节点名称
  826. nodeType: this.form.nodeType, // 节点类型
  827. associationType: this.form.associationType, //关联类型
  828. majorDataType: this.form.majorDataType, //内业资料类型
  829. displayHierarchy: this.form.displayHierarchy, //显示层级
  830. })
  831. } else {
  832. this.baocun({
  833. id: this.form.id,
  834. parentId: this.form.parentId, //上级节点id
  835. nodeName: this.form.nodeName, //节点名称
  836. nodeType: this.form.nodeType, // 节点类型
  837. associationType: this.form.associationType, //关联类型
  838. })
  839. }
  840. }
  841. }
  842. })
  843. },
  844. async baocun (da) {
  845. if (da.majorDataType) {
  846. if (da.majorDataType.length > 0) {
  847. let das = ''
  848. da.majorDataType.forEach((val, key) => {
  849. das += val
  850. if (da.majorDataType.length - 1 != key) {
  851. das += ','
  852. }
  853. })
  854. da.majorDataType = das
  855. }
  856. }
  857. if (this.form.id) {
  858. await this.archiveTreeUpdate(da)
  859. } else {
  860. await this.archiveTreeSave(da)
  861. }
  862. if (this.filterText) {
  863. this.archiveTreetree4()
  864. }
  865. },
  866. async archiveTreeSave (da) {//新增
  867. console.log(da);
  868. const { data: res } = await archiveTreeSave(da)
  869. console.log(res);
  870. if (res.code == 200) {
  871. this.$message({
  872. type: 'success',
  873. message: '新增成功'
  874. })
  875. this.treeTap = false
  876. let das = await this.lazyTree(da.parentId)
  877. this.$refs.trees1.updateKeyChildren(da.parentId, das)
  878. let node = this.$refs.trees1.getNode(da.parentId);
  879. node.isLeaf = false;
  880. node.isLeafByUser = false;
  881. }
  882. },
  883. async archiveTreeUpdate (da) {//编辑
  884. const { data: res } = await archiveTreeUpdate(da)
  885. console.log(res);
  886. if (res.code == 200) {
  887. this.$message({
  888. type: 'success',
  889. message: '编辑成功'
  890. })
  891. this.treeTap = false
  892. this.treeNode.title = da.nodeName
  893. this.treeNode.postType = da.postType
  894. }
  895. },
  896. //#endregion
  897. //#region 右侧树节点
  898. async rightPushTree () {//右侧节点树
  899. this.checkXuan = []
  900. await this.archiveTreetree2({
  901. token: this.token,
  902. nodeType: 2,
  903. })
  904. this.pushfileTap = true
  905. await this.saixuan(this.dialogData)
  906. console.log(this.checkXuan);
  907. this.$refs.trees.setCheckedKeys(this.checkXuan);
  908. },
  909. // 赛选
  910. saixuan (da) {//赛选
  911. if (da.length > 0) {
  912. let tag = true
  913. da.forEach(val => {
  914. if (val.isDisplayTree == 1 && val.hasChildren) {
  915. let ks = this.saixuan(val.children)
  916. if (ks) {
  917. this.checkXuan.push(val.id)
  918. }
  919. } else if (val.isDisplayTree == 1 && !val.hasChildren) {
  920. this.checkXuan.push(val.id)
  921. } else {
  922. tag = false
  923. }
  924. })
  925. return tag
  926. }
  927. },
  928. pushFileClose () {//弹框关闭事件
  929. this.checkXuan = []
  930. },
  931. async archiveTreetree (da) {//右侧树全加载接口
  932. const { data: res } = await archiveTreetree(da)
  933. console.log(res);
  934. if (res.code == 200 && res.msg == "操作成功") {
  935. this.rightData = res.data
  936. }
  937. },
  938. //#endregion
  939. //#region 右侧树弹框
  940. async submitDisplayConfigTree (ids) {//保存接口
  941. const { data: res } = await submitDisplayConfigTree({ ids })
  942. console.log(res);
  943. if (res.code == 200) {
  944. this.$message({
  945. type: 'success',
  946. message: '设置成功'
  947. })
  948. this.archiveTreetree({
  949. token: this.token,
  950. disPlayTree: 1,
  951. nodeType: 2,
  952. })
  953. this.pushfileTap = false
  954. }
  955. },
  956. async archiveTreetree2 (da) {//右侧树全加载接口
  957. const { data: res } = await archiveTreetree(da)
  958. console.log(res);
  959. if (res.code == 200 && res.msg == "操作成功") {
  960. this.dialogData = res.data
  961. }
  962. },
  963. saveFile () {//保存按钮
  964. let zi = this.$refs.trees.getCheckedKeys() //返回选中子节点的key
  965. let fu = this.$refs.trees.getHalfCheckedKeys()//返回选中子节点的父节点的key
  966. let arr = [...zi, ...fu]
  967. if (arr.length > 0) {
  968. let ids = ''
  969. arr.forEach((val, key) => {
  970. ids += val
  971. if (key != arr.length - 1) {
  972. ids += ','
  973. }
  974. })
  975. this.submitDisplayConfigTree(ids)
  976. } else {
  977. this.$message({
  978. type: 'error',
  979. message: '请先设置配置文件'
  980. })
  981. }
  982. },
  983. //#endregion
  984. },
  985. watch: {
  986. filterText (val) {
  987. this.$refs.trees2.filter(val);
  988. }
  989. },
  990. created () {
  991. this.token = 'bearer ' + getToken()
  992. this.archiveTreetree({
  993. token: this.token,
  994. disPlayTree: 1,
  995. nodeType: 2,
  996. })
  997. this.archiveTreetree4()//全加载左侧树
  998. },
  999. mounted () {
  1000. this.heights = this.$refs.container.$el.offsetHeight
  1001. }
  1002. }
  1003. </script>
  1004. <style lang="scss" scoped>
  1005. .peizhi {
  1006. border: 1px solid #e5e5e5;
  1007. border-radius: 5px;
  1008. padding: 15px 10px;
  1009. }
  1010. </style>