feedback-add.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div class="content" v-show="showDialog">
  3. <el-dialog title="意见反馈" top="30vh" :visible.sync="showDialog" width="700px" @closed="onClosed">
  4. <el-form inline ref="form" :model="feedback" label-width="100px" :rules="rules">
  5. <el-form-item label="标签:">
  6. <!-- 标签 -->
  7. <div class="flex flex-wrap">
  8. <div class="tag-item" :class="{ 'tat-active': item.selected }" @click="changeTag(index)"
  9. v-for="(item,index) in tagList" :key="index">{{ item.title }}</div>
  10. </div>
  11. </el-form-item>
  12. <el-form-item label="内容:" prop="content">
  13. <el-input type="textarea" :placeholder="feedback.placeholder" v-model="feedback.content" :rows="3"
  14. resize="none">
  15. </el-input>
  16. </el-form-item>
  17. </el-form>
  18. <div slot="footer" class="dialog-footer">
  19. <el-button type="primary" @click="submitForm">提交</el-button>
  20. <el-button @click="showDialog = false">取消</el-button>
  21. </div>
  22. </el-dialog>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. components: {},
  28. props: {
  29. value: {
  30. type: Boolean,
  31. default: false,
  32. },
  33. },
  34. data() {
  35. return {
  36. showDialog: false,
  37. feedback: {
  38. placeholder: '',
  39. content: '',
  40. },
  41. tagList: [],
  42. activeTag: 0,
  43. rules: {
  44. content: [{
  45. required: true,
  46. message: "请输入反馈内容",
  47. trigger: "change",
  48. }, ],
  49. },
  50. };
  51. },
  52. created() {
  53. this.getTagFun()
  54. },
  55. methods: {
  56. onClosed() {
  57. this.$refs.form.resetFields();
  58. },
  59. changeTag(index) {
  60. this.tagList[index].selected = !this.tagList[index].selected
  61. let placehoder = '#';
  62. this.tagList.forEach((item, index) => {
  63. if (item.selected) {
  64. placehoder += item.title + '#';
  65. }
  66. })
  67. this.feedback.placeholder = placehoder;
  68. this.$forceUpdate();
  69. },
  70. async submitForm() {
  71. if (!this.feedback.content) return this.$message.error('请输入反馈内容')
  72. const {
  73. status,
  74. data,
  75. msg
  76. } = await this.$post('/suggest', {
  77. title: this.feedback.placeholder, //标签
  78. content: this.feedback.content
  79. });
  80. if (status == 1) {
  81. this.$message.success(msg);
  82. this.showDialog = false;
  83. }
  84. },
  85. async getTagFun() {
  86. const {
  87. status,
  88. data
  89. } = await this.$get('/tag', {});
  90. if (status == 1) {
  91. this.tagList = data
  92. }
  93. },
  94. },
  95. watch: {
  96. value(val) {
  97. this.showDialog = val;
  98. },
  99. showDialog(val) {
  100. this.$emit('input', val)
  101. },
  102. },
  103. };
  104. </script>
  105. <style lang="scss" scoped>
  106. .content {
  107. .el-cascader {
  108. width: 468px;
  109. }
  110. .el-textarea {
  111. width: 468px;
  112. }
  113. .dialog-footer {
  114. text-align: center;
  115. .el-button {
  116. width: 160px;
  117. }
  118. }
  119. margin: 24px;
  120. padding: 24px;
  121. box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.03);
  122. border-radius: 18px 18px 18px 18px;
  123. }
  124. .tag-item {
  125. margin: 8px;
  126. padding: 0px 24px;
  127. border-radius: 28px;
  128. border: 1px solid #B8B8B8;
  129. cursor: pointer;
  130. line-height: 35px;
  131. }
  132. .tat-active {
  133. border: 1px solid #F37171;
  134. font-weight: 400;
  135. color: #F37171;
  136. }
  137. .uni-textarea {
  138. padding: 20px;
  139. height: 300px;
  140. background: #F7F7F7;
  141. border-radius: 5px;
  142. margin-bottom: 20px;
  143. textarea {
  144. width: 100%;
  145. height: 260px !important;
  146. min-height: 260px;
  147. max-height: 260px;
  148. overflow-y: hidden;
  149. font-size: 28px;
  150. }
  151. }
  152. .footer {
  153. margin-top: 40px;
  154. box-sizing: content-box;
  155. padding: 0 30px;
  156. .footer-text {
  157. height: 88px;
  158. line-height: 88px;
  159. background-color: $--color-primary;
  160. box-shadow: 0px 6px 12px 2px rgba(221, 66, 80, 0.23);
  161. border-radius: 18px 18px 18px 18px;
  162. font-size: 32px;
  163. font-family: PingFang SC-Medium, PingFang SC;
  164. font-weight: 500;
  165. }
  166. }
  167. .grade-form {
  168. //padding-bottom: calc(120px + env(safe-area-inset-bottom));
  169. }
  170. .user-content {
  171. padding: 30px;
  172. background-size: 100% auto;
  173. background-repeat: no-repeat;
  174. .user-img {
  175. width: 88px;
  176. height: 88px;
  177. overflow: hidden;
  178. border-radius: 50%;
  179. image {
  180. width: 100%;
  181. }
  182. }
  183. .user-text {}
  184. }
  185. </style>