publish.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <div class="app-container">
  3. <span><i class="el-icon-user"></i> 个人发表 - {{nickName}}</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="contents">
  7. <el-input
  8. v-model="queryParams.contents"
  9. placeholder="请输入内容"
  10. clearable
  11. size="small"
  12. @keyup.enter.native="handleQuery"
  13. />
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  17. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  18. </el-form-item>
  19. </el-form>
  20. <el-row :gutter="10" class="mb8">
  21. <el-col :span="1.5">
  22. <el-button
  23. type="danger"
  24. icon="el-icon-delete"
  25. size="mini"
  26. :disabled="multiple"
  27. @click="handleDelete"
  28. v-hasPermi="['system:publish:remove']"
  29. >删除</el-button>
  30. </el-col>
  31. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  32. </el-row>
  33. <el-table v-loading="loading" :data="publishList" @selection-change="handleSelectionChange">
  34. <el-table-column type="selection" width="55" align="center" />
  35. <el-table-column label="主键id" align="center" prop="id" v-if="false"/>
  36. <el-table-column label="发表内容" align="center" prop="contents" :formatter="contentsFormat" width="450"/>
  37. <el-table-column label="发布时间" align="center" prop="createTime" width="160"/>
  38. <el-table-column
  39. label="纪念留言"
  40. align="center"
  41. prop="message"
  42. :formatter="messageFormat"
  43. width="100"
  44. />
  45. <el-table-column label="点赞数" align="center" prop="thumbs" />
  46. <el-table-column label="评论数" align="center" prop="comments" />
  47. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  48. <template slot-scope="scope">
  49. <el-button
  50. size="mini"
  51. type="text"
  52. icon="el-icon-search"
  53. @click="handleUpdate(scope.row)"
  54. v-hasPermi="['system:publish:edit']"
  55. >查看</el-button>
  56. <el-button
  57. size="mini"
  58. type="text"
  59. icon="el-icon-delete"
  60. @click="handleDelete(scope.row)"
  61. v-hasPermi="['system:publish:remove']"
  62. >删除</el-button>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. <pagination
  67. v-show="total>0"
  68. :total="total"
  69. :page.sync="queryParams.pageNum"
  70. :limit.sync="queryParams.pageSize"
  71. @pagination="getList"
  72. />
  73. <!-- 添加或修改我的近况(发)对话框 -->
  74. <el-dialog :visible.sync="open" width="600px" append-to-body :close-on-click-modal=false>
  75. <el-card class="box-card">
  76. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  77. <el-card class="box-card" shadow="hover">
  78. <div style="line-height:150%">{{form.contents}}</div>
  79. <el-divider />
  80. <div>
  81. <div style="float: left;padding:0px 0px 10px;">
  82. <el-tag type="info"> 点赞数:{{form.thumbs}} </el-tag>
  83. </div>
  84. <div v-if="form.message == 'Y'" style="float: right;font-size: 10px;color:#909399;">
  85. <div style="padding:1px;">留 念 人:{{form.messageUser}}</div>
  86. <div style="padding:2px;">发布时间:{{form.createTime}}</div>
  87. </div>
  88. </div>
  89. </el-card>
  90. <div class="block1">
  91. <el-collapse>
  92. <el-collapse-item>
  93. <template slot="title">
  94. <i class="header-icon el-icon-picture-outline-round"></i> 查看图片
  95. </template>
  96. <div v-for="item in imgList" :key="item.key" class="block">
  97. <el-image :key="item.key" :src="item.value" :preview-src-list="[item.value]" class="images" />
  98. </div>
  99. </el-collapse-item>
  100. </el-collapse>
  101. </div>
  102. </el-form>
  103. <el-card class="box-card" shadow="hover" :body-style="{height:'200px'}">
  104. <div slot="header" class="clearfix">
  105. <span>评论</span>
  106. <div style="float: right; padding: 3px 0">{{form.comments}}</div>
  107. </div>
  108. <el-carousel :autoplay="false" :loop="false" arrow="always">
  109. <el-carousel-item v-for="item in commentList" :key="item.id">
  110. <el-row :gutter="10" type="flex" justify="start">
  111. <el-col :span="3" style="padding: 10px;margin:0 auto;text-align:center;">
  112. <el-avatar :size="40" :src="item.appUserUrl"></el-avatar>
  113. <div style="width: 100%;margin:0 auto;text-align:center;">
  114. <span>{{item.appUser}}</span>
  115. </div>
  116. </el-col>
  117. <el-col :span="21" style="padding: 10px">
  118. <div style="float: right;">
  119. <el-button type="danger" size="mini" icon="el-icon-delete" circle @click="delComm(item)"/>
  120. </div>
  121. <div style="float: top;font-size:11px;color:#909399;padding:0px 0px 10px">
  122. {{item.createTime}}
  123. </div>
  124. <div style="float: bottom;font-size:12px;height:120px">
  125. {{item.contents}}
  126. </div>
  127. </el-col>
  128. </el-row>
  129. </el-carousel-item>
  130. </el-carousel>
  131. </el-card>
  132. </el-card>
  133. <div slot="footer" class="dialog-footer">
  134. <el-button @click="cancel" type="primary">关 闭</el-button>
  135. </div>
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. import { listPublish, getPublish, delPublish, addPublish, updatePublish, exportPublish,listComment,delComment } from "@/api/system/publish";
  141. import { getUser } from "@/api/system/appUser";
  142. export default {
  143. name: "Publish",
  144. data() {
  145. return {
  146. // 遮罩层
  147. loading: true,
  148. // 选中数组
  149. ids: [],
  150. pid: null,
  151. // 非单个禁用
  152. single: true,
  153. // 非多个禁用
  154. multiple: true,
  155. // 显示搜索条件
  156. showSearch: true,
  157. // 总条数
  158. total: 0,
  159. // 我的近况表格数据
  160. publishList: [],
  161. imgList:[],
  162. messageOptions: [],
  163. // 弹出层标题
  164. title: "",
  165. // 是否显示弹出层
  166. open: false,
  167. nickName: "",
  168. commentList: [],
  169. // 查询参数
  170. queryParams: {
  171. pageNum: 1,
  172. pageSize: 10,
  173. appUserId: null,
  174. contents: null,
  175. message: null,
  176. messageUserId: null,
  177. deleted: null,
  178. },
  179. // 表单参数
  180. form: {},
  181. // 表单校验
  182. rules: {
  183. }
  184. };
  185. },
  186. created() {
  187. const uid = this.$route.query.uid;
  188. this.queryParams.appUserId = uid;
  189. this.getDicts("sys_yes_no").then(response => {
  190. this.messageOptions = response.data;
  191. });
  192. this.getUser(uid);
  193. this.getList();
  194. },
  195. methods: {
  196. getUser(id){
  197. getUser(id).then(response => {
  198. const nickName = response.data.nickName;
  199. this.nickName = nickName == null ? "全部" : nickName;
  200. });
  201. },
  202. /** 查询我的近况(发)列表 */
  203. getList() {
  204. this.loading = true;
  205. this.queryParams.deleted = 'N'
  206. listPublish(this.queryParams).then(response => {
  207. this.publishList = response.rows;
  208. this.total = response.total;
  209. this.loading = false;
  210. });
  211. },
  212. // 是否纪念留言 字典翻译
  213. messageFormat(row, column) {
  214. return this.selectDictLabel(this.messageOptions, row.message);
  215. },
  216. contentsFormat(row, column) {
  217. var len = 28;
  218. if(row.contents.length >= len) {
  219. return row.contents.substr(0,len)+"...";
  220. }
  221. return row.contents;
  222. },
  223. // 取消按钮
  224. cancel() {
  225. this.open = false;
  226. this.reset();
  227. },
  228. // 表单重置
  229. reset() {
  230. this.form = {
  231. id: null,
  232. appUserId: null,
  233. contents: null,
  234. message: null,
  235. messageUserId: null,
  236. thumbs: null,
  237. createBy: null,
  238. createTime: null,
  239. updateBy: null,
  240. updateTime: null,
  241. remark: null,
  242. imgList: []
  243. };
  244. this.resetForm("form");
  245. },
  246. /** 搜索按钮操作 */
  247. handleQuery() {
  248. this.queryParams.pageNum = 1;
  249. this.getList();
  250. },
  251. /** 重置按钮操作 */
  252. resetQuery() {
  253. this.resetForm("queryForm");
  254. this.handleQuery();
  255. },
  256. // 多选框选中数据
  257. handleSelectionChange(selection) {
  258. this.ids = selection.map(item => item.id)
  259. this.single = selection.length!==1
  260. this.multiple = !selection.length
  261. },
  262. /** 新增按钮操作 */
  263. handleAdd() {
  264. this.reset();
  265. this.open = true;
  266. this.title = "添加我的发表";
  267. },
  268. /** 修改按钮操作 */
  269. handleUpdate(row) {
  270. this.reset();
  271. const id = row.id || this.ids;
  272. getPublish(id).then(response => {
  273. this.form = response.data;
  274. this.open = true;
  275. this.title = "查看我的发表";
  276. this.imgList = [];
  277. var apiUrl = process.env.VUE_APP_BASE_API;
  278. var items = response.data.imgList;
  279. for (const i in items) {
  280. var url = apiUrl + items[i].url;
  281. this.imgList.push({ key: items[i].id, value: url})
  282. }
  283. this.listComment(id);
  284. });
  285. },
  286. listComment(id) {
  287. listComment(id).then(res => {
  288. this.commentList = res.rows;
  289. });
  290. },
  291. /** 提交按钮 */
  292. submitForm() {
  293. this.$refs["form"].validate(valid => {
  294. if (valid) {
  295. if (this.form.id != null) {
  296. updatePublish(this.form).then(response => {
  297. if (response.code === 200) {
  298. this.msgSuccess("修改成功");
  299. this.open = false;
  300. this.getList();
  301. }
  302. });
  303. } else {
  304. addPublish(this.form).then(response => {
  305. if (response.code === 200) {
  306. this.msgSuccess("新增成功");
  307. this.open = false;
  308. this.getList();
  309. }
  310. });
  311. }
  312. }
  313. });
  314. },
  315. /** 删除按钮操作 */
  316. handleDelete(row) {
  317. const ids = row.id || this.ids;
  318. this.$confirm('是否确认删除?', "警告", {
  319. confirmButtonText: "确定",
  320. cancelButtonText: "取消",
  321. type: "warning"
  322. }).then(function() {
  323. return delPublish(ids);
  324. }).then(() => {
  325. this.getList();
  326. this.msgSuccess("删除成功");
  327. }).catch(function() {});
  328. },
  329. /** 导出按钮操作 */
  330. handleExport() {
  331. const queryParams = this.queryParams;
  332. this.$confirm('是否确认导出所有我的发表数据项?', "警告", {
  333. confirmButtonText: "确定",
  334. cancelButtonText: "取消",
  335. type: "warning"
  336. }).then(function() {
  337. return exportPublish(queryParams);
  338. }).then(response => {
  339. this.download(response.msg);
  340. }).catch(function() {});
  341. },
  342. delComm(item) {
  343. var id = item.id;
  344. this.$confirm('是否删除这条评论?', "警告", {
  345. confirmButtonText: "确定",
  346. cancelButtonText: "取消",
  347. type: "warning"
  348. }).then(function() {
  349. return delComment(id);
  350. }).then(() => {
  351. this.listComment(item.publishId);
  352. this.form.comments -= 1;
  353. this.msgSuccess("删除成功");
  354. }).catch(function() {});
  355. }
  356. }
  357. };
  358. </script>
  359. <style>
  360. .el-dialog__body {
  361. padding: 10px 20px;
  362. }
  363. .el-form-item {
  364. margin-bottom: 8px;
  365. }
  366. .block {
  367. padding: 1px 1px 0px;
  368. display: inline-block;
  369. align-items: center;
  370. }
  371. .block1 {
  372. width: 100%;
  373. padding: 10px 0px 10px;
  374. }
  375. .images {
  376. width: 140px;
  377. display: block;
  378. }
  379. .image-slot {
  380. display: flex;
  381. justify-content: center;
  382. align-items: center;
  383. width: 100%;
  384. height: 100%;
  385. background: #f5f7fa;
  386. color: #909399;
  387. }
  388. .el-divider--horizontal {
  389. margin: 10px 0px;
  390. }
  391. .el-card__body {
  392. padding: 12px;
  393. }
  394. .el-carousel__item {
  395. height: 200px;
  396. }
  397. </style>