feat:添加unsaved change 开关
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import PerfectScrollbar from "perfect-scrollbar";
|
||||
import {getChart} from "./common";
|
||||
import MessageBox from "element-ui/packages/message-box/src/main";
|
||||
import vuex from 'vuex'
|
||||
import i18n from "../i18n";
|
||||
/*弹窗点击外部后关闭*/
|
||||
const exceptClassName = ["config-dropdown", "nz-pop", "el-picker", "chart-box-dropdown", 'metric-dropdown', 'el-cascader__dropdown', "asset-dropdown", "no-style-class", 'el-message-box','nz-dashboard-dropdown', "el-autocomplete-suggestion"]; //clickoutside排除的class(白名单) no-style-class:没有任何样式的class
|
||||
@@ -8,6 +9,7 @@ export const clickoutside = {
|
||||
// 初始化指令
|
||||
bind(el, binding, vnode) {
|
||||
if(!binding.expression) return;
|
||||
let unsavedChange = localStorage.getItem('nz-unnsaved-change');
|
||||
let oldValue;
|
||||
try{
|
||||
oldValue= JSON.parse(JSON.stringify(binding.value.obj));
|
||||
@@ -33,7 +35,7 @@ export const clickoutside = {
|
||||
}
|
||||
if(oldValue){
|
||||
let newValue = JSON.parse(JSON.stringify(binding.value.obj));
|
||||
if(!isEqual(oldValue,newValue)){
|
||||
if(unsavedChange=='on'&&!isEqual(oldValue,newValue)){
|
||||
MessageBox.confirm(i18n.t("tip.confirmCancel"), {
|
||||
confirmButtonText: i18n.t("tip.yes"),
|
||||
cancelButtonText: i18n.t("tip.no"),
|
||||
@@ -69,7 +71,6 @@ export const clickoutside = {
|
||||
},
|
||||
};
|
||||
function isEqual (o1, o2) {
|
||||
console.log(o1,o2)
|
||||
var isEqualForInner = function (obj1, obj2) {
|
||||
var o1 = obj1 instanceof Object;
|
||||
var o2 = obj2 instanceof Object;
|
||||
@@ -99,10 +100,11 @@ function isEqual (o1, o2) {
|
||||
export const cancelWithChange={
|
||||
bind:function(el,binding){
|
||||
if(!binding.value||!binding.value.obj) return;
|
||||
let unsavedChange = localStorage.getItem('nz-unnsaved-change');
|
||||
let oldValue = JSON.parse(JSON.stringify(binding.value.obj));
|
||||
function domClick(e){
|
||||
let newValue = JSON.parse(JSON.stringify(binding.value.obj));
|
||||
if(!isEqual(oldValue,newValue)){
|
||||
if(unsavedChange=='on'&&!isEqual(oldValue,newValue)){
|
||||
MessageBox.confirm(i18n.t("tip.confirmCancel"), {
|
||||
confirmButtonText: i18n.t("tip.yes"),
|
||||
cancelButtonText: i18n.t("tip.no"),
|
||||
|
||||
@@ -743,6 +743,7 @@ const cn = {
|
||||
second:'秒',
|
||||
day:'天',
|
||||
maxSeries:'Query max series',
|
||||
unsaved:'未保存提示'
|
||||
},
|
||||
email: {
|
||||
email: "邮件",
|
||||
|
||||
@@ -747,6 +747,7 @@ const en = {
|
||||
second:'second',
|
||||
day:'day',
|
||||
maxSeries:'Query max series',
|
||||
unsaved:'Unsaved tip'
|
||||
},
|
||||
email:{
|
||||
email:'Email',
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
<el-option v-for="(item,index) in timezoneOption" :key="index" :label="item.label" :value="item.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('config.system.basic.unsaved')" prop="unsaved_change">
|
||||
<el-switch v-model.number="basic.unsaved_change" active-color="rgb(238, 157, 63)" active-value='on' inactive-value='off'>
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<button
|
||||
@click="resetForm('basicForm','basic')" class="nz-btn nz-btn-size-normal-new nz-btn-style-light-new" type="button"
|
||||
@@ -362,7 +366,8 @@
|
||||
current_site_url:'',
|
||||
timezone:'',
|
||||
default_cabinet_usize:'',
|
||||
query_max_series:''
|
||||
query_max_series:'',
|
||||
unsaved_change:'on',
|
||||
},
|
||||
basicCopy:null,
|
||||
basicRules:{
|
||||
@@ -553,6 +558,7 @@
|
||||
localStorage.setItem('nz-sys-timezone',this.basic.timezone);
|
||||
localStorage.setItem('nz-sys-asset-ping-switch',this.basic.asset_ping_switch);
|
||||
localStorage.setItem('nz-sys-default-cabinet-usize',this.basic.default_cabinet_usize);
|
||||
localStorage.setItem('nz-unnsaved-change',this.basic.unsaved_change)
|
||||
}else if(type == 'terminal'){
|
||||
localStorage.setItem('nz-sys-max-terminal-num',this.terminal.max_terminal_num);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ const user = {
|
||||
state: {
|
||||
menuList: [],
|
||||
buttonList: [],
|
||||
roleList: []
|
||||
roleList: [],
|
||||
},
|
||||
mutations: {
|
||||
setMenuList(state, menuList) {
|
||||
@@ -45,7 +45,7 @@ const user = {
|
||||
localStorage.setItem('nz-sys-default-cabinet-usize',res.data.defaultCabinetUsize);
|
||||
localStorage.setItem('nz-sys-max-terminal-num',res.data.maxTerminalNum);
|
||||
localStorage.setItem('nz-sys-asset-ping-switch',res.data.assetPingSwitch);
|
||||
|
||||
localStorage.setItem('nz-unnsaved-change',res.data.unsavedChange)
|
||||
post("/sys/user/permissions", {token: res.data.token}).then(res => {
|
||||
let menuList = sortByOrderNum(res.data.menus);
|
||||
store.commit("setMenuList", menuList);
|
||||
|
||||
Reference in New Issue
Block a user