|
@@ -1,17 +1,32 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <BasicUpload
|
|
|
- :urls="imageUrls"
|
|
|
- :tip="tip"
|
|
|
- :showChooseBtn="true"
|
|
|
- :maxSize="20"
|
|
|
- :maxNumber="10"
|
|
|
- @change="handleChange"
|
|
|
- @openChooseModal="openChooseModal"
|
|
|
- @onInputChange="inputChange"
|
|
|
- :api="uploadApi"
|
|
|
- class="my-3"
|
|
|
- />
|
|
|
+ <div style="display: flex">
|
|
|
+ <Input
|
|
|
+ class="upload-input"
|
|
|
+ :value="imageUrls"
|
|
|
+ @focus="onFocus"
|
|
|
+ @change="onInputChange"
|
|
|
+ @blur="onBlur"
|
|
|
+ />
|
|
|
+ <BasicUpload
|
|
|
+ :maxSize="20"
|
|
|
+ :maxNumber="10"
|
|
|
+ @change="handleChange"
|
|
|
+ :api="uploadApi"
|
|
|
+ class="my-3"
|
|
|
+ />
|
|
|
+ <a-button
|
|
|
+ @click="openChooseModal"
|
|
|
+ style="position: relative; top: 12px; margin: 0 5px"
|
|
|
+ type="danger"
|
|
|
+ preIcon="ic:sharp-view-list"
|
|
|
+ :iconSize="16"
|
|
|
+ >
|
|
|
+ 选择
|
|
|
+ </a-button>
|
|
|
+ <span class="tip-span" v-if="tipShow">{{ tip }}</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
<div class="image-list" v-if="image_list">
|
|
|
<div v-for="(item, index) in image_list" :key="index">
|
|
|
<div class="image-item" v-if="imageUrls.split(',').includes(item.url)">
|
|
@@ -37,8 +52,9 @@
|
|
|
import { uploadApi } from '/@/api/sys/upload';
|
|
|
import ChooseModal from './ChooseModal.vue';
|
|
|
import { useModal } from '/@/components/Modal';
|
|
|
- import { Image } from 'ant-design-vue';
|
|
|
+ import { Image, Input } from 'ant-design-vue';
|
|
|
import Icon from '/@/components/Icon';
|
|
|
+ import { getAttachmentList } from '/@/api/sys/general';
|
|
|
|
|
|
const props = {
|
|
|
value: { type: String, default: '' },
|
|
@@ -49,7 +65,7 @@
|
|
|
rules: { type: Array, default: [] },
|
|
|
};
|
|
|
export default defineComponent({
|
|
|
- components: { BasicUpload, ChooseModal, aImage: Image, Icon },
|
|
|
+ components: { BasicUpload, ChooseModal, aImage: Image, Input, Icon },
|
|
|
props,
|
|
|
emits: ['change'],
|
|
|
setup(props, { emit }) {
|
|
@@ -60,32 +76,8 @@
|
|
|
}
|
|
|
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',
|
|
|
- },
|
|
|
- ],
|
|
|
+ image_list: [] as object[],
|
|
|
+ tipShow: false,
|
|
|
});
|
|
|
|
|
|
function deleteImage(url) {
|
|
@@ -95,7 +87,6 @@
|
|
|
1
|
|
|
);
|
|
|
state.imageUrls = arr.toString();
|
|
|
- console.log(`state.imageUrls`, state.imageUrls);
|
|
|
}
|
|
|
function checked(key, closeModal) {
|
|
|
console.log(`key`, key);
|
|
@@ -109,19 +100,34 @@
|
|
|
console.log('========checkedBatches========');
|
|
|
emit('change');
|
|
|
}
|
|
|
- function inputChange(val) {
|
|
|
- state.imageUrls = val;
|
|
|
+ function onInputChange(e) {
|
|
|
+ state.imageUrls = e.target.value;
|
|
|
+ }
|
|
|
+ function onFocus() {
|
|
|
+ state.tipShow = true;
|
|
|
+ }
|
|
|
+ function onBlur() {
|
|
|
+ state.tipShow = false;
|
|
|
+ }
|
|
|
+ getImageList();
|
|
|
+ async function getImageList() {
|
|
|
+ await getAttachmentList().then((res) => {
|
|
|
+ state.image_list = res.rows;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
handleChange: (list: string[]) => {
|
|
|
+ console.log(`list`, list);
|
|
|
createMessage.info(`已上传文件${JSON.stringify(list)}`);
|
|
|
},
|
|
|
checkedBatches,
|
|
|
checked,
|
|
|
openChooseModal,
|
|
|
deleteImage,
|
|
|
- inputChange,
|
|
|
+ onInputChange,
|
|
|
+ onFocus,
|
|
|
+ onBlur,
|
|
|
uploadApi,
|
|
|
chooseModalRegister,
|
|
|
openModal,
|
|
@@ -132,6 +138,14 @@
|
|
|
});
|
|
|
</script>
|
|
|
<style scoped>
|
|
|
+ .upload-input {
|
|
|
+ position: relative;
|
|
|
+ top: 11px;
|
|
|
+ width: 45%;
|
|
|
+ height: 34px;
|
|
|
+ margin-right: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
.image-list {
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|
|
@@ -161,4 +175,12 @@
|
|
|
background: #e74c3c;
|
|
|
border-radius: 2px;
|
|
|
}
|
|
|
+
|
|
|
+ .tip-span {
|
|
|
+ position: relative;
|
|
|
+ top: 11px;
|
|
|
+ font-size: 13px;
|
|
|
+ line-height: 250%;
|
|
|
+ color: gray;
|
|
|
+ }
|
|
|
</style>
|