123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- <template>
- <div class="create-container">
- <div class="create-body" v-loading="loading" style="width: 100%">
- <div class="title">测评机构认证</div>
- <el-form :model="authentication" :rules="rules" ref="authentication" label-width="12%" class="demo-report">
- <el-form-item prop="agencyPhoto" label="机构logo">
- <el-upload
- v-if="isModifyMode"
- class="avatar-uploader"
- action=""
- :show-file-list="false"
- :http-request="uploadFile"
- :before-upload="beforeFileUpload">
- <img v-if="authentication.agencyPhoto" :src="authentication.agencyPhoto" class="avatar">
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- <span v-if="!isModifyMode">
- <el-image
- style="width: 100px;"
- :src="authentication.agencyPhoto"
- fit="scale-down"></el-image>
- </span>
- </el-form-item>
- <el-form-item label="机构名称" prop="evaluationAgencyName">
- <el-input v-if="isModifyMode" v-model="authentication.evaluationAgencyName"></el-input>
- <span v-if="!isModifyMode">{{authentication.evaluationAgencyName}}</span>
- </el-form-item>
- <!--<el-form-item label="机构电话" prop="name">-->
- <!--<el-input v-if="isModifyMode" v-model="authentication.mobile"></el-input>-->
- <!--<!–<span v-if="!isModifyMode">{{authentication.name}}</span>–>-->
- <!--</el-form-item>-->
- <el-form-item v-if="!isModifyMode" label="认证状态" prop="name">
- <el-tag :type="authentication.authStatus.style">{{authentication.authStatus.text}}</el-tag>
- </el-form-item>
- <el-form-item v-if="!isModifyMode && authentication.authStatus.text == '认证失败'" label="失败原因" prop="name">
- <el-link v-if="authentication.explain!=null&&authentication.explain!=''" type="danger" disabled>
- {{authentication.explain}}
- </el-link>
- <el-link v-if="authentication.explain==null || authentication.explain==''" type="danger" disabled>管理员未填写
- </el-link>
- </el-form-item>
- <el-form-item label="对公账户" prop="bankAccount">
- <el-input v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
- <span v-if="!isModifyMode">{{authentication.bankAccount}}</span>
- </el-form-item>
- <el-form-item label="地址" prop="address">
- <el-input v-if="isModifyMode" v-model="authentication.address"></el-input>
- <span v-if="!isModifyMode">{{authentication.address}}</span>
- </el-form-item>
- <el-form-item label="测评机构能力" prop="evaluationAgencyAbilityList">
- <el-checkbox-group v-if="isModifyMode" v-model="authentication.evaluationAgencyAbilityList">
- <span v-for="(item,index) in serviceTypes" :key="index">
- <el-checkbox :label="item" name="type">{{item}} </el-checkbox>
- </span>
- </el-checkbox-group>
- <span v-if="!isModifyMode" v-for="(item,index) in authentication.evaluationAgencyAbilityList"
- :key="index"><span class="badge">{{item}}</span></span>
- </el-form-item>
- <el-form-item label="测评机构资源" prop="evaluationAgencyResourceList">
- <span v-if="isModifyMode" v-for="item in authentication.evaluationAgencyResourceList" :key="item.id"
- style="width: 2000px">
- 资源类型: <el-select v-model="item.type" placeholder="请选择" style="width: 15%;margin-bottom: 10px"
- :value="item.type">
- <el-option
- v-for="item in resourceTypes"
- :key="item"
- :label="item"
- :value="item">
- </el-option>
- </el-select>
- 资源名称: <el-input v-model="item.name" style="width: 15%"></el-input>
- 总量: <el-input-number :min="0" v-model="item.totalNum" style="width: 15%"></el-input-number>
- 可用数量: <el-input-number :min="0" :max="item.totalNum" style="width: 15%"
- v-model="item.availableNum"></el-input-number>
- <el-button type="danger" icon="el-icon-delete" @click="removeAgencyResource(item.id)"></el-button>
- <br/>
- </span>
- <el-button v-if="isModifyMode" type="primary" icon="el-icon-circle-plus" plain size="small"
- @click="addAgencyResource">添加资源
- </el-button>
- <span v-if="!isModifyMode" v-for="item in authentication.evaluationAgencyResourceList" :key="item.id">
- 资源类型:{{item.type}}; 资源名称:{{item.name}}; 资源总量:{{item.totalNum}}; 可用资源:{{item.availableNum}}<br/>
- </span>
- </el-form-item>
- <el-form-item v-if="!isModifyMode">
- <div class="btn btn-medium btn-info" @click="modifyInfo()">修改</div>
- </el-form-item>
- <el-form-item v-if="isModifyMode">
- <div class="btn btn-primary btn-info" @click="updateAuthInfo()">提交</div>
- <div class="btn btn-primary" @click="cancelModify()">取消</div>
- </el-form-item>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- import Http from '@/js/http'
- import Apis from '@/js/api'
- import {notify} from '@/constants/index'
- import {
- defaultValue,
- getAllAgencyResourceTypes,
- getAllServiceTypes,
- getCurrentAgencyAuthInfo,
- getCurrentAuthenInfo,
- getCurrentUser,
- getRolesPermissions,
- storageGet,
- storageSave,
- updateAgencyAuthInfo
- } from '@/js/index'
- export default {
- name: 'AgencyAuthentication',
- data () {
- return {
- userId: 0,
- user: {},
- loading: false,
- isModifyMode: false,
- resourceTypes: [],
- serviceTypes: [],
- authentication: {
- mobile: '',
- evaluationAgencyName: '',
- bankAccount: '',
- address: '',
- evaluationAgencyAbilityList: [],
- evaluationAgencyResourceList: [],
- photo: [],
- authStatus: {},
- agencyPhoto: defaultValue.image,
- explain: ''
- },
- rules: {
- // agencyPhoto: [
- // {required: true, message: '请输入机构名称', trigger: 'blur'},
- // { min: 3, max: 50, message: "机构名称长度在 3 到 50 个字符", trigger: "blur" }
- // ],
- evaluationAgencyName: [
- {required: true, message: '请输入机构名称', trigger: 'blur'},
- {min: 3, max: 50, message: '机构名称长度在 3 到 50 个字符', trigger: 'blur'}
- ],
- bankAccount: [
- {required: true, message: '请输入银行卡账户', trigger: 'blur'},
- {
- validator: (rule, value, callback) => {
- if (!this.checkNumber(value)) {
- callback(new Error('银行卡账户输入有误'))
- } else {
- callback()
- }
- }, trigger: 'blur'
- },
- ],
- address: [
- {required: true, message: '请输入地址', trigger: 'blur'}
- ],
- evaluationAgencyAbilityList: [
- {
- type: 'array',
- required: true,
- message: '请至少选择一种服务类型',
- trigger: 'change'
- }
- ],
- evaluationAgencyResourceList: [
- {
- validator: (rule, value, callback) => {
- var isError = false
- if (value == null || value.length == 0) {
- callback(new Error('机构资源不可为空'))
- } else {
- for (var i = 0; i < value.length; i++) {
- if (value[i].name == '') {
- isError = true
- break
- }
- }
- }
- if (isError) {
- callback(new Error('资源名称不可为空'))
- } else {
- callback()
- }
- }, trigger: 'blur'
- },
- ],
- }
- }
- },
- mounted () {
- this.$nextTick(() => {
- this.init()
- })
- },
- methods: {
- //初始化数据
- init () {
- this.setServiceTypes()
- this.setResourceTypes()
- this.setUserInfo()
- this.getAuthInfo()
- },
- //加载数据
- getAuthInfo () {
- this.showLoading()
- getCurrentAgencyAuthInfo(this.user.userVO.id, this.getAuthInfoSuccess, this.getAuthInfoFail)
- },
- getAuthInfoSuccess (res) {
- this.hideLoading()
- this.authentication.agencyPhoto = res.agencyPhoto == null ? defaultValue.image : res.agencyPhoto
- this.authentication.evaluationAgencyName = res.evaluationAgencyName == null ? '暂未填写' : res.evaluationAgencyName
- this.authentication.evaluationAgencyAbilityList = res.evaluationAgencyAbilityList == null ? [] : res.evaluationAgencyAbilityList
- this.authentication.evaluationAgencyResourceList = res.evaluationAgencyResourceList == null ? [] : res.evaluationAgencyResourceList
- this.authentication.bankAccount = res.bankAccount == null ? '暂未填写' : res.bankAccount
- this.authentication.address = res.address == null ? '暂未填写' : res.address
- this.authentication.authStatus = res.authStatus
- this.authentication.explain = res.explain
- console.log(this.authentication)
- },
- getAuthInfoFail (error) {
- this.hideLoading()
- notify('error', '加载认证信息失败:' + error.data)
- },
- //表单进入可编辑状态,可修改表单,不再使用
- modifyInfo () {
- this.isModifyMode = true
- },
- //提交认证信息
- updateAuthInfo () {
- //this.isModifyMode = false
- this.$refs['authentication'].validate(valid => {
- if (valid) {
- this.showLoading()
- const newAuthentication = {
- userId: this.user.userVO.id,
- evaluationAgencyName: this.authentication.evaluationAgencyName,
- bankAccount: this.authentication.bankAccount,
- address: this.authentication.address,
- evaluationAgencyAbilityList: this.authentication.evaluationAgencyAbilityList,
- evaluationAgencyResourceList: this.authentication.evaluationAgencyResourceList,
- agencyPhoto: this.authentication.agencyPhoto,
- }
- //console.log(newAuthentication)
- updateAgencyAuthInfo(this.user.userVO.id, newAuthentication, this.updateAuthInfoSuccess, this.updateAuthInfoFail)
- } else {
- notify('error', '表单填写错误!')
- return false
- }
- })
- },
- updateAuthInfoSuccess (res) {
- console.log(res)
- this.hideLoading()
- this.cancelModify()
- notify('success', '认证信息修改成功,正在为您刷新用户信息')
- getCurrentUser().then(res => {
- storageSave('user', res)
- this.user = res
- this.sendBusMessage()
- //this.rolesPermissions = getRolesPermissions(res.roleList)
- storageSave('rolesPermissions', getRolesPermissions(res.roleList))
- this.hideLoading()
- notify('success', '用户信息刷新成功')
- }).catch((error) => {
- this.hideLoading()
- notify('error', '重新获取用户信息失败:' + error.data)
- })
- },
- updateAuthInfoFail (error) {
- this.hideLoading()
- notify('error', error.data)
- },
- //取消修改表单,表单进入不可编辑状态,不再使用
- cancelModify () {
- this.isModifyMode = false
- this.getAuthInfo()
- },
- //上传文件时移除文件的响应函数
- handleRemove (file, fileList) {
- console.log(file, fileList)
- },
- //添加文件时的响应函数
- handleExceed (files, fileList) {
- this.$message.warning(
- `当前限制选择 1 个文件,本次选择了 ${
- files.length
- } 个文件,共选择了 ${files.length + fileList.length} 个文件`
- )
- },
- //移除文件前的响应函数
- beforeRemove (file, fileList) {
- //return this.$confirm(`确定移除 ${file.name}?`)
- },
- //文件上传前的响应函数
- beforeFileUpload () {
- },
- //上传文件,此处为上传图片
- uploadFile (param) {
- const formData = new FormData()
- let config = {
- //添加请求头
- headers: {'Content-Type': 'multipart/form-data'},
- }
- formData.append('file', param.file)
- Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
- console.log('上传成功')
- this.authentication.agencyPhoto = res.data
- console.log(res.data)
- notify('success', '上传成功')
- }).catch(error => {
- notify('error', error.data.msg)
- })
- },
- //设置服务类型
- setServiceTypes () {
- getAllServiceTypes().then((res) => {
- this.serviceTypes = res
- }).catch((error) => {
- notify('error', '机构能力加载失败')
- })
- },
- //设置机构资源类型
- setResourceTypes () {
- this.resourceTypes = getAllAgencyResourceTypes()
- },
- //添加一项测评机构资源
- addAgencyResource () {
- const tmpResource = {
- id: this.authentication.evaluationAgencyResourceList.length,
- type: this.resourceTypes[0],
- name: '',
- totalNum: 0,
- availableNum: 0,
- }
- this.authentication.evaluationAgencyResourceList.push(tmpResource)
- },
- //删除一项测评机构资源
- removeAgencyResource (id) {
- this.authentication.evaluationAgencyResourceList.splice(id, 1)
- for (var i = 0; i < this.authentication.evaluationAgencyResourceList.length; i++) {
- this.authentication.evaluationAgencyResourceList[i].id = i
- }
- },
- //检测测评机构资源填写是否有效
- checkAgencyResourceVaild () {
- if (this.authentication.evaluationAgencyResourceList.length === 0) {
- return true
- }
- for (var i = 0; i < this.authentication.evaluationAgencyResourceList.length; i++) {
- const item = this.authentication.evaluationAgencyResourceList[i]
- if (item.type === '') {
- notify('error', '资源类型不能为空')
- return false
- }
- if (item.name === '') {
- notify('error', '资源名称不能为空')
- return false
- }
- if (item.totalNum < item.availableNum) {
- notify('error', '资源总数量不能低于可用数量')
- return false
- }
- }
- return true
- },
- //
- setUserInfo () {
- this.user = storageGet('user')
- },
- //
- showLoading () {
- this.loading = true
- },
- hideLoading () {
- this.loading = false
- },
- submitSuccess () {
- },
- sendBusMessage () {
- this.$root.$emit('user', this.user)
- },
- checkNumber (value) {
- return /^\d+$/.test(value)
- },
- },
- created: function () {
- }
- }
- </script>
- <style scoped>
- .el-radio {
- margin: 10px 20px 10px 0;
- }
- .el-form-item /deep/ .el-tabs__content {
- max-height: 120px !important;
- overflow: auto;
- }
- .el-row {
- margin-bottom: 10px;
- }
- .el-input {
- width: 400px;
- }
- .avatar-uploader .el-upload {
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
- cursor: pointer;
- position: relative;
- overflow: hidden;
- }
- .avatar-uploader .el-upload:hover {
- border-color: #409EFF;
- }
- .avatar-uploader-icon {
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
- font-size: 28px;
- color: #8c939d;
- width: 176px;
- height: 178px;
- line-height: 178px;
- text-align: center;
- }
- .avatar-uploader-icon:hover {
- border-color: #409EFF;
- }
- .avatar {
- width: 178px;
- height: 178px;
- display: block;
- }
- </style>
|