Commit 65e404ec6e42f30b9f3280cf2b3a23cc42a27856

Authored by 杨泽宇
1 parent a561a5a8

debug

src/components/Photowall/index.vue
@@ -21,6 +21,7 @@ import type { @@ -21,6 +21,7 @@ import type {
21 * @prop {array} fileList 默认显示的图片 21 * @prop {array} fileList 默认显示的图片
22 * @prop {array<string>} formats 允许上传的图片格式 22 * @prop {array<string>} formats 允许上传的图片格式
23 * @prop {number | null} maxSize 允许上传的最大图片尺寸 default = 1 means 1MB 23 * @prop {number | null} maxSize 允许上传的最大图片尺寸 default = 1 means 1MB
  24 + * @prop {boolean} r 是否只读(用来判断+按钮是否显示)
24 */ 25 */
25 interface Props { 26 interface Props {
26 tagName?: string; 27 tagName?: string;
@@ -30,12 +31,14 @@ interface Props { @@ -30,12 +31,14 @@ interface Props {
30 formats?: string[]; 31 formats?: string[];
31 tip?: string; 32 tip?: string;
32 fileList?: string[]; 33 fileList?: string[];
  34 + r?: boolean;
33 } 35 }
34 const props = withDefaults(defineProps<Props>(), { 36 const props = withDefaults(defineProps<Props>(), {
35 tagName: "", 37 tagName: "",
36 moduleName: "test", 38 moduleName: "test",
37 limit: 9, 39 limit: 9,
38 maxSize: 1, 40 maxSize: 1,
  41 + r: false,
39 fileList: () => [], 42 fileList: () => [],
40 formats: () => [ 43 formats: () => [
41 "image/jpeg", 44 "image/jpeg",
@@ -104,10 +107,10 @@ const handleAvatarSuccess = ( @@ -104,10 +107,10 @@ const handleAvatarSuccess = (
104 file: ElFile, 107 file: ElFile,
105 fileList: ElFile[] 108 fileList: ElFile[]
106 ) => { 109 ) => {
107 - console.log(fileList) 110 + console.log(fileList);
108 emit( 111 emit(
109 "finish", 112 "finish",
110 - fileList.map((item) => item.response? item.response.data: item.url), 113 + fileList.map((item) => (item.response ? item.response.data : item.url)),
111 props.tagName 114 props.tagName
112 ); 115 );
113 }; 116 };
@@ -120,7 +123,7 @@ const handleAvatarSuccess = ( @@ -120,7 +123,7 @@ const handleAvatarSuccess = (
120 const handleRemove = (file: ElFile, fileList: ElFile[]) => { 123 const handleRemove = (file: ElFile, fileList: ElFile[]) => {
121 emit( 124 emit(
122 "finish", 125 "finish",
123 - fileList.map((item) => item.response? item.response.data: item.url), 126 + fileList.map((item) => (item.response ? item.response.data : item.url)),
124 props.tagName 127 props.tagName
125 ); 128 );
126 }; 129 };
@@ -143,10 +146,11 @@ const emit = defineEmits&lt;{ @@ -143,10 +146,11 @@ const emit = defineEmits&lt;{
143 :on-success="handleAvatarSuccess" 146 :on-success="handleAvatarSuccess"
144 :on-remove="handleRemove" 147 :on-remove="handleRemove"
145 :before-upload="beforeAvatarUpload" 148 :before-upload="beforeAvatarUpload"
  149 + :class="props.r ? 'photo-wall' : ''"
146 > 150 >
147 <el-icon><plus /></el-icon> 151 <el-icon><plus /></el-icon>
148 </el-upload> 152 </el-upload>
149 - <div class="tip">{{ props.tip }}</div> 153 + <div class="tip">{{ props.tip }} {{ props.r }}</div>
150 <el-dialog v-model="dialogVisible" title="图片预览"> 154 <el-dialog v-model="dialogVisible" title="图片预览">
151 <div style="text-align: center"> 155 <div style="text-align: center">
152 <el-image 156 <el-image
@@ -157,3 +161,12 @@ const emit = defineEmits&lt;{ @@ -157,3 +161,12 @@ const emit = defineEmits&lt;{
157 </div> 161 </div>
158 </el-dialog> 162 </el-dialog>
159 </template> 163 </template>
  164 +
  165 +<style lang="scss">
  166 +// 开启只读属性,不显示+按钮
  167 +.photo-wall {
  168 + .el-upload--picture-card {
  169 + display: none;
  170 + }
  171 +}
  172 +</style>
src/views/repair/edit.vue
@@ -306,6 +306,7 @@ onMounted(() =&gt; { @@ -306,6 +306,7 @@ onMounted(() =&gt; {
306 @finish="handleFinish" 306 @finish="handleFinish"
307 moduleName="repair" 307 moduleName="repair"
308 :limit="3" 308 :limit="3"
  309 + :r="form.dataType === 'edit'"
309 tip="最多可以上传3张图片,单张图片大小不可超过1MB" 310 tip="最多可以上传3张图片,单张图片大小不可超过1MB"
310 :fileList="form.publicityPic" 311 :fileList="form.publicityPic"
311 ></Photowall> 312 ></Photowall>