選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

addOrEditDialog.vue 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <el-dialog v-model="isShow" width="50%" :title="title" @closed="closed">
  3. <el-steps :active="active" finish-status="success" align-center>
  4. <el-step title="选择客户端" />
  5. <el-step title="选择模板" />
  6. <el-step title="其他数据填写" />
  7. </el-steps>
  8. <div style="margin-top: 15px" v-loading="isLoading">
  9. <oneBasicInformation
  10. v-show="active === 0"
  11. @handleTem="handleTem"
  12. :dataList="currentData"
  13. @oneNextHandle="nextHandle($event, 1)"
  14. :userList="userList"
  15. :isShow="isShow"
  16. />
  17. <twoBasicInformation
  18. v-show="active === 1"
  19. :temData="temData"
  20. :dataList="currentData"
  21. @twoNextHandle="nextHandle($event, 2)"
  22. :isShow="isShow"
  23. @backStep="backStep"
  24. />
  25. <threeBasicInformation
  26. v-show="active === 2"
  27. :dataList="currentData"
  28. @submitHandle="submitHandle"
  29. :isShow="isShow"
  30. @backStep="backStep"
  31. />
  32. </div>
  33. </el-dialog>
  34. </template>
  35. <!-- web端信息推送 -->
  36. <script lang="ts" setup>
  37. // 请求函数
  38. // @ts-ignore
  39. import BaseService from '@/utils/baseService'
  40. import { computed, ref } from 'vue'
  41. import oneBasicInformation from './stepFrom/oneBasicInformation.vue'
  42. import twoBasicInformation from './stepFrom/twoBasicInformation.vue'
  43. import threeBasicInformation from './stepFrom/threeBasicInformation.vue'
  44. import { ElMessage } from 'element-plus'
  45. const active = ref(0)
  46. const props = defineProps({
  47. modelValue: {
  48. type: Boolean,
  49. default: false,
  50. },
  51. title: {
  52. type: String,
  53. default: '微信公众号信息推送',
  54. },
  55. dataList: {
  56. type: Object,
  57. default: () => ({}),
  58. },
  59. })
  60. const emit = defineEmits([
  61. 'update:modelValue',
  62. 'handleSendSuccess',
  63. 'handleClose',
  64. ])
  65. const isShow = computed({
  66. get: function () {
  67. if (props.modelValue && props.dataList.id) {
  68. getList() //获取详情数据回填
  69. }
  70. return props.modelValue
  71. },
  72. set: function (newValue) {
  73. emit('update:modelValue', newValue)
  74. },
  75. })
  76. const closed = () => {
  77. emit('handleClose')
  78. }
  79. // 模板数据
  80. const temData = ref<any>([])
  81. let ruleForm: any = ref({})
  82. // 下一步
  83. const nextHandle = (data, step) => {
  84. ruleForm.value = {
  85. ...ruleForm.value,
  86. ...data,
  87. }
  88. active.value = step
  89. }
  90. // 上一步
  91. const backStep = () => {
  92. active.value--
  93. }
  94. // 提交处理
  95. const submitHandle = (data) => {
  96. ruleForm.value = {
  97. ...ruleForm.value,
  98. ...data,
  99. }
  100. let ifcode = ''
  101. let text = ''
  102. if (currentData.value.clientId) {
  103. ruleForm.value = {
  104. ...ruleForm.value,
  105. id: props.dataList.id,
  106. }
  107. ifcode = '/msgw/channel/wxmpsendmessageedit'
  108. text = '编辑'
  109. } else {
  110. ifcode = '/msgw/channel/wxmpsendmessage'
  111. text = '推送'
  112. }
  113. isLoading.value = true
  114. console.log(ruleForm.value)
  115. BaseService.post(ifcode, {
  116. ...ruleForm.value,
  117. })
  118. .then((res: any) => {
  119. isShow.value = false
  120. emit('handleSendSuccess')
  121. if (res && res.statusCode === 0) {
  122. console.log(res)
  123. ElMessage.success(`消息${text}成功`)
  124. } else {
  125. ElMessage.error(`消息${text}失败,原因:${res.message}`)
  126. }
  127. })
  128. .finally(() => {
  129. isLoading.value = false
  130. })
  131. }
  132. const isLoading = ref(false)
  133. const currentData = ref<any>({})
  134. const getList = () => {
  135. isLoading.value = true
  136. BaseService.post('/msgw/message/view', {
  137. id: props.dataList.id,
  138. }).then((res: any) => {
  139. if (res && res.statusCode === 0) {
  140. let bizContent = res.data
  141. let data = bizContent.data || []
  142. currentData.value = data
  143. Promise.allSettled([
  144. handleTem(data.clientId),
  145. getUserInfo(
  146. data.openIdList,
  147. data.registrationIdList,
  148. data.wxOpenidList,
  149. data.mobileList,
  150. data.mpOpenidList
  151. ),
  152. ]).then(() => {
  153. isLoading.value = false
  154. })
  155. } else {
  156. ElMessage.error(res.message)
  157. }
  158. })
  159. }
  160. const userList = ref<any>([])
  161. // 获取公众号模板
  162. const handleTem = async (clientId) => {
  163. await BaseService.post('/msgw/channel/wxmpmessagelist', { clientId }).then(
  164. (res: any) => {
  165. if (res && res.statusCode === 0) {
  166. const bizContent = res.data
  167. console.log(bizContent)
  168. let data = bizContent.data || []
  169. data = data.filter((item) => {
  170. return item.example !== ''
  171. })
  172. temData.value = [...data]
  173. } else {
  174. ElMessage.error(res.message)
  175. }
  176. }
  177. )
  178. }
  179. // 获取用户信息
  180. const getUserInfo = async (
  181. openIdList,
  182. ridList,
  183. wxOpenidList,
  184. mobileList,
  185. mpOpenidList
  186. ) => {
  187. if (
  188. !openIdList &&
  189. !ridList &&
  190. !wxOpenidList &&
  191. !mobileList &&
  192. !mpOpenidList
  193. ) {
  194. return
  195. }
  196. await BaseService.post('/msgw/push/getbyconditionlist', {
  197. openIdList,
  198. ridList,
  199. wxOpenidList,
  200. mobileList,
  201. mpOpenidList,
  202. }).then((res: any) => {
  203. if (res && res.statusCode === 0) {
  204. let bizContent = res.data
  205. let data = bizContent.data || []
  206. userList.value = data
  207. } else {
  208. ElMessage.error(res.message)
  209. }
  210. })
  211. }
  212. </script>