<script lang="ts" setup>
|
import { computed, onMounted, ref, unref } from 'vue';
|
|
import { useAttrs } from '@jnpf/hooks';
|
|
import { useUserStore } from '@vben/stores';
|
|
import { Input } from 'ant-design-vue';
|
import dayjs from 'dayjs';
|
|
import { openDataProps } from './props';
|
|
defineOptions({ inheritAttrs: false, name: 'JnpfOpenData' });
|
const props = defineProps(openDataProps);
|
const innerValue = ref('');
|
const attrs: any = useAttrs({ excludeDefaultKeys: false });
|
const userStore = useUserStore();
|
|
const getUserInfo: any = computed(() => userStore.getUserInfo || {});
|
const getStyle = computed(() => (Reflect.has(unref(attrs), 'style') ? unref(attrs).style : {}));
|
|
function setValue() {
|
if (props.type === 'currUser') {
|
innerValue.value = unref(getUserInfo).userName && unref(getUserInfo).userAccount ? `${unref(getUserInfo).userName}/${unref(getUserInfo).userAccount}` : '';
|
}
|
if (props.type === 'currTime') {
|
innerValue.value = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
}
|
if (props.type === 'currOrganize' && unref(getUserInfo).organizeList?.length) {
|
const list = unref(getUserInfo).organizeList.map((o) => o.treeName);
|
innerValue.value = list.join(',');
|
}
|
if (props.type === 'currPosition' && unref(getUserInfo).positionList?.length) {
|
const list = unref(getUserInfo).positionList.map((o) => o.treeName);
|
innerValue.value = list.join(',');
|
}
|
}
|
|
onMounted(() => {
|
setValue();
|
});
|
</script>
|
|
<template>
|
<div :style="getStyle">
|
<Input v-if="!detailed" :disabled="disabled" :value="value" placeholder="系统自动生成" readonly />
|
<p v-else class="m-0">{{ value || '' }}</p>
|
</div>
|
</template>
|