Commit 4af18f0b authored by renjintao's avatar renjintao

files/add/detail

parent 581db78c
......@@ -11,7 +11,7 @@
:show-upload-list="false"
:on-exceeded-size="onExceededSize"
:on-format-error="onFormatError"
multiple
:multiple="multiple"
:style="style"
:on-progress="onProgress"
>
......@@ -21,7 +21,7 @@
</div>
<Button icon="ios-cloud-upload-outline" v-if="!cloudIco">上传文件</Button>
</Upload>
<Progress :percent="per" :stroke-width="5" v-show="vshowPro"/>
<Progress :percent="per" :stroke-width="5" v-show="vshowPro" />
<Tag
v-for="(item,index) in nameList"
:key="index"
......@@ -36,23 +36,24 @@
</template>
<script>
export default {
name: 'files',
name: "files",
model: {
prop: 'value'
prop: "value"
},
data() {
return {
file: null,
downUrl: fileUrlDown,
fileUrlPath: '',
fileUrlPath: "",
nameList: [],
hbaseFileListNew: [],
formatList: ['png', 'jpg', 'gif'],
postUrl: '',
style: '',
formatList: ["png", "jpg", "gif"],
multiple: true,
postUrl: "",
style: "",
per: 0,
vshowPro: false
}
};
},
created() {},
props: {
......@@ -61,13 +62,17 @@ export default {
type: Boolean,
default: false
},
singleFile: {
type: Boolean,
default: false
},
maxSize: {
type: Number,
default: 10240
},
parms: {
type: [String, Object],
default: ''
default: ""
},
unClosable: {
type: Boolean,
......@@ -80,140 +85,146 @@ export default {
},
methods: {
onProgress(event, file, fileList) {
this.per = 0
this.vshowPro = true
this.per = 0;
this.vshowPro = true;
},
// change(event) {
// this.$emit('on-change', event)
// },
//上传成功文件
uploadSuccess(response, file, fileList) {
this.per = 60
this.vshowPro = true
const hbaseFileList = []
const filesList = []
this.per = 60;
this.vshowPro = true;
const hbaseFileList = [];
const filesList = [];
if (file.response.status == 0) {
let objImag = {}
objImag.fileName = file.response.data.fileName
objImag.filePath = file.response.data.downloadPath
objImag.id = file.response.data.id
filesList.push(objImag)
this.nameList = this.nameList.concat(filesList)
this.per = 100
let objImag = {};
objImag.fileName = file.response.data.fileName;
objImag.filePath = file.response.data.downloadPath;
objImag.id = file.response.data.id;
filesList.push(objImag);
this.nameList = this.nameList.concat(filesList);
this.per = 100;
setTimeout(() => {
this.per = 0
this.vshowPro = false
}, 2000)
this.per = 0;
this.vshowPro = false;
}, 2000);
} else {
this.$Message.error('上传失败,请重新上传!')
this.$Message.error("上传失败,请重新上传!");
}
},
//上传文件失败
uploadError(response, file, fileList) {
this.$Message.error('上传失败,请重新上传!')
this.$Message.error("上传失败,请重新上传!");
},
//文件大小验证返回
onExceededSize(file, fileList) {
if (Object.keys(file).length == 0) {
this.$Message.error(
'上传文件不能大于' + this.maxSize + 'k,请重新上传!'
)
"上传文件不能大于" + this.maxSize + "k,请重新上传!"
);
}
},
//文件格式验证
onFormatError(file, fileList) {
if (Object.keys(file).length == 0) {
this.$Message.error('上传文件格式不正确,请重新上传!')
this.$Message.error("上传文件格式不正确,请重新上传!");
}
},
//删除上传
removeFile(file, fileList) {},
handleClose2(event, name) {
//删除上传到文件服务器上的文件
this.$http.sysUser.deleteFile(name).then((res) => {
this.$http.sysUser.deleteFile(name).then(res => {
if (res.status == 0) {
const index = this.nameList.findIndex(function(item) {
return item.id === name
})
this.nameList.splice(index, 1)
return item.id === name;
});
this.nameList.splice(index, 1);
} else {
this.$Message.error('删除失败!')
this.$Message.error("删除失败!");
}
})
});
},
downFile(path) {
this.fileUrlPath = this.downUrl + path
this.fileUrlPath = this.downUrl + path;
},
formatL() {
if (this.files) {
this.formatList = [
'pdf',
'docx',
'doc',
'xls',
'xlsx',
'txt',
'png',
'jpg',
'gif'
]
"pdf",
"docx",
"doc",
"xls",
"xlsx",
"txt",
"png",
"jpg",
"gif"
];
}
return this.formatList;
},
mutipleStatu() {
if (this.singleFile) {
this.multiple = false;
} else {
this.multiple = true;
}
return this.formatList
},
//修改时使用
intFiles() {
this.postUrl =
fileUrl +
'/upload/?token=Bearer ' +
window.sessionStorage.getItem('token') +
'&' +
this.convertObj(this.parms)
"/upload/?token=Bearer " +
window.sessionStorage.getItem("token") +
"&" +
this.convertObj(this.parms);
//是否显示上传按钮
if (this.unClosable) {
this.style = 'display:none;'
this.style = "display:none;";
} else {
this.style = ''
this.style = "";
}
this.nameList = []
this.nameList = [];
//查询上传到文件服务器上的文件
this.$http.sysUser.getFile(this.parms).then((res) => {
this.$http.sysUser.getFile(this.parms).then(res => {
if (res.data != [] && res.data.length > 0) {
res.data.forEach((data) => {
let objImag = {}
objImag.fileName = data.fileName
objImag.filePath = data.downloadPath
objImag.id = data.id
this.nameList.push(objImag)
})
res.data.forEach(data => {
let objImag = {};
objImag.fileName = data.fileName;
objImag.filePath = data.downloadPath;
objImag.id = data.id;
this.nameList.push(objImag);
});
}
})
});
},
//新增时重新定义posturl使用
intFiles1() {
this.postUrl =
fileUrl +
'/upload/?token=Bearer ' +
window.sessionStorage.getItem('token') +
'&' +
this.convertObj(this.parms)
"/upload/?token=Bearer " +
window.sessionStorage.getItem("token") +
"&" +
this.convertObj(this.parms);
},
//obj转为url
convertObj(data) {
if (data.eid != null) {
var _result = []
var _result = [];
for (var key in data) {
var value = data[key]
var value = data[key];
if (value.constructor == Array) {
value.forEach(function(_value) {
_result.push(key + '=' + _value)
})
_result.push(key + "=" + _value);
});
} else {
_result.push(key + '=' + value)
_result.push(key + "=" + value);
}
}
return _result.join('&')
} else return ''
return _result.join("&");
} else return "";
}
},
computed: {},
......@@ -224,10 +235,11 @@ export default {
// }
},
mounted() {
this.formatL()
this.formatL();
this.mutipleStatu();
// this.intFiles()
}
}
};
</script>
<style lang="less">
</style>
\ No newline at end of file
......@@ -1289,7 +1289,6 @@ export default {
checkParams: '检测要求',
measurementUnit: '测量单位',
fillintype: '填报类型',
qualityTemplate: '模板',
isphotograph: '是否拍照',
status: '状态',
extend: '扩展字段',
......@@ -1297,6 +1296,7 @@ export default {
productionRequirement: '生产要求',
standard: '标准指标',
qualityTemplateName: '模板名称',
qualityTemplate: '模板',
isImportant: '关键检验',
firstCheck: '首件检验',
inspection: '巡检',
......
......@@ -92,7 +92,8 @@
</Col>
<Col :span="24">
<FormItem :label="l('qualityTemplateName')" prop="qualityTemplateName">
<Input v-model="entity.qualityTemplateName"></Input>
<files ref="refFile" :parms="parms" files singleFile />
<!-- <Input v-model="entity.qualityTemplateName"></Input> -->
</FormItem>
</Col>
<Col :span="12">
......@@ -198,7 +199,13 @@ export default {
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }]
},
routingDetailList: []
routingDetailList: [],
parms: {
app: 'qccard',
eid: null,
name: '',
field: ''
}
};
},
props: {
......@@ -207,6 +214,8 @@ export default {
},
mounted() {
this.loadDetails();
this.parms.eid = this.$u.guid()
this.$refs.refFile.intFiles()
if (this.eid > 0) {
this.load(this.eid);
}
......@@ -216,12 +225,29 @@ export default {
this.$refs.form.validate(v => {
if (v) {
this.disabled = true;
this.entity.qualityTemplateName = ''
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,'')
}
Api.create(this.entity)
.then(r => {
this.disabled = false;
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
//let newId = r.result
//this.updateEid(newId) //更新服务器上的id
} else {
this.$Message.error("保存失败");
}
......@@ -259,6 +285,20 @@ export default {
});
this.routingDetailList = tempD;
});
},
//新增时将uid转为eid
updateEid(newId) {
let parms = {
eid: this.parms.eid,
id: newId + ''
}
this.$http.sysUser.updateEid(parms).then((res) => {
if (res.status) {
// this.$Message.success('修改成功!')
} else {
//this.$Message.error('修改失败!')
}
})
},
l(key) {
key = "routing_qc_card" + "." + key;
......
......@@ -9,7 +9,7 @@
</Filed>
<Filed :span="12" :name="l('productionRequirement')">{{entity.productionRequirement}}</Filed>
<Filed :span="12" :name="l('checkContent')">{{entity.checkContent}}</Filed>
<Filed :span="12" :name="l('qualityTemplateName')">{{entity.qualityTemplateName}}</Filed>
<Filed :span="12" :name="l('qualityTemplateName')"><files ref="refFile" :parms="parms" unClosable style="display:inline" /></Filed>
<Filed :span="12" :name="l('isImportant')">
<state code="Process.state" :value="entity.isImportant+''" type="text"></state>
</Filed>
......@@ -69,7 +69,13 @@ export default {
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }],
code: [{ required: true, message: "必填", trigger: "blur" }]
}
},
parms: {
app: 'contract',
eid: null,
name: '',
field: ''
},
};
},
props: {
......@@ -84,6 +90,8 @@ export default {
load(v) {
Api.get({ id: v }).then(r => {
this.entity = r.result;
this.parms.eid = r.result.id
this.$refs.refFile.intFiles()
this.$emit("on-load");
});
},
......
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