Commit 9342746e authored by renjintao's avatar renjintao

单文件上传

parent 6428865d
<!--一次只能上传一个文件 --> <!--一次只能上传一个文件 -->
<template> <template>
<div> <div>
<Input v-model="newName" style="height:30px;width:240px;float:left" placeholder="请选择上传文件" disabled /> <div>
<Input
v-model="newName"
style="height:30px;width:240px;float:left;"
placeholder="请选择上传文件"
disabled
/>
<Upload <Upload
v-model="name" v-model="name"
:action="postUrl" :action="postUrl"
...@@ -15,37 +21,41 @@ ...@@ -15,37 +21,41 @@
:show-upload-list="false" :show-upload-list="false"
:files="files" :files="files"
:on-progress="onProgress" :on-progress="onProgress"
style="width:120px;float:left"
> >
<Button icon="ios-cloud-upload-outline">上传文件</Button> <Button icon="ios-cloud-upload-outline">上传文件</Button>
</Upload> </Upload>
<Progress :percent="per" :stroke-width="5" v-show="vshowPro"/> <a v-show="newName.length>2&&showButton" :href="fileUrlPath" @click="downFile(newPath)" target="_blank" style="float:left">查看</a>
</div>
<Progress :percent="per" :stroke-width="5" v-show="vshowPro" />
</div> </div>
</template> </template>
<script> <script>
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') + window.sessionStorage.getItem("token") +
'&' + "&" +
this.parms, this.parms,
formatList: ['png', 'jpg', 'gif'], formatList: ["png", "jpg", "gif"],
newName: '', newName: "",
newPath:'',
per: 0, per: 0,
vshowPro: false vshowPro: false
} };
}, },
created() {}, created() {},
props: { props: {
...@@ -60,55 +70,60 @@ export default { ...@@ -60,55 +70,60 @@ export default {
}, },
parms: { parms: {
type: String, type: String,
default: '' default: ""
},
showButton:{
type:Boolean,
default:true,
} }
}, },
methods: { methods: {
onProgress(event, file, fileList) { onProgress(event, file, fileList) {
this.per = 0 this.per = 0;
this.vshowPro = true this.vshowPro = true;
}, },
// 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.fileName;
this.$emit('on-change', JSON.stringify(filesList)) this.newPath=file.response.data.downloadPath
this.per = 100 this.$emit("on-change", JSON.stringify(filesList));
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 +131,40 @@ export default { ...@@ -116,36 +131,40 @@ 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;
},
downFile(path) {
this.fileUrlPath = this.downUrl + path;
},
}, },
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;
} }
}, },
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
...@@ -9558,7 +9558,8 @@ ...@@ -9558,7 +9558,8 @@
"dependencies": { "dependencies": {
"deepmerge": { "deepmerge": {
"version": "2.2.1", "version": "2.2.1",
"resolved": false "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz",
"integrity": "sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA=="
} }
} }
}, },
......
...@@ -5,7 +5,12 @@ ...@@ -5,7 +5,12 @@
<div style="height:415px;"> <div style="height:415px;">
<p style="text-align:center;padding-top:100px;"> <p style="text-align:center;padding-top:100px;">
<Avatar :src="avatorPath" size="150" v-if="avatorPath" /> <Avatar :src="avatorPath" size="150" v-if="avatorPath" />
<Avatar size="150" style="background-color: #87d068" v-else-if="!avatorPath" icon="ios-person" /> <Avatar
size="150"
style="background-color: #87d068"
v-else-if="!avatorPath"
icon="ios-person"
/>
</p> </p>
<p style="text-align:center;padding:10px;"> <p style="text-align:center;padding:10px;">
<Button @click="openModalAvatar">修改头像</Button> <Button @click="openModalAvatar">修改头像</Button>
...@@ -80,15 +85,19 @@ ...@@ -80,15 +85,19 @@
</Card> </Card>
<Modal v-model="modalAvatar" title="修改头像" :width="460"> <Modal v-model="modalAvatar" title="修改头像" :width="460">
<Form :model="imageModel"> <Form :model="imageModel">
<Row>
<div class="imgBg"> <div class="imgBg">
<img :src="avatorPath" /> <img :src="avatorPath" />
</div> </div>
<inputFiles v-model="imgName" :parms="parms" /> <inputFiles v-model="imgName" :parms="parms" :showButton="false" />
</Row>
</Form> </Form>
<div slot="footer"> <Row>
<div slot="footer" style="clear:both">
<Button @click="cancelAvatar">取消</Button> <Button @click="cancelAvatar">取消</Button>
<Button type="primary" @click="upAvatar">确定</Button> <Button type="primary" @click="upAvatar">确定</Button>
</div> </div>
</Row>
</Modal> </Modal>
</div> </div>
</template> </template>
...@@ -132,7 +141,7 @@ export default { ...@@ -132,7 +141,7 @@ export default {
remark: "", remark: "",
avatarUrl: "" avatarUrl: ""
}, },
userInfos:{}, userInfos: {},
imageModel: { imageModel: {
id: null, id: null,
avatar_Url: "", avatar_Url: "",
...@@ -208,7 +217,7 @@ export default { ...@@ -208,7 +217,7 @@ export default {
this.$http.sysUser.getuserinfo(parma).then(res => { this.$http.sysUser.getuserinfo(parma).then(res => {
if (res.result) { if (res.result) {
this.userInfo = res.result; this.userInfo = res.result;
this.userInfos=res.result; this.userInfos = res.result;
this.imageModel.id = this.userInfo.id; this.imageModel.id = this.userInfo.id;
if ( if (
res.result.avatarUrl && res.result.avatarUrl &&
...@@ -268,9 +277,9 @@ export default { ...@@ -268,9 +277,9 @@ export default {
}; };
</script> </script>
<style lang="less" > <style lang="less" >
.img_top01{ .img_top01 {
width:350px; width: 350px;
float:left; float: left;
.ivu-card-body { .ivu-card-body {
padding: 0px; padding: 0px;
} }
......
...@@ -112,10 +112,11 @@ ...@@ -112,10 +112,11 @@
</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 /> <inputFile v-model="tempFile" :parms="parms" />
</FormItem> </FormItem>
</Col> </Col>
<!-- <!--
<files ref="refFile" :parms="parms" files singleFile />
<Col :span="12"> <Col :span="12">
<FormItem :label="l('isImportant')" prop="isImportant"> <FormItem :label="l('isImportant')" prop="isImportant">
<Dictionary code="Process.state" v-model="entity.isImportant" type="radio"></Dictionary> <Dictionary code="Process.state" v-model="entity.isImportant" type="radio"></Dictionary>
...@@ -206,6 +207,7 @@ export default { ...@@ -206,6 +207,7 @@ export default {
sampling: null, sampling: null,
samplingBatch: "" samplingBatch: ""
}, },
tempFile: "",
rules: { rules: {
routingDetailId: [ routingDetailId: [
{ required: true, message: "请选择工序名称", type: "number" } { required: true, message: "请选择工序名称", type: "number" }
...@@ -213,12 +215,13 @@ export default { ...@@ -213,12 +215,13 @@ export default {
checkContent: [{ required: true, message: "必填", trigger: "blur" }] checkContent: [{ required: true, message: "必填", trigger: "blur" }]
}, },
routingDetailList: [], routingDetailList: [],
parms: { parms: "app=qccard&eid=" + this.$u.guid() + "&name=''"
app: "qccard", // parms: {
eid: null, // app: "qccard",
name: "", // eid: null,
field: "" // name: "",
} // field: ""
// }
}; };
}, },
props: { props: {
...@@ -236,26 +239,31 @@ export default { ...@@ -236,26 +239,31 @@ export default {
this.$refs.form.validate(v => { this.$refs.form.validate(v => {
if (v) { if (v) {
this.disabled = true; this.disabled = true;
if (this.tempFile != "") {
let tempName = JSON.parse(this.$u.clone(this.tempFile));
this.entity.qualityTemplateName = tempName[0].fileName;
this.entity.qualityTemplate = tempName[0].filePath;
} else {
this.entity.qualityTemplateName = ""; this.entity.qualityTemplateName = "";
this.entity.qualityTemplate = ""; this.entity.qualityTemplate = "";
if (this.$refs.refFile.nameList.length > 0) {
let nameList = this.$refs.refFile.nameList;
let names = [];
let url = [];
nameList.forEach(e => {
names.push(e.fileName);
url.push(e.filePath);
});
this.entity.qualityTemplateName = JSON.stringify(names)
.replace("[", "")
.replace("]", "")
.replace(/\"/g, ""); //附件本地库暂存文件名称
this.entity.qualityTemplate = JSON.stringify(url)
.replace("[", "")
.replace("]", "")
.replace(/\"/g, "");
} }
// if (this.$refs.refFile.nameList.length > 0) {
// let nameList = this.$refs.refFile.nameList;
// let names = [];
// let url = [];
// nameList.forEach(e => {
// names.push(e.fileName);
// url.push(e.filePath);
// });
// this.entity.qualityTemplateName = JSON.stringify(names)
// .replace("[", "")
// .replace("]", "")
// .replace(/\"/g, ""); //附件本地库暂存文件名称
// this.entity.qualityTemplate = JSON.stringify(url)
// .replace("[", "")
// .replace("]", "")
// .replace(/\"/g, "");
// }
this.entity.routingHeaderId = this.headid; this.entity.routingHeaderId = this.headid;
Api.create(this.entity) Api.create(this.entity)
......
...@@ -54,8 +54,9 @@ ...@@ -54,8 +54,9 @@
</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 /> <inputFile ref="inputfile" v-model="tempFile" :parms="parms" />
<!-- <!--
<files ref="refFile" :parms="parms" files singleFile />
<a <a
:href="fileUrlPath" :href="fileUrlPath"
@click="downFile(entity.qualityTemplate)" @click="downFile(entity.qualityTemplate)"
...@@ -82,10 +83,14 @@ export default { ...@@ -82,10 +83,14 @@ export default {
raidoDis: false, raidoDis: false,
downUrl: fileUrlDown, downUrl: fileUrlDown,
fileUrlPath: "", fileUrlPath: "",
tempFile: "",
tempFileName: "",
tempFilePath: "",
entity: { entity: {
qualityTemplateName: "", qualityTemplateName: "",
qualityTemplate: "" qualityTemplate: ""
}, },
rules: { rules: {
routingDetailId: [ routingDetailId: [
{ required: true, message: "请选择工序名称", type: "number" } { required: true, message: "请选择工序名称", type: "number" }
...@@ -93,12 +98,13 @@ export default { ...@@ -93,12 +98,13 @@ export default {
checkContent: [{ required: true, message: "必填", trigger: "blur" }] checkContent: [{ required: true, message: "必填", trigger: "blur" }]
}, },
routingDetailList: [], routingDetailList: [],
parms: { parms: "app=qccard&eid=" + this.$u.guid() + "&name=''"
app: "qccard", // parms: {
eid: this.eid, // app: "qccard",
name: "", // eid: this.eid,
field: "" // name: "",
} // field: ""
// }
}; };
}, },
props: { props: {
...@@ -115,10 +121,11 @@ export default { ...@@ -115,10 +121,11 @@ export default {
methods: { methods: {
load(v) { load(v) {
Api.get({ id: v }).then(r => { Api.get({ id: v }).then(r => {
this.$refs.refFile.intFilesClone(); // this.$refs.refFile.intFilesClone();
this.parms.eid = v; //this.parms.eid = v;
this.entity = r.result; this.entity = r.result;
this.$refs.inputfile.newName = this.entity.qualityTemplateName;
this.$refs.inputfile.newPath = this.entity.qualityTemplate;
if (r.result.checkType == 1 || r.result.checkType == 2) { if (r.result.checkType == 1 || r.result.checkType == 2) {
this.raidoDis = false; this.raidoDis = false;
this.entity.isphotograph = null; this.entity.isphotograph = null;
...@@ -134,26 +141,30 @@ export default { ...@@ -134,26 +141,30 @@ export default {
this.$refs.form.validate(v => { this.$refs.form.validate(v => {
if (v) { if (v) {
this.disabled = true; this.disabled = true;
this.entity.qualityTemplateName = ""; if (this.tempFile != "") {
this.entity.qualityTemplate = ""; let tempName = JSON.parse(this.$u.clone(this.tempFile));
if (this.$refs.refFile.nameList.length > 0) { this.entity.qualityTemplateName = tempName[0].fileName;
let nameList = this.$refs.refFile.nameList; this.entity.qualityTemplate = tempName[0].filePath;
let names = [];
let url = [];
nameList.forEach(e => {
names.push(e.fileName);
url.push(e.filePath);
});
this.entity.qualityTemplateName = JSON.stringify(names)
.replace("[", "")
.replace("]", "")
.replace(/\"/g, ""); //附件本地库暂存文件名称
this.entity.qualityTemplate = JSON.stringify(url)
.replace("[", "")
.replace("]", "")
.replace(/\"/g, "");
} }
// if (this.$refs.refFile.nameList.length > 0) {
// let nameList = this.$refs.refFile.nameList;
// let names = [];
// let url = [];
// nameList.forEach(e => {
// names.push(e.fileName);
// url.push(e.filePath);
// });
// this.entity.qualityTemplateName = JSON.stringify(names)
// .replace("[", "")
// .replace("]", "")
// .replace(/\"/g, ""); //附件本地库暂存文件名称
// this.entity.qualityTemplate = JSON.stringify(url)
// .replace("[", "")
// .replace("]", "")
// .replace(/\"/g, "");
// }
Api.update(this.entity) Api.update(this.entity)
.then(r => { .then(r => {
this.disabled = false; this.disabled = false;
...@@ -213,7 +224,7 @@ export default { ...@@ -213,7 +224,7 @@ export default {
if (v != 0) { if (v != 0) {
this.load(v); this.load(v);
} }
} },
} }
}; };
</script> </script>
...@@ -184,6 +184,9 @@ export default { ...@@ -184,6 +184,9 @@ export default {
this.$refs.refFile.intFilesClone(); this.$refs.refFile.intFilesClone();
this.parms.eid = this.uid; this.parms.eid = this.uid;
this.entity = r.result; this.entity = r.result;
if (this.entity.isEffect && this.entity.isEffect != "") {
this.entity.isEffect = Number(this.entity.isEffect);
}
}); });
}, },
handleSubmit() { handleSubmit() {
......
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