319 lines
10 KiB
Vue
319 lines
10 KiB
Vue
<template>
|
|
<div>
|
|
<base-info-form ref="baseInfoForm" v-bind="$attrs" disabled @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>
|
|
<!-- 操作区域 -->
|
|
<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">
|
|
|
|
<template slot="customTitleHandlingSuggestion">
|
|
<span class="table-header-required">*</span>
|
|
{{ $t('workCenter.enStandardRevision.handlingSuggestion') }}
|
|
</template>
|
|
|
|
</j-table>
|
|
</div>
|
|
<comment-modal ref="commentModal" @ok="modalFormOk"></comment-modal>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import BaseInfoForm from './BaseInfoForm'
|
|
import JTable from '@/components/jero/JTable'
|
|
import CommentModal from './CommentModal'
|
|
import { USER_INFO } from '@/store/mutation-types'
|
|
import Vue from 'vue'
|
|
import { onlineEditor } from '../../../../utils/onlyOfficeUtils'
|
|
import { getStandardEditFileByNo } from '../../../../api/workCenter'
|
|
import { ProjectType } from '../../../../enums/commonEnums'
|
|
|
|
export default {
|
|
name: 'MainDrafterCollectBaseInfo',
|
|
components: { CommentModal, BaseInfoForm, JTable },
|
|
props: {
|
|
disabled: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
loading: false,
|
|
/* 分页参数 */
|
|
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('serialNumber'),
|
|
dataIndex: '',
|
|
key: 'rowIndex',
|
|
align: 'center',
|
|
width: 80,
|
|
customRender: function (t, r, index) {
|
|
return parseInt(index) + 1
|
|
}
|
|
},
|
|
{ // 条款号
|
|
title: this.$t('workCenter.enStandardRevision.clauseNumber'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'clauseNum',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 条款名称
|
|
title: this.$t('workCenter.enStandardRevision.clauseName'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'clauseName',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 修改意见内容(包括修改理由和依据)
|
|
title: this.$t('workCenter.enStandardRevision.contentOfRevisedOpinion'),
|
|
align: 'center',
|
|
width: 300,
|
|
dataIndex: 'editAdvice',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 意见提出人
|
|
title: this.$t('workCenter.enStandardRevision.proposer'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'createUserId_dictText',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 处理意见
|
|
// title: this.$t('workCenter.enStandardRevision.handlingSuggestion'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'handleAdvice',
|
|
slots: { title: 'customTitleHandlingSuggestion' },
|
|
customRender: (text, row, index) => {
|
|
const obj = {
|
|
children: <a-select v-model={row.handleAdvice}
|
|
placeholder={this.$t('pleaseSelect')} class={'handle-suggest-select'}
|
|
options={this.handlingSuggestionOption}
|
|
/>,
|
|
attrs: {}
|
|
}
|
|
return obj
|
|
}
|
|
},
|
|
{ // 理由
|
|
title: this.$t('workCenter.enStandardRevision.reason'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'reason',
|
|
customRender: (text, row, index) => {
|
|
const obj = {
|
|
children: <a-input v-model={row.reason} maxLength={50}
|
|
title={row.reason} placeholder={this.$t('pleaseEnter')}
|
|
onChange={ e => {
|
|
e.target.value = e.target.value.trim()
|
|
row.reason = e.target.value.trim()
|
|
} }
|
|
/>,
|
|
attrs: {}
|
|
}
|
|
return obj
|
|
}
|
|
}
|
|
],
|
|
dataSource: [],
|
|
handlingSuggestionOption: [
|
|
{ value: '1', label: '采纳' },
|
|
{ value: '2', label: '部分采纳' },
|
|
{ value: '3', label: '不采纳' }
|
|
],
|
|
onEditFile: '', // 在线编辑文件id
|
|
standardCanOnlineEditFile: '' // 修订的时候企标本身可以带进在线编辑的文件
|
|
}
|
|
},
|
|
methods: {
|
|
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
|
|
initData (data) {
|
|
// 给表格赋值,在线编辑不知道要怎么赋值?
|
|
this.dataSource = data.advices.map(item => {
|
|
const uidGenerator = () => {
|
|
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
|
}
|
|
return {
|
|
uid: uidGenerator(),
|
|
...item,
|
|
handleAdvice: item.handleAdvice ? item.handleAdvice : undefined
|
|
}
|
|
})
|
|
this.onEditFile = data.onEditFile
|
|
// 给表单赋值
|
|
this.$nextTick(() => {
|
|
this.$refs.baseInfoForm.initData(data)
|
|
})
|
|
},
|
|
// 外层要获取数据
|
|
getData () {
|
|
// 把数据抛出,在线编辑不知道要不要抛
|
|
const data = {}
|
|
data.advices = this.dataSource
|
|
data.businessJson = JSON.stringify(this.$refs.baseInfoForm.getData())
|
|
data.onEditFile = this.onEditFile
|
|
return data
|
|
},
|
|
// 外层获取数据要过校验,返回false表示没有通过校验
|
|
getDataValidate () {
|
|
let hasErr = false
|
|
for (const item of this.dataSource) {
|
|
// 处理意见必填,不采纳,部分采纳必填理由
|
|
if (!item.handleAdvice || ((item.handleAdvice === '2' || item.handleAdvice === '3') && !item.reason)) {
|
|
console.log(item.handleAdvice)
|
|
hasErr = true
|
|
break
|
|
}
|
|
}
|
|
let data = {} // 需要返回的数据
|
|
if (hasErr) {
|
|
this.$message.warning(this.$t('pleaseCompleteTableInfo'))
|
|
data = false
|
|
} else {
|
|
data.advices = this.dataSource
|
|
data.onEditFile = this.onEditFile
|
|
}
|
|
return data
|
|
},
|
|
// 获取标准本身的文件
|
|
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)
|
|
}
|
|
},
|
|
handleTableChange (pagination) {
|
|
this.ipagination = pagination
|
|
},
|
|
// 新增征求意见
|
|
handleAdd () {
|
|
// 不知道左侧要预览哪个文件
|
|
const file = this.onEditFile
|
|
this.$refs.commentModal.title = this.$t('newlyAdded')
|
|
this.$refs.commentModal.add(file)
|
|
},
|
|
// 征求意见的编辑
|
|
handleEdit (record) {
|
|
// 不知道左侧要预览哪个文件
|
|
const file = this.onEditFile
|
|
this.$refs.commentModal.title = this.$t('edit')
|
|
this.$refs.commentModal.edit(file, record, record.uid)
|
|
},
|
|
// 征求意见的删除
|
|
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, uid) {
|
|
console.log(value, uid)
|
|
if (uid || uid === 0) {
|
|
// 有下标,说明是编辑
|
|
const dataIndex = this.dataSource.findIndex(item => item.uid === uid)
|
|
this.dataSource.splice(dataIndex, 1, value)
|
|
} else {
|
|
// 没有下标, 是新增
|
|
const currentUser = Vue.ls.get(USER_INFO)
|
|
const currentUserId = currentUser.realname + '(' + currentUser.username + ')'
|
|
const uidGenerator = () => {
|
|
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
|
}
|
|
this.dataSource.push({ ...value, createUserId_dictText: currentUserId, uid: uidGenerator() })
|
|
}
|
|
},
|
|
/**
|
|
* 跳转在线编辑
|
|
*/
|
|
async toOnlineEditor () {
|
|
// 获取参数(用于自动生成封面)
|
|
const params = this.$refs.baseInfoForm.getOnlineEditorParams()
|
|
if (!this.onEditFile) {
|
|
this.onEditFile = await onlineEditor(params, this.standardCanOnlineEditFile || '')
|
|
} else {
|
|
onlineEditor(params, this.onEditFile)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
@import '~@assets/less/common.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;
|
|
}
|
|
}
|
|
|
|
.handle-suggest-select {
|
|
width: 100%;
|
|
}
|
|
</style>
|