AI销管
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

messageList.vue 8.3 KiB

il y a 1 an
il y a 1 an
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <view class="message_list">
  3. <!-- 公告 -->
  4. <view class="m-nav">
  5. <view class="m-n-lside">
  6. <image src="@/static/images/notice.png" mode=""></image>
  7. 全部{{ count }}条新消息
  8. </view>
  9. <view class="m-n-rside" @click="allRead">
  10. 全部已读
  11. </view>
  12. </view>
  13. <!-- 选项卡 -->
  14. <view class="m-tabs">
  15. <u-tabs :list="list" :current="current" :is-scroll="false" @change="change"></u-tabs>
  16. </view>
  17. <template v-if="current == 0">
  18. <scroll-view :scroll-top="scrollTop" refresher-enabled="true" :refresher-triggered="triggered"
  19. @refresherpulling="onPulling" @refresherrefresh="onRefresh" @refresherrestore="onRestore"
  20. :scroll-y="true" class="scroll-Y" @scrolltolower="lower">
  21. <template v-if="updateAnnList.length!=0">
  22. <block v-for="(item,index) in updateAnnList" :key="index">
  23. <view class="upgradeItem" @click="goReception(item, index)">
  24. <view class="right">
  25. <view class="title">
  26. <template v-if="item.messageType == 2">
  27. {{ item.weekDate }}
  28. </template>
  29. <template v-else>
  30. {{ fomatDate(item.createTime) }}
  31. </template>
  32. <template v-if="item.orgCode&&item.orgName">
  33. {{ item.orgName }}
  34. </template>
  35. {{item.title}}
  36. <template v-if="item.readFlag==0">
  37. <view class="notRead"></view>
  38. </template>
  39. </view>
  40. <view class="time">{{item.createTime}}</view>
  41. </view>
  42. </view>
  43. </block>
  44. </template>
  45. <template v-else>
  46. <view style="padding: 100rpx 0;">
  47. <u-empty text="暂无数据" mode="list"></u-empty>
  48. </view>
  49. </template>
  50. </scroll-view>
  51. </template>
  52. <!-- 升级公告 -->
  53. <template v-if="current == 1 || current == 2">
  54. <scroll-view :scroll-top="scrollTop" refresher-enabled="true" :refresher-triggered="triggered"
  55. @refresherpulling="onPulling" @refresherrefresh="onRefresh" @refresherrestore="onRestore"
  56. :scroll-y="true" class="scroll-Y" @scrolltolower="lower">
  57. <template v-if="updateAnnList.length!=0">
  58. <block v-for="(item,index) in updateAnnList" :key="index">
  59. <view class="upgradeItem" @click="goDetail(item)">
  60. <view class="right">
  61. <view class="title">
  62. {{item.title}}
  63. <template v-if="item.readFlag==0">
  64. <view class="notRead"></view>
  65. </template>
  66. </view>
  67. <view class="time">{{item.createTime}}</view>
  68. </view>
  69. </view>
  70. </block>
  71. </template>
  72. <template v-else>
  73. <view style="padding: 100rpx 0;">
  74. <u-empty text="暂无数据" mode="list"></u-empty>
  75. </view>
  76. </template>
  77. </scroll-view>
  78. </template>
  79. </view>
  80. </template>
  81. <script>
  82. var util = require("../../utils/util.js");
  83. var config = require("../../config");
  84. export default {
  85. data() {
  86. return {
  87. triggered: true,
  88. scrollTop: 0,
  89. old: {
  90. scrollTop: 0
  91. },
  92. updateAnnList: [],
  93. sysItemList: [],
  94. projectId: uni.getStorageSync('buildingID').id,
  95. list: [{
  96. name: '接待报告',
  97. id: 1, // 1日报 2周报 3其他(非3为接待报告,3是系统消息)
  98. }, {
  99. name: '系统公告',
  100. id: 3, // 1日报 2周报 3其他(非3为接待报告,3是系统消息)
  101. }],
  102. count: 0, // 全部条数
  103. current: 0,
  104. pageNum: 1,
  105. pageSize: 10,
  106. };
  107. },
  108. onShow() {
  109. this.updateAnnList = []
  110. this.pageNum = 1
  111. this.updateInit()
  112. this.getMessageNotRed()
  113. },
  114. onLoad() {
  115. this._freshing = false;
  116. setTimeout(() => {
  117. this.triggered = true;
  118. }, 1000)
  119. },
  120. onPullDownRefresh() {
  121. this.initPage()
  122. setTimeout(function() {
  123. uni.stopPullDownRefresh();
  124. }, 1000);
  125. },
  126. methods: {
  127. onPulling(e) {
  128. console.log("onpulling", e);
  129. },
  130. onRefresh() {
  131. if (this._freshing) return;
  132. this.updateAnnList = []
  133. this.pageNum = 1
  134. this.updateInit()
  135. this._freshing = true;
  136. setTimeout(() => {
  137. this.triggered = false;
  138. this._freshing = false;
  139. }, 3000)
  140. },
  141. onRestore() {
  142. this.triggered = 'restore'; // 需要重置
  143. console.log("onRestore");
  144. },
  145. lower(e) {
  146. this.pageNum++
  147. this.updateInit()
  148. },
  149. initPage() {
  150. this.updateAnnList = []
  151. this.pageNum = 1
  152. this.updateInit()
  153. },
  154. // 全部标记已读
  155. allRead() {
  156. this.$u.get('/zkMessage/updateState', {
  157. accountId: uni.getStorageSync('weapp_session_userInfo_data').accountId,
  158. projectId: this.projectId,
  159. }).then(res => {
  160. uni.showToast({
  161. title: '全部已读成功!',
  162. duration: 2000
  163. });
  164. this.initPage()
  165. }).catch(e => {
  166. console.log(e)
  167. })
  168. },
  169. updateInit() {
  170. let obj = {
  171. messageType: this.list[this.current].id,
  172. id: uni.getStorageSync('weapp_session_userInfo_data').accountId,
  173. num: this.pageNum,
  174. size: this.pageSize,
  175. projectId: this.projectId,
  176. }
  177. uni.request({
  178. url: config.service.updateList,
  179. method: "GET",
  180. data: obj,
  181. header: {
  182. 'content-type': 'application/json',
  183. 'Authorization': 'Bearer ' + uni.getStorageSync('weapp_session_login_data').token
  184. },
  185. success: (res) => {
  186. if (res.data.data) {
  187. if (this.pageNum != 1) {
  188. this.updateAnnList = [...this.updateAnnList, ...res.data.data.list.records];
  189. } else {
  190. this.updateAnnList = res.data.data.list.records || []
  191. }
  192. }
  193. },
  194. fail: e => {
  195. console.log(e)
  196. }
  197. })
  198. },
  199. goDetail(data) {
  200. this.$store.commit('setMessageObj', data)
  201. uni.navigateTo({
  202. url: "./messageDetail"
  203. })
  204. },
  205. // 获取未读消息数量
  206. getMessageNotRed() {
  207. uni.request({
  208. url: config.service.notReadNum,
  209. method: "GET",
  210. data: {
  211. id: uni.getStorageSync('weapp_session_userInfo_data').accountId,
  212. projectId: this.projectId,
  213. },
  214. header: {
  215. 'content-type': 'application/json',
  216. 'Authorization': 'Bearer ' + uni.getStorageSync('weapp_session_login_data').token
  217. },
  218. success: (res) => {
  219. this.count = res.data.data || 0
  220. }
  221. })
  222. },
  223. // 跳转日报
  224. goReception(data, index) {
  225. this.$store.commit('setMessageObj', data)
  226. data.readFlag = 1
  227. if (data.messageType == 2) {
  228. uni.navigateTo({
  229. url: `/pages/reportExcel/weekReport?id=${data.id}`
  230. })
  231. } else {
  232. uni.navigateTo({
  233. url: `/pages/reportExcel/dayReport?id=${data.id}`
  234. })
  235. }
  236. },
  237. fomatDate(date) {
  238. if (!date) return '--'
  239. let arr = date.split(' ')
  240. let str = arr[0]
  241. let result = str.split('-')
  242. return `${result[1]}月${result[2]}日`
  243. },
  244. // 转换时间
  245. getTimeLine(date, type = 1) {
  246. let resu = '--'
  247. if (!date) return resu
  248. let time = new Date(date.replace(/-/g, '/'))
  249. time.setDate(time.getDate() - 7)
  250. let arr = date.split(' ')
  251. let str = arr[0]
  252. let result = str.split('-')
  253. let m = (time.getMonth() + 1) < 10 ? `0${time.getMonth() + 1}` : (time.getMonth() + 1)
  254. let d = time.getDate() < 10 ? `0${time.getDate()}` : time.getDate()
  255. if (type == 1) {
  256. resu = `${m}.${d}-${result[1]}.${result[2]}`
  257. } else {
  258. resu = `${m}月${d}日~${result[1]}月${result[2]}日`
  259. }
  260. return resu
  261. },
  262. change(index) {
  263. this.current = index;
  264. this.initPage()
  265. }
  266. }
  267. }
  268. </script>
  269. <style lang="scss">
  270. .message_list {
  271. width: 100vw;
  272. height: calc(100vh - var(--window-top));
  273. background: #F8F8F8;
  274. display: flex;
  275. flex-direction: column;
  276. .m-nav {
  277. flex-shrink: 0;
  278. padding: 0 30rpx;
  279. width: 100%;
  280. height: 68rpx;
  281. display: flex;
  282. align-items: center;
  283. .m-n-lside {
  284. flex-grow: 1;
  285. display: flex;
  286. align-items: center;
  287. image {
  288. margin-right: 16rpx;
  289. width: 36rpx;
  290. height: 36rpx;
  291. }
  292. }
  293. .m-n-rside {
  294. flex-shrink: 0;
  295. padding: 6rpx 14rpx;
  296. border: 1rpx solid #E0E0E0;
  297. font-size: 24rpx;
  298. }
  299. }
  300. .m-tabs {
  301. flex-shrink: 0;
  302. }
  303. .scroll-Y {
  304. padding: 20rpx 0 0 0;
  305. flex-grow: 1;
  306. overflow-y: scroll;
  307. .upgradeItem {
  308. margin: 0 0 20rpx 0;
  309. padding: 24rpx 30rpx 28rpx;
  310. height: 156rpx;
  311. display: flex;
  312. background: #fff;
  313. .right {
  314. .title {
  315. font-size: 32rpx;
  316. font-weight: bold;
  317. display: flex;
  318. .notRead {
  319. width: 14rpx;
  320. height: 14rpx;
  321. background: #FF0000;
  322. border-radius: 100%;
  323. }
  324. }
  325. .time {
  326. margin: 18rpx 0 0 0;
  327. color: #6f6f6f;
  328. font-size: 24rpx;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. </style>