archivetree.vue 31 KB

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