You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-cpt-vue/src/views/purchase/cert/supCertAddDialog.vue

420 lines
13 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<el-form :model="formData" :rules="formRules" ref="dataForm">
<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="3">
<div class="ao-text">
<span>证书名称</span>
</div>
</el-col>
<el-col :span="8">
<el-form-item prop="name">
<el-input v-model="formData.name" auto-complete="off" :disabled="formData.auditStatus == 1"></el-input>
</el-form-item>
</el-col>
<el-col :span="3">
<div class="ao-text">
<span>证书编号:</span>
</div>
</el-col>
<el-col :span="8">
<el-form-item prop="code">
<el-input v-model="formData.code" auto-complete="off" :disabled="formData.auditStatus == 1"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="3">
<div class="ao-text">
<span>生效期:</span>
</div>
</el-col>
<el-col :span="8">
<el-form-item prop="vailDate">
<el-date-picker
v-model="formData.vailDate"
type="date"
:disabled="formData.auditStatus == 1"
value-format="yyyy-MM-dd"
style="width: 100%"
placeholder="请选择生效期">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="3">
<div class="ao-text">
<span>失效期:</span>
</div>
</el-col>
<el-col :span="8">
<el-form-item prop="expireDate">
<el-date-picker
v-model="formData.expireDate"
type="date"
:disabled="formData.auditStatus == 1"
value-format="yyyy-MM-dd"
style="width: 100%"
placeholder="请选择失效期">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="3">
<div class="ao-text">
<span>备注:</span>
</div>
</el-col>
<el-col :span="8">
<el-form-item prop="remark">
<el-input v-model="formData.remark" auto-complete="off" type="textarea" autosize></el-input>
</el-form-item>
</el-col>
</el-row>
<!-- <el-row :gutter="20">-->
<!-- <el-col :span="4">-->
<!-- </el-col>-->
<!-- <el-col :span="16">-->
<!-- <div style="color: red">-->
<!-- 需要上传档案为:营业执照电子档案,经营许可证电子档案,经营备案证电子档案,开户行电子档案。-->
<!-- </div>-->
<!-- </el-col>-->
<!-- </el-row>-->
<!-- <el-row>-->
<!-- <el-col :span="3">-->
<!-- <div class="ao-text">-->
<!-- <span>文件:</span>-->
<!-- </div>-->
<!-- </el-col>-->
<!-- <el-col :span="8">-->
<!-- <el-form-item>-->
<!-- <el-upload-->
<!-- :disabled="formData.auditStatus == 1"-->
<!-- class="upload-demo"-->
<!-- ref="upload"-->
<!-- :action="this.uploadUrl"-->
<!-- :on-preview="uploadHandlePreview"-->
<!-- :on-remove="uploadHandleRemove"-->
<!-- :headers="headers"-->
<!-- :on-exceed="uploadHandleExceed"-->
<!-- accept=".jpg,.png"-->
<!-- :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 文件且不超过 3 MB</div>-->
<!-- </el-upload>-->
<!-- &lt;!&ndash; <el-button type="primary" size="mini" icon="search" @click="toViewCompanyCert"&ndash;&gt;-->
<!-- &lt;!&ndash; style="text-align:right"&ndash;&gt;-->
<!-- &lt;!&ndash; >文件预览&ndash;&gt;-->
<!-- &lt;!&ndash; </el-button&ndash;&gt;-->
<!-- &lt;!&ndash; >&ndash;&gt;-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- </el-row>-->
<el-row gutter="20" class="el-row" type="flex">
<el-col :span="11" class="el-col">
<el-form-item label="文件:" prop="filePath">
<cusEditor ref="editorRef" style="width:90vh;height: 100%;overflow: auto; " :content="formData.filePath"
:type="`image2`"/>
</el-form-item>
</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 ElImageViewer from "element-ui/packages/image/src/image-viewer"
import {lo} from "pinyin/data/dict-zi-web";
export default {
name: "supCompanyCertAdd",
props: {
closeDialog: {
type: Function,
required: true,
},
inputQuery: {
type: Object,
required: true,
},
editTye: {
type: Object,//1:新增2编辑
required: true,
},
addType: {
type: Object,
required: true,
},
},
data() {
return {
BASE_URL: process.env.VUE_APP_BASE_API,
code: "",
isCleck: false,
formData: {
type: 0,
vailDate: null,
expireDate: null,
remark: null,
code: null,
name: null,
manufacturerIdFk: null,
companyIdFk: null,
auditStatus: 6
},
formRules: {
name: [
{required: true, message: "请输入证书名称", trigger: "blur"}
],
code: [
{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.formData.auditStatus == 1) {
this.$confirm("该证书已审核通过,是否重新提交审核?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.onConfirmSubmit(1);
})
.catch(() => {
});
} else {
this.onConfirmSubmit();
}
}
});
},
onConfirmSubmit(val) {
this.formData.repeatUpload = val;
console.log(this.formData)
this.onSubmit();
// if (this.$isNotBlank(this.formData.filePath)) {
// if (this.$refs.upload.uploadFiles.length > 0) {
// this.$refs.upload.submit();
// this.onSubmit();
// } else {
// this.onSubmit();
// }
//
// } else {
// console.log(this.$refs.upload.uploadFiles.length);
// if (this.$refs.upload.uploadFiles.length > 0) {
// this.$refs.upload.submit();
// } else {
// this.$message.warning(`请选择文件`);
// }
// }
},
onSubmit() {
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.产品品种 4往来单位
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;
}else if (this.addType==4){
this.formData.companyIdFk = this.inputQuery.companyIdFk;
console.log(this.inputQuery.companyIdFk);
}
if (this.formData.auditStatus != 1)
this.formData.auditStatus = "6";
this.formData.filePath = this.$refs.editorRef.html
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.formData.filePath = "";
for (var i = 0; i < fileList.length; i++) {
this.formData.filePath += fileList[i].response.data.name + ",";
}
},
uploadHandlePreview(file) {
console.log(file);
console.log(this.fileList);
},
uploadHandleExceed(files, fileList) {
},
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") {
this.$message.error("上传文件只能是 jpg,png格式");
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 / 3 <= 1;
if (!isLt) {
this.$message.error("上传文件大小不能超过 3MB");
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) {
if (this.formData.filePath == null || this.isCleck == true) {
this.formData.filePath = response.data.name + ",";
this.isCleck = false;
} else {
this.formData.filePath += response.data.name + ",";
}
} else {
this.$message.error("文件上传失败:" + response.message);
}
},
uploadHandleError() {
},
toViewCompanyCert() {
this.certFileUrl = this.BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name=";
window.open(this.certFileUrl + this.formData.filePath);
},
},
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,
};
console.log("到富文本框啦");
console.log(this.inputQuery)
if (this.inputQuery.type==4){
this.formData = this.inputQuery;
}else {
if (this.inputQuery.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);
}
}
console.log("66"+this.inputQuery.formData);
if (this.formData.filePath != null) {
this.choiceFile = "更换文件";
this.isCleck = true;
} else {
this.choiceFile = "选取文件";
}
},
};
</script>
<style scoped>
.ao-text {
width: 100%;
font-size: 13px;
font-family: "Microsoft YaHei";
float: right;
text-align: right;
margin-top: 10px;
}
</style>