|
@@ -1,20 +1,24 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<BasicUpload
|
|
|
+ :urls="imageUrls"
|
|
|
:tip="tip"
|
|
|
:showChooseBtn="true"
|
|
|
:maxSize="20"
|
|
|
:maxNumber="10"
|
|
|
@change="handleChange"
|
|
|
@openChooseModal="openChooseModal"
|
|
|
+ @onInputChange="inputChange"
|
|
|
:api="uploadApi"
|
|
|
- class="my-5"
|
|
|
+ class="my-3"
|
|
|
/>
|
|
|
<div class="image-list" v-if="image_list">
|
|
|
- <div class="image-item" v-for="(item, index) in image_list" :key="index">
|
|
|
- <div class="image-wrap"> <a-image width="70px" :src="item" /></div>
|
|
|
- <div class="dele-image" @click="deleteImage">
|
|
|
- <Icon icon="ri:delete-bin-5-fill" />
|
|
|
+ <div v-for="(item, index) in image_list" :key="index">
|
|
|
+ <div class="image-item" v-if="imageUrls.split(',').includes(item.url)">
|
|
|
+ <div class="image-wrap"> <a-image width="70px" :src="item.preUrl" /></div>
|
|
|
+ <div class="dele-image" @click="deleteImage(item.url)">
|
|
|
+ <Icon icon="ri:delete-bin-5-fill" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -27,7 +31,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
- import { defineComponent, toRefs } from 'vue';
|
|
|
+ import { defineComponent, reactive, toRefs } from 'vue';
|
|
|
import { BasicUpload } from '/@/components/Upload';
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
import { uploadApi } from '/@/api/sys/upload';
|
|
@@ -39,6 +43,7 @@
|
|
|
const props = {
|
|
|
value: { type: String, default: '' },
|
|
|
tip: { type: String, default: '' },
|
|
|
+ urls: { type: String, default: '' },
|
|
|
type: { type: String, default: '' },
|
|
|
errMsg: { type: String, default: '' },
|
|
|
rules: { type: Array, default: [] },
|
|
@@ -53,9 +58,44 @@
|
|
|
function openChooseModal() {
|
|
|
openModal(true);
|
|
|
}
|
|
|
+ const state = reactive({
|
|
|
+ imageUrls: props.urls,
|
|
|
+ image_list: [
|
|
|
+ {
|
|
|
+ url: '/fake/fake.jpg',
|
|
|
+ preUrl: 'http://jetbill.cn/uploads/20210713/a05d360766d30868cdb878b4c0aac77d.jpg',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ url: '/fake1/fake1.jpg',
|
|
|
+ preUrl: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ url: '/fake2/fake2.jpg',
|
|
|
+ preUrl: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ url: '/fake3/fake3.jpg',
|
|
|
+ preUrl: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ url: '/fake4/fake4.jpg',
|
|
|
+ preUrl: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ url: '/fake5/fake5.jpg',
|
|
|
+ preUrl: 'http://jetbill.cn/uploads/20210713/a05d360766d30868cdb878b4c0aac77d.jpg',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
|
|
|
- function deleteImage() {
|
|
|
- console.log('========deleteImage========');
|
|
|
+ function deleteImage(url) {
|
|
|
+ const arr = state.imageUrls.split(',');
|
|
|
+ arr.splice(
|
|
|
+ arr.findIndex((item) => item === url),
|
|
|
+ 1
|
|
|
+ );
|
|
|
+ state.imageUrls = arr.toString();
|
|
|
+ console.log(`state.imageUrls`, state.imageUrls);
|
|
|
}
|
|
|
function checked(key, closeModal) {
|
|
|
console.log(`key`, key);
|
|
@@ -69,13 +109,11 @@
|
|
|
console.log('========checkedBatches========');
|
|
|
emit('change');
|
|
|
}
|
|
|
- const image_list = [
|
|
|
- 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
- 'http://jetbill.cn/uploads/20210713/a05d360766d30868cdb878b4c0aac77d.jpg',
|
|
|
- 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
- ];
|
|
|
+ function inputChange(val) {
|
|
|
+ state.imageUrls = val;
|
|
|
+ }
|
|
|
+
|
|
|
return {
|
|
|
- image_list,
|
|
|
handleChange: (list: string[]) => {
|
|
|
createMessage.info(`已上传文件${JSON.stringify(list)}`);
|
|
|
},
|
|
@@ -83,10 +121,12 @@
|
|
|
checked,
|
|
|
openChooseModal,
|
|
|
deleteImage,
|
|
|
+ inputChange,
|
|
|
uploadApi,
|
|
|
chooseModalRegister,
|
|
|
openModal,
|
|
|
...toRefs(props),
|
|
|
+ ...toRefs(state),
|
|
|
};
|
|
|
},
|
|
|
});
|
|
@@ -95,7 +135,7 @@
|
|
|
.image-list {
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|
|
|
- width: 65%;
|
|
|
+ width: 70%;
|
|
|
}
|
|
|
|
|
|
.image-item {
|