|
|
<template>
|
|
|
<div>
|
|
|
<el-form :model="inputQuery" :rules="formRules" ref="dataForm" label-width="110px">
|
|
|
<el-card style="margin-top: -30px">
|
|
|
<el-button-group style="display: flex">
|
|
|
<el-button type="primary" @click.native="submitUpload()" style="margin: 0 60px 10px auto; height: 35px"
|
|
|
:loading="loading">提交
|
|
|
</el-button>
|
|
|
</el-button-group>
|
|
|
<el-row>
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="规格型号:" prop="ggxh">
|
|
|
<el-input v-model="inputQuery.ggxh" auto-complete="off" :disabled="true"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="物资名称:" prop="cpmctymc">
|
|
|
<el-input v-model="inputQuery.cpmctymc" auto-complete="off" :disabled="true"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
|
<el-row >
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="机械编码:" prop="machineNo">
|
|
|
<el-input v-model="inputQuery.machineNo" auto-complete="off" ></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="发票代码:" prop="invoiceCode">
|
|
|
<el-input v-model="inputQuery.invoiceCode" auto-complete="off" ></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="发票编码:" prop="invoiceEncode">
|
|
|
<el-input v-model="inputQuery.invoiceEncode" auto-complete="off" ></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="发票价格:" prop="price">
|
|
|
<el-input v-model="inputQuery.price" auto-complete="off" ></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="开票日期:" prop="invoiceDate">
|
|
|
<el-date-picker
|
|
|
v-model="inputQuery.invoiceDate"
|
|
|
type="datetime"
|
|
|
placeholder="请选择日期"
|
|
|
clearable
|
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
style="width: 100%"
|
|
|
>
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="备注:" prop="remark">
|
|
|
<el-input v-model="inputQuery.remark" auto-complete="off" ></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
<el-row>
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="文件:">
|
|
|
<el-upload
|
|
|
:disabled="formData.auditStatus == 1"
|
|
|
class="upload-demo"
|
|
|
ref="upload"
|
|
|
:action="this.uploadUrl"
|
|
|
:on-preview="uploadHandlePreview"
|
|
|
:on-remove="uploadHandleRemove"
|
|
|
:limit="1"
|
|
|
:headers="headers"
|
|
|
:on-exceed="uploadHandleExceed"
|
|
|
accept=".jpg,.png,.pdf,.doc"
|
|
|
:on-change="uploadOnchange"
|
|
|
:on-success="uploadHandleSuccess"
|
|
|
:on-error="uploadHandleError"
|
|
|
:file-list="fileList"
|
|
|
:data="{type:'image2'}"
|
|
|
:auto-upload="true">
|
|
|
<el-button slot="trigger" size="small" type="primary" :disabled="formData.auditStatus == 1">
|
|
|
{{ choiceFile }}
|
|
|
</el-button>
|
|
|
<div>只能上传 jpg,png 文件,且不超过 10 MB</div>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
<el-col :span="11">
|
|
|
<el-form-item label="文件预览:">
|
|
|
<el-button type="success" size="mini" icon="search" v-if="this.inputQuery.licenseUrl!=null"
|
|
|
style="text-align:right" @click="showImgViewer" >
|
|
|
文件预览
|
|
|
</el-button>
|
|
|
</el-form-item>
|
|
|
<el-image-viewer v-if="imgViewerVisible" style="z-index:9999" :on-close="closeImgViewer" :url-list="imgList"/>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
</el-card>
|
|
|
</el-form>
|
|
|
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import draggable from "vuedraggable";
|
|
|
import store from "@/store";
|
|
|
import {insertCompanyCert, updateCompanyCert} from "@/api/purchase/companyCert";
|
|
|
import {updateById} from '@/api/inout/orderDetailBiz'
|
|
|
import ElImageViewer from "element-ui/packages/image/src/image-viewer";
|
|
|
import { previewImage } from '@/api/purchase/supCompany'
|
|
|
|
|
|
|
|
|
export default {
|
|
|
name: "DialogInvoice",
|
|
|
props: {
|
|
|
closeDialog: {
|
|
|
type: Function,
|
|
|
required: true,
|
|
|
},
|
|
|
inputQuery: {
|
|
|
type: Object,
|
|
|
required: true,
|
|
|
},
|
|
|
|
|
|
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
imgList:[],
|
|
|
imgViewerVisible:false,
|
|
|
BASE_URL: process.env.VUE_APP_BASE_API,
|
|
|
code: "",
|
|
|
formData: {
|
|
|
ggxh:"",
|
|
|
cpmctymc:"",
|
|
|
machineNo:"",
|
|
|
invoiceCode:"",
|
|
|
invoiceEncode:"",
|
|
|
price:"",
|
|
|
remark:"",
|
|
|
licenseUrl:""
|
|
|
},
|
|
|
formRules: {
|
|
|
machineNo: [
|
|
|
{required: true, message: "请输入机械编码", trigger: "blur"}
|
|
|
],
|
|
|
invoiceCode: [
|
|
|
{required: true, message: "请输入发票代码", trigger: "blur"}
|
|
|
],
|
|
|
invoiceEncode: [
|
|
|
{required: true, message: "请输入发票编码", trigger: "blur"}
|
|
|
],
|
|
|
price: [
|
|
|
{required : true, message: "请输入发票价格", trigger:"blur"}
|
|
|
],
|
|
|
remark: [
|
|
|
{required : true, message: "请输入备注", trigger:"blur"}
|
|
|
],
|
|
|
},
|
|
|
loading: false,
|
|
|
uploadUrl: "",
|
|
|
fileList: [],
|
|
|
headers: {},
|
|
|
choiceFile: "选取文件",
|
|
|
|
|
|
};
|
|
|
},
|
|
|
components: {
|
|
|
draggable,ElImageViewer
|
|
|
},
|
|
|
methods: {
|
|
|
submitUpload() {
|
|
|
this.$refs["dataForm"].validate(valid => {
|
|
|
if (valid) {
|
|
|
if (this.$isBlank(this.inputQuery.machineNo)) {
|
|
|
this.$message.error("机械编码不能为空!");
|
|
|
return;
|
|
|
}
|
|
|
if (this.$isBlank(this.inputQuery.invoiceCode)) {
|
|
|
this.$message.error("发票代码不能为空!");
|
|
|
return;
|
|
|
}
|
|
|
if (this.$isBlank(this.inputQuery.invoiceEncode)) {
|
|
|
this.$message.error("发票编码不能为空!");
|
|
|
return;
|
|
|
}
|
|
|
if (this.$isBlank(this.inputQuery.price)) {
|
|
|
this.$message.error("发票价格不能为空!");
|
|
|
return;
|
|
|
}
|
|
|
if (this.$isBlank(this.inputQuery.remark)) {
|
|
|
this.$message.error("备注不能为空!");
|
|
|
return;
|
|
|
}
|
|
|
updateById(this.inputQuery).then((res) => {
|
|
|
if (res.code == 20000) {
|
|
|
this.$message({
|
|
|
type: "success",
|
|
|
message: "修改成功!",
|
|
|
});
|
|
|
this.closeDialog();
|
|
|
}
|
|
|
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// onSubmit() {
|
|
|
// this.loading = true;
|
|
|
// this.formData.customerId = this.inputQuery.customerId;
|
|
|
// if (this.formData.customerId == null) {
|
|
|
// this.formData.customerId = store.getters.customerId
|
|
|
// }
|
|
|
// this.formData.type = this.addType;
|
|
|
// //证书类型:1:供应商;2.生产企业;3.产品品种
|
|
|
// if (this.addType == 2) {
|
|
|
// this.formData.manufacturerIdFk = this.inputQuery.manufacturerId;
|
|
|
// } else if (this.addType == 3) {
|
|
|
// this.formData.manufacturerIdFk = this.inputQuery.manufacturerIdFk;
|
|
|
// this.formData.productIdFk = this.inputQuery.productId;
|
|
|
// }
|
|
|
// if (this.formData.auditStatus != 1)
|
|
|
// this.formData.auditStatus = "6";
|
|
|
//
|
|
|
// if (this.editTye == 1) {
|
|
|
// insertCompanyCert(this.formData).then(response => {
|
|
|
// this.loading = false;
|
|
|
// if (response.code === 20000) {
|
|
|
// this.$message.success("添加成功");
|
|
|
// this.closeDialog(true);
|
|
|
// } else {
|
|
|
// this.$message.error(response.message);
|
|
|
// }
|
|
|
// });
|
|
|
// } else {
|
|
|
// updateCompanyCert(this.formData).then(response => {
|
|
|
// this.loading = false;
|
|
|
// if (response.code === 20000) {
|
|
|
// this.$message.success("添加成功");
|
|
|
// this.closeDialog(true);
|
|
|
// } else {
|
|
|
// this.$message.error(response.message);
|
|
|
// }
|
|
|
// });
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// },
|
|
|
uploadHandleRemove(file, fileList) {
|
|
|
this.inputQuery.licenseUrl=null;
|
|
|
console.log(file, fileList);
|
|
|
},
|
|
|
uploadHandlePreview(file) {
|
|
|
console.log(file);
|
|
|
console.log(this.fileList);
|
|
|
},
|
|
|
uploadHandleExceed(files, fileList) {
|
|
|
this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
|
|
|
},
|
|
|
uploadOnchange(file, fileList) {
|
|
|
let fileName = file.name;
|
|
|
let uid = file.uid
|
|
|
let pos = fileName.lastIndexOf(".");
|
|
|
let lastName = fileName.substring(pos, fileName.length);
|
|
|
if (lastName.toLowerCase() !== ".jpg" && lastName.toLowerCase() !== ".png" && lastName.toLowerCase() !== ".doc" && lastName.toLowerCase() !== ".pdf") {
|
|
|
this.$message.error("上传文件只能是 jpg,png,doc,pdf 格式");
|
|
|
for (let i = 0; i < fileList.length; i++) {//从list删除
|
|
|
if (fileList[i].uid === uid) {
|
|
|
fileList.splice(i, 1)
|
|
|
}
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
// 限制上传文件的大小
|
|
|
const isLt = file.size / 1024 / 1024 / 30 <= 1;
|
|
|
if (!isLt) {
|
|
|
this.$message.error("上传文件大小不能超过 30MB");
|
|
|
for (let i = 0; i < fileList.length; i++) {
|
|
|
if (fileList[i].uid === uid) {
|
|
|
fileList.splice(i, 1)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return isLt;
|
|
|
},
|
|
|
uploadHandleSuccess(response, file, fileList) {
|
|
|
if (response.code === 20000) {
|
|
|
this.inputQuery.licenseUrl = response.data.name;
|
|
|
// this.onSubmit();
|
|
|
} else {
|
|
|
this.$message.error("文件上传失败:" + response.message);
|
|
|
}
|
|
|
},
|
|
|
uploadHandleError() {
|
|
|
|
|
|
},
|
|
|
showImgViewer(){
|
|
|
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name=";
|
|
|
this.imgList=[];
|
|
|
previewImage({imageUrl:this.inputQuery.licenseUrl,certFileUrl:this.certFileUrl}).then(response => {
|
|
|
if (response.code === 20000) {
|
|
|
this.imgList=response.data;
|
|
|
}
|
|
|
console.log(this.imgList)
|
|
|
this.imgViewerVisible = true;
|
|
|
});
|
|
|
const m = (e) => { e.preventDefault() };
|
|
|
document.body.style.overflow = 'hidden';
|
|
|
document.addEventListener("touchmove", m, false); // 禁止页面滑动
|
|
|
},
|
|
|
|
|
|
closeImgViewer(){
|
|
|
this.imgViewerVisible = false;
|
|
|
const m = (e) => { e.preventDefault() };
|
|
|
document.body.style.overflow = 'auto';
|
|
|
document.removeEventListener("touchmove", m, true);
|
|
|
},
|
|
|
|
|
|
},
|
|
|
filters: {},
|
|
|
mounted() {
|
|
|
document.body.ondrop = function (event) {
|
|
|
event.preventDefault();
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
this.uploadUrl = this.BASE_URL + "/udiwms/upload/register/file";
|
|
|
this.headers = {
|
|
|
ADMIN_ID: store.getters.adminId,
|
|
|
ADMIN_TOKEN: store.getters.token,
|
|
|
};
|
|
|
if (this.formData.formData == null) {
|
|
|
this.formData = {}
|
|
|
} else if (this.inputQuery.formData != null && this.inputQuery.formData.addType == 1) {
|
|
|
this.formData = {}
|
|
|
} else {
|
|
|
this.formData = this.inputQuery.formData;
|
|
|
console.log(this.inputQuery.formData);
|
|
|
}
|
|
|
if (this.inputQuery.licenseUrl != null) {
|
|
|
this.choiceFile = "更换文件";
|
|
|
} else {
|
|
|
this.choiceFile = "选取文件";
|
|
|
}
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
<style>
|
|
|
|
|
|
.ao-text {
|
|
|
width: 100%;
|
|
|
font-size: 13px;
|
|
|
font-family: "Microsoft YaHei";
|
|
|
float: right;
|
|
|
text-align: right;
|
|
|
margin-top: 10px;
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|