| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- <template>
- <wrapper
- v-loading="loading"
- class="c-step"
- fill
- margin
- padding
- background
- >
- <div class="l-flex__none l-flex--row c-sibling-item--v u-color--black">
- <i
- class="l-flex__none c-sibling-item o-icon o-icon--hover el-icon-arrow-left u-pointer u-bold"
- @click="onBack"
- />
- <span
- v-if="title"
- class="c-sibling-item near u-font-size--md u-bold"
- >
- {{ title }}
- </span>
- </div>
- <status-wrapper
- v-if="loading || error"
- :error="error"
- @click="getWorkflow"
- />
- <template v-else>
- <template v-if="audit === 0">
- <div class="l-flex__none c-sibling-item--v">
- <schema-table :schema="schema" />
- </div>
- <div class="l-flex__fill l-flex c-sibling-item--v c-step">
- <div class="l-flex__none l-flex--col c-step__column u-width--md">
- <schema-table :schema="deviceSchema" />
- </div>
- <div class="l-flex__none l-flex--col c-step__column u-width--lg">
- <schema-table :schema="timeSchema" />
- </div>
- <template v-if="hasAssets">
- <div class="l-flex__fill l-flex--col c-step__column">
- <schema-table :schema="assetSchema" />
- </div>
- <preview-dialog ref="previewDialog" />
- </template>
- </div>
- </template>
- <div
- v-if="audit === 1"
- class="has-padding"
- >
- <el-result
- icon="success"
- title="审核成功"
- >
- <template slot="extra">
- <el-link
- type="primary"
- @click="onBack"
- >
- 返回列表
- </el-link>
- </template>
- </el-result>
- </div>
- <material-dialog ref="materialDialog" />
- <confirm-dialog
- ref="rejectDialog"
- title="驳回"
- @confirm="onConfirmReject"
- >
- <div class="c-grid-form u-align-self--center">
- <span class="c-grid-form__label">
- 审核意见
- </span>
- <el-select
- v-model="review.type"
- placeholder="请选择"
- >
- <el-option
- v-for="option in reviewOptions"
- :key="option.label"
- :label="option.label"
- :value="option.value"
- />
- </el-select>
- <template v-if="review.type === 'reject'">
- <span class="c-grid-form__label u-required">
- 原因
- </span>
- <el-input
- v-model.trim="review.reason"
- type="textarea"
- placeholder="请填写驳回原因"
- maxlength="50"
- :rows="3"
- resize="none"
- show-word-limit
- />
- </template>
- </div>
- </confirm-dialog>
- </template>
- </wrapper>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import {
- State,
- Access,
- WorkflowState,
- WorkflowStateInfo,
- PublishTargetType,
- EventTarget,
- AssetTagInfo,
- AssetTypeInfo
- } from '@/constant.js'
- import { parseDuration } from '@/utils'
- import { parseDeploy } from '../utils.js'
- import {
- getWorkflow,
- resolveWorkflow,
- rejectWorkflow,
- getAssetsByProgramSnap,
- getQrCodeStatus,
- updateQrCodeStatus
- } from '../api.js'
- import {
- QRCODE_STATUS,
- getTenantAttribute
- } from '@/views/realm/settings/api.js'
- export default {
- name: 'WorkflowAudit',
- data () {
- return {
- loading: true,
- error: false,
- workflow: null,
- audit: -1,
- deviceSchema: {
- nonPagination: true,
- props: {
- size: 'small'
- },
- list: this.getDevices,
- cols: [
- { prop: 'deviceName', label: '上播设备', 'show-overflow-tooltip': false }
- ]
- },
- timeSchema: {
- nonPagination: true,
- props: {
- size: 'small'
- },
- list: this.getTimes,
- cols: [
- { prop: 'time', label: '上播时间', 'show-overflow-tooltip': false }
- ]
- },
- assetSchema: {
- nonPagination: true,
- props: {
- size: 'small'
- },
- list: this.getAssets,
- cols: [
- { prop: 'tagInfo', label: '分类', width: 72, align: 'center' },
- { prop: 'typeInfo', label: '资源', width: 72, align: 'center' },
- { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
- { prop: 'name', label: '' },
- { prop: 'adDuration', label: '上播时长', width: 80, align: 'center' },
- { type: 'invoke', render: [
- { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
- ], width: 64 }
- ]
- },
- reviewOptions: [
- { value: 'reject', label: '驳回' },
- { value: '图文不符' },
- { value: '内容不合规' }
- ],
- review: {
- type: '',
- reason: ''
- },
- qrCodeType: '0',
- qrCodeStatus: 1,
- qrCodeStatusTimer: -1,
- qrCodeLoading: false
- }
- },
- computed: {
- ...mapGetters(['access']),
- id () {
- return this.$route.params.id
- },
- status () {
- const isFinal = this.access.has(Access.REVIEW_RELEASE_FINAL)
- if (__JUMP_REVIEW__ && isFinal) {
- return [WorkflowState.FIRST_LEVEL, WorkflowState.SECOND_LEVEL, WorkflowState.FINAL_LEVEL]
- }
- const arr = []
- if (isFinal) {
- arr.push(WorkflowState.FIRST_LEVEL)
- }
- if (this.access.has(Access.REVIEW_RELEASE_SECOND)) {
- arr.push(WorkflowState.SECOND_LEVEL)
- }
- if (this.access.has(Access.REVIEW_RELEASE_FIRST)) {
- arr.push(WorkflowState.FINAL_LEVEL)
- }
- return arr
- },
- title () {
- if (__JUMP_REVIEW__ && this.access.has(Access.REVIEW_RELEASE_FINAL)) {
- return '审核'
- }
- if (this.workflow) {
- return WorkflowStateInfo[this.workflow.currentSeveralReviewed]
- }
- return ''
- },
- isProgram () {
- if (this.workflow) {
- return this.workflow.options.publish === PublishTargetType.EVENT && this.workflow.options.event === EventTarget.PROGRAM
- }
- return false
- },
- isAssets () {
- if (this.workflow) {
- return this.workflow.options.publish === PublishTargetType.EVENT && this.workflow.options.event === EventTarget.ASSETS
- }
- return false
- },
- needView () {
- if (this.workflow) {
- return this.workflow.options.publish === PublishTargetType.CALENDAR || this.isProgram
- }
- return false
- },
- hasAssets () {
- return this.isProgram || this.isAssets
- },
- schema () {
- return {
- nonPagination: true,
- list: this.getList,
- cols: [
- { prop: 'priority', label: '优先级', width: 100, align: 'center' },
- { prop: 'type', label: '上播内容', width: 80, align: 'center' },
- { prop: 'name', label: '' },
- { prop: 'ratio', label: '适配', width: 120 },
- this.needMarketing && { prop: 'qrCodeStatus', label: '营销二维码状态', render: (data, h) => this.qrCodeStatus === 0
- ? h('el-tag', {
- key: 'success',
- staticClass: 'o-tag',
- props: {
- type: 'success',
- size: 'small',
- 'disable-transitions': true
- }
- }, '成功')
- : this.qrCodeLoading
- ? h('i', {
- key: 'loading',
- staticClass: 'u-height--sm el-icon-loading u-font-size--md'
- })
- : h('el-tag', {
- key: 'warning',
- staticClass: 'o-tag u-pointer',
- props: {
- type: 'warning',
- size: 'small',
- 'disable-transitions': true
- },
- on: {
- click: this.onQrCode
- }
- }, '未获取,点击重试'), width: 160, align: 'center' },
- { prop: 'user', label: '申请人', width: 160, align: 'center' },
- { type: 'invoke', render: [
- this.needView && { label: '查看', on: this.onView },
- { label: '通过', allow: () => !this.needMarketing || this.qrCodeStatus === 0, on: this.onResolve },
- { label: '驳回', on: this.onReject }
- ].filter(Boolean), width: 160 }
- ]
- }
- },
- workflowNodeId () {
- // 待审核节点
- return this.workflow?.nodes.find(({ status }) => status === State.SUBMITTED)?.id
- },
- needMarketing () {
- return this.qrCodeType === '1'
- }
- },
- created () {
- this.getWorkflow()
- },
- beforeDestroy () {
- clearTimeout(this.qrCodeStatusTimer)
- this.qrCodeStatusTimer = null
- },
- methods: {
- getQrCodeType () {
- return getTenantAttribute(QRCODE_STATUS, false).then(({ data }) => {
- if (data) {
- this.qrCodeType = data.attributeValue
- if (this.needMarketing) {
- this.qrCodeLoading = true
- this.getQrCodeStatus().finally(() => {
- this.qrCodeLoading = false
- })
- }
- }
- })
- },
- getQrCodeStatus () {
- return getQrCodeStatus(this.id).then(({ data }) => {
- this.qrCodeStatus = data
- })
- },
- getCodeStatusDelay (count) {
- this.getQrCodeStatus().finally(() => {
- if (this.qrCodeStatusTimer === null || count >= 3 || this.qrCodeStatus === 0) {
- this.qrCodeLoading = false
- return
- }
- this.qrCodeStatusTimer = setTimeout(() => {
- this.getCodeStatusDelay(count + 1)
- }, 5000)
- })
- },
- onQrCode () {
- this.qrCodeLoading = true
- updateQrCodeStatus(this.id).then(() => {
- this.getCodeStatusDelay(1)
- }, () => {
- this.qrCodeLoading = false
- })
- },
- getWorkflow () {
- this.loading = true
- this.error = false
- getWorkflow(this.id).then(({ data }) => {
- if (data.status === State.SUBMITTED && this.status.includes(data.currentSeveralReviewed)) {
- this.workflow = {
- id: data.id,
- user: data.createUser,
- currentSeveralReviewed: data.currentSeveralReviewed,
- nodes: data.workflowNodeDtoList,
- ...parseDeploy(data.businessData)
- }
- this.audit = 0
- return this.getQrCodeType()
- }
- this.$message({
- type: 'warning',
- message: '流程已结束或无审核权限'
- })
- this.onBack()
- return Promise.resolce()
- }).then(() => {
- this.loading = false
- }, () => {
- this.loading = false
- this.error = true
- })
- },
- getList () {
- return Promise.resolve({ data: [this.workflow] })
- },
- getDevices () {
- return Promise.resolve({ data: this.workflow.deviceList })
- },
- getTimes () {
- return Promise.resolve({ data: this.workflow.targetList })
- },
- onView ({ detail }) {
- this.$refs.materialDialog.showPublishTarget(detail)
- },
- getAssets () {
- if (this.isAssets) {
- const assets = this.workflow.detail.detail.target.sources.map(this.transformAsset)
- if (assets.length === 1) {
- assets[0].adDuration = '独占'
- }
- return Promise.resolve({ data: Object.freeze(assets) })
- }
- if (this.isProgram) {
- return getAssetsByProgramSnap(this.workflow.detail.detail.target.id).then(({ data }) => {
- return {
- data: data.map(this.transformAsset)
- }
- })
- }
- return Promise.resolve({ data: [] })
- },
- transformAsset ({ tag, type, keyName, name, originalName, duration }) {
- if (!type) {
- return {
- name: '资源已删除'
- }
- }
- return {
- tagInfo: AssetTagInfo[tag],
- typeInfo: AssetTypeInfo[type],
- file: {
- type,
- url: keyName
- },
- name: name || originalName,
- adDuration: parseDuration(duration)
- }
- },
- onViewAsset ({ file }) {
- this.$refs.previewDialog.show(file)
- },
- onBack () {
- this.$router.replace({ name: 'workflow-list' })
- },
- resolveWorkflow () {
- return resolveWorkflow(this.workflowNodeId)
- },
- onResolve () {
- this.$confirm(
- '审核通过?',
- '操作确认',
- { type: 'warning' }
- ).then(() => {
- this.resolveWorkflow().then(() => {
- this.audit = 1
- })
- })
- },
- onReject () {
- this.review = {
- type: 'reject',
- reason: ''
- }
- this.$refs.rejectDialog.show()
- },
- onConfirmReject (done) {
- const reason = this.review.type === 'reject' ? this.review.reason : this.review.type
- if (!reason) {
- this.$message({
- type: 'warning',
- message: '请选择或填写驳回原因'
- })
- return
- }
- rejectWorkflow(this.workflowNodeId, reason).then(() => {
- done()
- this.audit = 1
- })
- }
- }
- }
- </script>
|