This commit is contained in:
闫晓茹 2023-04-27 15:54:48 +08:00
parent a32345373c
commit b7d2367b6e
4 changed files with 111 additions and 79 deletions

View File

@ -12,7 +12,7 @@ let downloadLoadingInstance;
export let isRelogin = { show: false };
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例
// 创建axios实例
const service = axios.create({
// axios中请求配置有baseURL选项表示请求URL公共部分
baseURL: process.env.VUE_APP_BASE_API,
@ -24,7 +24,7 @@ const service = axios.create({
service.interceptors.request.use(config => {
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false
// 是否需要防止数据重复提交
// 是否需要防止数据重复提交
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
if (getToken() && !isToken) {
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
@ -67,48 +67,48 @@ service.interceptors.request.use(config => {
// 响应拦截器
service.interceptors.response.use(res => {
// 未设置状态码则默认成功状态
const code = res.data.code || 200;
// 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default']
// 二进制数据则直接返回
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
return res.data
// 未设置状态码则默认成功状态
const code = res.data.code || 200;
// 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default']
// 二进制数据则直接返回
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
return res.data
}
if (code === 401) {
if (!isRelogin.show) {
isRelogin.show = true;
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
confirmButtonText: '重新登录',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
isRelogin.show = false;
store.dispatch('LogOut').then(() => {
location.href = '/index';
})
}).catch(() => {
isRelogin.show = false;
});
}
if (code === 401) {
if (!isRelogin.show) {
isRelogin.show = true;
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
confirmButtonText: '重新登录',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
isRelogin.show = false;
store.dispatch('LogOut').then(() => {
location.href = '/index';
})
}).catch(() => {
isRelogin.show = false;
});
}
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
Message({
message: msg,
type: 'error'
})
return Promise.reject(new Error(msg))
} else if (code === 600) {
return Promise.reject(new Error(msg))
} else if (code !== 200) {
Notification.error({
title: msg
})
return Promise.reject('error')
} else {
return res.data
}
},
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
Message({
message: msg,
type: 'error'
})
return res.data & Promise.reject(new Error(msg))
} else if (code === 600) {
return Promise.reject(new Error(msg))
} else if (code !== 200) {
Notification.error({
title: msg
})
return Promise.reject('error')
} else {
return res.data
}
},
error => {
console.log('err' + error)
let { message } = error;
@ -135,7 +135,7 @@ export function download(url, params, filename) {
transformRequest: [(params) => { return tansParams(params) }],
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob'
}).then(async(data) => {
}).then(async (data) => {
const isLogin = await blobValidate(data);
if (isLogin) {
const blob = new Blob([data])

View File

@ -1,13 +1,19 @@
<template>
<div>
<div class="user-info-head" :class="video.VideoPath ? 'wihi' : ''" @click="editCropper()">
<div
class="user-info-head"
:class="video.VideoPath ? 'wihi' : ''"
@click="editCropper()"
>
<video
style="width: 208px; height: 208px"
v-if="video.VideoPath"
v-bind:src="video.VideoPath"
class="avatar video-avatar"
controls="controls"
>您的浏览器不支持视频播放</video>
>
您的浏览器不支持视频播放
</video>
<img
v-if="options.img"
v-bind:src="options.img"
@ -56,8 +62,14 @@
v-bind:src="videoForm.showVideoPath"
class="avatar video-avatar"
controls="controls"
>您的浏览器不支持视频播放</video>
<img style="width: 100%; height: 100%" v-if="previews.url" :src="previews.url" />
>
您的浏览器不支持视频播放
</video>
<img
style="width: 100%; height: 100%"
v-if="previews.url"
:src="previews.url"
/>
<div v-else></div>
</div>
<div
@ -67,7 +79,9 @@
types != 'posterPictureUrl' &&
types != 'itemDirectoryUrl'
"
>请上传图片为800x800px的正方形</div>
>
请上传图片为800x800px的正方形
</div>
</el-col>
</el-row>
<br />
@ -113,9 +127,17 @@
@click="rotateRight()"
></el-button>
</el-col>-->
<el-col :lg="{ span: 2, offset: 19}" :md="2">
<el-button v-if="uploadbtn" type="primary" size="small" @click="uploadImg()"> </el-button>
<el-button v-else :loading="!uploadbtn" type="primary" size="small"> ...</el-button>
<el-col :lg="{ span: 2, offset: 19 }" :md="2">
<el-button
v-if="uploadbtn"
type="primary"
size="small"
@click="uploadImg()"
> </el-button
>
<el-button v-else :loading="!uploadbtn" type="primary" size="small"
> ...</el-button
>
</el-col>
</el-row>
</el-dialog>
@ -131,7 +153,7 @@ import {
uploadVideoUrl,
uploadTrainingCategoryPicture,
updatePoserHeads,
uploadUrl
uploadUrl,
} from "@/api/system/stationAvatar.js";
export default {
@ -153,17 +175,17 @@ export default {
autoCrop: true, //
autoCropWidth: 300, //
autoCropHeight: 300, //
fixedBox: true //
fixedBox: true, //
},
previews: {},
items: {},
//
videoForm: {
showVideoPath: null //
showVideoPath: null, //
},
video: {
VideoPath: null //
}
VideoPath: null, //
},
};
},
created() {
@ -191,12 +213,12 @@ export default {
},
watch: {
tovideo: {
handler(newimg, oldimg) {}
handler(newimg, oldimg) {},
},
item: {
handler(newimg, oldimg) {
this.items = this.item;
}
},
},
img: {
handler(newimg, oldimg) {
@ -207,13 +229,13 @@ export default {
} else {
this.options.img = baseurl + this.img;
}
}
},
},
type: {
handler(newimg, oldimg) {
this.types = this.type;
}
}
},
},
},
methods: {
//
@ -276,38 +298,45 @@ export default {
if (this.types == "itemDirectoryUrl") {
this.$modal.msgSuccess("上传视频中,请耐心等待");
this.uploadbtn = false;
uploadVideoUrl(formData).then(response => {
this.video.VideoPath = baseurl + response.imgUrl;
this.$emit("imgUrl", response.imgUrl);
this.items.itemDirectoryUrl = response.imgUrl;
this.$emit("item", JSON.stringify(this.items));
uploadVideoUrl(formData).then((response) => {
if (response.code == 200) {
this.video.VideoPath = baseurl + response.imgUrl;
this.$emit("imgUrl", response.imgUrl);
this.items.itemDirectoryUrl = response.imgUrl;
this.$emit("item", JSON.stringify(this.items));
this.openimg = false;
} else {
this.$emit("item", "false");
setTimeout((e) => {
this.openimg = false;
}, 1000);
}
this.uploadbtn = true;
this.openimg = false;
});
} else if (
this.types == "trainingItemCoverUrl" ||
this.types == "trainingItemContentUrl" ||
this.types == "trainingItemPosterUrl"
) {
uploadUrl(formData).then(response => {
uploadUrl(formData).then((response) => {
this.options.img = baseurl + response.imgUrl;
this.$emit("imgUrl", response.imgUrl);
this.openimg = false;
});
} else if (this.types == "trainingCategoryPictureUrl") {
uploadTrainingCategoryPicture(formData).then(response => {
uploadTrainingCategoryPicture(formData).then((response) => {
this.options.img = baseurl + response.imgUrl;
this.$emit("imgUrl", response.imgUrl);
this.openimg = false;
});
} else if (this.types == "posterVideoUrl") {
updatePoserHeads(formData).then(response => {
updatePoserHeads(formData).then((response) => {
this.video.VideoPath = baseurl + response.imgUrl;
this.$emit("imgUrl", response.imgUrl);
this.openimg = false;
});
} else {
updateNurseStationHeads(formData).then(response => {
updateNurseStationHeads(formData).then((response) => {
this.options.img = baseurl + response.imgUrl;
this.$emit("imgUrl", response.imgUrl);
if (this.types == "attributePitureUrl") {
@ -349,8 +378,8 @@ export default {
closeDialog() {
this.imgs = "";
this.visible = false;
}
}
},
},
};
</script>
<style scoped lang="scss">

View File

@ -1093,7 +1093,6 @@ export default {
//
itemDirectoryUrl(item) {
let items = JSON.parse(item);
console.log(items);
if (items.idd && !items.trainingItemDirectoryId) {
this.form.trainingItemDirectoryList.forEach((e) => {
if (e.idd == items.idd) {
@ -1298,7 +1297,7 @@ export default {
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams.trainingItemType='';
this.queryParams.trainingItemType = "";
this.resetForm("queryForm");
this.handleQuery();
},
@ -1403,11 +1402,14 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
console.log(row)
console.log(row);
const ids = row.id || this.ids;
const trainingItemTitles = row.trainingItemTitle || this.trainingItemTitles;
const trainingItemTitles =
row.trainingItemTitle || this.trainingItemTitles;
this.$modal
.confirm('是否确认删除培训课程名称为"' + trainingItemTitles + '"的数据项?')
.confirm(
'是否确认删除培训课程名称为"' + trainingItemTitles + '"的数据项?'
)
.then(function () {
return delTrainingItem(ids);
})

View File

@ -673,6 +673,7 @@ export default {
this.reset();
const id = row.id || this.ids;
getTrainingOrder(id).then((response) => {
console.log(response)
this.form = response.data;
this.form.trainingOrderDetailsList =
response.data.trainingOrderDetailsList;