Browse Source

文件回显

master
zhang_li 9 months ago
parent
commit
87a6d28214
  1. 2
      src/components/BasicForm/src/BasicForm.vue
  2. 1
      src/components/Detail/src/DetailDeviceLedger.vue
  3. 20
      src/components/UploadFile/src/UploadFile.vue
  4. 7
      src/views/eam/device/problemSolving/index.vue
  5. 3
      src/views/eam/device/problemSolving/problemSolving.data.ts

2
src/components/BasicForm/src/BasicForm.vue

@ -380,8 +380,10 @@ const open = async (type: string, row?: any, masterParmas?: any) => {
formLoading.value = true formLoading.value = true
try { try {
nextTick(() => { nextTick(() => {
console.log('row11',row)
formRef.value.setValues(row) formRef.value.setValues(row)
}) })
} finally { } finally {
formLoading.value = false formLoading.value = false
} }

1
src/components/Detail/src/DetailDeviceLedger.vue

@ -594,6 +594,7 @@ const getImage = () => {
if (imageParmas.value.funcCode == 'device_mould_picture') { if (imageParmas.value.funcCode == 'device_mould_picture') {
imageFormData.value.filePathList = res imageFormData.value.filePathList = res
} else { } else {
console.log(444,res)
fileFormData.value.filePathList = res fileFormData.value.filePathList = res
formKey.value += 1 formKey.value += 1
} }

20
src/components/UploadFile/src/UploadFile.vue

@ -6,7 +6,7 @@
name="file" name="file"
v-model="valueRef" v-model="valueRef"
v-model:file-list="fileList" v-model:file-list="fileList"
:show-file-list="true" :show-file-list="isShowFileList"
:auto-upload="autoUpload" :auto-upload="autoUpload"
:action="updateUrl" :action="updateUrl"
:headers="uploadHeaders" :headers="uploadHeaders"
@ -28,6 +28,7 @@
<div style="font-size: 8px;line-height: initial;"> <div style="font-size: 8px;line-height: initial;">
格式为 <b style="color: #f56c6c">{{ fileType.join('/') }}</b> 的文件 格式为 <b style="color: #f56c6c">{{ fileType.join('/') }}</b> 的文件
</div> </div>
<Preview1 :fileList="fileList" v-if="!isShowFile"/>
</template> </template>
<template v-if="!isShowFile" #file > <template v-if="!isShowFile" #file >
<div> <div>
@ -42,6 +43,7 @@ import { PropType } from 'vue'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { getAccessToken, getTenantId } from '@/utils/auth' import { getAccessToken, getTenantId } from '@/utils/auth'
import type { UploadInstance, UploadUserFile, UploadProps, UploadRawFile } from 'element-plus' import type { UploadInstance, UploadUserFile, UploadProps, UploadRawFile } from 'element-plus'
import Preview1 from '@/components/UploadFile/src/Preview.vue'
defineOptions({ name: 'UploadFile' }) defineOptions({ name: 'UploadFile' })
@ -63,19 +65,25 @@ const props = defineProps({
drag: propTypes.bool.def(false), // drag: propTypes.bool.def(false), //
isShowTip: propTypes.bool.def(true), // isShowTip: propTypes.bool.def(true), //
isShowFile: propTypes.bool.def(true), // isShowFile: propTypes.bool.def(true), //
// isShowFileList: propTypes.bool.def(true), //
}) })
// ========== ========== // ========== ==========
// setTimeout(()=>{
// console.log('props.modelValue',props.modelValue)
// },2000)
const valueRef = ref(props.modelValue) const valueRef = ref(props.modelValue)
const uploadRef = ref<UploadInstance>() const uploadRef = ref<UploadInstance>()
const uploadList = ref<UploadUserFile[]>([]) const uploadList = ref<UploadUserFile[]>([])
console.log('88',props.modelValue)
const fileList = props.modelValue && props.modelValue.length > 0 ? ref<UploadUserFile[]>(props.modelValue) : ref<UploadUserFile[]>([]) const fileList = props.modelValue && props.modelValue.length > 0 ? ref<UploadUserFile[]>(props.modelValue) : ref<UploadUserFile[]>([])
const uploadNumber = ref<number>(0) const uploadNumber = ref<number>(0)
const uploadHeaders = ref({ const uploadHeaders = ref({
Authorization: 'Bearer ' + getAccessToken(), Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId() 'tenant-id': getTenantId()
}) })
// //
const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => { const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => {
if (fileList.value.length >= props.limit) { if (fileList.value.length >= props.limit) {
@ -149,6 +157,14 @@ const listToString = (list: UploadUserFile[], separator?: string) => {
} }
return strs != '' ? strs.substr(0, strs.length - 1) : '' return strs != '' ? strs.substr(0, strs.length - 1) : ''
} }
watch(
() => props.modelValue,
(val) => {
// if (val === unref(colorVal)) return
valueRef.value = val
fileList.value = val && val.length > 0 ?val:[]
}
)
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.upload-file-uploader { .upload-file-uploader {

7
src/views/eam/device/problemSolving/index.vue

@ -126,6 +126,13 @@
/** 添加/修改操作 */ /** 添加/修改操作 */
const basicFormRef = ref() const basicFormRef = ref()
const openForm = (type : string, row ?: any) => { const openForm = (type : string, row ?: any) => {
// console.log(99,row)
row.filePathListView = row.filePathList.map(item=>{
return {
name:item,
url:item
}
})
basicFormRef.value.open(type, row) basicFormRef.value.open(type, row)
} }

3
src/views/eam/device/problemSolving/problemSolving.data.ts

@ -45,7 +45,6 @@ export const ProblemSolving = useCrudSchemas(reactive<CrudSchema[]>([
form: { form: {
component: 'UploadFile', component: 'UploadFile',
componentProps: { componentProps: {
} }
} }
}, },
@ -60,7 +59,7 @@ export const ProblemSolving = useCrudSchemas(reactive<CrudSchema[]>([
form: { form: {
component: 'UploadFile', component: 'UploadFile',
componentProps: { componentProps: {
} }
} }
}, },

Loading…
Cancel
Save