FeiXianChengGuanHouTaiGuanLi/public/ueditor/formdesign/el-input.html

84 lines
2.5 KiB
HTML
Raw Permalink Normal View History

2023-09-28 14:12:42 +08:00
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- import CSS -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
<el-form ref="form" label-width="80px" size="mini">
<el-form-item :label="title">
<el-upload class="upload-demo" :action="baseURL +'/Files/Upload'" :on-success="handleSucess"
:file-list="fileList" :on-remove="handleRemove" name="files">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>
</el-upload>
</el-form-item>
</el-form>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
var GetQueryString = function(name) {
var search = decodeURI(decodeURI(window.location.search))
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
var r = search.substr(1).match(reg)
if (r != null) return unescape(r[2])
return null
}
// eslint-disable-next-line no-undef
var appVue = new Vue({
el: '#app',
data: {
baseURL: 'http://119.84.146.233:52789/api', // api的base_url
fileList: [],
title: ''
},
created() {
var info = GetQueryString('info')
if (info && info.length > 0) {
var infoObj = JSON.parse(info)
if (infoObj && infoObj.gValue != '') {
this.title = infoObj.gValue
}
}
},
methods: {
getInfo() {
return this.fileList
},
handleSucess(response, file, fileList) {
console.log(response)
console.log(file)
if (response.code == 200) {
if (response.result.length > 0) {
this.fileList.push({
name: response.result[0].fileName,
url: 'http://119.84.146.233:52789/' + response.result[0].filePath
})
}
}
},
handleRemove(file, fileList) {
var indexOf = fileList.indexOf(file)
this.fileList.split(indexOf, 1)
}
}
})
// eslint-disable-next-line no-unused-vars
var getData = function() {
return appVue.fileList
}
</script>
</html>