edbCollectDia.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div class="edbCollectDia-container">
  3. <el-dialog
  4. :visible.sync="show"
  5. :close-on-click-modal="false"
  6. :modal-append-to-body="false"
  7. title="收藏"
  8. @close="cancelHandle"
  9. custom-class="dialog"
  10. center
  11. width="560px"
  12. v-dialogDrag
  13. >
  14. <div class="dialog-min">
  15. <div class="classify-cont">
  16. <el-tag
  17. v-for="item in classifyArr"
  18. :class="['classify-tag',{'act': checkedClassifys.includes(item.ClassifyId)}]"
  19. :key="item.ClassifyId"
  20. type="info"
  21. effect="plain"
  22. @click="chooseClassify(item.ClassifyId)"
  23. >
  24. {{ item.ClassifyName }}
  25. </el-tag>
  26. </div>
  27. <span class="add-cont" @click="$parent.handleOpenCollectClassify">
  28. <i class="el-icon-circle-plus-outline" />新增
  29. </span>
  30. </div>
  31. <div class="dia-bot">
  32. <el-button type="primary" style="margin-right: 20px" plain @click="cancelHandle">{{$t('Dialog.cancel_btn')}}</el-button>
  33. <el-button type="primary" @click="saveHandle"
  34. >{{$t('Dialog.confirm_save_btn')}}</el-button
  35. >
  36. </div>
  37. </el-dialog>
  38. </div>
  39. </template>
  40. <script>
  41. import { edbCollectInterface } from '@/api/modules/chartApi'
  42. export default {
  43. name:'',
  44. props: {
  45. show: {
  46. type: Boolean,
  47. },
  48. edbId: {
  49. type: Number,
  50. },
  51. add_ids: {
  52. type: Array,
  53. default: []
  54. }
  55. },
  56. watch: {
  57. show(newval) {
  58. if(newval) {
  59. this.getClassify();
  60. }
  61. }
  62. },
  63. data () {
  64. return {
  65. classifyArr:[],//分类列表
  66. checkedClassifys: [],
  67. addRules: {
  68. name:[
  69. { required: true, message: /* '分类名称不能为空' */this.$t('Chart.Vailds.classify_msg'), trigger: 'blur' },
  70. ],
  71. }
  72. };
  73. },
  74. methods: {
  75. /* 获取分类列表 */
  76. getClassify() {
  77. edbCollectInterface.getEdbCollectClassifyOne()
  78. .then(res => {
  79. if(res.Ret !== 200) return
  80. this.classifyArr = res.Data || [];
  81. this.checkedClassifys = _.cloneDeep(this.add_ids);
  82. })
  83. },
  84. chooseClassify(id) {
  85. if(this.checkedClassifys.includes(id)) {
  86. let index = this.checkedClassifys.indexOf(id);
  87. this.checkedClassifys.splice(index, 1);
  88. }else {
  89. this.checkedClassifys.push(id);
  90. }
  91. },
  92. /* 加入收藏 */
  93. saveHandle() {
  94. if(!this.checkedClassifys.length) return this.$message.warning('请选择分类');
  95. edbCollectInterface.edbCollect({
  96. EdbInfoId: this.edbId,
  97. ClassifyIdList: this.checkedClassifys
  98. }).then(res => {
  99. if(res.Ret !== 200) return
  100. this.$message.success('收藏成功')
  101. this.$emit('success',this.checkedClassifys)
  102. this.cancelHandle()
  103. })
  104. },
  105. cancelHandle() {
  106. this.checkedClassifys = [];
  107. this.$emit('update:show')
  108. }
  109. },
  110. }
  111. </script>
  112. <style lang="scss">
  113. .edbCollectDia-container {
  114. .el-dialog--center .el-dialog__body {
  115. padding: 25px 25px 30px !important;
  116. }
  117. .dialog-min {
  118. .classify-cont {
  119. padding: 30px 10px;
  120. border: 1px dashed #999;
  121. display: flex;
  122. flex-wrap: wrap;
  123. margin-bottom: 20px;
  124. .classify-tag {
  125. margin: 5px;
  126. padding: 0 20px;
  127. cursor: pointer;
  128. &.act {
  129. background: #0052D9;
  130. color: #fff;
  131. }
  132. }
  133. }
  134. .add-cont {
  135. color: #0052D9;
  136. cursor: pointer;
  137. }
  138. }
  139. .dia-bot {
  140. margin: 52px 0 30px;
  141. display: flex;
  142. justify-content: center;
  143. }
  144. }
  145. </style>