feat: v3版疗休养优化4

This commit is contained in:
2026-10-26 14:28:19 +08:00
parent 65fac78cfb
commit fcb6ba7e2d
17 changed files with 281 additions and 372 deletions
@@ -1,10 +1,26 @@
<template>
<el-drawer title="参加人员范围设置" :visible.sync="userScopeDialog" size="90%" :append-to-body="true" @closed="$emit('group_change')">
<iframe v-if="userScopeDialog" src="/platform/activity/basic/scope" title="参加人员范围设置" style="width:100%;height:calc(100vh - 90px);border:0"></iframe>
<el-drawer title="参加人员范围设置" :visible.sync="userScopeDialog" size="90%" :append-to-body="true" @closed="loadGroups">
<div style="padding:0 20px 10px">
<el-select :value="group_id" placeholder="选择疗休养参加人员分组" filterable clearable @change="$emit('update:group_id', $event)">
<el-option v-for="group in groups" :key="group.groupId" :label="group.groupName" :value="group.groupId"></el-option>
</el-select>
<el-button type="text" @click="loadGroups">刷新分组</el-button>
</div>
<iframe v-if="userScopeDialog" src="/platform/activity/basic/scope" title="参加人员范围设置" style="width:100%;height:calc(100vh - 150px);border:0"></iframe>
</el-drawer>
</template>
<script>
module.exports = {
data() { return {userScopeDialog: false}; }
props: {group_id: {type: [String, Number], default: null}},
data() { return {userScopeDialog: false, groups: []}; },
watch: {userScopeDialog(value) { if (value) this.loadGroups(); }},
methods: {
async loadGroups() {
const result = await $.get('/platform/activity/basic/scope/getActivityUserScopeGroup');
if (result.code !== 0) { this.$message.error(result.msg); return; }
this.groups = result.data || [];
this.$emit('group_change');
}
}
};
</script>
@@ -1,7 +1,7 @@
<template>
<div>
<div v-if="view">
<a v-for="file in files" :key="file.id || file.filepath" :href="file.filepath || preview(file.id)" target="_blank" style="display:block">{{ file.filename || file.name }}</a>
<a v-for="file in files" :key="file.id || file.filepath" :href="file.downloadPath || file.filepath || preview(file.id)" target="_blank" style="display:block">{{ file.name || file.filename }}</a>
</div>
<el-upload v-else action="/platform/inclusiveTherapyV3/common/uploadFile" name="file"
:limit="max" :multiple="max > 1" :file-list="fileList" :drag="card"
@@ -17,7 +17,7 @@ module.exports = {
max: {type: Number, default: 10}, type: Array, max_size: Number},
data() { return {fileList: []}; },
watch: {files: {immediate: true, deep: true, handler(files) {
this.fileList = (files || []).map(file => ({name: file.filename || file.name, url: file.filepath || therapyPreview(file.id), rawInfo: file}));
this.fileList = (files || []).map(file => ({name: file.name || file.filename, url: file.downloadPath || file.filepath || therapyPreview(file.id), rawInfo: file}));
}}},
methods: {
preview: therapyPreview,
@@ -28,15 +28,19 @@ module.exports = {
return true;
},
success(result, file, list) {
if (result.code !== 0) { this.$message.error(result.msg); return; }
if (result.code !== 0) {
list.splice(list.indexOf(file), 1);
this.$message.error(result.msg); return;
}
file.rawInfo = result.data;
file.url = result.data.downloadPath || result.data.filepath;
this.emit(list);
},
remove(file, list) { this.emit(list); },
emit(list) {
this.$emit('update:files', list.map(file => file.rawInfo || file.response && file.response.data).filter(Boolean));
},
open(file) { window.open(file.url || file.rawInfo && file.rawInfo.filepath); }
open(file) { window.open(file.url || file.rawInfo && (file.rawInfo.downloadPath || file.rawInfo.filepath)); }
}
};
</script>
@@ -8,11 +8,12 @@
</template>
<script>
module.exports = {
props: {value: {type: Array, default: () => []}, limit: {type: Number, default: 1},
props: {value: {type: [String, Array], default: ''}, limit: {type: Number, default: 1},
width: {type: Number, default: 100}, height: {type: Number, default: 100}, fileType: Array, fileSize: Number},
data() { return {fileList: []}; },
watch: {value: {immediate: true, deep: true, handler(values) {
this.fileList = (values || []).map((value, index) => ({name: '图片' + (index + 1), url: therapyPreview(value)}));
const items = Array.isArray(values) ? values : values ? [values] : [];
this.fileList = items.map((value, index) => ({name: '图片' + (index + 1), url: therapyPreview(value), storedValue: value}));
}}},
methods: {
beforeUpload(file) {
@@ -25,12 +26,19 @@ module.exports = {
return true;
},
success(result, file, list) {
if (result.code !== 0) { this.$message.error(result.msg); return; }
if (result.code !== 0) {
list.splice(list.indexOf(file), 1);
this.$message.error(result.msg); return;
}
file.url = result.data.filepath;
file.storedValue = result.data.filepath;
this.emit(list);
},
remove(file, list) { this.emit(list); },
emit(list) { this.$emit('input', list.map(file => file.response ? file.response.data.filepath : file.url)); },
emit(list) {
const values = list.map(file => file.storedValue).filter(Boolean);
this.$emit('input', Array.isArray(this.value) ? values : values[0] || '');
},
open(file) { window.open(file.url); }
}
};
@@ -448,10 +448,11 @@ module.exports = {
methods: {
// 返回布尔值
beforeRead(file) {
if (Array.isArray(file)) return file.every(item => this.beforeRead(item));
const lastIndexOf = file.name.lastIndexOf(".")
const type = this.type.map(v => v.toLowerCase()).includes(file.name.substr(lastIndexOf + 1).toLowerCase())
if (!type) {
this.$message.warning(`上传文件只能是 ${this.type.map(v => v.toLowerCase()).join("/")} 格式!`);
this.$toast(`上传文件只能是 ${this.type.map(v => v.toLowerCase()).join("/")} 格式!`);
return false;
}
return true;
@@ -466,13 +467,11 @@ module.exports = {
* 查看资源
*/
showSource(showItem) {
const show = this.resolvingShowByFileName(showItem.filepath)
const show = this.resolvingShowByFileName(showItem.name || showItem.filename || '')
if (show == 1 || show == 2 || show == 3) {
$('.viewFile').viewer({
url: 'src',
});
window.open(showItem.downloadPath || showItem.filepath || therapyPreview(showItem.id));
} else if (show == 4 || show == 5 || show == 7) {
preview(showItem.filepath, showItem.id)
preview(showItem.name || showItem.filename, showItem.id)
}
},
/**
@@ -596,9 +595,13 @@ module.exports = {
return FILE_DOMAIN + fileItem;
},
change(fileList) {
this.$emit("update:files", fileList.map(v => v.data))
this.$emit("update:files", fileList.map(v => v.data).filter(Boolean))
},
afterRead(file) {
if (Array.isArray(file)) {
file.forEach(item => this.afterRead(item));
return;
}
file.status = 'uploading';
file.message = '上传中...';
@@ -616,7 +619,12 @@ module.exports = {
if (code === 0) {
file.status = 'success';
file.data = data
file.url = data.downloadPath || data.filepath || therapyPreview(data.id)
this.change(this.fileList)
} else {
file.status = 'failed';
file.message = res.msg || '上传失败';
this.$toast.fail(file.message);
}
},
error: (err) => {
@@ -627,18 +635,19 @@ module.exports = {
},
doDelete(file) {
if (file.data) {
const {filename, filepath} = file.data
if (this.del) {
$.post(FILE_DELETE_ADDRESS, {filepath})
const {id} = file.data
if (this.del && id) {
$.post(FILE_DELETE_ADDRESS, {id})
}
this.change(this.fileList)
}
},
clickPreview(file) {
const {filepath, id} = file.data
const show = this.resolvingShowByFileName(filepath)
if (!file.data) return;
const {filename, name, id} = file.data
const show = this.resolvingShowByFileName(name || filename || '')
if (show == 4 || show == 5 || show == 7) {
preview(filepath, id)
preview(name || filename, id)
}
},
updateFileList(val) {
@@ -647,15 +656,15 @@ module.exports = {
return
}
const pending = this.fileList.filter(file => !file.data);
this.fileList = val.map(v => {
let url = ''
if (this.resolvingShowByFileName(v.filename) == 1) {
url = APP_DOMAIN + '/platform/inclusiveTherapyV3/common/preview?id=' + v.id
console.log(url)
return {data: v, url, isImage: true, file: {name: v.filename}, status: 'success'}
const name = v.name || v.filename || ''
const url = v.downloadPath || v.filepath || therapyPreview(v.id)
if (this.resolvingShowByFileName(name) == 1) {
return {data: v, url, isImage: true, file: {name}, status: 'success'}
}
return {data: v, url, file: {name: v.filename}, status: 'success'}
})
return {data: v, url, file: {name}, status: 'success'}
}).concat(pending)
},
},
created() {
@@ -668,4 +677,4 @@ module.exports = {
.van-image-preview .van-image-preview__close-icon--top-right {
font-size: 50px !important;
}
</style>
</style>