archivetree.vue 27 KB

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