index.vue 8.9 KB

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