1
0
forked from dyf/APP

添加102联机记录

This commit is contained in:
liub
2026-03-05 10:06:37 +08:00
parent aa87a1a78f
commit c1c7d4491b
43 changed files with 4732 additions and 745 deletions

View File

@ -1,57 +1,66 @@
<template>
<template>
<view class="msgBox" v-if="Msgboxs.length>0">
<MessagePopup v-for="item,index in Msgboxs" :visible="item.showPop" :type="item.popType" :bgColor="item.bgColor"
:borderColor="item.borderColor" :textColor="item.textColor" :buttonBgColor="item.buttonBgColor"
:buttonTextColor="item.buttonTextColor" :iconUrl="item.iconUrl" :message="item.message"
:buttonText="item.buttonText" @buttonClick="okCallback(item,index)" :visiblePrompt="item.visiblePrompt"
:promptTitle="item.promptTitle" v-model="item.modelValue" @closePop="closePop(item)"
:buttonCancelText="item.buttonCancelText" :showCancel="item.showCancel" @cancelPop="cancelClick(item,index)" />
</view>
</template>
<script>
:buttonCancelText="item.buttonCancelText" :showCancel="item.showCancel"
:showHeader="item.showHeader" :headerTxt="item.headerTxt"
@cancelPop="cancelClick(item,index)" />
</view>
</template>
<script>
import Common from '@/utils/Common.js'
export default {
name: 'MsgBox',
data() {
return {
Msgboxs:[]
}
},
name: 'MsgBox',
data() {
return {
Msgboxs: []
}
},
methods: {
//确认按钮事件如果回调函数返回true,将阻止关闭弹窗
okCallback(item,index){
let flag=false;
if(item.okCallback){
flag=item.okCallback(item,index)
okCallback(item, index) {
let flag = false;
if (item.okCallback) {
flag = item.okCallback(item, index)
}
if(flag){
if (flag) {
return;
}
this.closePop(item);
},
//取消按钮,如果回调函数返回true将阻止关闭弹窗
cancelClick(item,index){
let flag=false;
if(item.cancelCallback){
flag=item.cancelCallback(item,index)
cancelClick(item, index) {
let flag = false;
if (item.cancelCallback) {
flag = item.cancelCallback(item, index)
}
if(flag){
if (flag) {
return;
}
this.closePop(item);
},
},
closePop: function(item) {
debugger;
if (item) {
this.Msgboxs.find((v, i) => {
if (item.key === v.key) {
this.Msgboxs.splice(i, 1);
debugger;
if (item.key && v.key) {
if (item.key === v.key) {
this.Msgboxs.splice(i, 1);
return true;
}
}
});
if (item.cancelCallback) {
item.cancelCallback();
}
@ -59,12 +68,12 @@
if (this.Msgboxs.length > 0) {
this.Msgboxs.splice(this.Msgboxs.length - 1, 1);
}
}
},
//根据传入的配置,自定义一个弹窗
showPop: function(option,isClear) {
showPop: function(option, isClear) {
let def = {
key: '',
showPop: true, //是否显示弹窗
@ -86,41 +95,44 @@
showSlot: false,
buttonCancelText: '',
showCancel: false,
cancelCallback: null
cancelCallback: null,
visible:false,
promptPlaceholder:'',
type:'custom',
showHeader:false,
headerTxt:''
}
let json = {};
let keys = Object.keys(def);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
json[key] = def[key];
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
json[key] = option[key];
}
Object.assign(json, option);
}
if (!json.borderColor) {
json.borderColor = '#BBE600';
json.buttonBgColor = '#BBE600';
}
json.showPop = true;
if (!('key' in json)) {
json.key = new Date().getTime();
if(!json.key){
json.key =Common.guid();
}
this.Msgboxs.push(json);
return json;
},
//弹出预定好的三种弹窗
showMsg(msg,btnTxt, type,okCallback) {
//弹出预定好的三种弹窗
showMsg(msg, btnTxt, type, okCallback) {
let cfg = {
error: {
icoUrl: '/static/images/6155/DeviceDetail/uploadErr.png',
@ -138,50 +150,50 @@
buttonBgColor: "#FFC84E",
}
}
if (!type) {
type = 'error';
}
if (!cfg[type]) {
type = 'error';
}
let guid = new Date().getTime()+"";
let guid =Common.guid();
let options = {
key: guid,
message: msg,
iconUrl: cfg[type].icoUrl,
borderColor: cfg[type].borderColor,
buttonBgColor: cfg[type].buttonBgColor,
buttonText: btnTxt?btnTxt:'确定',
okCallback: okCallback?okCallback:this.closePop
buttonText: btnTxt ? btnTxt : '确定',
okCallback: okCallback ? okCallback : this.closePop
};
return this.showPop(options);
},
},
//清除所有弹窗
clearPops(){
this.Msgboxs=[];
clearPops() {
this.Msgboxs = [];
},
//获取当前所有弹窗的数量
getPops(){
getPops() {
return this.Msgboxs.length;
}
}
}
</script>
<style>
.msgBox{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 9999;
display: flex;
justify-content: center;
align-items: center;
}
</style>
}
}
}
</script>
<style>
.msgBox {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 99999;
display: flex;
justify-content: center;
align-items: center;
}
</style>