上传图片采用素材管理

master
15386982806 2024-01-09 17:09:23 +08:00
parent 92b61a203f
commit c81eff58d3
1 changed files with 45 additions and 19 deletions

View File

@ -19,24 +19,24 @@
</div> </div>
</Poptip> </Poptip>
</Input> </Input>
<Button @click="handleCLickImg('storeLogo')"></Button>
<Upload <!--<Upload-->
:action="uploadFileUrl" <!--:action="uploadFileUrl"-->
:headers="accessToken" <!--:headers="accessToken"-->
:on-success="handleSuccess" <!--:on-success="handleSuccess"-->
:on-error="handleError" <!--:on-error="handleError"-->
:format="['jpg','jpeg','png','gif','bmp']" <!--:format="['jpg','jpeg','png','gif','bmp']"-->
accept=".jpg, .jpeg, .png, .gif, .bmp" <!--accept=".jpg, .jpeg, .png, .gif, .bmp"-->
:max-size="1024" <!--:max-size="1024"-->
:on-format-error="handleFormatError" <!--:on-format-error="handleFormatError"-->
:on-exceeded-size="handleMaxSize" <!--:on-exceeded-size="handleMaxSize"-->
:before-upload="beforeUpload" <!--:before-upload="beforeUpload"-->
:show-upload-list="false" <!--:show-upload-list="false"-->
ref="up" <!--ref="up"-->
class="upload" <!--class="upload"-->
> <!--&gt;-->
<Button :loading="loading" :size="size" :disabled="disabled">上传图片</Button> <!--<Button :loading="loading" :size="size" :disabled="disabled">上传图片</Button>-->
</Upload> <!--</Upload>-->
</div> </div>
<Modal title="图片预览" v-model="viewImage" :styles="{top: '30px'}" draggable> <Modal title="图片预览" v-model="viewImage" :styles="{top: '30px'}" draggable>
@ -45,13 +45,22 @@
<Button @click="viewImage=false"></Button> <Button @click="viewImage=false"></Button>
</div> </div>
</Modal> </Modal>
<Modal width="1200px" v-model="picModalFlag">
<ossManage @callback="callbackSelected" ref="ossManage" />
</Modal>
</div> </div>
</template> </template>
<script> <script>
import { uploadFile } from "@/api/index"; import { uploadFile } from "@/api/index";
import ossManage from "@/views/sys/oss-manage/ossManage";
export default { export default {
name: "uploadPicInput", name: "uploadPicInput",
components: {
ossManage,
},
props: { props: {
value: String, value: String,
size: { size: {
@ -86,10 +95,26 @@ export default {
currentValue: this.value, // currentValue: this.value, //
loading: false, // loading: false, //
viewImage: false, // modal viewImage: false, // modal
uploadFileUrl: uploadFile // uploadFileUrl: uploadFile, //
picModalFlag: false, //
selectedFormBtnName: "", // form
picIndex: "", // 便
}; };
}, },
methods: { methods: {
// modal
handleCLickImg(val, index) {
this.$refs.ossManage.selectImage = true;
this.picModalFlag = true;
this.selectedFormBtnName = val;
this.picIndex = index;
},
//
callbackSelected(val) {
this.picModalFlag = false;
this.currentValue = val.url;
this.picIndex = "";
},
// //
init() { init() {
this.accessToken = { this.accessToken = {
@ -125,6 +150,7 @@ export default {
this.loading = false; this.loading = false;
if (res.success) { if (res.success) {
this.currentValue = res.result; this.currentValue = res.result;
console.log('this.currentValue', this.currentValue);
this.$emit("input", this.currentValue); this.$emit("input", this.currentValue);
this.$emit("on-change", this.currentValue); this.$emit("on-change", this.currentValue);
} else { } else {