feat: v3版疗休养优化6

This commit is contained in:
2026-10-26 16:50:49 +08:00
parent 4c03b389d4
commit 56cc3fee91
30 changed files with 868 additions and 342 deletions
@@ -105,11 +105,11 @@ const nation = [
'基诺族'
];
const loc = () => {
function loc() {
return location.href.replace(location.search, "").replace(location.hash, "")
}
const clone = (obj) => {
function clone(obj) {
return JSON.parse(JSON.stringify(obj))
}
@@ -1,4 +1,7 @@
const sublime = {
jumpPagePjax(url) {
window.location.href = url;
},
showLoadingbar() {
if (!document.getElementById('therapy-loading')) {
const bar = document.createElement('div');
@@ -12,6 +15,77 @@ const sublime = {
}
};
Vue.prototype.$validateForm = function(form) {
return new Promise(resolve => {
if (!form) {
this.$message.error('表单尚未加载完成');
resolve(false);
return;
}
const uploading = component => {
if (Array.isArray(component.uploadFiles) && component.uploadFiles.some(file => file.status === 'uploading')) return true;
return (component.$children || []).some(uploading);
};
if (uploading(form)) {
this.$message.warning('请等待图片或附件上传完成后再提交');
resolve(false);
return;
}
form.validate((valid, fields) => {
if (!valid) {
const errors = Object.values(fields || {}).flat();
this.$message.warning(errors.length ? errors[0].message : '请检查必填项和填写格式');
}
resolve(valid);
});
});
};
Vue.prototype.$confirmAction = async function(...args) {
try {
return await this.$confirm(...args);
} catch (error) {
if (error === 'cancel' || error === 'close') return false;
throw error;
}
};
Vue.prototype.$actionError = function(error) {
if (error === 'cancel' || error === 'close') return;
const message = error && (error.responseJSON && error.responseJSON.msg || error.msg || error.message);
this.$message.error(message || '操作失败,请稍后重试');
};
Vue.prototype.$downloadFile = function(url) {
window.location.href = url;
};
Vue.prototype.$importExcel = function(url, files) {
const data = new FormData();
files.forEach(file => data.append('file', file.raw, file.raw.name));
return $.ajax({url: url, type: 'POST', data: data, processData: false, contentType: false});
};
Vue.directive('throttle', {
bind(el) {
let lastClick = 0;
el.therapyThrottleHandler = event => {
const now = Date.now();
if (now - lastClick < 1000) {
event.preventDefault();
event.stopImmediatePropagation();
return;
}
lastClick = now;
};
el.addEventListener('click', el.therapyThrottleHandler, true);
},
unbind(el) {
el.removeEventListener('click', el.therapyThrottleHandler, true);
delete el.therapyThrottleHandler;
}
});
$.ajaxSetup({
traditional: true,
error(xhr) {
@@ -54,7 +54,7 @@ const initTableMixins = {
removeFile()
}
if (size && !file.size < size) {
if (size && file.size > size) {
this.notifyWarning(`文件大小不能超过 ${size / 1024 / 1024}MB!`)
removeFile()
}
@@ -104,7 +104,10 @@ const initTableMixins = {
} else {
this.$message.error(data.msg);
}
}, "json");
}, "json").always(() => {
sublime.closeLoadingbar();
this.tableLoading = false;
});
},
notifySuccess(msg) {
this.$notify({