smsLog.vue 12.6 KB
Newer Older
sunhongwei's avatar
sunhongwei committed
1 2 3 4 5
<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
Marcus's avatar
Marcus committed
6 7
      <el-form-item :label="$t('手机号')" prop="mobile">
        <el-input v-model="queryParams.mobile" :placeholder="$t('请输入手机号')" clearable @keyup.enter.native="handleQuery"/>
sunhongwei's avatar
sunhongwei committed
8
      </el-form-item>
Marcus's avatar
Marcus committed
9 10
      <el-form-item :label="$t('短信渠道')" prop="channelId">
        <el-select v-model="queryParams.channelId" :placeholder="$t('请选择短信渠道')" clearable>
sunhongwei's avatar
sunhongwei committed
11 12 13 14 15
          <el-option v-for="channel in channelOptions"
                     :key="channel.id" :value="channel.id"
                     :label="channel.signature + '【' + getDictDataLabel(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE, channel.code) + '】'" />
        </el-select>
      </el-form-item>
Marcus's avatar
Marcus committed
16 17
      <el-form-item :label="$t('模板编号')" prop="templateId">
        <el-input v-model="queryParams.templateId" :placeholder="$t('请输入模板编号')" clearable @keyup.enter.native="handleQuery"/>
sunhongwei's avatar
sunhongwei committed
18
      </el-form-item>
Marcus's avatar
Marcus committed
19 20
      <el-form-item :label="$t('发送状态')" prop="sendStatus">
        <el-select v-model="queryParams.sendStatus" :placeholder="$t('请选择发送状态')" clearable>
sunhongwei's avatar
sunhongwei committed
21 22 23 24
          <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_SEND_STATUS)"
                     :key="dict.value" :label="dict.label" :value="dict.value"/>
        </el-select>
      </el-form-item>
Marcus's avatar
Marcus committed
25
      <el-form-item :label="$t('发送时间')">
邓春圆's avatar
邓春圆 committed
26 27
        <el-date-picker v-model="dateRangeSendTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                        type="datetimerange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
sunhongwei's avatar
sunhongwei committed
28
      </el-form-item>
Marcus's avatar
Marcus committed
29 30
      <el-form-item :label="$t('接收状态')" prop="receiveStatus">
        <el-select v-model="queryParams.receiveStatus" :placeholder="$t('请选择接收状态')" clearable>
sunhongwei's avatar
sunhongwei committed
31 32 33 34
          <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS)"
                     :key="dict.value" :label="dict.label" :value="dict.value"/>
        </el-select>
      </el-form-item>
Marcus's avatar
Marcus committed
35
      <el-form-item :label="$t('接收时间')">
邓春圆's avatar
邓春圆 committed
36 37
        <el-date-picker v-model="dateRangeReceiveTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                        type="datetimerange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
sunhongwei's avatar
sunhongwei committed
38 39
      </el-form-item>
      <el-form-item>
Marcus's avatar
Marcus committed
40 41
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{ $t('重置') }}</el-button>
sunhongwei's avatar
sunhongwei committed
42 43 44 45 46 47
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
邓春圆's avatar
邓春圆 committed
48
        <el-button type="primary" plain icon="el-icon-plus" size="mini"
Marcus's avatar
Marcus committed
49
                   v-hasPermi="['system:sms-log:create']">{{ $t('新增') }}</el-button>
sunhongwei's avatar
sunhongwei committed
50 51 52
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
Marcus's avatar
Marcus committed
53
                   v-hasPermi="['system:sms-log:export']">{{ $t('导出') }}</el-button>
sunhongwei's avatar
sunhongwei committed
54 55 56 57 58 59
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
Marcus's avatar
Marcus committed
60 61
      <el-table-column :label="$t('编号')" align="center" prop="id" />
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" width="180">
sunhongwei's avatar
sunhongwei committed
62 63 64 65
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
66
      <el-table-column :label="$t('手机号')" align="center" prop="mobile" width="120">
