ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<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>