WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2024-08-14 06330ed7b98d5d90e873e6f3e92565e1b5b555e3
优化CAlert弹窗使用
1 files modified
19 ■■■■ changed files
layout/alert/CAlert.vue 19 ●●●● patch | view | raw | blame | history
layout/alert/CAlert.vue
@@ -13,6 +13,11 @@
        <AtModalHeader v-if="title">{{title}}</AtModalHeader>
        <AtModalContent>
            {{content}}
            <view
                v-for="(cont,index) of contents"
                :key="index"
                style="padding-bottom:6px"
            >{{cont}}</view>
        </AtModalContent>
        <AtModalAction>
            <button @tap="evt => handleClose()">{{mode==='alert'?'知道了':'取消'}}</button>
@@ -46,41 +51,51 @@
            isOpened: false,
            title: '',
            content: '',
            contents: [],
            callback: null,
        };
    },
    methods: {
        handleClose() {
            this.isOpened = false;
            if (this.mode === 'alert') {
                this.callback && this.callback();
            }
        },
        handleConfirm() {
            this.isOpened = false;
            this.onConfirm && this.onConfirm();
            this.callback && this.callback();
        },
        $alert(option) {
        $alert(option, callback) {
            if (!option) {
                return;
            }
            this.mode = 'alert';
            this.callback = callback;
            if (typeof option === 'string') {
                this.title = '';
                this.content = option;
            } else if (Tools.isObject(option)) {
                this.title = option.title;
                this.content = option.content;
                this.contents = option.contents;
            }
            this.isOpened = true;
        },
        $confirm(option) {
        $confirm(option, callback) {
            if (!option) {
                return;
            }
            this.mode = 'comfirm';
            this.callback = callback;
            if (typeof option === 'string') {
                this.title = '';
                this.content = option;
            } else if (Tools.isObject(option)) {
                this.title = option.title;
                this.content = option.content;
                this.contents = option.contents;
            }
            this.isOpened = true;
        },