archivetree.vue 31 KB

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