feat: 对接Comments -> Add

This commit is contained in:
Xu Zhimeng 2023-09-26 14:40:08 +08:00
parent 90017662ed
commit 2ffa1abbce

View File

@ -7,7 +7,7 @@
</template> </template>
<script> <script>
import { getAction } from '@/api/manage' import { getAction, putAction } from '@/api/manage'
import ModalMixin from '@/mixins/ModalMixin' import ModalMixin from '@/mixins/ModalMixin'
import SampleDataMixin from '../../SampleDataMixin' import SampleDataMixin from '../../SampleDataMixin'
@ -16,13 +16,13 @@ export default {
props: { props: {
isAdd: { isAdd: {
type: Boolean, type: Boolean,
default: true default: true,
} },
}, },
data() { data() {
return { return {
isLoading: false, isLoading: false,
comments: '' comments: '',
} }
}, },
methods: { methods: {
@ -30,18 +30,20 @@ export default {
beforeModalOpen() { beforeModalOpen() {
if (this.isAdd) { if (this.isAdd) {
this.comments = '' this.comments = ''
this.getTotalComment()
} else { } else {
this.getInfo() this.getInfo()
} }
}, },
// View
async getInfo() { async getInfo() {
try { try {
this.isLoading = true this.isLoading = true
const { sampleId, inputFileName: fileName } = this.sampleData const { sampleId, inputFileName: fileName } = this.sampleData
const { success, result, message } = await getAction('/gamma/viewComment', { const { success, result, message } = await getAction('/gamma/viewComment', {
sampleId, sampleId,
fileName fileName,
}) })
this.isLoading = false this.isLoading = false
if (success) { if (success) {
@ -53,10 +55,35 @@ export default {
console.error(error) console.error(error)
} }
}, },
handleOk() {
console.log('%c [ ]-26', 'font-size:13px; background:pink; color:#bf2c9f;', this.comments) // 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)
}
},
},
} }
</script> </script>