modelQaEdit.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <m-dialog title="编辑" :visible.sync="show" @submit="handleSubmit">
  3. <MForm ref="form" :items="formItems" v-model="formValues" v-loading="loading"></MForm>
  4. </m-dialog>
  5. </template>
  6. <script>
  7. import MForm from '@/components/MForm'
  8. import MDialog from '@/components/Dialog'
  9. import { updateFeedback } from '@/api/dataChart'
  10. export default {
  11. name: 'modelQaEdit',
  12. components: {
  13. MDialog,
  14. MForm
  15. },
  16. data () {
  17. return {
  18. loading: false,
  19. show: false,
  20. formValues: {},
  21. formItems: [
  22. {
  23. label: '问题',
  24. key: 'question',
  25. type: 'textarea'
  26. },
  27. {
  28. label: 'SQL',
  29. key: 'sql',
  30. type: 'textarea',
  31. rows: 10
  32. },
  33. {
  34. label: '用户反馈',
  35. key: 'is_thumb_up',
  36. type: 'ifRadio',
  37. items: [
  38. {
  39. label: '赞同',
  40. value: true
  41. },
  42. {
  43. label: '不赞同',
  44. value: false
  45. }
  46. ]
  47. }
  48. ]
  49. }
  50. },
  51. methods: {
  52. open (item) {
  53. this.formValues = {
  54. question: item.question,
  55. sql: item.sql,
  56. is_thumb_up: item.is_thumb_up,
  57. id: item.id
  58. }
  59. this.show = true
  60. },
  61. async handleSubmit () {
  62. if (!this.$refs.form.validate()) {
  63. return
  64. }
  65. this.loading = true
  66. const { id, ...params } = this.formValues
  67. try {
  68. await updateFeedback(id, params)
  69. this.$snackbar.success('保存成功')
  70. } catch (error) {
  71. this.$snackbar.error(error)
  72. } finally {
  73. this.loading = false
  74. }
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. </style>