sunhongwei's avatar
sunhongwei committed
67 68 69 70 71 72 73
        <template slot-scope="scope">
          <div>{{ scope.row.mobile }}</div>
          <div v-if="scope.row.userType && scope.row.userId">
            <dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType"/>{{ '(' + scope.row.userId + ')' }}
          </div>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
74 75
      <el-table-column :label="$t('短信内容')" align="center" prop="templateContent" width="300" />
      <el-table-column :label="$t('发送状态')" align="center" width="180">
sunhongwei's avatar
sunhongwei committed
76 77 78 79 80
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.SYSTEM_SMS_SEND_STATUS" :value="scope.row.sendStatus"/>
          <div>{{ parseTime(scope.row.sendTime) }}</div>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
81
      <el-table-column :label="$t('接收状态')" align="center" width="180">
sunhongwei's avatar
sunhongwei committed
82 83 84 85 86
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS" :value="scope.row.receiveStatus"/>
          <div>{{ parseTime(scope.row.receiveTime) }}</div>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
87
      <el-table-column :label="$t('短信渠道')" align="center" width="120">
sunhongwei's avatar
sunhongwei committed
88 89 90 91 92
        <template slot-scope="scope">
          <div>{{ formatChannelSignature(scope.row.channelId) }}</div>
          <dict-tag :type="DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE" :value="scope.row.channelCode"/>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
93 94
      <el-table-column :label="$t('模板编号')" align="center" prop="templateId" />
      <el-table-column :label="$t('短信类型')" align="center" prop="templateType">
sunhongwei's avatar
sunhongwei committed
95 96 97 98
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE" :value="scope.row.templateType"/>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
99
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width">
sunhongwei's avatar
sunhongwei committed
100 101
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row,scope.index)"
Marcus's avatar
Marcus committed
102
                     v-hasPermi="['system:sms-log:query']">{{ $t('详细') }}</el-button>
sunhongwei's avatar
sunhongwei committed
103 104 105 106 107 108 109 110
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

    <!-- 短信日志详细 -->
Marcus's avatar
Marcus committed
111
    <el-dialog :title="$t('短信日志详细')" :visible.sync="open" width="700px" append-to-body>
sunhongwei's avatar
sunhongwei committed
112 113 114
      <el-form ref="form" :model="form" label-width="140px" size="mini">
        <el-row>
          <el-col :span="24">
Marcus's avatar
Marcus committed
115
            <el-form-item :label="$t('日志主键:')">{{ form.id }}</el-form-item>
sunhongwei's avatar
sunhongwei committed
116 117
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
118
            <el-form-item :label="$t('短信渠道:')">
sunhongwei's avatar
sunhongwei committed
119 120 121 122 123
              {{formatChannelSignature(form.channelId) }}
              <dict-tag :type="DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE" :value="form.channelCode"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
124
            <el-form-item :label="$t('短信模板:')">
sunhongwei's avatar
sunhongwei committed
125 126 127 128 129 130 131 132
              {{ form.templateId }} | {{ form.templateCode }}
              <dict-tag :type="DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE" :value="form.templateType"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="API 的模板编号:">{{ form.apiTemplateId }}</el-form-item>
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
133
            <el-form-item :label="$t('用户信息:')">{{ form.mobile }}
sunhongwei's avatar
sunhongwei committed
134 135 136 137 138 139
              <span v-if="form.userType && form.userId">
                <dict-tag :type="DICT_TYPE.USER_TYPE" :value="form.userType"/>({{ form.userId }})
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
140
            <el-form-item :label="$t('短信内容:')">{{ form.templateContent }}</el-form-item>
sunhongwei's avatar
sunhongwei committed
141 142
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
143
            <el-form-item :label="$t('短信参数:')">{{ form.templateParams }}</el-form-item>
