274 lines
8.9 KiB
Vue
274 lines
8.9 KiB
Vue
<template>
|
|
<div>
|
|
<base-info-form ref="baseInfoForm" v-bind="$attrs" :disabled="disabled" @processNameChange="processNameChange" @typeOfRevisionChange="typeOfRevisionChange"></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>
|
|
<!-- 其他起草人 -->
|
|
<!-- 添加其他起草人 -->
|
|
<p class="base-info-inner-title">{{ $t('workCenter.enStandardRevision.addOtherDrafter') }}</p>
|
|
<!-- 操作区域 -->
|
|
<div v-if="!disabled" class="table-operator">
|
|
<!-- 新增 -->
|
|
<a-button icon="plus" type="primary" @click="handleAdd" :disabled="disabled">
|
|
{{ $t('newlyAdded') }}
|
|
</a-button>
|
|
</div>
|
|
|
|
<div>
|
|
<j-table
|
|
:can-drag="true"
|
|
:scroll="{x: '100%'}"
|
|
ref="table"
|
|
rowKey="uid"
|
|
:columns="columns"
|
|
:dataSource="dataSource"
|
|
:pagination="ipagination"
|
|
:loading="loading"
|
|
@change="handleTableChange">
|
|
|
|
<!-- 操作栏 -->
|
|
<div slot="action" slot-scope="{record}" class="action-span-cell">
|
|
<a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
|
|
<a-divider type="vertical" />
|
|
<a @click="handleDelete(record.uid)" class="table-ope-btn" :disabled="disabled">{{ $t('delete') }}</a>
|
|
</div>
|
|
|
|
</j-table>
|
|
</div>
|
|
<add-edit-drafter-drawer ref="addEditDrafterDrawer" @ok="modalFormOk"></add-edit-drafter-drawer>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import JTable from '@/components/jero/JTable'
|
|
import BaseInfoForm from './BaseInfoForm'
|
|
import AddEditDrafterDrawer from './AddEditDrafterDrawer'
|
|
import { onlineEditor } from '../../../../utils/onlyOfficeUtils'
|
|
import { getEnterpriseStandardInfoById } from '../../../../api/enterpriseStandardLibraryApi'
|
|
import { ProjectType } from '../../../../enums/commonEnums'
|
|
import { getStandardEditFileByNo } from '../../../../api/workCenter'
|
|
|
|
export default {
|
|
name: 'MainDrafterSentBaseInfo',
|
|
components: { AddEditDrafterDrawer, BaseInfoForm, JTable },
|
|
props: {
|
|
disabled: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
/* 分页参数 */
|
|
ipagination: {
|
|
current: 1,
|
|
pageSize: 5,
|
|
pageSizeOptions: ['5', '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: 180,
|
|
dataIndex: 'dept_dictText',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 起草人
|
|
title: this.$t('workCenter.enStandardRevision.drafter'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'user_dictText',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 起草范围
|
|
title: this.$t('workCenter.enStandardRevision.draftingScope'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'scope',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 截止日期
|
|
title: this.$t('expirationDate'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'deadline',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 操作
|
|
title: this.$t('operation'),
|
|
scopedSlots: { customRender: 'action' },
|
|
align: 'center',
|
|
fixed: 'right',
|
|
width: 200
|
|
}
|
|
],
|
|
dataSource: [],
|
|
loading: false,
|
|
modalType: undefined, // 当前是新增还是编辑编辑的话是edit+编辑行的下标
|
|
onEditFile: '', // 在线编辑文件
|
|
standardCanOnlineEditFile: '' // 修订的时候企标本身可以带进在线编辑的文件
|
|
}
|
|
},
|
|
methods: {
|
|
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
|
|
initData (data) {
|
|
// 给表格赋值,在线编辑不知道要怎么赋值?
|
|
this.dataSource = data.otherDraftUserVOS && data.otherDraftUserVOS.length > 0 ? 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())
|
|
// 在线编辑文件id
|
|
data.onEditFile = this.onEditFile
|
|
return data
|
|
},
|
|
// 外层获取数据要过校验,返回false表示没有通过校验
|
|
async getDataValidate () {
|
|
const formData = await this.$refs.baseInfoForm.getDataValidate()
|
|
console.log(formData)
|
|
if (formData) {
|
|
// 有数据可以抛出
|
|
const data = {}
|
|
data.otherDraftUserVOS = this.dataSource || []
|
|
data.formInline = formData.formInline
|
|
data.onEditFile = this.onEditFile
|
|
return data
|
|
} else {
|
|
return false
|
|
}
|
|
},
|
|
// 获取标准本身的文件
|
|
async getStandardFile (standardNum) {
|
|
await getStandardEditFileByNo({ standardNo: standardNum }).then(res => {
|
|
if (res.success) {
|
|
const fileId = res.result ? res.result.id : ''
|
|
this.standardCanOnlineEditFile = fileId
|
|
}
|
|
})
|
|
},
|
|
// 制修订类型改变
|
|
typeOfRevisionChange (val, originStandardNum) {
|
|
if (val === ProjectType.ENACT.value) {
|
|
this.standardCanOnlineEditFile = ''
|
|
} else if (val === ProjectType.MODIFY.value) {
|
|
this.getStandardFile(originStandardNum)
|
|
}
|
|
},
|
|
processNameChange (value) {
|
|
this.$emit('processNameChange', value)
|
|
},
|
|
handleTableChange (pagination) {
|
|
this.ipagination = pagination
|
|
},
|
|
handleAdd () {
|
|
this.modalType = 'add'
|
|
this.$refs.addEditDrafterDrawer.add()
|
|
},
|
|
// 编辑
|
|
handleEdit (record) {
|
|
this.modalType = 'edit' + ',' + record.uid
|
|
this.$refs.addEditDrafterDrawer.edit(record)
|
|
},
|
|
// 删除
|
|
handleDelete (uid) {
|
|
this.$confirm({
|
|
title: this.$t('confirmDeletion'),
|
|
content: this.$t('areYouSure'),
|
|
onOk: () => {
|
|
const dataIndex = this.dataSource.findIndex(item => item.uid === uid)
|
|
this.dataSource.splice(dataIndex, 1)
|
|
}
|
|
})
|
|
},
|
|
// 新增或编辑完成
|
|
modalFormOk (value) {
|
|
if (this.modalType === 'add') {
|
|
const uidGenerator = () => {
|
|
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
|
}
|
|
this.dataSource.push({ uid: uidGenerator(), ...value })
|
|
} else if (this.modalType && this.modalType.split(',')[0] === 'edit') {
|
|
const dataIndex = this.dataSource.findIndex(item => item.uid === this.modalType.split(',')[1])
|
|
this.dataSource.splice(dataIndex, 1, value)
|
|
}
|
|
},
|
|
/**
|
|
* 跳转在线编辑
|
|
*/
|
|
async toOnlineEditor () {
|
|
// 获取参数(用于自动生成封面)
|
|
const params = this.$refs.baseInfoForm.getOnlineEditorParams()
|
|
// 校验必填字段(最后一个字段是企标编号)
|
|
const requiredField = ['implementation_date', 'release_date', 'standard_name', 'standard_number', 'espId']
|
|
const validateResult = this.$refs.baseInfoForm.validateFormByFields(requiredField)
|
|
if (validateResult) {
|
|
console.log(this.onEditFile || this.standardCanOnlineEditFile || '')
|
|
this.onEditFile = await onlineEditor(params, this.onEditFile || this.standardCanOnlineEditFile || '')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
@import '~@assets/less/common.less';
|
|
|
|
.collapsible-content-no-head {
|
|
border-top: 1px solid #E5E6EB;
|
|
border-radius: 8px 8px 8px 8px;
|
|
}
|
|
|
|
.online-edit-wrapper {
|
|
height: 100%;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
|
|
p {
|
|
margin-bottom: 0;
|
|
height: 100%;
|
|
}
|
|
}
|
|
|
|
.base-info-inner-title {
|
|
color: #1D2129;
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
}
|
|
</style>
|