Files

155 lines
4.2 KiB
Vue
Executable File

<template>
<opsoft-dialog v-bind="$attrs" :popuContentStyle="noticeStyle"
:dialogContent="dialogNoticeContent" :dialogShow="dialogNoticeShow"
ref="opsoftDialog">
<template v-slot:dialogTitle>
<view class="dialog-notice-title">
<view :class="['dialog-notice-title-icon', titleIconClass]"/>
<view>{{dialogNoticeTitle}}</view>
</view>
</template>
<template v-slot:dialogButton>
<view class="dialog-notice-buttons">
<view class="dialog-notice-button" @tap.stop="dialogNoticeConfirmClick">{{dialogNoticeConfirm}}</view>
</view>
</template>
</opsoft-dialog>
</template>
<script>
export default {
name: "opsoft-dialog-notice",
props: {
dialogNoticeConfirm: {type:String, default:'确定'},
dialogNoticeType: {type:String, default:'error'},
dialogNoticeTitle: {type:String, default:''},
dialogNoticeContent: {type:String, default:''},
dialogNoticeShow: {type:Boolean, default:false},
dialogNoticeClickCallback: {type:Object},
},
data() {
return {
titleIconClass: "",
noticeStyle: {height:"216px"},
title: "",
}
},
watch:{
dialogNoticeType(newValue, oldValue) {
if (newValue == 'error') {
this.titleIconClass = "dialog-notice-title-icon-error";
if (!this.title) {
this.title = "错误提示";
}
}
else if (newValue == 'success') {
this.titleIconClass = "dialog-notice-title-icon-success";
if (!this.title) {
this.title = "成功提示";
}
}
else if (newValue == 'tips') {
this.titleIconClass = "dialog-notice-title-icon-tips";
if (!this.title) {
this.title = "信息提示";
}
}
else if (newValue == 'warning') {
this.titleIconClass = "dialog-notice-title-icon-warning";
if (!this.title) {
this.title = "警告提示";
}
}
},
},
created() {
this.title = this.dialogNoticeTitle;
if (this.dialogNoticeType == 'error') {
this.titleIconClass = "dialog-notice-title-icon-error";
if (!this.title) {
this.title = "错误提示";
}
}
else if (this.dialogNoticeType == 'success') {
this.titleIconClass = "dialog-notice-title-icon-success";
if (!this.title) {
this.title = "成功提示";
}
}
else if (this.dialogNoticeType == 'tips') {
this.titleIconClass = "dialog-notice-title-icon-tips";
if (!this.title) {
this.title = "信息提示";
}
}
else if (this.dialogNoticeType == 'warning') {
this.titleIconClass = "dialog-notice-title-icon-warning";
if (!this.title) {
this.title = "警告提示";
}
}
},
methods: {
dialogNoticeConfirmClick(event) {
this.$emit("update:dialogNoticeShow",false);
if (this.dialogNoticeClickCallback) {
this.dialogNoticeClickCallback('comfirm', event);
}
this.$emit("dialogNoticeConfirmClick", event);
},
showDialog(show){
this.dialogNoticeShow = show;
this.$refs.opsoftDialog.showDialog(this.dialogNoticeShow);
}
}
}
</script>
<style lang="scss">
.dialog-notice-title{
color: rgba(51, 51, 51, 1);
font-size: 36rpx;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
.dialog-notice-title-icon {
background-size: 44rpx 44rpx;
background-repeat: no-repeat;
background-position:center center;
width: 44rpx;
height: 44rpx;
margin-right: 16rpx;
}
.dialog-notice-title-icon-error {
background-image: url(./static/error.svg);
}
.dialog-notice-title-icon-success {
background-image: url(./static/success.svg);
}
.dialog-notice-title-icon-tips {
background-image: url(./static/tips.svg);
}
.dialog-notice-title-icon-warning {
background-image: url(./static/warning.svg);
}
}
.dialog-notice-buttons {
flex-grow: 0;
flex-shrink: 0;
margin-bottom: 40rpx;
width: 100%;
.dialog-notice-button{
margin-left: 48rpx;
margin-right: 48rpx;
height: 64rpx;
line-height: 64rpx;
text-align: center;
background: linear-gradient(90deg, rgba(72, 162, 249, 1) 0%, rgba(41, 138, 240, 1) 100%);
background: rgba(52, 146, 242, 1);
border-radius: 4px;
color: rgba(255, 255, 255, 1);
font-size: 14px;
}
}
</style>