Files
laws-sinotruk-client/src/views/workCenter/enterpriseStandardRevision/modules/OtherDrafterUploadStandardBaseInfo.vue
T

238 lines
7.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div>
<base-info-form ref="baseInfoForm" v-bind="$attrs" disabled></base-info-form>
<!-- 标准文本 -->
<div class="box-title-text form-flex-item">
<div class="title-text">
<span class="title-text-text" :title="$t('workCenter.enStandardRevision.standardText')">
{{ $t('workCenter.enStandardRevision.standardText') }}
</span>
</div>
<a-form-model-item class="item-model">
<div class="online-edit-wrapper">
<p>{{ $t('enterpriseStandard') }}</p>
<a-button type="primary" @click="toOnlineEditor">{{ $t('workCenter.enStandardRevision.onLineEditing') }}</a-button>
</div>
</a-form-model-item>
</div>
<div>
<j-table
:can-drag="true"
:scroll="{x: '100%'}"
ref="table"
rowKey="uid"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
@change="handleTableChange">
<!-- 起草人 -->
<!--<template slot="user" slot-scope="{record, text}">-->
<!-- <a-tooltip overlay-class-name="tooltip-style">-->
<!-- <template slot="title">{{ record.operateType === '2' ? '我' : (text || global.emptyLine) }}</template>-->
<!-- <div class="table-text">{{ record.operateType === '2' ? '我' : (text || global.emptyLine) }}</div>-->
<!-- </a-tooltip>-->
<!--</template>-->
<!-- 操作栏 -->
<div slot="action" slot-scope="{record}" class="action-span-cell">
<!-- 上传企标 只能上传分配给自己的上传企标,到期未上传跳过该起草人,操作列表显示- -->
<a v-if="record.operateType !== '1'"
@click="handleUploadStandard(record)"
class="table-ope-btn"
:disabled="disabled"
>
{{ $t('workCenter.enStandardRevision.uploadStandard') }}
</a>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</div>
</j-table>
</div>
<!-- 上传文件弹框 -->
<upload-file ref="uploadFile" @change="uploadFileChange" :multiple="false" :number="1" :return-url="false" :disabled="disabled"></upload-file>
</div>
</template>
<script>
import JTable from '@/components/jero/JTable'
import BaseInfoForm from './BaseInfoForm'
import UploadFile from '@/components/UploadFile'
import Vue from 'vue'
import { USER_INFO } from '@/store/mutation-types'
import { onlineEditor } from '../../../../utils/onlyOfficeUtils'
export default {
name: 'OtherDrafterUploadStandardBaseInfo',
components: { BaseInfoForm, JTable, UploadFile },
props: {
disabled: {
type: Boolean,
required: false,
default: false
}
},
data () {
return {
/* 分页参数 */
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '30', '50', '100', '150', '200'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + this.$t('total') + total + this.$t('strip')
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
columns: [
{ // 起草单位
title: this.$t('workCenter.enStandardRevision.draftingUnit'),
align: 'center',
width: 200,
dataIndex: 'dept_dictText',
scopedSlots: { customRender: 'text' }
},
{ // 起草人
title: this.$t('workCenter.enStandardRevision.drafter'),
align: 'center',
width: 200,
dataIndex: 'user_dictText',
scopedSlots: { customRender: 'text' }
},
{ // 起草范围
title: this.$t('workCenter.enStandardRevision.draftingScope'),
align: 'center',
width: 200,
dataIndex: 'scope',
scopedSlots: { customRender: 'text' }
},
{ // 截止日期
title: this.$t('expirationDate'),
align: 'center',
width: 200,
dataIndex: 'deadline',
scopedSlots: { customRender: 'text' }
},
{ // 操作
title: this.$t('operation'),
scopedSlots: { customRender: 'action' },
align: 'center',
// fixed: 'right',
width: 200
}
],
dataSource: [],
loading: false,
userInfo: {}, // 当前登录人信息
currentDate: '',
uploadUid: undefined, // 正在上传企标的行uid
onEditFile: '' // 在线编辑的文件
}
},
mounted () {
this.userInfo = Vue.ls.get(USER_INFO)
this.currentDate = new Date().getFullYear() + '-' + new Date().getMonth() + '-' + new Date().getDate()
},
methods: {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) {
// 给表格赋值
this.dataSource = data.otherDraftUserVOS.map(item => {
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
return {
uid: uidGenerator(),
...item
}
})
this.onEditFile = data.onEditFile
// 给表单赋值
this.$nextTick(() => {
this.$refs.baseInfoForm.initData(data)
})
},
// 外层要获取数据
getData () {
// 把数据抛出
const data = {}
data.otherDraftUserVOS = this.dataSource
data.businessJson = JSON.stringify(this.$refs.baseInfoForm.getData())
return data
},
// 外层获取数据要过校验,返回false表示没有通过校验
getDataValidate () {
let data = {}// 需要返回的值
if (this.dataSource && this.dataSource.length > 0) {
// 看能上传企标的行是否都上传了
let hasErr = false
for (const item of this.dataSource) {
if (item.operateType !== '1' && !item.fileId) {
// 需要上传企标,但是没有企标文件
hasErr = true
}
}
// 根据hasErr看有没有通过校验
if (hasErr) {
this.$message.warning(this.$t('workCenter.enStandardRevision.pleaseUploadStandard'))
data = false
} else {
data.otherDraftUserVOS = this.dataSource
}
} else {
data = false
}
return data
},
handleTableChange (pagination) {
this.ipagination = pagination
},
// 上传企标
handleUploadStandard (record) {
this.$refs.uploadFile.open(record.fileId)
this.uploadUid = record.uid
},
// 上传企标后的回调
uploadFileChange (data) {
const attIdList = []
if (data && data.length > 0) {
data.map(item => {
attIdList.push(item.id)
})
}
/** 赋值给对应行的企标 */
const dataIndex = this.dataSource.findIndex(item => item.uid === this.uploadUid)
this.dataSource[dataIndex].fileId = attIdList.join(',')
},
/**
* 跳转在线编辑
*/
toOnlineEditor () {
// 获取参数(用于自动生成封面)
const params = this.$refs.baseInfoForm.getOnlineEditorParams()
// 已经有的在线编辑文件
onlineEditor(params, this.onEditFile)
}
}
}
</script>
<style scoped lang="less">
.online-edit-wrapper {
height: 100%;
display: flex;
justify-content: space-between;
align-items: center;
p {
margin-bottom: 0;
height: 100%;
}
.ant-btn {
margin-right: 20px;
}
}
</style>