<template>
|
<el-dialog
|
:title="title"
|
:visible.sync="dialogVisible"
|
:close-on-press-escape="false"
|
width="45%">
|
<el-form :model="productJudgeForm" ref="ruleForm" label-width="200px">
|
<el-row>
|
<el-col :span="20">
|
<el-form-item label="企业名称" prop="enterprisename" >
|
<el-select v-model="productJudgeForm.enterprisename" filterable @change="giveEnterpriseNumber">
|
<el-option
|
v-for="item in enterpriseList"
|
:key="item.id"
|
:value="item.enterprisename"
|
:label="item.enterprisename">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="20">
|
<el-form-item label="处罚类型" prop="punishmentmeasure">
|
<el-select v-model="productJudgeForm.punishmentmeasure">
|
<el-option
|
v-for="item in punishmentMeasureList"
|
:key="item.id"
|
:value="item.value"
|
:label="item.text">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="20">
|
<el-form-item label="处罚原因" prop="punishmentreason">
|
<el-input type="textarea" :row="2" v-model="productJudgeForm.punishmentreason">
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="20">
|
<el-form-item label="文件:" prop="directionCode">
|
<input id="upload" ref="upload" type="file" accept="image/*"/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<div align="center">
|
<el-button @click="dialogVisible = false">取消</el-button>
|
<el-button type="primary" @click="submit()">确定</el-button>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
import {getEnterprise , addProductJudge , updateProductJudge} from "../../../../api/productJudge";
|
import {dictionaryAllItems} from "../../../../api/dictionary";
|
import {parseError} from "../../../../utils/messageDialog";
|
|
export default {
|
name: "productJudgeForm",
|
data(){
|
return{
|
title:'',
|
dialogVisible:false,
|
productJudgeForm:{
|
enterprisename:'',
|
enterprisenumber:'',
|
punishmentmeasure:'',
|
punishmentreason:'',
|
file:'',
|
},
|
enterpriseList:[],
|
punishmentMeasureList:[],
|
}
|
},
|
created(){
|
this.getEnterpriseList()
|
},
|
methods:{
|
showProductJudgeForm(title,value,punishmentMeasureList){
|
this.dialogVisible = true
|
this.title = title
|
this.punishmentMeasureList = punishmentMeasureList
|
if(this.title === '新增'){
|
this.productJudgeForm = {
|
enterprisename:'',
|
enterprisenumber:'',
|
punishmentmeasure:'',
|
punishmentreason:'',
|
}
|
}else{
|
let form = JSON.parse(JSON.stringify(value))
|
this.productJudgeForm.enterprisename = form.enterprisename
|
this.productJudgeForm.enterprisenumber = form.enterprisenumber
|
this.productJudgeForm.punishmentmeasure = form.punishmentmeasure
|
this.productJudgeForm.punishmentreason = form.punishmentreason
|
this.productJudgeForm.id = form.id
|
}
|
},
|
async getEnterpriseList(){
|
let type = 1
|
let res= await getEnterprise(type)
|
if(res.data.code === '200'){
|
this.enterpriseList = res.data.result
|
}
|
},
|
async submit(){
|
const formData = new FormData();
|
for (const i in this.productJudgeForm) {
|
if (
|
this.productJudgeForm[i] != undefined &&
|
this.productJudgeForm[i].toString() != ""
|
) {
|
formData.append(i, this.productJudgeForm[i]);
|
}
|
}
|
const files1 = this.$refs["upload"].files;
|
if (files1 && files1.length > 0) {
|
for (let i = 0; i < files1.length; i++)
|
formData.append("file", files1[i]);
|
}
|
if(this.title === '新增'){
|
let res = await addProductJudge(formData)
|
if(res.data.code === '200'){
|
this.dialogVisible = false
|
this.$emit('getinfo')
|
this.$notify({
|
duration:2000,
|
type:'success',
|
title:'成功',
|
message:'新增成功'
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
}else{
|
let res = await updateProductJudge(formData)
|
if(res.data.code === '200'){
|
this.dialogVisible = false
|
this.$emit('getinfo')
|
this.$notify({
|
duration:2000,
|
type:'success',
|
title:'成功',
|
message:'修改成功'
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
}
|
},
|
giveEnterpriseNumber(){
|
for( let i = 0;i<this.enterpriseList.length;i++){
|
if(this.productJudgeForm.enterprisename === this.enterpriseList[i].enterprisename){
|
this.productJudgeForm.enterprisenumber = this.enterpriseList[i].enterprisenumber
|
console.log(this.productJudgeForm.enterprisenumber);
|
}
|
}
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
/deep/.el-input__inner {
|
width:400px;
|
}
|
/deep/textarea.el-textarea__inner{
|
width:400px;
|
}
|
</style>
|