Files
laws-sinotruk-client/src/views/documentTool/documentComparison/modules/ComparisonResultEditModal.vue
T
2023-10-08 16:48:57 +08:00

136 lines
4.0 KiB
Vue

<template>
<j-modal
:title="title"
:width="600"
:visible="visible"
:confirm-loading="confirmLoading"
:maskClosable="false"
switchFullscreen
@cancel="visible = false"
>
<template slot="footer">
<a-button key="back" @click="visible = false">
{{ $t('cancel') }}
</a-button>
<a-button type="primary" :loading="confirmLoading" @click="fullTextCommentsSubmit">
{{ $t('submit') }}
</a-button>
</template>
<a-form-model :model="formInlineText" class="formAdd" :rules="rulesText" ref="ruleFormText">
<a-form-model-item class="item-model"
prop="comment"
v-if="title === $t('docTool.comparison.fullTextComments')"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
:label="$t('docTool.comparison.fullTextComments')">
<a-textarea :placeholder="$t('pleaseEnter') + $t('docTool.comparison.fullTextComments')"
v-model.trim="formInlineText.comment"
:maxLength="500"
:rows="4" />
</a-form-model-item>
<a-form-model-item class="item-model"
prop="comment"
v-if="title === $t('docTool.comparison.comparativeComments')"
:labelCol="labelCol"
:wrapperCol="wrapperCol"
:label="$t('docTool.comparison.comparativeComments')">
<a-textarea :placeholder="$t('pleaseEnter')+$t('docTool.comparison.comparativeComments')"
v-model.trim="formInlineText.comment"
:maxLength="500"
:rows="4" />
</a-form-model-item>
</a-form-model>
</j-modal>
</template>
<script>
import { putAction } from '../../../../api/manage.js'
import { addFullTextComment, editComparisonComment } from '../../../../api/documentToolApi.js'
export default {
name: 'ComparisonResultEditModal',
data () {
return {
title: '',
visible: false,
confirmLoading: false,
formInlineText: {},
rulesText: {},
labelCol: {
span: 5
},
wrapperCol: {
span: 18
}
}
},
methods: {
open (form) {
this.initData()
this.visible = true
this.formInlineText = Object.assign({}, form)
},
initData () {
this.$nextTick(() => {
this.$refs.ruleFormText.clearValidate()
})
},
// 发表评论弹框的提交按钮点击
fullTextCommentsSubmit () {
this.$refs.ruleFormText.validate(valid => {
if (valid) {
if (this.title === this.$t('docTool.comparison.fullTextComments')) {
this.fullTextComments()
} else {
this.comparaComments()
}
}
})
},
// 全文评论提交
fullTextComments () {
this.confirmLoading = true
const query = {
id: this.$route.query.id,
comments: this.formInlineText.comment
}
addFullTextComment(query).then((res) => {
if (res.success) {
this.$message.success(this.$t('operationSuccessful'))
this.visible = false
this.$emit('ok')
} else {
this.$message.warning(this.$t('operationFailed'))
}
}).finally(() => {
this.confirmLoading = false
})
},
// 发表评论提交
comparaComments () {
this.confirmLoading = true
const query = {
infoId: this.$route.query.id,
id: this.formInlineText.id,
comment: this.formInlineText.comment
}
editComparisonComment(query).then((res) => {
if (res.success) {
this.$message.success(this.$t('operationSuccessful'))
this.visible = false
this.$emit('ok')
} else {
this.$message.warning(this.$t('operationFailed'))
}
}).finally(() => {
this.confirmLoading = false
})
}
}
}
</script>
<style scoped lang="less">
@import '~../../../../assets/less/common.less';
</style>