chooseLable.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view>
  3. <mp-tree v-slot:default="{item}" :checkList="checkList" v-if="tree.length>0" :props="prop"
  4. @sendValue="confirm" :parent="false" :isCheck="true" :trees="tree">
  5. <!-- 内容插槽 -->
  6. <view>
  7. <view class="content-item">
  8. <view class="word">{{item.dictKey}}</view>
  9. </view>
  10. </view>
  11. </mp-tree>
  12. </view>
  13. </template>
  14. <script>
  15. import mpTree from '@/components/mp-tree/tree.vue';
  16. export default {
  17. components: {
  18. mpTree
  19. },
  20. data() {
  21. return {
  22. tree: [],
  23. checkList: [{
  24. dictKey: "美食",
  25. dictValue: "美食",
  26. hasChildren: true,
  27. id: "1430416319940947969"
  28. }],
  29. prop: {
  30. label: 'dictKey',
  31. children: 'children',
  32. multiple: true,
  33. checkStrictly: true
  34. },
  35. }
  36. },
  37. onLoad(option) {
  38. this.getLabel()
  39. },
  40. methods: {
  41. getLabel(){
  42. let params={
  43. code:'business_label'
  44. }
  45. this.$api.dict.dictionaryTree(params).then(res=>{
  46. this.tree=res.data
  47. })
  48. },
  49. //获取选中的值
  50. confirm(val, back) {
  51. let checkList=[]
  52. val.forEach(item=>{
  53. let obj={
  54. id:item.id,
  55. hasChildren:item.hasChildren,
  56. dictKey:item.dictKey,
  57. dictValue:item.dictValue
  58. }
  59. checkList.push(obj)
  60. })
  61. console.log(checkList);
  62. },
  63. }
  64. }
  65. </script>
  66. <style lang="scss">
  67. .box_sizing {
  68. -webkit-box-sizing: border-box;
  69. -moz-box-sizing: border-box;
  70. box-sizing: border-box;
  71. }
  72. .btn {
  73. position: fixed;
  74. bottom: 0;
  75. padding: 10px;
  76. background-color: #fff;
  77. width: 100%;
  78. .sureBtn {
  79. background-color: #0095F2;
  80. color: #fff;
  81. }
  82. }
  83. .content-item {
  84. display: flex;
  85. position: relative;
  86. align-items: center;
  87. .person {
  88. height: 64rpx;
  89. min-width: 64rpx;
  90. border-radius: 50%;
  91. border: 1rpx solid rgba(0, 149, 235, 0.15);
  92. background-color: rgba(0, 149, 235, 0.1);
  93. margin-left: 0px;
  94. color: #0095F2;
  95. line-height: 64rpx;
  96. font-size: 22rpx;
  97. text-align: center;
  98. margin-left: 20rpx;
  99. }
  100. .word {
  101. margin-left: 16rpx;
  102. font-size: 30rpx;
  103. color: #5b5757;
  104. width: 500rpx;
  105. word-break: break-all;
  106. }
  107. }
  108. </style>