<template>
|
<GlobalWindow
|
:title="title"
|
width="50%"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="confirm"
|
>
|
<el-form :model="form" ref="form" :rules="rules">
|
<el-form-item label="授权账号" prop="userId">
|
<el-select v-model="form.userId" filterable placeholder="请选择">
|
<el-option
|
v-for="item in account"
|
:key="item.id"
|
:label="item.username"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="申请授权企业" prop="companyIds">
|
<el-select
|
v-model="form.companyIds"
|
multiple
|
filterable
|
allow-create
|
default-first-option
|
placeholder="请选择">
|
<el-option
|
v-for="item in company"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="申请说明" prop="content">
|
<el-input
|
type="textarea"
|
placeholder="请输入申请说明"
|
v-model="form.content"
|
maxlength="300"
|
show-word-limit />
|
</el-form-item>
|
<el-form-item label="授权书" prop="multifileList">
|
<UploadFile @remove="deleFile" :limit="99" :uploadData="{ folder: 'companyUserApply', fileType:'.pdf' }" :fileList="fileList" @uploadSuccess="editFanganFile" />
|
</el-form-item>
|
</el-form>
|
</GlobalWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import GlobalWindow from '@/components/common/GlobalWindow'
|
import UploadFile from '@/components/common/UploadFile'
|
import { findUserList } from '@/api/system/user'
|
import { findAllCompanyList } from '@/api/business/company'
|
export default {
|
name: 'OperaCompanyUserApplyWindow',
|
extends: BaseOpera,
|
components: { GlobalWindow, UploadFile },
|
data () {
|
return {
|
// 表单数据
|
form: {
|
id: null,
|
userId: '',
|
content: '',
|
companyIds: [],
|
multifileList: []
|
},
|
// 验证规则
|
rules: {
|
multifileList: [
|
{ required: true, message: '请上传授权书' }
|
],
|
companyIds: [
|
{ required: true, message: '请选择授权企业' }
|
],
|
userId: [
|
{ required: true, message: '请选择授权账号' }
|
]
|
},
|
account: [],
|
fileList: [],
|
company: []
|
}
|
},
|
created () {
|
this.config({
|
api: '/business/companyUserApply',
|
'field.id': 'id'
|
})
|
},
|
methods: {
|
__confirmCreate () {
|
this.$refs.form.validate((valid) => {
|
if (!valid) {
|
return
|
}
|
let obj = JSON.parse(JSON.stringify(this.form))
|
obj.companyIds = obj.companyIds.join(',')
|
obj.companyNames = []
|
this.form.companyIds.forEach(item => {
|
this.company.forEach(row => {
|
if (item === row.id) {
|
obj.companyNames.push(row.name)
|
}
|
})
|
})
|
obj.companyNames = obj.companyNames.join(',')
|
this.isWorking = true
|
this.api.create(obj)
|
.then(() => {
|
this.visible = false
|
this.$tip.apiSuccess('新建成功')
|
this.$emit('success')
|
})
|
.catch(e => {
|
this.$tip.apiFailed(e)
|
})
|
.finally(() => {
|
this.isWorking = false
|
})
|
})
|
},
|
// 确认修改
|
__confirmEdit () {
|
this.$refs.form.validate((valid) => {
|
if (!valid) {
|
return
|
}
|
let obj = JSON.parse(JSON.stringify(this.form))
|
obj.companyIds = obj.companyIds.join(',')
|
obj.companyNames = []
|
this.form.companyIds.forEach(item => {
|
this.company.forEach(row => {
|
if (item === row.id) {
|
obj.companyNames.push(row.name)
|
}
|
})
|
})
|
obj.companyNames = obj.companyNames.join(',')
|
this.isWorking = true
|
this.api.updateById(obj)
|
.then(() => {
|
this.visible = false
|
this.$tip.apiSuccess('修改成功')
|
this.$emit('success')
|
})
|
.catch(e => {
|
this.$tip.apiFailed(e)
|
})
|
.finally(() => {
|
this.isWorking = false
|
})
|
})
|
},
|
open (title, target) {
|
this.title = title
|
this.visible = true
|
this.getAccount()
|
this.getFindAllCompanyList()
|
// 新建
|
if (target == null) {
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.form[this.configData['field.id']] = null
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
for (const key in this.form) {
|
this.form[key] = target[key]
|
}
|
})
|
},
|
deleFile (imgaddr) {
|
this.form.multifileList.forEach((item, index) => {
|
if (item.imgaddr === imgaddr) {
|
this.form.multifileList.splice(index, 1)
|
}
|
})
|
},
|
editFanganFile (data) {
|
this.form.multifileList.push(data)
|
},
|
getAccount() {
|
findUserList({})
|
.then(res => {
|
console.log(res)
|
this.account = res
|
})
|
},
|
getFindAllCompanyList() {
|
findAllCompanyList({})
|
.then(res => {
|
console.log(res)
|
this.company = res
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.list {
|
width: 100%;
|
padding: 10px 16px;
|
box-sizing: border-box;
|
background: #F4F7FC;
|
border-radius: 2px;
|
border: 1px solid #DFE2E8;
|
margin-top: 10px;
|
.list_label {
|
font-weight: 400;
|
font-size: 13px;
|
color: #333333;
|
}
|
.list_box {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
flex-wrap: wrap;
|
.list_box_row {
|
padding: 0 10px;
|
box-sizing: border-box;
|
background: #FFFFFF;
|
border-radius: 2px;
|
display: flex;
|
align-items: center;
|
margin-right: 10px;
|
&:last-child {
|
margin: 0 !important;
|
}
|
span {
|
font-weight: 400;
|
font-size: 12px;
|
color: #3F4F69;
|
margin-right: 12px;
|
}
|
i {
|
color: #BFC3CB;
|
cursor: pointer;
|
}
|
}
|
}
|
}
|
</style>
|