EditReply.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div class="EditReply">
  3. <template-grail>
  4. <template slot="left">
  5. <a-form :form="form" :label-col="{ span:3 }" :wrapper-col="{ span: 20 }" @submit="handleSubmit">
  6. <a-form-item label="当前公众号">
  7. <div class="public-account">
  8. <div class="account">
  9. <img class="img" :src="editReplyData.headImage" alt="">
  10. {{ editReplyData.nikeName }}
  11. </div>
  12. </div>
  13. </a-form-item>
  14. <a-form-item label="推送内容">
  15. <div class="current-code-desc"><a-icon type="exclamation-circle" /> 推送方式为“全部推送”、“按顺序推送”时,仅第一条消息可设置成多图文。
  16. </div>
  17. </a-form-item>
  18. <a-form-item label="推送方式">
  19. <a-radio-group
  20. v-decorator="['pushType', { rules: [{ required: true, message: '请选择推送方式' }] }]"
  21. >
  22. <a-radio :value="0">
  23. 全部推送
  24. </a-radio>
  25. <a-radio :value="1">
  26. 按顺序推送
  27. </a-radio>
  28. <a-radio :value="2">
  29. 随机推送一条
  30. </a-radio>
  31. </a-radio-group>
  32. </a-form-item>
  33. <a-form-item label="推送内容" class="template-edit-style">
  34. <div class="template-edit">
  35. <template-edit :edit-list="content" @changeContent="changeContent" />
  36. </div>
  37. </a-form-item>
  38. <a-form-item :wrapper-col="{ span: 12, offset: 12 }">
  39. <a-button type="primary" html-type="submit">提交</a-button>
  40. </a-form-item>
  41. </a-form>
  42. </template>
  43. <template slot="right">
  44. <pre-view :list="content"/>
  45. </template>
  46. </template-grail>
  47. </div>
  48. </template>
  49. <script>
  50. import TemplateGrail from '@/components/TemplateGrail'
  51. import PreView from '@/components/PreView'
  52. import TemplateEdit from '@/components/TemplateEdit'
  53. import { getFollowReplyDetail, putFollowReplyEnable } from '@/api/interaction'
  54. import { repalceTag } from '@/utils/global'
  55. export default {
  56. name: 'EditReply',
  57. components: {
  58. TemplateGrail,
  59. PreView,
  60. TemplateEdit
  61. },
  62. created () {
  63. this.getFollowReplyDetail()
  64. },
  65. data () {
  66. return {
  67. form: this.$form.createForm(this, { name: 'coordinated' }),
  68. editReplyData: {},
  69. content: []
  70. }
  71. },
  72. methods: {
  73. // 提交表单
  74. handleSubmit (e) {
  75. e.preventDefault()
  76. this.form.validateFields((err, values) => {
  77. if (!err) {
  78. const { pushType } = values
  79. console.log('Received values of form: ', values)
  80. this.putFollowReplyEnable(pushType)
  81. }
  82. })
  83. },
  84. // 发布二维码
  85. async putFollowReplyEnable (pushType) {
  86. const resultContent = repalceTag.dealListPost(JSON.parse(JSON.stringify(this.content)))
  87. const $par = {
  88. accountId: this.$route.query.accountId,
  89. content: JSON.stringify(resultContent),
  90. pushType,
  91. id: this.$route.query.id
  92. }
  93. if (this.content.length === 0) {
  94. this.$message.error('请填写content的值')
  95. return
  96. }
  97. const { data, code } = await putFollowReplyEnable($par)
  98. if (code === 200) {
  99. console.log(data)
  100. this.$message.success('新增成功')
  101. this.$router.push('/interaction/followReply')
  102. }
  103. },
  104. // 编辑去内容改变
  105. changeContent (item) {
  106. this.content = item
  107. },
  108. // 获取详情
  109. async getFollowReplyDetail () {
  110. const { accountId, id } = this.$route.query
  111. const { data, code } = await getFollowReplyDetail({ accountId }, id)
  112. if (code === 200) {
  113. console.log(data)
  114. this.editReplyData = data
  115. // JSON.parse(data.contents)
  116. this.content = JSON.parse(data.content) || []
  117. this.fillForm(data)
  118. }
  119. },
  120. // 反填表格
  121. fillForm (record) {
  122. const { pushType } = record
  123. this.form.setFieldsValue({ pushType })
  124. }
  125. }
  126. }
  127. </script>
  128. <style scoped lang="less">
  129. .public-account {
  130. display: flex;
  131. .account {
  132. min-width: 240px;
  133. background: #fff;
  134. border: 1px solid #e9e9e9;
  135. overflow: hidden;
  136. height: 48px;
  137. padding: 8px;
  138. display: flex;
  139. justify-content: flex-start;
  140. align-items: center;
  141. margin-right: 20px;
  142. box-sizing: border-box;
  143. img {
  144. width: 30px;
  145. height: 30px;
  146. margin-right: 10px;
  147. }
  148. }
  149. .change-account {
  150. color: #1890ff;
  151. .anticon-swap {
  152. transform: rotate(90deg);
  153. }
  154. }
  155. }
  156. .current-code-desc {
  157. background: #e6f7ff;
  158. border: 1px solid #91d5ff;
  159. padding: 10px 0 10px 16px;
  160. margin-bottom: 12px;
  161. margin-top: 5px;
  162. i {
  163. margin-right: 10px;
  164. color: #0091fa;
  165. }
  166. }
  167. </style>