index.vue 10.1 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
<!--      <el-form-item :label="$t('创建时间')">-->
23 24 25
<!--        <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>-->
jiuping520's avatar
jiuping520 committed
26
      <el-form-item>
Marcus's avatar
Marcus committed
27 28
        <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
29 30 31 32 33 34 35
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
Marcus's avatar
Marcus committed
36
                   v-hasPermi="['ecw:internal-message:create']">{{ $t('新增') }}</el-button>
jiuping520's avatar
jiuping520 committed
37
      </el-col>
chenjiuping's avatar
chenjiuping committed
38
<!--      <el-col :span="1.5">
jiuping520's avatar
jiuping520 committed
39
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
Marcus's avatar
Marcus committed
40
                   v-hasPermi="['ecw:internal-message:export']">{{ $t('导出') }}</el-button>
chenjiuping's avatar
chenjiuping committed
41
      </el-col>-->
jiuping520's avatar
jiuping520 committed
42 43 44 45 46
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
chenjiuping's avatar
chenjiuping committed
47
      <el-table-column :label="$t('编号')" align="center" prop="id" />
Marcus's avatar
Marcus committed
48 49
      <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
50 51 52 53
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.sendTime) }}</span>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
54 55 56
      <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
57 58 59 60
        <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
61
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" width="180">
chenjiuping's avatar
chenjiuping 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" class-name="small-padding fixed-width">
jiuping520's avatar
jiuping520 committed
67 68
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
Marcus's avatar
Marcus committed
69
                     v-hasPermi="['ecw:internal-message:update']">{{ $t('修改') }}</el-button>
jiuping520's avatar
jiuping520 committed
70
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
Marcus's avatar
Marcus committed
71
                     v-hasPermi="['ecw:internal-message:delete']">{{ $t('删除') }}</el-button>
jiuping520's avatar
jiuping520 committed
72 73 74 75
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
chenjiuping's avatar
chenjiuping committed
76
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.rows"
jiuping520's avatar
jiuping520 committed
77 78 79 80 81
                @pagination="getList"/>

    <!-- 对话框(添加 / 修改) -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
Marcus's avatar
Marcus committed
82 83
        <el-form-item :label="$t('来源')" prop="fromId">
         <el-input v-model="form.fromId" :placeholder="$t('请输入站内信来源')" />
chenjiuping's avatar
chenjiuping committed
84
       </el-form-item>
Marcus's avatar
Marcus committed
85 86
        <el-form-item :label="$t('发送时间')" prop="sendTime">
          <el-date-picker clearable v-model="form.sendTime" type="date" value-format="yyyy-MM-dd" :placeholder="$t('选择发送时间')" />
jiuping520's avatar
jiuping520 committed
87
        </el-form-item>
Marcus's avatar
Marcus committed
88 89
        <el-form-item :label="$t('标题')" prop="title">
          <el-input v-model="form.title" :placeholder="$t('请输入标题')" />
jiuping520's avatar
jiuping520 committed
90
        </el-form-item>
Marcus's avatar
Marcus committed
91
        <el-form-item :label="$t('内容')">
jiuping520's avatar
jiuping520 committed
92 93
          <editor v-model="form.content" :min-height="192"/>
        </el-form-item>
Marcus's avatar
Marcus committed
94 95
        <el-form-item :label="$t('消息类型')" prop="type">
          <el-select v-model="form.type" :placeholder="$t('请选择')">
jiuping520's avatar
jiuping520 committed
96 97 98 99 100 101
            <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INTERNAL_MESSAGE_TYPE)"
                       :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
Marcus's avatar
Marcus committed
102 103
        <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
        <el-button @click="cancel">{{ $t('取 消') }}</el-button>
jiuping520's avatar
jiuping520 committed
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { createInternalMessage, updateInternalMessage, deleteInternalMessage, getInternalMessage, getInternalMessagePage, exportInternalMessageExcel } from "@/api/system/internalMessage";
import Editor from '@/components/Editor';

export default {
  name: "InternalMessage",
  components: {
    Editor,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 站内信列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dateRangeSendTime: [],
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
chenjiuping's avatar
chenjiuping committed
138 139
        page: 1,
        rows: 10,
jiuping520's avatar
jiuping520 committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 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 196 197 198 199 200 201 202
        fromId: null,
        title: null,
        content: null,
        type: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
      this.addBeginAndEndTime(params, this.dateRangeSendTime, 'sendTime');
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行查询
      getInternalMessagePage(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    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();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
Marcus's avatar
Marcus committed
203
      this.title = this.$t("添加站内信");
jiuping520's avatar
jiuping520 committed
204 205 206 207 208 209 210 211
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id;
      getInternalMessage(id).then(response => {
        this.form = response.data;
        this.open = true;
Marcus's avatar
Marcus committed
212
        this.title = this.$t("修改站内信");
jiuping520's avatar
jiuping520 committed
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 246 247 248 249 250 251
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }
        // 修改的提交
        if (this.form.id != null) {
          updateInternalMessage(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        createInternalMessage(this.form).then(response => {
          this.$modal.msgSuccess("新增成功");
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
      this.$modal.confirm('是否确认删除站内信编号为"' + id + '"的数据项?').then(function() {
          return deleteInternalMessage(id);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
chenjiuping's avatar
chenjiuping committed
252 253
      params.page = undefined;
      params.rows = undefined;
jiuping520's avatar
jiuping520 committed
254 255 256 257 258 259 260 261 262 263 264 265 266 267
      this.addBeginAndEndTime(params, this.dateRangeSendTime, 'sendTime');
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行导出
      this.$modal.confirm('是否确认导出所有站内信数据项?').then(() => {
          this.exportLoading = true;
          return exportInternalMessageExcel(params);
        }).then(response => {
          this.$download.excel(response, '${table.classComment}.xls');
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>