addList.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div class='add-transfer'>
  3. <div>
  4. <el-input
  5. size='small'
  6. @keyup.enter.native='queryAll'
  7. prefix-icon='el-icon-search'
  8. v-model='keyword'
  9. style='width:192px;margin-right:12px;margin-top:20px;margin-bottom:12px'
  10. ></el-input>
  11. </div>
  12. <el-transfer v-model='value' :data='data' v-loading='loading' @change='transferChange'></el-transfer>
  13. </div>
  14. </template>
  15. <script>
  16. import { getTransfer, updateRelation, queryRelation } from '@/api/legendLibrary.js'
  17. export default {
  18. data() {
  19. return {
  20. data: [],
  21. value: [],
  22. keyword: '',
  23. multipleSelection: [],
  24. loading: false
  25. }
  26. },
  27. props: ['GraphCategoryId'],
  28. methods: {
  29. transferChange(value) {
  30. this.multipleSelection = value
  31. },
  32. queryAll() {
  33. let getParams = {
  34. keywords: this.keyword
  35. }
  36. this.data = []
  37. getTransfer({ getParams }).then(res => {
  38. //console.log(res)
  39. let content = res.Content
  40. content.forEach(el => {
  41. this.data.push({
  42. label: el.Name + '',
  43. key: el.Id
  44. })
  45. })
  46. })
  47. if (this.GraphCategoryId) {
  48. this.querySelectTab(this.GraphCategoryId)
  49. }
  50. },
  51. querySelectTab(GraphCategoryId) {
  52. let postParams = {}
  53. let data = {
  54. graphCategoryId: GraphCategoryId
  55. }
  56. queryRelation({ data, postParams }).then(res => {
  57. let content = res.data.Content
  58. content.forEach(el => {
  59. this.value.push(el.Id)
  60. })
  61. this.loading = false
  62. })
  63. },
  64. save() {
  65. this.loading = true
  66. let GraphElementIds = this.value.forEach
  67. let postParams = {
  68. GraphCategoryId: this.GraphCategoryId,
  69. GraphElementIds: this.value
  70. }
  71. updateRelation({ postParams }).then(res => {
  72. if (res.Result == 'success') {
  73. this.$message.success('添加成功!')
  74. this.$emit('mesg')
  75. }
  76. })
  77. }
  78. },
  79. mounted() {
  80. this.queryAll()
  81. }
  82. }
  83. </script>
  84. <style lang='less' scoped>
  85. .add-transfer {
  86. margin-top: 20px;
  87. margin-left: 20px;
  88. }
  89. </style>