Files
laws-sinotruk-client/src/views/standardRegulationLibrary/commonPage/StandardDetailPage.vue
T

235 lines
7.7 KiB
Vue

<template>
<div class="detail-page">
<a-spin :spinning="loading">
<div class="detail-page-title">{{ pageTitle }}{{ $t('details') }}</div>
<div class="detail-page-part" v-for="(part, index) in partList" :key="part + index">
<div class="detail-page-part-title">
<span>{{ part }}</span>
<div class="detail-page-part-title-operate-box" v-if="index === 0">
<!-- 更新记录-->
<a-button type="link" @click="handleOpenUpdateRecord" v-has="btnPermission.updateRecord">
<i class="iconfont icon-root-list" />
{{ $t('standardRegulationLibrary.updateRecord') }}
</a-button>
<!-- 提交问题-->
<a-button type="link" @click="submitQuestion" v-has="btnPermission.submitQuestion">
<a-icon type="database" />
{{ $t('standardRegulationLibrary.submitQuestion') }}
</a-button>
<!-- 分享-->
<a-button type="link" @click="handleShare" v-has="btnPermission.share">
<i class="iconfont icon-share-internal" />{{ $t('share') }}
</a-button>
</div>
</div>
<div class="detail-page-part-form" v-if="index !== 3">
<div class="detail-page-part-form-item" v-for="formItem in form[part]" :key="formItem.id">
<label>{{ formItem.dbFieldTxt }}</label>
<span>{{ detailData[formItem.dbFieldName] }}</span>
</div>
</div>
<!-- 过程稿件特殊处理-->
<div class="detail-page-process-manuscript" v-if="index === 3">
<div class="detail-page-process-manuscript-item" v-for="formItem in form[part]" :key="formItem.id">
<div class="detail-page-process-manuscript-title">
<span>{{ formItem.dbFieldTxt }}</span>
<!-- 标准分解单-->
<a-button type="primary" ghost icon="file-text" @click="previewStandardResolutionSheet" v-has="btnPermission.standardResolutionSheet">
{{ $t('standardRegulationLibrary.standardResolutionSheet') }}
</a-button>
</div>
<div class="detail-page-process-manuscript-file" v-for="file in detailData[formItem.dbFieldName]" :key="file.id">
<div class="detail-page-process-manuscript-file-info">
<a-icon type="link" />
<div class="detail-page-process-manuscript-file-name">{{ file.fileName }}</div>
</div>
<div class="detail-page-process-manuscript-file-operate">
<!-- 下载-->
<a-button type="link" icon="download" v-has="btnPermission.download">{{ $t('download') }}</a-button>
<!-- 无水印下载-->
<a-button type="link" v-has="btnPermission.unwatermarkedDownload">
<i class="iconfont icon-water-drop-slash"></i>
{{ $t('unwatermarkedDownload') }}
</a-button>
</div>
</div>
</div>
</div>
</div>
</a-spin>
<!-- 更新记录-->
<upload-record-modal ref="uploadRecordModal" />
<!-- 提交问题-->
<submit-question-modal ref="submitQuestionModal" />
<!-- 分享选人-->
<user-select-modal ref="userSelectModal" type="checkbox" @change="continueShare" />
<!-- 标准分解单-->
<standard-resolution-sheet-modal ref="standardResolutionSheetModal" />
</div>
</template>
<script>
import '@assets/less/common.less'
import { TagsTypeEnums } from '../../../enums/commonEnums'
import { getDomesticStandardFormModal, shareDomesticStandard, getDomesticStandardDetail } from '../../../api/standardRegulationLibraryApi'
import UploadRecordModal from './modules/UploadRecordModal.vue'
import SubmitQuestionModal from './modules/SubmitQuestionModal.vue'
import UserSelectModal from '../../../components/selection/UserSelectModal.vue'
import StandardResolutionSheetModal from './modules/StandardResolutionSheetModal.vue'
// 国内标准权限
const DomesticStandardPermission = {
updateRecord: 'domesticStandard:updateRecord', // 更新记录
submitQuestion: 'domesticStandard:submitQuestion', // 提交问题
share: 'domesticStandard:share', // 分享
standardResolutionSheet: 'domesticStandard:standardResolutionSheet', // 标准分解单
download: 'domesticStandard:download', // 下载
unwatermarkedDownload: 'domesticStandard:unwatermarkedDownload' // 无水印下载
}
// 国内标准接口
const DomesticApi = {
getFormFunc: getDomesticStandardFormModal, // 获取字段
getDetailData: getDomesticStandardDetail // 获取详情数据
}
export default {
name: 'StandardDetailPage',
components: { UploadRecordModal, SubmitQuestionModal, UserSelectModal, StandardResolutionSheetModal },
data () {
return {
loading: false,
partList: [], // 页面模块列表
form: {}, // 页面字段
// 页面数据
detailData: {
// 修改单
modification_list: [],
// 报批稿
draft_for_review: [],
// 送审稿
draft_for_approval: [],
// 征求意见稿
draft_for_comment: [],
// 草案
draft: []
}
}
},
computed: {
// 页面标题
pageTitle () {
return TagsTypeEnums.nameOfIndex(this.$route.query.type)
},
// 按钮权限
btnPermission () {
let permission = {}
switch (this.$route.query.type) {
// 国内标准法规
case TagsTypeEnums.DOMESTIC_LIST.value + '':
permission = DomesticStandardPermission
break
default:
break
}
return permission
},
// 操作接口
operateApiFunc () {
let func = {}
switch (this.$route.query.type) {
case TagsTypeEnums.DOMESTIC_LIST.value + '':
func = DomesticApi
break
default:
break
}
return func
}
},
created () {
this.initForm()
this.initDetailData()
},
methods: {
/**
* 获取页面字段
*/
initForm () {
this.operateApiFunc.getFormFunc().then(res => {
if (res.success) {
const data = res.result || {}
this.partList = Object.keys(data)
this.form = data
} else {
this.$message.warn(res.message)
}
})
},
// 获取数据
initDetailData () {
this.loading = true
this.operateApiFunc.getDetailData({ id: this.$route.query.id }).then(res => {
if (res.success) {
this.detailData = Object.assign({}, res.result || {})
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.loading = false
})
},
/**
* 更新记录
*/
handleOpenUpdateRecord () {
this.$refs.uploadRecordModal.open()
},
/**
* 提交问题
*/
submitQuestion () {
this.$refs.submitQuestionModal.open()
},
/**
* 分享
*/
handleShare () {
this.$refs.userSelectModal.open()
},
/**
* 选择分享的人之后继续分享
* @param ids
*/
continueShare (ids) {
const params = {
id: this.$route.query.id, // 要分享的标准的id
recipientId: ids // 分享给的用户的id
}
this.loading = true
shareDomesticStandard(params).then(res => {
if (res.success) {
this.$message.success(res.message)
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.loading = false
})
},
/**
* 查看标准分解单
*/
previewStandardResolutionSheet () {
this.$refs.standardResolutionSheetModal.open()
}
}
}
</script>
<style scoped lang="less">
</style>