1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <template>
- <m-dialog title="编辑" :visible.sync="show" @submit="handleSubmit">
- <MForm ref="form" :items="formItems" v-model="formValues" v-loading="loading"></MForm>
- </m-dialog>
- </template>
- <script>
- import MForm from '@/components/MForm'
- import MDialog from '@/components/Dialog'
- import { updateFeedback } from '@/api/dataChart'
- export default {
- name: 'modelQaEdit',
- components: {
- MDialog,
- MForm
- },
- data () {
- return {
- loading: false,
- show: false,
- formValues: {},
- formItems: [
- {
- label: '问题',
- key: 'question',
- type: 'textarea'
- },
- {
- label: 'SQL',
- key: 'sql',
- type: 'textarea',
- rows: 10
- },
- {
- label: '用户反馈',
- key: 'is_thumb_up',
- type: 'ifRadio',
- items: [
- {
- label: '赞同',
- value: true
- },
- {
- label: '不赞同',
- value: false
- }
- ]
- }
- ]
- }
- },
- methods: {
- open (item) {
- this.formValues = {
- question: item.question,
- sql: item.sql,
- is_thumb_up: item.is_thumb_up,
- id: item.id
- }
- this.show = true
- },
- async handleSubmit () {
- if (!this.$refs.form.validate()) {
- return
- }
- this.loading = true
- const { id, ...params } = this.formValues
- try {
- await updateFeedback(id, params)
- this.$snackbar.success('保存成功')
- } catch (error) {
- this.$snackbar.error(error)
- } finally {
- this.loading = false
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|