userCenterCollectionInformation.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div style="width: 95%;background: #fff;min-height: 700px;color: #666;margin-left:0" class="userCenterMyActivity">
  3. <div style="margin-top: 10px;">
  4. <el-table
  5. :data="tableData"
  6. stripe
  7. highlight-current-row
  8. style="text-align:center"
  9. @cell-click="cellClick"
  10. >
  11. <template slot="empty">
  12. {{ $t('common.UserNoData') }}
  13. </template>
  14. <el-table-column type="index" fixed :label="$t('common.serialNumber')" width="80"></el-table-column>
  15. <el-table-column prop="title" :label="$t('common.titleInformation')" width='540px'></el-table-column>
  16. <!-- <el-table-column prop="businessType" :label="$t('common.Type')" width='220'> </el-table-column> -->
  17. <el-table-column prop="collectDate" :label="$t('common.CollectionTime')" width="200"></el-table-column>
  18. <el-table-column prop="address5" :label="$t('common.Option')" width="100">
  19. <template slot-scope="scope">
  20. <el-button
  21. type="text"
  22. size="small">
  23. {{ $t('common.CancelCollection') }}
  24. </el-button>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  28. </div>
  29. <div style="position: relative;width: 100%;height: 200px;" v-if="tableData.length>0">
  30. <el-pagination
  31. type="index"
  32. :index="indexMethod"
  33. style="position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);"
  34. background
  35. layout="prev, pager, next"
  36. :page-size="10"
  37. :total="total-0"
  38. @current-change="handleCurrentChange">
  39. </el-pagination>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import {get, collectModelStatusByModelIdAndUserId, del} from '@/api/operation/consultMessageInfo'
  45. import {addCollectInfo} from "@/api/baseUnitView";
  46. import {getPortalMyCollecModel} from "@/api/baseContactsInfo"
  47. import Base from "@/views/base/Base";
  48. import {formatDate} from "@/utils/formatUtils";
  49. import {getToken, resetToken} from "@/utils/auth";
  50. export default {
  51. name: 'userCenterCollectionInformation',
  52. extends: Base,
  53. data() {
  54. return {
  55. formInline: {
  56. user: '',
  57. region: ''
  58. },
  59. params: {
  60. modelType: 'message',
  61. userId: "",
  62. language: '',
  63. pageNo: '1'
  64. },
  65. num: 0,
  66. total: 0,
  67. userId: '',
  68. tableData: []
  69. }
  70. },
  71. mounted() {
  72. this.getInData();
  73. },
  74. watch: {
  75. '$i18n.locale'() {
  76. this.getInData();
  77. }
  78. },
  79. methods: {
  80. cellClick(row, column, cell, event) {
  81. if (column.property != 'address5') {
  82. this.openDetails(row)
  83. } else {
  84. this.unCollection(row.baseEntityId)
  85. }
  86. },
  87. openDetails(row) {
  88. this.toView('realTimeInfoItemdetails', row.baseEntityId)
  89. },
  90. toView(router, json) {
  91. this.$store.commit('modify', router);
  92. window.localStorage.setItem('router', router);
  93. const {href} = this.$router.resolve({
  94. name: router,
  95. query: {
  96. key: json
  97. }
  98. });
  99. window.open(href, '_blank');
  100. },
  101. unCollection: function (id) {
  102. let user = window.localStorage.getItem("user");
  103. if (!this.$Cookies.get('token')) {
  104. this.$message.warning(this.$i18n.locale == 'zh' ? "请先登录" : "Please login first");
  105. } else {
  106. var users = JSON.parse(user);
  107. var token = "" + getToken();
  108. this.userId = users.userId;
  109. var modelId = id;
  110. this.submitHandler((token) => {
  111. addCollectInfo(modelId, "message", this.userId, "uncollect", token).then((res) => {
  112. if (res.status == 200) {
  113. this.$message({
  114. message: this.$i18n.locale == 'zh' ? "取消收藏" : "Cancel the like",
  115. type: 'success'
  116. });
  117. }
  118. this.resetToken();
  119. }).catch(error => {
  120. this.resetToken();
  121. });
  122. });
  123. }
  124. },
  125. getInData() {
  126. let user = window.localStorage.getItem('user');
  127. var users = JSON.parse(user);
  128. var userId = users.userId;
  129. this.params.language = this.$i18n.locale.toUpperCase()
  130. this.params.userId = userId;
  131. getPortalMyCollecModel(this.params).then(res => {
  132. this.num = res.data.models.cmsInformationViewList.length;
  133. this.tableData = res.data.models.cmsInformationViewList;
  134. let tableCmsInformationViewData = [];
  135. this.tableData.forEach((i) => {
  136. i.createDate = i.createDate ? formatDate(i.createDate, "YYYY-MM-DD") : "";
  137. i.collectDate = i.collectDate ? formatDate(i.collectDate, "YYYY-MM-DD") : "";
  138. if (Object.is(i.language, this.$i18n.locale.toUpperCase())) {
  139. tableCmsInformationViewData.push(i);
  140. }
  141. });
  142. this.tableData = tableCmsInformationViewData;
  143. this.total = res.data ? res.data.page.totalCount - 0 : 0;
  144. })
  145. },
  146. //时间格式化
  147. dateFormat(row, column, cellValue, index) {
  148. const daterc = row[column.property];
  149. if (daterc != null) {
  150. const dateMat = new Date(parseInt(daterc.replace("/Date(", "").replace(")/", ""), 10));
  151. const year = dateMat.getFullYear();
  152. const month = dateMat.getMonth() + 1;
  153. const day = dateMat.getDate();
  154. const hh = dateMat.getHours();
  155. const mm = dateMat.getMinutes();
  156. const ss = dateMat.getSeconds();
  157. const timeFormat = year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;
  158. return timeFormat;
  159. }
  160. },
  161. // 发布
  162. release(index, rows) {
  163. console.log(index, rows)
  164. },
  165. // 编辑
  166. change(index, rows) {
  167. console.log(index, rows)
  168. },
  169. // 删除
  170. deleteRow(index, rows) {
  171. console.log(index, rows)
  172. },
  173. // 撤回
  174. withdraw(index, rows) {
  175. console.log(index, rows)
  176. },
  177. //分页索引接着上一页的索引
  178. indexMethod(index) {
  179. return (this.page - 1) * 10 + index + 1;
  180. },
  181. // handleSizeChange(val) {
  182. // console.log(`每页 ${val} 条`);
  183. // },
  184. handleCurrentChange(val) {
  185. this.params.pageNo = val;
  186. this.getInData();
  187. }
  188. }
  189. }
  190. </script>
  191. <style scoped>
  192. .el-input {
  193. width: 200px;
  194. }
  195. .el-form-item__content, .el-select {
  196. width: 200px !important;
  197. }
  198. .el-table thead {
  199. background: #eee;
  200. }
  201. .userCenterMyActivity >>> .el-pagination .el-pager li,
  202. .userCenterMyActivity >>> .el-pagination .btn-next,
  203. .userCenterMyActivity >>> .el-pagination .btn-prev {
  204. width: 35px;
  205. height: 35px;
  206. line-height: 35px;
  207. }
  208. .userCenterMyActivity >>> .el-pagination.is-background .el-pager li:not(.disabled).active {
  209. background: #0050d8;
  210. }
  211. /* .margin_left {
  212. margin-left: 5px;
  213. } */
  214. /* .margin_top{
  215. margin-top: 5px;
  216. } */
  217. .myActivityLi {
  218. width: 295px;
  219. float: left;
  220. height: 256px;
  221. margin-bottom: 20px;
  222. border: 1px solid rgba(228, 228, 228, 1);
  223. box-shadow: rgba(228, 228, 228, 1);
  224. }
  225. .myActivityLi .title {
  226. color: #ccc;
  227. font-size: 14px;
  228. }
  229. .myActivityLi_data {
  230. color: #666;
  231. font-size: 12px;
  232. margin-top: 5px;
  233. margin-left: 10px;
  234. }
  235. .myActivity ul {
  236. text-align: top;
  237. height: 100%;
  238. display: flex;
  239. display: -webkit-flex; /* Safari */
  240. justify-content: space-between;
  241. flex-wrap: wrap;
  242. }
  243. .el-tag {
  244. height: 22px;
  245. line-height: 22px;
  246. margin-right: 5px;
  247. }
  248. /* .el-table_1_column_2 {
  249. overflow: hidden;
  250. text-overflow:ellipsis;
  251. white-space: nowrap;
  252. } */
  253. .el-table-column {
  254. overflow: hidden;
  255. text-overflow: ellipsis;
  256. white-space: nowrap;
  257. }
  258. .userCenterMyActivity >>> .el-table .el-table__row .cell:hover {
  259. color: blue;
  260. cursor: pointer;
  261. }
  262. </style>