Commit 65e404ec6e42f30b9f3280cf2b3a23cc42a27856

Authored by 杨泽宇
1 parent a561a5a8

debug

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