Commit 5ce7025c authored by 周远喜's avatar 周远喜

ok

parent 3b288b5f
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
</div> </div>
</template> </template>
<script> <script>
import util from '@/libs/util';
export default { export default {
name: "files", name: "files",
model: { model: {
...@@ -185,7 +186,7 @@ export default { ...@@ -185,7 +186,7 @@ export default {
this.postUrl = this.postUrl =
fileUrl + fileUrl +
"/upload/?token=Bearer " + "/upload/?token=Bearer " +
window.sessionStorage.getItem("token") + util.cookies.get('token') +
"&" + "&" +
this.convertObj(this.parms); this.convertObj(this.parms);
//是否显示上传按钮 //是否显示上传按钮
......
<!--一次只能上传一个文件 --> <!--一次只能上传一个文件 -->
<template> <template>
<div> <div>
<Input v-model="newName" style="height:30px;width:240px;float:left" placeholder="请选择上传文件" disabled /> <Input v-model="newName" placeholder="请选择上传文件">
<Button v-if="view" icon="ios-eye" slot="prepend"> </Button>
<Button type="primary" icon="ios-cloud-upload-outline" slot="append" @click="handler">上传</Button>
</Input>
<Upload <Upload
v-model="name" v-model="name"
:action="postUrl" :action="postUrl"
...@@ -16,36 +19,37 @@ ...@@ -16,36 +19,37 @@
:files="files" :files="files"
:on-progress="onProgress" :on-progress="onProgress"
> >
<Button icon="ios-cloud-upload-outline">上传文件</Button> <Button v-show="1==2" type="primary" ref="upload">上传</Button>
</Upload> </Upload>
<Progress :percent="per" :stroke-width="5" v-show="vshowPro"/> <Progress :percent="per" :stroke-width="5" v-show="vshowPro" />
</div> </div>
</template> </template>
<script> <script>
import util from "@/libs/util";
export default { export default {
name: 'inputFile', name: "inputFile",
model: { model: {
prop: 'value', prop: "value",
event: 'on-change' event: "on-change"
}, },
data() { data() {
return { return {
file: null, file: null,
name: this.value, name: this.value,
downUrl: fileUrlDown, downUrl: fileUrlDown,
fileUrlPath: '', fileUrlPath: "",
nameList: [], nameList: [],
postUrl: postUrl:
fileUrl + fileUrl +
'/upload/?token=Bearer ' + "/upload/?token=Bearer " +
window.sessionStorage.getItem('token') + util.cookies.get("token") +
'&' + "&" +
this.parms, this.parms,
formatList: ['png', 'jpg', 'gif'], formatList: ["png", "jpg", "gif"],
newName: '', newName: "",
per: 0, per: 0,
vshowPro: false vshowPro: false
} };
}, },
created() {}, created() {},
props: { props: {
...@@ -60,55 +64,58 @@ export default { ...@@ -60,55 +64,58 @@ export default {
}, },
parms: { parms: {
type: String, type: String,
default: '' default: ""
} }
}, },
methods: { methods: {
onProgress(event, file, fileList) { onProgress(event, file, fileList) {
this.per = 0 this.per = 0;
this.vshowPro = true this.vshowPro = true;
},
handler() {
this.$refs.upload.$el.click();
}, },
// change(event) { // change(event) {
// this.$emit('on-change', event.target.value) // this.$emit('on-change', event.target.value)
// }, // },
//上传成功文件 //上传成功文件
uploadSuccess(response, file, fileList) { uploadSuccess(response, file, fileList) {
this.per = 60 this.per = 60;
this.vshowPro = true this.vshowPro = true;
const hbaseFileList = [] const hbaseFileList = [];
const filesList = [] const filesList = [];
if (file.response.status == 0) { if (file.response.status == 0) {
let objImag = {} let objImag = {};
objImag.fileName = file.response.data.fileName objImag.fileName = file.response.data.fileName;
objImag.filePath = file.response.data.downloadPath objImag.filePath = file.response.data.downloadPath;
filesList.push(objImag) filesList.push(objImag);
this.newName = file.response.data.fileName this.newName = file.response.data.downloadPath;
this.$emit('on-change', JSON.stringify(filesList)) this.$emit("on-change", JSON.stringify(filesList));
this.per = 100 this.per = 100;
setTimeout(() => { setTimeout(() => {
this.per = 0 this.per = 0;
this.vshowPro = false this.vshowPro = false;
}, 2000) }, 2000);
} else { } else {
this.$Message.error('上传失败,请重新上传!') this.$Message.error("上传失败,请重新上传!");
} }
}, },
//上传文件失败 //上传文件失败
uploadError(response, file, fileList) { uploadError(response, file, fileList) {
this.$Message.error('上传失败,请重新上传!') this.$Message.error("上传失败,请重新上传!");
}, },
//文件大小验证返回 //文件大小验证返回
onExceededSize(file, fileList) { onExceededSize(file, fileList) {
if (Object.keys(file).length == 0) { if (Object.keys(file).length == 0) {
this.$Message.error( this.$Message.error(
'上传文件不能大于' + this.maxSize + 'k,请重新上传!' "上传文件不能大于" + this.maxSize + "k,请重新上传!"
) );
} }
}, },
//文件格式验证 //文件格式验证
onFormatError(file, fileList) { onFormatError(file, fileList) {
if (Object.keys(file).length == 0) { if (Object.keys(file).length == 0) {
this.$Message.error('上传文件格式不正确,请重新上传!') this.$Message.error("上传文件格式不正确,请重新上传!");
} }
}, },
//删除上传 //删除上传
...@@ -116,36 +123,39 @@ export default { ...@@ -116,36 +123,39 @@ export default {
formatL() { formatL() {
if (this.files) { if (this.files) {
this.formatList = [ this.formatList = [
'pdf', "pdf",
'docx', "docx",
'doc', "doc",
'xls', "xls",
'xlsx', "xlsx",
'txt', "txt",
'png', "png",
'jpg', "jpg",
'gif', "gif",
'zip', "zip",
'rar' "rar"
] ];
} }
return this.formatList return this.formatList;
} }
}, },
mounted() { mounted() {
this.formatL() this.formatL();
}, },
computed: { computed: {
nativeInputValue() { nativeInputValue() {
return this.value === null || this.value === undefined ? '' : this.value return this.value === null || this.value === undefined ? "" : this.value;
},
view(){
return true
} }
}, },
watch: { watch: {
value(v) { value(v) {
this.name = v this.name = v;
} }
} }
} };
</script> </script>
<style lang="less"> <style lang="less">
</style> </style>
\ No newline at end of file
...@@ -112,7 +112,8 @@ ...@@ -112,7 +112,8 @@
</Col> </Col>
<Col :span="24"> <Col :span="24">
<FormItem :label="l('qualityTemplateName')" prop="qualityTemplateName"> <FormItem :label="l('qualityTemplateName')" prop="qualityTemplateName">
<files ref="refFile" :parms="parms" files singleFile /> <!-- <files ref="refFile" :parms="parms" files singleFile /> -->
<InputFile v-model="entity.qualityTemplateName"/>
</FormItem> </FormItem>
</Col> </Col>
<!-- <!--
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<Input <Input
placeholder="请输入检测要求/标准指标" placeholder="请输入检测要求/标准指标"
v-model="easySearch.keys.value" v-model="easySearch.keys.value"
v-width="200"
/> />
</FormItem> </FormItem>
<FormItem> <FormItem>
......
...@@ -32,7 +32,7 @@ import clipboard from 'clipboard'; ...@@ -32,7 +32,7 @@ import clipboard from 'clipboard';
import radioButton from '@/components/page/radioButton.vue' import radioButton from '@/components/page/radioButton.vue'
import InputIcon from '@/components/page/inputIcon.vue' import InputIcon from '@/components/page/inputIcon.vue'
import checkBoxButton from '@/components/page/checkBoxButton.vue' import checkBoxButton from '@/components/page/checkBoxButton.vue'
import inputFile from '@/components/page/inputFile.vue' import InputFile from '@/components/page/inputFile.vue'
import imgUploadFile from '@/components/page/imgUploadFile.vue' import imgUploadFile from '@/components/page/imgUploadFile.vue'
import files from '@/components/page/files.vue' import files from '@/components/page/files.vue'
import FilesList from '@/components/page/filesList.vue' import FilesList from '@/components/page/filesList.vue'
...@@ -74,7 +74,7 @@ Vue.component("State", State) ...@@ -74,7 +74,7 @@ Vue.component("State", State)
Vue.component("Dictionary", Dictionary) Vue.component("Dictionary", Dictionary)
Vue.component("radioButton", radioButton) Vue.component("radioButton", radioButton)
Vue.component("checkBoxButton", checkBoxButton) Vue.component("checkBoxButton", checkBoxButton)
Vue.component("inputFile", inputFile) Vue.component("InputFile", InputFile)
Vue.component("imgUploadFile", imgUploadFile) Vue.component("imgUploadFile", imgUploadFile)
Vue.component("InputIcon", InputIcon) Vue.component("InputIcon", InputIcon)
Vue.component("files", files) Vue.component("files", files)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment