更新页面
This commit is contained in:
@ -1,14 +1,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="form-item-box" :style="{ width: width }">
|
<div class="form-item-box" :class="props.showBtn ? 'showBtn-upload' : ''" :style="{ width: width }">
|
||||||
<el-upload v-bind="$attrs" :headers="headers" :multiple="false" class="avatar-uploader" :limit="props.limit"
|
<el-upload
|
||||||
:action="actionUrl" list-type="picture-card" :file-list="fileList" show-file-list :on-exceed="handleExceed"
|
v-bind="$attrs"
|
||||||
:on-success="handlerSuccess" :before-upload="beforeImgUpload">
|
:headers="headers"
|
||||||
|
:multiple="false"
|
||||||
|
class="avatar-uploader"
|
||||||
|
:limit="props.limit"
|
||||||
|
:action="actionUrl"
|
||||||
|
:list-type="props.showBtn ? '' : 'picture-card'"
|
||||||
|
:file-list="fileList" show-file-list
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
:on-success="handlerSuccess"
|
||||||
|
:before-upload="beforeImgUpload">
|
||||||
<template #default>
|
<template #default>
|
||||||
<el-icon>
|
<el-button v-if="props.showBtn" size="small" type="primary">上传文件</el-button>
|
||||||
<Plus />
|
<el-icon v-else><Plus /></el-icon>
|
||||||
</el-icon>
|
|
||||||
</template>
|
</template>
|
||||||
<template #file="{ file }">
|
<template #file="{ file }" v-if="!props.showBtn">
|
||||||
<div v-if="props.isImg">
|
<div v-if="props.isImg">
|
||||||
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
|
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
|
||||||
<span class="el-upload-list__item-actions">
|
<span class="el-upload-list__item-actions">
|
||||||
@ -16,29 +24,21 @@
|
|||||||
<el-icon> <zoom-in /></el-icon>
|
<el-icon> <zoom-in /></el-icon>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file, fileList)">
|
<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file, fileList)">
|
||||||
<el-icon>
|
<el-icon><Delete /></el-icon>
|
||||||
<Delete />
|
|
||||||
</el-icon>
|
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="file-wrap">
|
<div class="file-wrap">
|
||||||
<span>
|
<span><svg-icon :icon="getSuffix(file.name)" /></span>
|
||||||
<svg-icon :icon="getSuffix(file.name)" />
|
|
||||||
</span>
|
|
||||||
<span class="file-name">{{ file.name }}</span>
|
<span class="file-name">{{ file.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="el-upload-list__item-actions">
|
<span class="el-upload-list__item-actions">
|
||||||
<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
|
<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
|
||||||
<el-icon>
|
<el-icon><Download /></el-icon>
|
||||||
<Download />
|
|
||||||
</el-icon>
|
|
||||||
</span>
|
</span>
|
||||||
<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file, fileList)">
|
<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file, fileList)">
|
||||||
<el-icon>
|
<el-icon><Delete /></el-icon>
|
||||||
<Delete />
|
|
||||||
</el-icon>
|
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -52,9 +52,8 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { COMPONENT_WIDTH } from "@/constant";
|
import { COMPONENT_WIDTH } from "@/constant";
|
||||||
import { ref, defineProps, defineEmits, defineExpose, computed, watch, onMounted } from "vue";
|
import { ref, defineProps, defineEmits, computed, watch, onMounted } from "vue";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
|
||||||
import { useStore } from "vuex";
|
import { useStore } from "vuex";
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
//获取组件传值
|
//获取组件传值
|
||||||
@ -73,12 +72,24 @@ const props = defineProps({
|
|||||||
width: {
|
width: {
|
||||||
default: COMPONENT_WIDTH,
|
default: COMPONENT_WIDTH,
|
||||||
type: String
|
type: String
|
||||||
|
},
|
||||||
|
showBtn: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
isAll: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false //所有类型都可以用这个接口,返回的是id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const actionUrl = computed(() =>
|
const actionUrl = computed(() => {
|
||||||
props.isImg ? "/mosty-base/minio/image/upload/id" : "/mosty-base/minio/file/upload"
|
if (props.isAll) {
|
||||||
);
|
return "/mosty-base/minio/image/upload/id";
|
||||||
|
} else {
|
||||||
|
return props.isImg ? "/mosty-base/minio/image/upload/id": "/mosty-base/minio/file/upload";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const emits = defineEmits(["update:modelValue", "handleChange"]);
|
const emits = defineEmits(["update:modelValue", "handleChange"]);
|
||||||
|
|
||||||
@ -104,33 +115,25 @@ const getSuffix = (fileName) => {
|
|||||||
//excel XLS
|
//excel XLS
|
||||||
const excelist = ["xls", "xlsx"];
|
const excelist = ["xls", "xlsx"];
|
||||||
if (excelist.includes(suffix)) return "XLS";
|
if (excelist.includes(suffix)) return "XLS";
|
||||||
|
|
||||||
// 匹配 word
|
// 匹配 word
|
||||||
var wordlist = ["doc", "docx"];
|
var wordlist = ["doc", "docx"];
|
||||||
if (wordlist.includes(suffix)) return "DOC";
|
if (wordlist.includes(suffix)) return "DOC";
|
||||||
|
|
||||||
//pdf
|
//pdf
|
||||||
if (suffix === "pdf") return "PDF";
|
if (suffix === "pdf") return "PDF";
|
||||||
|
|
||||||
//视频 音频
|
//视频 音频
|
||||||
var videolist = ["mp4","m2v","mkv","rmvb","wmv","avi","flv","mov","m4v"];
|
var videolist = ["mp4","m2v","mkv","rmvb","wmv","avi","flv","mov","m4v"];
|
||||||
if (videolist.includes(suffix)) return "VIDEO";
|
if (videolist.includes(suffix)) return "VIDEO";
|
||||||
|
|
||||||
var musiclist = ["mp3", "wav", "wmv"];
|
var musiclist = ["mp3", "wav", "wmv"];
|
||||||
if (musiclist.includes(suffix)) return "MUSIC";
|
if (musiclist.includes(suffix)) return "MUSIC";
|
||||||
|
|
||||||
var pptlist = ["ppt", "pptx"];
|
var pptlist = ["ppt", "pptx"];
|
||||||
if (pptlist.includes(suffix)) return "PPT";
|
if (pptlist.includes(suffix)) return "PPT";
|
||||||
|
|
||||||
//压缩包
|
//压缩包
|
||||||
var yslist = ["7z", "rar", "zip", "apz", "ar", "hpk", "hyp", "hbc2"];
|
var yslist = ["7z", "rar", "zip", "apz", "ar", "hpk", "hyp", "hbc2"];
|
||||||
if (yslist.includes(suffix)) return "YS";
|
if (yslist.includes(suffix)) return "YS";
|
||||||
|
|
||||||
//否则返回other
|
//否则返回other
|
||||||
return "OTHER";
|
return "OTHER";
|
||||||
};
|
};
|
||||||
|
|
||||||
const imageUrl = ref("");
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const dialogImageUrl = ref("");
|
const dialogImageUrl = ref("");
|
||||||
const dialogVisible = ref(false);
|
const dialogVisible = ref(false);
|
||||||
@ -139,47 +142,37 @@ const headers = ref({
|
|||||||
Authorization: store.getters.token
|
Authorization: store.getters.token
|
||||||
});
|
});
|
||||||
|
|
||||||
const propsModelValue = ref()
|
|
||||||
const fileList = ref([]);
|
const fileList = ref([]);
|
||||||
watch(() => props.modelValue,(val) => {
|
watch(() => props.modelValue,(val) => {
|
||||||
console.log(val,"xxxxxxxxxxx");
|
let arr = val ? (Array.isArray(val) ? val :[val]): [];
|
||||||
if (Array.isArray(val)) {
|
if (arr.length > 0) {
|
||||||
propsModelValue.value=val
|
fileList.value = arr.map((el) => {
|
||||||
|
if (Object.prototype.toString.call(el) === "[object Object]") {
|
||||||
|
return { url: `/mosty-base/minio/image/download/` + el, name: el.name};
|
||||||
} else {
|
} else {
|
||||||
propsModelValue.value = val ? val.split(',') : []
|
|
||||||
}
|
|
||||||
if (propsModelValue.value) {
|
|
||||||
fileList.value = propsModelValue.value.map((el) => {
|
|
||||||
return { url: `/mosty-base/minio/image/download/` + el };
|
return { url: `/mosty-base/minio/image/download/` + el };
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},{deep:true,immediate:true});
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
// 初始化数据
|
|
||||||
// if (propsModelValue.value) {
|
|
||||||
// fileList.value = propsModelValue.value.map((el) => {
|
|
||||||
// return { url: `/mosty-base/minio/image/download/` + el };
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
|
}else{
|
||||||
|
fileList.value = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
const handlerSuccess = (res, file) => {
|
const handlerSuccess = (res, file) => {
|
||||||
file.url = `/mosty-base/minio/image/download/` + res.data;
|
file.url = `/mosty-base/minio/image/download/` + res.data;
|
||||||
fileList.value.push(file);
|
fileList.value.push(file);
|
||||||
if (Array.isArray(propsModelValue.value)) {
|
let arr = props.modelValue ? props.modelValue : [];
|
||||||
propsModelValue.value.push(res.data);
|
if(props.isImg){
|
||||||
|
arr.push(res.data);
|
||||||
}else{
|
}else{
|
||||||
propsModelValue.value =propsModelValue.value? propsModelValue.value.split(','):[]
|
arr.push({url:res.data,name:file.name});
|
||||||
propsModelValue.value.push(res.data);
|
|
||||||
}
|
}
|
||||||
|
emits("update:modelValue", arr);
|
||||||
console.log( propsModelValue.value);
|
emits("handleChange", props.modelValue);
|
||||||
emits("update:modelValue", propsModelValue.value.toString());
|
|
||||||
// emits("handleChange", propsModelValue.value);
|
|
||||||
};
|
};
|
||||||
const handlePreview = (file) => { };
|
|
||||||
const handleExceed = (files, fileList) => {
|
const handleExceed = (files, fileList) => {
|
||||||
ElMessage.warning(`限制,只能上传${props.limit}个文件或图片`);
|
ElMessage.warning(`限制,只能上传${props.limit}个文件或图片`);
|
||||||
};
|
};
|
||||||
@ -187,7 +180,7 @@ const handleExceed = (files, fileList) => {
|
|||||||
const beforeImgUpload = (file) => {
|
const beforeImgUpload = (file) => {
|
||||||
if (props.isImg) {
|
if (props.isImg) {
|
||||||
let isIMG = false;
|
let isIMG = false;
|
||||||
if (getSuffix(file.name) === "IMG" || getSuffix(file.name) === "MUSIC") {
|
if (getSuffix(file.name) === "IMG") {
|
||||||
isIMG = true;
|
isIMG = true;
|
||||||
}
|
}
|
||||||
const isLt5M = file.size / 1024 / 1024 < 5;
|
const isLt5M = file.size / 1024 / 1024 < 5;
|
||||||
@ -202,62 +195,27 @@ const beforeImgUpload = (file) => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleAvatarSuccess = (res, file) => {
|
|
||||||
imageUrl.value = URL.createObjectURL(file.raw);
|
|
||||||
};
|
|
||||||
//查询图片
|
//查询图片
|
||||||
const handlePictureCardPreview = (file) => {
|
const handlePictureCardPreview = (file) => {
|
||||||
dialogImageUrl.value = file.url;
|
dialogImageUrl.value = file.url;
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
};
|
};
|
||||||
const handleDownload = (file) => {
|
const handleDownload = (file) => {
|
||||||
console.log(file);
|
window.open(file.response.data);
|
||||||
|
|
||||||
// window.open(file.response.data);
|
|
||||||
window.open(file);
|
|
||||||
};
|
};
|
||||||
const handleRemove = (file) => {
|
const handleRemove = (file) => {
|
||||||
let index = fileList.value.findIndex(function (item) {
|
let index = fileList.value.findIndex(function (item) {
|
||||||
return item.url === file.url;
|
return item.url === file.url;
|
||||||
});
|
});
|
||||||
fileList.value.splice(index, 1);
|
fileList.value.splice(index, 1);
|
||||||
propsModelValue.value.splice(index, 1);
|
props.modelValue.splice(index, 1);
|
||||||
// emits("handleChange", propsModelValue.value);
|
emits("handleChange", props.modelValue);
|
||||||
emits("update:modelValue", propsModelValue.value.toString());
|
emits("update:modelValue", props.modelValue);
|
||||||
};
|
};
|
||||||
watch(
|
const propsModelValue = ref();
|
||||||
() => props.modelValue,
|
|
||||||
(val) => {
|
|
||||||
let arr = val ? val : [];
|
|
||||||
if(Array.isArray(arr)){
|
|
||||||
if (arr && arr.length > 0) {
|
|
||||||
fileList.value = arr.map((el) => {
|
|
||||||
return { url: `/mosty-base/minio/image/download/` + el };
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
arr.split(",").map(item=>{
|
|
||||||
return { url: `/mosty-base/minio/image/download/` + item };
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.avatar-uploader {
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader .el-upload {
|
.avatar-uploader .el-upload {
|
||||||
border: 1px dashed #d9d9d9;
|
border: 1px dashed #d9d9d9;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
@ -309,11 +267,4 @@ arr.split(",").map(item=>{
|
|||||||
-webkit-line-clamp: 2;
|
-webkit-line-clamp: 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .el-upload-list--picture-card {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding-top: 7px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
<MOSTY.Date v-else-if="item.type == 'date'" :type="item.lx ? item.lx : 'date'" width="100%" clearable
|
<MOSTY.Date v-else-if="item.type == 'date'" :type="item.lx ? item.lx : 'date'" width="100%" clearable
|
||||||
v-model="listQuery[item.prop]" />
|
v-model="listQuery[item.prop]" />
|
||||||
<!-- 上传 upload limit:'限制张数'-->
|
<!-- 上传 upload limit:'限制张数'-->
|
||||||
<MOSTY.Upload v-else-if="item.type == 'upload'" :showBtn="item.showBtn" :isImg="item.isImg" :limit="item.limit" width="100%"
|
<MOSTY.Upload v-else-if="item.type == 'upload'" :isAll="item.isAll" :showBtn="item.showBtn" :isImg="item.isImg" :limit="item.limit" width="100%"
|
||||||
v-model="listQuery[item.prop]" />
|
v-model="listQuery[item.prop]" />
|
||||||
<!--选择checkbox -->
|
<!--选择checkbox -->
|
||||||
<MOSTY.CheckBox v-else-if="item.type == 'checkbox'" width="100%" clearable v-model="listQuery[item.prop]"
|
<MOSTY.CheckBox v-else-if="item.type == 'checkbox'" width="100%" clearable v-model="listQuery[item.prop]"
|
||||||
|
|||||||
@ -69,10 +69,12 @@ function getDateById (id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const save = () => {
|
const save = () => {
|
||||||
FormRef.value.submit(()=>{
|
FormRef.value.submit((val)=>{
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
let url = title.value == '新增' ? `/mosty-base/baxx/jxda/add` : `/mosty-base/baxx/jxda/edit`;
|
let url = title.value == '新增' ? `/mosty-base/baxx/jxda/add` : `/mosty-base/baxx/jxda/edit`;
|
||||||
qcckPost(listQuery.value, url).then(() => {
|
let params = { ...val }
|
||||||
|
params.fj = params.fj ? params.fj.join(','):''
|
||||||
|
qcckPost(params, url).then(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
proxy.$message.success("保存成功");
|
proxy.$message.success("保存成功");
|
||||||
emit("refresh");
|
emit("refresh");
|
||||||
@ -84,7 +86,7 @@ const save = () => {
|
|||||||
}
|
}
|
||||||
const close = () => {
|
const close = () => {
|
||||||
dialogForm.value = false;
|
dialogForm.value = false;
|
||||||
listQuery.value = {fj:''}
|
listQuery.value = {fj:[]}
|
||||||
FormRef.value.reset()
|
FormRef.value.reset()
|
||||||
};;
|
};;
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ const formList = reactive([
|
|||||||
{ label: "视频标题", prop: "spbt", type: "input" },
|
{ label: "视频标题", prop: "spbt", type: "input" },
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{ label: "附件", prop: "fjid", type: "upload",isImg:false,showBtn:true,limit:2 },
|
{ label: "附件", prop: "fjid", type: "upload",isImg:false,showBtn:true,limit:2 ,isAll:true},
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -46,14 +46,23 @@ const init = (type, row = {}) => {
|
|||||||
dialogForm.value = true;
|
dialogForm.value = true;
|
||||||
openType.value = type;
|
openType.value = type;
|
||||||
title.value = type == "add" ? "新增" : "编辑";
|
title.value = type == "add" ? "新增" : "编辑";
|
||||||
listQuery.value = { ...row }
|
if(row) getDateById(row.id)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getDateById = (id) =>{
|
||||||
|
qcckPost({},'/mosty-base/baxx/sok/getInfo/'+id).then(res=>{
|
||||||
|
res.fjid = res.fjid ? JSON.parse(res.fjid):[];
|
||||||
|
listQuery.value = res || {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const save = () => {
|
const save = () => {
|
||||||
FormRef.value.submit(()=>{
|
FormRef.value.submit((val)=>{
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
let url = title.value == '新增' ? `/mosty-base/baxx/sok/add` : `/mosty-base/baxx/sok/edit`;
|
let url = title.value == '新增' ? `/mosty-base/baxx/sok/add` : `/mosty-base/baxx/sok/edit`;
|
||||||
qcckPost(listQuery.value, url).then(() => {
|
let params = {...val }
|
||||||
|
params.fjid = params.fjid ? JSON.stringify(params.fjid):''
|
||||||
|
qcckPost(params, url).then(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
proxy.$message.success("保存成功");
|
proxy.$message.success("保存成功");
|
||||||
emit("refresh");
|
emit("refresh");
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
<template #controls="{ row }">
|
<template #controls="{ row }">
|
||||||
<el-link type="primary" link @click="addEdit('edit', row)">编辑</el-link>
|
<el-link type="primary" link @click="addEdit('edit', row)">编辑</el-link>
|
||||||
<el-link type="primary" link @click="addEdit('detail', row)">详情</el-link>
|
<el-link type="primary" link @click="addEdit('detail', row)">详情</el-link>
|
||||||
<el-link type="danger" link @click="handleDelete(row.id)">删除</el-link>
|
<el-link type="danger" link @click="handleDelete([row.id])">删除</el-link>
|
||||||
</template>
|
</template>
|
||||||
</MyTable>
|
</MyTable>
|
||||||
<Pages @changeNo="changeNo" @changeSize="changeSize" :tableHeight="pageData.tableHeight" :pageConfiger="{
|
<Pages @changeNo="changeNo" @changeSize="changeSize" :tableHeight="pageData.tableHeight" :pageConfiger="{
|
||||||
@ -115,7 +115,7 @@ const getList = () => {
|
|||||||
// 删除
|
// 删除
|
||||||
const handleDelete = (ids) => {
|
const handleDelete = (ids) => {
|
||||||
proxy.$modal.confirm("是否确认删除该视频?").then(() => {
|
proxy.$modal.confirm("是否确认删除该视频?").then(() => {
|
||||||
qcckPost({ ids }, "/mosty-base/baxx/sok/remove").then(() => {
|
qcckPost(ids, "/mosty-base/baxx/sok/remove").then(() => {
|
||||||
proxy.$modal.msgSuccess("删除成功");
|
proxy.$modal.msgSuccess("删除成功");
|
||||||
getList();
|
getList();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user