Commit 4af18f0b authored by renjintao's avatar renjintao

files/add/detail

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