quickcommand.showConfirmBox支持html及设置宽度

This commit is contained in:
fofolee 2024-03-01 09:24:52 +08:00
parent ebb1b79b73
commit f34b80ee42
2 changed files with 28 additions and 37 deletions

View File

@ -1,11 +1,12 @@
<template> <template>
<q-card class="q-dialog-plugin"> <q-card class="q-dialog-plugin" :style="{
width: options.width ? options.width + 'px' : '450px'
}">
<q-card-section> <q-card-section>
<div class="text-h5" align="left" v-text="options.title"></div> <div class="text-h5" align="left" v-text="options.title"></div>
</q-card-section> </q-card-section>
<q-card-section> <q-card-section v-if="options.isHtml" v-html="options.message" class="content" />
{{ options.message }} <q-card-section v-else v-text="options.message" class="content" />
</q-card-section>
<q-card-section class="flex justify-end q-gutter-sm"> <q-card-section class="flex justify-end q-gutter-sm">
<q-btn flat label="取消" color="grey" @click="hide" /> <q-btn flat label="取消" color="grey" @click="hide" />
<q-btn flat autofocus label="确定" color="primary" @click="clickOK()" /> <q-btn flat autofocus label="确定" color="primary" @click="clickOK()" />
@ -29,3 +30,10 @@ export default {
}, },
}; };
</script> </script>
<style scoped>
.content {
overflow: auto;
max-height: 350px;
}
</style>

View File

@ -1,30 +1,13 @@
<template> <template>
<q-dialog <q-dialog v-model="showDialog" :maximized="maximized" :transition-show="maximized ? 'fade' : 'scale'"
v-model="showDialog" :transition-hide="maximized ? 'fade' : 'scale'">
:maximized="maximized" <component ref="ui" :is="currentUI" :options="options" @clickOK="clickOK" @hide="showDialog = false" />
:transition-show="maximized ? 'fade' : 'scale'"
:transition-hide="maximized ? 'fade' : 'scale'"
>
<component
ref="ui"
:is="currentUI"
:options="options"
@clickOK="clickOK"
@hide="showDialog = false"
/>
</q-dialog> </q-dialog>
<!-- waitButton 单独一个 --> <!-- waitButton 单独一个 -->
<q-btn <q-btn class="fixed-top-right" style="z-index: 9999" v-if="showWb" color="primary" :label="wbLabel" @click="
class="fixed-top-right" showWb = false;
style="z-index: 9999" wbEvent();
v-if="showWb" " />
color="primary"
:label="wbLabel"
@click="
showWb = false;
wbEvent();
"
/>
</template> </template>
<script> <script>
@ -79,9 +62,9 @@ export default {
this.showUI(ButtonBox, { labels, title }, false, reslove); this.showUI(ButtonBox, { labels, title }, false, reslove);
}), }),
showConfirmBox: (message = "", title = "提示") => showConfirmBox: (message = "", title = "提示", isHtml = false, width) =>
new Promise((reslove, reject) => { new Promise((reslove, reject) => {
this.showUI(ConfirmBox, { message, title }, false, reslove); this.showUI(ConfirmBox, { message, title, isHtml, width }, false, reslove);
}), }),
showMessageBox: (message, icon = "success", time) => { showMessageBox: (message, icon = "success", time) => {
@ -98,11 +81,11 @@ export default {
actions: actions:
time === 0 time === 0
? [ ? [
{ {
label: "确定", label: "确定",
color: "white", color: "white",
}, },
] ]
: [], : [],
}); });
}, },
@ -160,8 +143,8 @@ export default {
Object.freeze(quickcommand); Object.freeze(quickcommand);
}, },
methods: { methods: {
clickOK() {}, clickOK() { },
wbEvent() {}, wbEvent() { },
showUI(uiComponent, options, maximized, reslove) { showUI(uiComponent, options, maximized, reslove) {
this.showDialog = true; this.showDialog = true;
this.options = options; this.options = options;