mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-student.git
synced 2025-12-12 12:26:49 +08:00
init
This commit is contained in:
@@ -5,7 +5,9 @@
|
|||||||
method="POST"
|
method="POST"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
:on-change="handleChange"
|
:on-change="handleChange"
|
||||||
|
:limit="max"
|
||||||
ref="imageRef"
|
ref="imageRef"
|
||||||
|
:on-exceed="exceed"
|
||||||
>
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<div>
|
<div>
|
||||||
@@ -16,19 +18,31 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import {FILE_UPLOAD} from "@/api/api";
|
import {FILE_UPLOAD} from "@/api/api";
|
||||||
import {defineProps, ref} from "vue";
|
import {defineProps, ref, watch} from "vue";
|
||||||
|
import {ElMessage} from "element-plus";
|
||||||
|
|
||||||
const {modelValue = []} = defineProps({
|
const props = defineProps({
|
||||||
modelValue: []
|
value: [],
|
||||||
|
max: {
|
||||||
|
type: Number,
|
||||||
|
default: 1
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits()
|
const emit = defineEmits()
|
||||||
|
|
||||||
const files = ref(modelValue)
|
const files = ref([])
|
||||||
const imageRef = ref()
|
const imageRef = ref()
|
||||||
|
|
||||||
|
watch(props.value, () => {
|
||||||
|
props.value.length || (files.value = props.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
function exceed() {
|
||||||
|
ElMessage.error(`只能上传${props.max}个附件`);
|
||||||
|
}
|
||||||
|
|
||||||
function handleChange(e) {
|
function handleChange(e) {
|
||||||
console.log(e)
|
|
||||||
if (e.response && e.response.code === 200) {
|
if (e.response && e.response.code === 200) {
|
||||||
e.url = e.response.data
|
e.url = e.response.data
|
||||||
}
|
}
|
||||||
@@ -39,7 +53,7 @@ function handleChange(e) {
|
|||||||
} else {
|
} else {
|
||||||
files.value[index] = e
|
files.value[index] = e
|
||||||
}
|
}
|
||||||
emit('update:modelValue', files)
|
emit('update:value', files.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove(i) {
|
function remove(i) {
|
||||||
@@ -50,7 +64,7 @@ function reUpload(i) {
|
|||||||
if (files.value[i].status === 'ready' || files.value[i].status === 'uploading') {
|
if (files.value[i].status === 'ready' || files.value[i].status === 'uploading') {
|
||||||
imageRef.value.abort(files.value[i].raw)
|
imageRef.value.abort(files.value[i].raw)
|
||||||
files.value[i].status = 'abort';
|
files.value[i].status = 'abort';
|
||||||
} else if (files.value[i].status === 'fail'||files.value[i].status === 'abort') {
|
} else if (files.value[i].status === 'fail' || files.value[i].status === 'abort') {
|
||||||
imageRef.value.handleStart(files.value[i].raw)
|
imageRef.value.handleStart(files.value[i].raw)
|
||||||
imageRef.value.submit()
|
imageRef.value.submit()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,12 +58,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<UploadImg v-model="fileList" ref="uploadRef">
|
<UploadImg v-model:value="fileList" ref="uploadRef">
|
||||||
<button
|
<button
|
||||||
class="shangchuan"
|
class="shangchuan"
|
||||||
style="cursor: pointer"
|
style="cursor: pointer"
|
||||||
@mousemove="showFileList = 1"
|
|
||||||
@mouseout="showFileList = 0"
|
|
||||||
>
|
>
|
||||||
上传
|
上传
|
||||||
</button>
|
</button>
|
||||||
@@ -71,8 +69,6 @@
|
|||||||
<div
|
<div
|
||||||
class="uploadDetail"
|
class="uploadDetail"
|
||||||
:style="{ display: showFileList ? 'block' : 'none' }"
|
:style="{ display: showFileList ? 'block' : 'none' }"
|
||||||
@mousemove="showFileList = 1"
|
|
||||||
@mouseout="showFileList = 0"
|
|
||||||
style="padding-top: 60px"
|
style="padding-top: 60px"
|
||||||
>
|
>
|
||||||
<div class="triangle"></div>
|
<div class="triangle"></div>
|
||||||
@@ -193,6 +189,9 @@
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
{{ value.workUploadContent }}
|
{{ value.workUploadContent }}
|
||||||
|
<span style="margin-left: 10px">
|
||||||
|
<el-link target="_blank" type="primary" :href="value.workUploadAddress?.split(',')[0] || ''">{{value.workUploadAddress?.split(',')[0].split('/').at(-1)|| ''}}</el-link>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -256,7 +255,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, toRefs } from "vue";
|
import {computed, reactive, ref, toRefs} from "vue";
|
||||||
import { request, useRequest } from "@/api/request";
|
import { request, useRequest } from "@/api/request";
|
||||||
import {
|
import {
|
||||||
TASK_WORK_COMMIT,
|
TASK_WORK_COMMIT,
|
||||||
@@ -272,7 +271,6 @@ import { useRoute } from "vue-router/dist/vue-router";
|
|||||||
|
|
||||||
const fileList = ref([]);
|
const fileList = ref([]);
|
||||||
const uploadRef = ref();
|
const uploadRef = ref();
|
||||||
const showFileList = ref(0);
|
|
||||||
const sbValue = ref({
|
const sbValue = ref({
|
||||||
content: "",
|
content: "",
|
||||||
attach: "",
|
attach: "",
|
||||||
@@ -290,9 +288,11 @@ const { data: submitList } = useRequest(TASK_WORK_SUBMIT_LIST, {
|
|||||||
workerId: workId,
|
workerId: workId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const showFileList = computed(()=>{
|
||||||
|
return fileList.value.length
|
||||||
|
})
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
console.log(sbValue.value);
|
|
||||||
console.log(fileList);
|
|
||||||
request(TASK_WORK_COMMIT, {
|
request(TASK_WORK_COMMIT, {
|
||||||
projectOrRouterLogo: type,
|
projectOrRouterLogo: type,
|
||||||
workUploadContent: sbValue.value.content,
|
workUploadContent: sbValue.value.content,
|
||||||
@@ -304,6 +304,7 @@ const handleClick = () => {
|
|||||||
submitList.value.unshift(res.data);
|
submitList.value.unshift(res.data);
|
||||||
});
|
});
|
||||||
sbValue.value.content = "";
|
sbValue.value.content = "";
|
||||||
|
fileList.value = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
function remove(i) {
|
function remove(i) {
|
||||||
@@ -452,8 +453,8 @@ function reUpload(i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.square {
|
.square {
|
||||||
width: 475px;
|
padding-bottom: 40px;
|
||||||
height: 243px;
|
width: 600px;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
box-shadow: 0px 1px 24px 0px rgba(0, 0, 0, 0.11);
|
box-shadow: 0px 1px 24px 0px rgba(0, 0, 0, 0.11);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
|||||||
Reference in New Issue
Block a user