index.vue 8.5 KB
Newer Older
jiuping520's avatar
jiuping520 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="68px">
Marcus's avatar
Marcus committed
6 7
<!--      <el-form-item :label="$t('来源')" prop="fromId">
        <el-input v-model="queryParams.fromId" :placeholder="$t('请输入站内信来源')" clearable @keyup.enter.native="handleQuery"/>
8
      </el-form-item>-->
Marcus's avatar
Marcus committed
9
      <el-form-item :label="$t('发送时间')">
jiuping520's avatar
jiuping520 committed
10 11 12
        <el-date-picker v-model="dateRangeSendTime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item>
Marcus's avatar
Marcus committed
13 14
      <el-form-item :label="$t('标题')" prop="title">
        <el-input v-model="queryParams.title" :placeholder="$t('请输入标题')" clearable @keyup.enter.native="handleQuery"/>
jiuping520's avatar
jiuping520 committed
15
      </el-form-item>
Marcus's avatar
Marcus committed
16 17
      <el-form-item :label="$t('消息类型')" prop="type">
        <el-select v-model="queryParams.type" :placeholder="$t('请选择')" clearable size="small">
jiuping520's avatar
jiuping520 committed
18 19 20 21
          <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INTERNAL_MESSAGE_TYPE)"
                       :key="dict.value" :label="dict.label" :value="dict.value"/>
        </el-select>
      </el-form-item>
Marcus's avatar
Marcus committed
22 23
      <el-form-item :label="$t('状态')" prop="status">
        <el-select v-model="queryParams.status" :placeholder="$t('请选择')" clearable size="small">
jiuping520's avatar
jiuping520 committed
24 25 26 27
          <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INTERNAL_MESSAGE_READ_STATUS)"
                     :key="dict.value" :label="dict.label" :value="dict.value"/>
        </el-select>
      </el-form-item>
Marcus's avatar
Marcus committed
28
      <el-form-item :label="$t('创建时间')">
jiuping520's avatar
jiuping520 committed
29 30 31 32
        <el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item>
      <el-form-item>
Marcus's avatar
Marcus committed
33 34
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{ $t('重置') }}</el-button>
jiuping520's avatar
jiuping520 committed
35 36 37 38 39 40
      </el-form-item>
    </el-form>


    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
chenjiuping's avatar
chenjiuping committed
41
      <el-table-column :label="$t('编号')" align="center" prop="id" />
Marcus's avatar
Marcus committed
42 43
<!--      <el-table-column :label="$t('来源')" align="center" prop="fromId" />-->
      <el-table-column :label="$t('发送时间')" align="center" prop="sendTime" width="180">
jiuping520's avatar
jiuping520 committed
44 45 46 47
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.sendTime) }}</span>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
48 49 50
      <el-table-column :label="$t('标题')" align="center" prop="title" />
<!--      <el-table-column :label="$t('内容')" align="center" prop="content" />-->
      <el-table-column :label="$t('消息类型')" align="center" prop="type">
jiuping520's avatar
jiuping520 committed
51 52 53 54
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.INTERNAL_MESSAGE_TYPE" :value="scope.row.type" />
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
55
      <el-table-column :label="$t('状态')" align="center" prop="status" width="50">
jiuping520's avatar
jiuping520 committed
56 57 58 59
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.INTERNAL_MESSAGE_READ_STATUS" :value="scope.row.status" />
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
60
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" width="180">
jiuping520's avatar
jiuping520 committed
61 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" class-name="small-padding fixed-width">
jiuping520's avatar
jiuping520 committed
67
        <template slot-scope="scope">
Marcus's avatar
Marcus committed
68 69
          <el-button size="mini" type="text" icon="el-icon-edit" @click="viewMessage(scope.row)">{{ $t('查看') }}</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="deleteFn(scope.row)">{{ $t('删除') }}</el-button>
jiuping520's avatar
jiuping520 committed
70 71 72 73
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
dcy's avatar
dcy committed
74
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.rows"
jiuping520's avatar
jiuping520 committed
75
                @pagination="getList"/>
dcy's avatar
dcy committed
76 77

    <el-dialog
Marcus's avatar
Marcus committed
78
      :title="$t('站内信')"
dcy's avatar
dcy committed
79 80 81 82
      :visible.sync="dialogVisible"
      width="50%">
      <div class="from">
      <div class="from-item">
