defaultBizConfig.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * @description: 此处是业务组件的代码案例
  3. * @Date: 2023-06-06 15:45:07
  4. */
  5. // vue 组件片段
  6. export const defaultVueContent = `
  7. <!-- 这是一个代码案例 -->
  8. <template>
  9. <div class="div-test-container" @click="testClick">
  10. <p>点击测试下点击事件</p>
  11. <br />
  12. {{ customize.text }}
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'TestA',
  18. components: {
  19. },
  20. // 业务组件提供的props
  21. props: {
  22. config: {
  23. type: Object,
  24. default: () => ({})
  25. }
  26. },
  27. data () {
  28. return {
  29. }
  30. },
  31. // 计算属性
  32. computed: {
  33. option () {
  34. return this.config.option
  35. },
  36. optionData () {
  37. return this.option.data
  38. },
  39. customize () {
  40. return this.option.customize
  41. }
  42. },
  43. methods: {
  44. // 联动需要调用次接口
  45. linkage (row) {
  46. this.$emit('linkage', row)
  47. },
  48. // 自己随便写的方法
  49. testClick () {
  50. this.$message.success('点击了边框')
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. // 此处书写样式,支持scss
  57. .div-test-container {
  58. width: 200px;
  59. height: 200px;
  60. border: 4px solid #f00;
  61. display: flex;
  62. justify-content: center;
  63. align-items: center;
  64. color: #fff;
  65. flex-direction: column;
  66. .item {
  67. width: 100%;
  68. height: 50px;
  69. line-height: 50px;
  70. text-align: center;
  71. }
  72. }
  73. </style>
  74. `
  75. // 配置 片段
  76. export const defaultSettingContent = `
  77. // 这是一个配置案例
  78. // 组件备注名称
  79. const title = '边框案例'
  80. // 右侧配置项
  81. const setting = [
  82. {
  83. label: '维度',
  84. // 设置组件类型, select / input / colorPicker
  85. type: 'select',
  86. // 字段
  87. field: 'xField',
  88. optionField: 'xField', // 对应options中的字段
  89. // 是否多选
  90. multiple: false,
  91. // 绑定的值
  92. value: '',
  93. // tab页。 data: 数据, custom: 自定义
  94. tabName: 'data'
  95. },
  96. {
  97. label: '指标',
  98. // 设置组件类型
  99. type: 'select',
  100. // 字段
  101. field: 'yField',
  102. // 对应options中的字段
  103. optionField: 'yField',
  104. // 是否多选
  105. multiple: false,
  106. value: '',
  107. tabName: 'data'
  108. },
  109. {
  110. label: '用户名',
  111. // 设置组件类型, select / input / colorPicker
  112. type: 'input',
  113. // 字段
  114. field: 'customize_username',
  115. optionField: 'customize.username', // 对应options中的字段
  116. // 是否多选
  117. multiple: false,
  118. // 绑定的值
  119. value: '',
  120. // tab页。 data: 数据, custom: 自定义
  121. tabName: 'custom'
  122. },
  123. {
  124. label: '手机号',
  125. // 设置组件类型, select / input / colorPicker
  126. type: 'input',
  127. // 字段
  128. field: 'customize_phone',
  129. optionField: 'customize.phone', // 对应options中的字段
  130. // 是否多选
  131. multiple: false,
  132. // 绑定的值
  133. value: '',
  134. // tab页。 data: 数据, custom: 自定义
  135. tabName: 'custom'
  136. }
  137. ]
  138. // 模拟数据
  139. const data = []
  140. const option = {
  141. // 数据
  142. data: data,
  143. // 数据的字段相关属性
  144. xField: '',
  145. yField: '',
  146. seriesField: '',
  147. // 自定义组件其他属性
  148. customize: {
  149. text: '这是一个边框'
  150. }
  151. }
  152. export default {
  153. title,
  154. option,
  155. setting
  156. }
  157. `