ny
昨天 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<script lang="ts" setup>
import { computed, ref, watch } from 'vue';
 
import { isNullOrUnDef } from '@jnpf/utils';
 
import { globalShareState } from '@vben-core/shared/global-state';
 
import { QrCode } from '../../../core';
import { qrcodeProps } from './props';
 
defineOptions({ inheritAttrs: false, name: 'JnpfQrcode' });
const props = defineProps(qrcodeProps);
const { useGeneratorStore } = globalShareState.getStores();
const generatorStore = useGeneratorStore();
const relationText = ref('');
 
const options = computed(() => ({
  color: { dark: props.colorDark, light: props.colorLight },
  margin: 1,
}));
const qrcode = computed(() => {
  const dynamicModelExtra = generatorStore.getDynamicModelExtra;
  if (props.dataType === 'static') {
    return props.staticText;
  } else if (props.dataType === 'relation') {
    return relationText.value;
  } else {
    if (props.formData && dynamicModelExtra && dynamicModelExtra.id && dynamicModelExtra.modelId) {
      const json = {
        fid: dynamicModelExtra.flowId || '',
        ftid: dynamicModelExtra.taskId || '',
        id: dynamicModelExtra.id,
        mid: dynamicModelExtra.modelId,
        mt: dynamicModelExtra.type,
        opt: dynamicModelExtra.opType,
        pid: dynamicModelExtra.processId || '',
        t: 'DFD',
      };
      return JSON.stringify(json);
    }
    return '';
  }
});
 
watch(
  () => props.formData,
  (val) => {
    if (val && props.dataType === 'relation' && props.relationField) {
      relationText.value = isNullOrUnDef(val[props.relationField]) ? '' : val[props.relationField];
    }
  },
  { deep: true, immediate: true },
);
</script>
 
<template>
  <div class="jnpf-qrcode">
    <QrCode :options="options" :value="qrcode" :width="width" tag="img" />
  </div>
</template>
<style lang="scss" scoped>
.jnpf-qrcode {
  width: 100%;
  max-width: 100% !important;
  min-height: 40px;
  padding: 0;
}
</style>