1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <!-- 字典 -->
- <template>
- <u-picker
- ref="pickerRef"
- :keyName="'dictLabel'"
- :show="isShow"
- :columns="[columns]"
- @confirm="confirm"
- @cancel="close"></u-picker>
- </template>
- <script>
- /* https://uviewui.com/components/picker.html */
- import { getDicts } from "@/api/dict/data";
- export default {
- props: {
- dictType: { //字典类型
- type: String,
- default: ''
- },
- },
- data() {
- return {
- columns: [],
- isShow: false,
- }
- },
- mounted() {
- this.init()
- },
- methods: {
- // 获取字典数据
- init() {
- getDicts(this.dictType).then((res) => {
- this.columns = res.data
- })
- },
- show() {
- this.isShow = true;
- },
- close() {
- this.isShow = false
- },
- confirm(e) {
- console.log('确定', e)
- const { value } = e
- this.$emit('confirm', value[0])
- this.close()
- },
- }
- }
- </script>
- <style lang="scss" scoped></style>
|