304 lines
11 KiB
Vue
304 lines
11 KiB
Vue
<template>
|
|
<div>
|
|
<a-spin :spinning="loading">
|
|
<div class="process-part-title">{{ $t('basicServiceInformation') }}</div>
|
|
<div v-if="!disabled" class="table-operator">
|
|
<!-- 添加标准 -->
|
|
<a-button icon="plus" type="primary" @click="handleAddStandard">
|
|
{{$t('workCenter.standardInterpretationProcess.addStandard')}}
|
|
</a-button>
|
|
<!-- 选择条款 -->
|
|
<a-button icon="plus" type="primary" @click="handleSelectClause">
|
|
{{$t('workCenter.standardInterpretationProcess.selectStandard')}}
|
|
</a-button>
|
|
</div>
|
|
<div class="table-container mb-20">
|
|
<j-table
|
|
:can-drag="true"
|
|
:scroll="{x: '100%'}"
|
|
ref="table"
|
|
rowKey="id"
|
|
:columns="columns"
|
|
:dataSource="dataSource"
|
|
:pagination="false">
|
|
<!-- 标准编号、标准名称 -->
|
|
<template v-slot:toDetail="{text, record}">
|
|
<a-tooltip overlay-class-name="tooltip-style">
|
|
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
|
|
<a class="link-a" @click="toDetail(record)">{{ text }}</a>
|
|
</a-tooltip>
|
|
</template>
|
|
<!-- 分解单来源-->
|
|
<template v-slot:decompositionSource="{text, record}">
|
|
<a-select v-model="record.decompositionSource"
|
|
@change="handleChangeDecompositionSource"
|
|
:placeholder="$t('pleaseSelect') + $t('workCenter.standardInterpretationProcess.decompositionOrderSource')"
|
|
style="width: 100%;">
|
|
<a-select-option v-for="item in decompositionSourceList"
|
|
:disabled="item.isDisabled === '1'"
|
|
:key="item.value" :value="item.value">
|
|
{{ item.text || item.title }}
|
|
</a-select-option>
|
|
</a-select>
|
|
</template>
|
|
</j-table>
|
|
</div>
|
|
<template v-if="showClauseTable">
|
|
<!-- 条款的表格 -->
|
|
<interpretation-clause-table ref="interpretationClauseTable" :disabled="disabled" :current-node-id="currentNodeId"/>
|
|
</template>
|
|
</a-spin>
|
|
<!-- 添加标准弹框-只选择已拆分的数据 -->
|
|
<standard-selection-modal ref="selectStandardRef"
|
|
type="radio"
|
|
@listChange="handleAddStandardCallback"
|
|
:canSelectedSource="[StandardSource.FOREIGN.value]"
|
|
:filters="{releaseSplitFlag: '1'}"
|
|
disabledSourceSearch/>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import StandardSelectionModal from '@comp/selection/StandardSelectionModal'
|
|
import { interpretGetClauseList, interpretGetFileByStandardId } from '@api/workCenter'
|
|
import { DecompositionSource, StandardSource } from '@/enums/commonEnums'
|
|
import InterpretationClauseTable
|
|
from '@views/workCenter/standardInterpretationProcess/modules/InterpretationClauseTable'
|
|
export default {
|
|
name: 'InterpretationInitiate',
|
|
components: { InterpretationClauseTable, StandardSelectionModal },
|
|
props: {
|
|
// 当前节点
|
|
currentNodeId: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
StandardSource,
|
|
loading: false,
|
|
columns: [
|
|
{ // 标准编号
|
|
title: this.$t('standardNumber'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'standardNumber',
|
|
scopedSlots: { customRender: 'toDetail' }
|
|
},
|
|
{ // 标准名称
|
|
title: this.$t('standardName'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'standardName',
|
|
scopedSlots: { customRender: 'toDetail' }
|
|
},
|
|
{ // 标准状态
|
|
title: this.$t('standardState'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'standardState_dictText',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 分解单来源
|
|
title: this.$t('workCenter.standardInterpretationProcess.decompositionOrderSource'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'decompositionSource_dictText',
|
|
scopedSlots: { customRender: 'decompositionSource' }
|
|
},
|
|
{ // 实施日期
|
|
title: this.$t('implementationDate'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'implementationDate',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 新生产车实施日期
|
|
title: this.$t('newProductionVehicleImplementationDate'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'newProductImplDate',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{ // 新认证车实施日期
|
|
title: this.$t('newCertifiedVehicleImplementationDate'),
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'newAuthImplDate',
|
|
scopedSlots: { customRender: 'text' }
|
|
}
|
|
],
|
|
dataSource: [],
|
|
decompositionSourceList: [], // 标准分解单下拉
|
|
// 是否显示条款的表格部分
|
|
showClauseTable: false,
|
|
// 删除的数据id
|
|
delIds: []
|
|
}
|
|
},
|
|
methods: {
|
|
// 跳转详情
|
|
toDetail (record) {
|
|
const path = '/standardRegulationLibrary/foreignStandardDetailPage'
|
|
this.$openPageNewSheet({
|
|
path: path,
|
|
query: {
|
|
id: record.standardId
|
|
}
|
|
})
|
|
},
|
|
/**
|
|
* 获取组件内的数据
|
|
* @param isValidate - 是否需要校验
|
|
*/
|
|
async getData (isValidate) {
|
|
const obj = {}
|
|
if (isValidate) {
|
|
// 如果没有选择标准
|
|
if (!this.dataSource.length) {
|
|
this.$message.warn(this.$t('addAtLeastOneRowOfData'))
|
|
// 校验失败就标记true
|
|
obj._flag = true
|
|
}
|
|
// 如果来源选择不带入,至少选择一条条款信息
|
|
const isNoInput = this.dataSource.length && (this.dataSource[0].decompositionSource === DecompositionSource.NO_INPUT.value)
|
|
// 是否没有条款数据
|
|
const isClauseNotData = !this.showClauseTable || !this.$refs.interpretationClauseTable.getData().length
|
|
if (isNoInput && isClauseNotData) {
|
|
this.$message.warn(this.$t('workCenter.standardInterpretationProcess.pleaseSelectClause'))
|
|
obj._flag = true
|
|
}
|
|
// 选择条款后来源选择其他,没有条款数据提示至少一条数据
|
|
if (this.showClauseTable && !isNoInput && isClauseNotData) {
|
|
this.$message.warn(this.$t('addAtLeastOneRowOfData'))
|
|
// 校验失败就标记true
|
|
obj._flag = true
|
|
}
|
|
}
|
|
// 选择的标准列表
|
|
obj.standardData = this.dataSource
|
|
// 选择的条款列表
|
|
if (this.showClauseTable) {
|
|
obj.clauseData = this.$refs.interpretationClauseTable.getData()
|
|
}
|
|
// 父组件的ids和子组件的合并返回
|
|
const delIds = this.delIds
|
|
if (this.$refs.interpretationClauseTable) {
|
|
delIds.push(...this.$refs.interpretationClauseTable.processAllDelIds)
|
|
}
|
|
// 获取所有删除的id
|
|
obj.processAllDelIds = delIds
|
|
return obj
|
|
},
|
|
// 更新组件内的数据
|
|
setData (data) {
|
|
const info = data.data.processStandardInterpret
|
|
if (info.standardId) {
|
|
this.dataSource = [info]
|
|
}
|
|
// 有数据更新下拉菜单
|
|
if (this.dataSource.length) {
|
|
this.initInterpretGetFileByStandardId(this.dataSource[0].standardId)
|
|
}
|
|
// 如果有条款列表就回显条款列表
|
|
if (data.data.processStandardInterpretClauseList && data.data.processStandardInterpretClauseList.length) {
|
|
this.showClauseTable = true
|
|
this.$nextTick(() => {
|
|
this.$refs.interpretationClauseTable.setData(data.data.processStandardInterpretClauseList)
|
|
})
|
|
}
|
|
},
|
|
// 添加标准
|
|
handleAddStandard () {
|
|
this.$refs.selectStandardRef.open()
|
|
},
|
|
// 选择条款
|
|
handleSelectClause () {
|
|
// 请添加一条标准
|
|
if (!this.dataSource.length) {
|
|
this.$message.warn(this.$t('workCenter.standardInterpretationProcess.pleaseAddStandard'))
|
|
return
|
|
}
|
|
// 如果有条款的表格,就清空然后隐藏
|
|
if (this.$refs.interpretationClauseTable) {
|
|
// 清空上次的数据,需要记录删除的id
|
|
this.delIds.push(...this.$refs.interpretationClauseTable.getData().map(item => item.id))
|
|
this.$refs.interpretationClauseTable.setData([])
|
|
}
|
|
this.showClauseTable = true
|
|
// 如果是不带入,不需要请求,直接将标准数据带入
|
|
if (this.dataSource[0].decompositionSource === DecompositionSource.NO_INPUT.value) {
|
|
this.$nextTick(() => {
|
|
this.$refs.interpretationClauseTable.setData([{
|
|
clauseId: this.dataSource[0].standardId,
|
|
itemTitle: this.dataSource[0].standardName,
|
|
itemNum: this.dataSource[0].standardNumber
|
|
}])
|
|
})
|
|
return
|
|
}
|
|
this.loading = true
|
|
interpretGetClauseList({
|
|
standardId: this.dataSource[0].standardId,
|
|
fileType: this.dataSource[0].decompositionSource
|
|
}).then(res => {
|
|
if (res.success) {
|
|
this.$refs.interpretationClauseTable.setData(res.result || [])
|
|
}
|
|
}).finally(() => {
|
|
this.loading = false
|
|
})
|
|
},
|
|
// 选择完标准回调
|
|
handleAddStandardCallback (list) {
|
|
console.log(list)
|
|
this.dataSource = list || []
|
|
if (this.dataSource.length) {
|
|
this.resetClauseTable()
|
|
this.dataSource[0].standardId = this.dataSource[0].id
|
|
this.$set(this.dataSource[0], 'decompositionSource', DecompositionSource.NO_INPUT.value)
|
|
this.initInterpretGetFileByStandardId(this.dataSource[0].id)
|
|
}
|
|
},
|
|
// 重置条款表格
|
|
resetClauseTable () {
|
|
this.$refs.interpretationClauseTable && this.$refs.interpretationClauseTable.setData([])
|
|
this.showClauseTable = false
|
|
},
|
|
/**
|
|
* 获取分解单来源下拉
|
|
* @param standardId - 标准id
|
|
*/
|
|
initInterpretGetFileByStandardId (standardId) {
|
|
this.decompositionSourceList = []
|
|
interpretGetFileByStandardId({ standardId }).then(res => {
|
|
if (res.success) {
|
|
this.decompositionSourceList = res.result || []
|
|
}
|
|
})
|
|
},
|
|
// 修改分解单来源
|
|
handleChangeDecompositionSource (val) {
|
|
this.decompositionSource = val
|
|
this.resetClauseTable()
|
|
const find = this.decompositionSourceList.find(item => item.value === val)
|
|
if (find) {
|
|
this.dataSource.decompositionSource_dictText = find.text || find.title
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
.mb-20 {
|
|
margin-bottom: 20px;
|
|
}
|
|
</style>
|