index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="用户名称" prop="nickName">
  5. <el-input
  6. v-model="queryParams.nickName"
  7. placeholder="请输入用户名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="手机号" prop="phoneNum">
  14. <el-input
  15. v-model="queryParams.phoneNum"
  16. placeholder="请输入手机号"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <!-- <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. plain
  32. icon="el-icon-plus"
  33. size="mini"
  34. @click="handleAdd"
  35. v-hasPermi="['system:messageLog:add']"
  36. >新增</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. plain
  42. icon="el-icon-edit"
  43. size="mini"
  44. :disabled="single"
  45. @click="handleUpdate"
  46. v-hasPermi="['system:messageLog:edit']"
  47. >修改</el-button>
  48. </el-col> -->
  49. <el-col :span="1.5">
  50. <el-button
  51. type="danger"
  52. plain
  53. icon="el-icon-delete"
  54. size="mini"
  55. :disabled="multiple"
  56. @click="handleDelete"
  57. v-hasPermi="['system:messageLog:remove']"
  58. >删除</el-button>
  59. </el-col>
  60. <!-- <el-col :span="1.5">
  61. <el-button
  62. type="warning"
  63. plain
  64. icon="el-icon-download"
  65. size="mini"
  66. @click="handleExport"
  67. v-hasPermi="['system:messageLog:export']"
  68. >导出</el-button>
  69. </el-col> -->
  70. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  71. </el-row>
  72. <el-table v-loading="loading" :data="messageLogList" @selection-change="handleSelectionChange">
  73. <el-table-column type="selection" width="55" align="center" />
  74. <el-table-column label="编号" align="center" prop="id" />
  75. <el-table-column label="用户名称" align="center" prop="nickName" />
  76. <el-table-column label="手机号" align="center" prop="phoneNum" />
  77. <el-table-column label="短信内容" align="center" prop="content" />
  78. <el-table-column label="是否删除" align="center" prop="isDel" />
  79. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  80. <template slot-scope="scope">
  81. <!-- <el-button
  82. size="mini"
  83. type="text"
  84. icon="el-icon-edit"
  85. @click="handleUpdate(scope.row)"
  86. v-hasPermi="['system:messageLog:edit']"
  87. >修改</el-button> -->
  88. <el-button
  89. size="mini"
  90. type="text"
  91. icon="el-icon-delete"
  92. @click="handleDelete(scope.row)"
  93. v-hasPermi="['system:messageLog:remove']"
  94. >删除</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <pagination
  99. v-show="total>0"
  100. :total="total"
  101. :page.sync="queryParams.pageNum"
  102. :limit.sync="queryParams.pageSize"
  103. @pagination="getList"
  104. />
  105. <!-- 添加或修改短信记录对话框 -->
  106. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  107. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  108. <el-form-item label="用户名称" prop="nickName">
  109. <el-input v-model="form.nickName" placeholder="请输入用户名称" />
  110. </el-form-item>
  111. <el-form-item label="手机号" prop="phoneNum">
  112. <el-input v-model="form.phoneNum" placeholder="请输入手机号" />
  113. </el-form-item>
  114. <el-form-item label="短信内容">
  115. <editor v-model="form.content" :min-height="192"/>
  116. </el-form-item>
  117. <el-form-item label="是否删除" prop="isDel">
  118. <el-input v-model="form.isDel" placeholder="请输入是否删除" />
  119. </el-form-item>
  120. </el-form>
  121. <div slot="footer" class="dialog-footer">
  122. <el-button type="primary" @click="submitForm">确 定</el-button>
  123. <el-button @click="cancel">取 消</el-button>
  124. </div>
  125. </el-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import { listMessageLog, getMessageLog, delMessageLog, addMessageLog, updateMessageLog, exportMessageLog } from "@/api/system/messageLog";
  130. import Editor from '@/components/Editor';
  131. export default {
  132. name: "MessageLog",
  133. components: {
  134. Editor,
  135. },
  136. data() {
  137. return {
  138. // 遮罩层
  139. loading: true,
  140. // 选中数组
  141. ids: [],
  142. // 非单个禁用
  143. single: true,
  144. // 非多个禁用
  145. multiple: true,
  146. // 显示搜索条件
  147. showSearch: true,
  148. // 总条数
  149. total: 0,
  150. // 短信记录表格数据
  151. messageLogList: [],
  152. // 弹出层标题
  153. title: "",
  154. // 是否显示弹出层
  155. open: false,
  156. // 查询参数
  157. queryParams: {
  158. pageNum: 1,
  159. pageSize: 10,
  160. nickName: null,
  161. phoneNum: null,
  162. content: null,
  163. isDel: null
  164. },
  165. // 表单参数
  166. form: {},
  167. // 表单校验
  168. rules: {
  169. }
  170. };
  171. },
  172. created() {
  173. this.getList();
  174. },
  175. methods: {
  176. /** 查询短信记录列表 */
  177. getList() {
  178. this.loading = true;
  179. listMessageLog(this.queryParams).then(response => {
  180. this.messageLogList = response.rows;
  181. this.total = response.total;
  182. this.loading = false;
  183. });
  184. },
  185. // 取消按钮
  186. cancel() {
  187. this.open = false;
  188. this.reset();
  189. },
  190. // 表单重置
  191. reset() {
  192. this.form = {
  193. id: null,
  194. nickName: null,
  195. phoneNum: null,
  196. content: null,
  197. createBy: null,
  198. createTime: null,
  199. updateBy: null,
  200. updateTime: null,
  201. isDel: null
  202. };
  203. this.resetForm("form");
  204. },
  205. /** 搜索按钮操作 */
  206. handleQuery() {
  207. this.queryParams.pageNum = 1;
  208. this.getList();
  209. },
  210. /** 重置按钮操作 */
  211. resetQuery() {
  212. this.resetForm("queryForm");
  213. this.handleQuery();
  214. },
  215. // 多选框选中数据
  216. handleSelectionChange(selection) {
  217. this.ids = selection.map(item => item.id)
  218. this.single = selection.length!==1
  219. this.multiple = !selection.length
  220. },
  221. /** 新增按钮操作 */
  222. handleAdd() {
  223. this.reset();
  224. this.open = true;
  225. this.title = "添加短信记录";
  226. },
  227. /** 修改按钮操作 */
  228. handleUpdate(row) {
  229. this.reset();
  230. const id = row.id || this.ids
  231. getMessageLog(id).then(response => {
  232. this.form = response.data;
  233. this.open = true;
  234. this.title = "修改短信记录";
  235. });
  236. },
  237. /** 提交按钮 */
  238. submitForm() {
  239. this.$refs["form"].validate(valid => {
  240. if (valid) {
  241. if (this.form.id != null) {
  242. updateMessageLog(this.form).then(response => {
  243. this.msgSuccess("修改成功");
  244. this.open = false;
  245. this.getList();
  246. });
  247. } else {
  248. addMessageLog(this.form).then(response => {
  249. this.msgSuccess("新增成功");
  250. this.open = false;
  251. this.getList();
  252. });
  253. }
  254. }
  255. });
  256. },
  257. /** 删除按钮操作 */
  258. handleDelete(row) {
  259. const ids = row.id || this.ids;
  260. this.$confirm('是否确认删除短信记录编号为"' + ids + '"的数据项?', "警告", {
  261. confirmButtonText: "确定",
  262. cancelButtonText: "取消",
  263. type: "warning"
  264. }).then(function() {
  265. return delMessageLog(ids);
  266. }).then(() => {
  267. this.getList();
  268. this.msgSuccess("删除成功");
  269. })
  270. },
  271. /** 导出按钮操作 */
  272. handleExport() {
  273. const queryParams = this.queryParams;
  274. this.$confirm('是否确认导出所有短信记录数据项?', "警告", {
  275. confirmButtonText: "确定",
  276. cancelButtonText: "取消",
  277. type: "warning"
  278. }).then(function() {
  279. return exportMessageLog(queryParams);
  280. }).then(response => {
  281. this.download(response.msg);
  282. })
  283. }
  284. }
  285. };
  286. </script>