location_flag.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div class="localtion-falg">
  3. <div class="select-flag dcenter">
  4. <el-tag class="localtion-tag" @close="delTags(item)" :key="item" color="#FFF6E7" type="warning" size="small" v-for="item in localtionArr" closable>{{item}}</el-tag>
  5. </div>
  6. <div class="localtion-do-point dcenter pointer">更多可用标签</div>
  7. <div class="localtion-view">
  8. <div class="location-tag-view">
  9. <el-tag @click="addToActive(item.Name)" :key="item.Name" class="default-tag pointer" v-for="item in queryLocaltionArr" size="small" color="#fff">{{item.Name}}</el-tag>
  10. </div>
  11. </div>
  12. <div class="center">
  13. <el-input v-model="localtionName" style="width:200px;margin-right:10px;"></el-input>
  14. <el-button type="primary" @click="addLocaltion">新增标签</el-button>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import {
  20. mapGetters,
  21. mapActions
  22. } from "vuex";
  23. import {
  24. queryLocaltionFlag,
  25. updateLocaltionFlag,
  26. delLocaltionFlag,
  27. addLocaltionFlag
  28. } from "@/fetch/point_http"
  29. export default {
  30. name: 'localtion-flag',
  31. props: {
  32. renderData: {
  33. type: Object,
  34. default:function(){
  35. return {
  36. LocationFlag: []
  37. }
  38. }
  39. }
  40. },
  41. data() {
  42. return {
  43. localtionArr: [],
  44. localtionName: "",
  45. queryLocaltionArr: []
  46. }
  47. },
  48. computed: {
  49. ...mapGetters("project", [
  50. "projectId",
  51. "datasourceId",
  52. "protocolType"
  53. ])
  54. },
  55. created() {},
  56. mounted() {
  57. this.queryData()
  58. this.changeData()
  59. },
  60. methods: {
  61. //将标签添加到活跃标签中
  62. addToActive(val){
  63. console.log(val)
  64. this.localtionArr.push(val)
  65. this.changeTags()
  66. },
  67. //删除已有标签
  68. delTags(val){
  69. this.localtionArr = this.localtionArr.map(item => {
  70. if(item == val){
  71. return undefined
  72. }else{
  73. return item
  74. }
  75. }).filter(d => d);
  76. console.log(this.localtionArr)
  77. this.changeTags()
  78. },
  79. changeTags(){
  80. this.renderData.LocationFlag = this.localtionArr
  81. this.$emit("changeTag")
  82. },
  83. queryData(){
  84. queryLocaltionFlag({},res => {
  85. console.log(res)
  86. this.queryLocaltionArr = res.Content
  87. })
  88. },
  89. //添加位置标签
  90. addLocaltion(){
  91. let param = {
  92. Name: this.localtionName
  93. }
  94. addLocaltionFlag(param,res => {
  95. this.queryData()
  96. this.$message.success("添加成功")
  97. this.localtionName = ""
  98. })
  99. },
  100. changeData(){
  101. this.localtionArr = this.renderData.LocationFlag || []
  102. }
  103. },
  104. watch: {
  105. renderData: {
  106. deep: true,
  107. handler: function(){
  108. this.changeData()
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. .localtion-falg{
  116. height: 300px;
  117. overflow: hidden;
  118. .select-flag{
  119. height: 80px;
  120. width: 540px;
  121. line-height: 40px;
  122. border-bottom: 1px solid #DEE3F3;
  123. overflow-y: auto;
  124. }
  125. .localtion-do-point{
  126. height: 30px;
  127. width: 112px;
  128. line-height: 30px;
  129. background-color: #EEFAFF;
  130. font-size: 12px;
  131. color: #8E9CC1;
  132. text-align: center;
  133. }
  134. .localtion-tag{
  135. border-radius: 100px;
  136. color: #F5A623;
  137. border-color: #F5A623;
  138. margin-right: 10px;
  139. }
  140. .localtion-view{
  141. height: 115px;
  142. margin-top: 10px;
  143. .location-tag-view{
  144. margin-left: 20px;
  145. height: 100%;
  146. overflow-y: auto;
  147. .default-tag{
  148. border-color: #C2CEDB;
  149. color:#8E9CC1;
  150. border-radius: 100px;
  151. margin-right: 10px;
  152. }
  153. }
  154. }
  155. }
  156. </style>