index.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!-- 字典 -->
  2. <template>
  3. <u-picker
  4. ref="pickerRef"
  5. :keyName="'dictLabel'"
  6. :show="isShow"
  7. :columns="[columns]"
  8. @confirm="confirm"
  9. @cancel="close"></u-picker>
  10. </template>
  11. <script>
  12. /* https://uviewui.com/components/picker.html */
  13. import { getDicts } from "@/api/dict/data";
  14. export default {
  15. props: {
  16. dictType: { //字典类型
  17. type: String,
  18. default: ''
  19. },
  20. },
  21. data() {
  22. return {
  23. columns: [],
  24. isShow: false,
  25. }
  26. },
  27. mounted() {
  28. this.init()
  29. },
  30. methods: {
  31. // 获取字典数据
  32. init() {
  33. getDicts(this.dictType).then((res) => {
  34. this.columns = res.data
  35. })
  36. },
  37. show() {
  38. this.isShow = true;
  39. },
  40. close() {
  41. this.isShow = false
  42. },
  43. confirm(e) {
  44. console.log('确定', e)
  45. const { value } = e
  46. this.$emit('confirm', value[0])
  47. this.close()
  48. },
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped></style>