app-form-group.vue 9.4 KB
Newer Older
1
<template>
neko's avatar
neko committed
2 3
    <div :class="classes">
        <template v-if="uiStyle=='STYLE2'">
4 5 6 7 8 9 10 11 12
            <app-form-group2
                :caption="caption"
                :uiStyle="uiStyle"
                :layoutType="layoutType"
                :isShowCaption="isShowCaption"
                :uiActionGroup="uiActionGroup"
                :titleBarCloseMode="titleBarCloseMode">
                   <slot></slot>
                </app-form-group2>
neko's avatar
neko committed
13 14
        </template>
        <template v-else>
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
            <card v-if="isShowCaption === true" :bordered="false" :dis-hover="true" :class="classes">
                <p class='' slot='title'>
                     <icon v-if="titleBarCloseMode !== 0" :type="collapseContant ? 'ios-arrow-dropright-circle' : 'ios-arrow-dropdown-circle'"
                    @click="clickCollapse"></icon>
                    <span :class="titleClass">{{caption}}</span>
                </p>
                <template v-if="uiActionGroup">
                    <a slot='extra'>
                        <template v-if="uiActionGroup.extractMode && Object.is(uiActionGroup.extractMode, 'ITEMS')">
                            <dropdown :transfer="true" trigger='click'>
                            <a href='javascript:void(0)'>
                                {{uiActionGroup.caption}}
                            </a>
                            <dropdown-menu slot='list' v-if="uiActionGroup.details && Array.isArray(uiActionGroup.details)">
                                <dropdown-item v-for="(detail,index) in (uiActionGroup.details)" :key="index" :name="detail.name">
                                    <span class='item' @click="doUIAction($event, detail)">
31 32 33 34 35 36 37 38 39
                                        <template v-if="detail.isShowIcon">
                                            <template v-if="detail.icon && !Object.is(detail.icon, '')">
                                                <i :class="detail.icon" ></i>
                                            </template>
                                            <template v-if="!(detail.icon && !Object.is(detail.icon, ''))">
                                                <div v-if="detail.img && !Object.is(detail.img, '')">
                                                    <img :src="detail.img" />
                                                </div>
                                            </template>
40 41 42
                                        </template>
                                        &nbsp;
                                        <span>
43 44 45 46 47 48 49
                                            <template v-if="detail.isShowCaption">
                                                <template v-if="uiActionGroup.langbase && !Object.is(uiActionGroup.langbase, '') && detail.uiactiontag && !Object.is(detail.uiactiontag, '')">
                                                    {{$t(`${uiActionGroup.langbase}.uiactions.${detail.uiactiontag}`)}}
                                                </template>
                                                <template v-if="!(uiActionGroup.langbase && !Object.is(uiActionGroup.langbase, '') && detail.uiactiontag && !Object.is(detail.uiactiontag, ''))">
                                                    {{detail.caption}}
                                                </template>
50 51 52 53 54 55 56 57 58 59 60 61
                                            </template>
                                        </span>
                                    </span>
                                </dropdown-item>
                            </dropdown-menu>
                        </dropdown>
                        </template>
                        <template v-if="!(uiActionGroup.extractMode && Object.is(uiActionGroup.extractMode, 'ITEMS'))">
                             <span class='item-extract-mode'>
                                <template v-if="uiActionGroup.details && Array.isArray(uiActionGroup.details)">
                                    <div v-for="(detail,index) in uiActionGroup.details" :key="index">
                                        <span class='item' @click="doUIAction($event, detail)">
62 63 64 65 66 67 68 69 70 71
                                            <template v-if="detail.isShowIcon">
                                                <template v-if="detail.icon && !Object.is(detail.icon, '')">
                                                    <i :class="detail.icon" ></i>
                                                </template>
                                                <template v-if="!(detail.icon && !Object.is(detail.icon, ''))">
                                                    <div v-if="detail.img && !Object.is(detail.img, '')">
                                                        <img :src="detail.img" />
                                                    </div>
                                                </template>
                                            </template>
72 73
                                        &nbsp;
                                        <span>
