2023-07-13 19:18:23 +08:00
|
|
|
<template>
|
|
|
|
<custom-modal v-model="visible" title="Spectrum Comments" :okHandler="handleOk" :footer="isAdd ? undefined : null">
|
2023-08-28 19:52:35 +08:00
|
|
|
<a-spin :spinning="isLoading">
|
|
|
|
<a-textarea v-model="comments" :rows="8" :disabled="!isAdd"></a-textarea>
|
|
|
|
</a-spin>
|
2023-07-13 19:18:23 +08:00
|
|
|
</custom-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-09-26 14:40:08 +08:00
|
|
|
import { getAction, putAction } from '@/api/manage'
|
2023-07-13 19:18:23 +08:00
|
|
|
import ModalMixin from '@/mixins/ModalMixin'
|
2023-09-05 19:06:19 +08:00
|
|
|
import SampleDataMixin from '../../SampleDataMixin'
|
|
|
|
|
2023-07-13 19:18:23 +08:00
|
|
|
export default {
|
2023-09-05 19:06:19 +08:00
|
|
|
mixins: [ModalMixin, SampleDataMixin],
|
2023-07-13 19:18:23 +08:00
|
|
|
props: {
|
|
|
|
isAdd: {
|
|
|
|
type: Boolean,
|
2023-09-26 14:40:08 +08:00
|
|
|
default: true,
|
|
|
|
},
|
2023-07-13 19:18:23 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2023-08-28 19:52:35 +08:00
|
|
|
isLoading: false,
|
2023-09-26 14:40:08 +08:00
|
|
|
comments: '',
|
2023-07-13 19:18:23 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// ModalMixin 中的生命周期方法
|
|
|
|
beforeModalOpen() {
|
2023-08-28 19:52:35 +08:00
|
|
|
if (this.isAdd) {
|
|
|
|
this.comments = ''
|
2023-09-26 14:40:08 +08:00
|
|
|
this.getTotalComment()
|
2023-08-28 19:52:35 +08:00
|
|
|
} else {
|
|
|
|
this.getInfo()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-09-26 14:40:08 +08:00
|
|
|
// View接口
|
2023-08-28 19:52:35 +08:00
|
|
|
async getInfo() {
|
|
|
|
try {
|
|
|
|
this.isLoading = true
|
2023-09-05 19:06:19 +08:00
|
|
|
const { sampleId, inputFileName: fileName } = this.sampleData
|
2023-08-28 19:52:35 +08:00
|
|
|
const { success, result, message } = await getAction('/gamma/viewComment', {
|
2023-09-05 19:06:19 +08:00
|
|
|
sampleId,
|
2023-09-26 14:40:08 +08:00
|
|
|
fileName,
|
2023-08-28 19:52:35 +08:00
|
|
|
})
|
|
|
|
this.isLoading = false
|
|
|
|
if (success) {
|
|
|
|
this.comments = result
|
|
|
|
} else {
|
|
|
|
this.$message.error(message)
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
}
|
2023-07-13 19:18:23 +08:00
|
|
|
},
|
2023-09-26 14:40:08 +08:00
|
|
|
|
|
|
|
// Add 获取 Comment 接口
|
|
|
|
async getTotalComment() {
|
|
|
|
try {
|
|
|
|
this.isLoading = true
|
|
|
|
const { inputFileName: fileName } = this.sampleData
|
|
|
|
const { success, result, message } = await getAction('/gamma/viewGeneralComment', {
|
|
|
|
fileName,
|
|
|
|
})
|
|
|
|
this.isLoading = false
|
|
|
|
if (success) {
|
|
|
|
this.comments = result
|
|
|
|
} else {
|
|
|
|
this.$message.error(message)
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
async handleOk() {
|
|
|
|
const { inputFileName: fileName } = this.sampleData
|
|
|
|
const { success, message } = await putAction(`/gamma/addComment?fileName=${fileName}&comment=${this.comments}`)
|
|
|
|
if (!success) {
|
|
|
|
this.$message.error(message)
|
|
|
|
throw new Error(message)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2023-07-13 19:18:23 +08:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style></style>
|