Marcus's avatar
Marcus committed
83
        <div class="label">{{ $t('标题:') }}</div>
dcy's avatar
dcy committed
84 85 86
        <div class="content">{{publicObj.title}}</div>
      </div>
      <div class="from-item">
Marcus's avatar
Marcus committed
87
        <div class="label">{{ $t('消息分类:') }}</div>
dcy's avatar
dcy committed
88 89 90
        <div class="content">{{type[publicObj.type]}}</div>
      </div>
      <div class="from-item">
Marcus's avatar
Marcus committed
91
        <div class="label">{{ $t('创建时间') }}</div>
dcy's avatar
dcy committed
92 93 94
        <div class="content">{{parseTime(publicObj.createTime)}}</div>
      </div>
      <div class="from-item">
Marcus's avatar
Marcus committed
95
        <div class="label">{{ $t('消息内容:') }}</div>
dcy's avatar
dcy committed
96 97 98 99
        <div class="content">{{publicObj.content}}</div>
      </div>
      </div>
      <span slot="footer" class="dialog-footer">
Marcus's avatar
Marcus committed
100
    <el-button @click="dialogVisible = false">{{ $t('关 闭') }}</el-button>
dcy's avatar
dcy committed
101 102
  </span>
    </el-dialog>
jiuping520's avatar
jiuping520 committed
103 104 105 106
  </div>
</template>

<script>
dcy's avatar
dcy committed
107
import {  getMyInternalMessagePage ,getRedInternalMessage, deleteInternalMessage} from "@/api/system/internalMessage";
jiuping520's avatar
jiuping520 committed
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
export default {
  name: "MyInternalMessage",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 站内信列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dateRangeSendTime: [],
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
dcy's avatar
dcy committed
130 131
        page: 1,
        rows: 10,
jiuping520's avatar
jiuping520 committed
132 133 134 135 136 137 138 139
        fromId: null,
        title: null,
        content: null,
        type: null,
        status: this.$route.query.status?this.$route.query.status:null,
      },
      // 表单参数
      form: {},
dcy's avatar
dcy committed
140 141
      dialogVisible:false,
      publicObj:{},
142 143 144 145 146
      type: {
        1:this.$t('订单消息'),
        2:this.$t('出货消息'),
        3:this.$t('提醒消息'),
      },
jiuping520's avatar
jiuping520 committed
147 148
    };
  },
dcy's avatar
dcy committed
149 150 151 152 153
  computed:{
    notMessage() {
      return this.$store.state.user.notMessage;
    }
  },
jiuping520's avatar
jiuping520 committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
      this.addBeginAndEndTime(params, this.dateRangeSendTime, 'sendTime');
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行查询
      getMyInternalMessagePage(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        fromId: undefined,
        sendTime: undefined,
        title: undefined,
        content: undefined,
        type: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeSendTime = [];
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
dcy's avatar
dcy committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
    viewMessage(row){
     this.publicObj = row;
     this.dialogVisible = true;
     if(row.status == 0)this.setNotMessage(row.id)
    },
    setNotMessage(id){
      getRedInternalMessage({messageId:id}).then(r =>{
      console.log(r)
        if(r.code === 0){
          this.getList()
          let num = Number(this.notMessage);
          this.$store.commit('NOt_MESSAGE',--num);
        }
      })
    },
    deleteFn(row){
chenjiuping's avatar
chenjiuping committed
212
      this.$confirm(`是否要删除编号为“${row.id}”的站内信?`, this.$t('提示'), {
Marcus's avatar
Marcus committed
213 214
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
dcy's avatar
dcy committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228
        type: 'warning'
      }).then(() => {
        deleteInternalMessage(row.id).then(r => {
          if(r.code === 0){
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            this.getList();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
Marcus's avatar
Marcus committed
229
          message: this.$t('已取消删除')
dcy's avatar
dcy committed
230 231
        });
      });
jiuping520's avatar
jiuping520 committed
232 233 234 235
    }
  }
};
</script>
dcy's avatar
dcy committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249
<style lang="scss" scoped>
.from{
  .from-item{
    display: flex;
    margin: 10px 0;
    .label{
      width:80px;
    }
    .content{
      flex: 1;
    }
  }
}
</style>