index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <uni-tag :text='text' :type='type' :disabled='disabled' :inverted='inverted' :circle='circle' :size='size'
  3. @click="bindClick"></uni-tag>
  4. </template>
  5. <script>
  6. import {
  7. onReachBottom
  8. } from '@dcloudio/uni-app'
  9. import {
  10. ref,
  11. toRefs,
  12. defineProps,
  13. defineComponent,
  14. computed,
  15. onMounted,
  16. reactive
  17. } from 'vue'
  18. import {
  19. useSetDictStore
  20. } from '@/stores/useSetDictStore';
  21. export default defineComponent({
  22. name: 'DictTag',
  23. props: {
  24. dictType: {
  25. type: String,
  26. required: true
  27. },
  28. value: {
  29. type: String,
  30. required: true
  31. },
  32. type: {
  33. type: String,
  34. default: 'primary',
  35. required: false
  36. },
  37. disabled: {
  38. type: Boolean,
  39. default: false,
  40. required: false
  41. },
  42. inverted: {
  43. type: Boolean,
  44. default: true,
  45. required: false
  46. },
  47. circle: {
  48. type: Boolean,
  49. default: false,
  50. required: false
  51. },
  52. size: {
  53. type: String,
  54. default: 'normal',
  55. required: false
  56. }
  57. },
  58. setup(props) {
  59. const {
  60. value,
  61. type,
  62. disabled,
  63. inverted,
  64. circle,
  65. size
  66. } = props
  67. const attrs = reactive({
  68. ...props,
  69. text: '',
  70. })
  71. const store = useSetDictStore();
  72. onMounted(() => {
  73. if(store.dicts?.length > 0) {
  74. for (let x = 0; x < store.dicts.length; x++) {
  75. const { dictType, value, colorType, label } = store.dicts[x]
  76. if (dictType === props.dictType && value * 1 === props.value) {
  77. }
  78. console.log(store.dicts[x]);
  79. }
  80. }
  81. console.log(props.dictType, store.dicts?.length);
  82. })
  83. return {
  84. value,
  85. type,
  86. disabled,
  87. inverted,
  88. circle,
  89. size,
  90. ...toRefs(attrs)
  91. }
  92. }
  93. })
  94. </script>
  95. <style>
  96. </style>