Authored by 鲁尚清

【业务视图】业务视图下展示文档列表上传带有空格的.txt文件用户带来预览乱码,文件上传更改为单文件上传

@@ -598,7 +598,7 @@ export default { @@ -598,7 +598,7 @@ export default {
598 // proxy.$global.showMsg("请输入关键字!", "warning") 598 // proxy.$global.showMsg("请输入关键字!", "warning")
599 // return; 599 // return;
600 // } 600 // }
601 - getPage(''); 601 + getPage(props.viewTypeId);
602 602
603 } 603 }
604 604
1 <cm-dialog v-if="!isInset" title="文件上传" width="500px" :showDialogVisible="show" @hidedialog="hidedialog" @okfunc="uploadFile" okText="上传"> 1 <cm-dialog v-if="!isInset" title="文件上传" width="500px" :showDialogVisible="show" @hidedialog="hidedialog" @okfunc="uploadFile" okText="上传">
2 <template v-slot> 2 <template v-slot>
3 - 3 + <!-- //start lsq 文件上传更换为单文件通过multiple值判断,:on-change="handleChange",:file-list="fileListNow" 2022-03-30-->
4 <el-upload 4 <el-upload
5 :accept="accept" 5 :accept="accept"
6 ref="upload" 6 ref="upload"
7 :http-request="getFile" 7 :http-request="getFile"
8 - :multiple="true" 8 + :multiple="multiple"
9 :before-upload="beforeUpload" 9 :before-upload="beforeUpload"
  10 + :on-change="handleChange"
  11 + :file-list="fileListNow"
10 :auto-upload="false"> 12 :auto-upload="false">
11 <template #trigger> 13 <template #trigger>
12 <el-button size="small" type="primary">{{btnText}}</el-button> 14 <el-button size="small" type="primary">{{btnText}}</el-button>
@@ -25,6 +27,7 @@ @@ -25,6 +27,7 @@
25 </template> 27 </template>
26 </el-upload> 28 </el-upload>
27 <div class="text-tip" style="position: absolute;bottom:30px;left: 20px;color:#f78989"> 29 <div class="text-tip" style="position: absolute;bottom:30px;left: 20px;color:#f78989">
  30 + <span v-if="!multiple">单文件上传,</span>
28 文件上传大小限制200M 31 文件上传大小限制200M
29 </div> 32 </div>
30 </template> 33 </template>
@@ -46,6 +46,11 @@ export default { @@ -46,6 +46,11 @@ export default {
46 type: String, 46 type: String,
47 default: '' 47 default: ''
48 }, 48 },
  49 + //lsq 是否为多文件上传 2022-03-30
  50 + multiple:{
  51 + type: Boolean,
  52 + default: false
  53 + },
49 accept: { 54 accept: {
50 type: String, 55 type: String,
51 default: [".3gpp", 56 default: [".3gpp",
@@ -147,6 +152,17 @@ export default { @@ -147,6 +152,17 @@ export default {
147 } 152 }
148 153
149 } 154 }
  155 + //start lsq 单文件上传时 新文件覆盖旧文件 2022-03-30
  156 + let fileListNow=props.fileList?Vue.ref(props.fileList):Vue.ref([]);
  157 + let handleChange=(file, fileList)=> {
  158 + if(!props.multiple){
  159 + if (fileList.length > 0) {
  160 + fileListNow.value= [fileList[fileList.length - 1]] // 这一步,是 展示最后一次选择的文件
  161 + }
  162 + }
  163 +
  164 + }
  165 + //end lsq 2022-03-30
150 166
151 let fileChange = (file, fileList) =>{ 167 let fileChange = (file, fileList) =>{
152 console.log(file, fileList); 168 console.log(file, fileList);
@@ -166,7 +182,6 @@ export default { @@ -166,7 +182,6 @@ export default {
166 let fileObj = param.file 182 let fileObj = param.file
167 emit('callback',fileObj) 183 emit('callback',fileObj)
168 } 184 }
169 -  
170 // 监听编辑状态 185 // 监听编辑状态
171 Vue.watch( 186 Vue.watch(
172 () => props.showDialogVisible, (newValue, oldVlaue) => { 187 () => props.showDialogVisible, (newValue, oldVlaue) => {
@@ -189,7 +204,9 @@ export default { @@ -189,7 +204,9 @@ export default {
189 uploadFile, 204 uploadFile,
190 hidedialog, 205 hidedialog,
191 beforeUpload, 206 beforeUpload,
192 - fileChange 207 + fileChange,
  208 + handleChange,
  209 + fileListNow
193 } 210 }
194 } 211 }
195 } 212 }