sunhongwei's avatar
sunhongwei committed
144 145
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
146
            <el-form-item :label="$t('创建时间:')">{{ parseTime(form.createTime) }}</el-form-item>
sunhongwei's avatar
sunhongwei committed
147 148
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
149
            <el-form-item :label="$t('发送状态:')">
sunhongwei's avatar
sunhongwei committed
150 151 152 153
              <dict-tag :type="DICT_TYPE.SYSTEM_SMS_SEND_STATUS" :value="form.sendStatus"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
154
            <el-form-item :label="$t('发送时间:')">{{ parseTime(form.sendTime) }}</el-form-item>
sunhongwei's avatar
sunhongwei committed
155 156
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
157
            <el-form-item :label="$t('发送结果:')">{{ form.sendCode }} | {{ form.sendMsg }}
sunhongwei's avatar
sunhongwei committed
158 159 160 161 162 163 164 165 166 167 168 169
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="API 发送结果:">{{ form.apiSendCode }} | {{ form.apiSendMsg }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="API 短信编号:">{{ form.apiSerialNo }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="API 请求编号:">{{ form.apiRequestId }}</el-form-item>
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
170
            <el-form-item :label="$t('接收状态:')">
sunhongwei's avatar
sunhongwei committed
171 172 173 174
              <dict-tag :type="DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS" :value="form.receiveStatus"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
175
            <el-form-item :label="$t('接收时间:')">{{ parseTime(form.receiveTime) }}</el-form-item>
sunhongwei's avatar
sunhongwei committed
176 177 178 179 180 181 182 183
          </el-col>
          <el-col :span="24">
            <el-form-item label="API 接收结果:">{{ form.apiReceiveCode }} | {{ form.apiReceiveMsg }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
Marcus's avatar
Marcus committed
184
        <el-button @click="open = false">{{ $t('关 闭') }}</el-button>
sunhongwei's avatar
sunhongwei committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { getSmsLogPage, exportSmsLogExcel } from "@/api/system/sms/smsLog";
import {  getSimpleSmsChannels } from "@/api/system/sms/smsChannel";

export default {
  name: "SmsLog",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 短信日志列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dateRangeSendTime: [],
      dateRangeReceiveTime: [],
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        channelId: null,
        templateId: null,
        mobile: null,
        sendStatus: null,
        receiveStatus: null,
      },
      // 短信渠道
      channelOptions: [],
    };
  },
  created() {
    this.getList();
    // 获得短信渠道
    getSimpleSmsChannels().then(response => {
      this.channelOptions = response.data;
    })
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
邓春圆's avatar
邓春圆 committed
246 247
      this.addBeginAndEndTime(params, this.dateRangeSendTime, 'sendTime', false);
      this.addBeginAndEndTime(params, this.dateRangeReceiveTime, 'receiveTime', false);
sunhongwei's avatar
sunhongwei committed
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
      // 执行查询
      getSmsLogPage(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeSendTime = [];
      this.dateRangeReceiveTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.addBeginAndEndTime(params, this.dateRangeSendTime, 'sendTime');
      this.addBeginAndEndTime(params, this.dateRangeReceiveTime, 'receiveTime');
      // 执行导出
      this.$modal.confirm('是否确认导出所有短信日志数据项?').then(() => {
        this.exportLoading = true;
        return exportSmsLogExcel(params);
      }).then(response => {
        this.$download.excel(response, '短信日志.xls');
        this.exportLoading = false;
      }).catch(() => {});
    },
    /** 详细按钮操作 */
    handleView(row) {
      this.open = true;
      this.form = row;
    },
    /** 格式化短信渠道 */
    formatChannelSignature(channelId) {
      for (const channel of this.channelOptions) {
        if (channel.id === channelId) {
          return channel.signature;
        }
      }
Marcus's avatar
Marcus committed
301
      return this.$t('找不到签名:') + channelId;
sunhongwei's avatar
sunhongwei committed
302 303 304 305
    }
  }
};
</script>