app-span.vue 3.6 KB
Newer Older
1
<template>
2
    <codelist v-if="tag" :tag="tag" :value="value" :codelistType="codelistType" :renderMode="renderMode" :valueSeparator="valueSeparator" :textSeparator="textSeparator" :data="data" :localContext="localContext" :localParam="localParam" :context="context" :viewparams="viewparams"></codelist>
3
    <app-upload-file-info v-else-if="Object.is(this.editorType,'PICTURE') || Object.is(this.editorType,'PICTURE_ONE') || Object.is(this.editorType,'FILEUPLOADER')" :value="value" :name="name"></app-upload-file-info>
4 5 6 7 8 9 10
    <span class="app-span" v-else >{{text}}</span>
</template>

<script lang="ts">
import { Vue, Component, Prop, Watch, Model } from 'vue-property-decorator';

@Component({})
11
export default class AppSpan extends Vue {
12 13 14 15 16 17 18 19 20

    /**
     * 当前值
     * 
     * @type {*}
     * @memberof AppSpan
     */
    @Prop() public value?: any;

21 22 23 24 25 26 27 28
    /**
     * 当前表单项名称
     * 
     * @type {*}
     * @memberof AppSpan
     */
    @Prop() public name?: any;

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    /**
     * 代码表标识
     *
     * @type {string}
     * @memberof AppSpan
     */
    @Prop() public tag?: string;

    /**
     * 代码表类型
     *
     * @type {string}
     * @memberof AppSpan
     */
    @Prop() public codelistType?: string;

    /**
     * 获取或模式
     * @type {boolean}
48
     * @memberof AppSpan
49 50 51 52 53 54
     */
    @Prop({default:"STR"}) public renderMode?: string;

    /**
     * 文本分隔符
     * @type {boolean}
55
     * @memberof AppSpan
56
     */
57
    @Prop({default:'、'}) public textSeparator?: string;
58 59 60 61

    /**
     * 值分隔符
     * @type {boolean}
62
     * @memberof AppSpan
63
     */
64
    @Prop({default:','}) public valueSeparator?: string;
65

66 67 68 69 70 71 72 73 74
    /**
     * 传入表单数据
     *
     * @type {*}
     * @memberof AppSpan
     */
    @Prop() public data?: any;

    /**
75 76 77 78 79 80 81 82 83 84 85
     * 局部上下文导航参数
     * 
     * @type {any}
     * @memberof AppSpan
     */
    @Prop() public localContext!:any;

    /**
     * 局部导航参数
     * 
     * @type {any}
86 87
     * @memberof AppSpan
     */
88
    @Prop() public localParam!:any;
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

    /**
     * 视图上下文
     *
     * @type {*}
     * @memberof AppSpan
     */
    @Prop() public context!: any;

    /**
     * 视图参数
     *
     * @type {*}
     * @memberof AppSpan
     */
    @Prop() public viewparams!: any;

106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
    /**
     * 监控表单属性 data 值
     *
     * @memberof AppSpan
     */
    @Watch('value')
    onDataChange(newVal: any, oldVal: any) {
        if(newVal !== oldVal){
           this.load();
        }
    }

    /**
     * 显示值
     * @type {*}
     * @memberof AppSpan
     */
    public text:any = '';

    /**
     * 编辑器类型
     *
     * @type {string}
     * @memberof AppSpan
     */
    @Prop() public editorType?: string;

    /**
     * vue  生命周期
     *
     * @memberof AppSpan
     */
    public created() {
        this.load();
    }

    /**
     * 处理数据
     * 
     * @memberof AppSpan
     */
    public load(){
148
        if(this.tag){
149
            return;  //代码表走codelist组件
150
        }else if(this.editorType === "ADDRESSPICKUP"){
151 152 153 154 155 156 157
            if(this.$util.isEmpty(this.value)){
                this.text = '';
            }else{
                JSON.parse(this.value).forEach((item:any,index:number) => {
                  this.text += index === 0 ? item.srfmajortext : ","+item.srfmajortext;
                });
            }
158
        }else{
159 160 161 162 163
            if(this.$util.isEmpty(this.value)){
                this.text = '';
            }else{
                this.text = this.value;
            }
164 165 166 167 168 169 170 171 172
        }
    }
    
}
</script>

<style lang='less'>
@import './app-span.less';
</style>