RelationSetting.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <!--
  2. * @description: 设置联动的弹窗
  3. * @Date: 2023-01-04 14:57:06
  4. * @Author: xing.heng
  5. * @LastEditors: wujian
  6. * @LastEditTime: 2023-05-23 15:46:03
  7. -->
  8. <template>
  9. <el-dialog
  10. title="组件联动设置"
  11. :visible.sync="settingVisible"
  12. :close-on-click-modal="false"
  13. :before-close="handleClose"
  14. width="800px"
  15. append-to-body
  16. class="bs-dialog-wrap bs-el-dialog"
  17. >
  18. <el-form
  19. ref="form"
  20. label-width="100px"
  21. class="bs-el-form"
  22. >
  23. <el-table
  24. :data="configMapConfig.maps"
  25. class="bs-table bs-el-table"
  26. >
  27. <el-empty />
  28. <el-table-column
  29. label="当前组件映射参数"
  30. align="center"
  31. >
  32. <template #default="scope">
  33. <el-select
  34. v-model="configMapConfig.maps[scope.$index].sourceField"
  35. popper-class="bs-el-select"
  36. class="bs-el-select"
  37. >
  38. <el-option
  39. v-for="sourceField in sourceFieldList"
  40. :key="sourceField.value"
  41. :label="sourceField.label"
  42. :value="sourceField.value"
  43. />
  44. </el-select>
  45. </template>
  46. </el-table-column>
  47. <el-table-column
  48. label="映射规则"
  49. align="center"
  50. >
  51. <span>赋值给</span>
  52. </el-table-column>
  53. <el-table-column
  54. label="目标组件接收参数"
  55. align="center"
  56. >
  57. <template #default="scope">
  58. <el-select
  59. v-model="configMapConfig.maps[scope.$index].targetField"
  60. popper-class="bs-el-select"
  61. class="bs-el-select"
  62. >
  63. <el-option
  64. v-for="targetField in targetFieldList"
  65. :key="targetField.value"
  66. :label="targetField.label"
  67. :value="targetField.value"
  68. :disabled="choosedTargetFields.includes(targetField.value)"
  69. />
  70. </el-select>
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. label="操作"
  75. align="center"
  76. width="100px"
  77. >
  78. <template slot-scope="scope">
  79. <el-button
  80. type="text"
  81. size="small"
  82. @click="handleDelete(scope.$index)"
  83. >
  84. 删除
  85. </el-button>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. </el-form>
  90. <el-button
  91. v-block
  92. type="primary"
  93. @click="addRelatedField"
  94. >
  95. 新增联动字段
  96. </el-button>
  97. <div
  98. slot="footer"
  99. class="dialog-footer"
  100. >
  101. <el-button
  102. class="bs-el-button-default"
  103. @click="handleClose"
  104. >
  105. 取消
  106. </el-button>
  107. <el-button
  108. type="primary"
  109. @click="updateConfig"
  110. >
  111. 确定
  112. </el-button>
  113. </div>
  114. </el-dialog>
  115. </template>
  116. <script>
  117. import { operatorList } from 'data-room-ui/js/dict/chartDict'
  118. export default {
  119. name: 'RalationSetting',
  120. components: {
  121. },
  122. directives: {
  123. block: {
  124. bind (el, binding) {
  125. el.style.width = binding.value || '100%'
  126. el.style.margin = '10px auto'
  127. }
  128. }
  129. },
  130. props: {
  131. settingVisible: {
  132. type: Boolean,
  133. default: false
  134. },
  135. configMap: {
  136. type: Object,
  137. default: () => ({})
  138. },
  139. sourceFieldList: {
  140. type: Array,
  141. default: () => []
  142. },
  143. targetFieldList: {
  144. type: Array,
  145. default: () => []
  146. }
  147. },
  148. data () {
  149. return {
  150. operatorList
  151. }
  152. },
  153. computed: {
  154. configMapConfig: {
  155. get () {
  156. return this.configMap || {
  157. componentKey: '',
  158. maps: []
  159. }
  160. },
  161. set () { }
  162. },
  163. choosedTargetFields () {
  164. return this.configMapConfig.maps.map(item => item.targetField)
  165. }
  166. },
  167. mounted () { },
  168. methods: {
  169. /**
  170. * @description: 关闭弹窗
  171. */
  172. handleClose () {
  173. this.$emit('update:settingVisible')
  174. },
  175. /**
  176. * @description: 更新配置
  177. */
  178. updateConfig () {
  179. this.$emit('updateConfig', this.configMapConfig)
  180. this.handleClose()
  181. },
  182. /**
  183. * @description: 新增关联字段
  184. */
  185. addRelatedField () {
  186. this.configMapConfig.maps.push({
  187. targetField: '',
  188. sourceField: '',
  189. queryRule: '='
  190. })
  191. },
  192. handleDelete (index) {
  193. this.configMapConfig.maps.splice(index, 1)
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss" scoped>
  199. @import '../../../assets/style/bsTheme.scss';
  200. </style>