DialogForm.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <el-dialog
  3. v-if="visible"
  4. :title="form.id?'编辑客诉信息':'新建客诉信息'"
  5. :visible.sync="visible"
  6. width="800px"
  7. >
  8. <el-form v-loading="isLoading" :model="form" label-width="100px" label-position="top">
  9. <el-form-item label="标题">
  10. <el-input v-model="form.title" />
  11. </el-form-item>
  12. <el-row :gutter="24">
  13. <el-col :span="12">
  14. <el-form-item label="类型">
  15. <el-input v-model="form.category" />
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="12">
  19. <el-form-item label="渠道">
  20. <el-input v-model="form.channel" />
  21. </el-form-item>
  22. </el-col>
  23. </el-row>
  24. <el-form-item label="图片">
  25. <el-upload
  26. :file-list="fileList"
  27. action="#"
  28. list-type="picture-card"
  29. name="fileData"
  30. :http-request="uploaderHandle"
  31. :on-success="uploadSuccess"
  32. :on-remove="handleRemove"
  33. :auto-upload="true"
  34. >
  35. <i slot="default" class="el-icon-plus" />
  36. </el-upload>
  37. </el-form-item>
  38. <el-form-item label="内容">
  39. <el-input v-model="form.content" type="textarea" rows="10" />
  40. </el-form-item>
  41. </el-form>
  42. <div slot="footer" class="dialog-footer">
  43. <el-button @click="visible = false">取 消</el-button>
  44. <el-button type="primary" @click="handleSubmit">确 定</el-button>
  45. </div>
  46. </el-dialog>
  47. </template>
  48. <script>
  49. import { uploaderHandle } from '@/api/statistics/upload'
  50. import { save, updateById } from '@/api/statistics/complaint'
  51. export default {
  52. components: {},
  53. data() {
  54. return {
  55. visible: false,
  56. isLoading: false,
  57. form: {},
  58. fileList: []
  59. }
  60. },
  61. mounted() {
  62. },
  63. methods: {
  64. uploaderHandle,
  65. handleRemove(file, fileList) {
  66. this.fileList = fileList
  67. },
  68. uploadSuccess(res, file, fileList) {
  69. file.url = res.url
  70. this.fileList = fileList
  71. },
  72. open(data) {
  73. this.visible = true
  74. this.isLoading = false
  75. this.fileList = []
  76. this.form = {}
  77. console.log(data)
  78. if (data.litpics) {
  79. data.litpics.forEach(o => {
  80. this.fileList.push({ url: o })
  81. })
  82. }
  83. this.form = Object.assign({}, data)
  84. },
  85. handleSubmit() {
  86. const litpics = []
  87. this.fileList.forEach(o => {
  88. litpics.push(o.url)
  89. })
  90. this.isLoading = true
  91. const param = { ...this.form, 'litpics': litpics }
  92. console.log(param)
  93. if (this.form.id) {
  94. updateById(this.form.id, param).then(() => {
  95. this.visible = false
  96. this.$emit('ok')
  97. }).finally(() => {
  98. this.isLoading = false
  99. })
  100. } else {
  101. save(param).then(res => {
  102. this.visible = false
  103. this.$emit('ok')
  104. }).finally(() => {
  105. this.isLoading = false
  106. })
  107. }
  108. }
  109. }
  110. }
  111. </script>