|
@@ -17,7 +17,28 @@
|
|
|
clearable
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="文件:" class="mandatory uploadFile" style="margin-left: 12px">
|
|
|
+ <el-form-item label="文件类别:" class="mandatory">
|
|
|
+ <el-select
|
|
|
+ style="width: 300px;"
|
|
|
+ v-model="caseFile.filesType"
|
|
|
+ placeholder="请选择文件类别"
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option label="本地上传" :value="1" />
|
|
|
+ <el-option label="媒体库上传" :value="0" />
|
|
|
+ </el-select>
|
|
|
+ <!-- <el-cascader
|
|
|
+ v-model="caseFile.filesTypeId"
|
|
|
+ :how-all-levels="false"
|
|
|
+ style="width: 300px;"
|
|
|
+ :options="fileOptions"
|
|
|
+ :props="{
|
|
|
+ checkStrictly: false,
|
|
|
+ }"
|
|
|
+ clearable
|
|
|
+ /> -->
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="文件:" v-if="caseFile.filesType == 1" class="mandatory uploadFile">
|
|
|
<el-upload
|
|
|
class="upload-demo"
|
|
|
:multiple="false"
|
|
@@ -46,15 +67,21 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-upload>
|
|
|
- <el-button style="margin-left: 20px" type="primary" class="mtk" @click="handleAdd"
|
|
|
- >从媒体库上传</el-button
|
|
|
- >
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="文件:" v-else class="mandatory uploadFile">
|
|
|
+ <el-button type="primary" class="mtk" @click="handleAdd"
|
|
|
+ >从媒体库上传</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ <div style="padding-left: 90px">
|
|
|
+ <viewImg :list="mtkList" edit @handleItem="handleItem"/>
|
|
|
+ </div>
|
|
|
</el-form>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { uploadNewFile, addByMediaLiBrary } from "@/store/case";
|
|
|
+import viewImg from "@/components/viewImg/index.vue"
|
|
|
import {
|
|
|
DrawFormatDesc,
|
|
|
DrawFormats,
|
|
@@ -75,9 +102,10 @@ const props = defineProps<{
|
|
|
caseId: number;
|
|
|
fileType: number;
|
|
|
filesTypeName: [string];
|
|
|
+ fileInfo?: Object;
|
|
|
}>();
|
|
|
const fileOptions = ref([])
|
|
|
-
|
|
|
+const mtkList = ref([]);
|
|
|
onMounted(async () => {
|
|
|
let newfileOptions = await updateSelectByTreeFileLists();
|
|
|
if(props.filesTypeName){
|
|
@@ -99,11 +127,12 @@ const caseFile = ref({
|
|
|
filesTitle: "",
|
|
|
dictId: '',
|
|
|
uploadId: '',
|
|
|
+ filesType: 1,
|
|
|
});
|
|
|
-
|
|
|
+console.log('caseFile', props.fileInfo);
|
|
|
const { size, fileList, upload, removeFile, previewFile, file, accept } = useUpload({
|
|
|
- maxSize: 10 * 1024 * 1024,
|
|
|
- formats: [".jpg", ".jpeg", ".png", '.mp4'],
|
|
|
+ maxSize: props.fileInfo?.fileSize || 10 * 1024 * 1024,
|
|
|
+ formats: props.fileInfo?.formats || [".jpg", ".jpeg", ".png", '.mp4'],
|
|
|
});
|
|
|
|
|
|
const formatDesc = computed(() =>
|
|
@@ -116,7 +145,17 @@ const handleSuccess = (option) => {
|
|
|
}
|
|
|
|
|
|
const handleAdd = async () => {
|
|
|
- await addCaseScenes();
|
|
|
+ let fileId = await addCaseScenes();
|
|
|
+ mtkList.value = fileId.map(ele => {
|
|
|
+ return {
|
|
|
+ filesUrl: ele.fileUrl,
|
|
|
+ ...ele,
|
|
|
+ }
|
|
|
+ }) || [];
|
|
|
+ console.log("handleItem", mtkList.value);
|
|
|
+};
|
|
|
+const handleItem = (type, item) => {
|
|
|
+ console.log("handleItem", type, item);
|
|
|
};
|
|
|
watchEffect(() => {
|
|
|
console.log('file', file.value);
|
|
@@ -128,7 +167,7 @@ watchEffect(() => {
|
|
|
defineExpose<QuiskExpose>({
|
|
|
async submit() {
|
|
|
console.log('filesTypeId', caseFile.value);
|
|
|
- if (!file.value) {
|
|
|
+ if (!file.value && mtkList.value.length == 0) {
|
|
|
ElMessage.error("请上传文件");
|
|
|
throw "请上传文件";
|
|
|
} else if (!caseFile.value.filesTypeId) {
|
|
@@ -136,8 +175,9 @@ defineExpose<QuiskExpose>({
|
|
|
throw "文件类别不能为空!";
|
|
|
}
|
|
|
let filesTypeId = caseFile.value.filesTypeId?.slice(-1),
|
|
|
- uploadId = file.value?.response?.data.id
|
|
|
- let params = { ...caseFile.value, file: file.value, filesTypeId: filesTypeId[0], uploadId };
|
|
|
+ uploadId = file.value?.response?.data.id,
|
|
|
+ uploadIds = mtkList.value.map(ele => ele.id) || [];
|
|
|
+ let params = { ...caseFile.value, file: file.value, filesTypeId: filesTypeId[0], uploadId, uploadIds };
|
|
|
console.log('filesTypeId', params);
|
|
|
await addByMediaLiBrary(params);
|
|
|
return caseFile.value;
|
|
@@ -164,10 +204,10 @@ defineExpose<QuiskExpose>({
|
|
|
}
|
|
|
}
|
|
|
.jm-file-upload {
|
|
|
- .mtk {
|
|
|
- position: absolute;
|
|
|
- right: 0;
|
|
|
- top: 0;
|
|
|
- }
|
|
|
+ // .mtk {
|
|
|
+ // position: absolute;
|
|
|
+ // right: 0;
|
|
|
+ // top: 0;
|
|
|
+ // }
|
|
|
}
|
|
|
</style>
|