dynamicCard.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :span="6">
  5. <el-card :body-style="{ padding: '0px' }" @click="changeFn">
  6. <div style="display: flex; align-items: center;">
  7. <div>
  8. <div>
  9. <el-select v-model="value" placeholder="Select" size="small">
  10. <el-option
  11. v-for="item in options"
  12. :key="item.value"
  13. :label="item.label"
  14. :value="item.value"
  15. :disabled="item.disabled"
  16. />
  17. </el-select>
  18. </div>
  19. <!--<div style="color:#909399;margin-left: 8px">{{ color }}</div>-->
  20. <div style="font-weight: bold;font-size: large;margin-left: 8px">{{ cardMiddle }}</div>
  21. <div style="margin-left: 8px">
  22. <span style="color:#909399;">{{ cardBottom }}</span> ⬇️
  23. <span style="color:orangered;">{{ `${ cardBottomRight }%` }}</span>
  24. </div>
  25. </div>
  26. </div>
  27. </el-card>
  28. </el-col>
  29. </el-row>
  30. </div>
  31. </template>
  32. <script>
  33. import { ref, toRefs, computed, reactive } from 'vue'
  34. export default {
  35. props: ['dynamicCardData', 'selectOptions'],
  36. emits: ['change'],
  37. setup(props, context) {
  38. // 父组件传递的卡片数据
  39. let cardData = props.dynamicCardData
  40. // 父组件传递的下拉框数据
  41. let selectOptions = props.selectOptions
  42. // el-selection配置
  43. const value = ref('')
  44. const options = selectOptions
  45. // todo 抛出点击后切换显示图线的方法
  46. let status = true
  47. function changeFn() {
  48. status = !status
  49. context.emit('change', status)
  50. }
  51. return {
  52. cardData,
  53. ...toRefs(cardData),
  54. selectOptions,
  55. value,
  56. options,
  57. changeFn
  58. }
  59. }
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. </style>