SelectBoard.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <el-dialog
  3. title="设置首页内容"
  4. :visible.sync="show"
  5. :modal-append-to-body="false"
  6. :close-on-click-modal="false"
  7. :center="true"
  8. v-dialogDrag
  9. custom-class="dialogclass"
  10. width="680px"
  11. @close="handleClose"
  12. >
  13. <div class="set-board-wrap">
  14. <div>BI看板</div>
  15. <el-cascader
  16. style="width:500px"
  17. v-model="selectBoardId"
  18. :props="{ emitPath: false }"
  19. :options="list"
  20. ref="selectBoardEl"
  21. ></el-cascader>
  22. </div>
  23. <div class="dia-bot">
  24. <el-button
  25. type="primary"
  26. plain
  27. @click="handleClose"
  28. style="margin-right: 20px"
  29. >{{ $t("Dialog.cancel_btn") }}</el-button
  30. >
  31. <el-button type="primary" @click="saveHandle">{{
  32. $t("Dialog.confirm_save_btn")
  33. }}</el-button>
  34. </div>
  35. </el-dialog>
  36. </template>
  37. <script>
  38. import apiBiBoard from '@/api/modules/BIBoard.js'
  39. export default {
  40. name: "selectBoard",
  41. model: {
  42. prop: 'show',
  43. event: 'showChange'
  44. },
  45. props: {
  46. show: {
  47. type: Boolean,
  48. default: false
  49. },
  50. boardId:''
  51. },
  52. watch: {
  53. show(n) {
  54. if (n) {
  55. this.selectBoardId=this.boardId||''
  56. this.getList()
  57. }
  58. }
  59. },
  60. data() {
  61. return {
  62. list: [
  63. {
  64. label: '我的看板',
  65. value: '我的看板',
  66. children: []
  67. },
  68. {
  69. label: '共享看板',
  70. value: '共享看板',
  71. children: []
  72. },
  73. {
  74. label: '公共看板',
  75. value: '公共看板',
  76. children: []
  77. }
  78. ],
  79. selectBoardId: ''
  80. }
  81. },
  82. methods: {
  83. async saveHandle(){
  84. if(!this.selectBoardId){
  85. this.$message.warning('请选择BI看板')
  86. return
  87. }
  88. let FromType=3
  89. const elData=this.$refs.selectBoardEl.getCheckedNodes()
  90. if(elData[0].path[0]==='我的看板'){
  91. FromType=1
  92. }else if(elData[0].path[0]==='共享看板'){
  93. FromType=2
  94. }else{
  95. FromType=3
  96. }
  97. const res=await apiBiBoard.setHomePageBoard({
  98. BiDashboardId:this.selectBoardId,
  99. FromType:FromType
  100. })
  101. if(res.Ret===200){
  102. this.$message.success('保存成功')
  103. this.handleClose()
  104. this.$emit('change')
  105. }
  106. },
  107. // 公共看板列表
  108. async getList(type) {
  109. const resMy = await apiBiBoard.myBoardList()
  110. if (resMy.Ret === 200) {
  111. const arr = resMy.Data || []
  112. this.list[0].children = arr.map(item => {
  113. return {
  114. label: item.BiDashboardName,
  115. value: item.BiDashboardId
  116. }
  117. })
  118. }
  119. const resShare = await apiBiBoard.shareBoardList()
  120. if (resShare.Ret === 200) {
  121. const myArr = resShare.Data.MyList || []
  122. const otherArr = resShare.Data.OtherList || []
  123. this.list[1].children = [
  124. {
  125. label: '我共享的',
  126. value: 'my_share',
  127. children: myArr.map(item => {
  128. return {
  129. label: item.BiDashboardName,
  130. value: item.BiDashboardId
  131. }
  132. })
  133. },
  134. {
  135. label: '共享给我的',
  136. value: 'other_share',
  137. children: otherArr.map(item => {
  138. return {
  139. label: item.BiDashboardName,
  140. value: item.BiDashboardId
  141. }
  142. })
  143. }
  144. ]
  145. }
  146. const resCommon = await apiBiBoard.commonBoardList()
  147. if(resCommon.Ret===200){
  148. const arr=resCommon.Data||[]
  149. this.list[2].children=arr.map(item1=>{
  150. const obj1={
  151. label:item1.GroupName,
  152. value:item1.GroupId+item1.GroupName,
  153. children:[]
  154. }
  155. obj1.children=item1.Children?item1.Children.map(item2=>{
  156. const obj2={
  157. label:item2.GroupName,
  158. value:item2.GroupId+item2.GroupName,
  159. children:[]
  160. }
  161. obj2.children=item2.DashboardList?item2.DashboardList.map(item3=>{
  162. return {
  163. label:item3.BiDashboardName,
  164. value:item3.BiDashboardId,
  165. }
  166. }):[]
  167. }):[]
  168. return obj1
  169. })
  170. }
  171. },
  172. handleClose() {
  173. this.boardId = ''
  174. this.$emit('showChange', false)
  175. },
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .set-board-wrap{
  181. display: flex;
  182. align-items: center;
  183. gap: 0 10px;
  184. }
  185. .dia-bot {
  186. display: flex;
  187. justify-content: center;
  188. margin: 60px 0 40px 0;
  189. }
  190. </style>