<template>
|
<el-dialog
|
:visible.sync="permitFormVisible"
|
append-to-body
|
:title="title"
|
:close-on-click-modal="false"
|
width="600px"
|
>
|
<el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="140px" width="600px">
|
<el-form-item label="许可证编号:" prop="licensenumber" >
|
<el-input v-model="dataForm.licensenumber" width="150px"/>
|
</el-form-item>
|
<el-form-item label="许可证名字:" prop="licensename">
|
<el-input v-model="dataForm.licensename"/>
|
</el-form-item>
|
<el-form-item label="发证机关:" prop="authority">
|
<el-input v-model="dataForm.authority"/>
|
</el-form-item>
|
<el-form-item label="许可范围:" prop="ranges">
|
<el-input v-model="dataForm.ranges"/>
|
</el-form-item>
|
<!-- <el-form-item label="许可范围:" prop="ranges">-->
|
<!-- <template slot-scope="scope">-->
|
<!-- <img v-for="(item,index) in scope.row.enterprisesource"></img>-->
|
<!-- </template>-->
|
<!-- </el-form-item>-->
|
<el-form-item label="有效期:" prop="specification">
|
<el-date-picker
|
value-format="yyyy-MM-dd"
|
v-model="dataTime"
|
type="daterange"
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
@change="giveData"
|
>
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="证件照片:" prop="directionCode">
|
<input id="upload" ref="upload" type="file" accept="image/*" multiple/>
|
</el-form-item>
|
</el-form>
|
<div align="right">
|
<el-button @click="permitFormVisible = false">取消</el-button>
|
<el-button type="primary" @click="submitPermit()">确认</el-button>
|
</div>
|
</el-dialog>
|
|
</template>
|
|
<script>
|
import { getToken } from '@/utils/auth'
|
import { uploadUrl } from '@/assets/upload/url'
|
import { addPermitInformation ,updatePermitInformation } from "../../../../api/permitInformation";
|
|
export default {
|
name: "permitForm",
|
data(){
|
return{
|
title:'',
|
dataTime:['',''],
|
permitFormVisible:false,
|
uploadUrl,
|
header:{
|
'Authorization': getToken()
|
},
|
enterpriseId:'',
|
dataForm:{
|
authority: "",
|
file: [
|
],
|
id: 0,
|
imgids: [
|
],
|
licensename: "",
|
licensenumber: "",
|
ranges: "",
|
validendtime: "",
|
validstarttime: ""
|
},
|
dataFormRules:{
|
safetysupervision:[
|
{ required: true, message: '请填写许可证编号', trigger: 'blur' },
|
],
|
licensename:[
|
{ required: true, message: '请填写许可证名称', trigger: 'blur' },
|
],
|
},
|
pageSize: 10,
|
recordTotal: 0,
|
currentPage: 1,
|
pageTotal: 0,
|
dialogImageUrl: '',
|
dialogVisible: false,
|
disabled: false,
|
fileList:[],
|
uploadData:{
|
enterprise:1
|
},
|
}
|
},
|
methods:{
|
showPermitForm(title,value,enterpriseId){
|
// this.$refs["upload"].files = []
|
this.enterpriseId = enterpriseId
|
this.permitFormVisible = true
|
this.title = title
|
if(this.title === '新增'){
|
this.dataTime = ['','']
|
this.dataForm = {
|
authority: "",
|
file: [
|
],
|
id: 0,
|
imgids: [
|
],
|
licensename: "",
|
licensenumber: "",
|
ranges: "",
|
validendtime: "",
|
validstarttime: ""
|
}
|
}else{
|
this.dataForm.id = value.id
|
if(value.validstarttime === null && value.validendtime === null){
|
this.dateTime = ['','']
|
this.dataForm.validstarttime = ''
|
this.dataForm.validendtime = ''
|
}else{
|
if(value.validstarttime != null && value.validendtime != null){
|
this.dataTime = [value.validstarttime, value.validendtime]
|
this.dataForm.validstarttime = this.dataTime[0]
|
this.dataForm.validendtime = this.dataTime[1]
|
}else{
|
this.dateTime = ['','']
|
this.dataForm.validstarttime = ''
|
this.dataForm.validendtime = ''
|
}
|
}
|
this.dataForm.licensename = value.licensename
|
this.dataForm.licensenumber = value.licensenumber
|
this.dataForm.authority = value.authority
|
this.dataForm.ranges = value.ranges
|
for(let i = 0;i<value.enterpriseResources.length;i++){
|
this.dataForm.imgids.push(value.enterpriseResources[i].id)
|
}
|
}
|
},
|
async submitPermit(){
|
const formData = new FormData();
|
if(this.$refs["upload"].files.length === 0){
|
this.dataForm.imgids = []
|
}
|
for (const i in this.dataForm) {
|
if (
|
this.dataForm[i] != undefined &&
|
this.dataForm[i].toString() != ""
|
) {
|
formData.append(i, this.dataForm[i]);
|
}
|
}
|
formData.append("enterpriseid",this.enterpriseId)
|
|
const files1 = this.$refs["upload"].files;
|
if (files1 && files1.length > 0) {
|
for (let i = 0; i < files1.length; i++)
|
formData.append("file", files1[i]);
|
}
|
|
// formData.append("file", this.$refs["upload"].files);
|
if(this.title === '新增'){
|
let res = await addPermitInformation(formData)
|
if(res.data.code === "200"){
|
this.$refs["upload"].value = ''
|
this.$emit('getinfo')
|
this.permitFormVisible = false
|
this.$notify({
|
type:'success',
|
duration:2000,
|
message:'成功',
|
title:'成功',
|
})
|
}else {
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
}else{
|
let res = await updatePermitInformation(formData)
|
if(res.data.code === "200") {
|
this.$refs["upload"].value = ''
|
this.$emit('getinfo')
|
this.permitFormVisible = false
|
this.$notify({
|
type: 'success',
|
duration: 2000,
|
message: '成功',
|
title: '成功',
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
}
|
},
|
async getBasic(){
|
const params = {}
|
params['pageIndex'] = this.currentPage
|
params['pageSize'] = this.pageSize
|
let res = await getPicListData(params,{id:this.enterpriseId})
|
if (res.data.code === '200'){
|
this.form = res.data
|
}else {
|
parseError({ error: res.message, vm: _this })
|
}
|
},
|
async getPicList(){
|
this.fileList = []
|
const params = {}
|
params['pageIndex'] = this.currentPage
|
params['pageSize'] = this.pageSize
|
let res = await getPicListData(params,{id:this.enterpriseId})
|
if (res.data.code == 200){
|
if (res.data != null){
|
for (let i=0;i<res.data.result.records.length;i++){
|
this.fileList.push({id:res.data.result.records[i].enterpriseResources[0].id, url: "http://192.168.0.7:8100/upload/enterprise/" + res.data.result.records[i].enterpriseResources[0].url})
|
}
|
}else {
|
parseError({ error: res.message, vm: _this })
|
}
|
}
|
}, // 获取已上传的附件列表
|
async onPreview(file) {
|
window.open(file.url, '_blank')
|
},// 点击附件
|
beforeUpload() {
|
if (this.uploadData.fileType == '') {
|
this.$message({
|
type: 'info',
|
message: '请选择要上传的附件类型'
|
})
|
return false
|
}
|
},
|
onSuccess(response, file, fileList) {
|
if (response.code == 200) {
|
this.$notify({
|
title: '成功',
|
message: '上传成功',
|
type: 'success',
|
duration: 2000
|
})
|
}
|
},
|
beforeRemove(file, fileList) {
|
return this.$confirm(`确定移除 ${file.name}?`);
|
},
|
async onRemove(file, fileList) {
|
if (file.status == "success"){
|
let res = await deletePicData(file.id)
|
if (res.data.code == 200){
|
this.$notify({
|
title: '成功',
|
message: '删除成功',
|
type: 'success',
|
duration: 2000
|
})
|
this.getPicListData()
|
} else {
|
this.$message({
|
message: res.msg,
|
type: 'warning'
|
});
|
}
|
}
|
},
|
uploadFiles(){
|
this.$refs.upload.submit()
|
},
|
giveData(){
|
if(this.dataTime ===null){
|
this.dataForm.validstarttime = ""
|
this.dataForm.validendtime = ""
|
}else{
|
this.dataForm.validstarttime = this.dataTime[0]
|
this.dataForm.validendtime = this.dataTime[1]
|
}
|
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
/deep/ .el-input__inner {
|
width:300px;
|
}
|
</style>
|