Files
laws_chery_client/src/views/workCenter/standardInterpretationProcess/modules/InterpretationLiaisonDistribute.vue
T

123 lines
3.9 KiB
Vue

<template>
<div>
<a-spin :spinning="loading">
<div class="process-part-title">{{ $t('dispatchInformation') }}</div>
<!-- 条款的表格 -->
<interpretation-clause-table v-if="showClauseTable" ref="interpretationClauseTable" :disabled="disabled" :current-node-id="currentNodeId"/>
<a-form :form="form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row>
<a-col :span="8">
<a-form-item :label="$t('workCenter.standardInterpretationProcess.mainInterpreter')" :colon="false">
<!--主解读人-->
<user-selection :placeholder="$t('pleaseSelect')+$t('workCenter.standardInterpretationProcess.mainInterpreter')"
v-decorator="['masterInterpretId', validatorRules.masterInterpretId]"
:disabled="disabled"
filedName="masterInterpretId"
@nameChange="userSelectNameChange"
:nameStr="formInline.masterInterpretId_dictText" />
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-spin>
</div>
</template>
<script>
import UserSelection from '@comp/selection/UserSelection'
import InterpretationClauseTable
from '@views/workCenter/standardInterpretationProcess/modules/InterpretationClauseTable'
import { YesOrNoEnum } from '@/enums/commonEnums'
export default {
name: 'InterpretationLiaisonDistribute',
components: { InterpretationClauseTable, UserSelection },
props: {
// 当前节点
currentNodeId: {
type: String,
required: true
},
disabled: {
type: Boolean,
required: false,
default: false
}
},
data () {
return {
form: this.$form.createForm(this),
loading: false,
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 }
},
validatorRules: {
// 主解读人
masterInterpretId: {
rules: [{ required: true, message: this.$t('pleaseEnter') + this.$t('processName') }],
validateTrigger: 'blur'
}
},
// 表单的数据
formInline: {},
// 是否显示条款表格
showClauseTable: false
}
},
methods: {
/**
* 获取组件内的数据
* @param isValidate - 是否需要校验
*/
async getData (isValidate) {
const obj = {}
if (isValidate) {
// 至少一条数据
if (this.showClauseTable && !this.$refs.interpretationClauseTable.getData().length) {
this.$message.warn(this.$t('addAtLeastOneRowOfData'))
this._flag = true
}
obj.formData = await new Promise((resolve) => {
this.form.validateFields((err, values) => {
if (err) { obj._flag = true }
// 校验成功失败都返回表单数据
resolve(values)
})
})
} else {
obj.formData = this.form.getFieldsValue()
}
// 条款列表
obj.clauseData = this.showClauseTable ? this.$refs.interpretationClauseTable.getData() : []
// 获取所有删除的id
obj.processAllDelIds = this.$refs.interpretationClauseTable && this.$refs.interpretationClauseTable.processAllDelIds
return obj
},
// 更新组件内的数据
setData (data) {
this.clauseDataSource = data.data.processStandardInterpretClauseList || []
this.formInline = data.data.processStandardInterpret || {}
this.showClauseTable = this.formInline.chooseClause === YesOrNoEnum.YES.value
this.$nextTick(() => {
this.form.setFieldsValue(this.formInline)
this.$refs.interpretationClauseTable.setData(this.clauseDataSource)
})
},
// 选择用户回显用户名
userSelectNameChange (value, fieldName) {
this.formInline[fieldName + '_dictText'] = value
}
}
}
</script>
<style lang="less" scoped>
.mb-20 {
margin-bottom: 20px;
}
</style>