Test1.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <a-row :gutter="10">
  3. <a-col :span="5">
  4. <a-card title="基础">
  5. <a-row>
  6. <VueDraggable
  7. v-model="list1"
  8. :animation="150"
  9. :group="{ name: 'people', pull: 'clone', put: false }"
  10. :sort="false"
  11. :clone="onClone"
  12. >
  13. <a-col
  14. :span="12"
  15. v-for="item in list1"
  16. :key="item.id">
  17. <div
  18. class="hover type"
  19. >
  20. <a-space>
  21. <a-icon type="profile" /> {{ item.name }}
  22. </a-space>
  23. </div>
  24. </a-col>
  25. </VueDraggable>
  26. </a-row>
  27. </a-card>
  28. </a-col>
  29. <a-col :span="15">
  30. <a-card>
  31. <a-form
  32. :form="form"
  33. :labelCol="BaseTool.Constant.labelCol"
  34. :wrapperCol="BaseTool.Constant.wrapperCol">
  35. <row-list :col="2">
  36. <VueDraggable
  37. v-model="list2"
  38. :animation="150"
  39. group="people"
  40. >
  41. <row-item
  42. class="hover"
  43. v-for="item in list2"
  44. :key="item.id"
  45. >
  46. <MComponent
  47. :detail="item"
  48. @select="handleSelect"
  49. />
  50. </row-item>
  51. </VueDraggable>
  52. </row-list>
  53. </a-form>
  54. </a-card>
  55. </a-col>
  56. <a-col :span="4">
  57. <Detail ref="detail"/>
  58. </a-col>
  59. </a-row>
  60. </template>
  61. <script>
  62. import { VueDraggable } from 'vue-draggable-plus'
  63. import Detail from './modules/Detail.vue'
  64. import MComponent from './modules/Component.vue'
  65. export default {
  66. name: 'Test1',
  67. components: {
  68. VueDraggable,
  69. Detail,
  70. MComponent
  71. },
  72. data () {
  73. return {
  74. form: this.$form.createForm(this),
  75. list1: [
  76. {
  77. id: 1,
  78. name: '单行文本',
  79. type: 'input',
  80. value: 'input',
  81. dependentId: false,
  82. required: true,
  83. label: 'label',
  84. attrs: {
  85. placeholder: '请输入'
  86. }
  87. },
  88. {
  89. id: 2,
  90. name: '多行文本',
  91. type: 'textarea',
  92. value: 'textarea',
  93. dependentId: false,
  94. required: true,
  95. label: 'label',
  96. attrs: {
  97. placeholder: '请输入'
  98. }
  99. }
  100. ],
  101. list2: [],
  102. detail: {}
  103. }
  104. },
  105. created () {
  106. },
  107. methods: {
  108. onClone (element) {
  109. // 生成随机id
  110. const val = {
  111. ...element,
  112. id: Math.floor(Math.random() * 10000000000000)
  113. }
  114. this.handleSelect(val)
  115. return val
  116. },
  117. update (val) {
  118. console.log(val)
  119. },
  120. handleSelect (item) {
  121. this.$refs.detail.base(item)
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="less" scoped>
  127. .type{
  128. border: 1px solid #ccc;
  129. padding: 5px;
  130. margin: 5px;
  131. border-radius: 5px;
  132. }
  133. </style>