peng
2026-03-18 b89df58e3b783f3d718bd85a3e4c6a3bd9ee353c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <a-form>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="模板标题">
          <a-input disabled v-model="templateName" />
        </a-form-item>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="模板内容">
          <a-textarea disabled v-model="templateContent" :autosize="{ minRows: 5, maxRows: 8 }" />
        </a-form-item>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="测试数据">
          <a-textarea placeholder="请输入json格式测试数据" v-model="testData" :autosize="{ minRows: 5, maxRows: 8 }" />
        </a-form-item>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="消息类型">
          <j-dict-select-tag v-model="msgType" placeholder="请选择消息类型" dictCode="msgType" />
        </a-form-item>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="消息接收方">
          <a-input placeholder="请输入消息接收方" v-model="receiver" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>
 
<script>
import { httpAction } from '@tievd/cube-block/lib/api/manage'
 
export default {
  name: 'SysMessageTestModal',
  data() {
    return {
      title: '操作',
      visible: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
 
      confirmLoading: false,
      url: {
        send: '/sys/message/sysMessageTemplate/sendMsg'
      },
      templateName: '',
      templateContent: '',
      receiver: '',
      msgType: '',
      testData: '',
      sendParams: {}
    }
  },
  methods: {
    open(record) {
      this.sendParams.templateCode = record.templateCode
      this.templateName = record.templateName
      this.templateContent = record.templateContent
      this.testData = record.templateTestJson
      this.visible = true
    },
    close() {
      this.receiver = ''
      this.msgType = ''
      this.sendParams = {}
      this.visible = false
    },
    handleOk() {
      let httpurl = this.url.send
      let method = 'post'
      this.sendParams.testData = this.testData
      this.sendParams.receiver = this.receiver
      this.sendParams.msgType = this.msgType
      httpAction(httpurl, this.sendParams, method)
        .then(res => {
          if (res.success) {
            this.$message.success(res.message)
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.confirmLoading = false
          this.close()
        })
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>
 
<style scoped></style>