74 75 76 77 78 79 80
                                            <template v-if="detail.isShowCaption">
                                                <template v-if="uiActionGroup.langbase && !Object.is(uiActionGroup.langbase, '') && detail.uiactiontag && !Object.is(detail.uiactiontag, '')">
                                                    {{$t(`${uiActionGroup.langbase}.uiactions.${detail.uiactiontag}`)}}
                                                </template>
                                                <template v-if="!(uiActionGroup.langbase && !Object.is(uiActionGroup.langbase, '') && detail.uiactiontag && !Object.is(detail.uiactiontag, ''))">
                                                    {{detail.caption}}
                                                </template>
81 82 83 84 85 86 87 88 89
                                            </template>
                                        </span>
                                    </span>
                                    </div>
                                </template>
                            </span>
                        </template>
                    </a >
                </template>
neko's avatar
neko committed
90
                <template v-if="Object.is(layoutType, 'FLEX')">
91
                    <slot></slot>
neko's avatar
neko committed
92 93
                </template>
                <template v-if="!Object.is(layoutType, 'FLEX')">
94
                    <row :gutter="10"><slot></slot></row>
neko's avatar
neko committed
95
                </template>
96
            </card>
neko's avatar
neko committed
97
            <template v-if="isShowCaption === false">
neko's avatar
neko committed
98
                <slot></slot>
neko's avatar
neko committed
99 100
            </template>
        </template>
101 102 103 104 105 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
    </div>
</template>

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

@Component({})
export default class AppFormGroup extends Vue {

    /**
     * 标题
     *
     * @type {string}
     * @memberof AppFormGroup
     */
    @Prop() public caption?: string;

    /**
     * 内置界面样式
     * 
     * @type {string}
     * @memberof AppFormGroup
     */
    @Prop() public uiStyle?: string;

    /**
     * 布局模式
     *
     * @type {string}
     * @memberof AppFormGroup
     */
    @Prop() public layoutType?: string;

    /**
     * 标题样式
     *
     * @type {string}
     * @memberof AppFormGroup
     */    
    @Prop() public titleStyle?:string;

142 143 144 145 146 147 148 149
    /**
     * 分组图标
     *
     * @type {string}
     * @memberof AppFormGroup
     */ 
    @Prop() public iconInfo?:any;

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
    /**
     * 是否显示标题
     *
     * @type {boolean}
     * @memberof AppFormGroup
     */
    @Prop({ default: true }) public isShowCaption!: boolean;

    /**
     * 信息面板模式
     *
     * @type {boolean}
     * @memberof AppFormGroup
     */
    @Prop({ default: false }) public isInfoGroupMode!: boolean;

    /**
     * 界面行为组
     *
     * @type {*}
     * @memberof AppFormGroup
     */
    @Prop() public uiActionGroup?: any;

    /**
     * 标题栏关闭模式
     * 0: 不支持关闭
     * 1: 默认打开
     * 2: 默认关闭
     *
     * @type {(number | 0 | 1 | 2)} 
     * @memberof AppFormGroup
     */
    @Prop({ default: 0 }) public titleBarCloseMode!: number | 0 | 1 | 2;

    /**
     * 收缩内容
     *
     * @type {boolean}
     * @memberof AppFormGroup
     */
    public collapseContant: boolean = false;

    /**
     * 计算样式
     *
     * @readonly
     * @type {string[]}
     * @memberof AppFormGroup
     */
    get classes(): string[] {
        return [
            'app-form-group',
            this.isShowCaption && this.collapseContant ? 'app-group-collapse-contant' : '',
            this.isInfoGroupMode ? 'app-info-group-mode' : '',
            Object.is(this.layoutType, 'FLEX') ? 'app-group-flex': ''
        ];
    }

    /**
     * 标题样式
     *
     * @readonly
     * @type {string}
     * @memberof AppFormGroup
     */
    get titleClass():string{
        return this.titleStyle?this.titleStyle:'';
    }

    /**
     * vue 生命周期
     *
     * @memberof AppFormGroup
     */
    public created() {
        this.collapseContant = this.titleBarCloseMode === 2 ? true : false;
    }

    /**
     * 触发收缩
     *
     * @memberof AppFormGroup
     */
    public clickCollapse(): void {
        this.collapseContant = !this.collapseContant;
    }

    /**
     * 执行界面行
     *
     * @param {*} $event
     * @memberof AppFormGroup
     */
    public doUIAction($event: any, item: any): void {
        this.$emit('groupuiactionclick', { event: $event, item: item });
    }
}
</script>
<style lang='less'>
@import './app-form-group.less';
</style>