index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <u-navbar :titleStyle="{ color: '#fff' }" :autoBack="true" title="消息列表" :placeholder="true" :safeAreaInsetTop="true" :bgColor="proxy.$settingStore.themeColor.color">
  3. <template #left>
  4. <view class="u-navbar__content__left__item">
  5. <u-icon name="arrow-left" size="20" color="#fff"></u-icon>
  6. </view>
  7. </template>
  8. </u-navbar>
  9. <oa-scroll
  10. customClass="appMessage-container scroll-height"
  11. :customStyle="{ height: `calc(100vh - (44px + ${proxy.$settingStore.StatusBarHeight} + ${proxy.$settingStore.tabBarHeight}))` }"
  12. :pageSize="state.size"
  13. :total="state.total"
  14. :refresherLoad="true"
  15. :refresherEnabled="true"
  16. :refresherDefaultStyle="'none'"
  17. :refresherThreshold="44"
  18. :refresherBackground="'#f5f6f7'"
  19. @load="load"
  20. @refresh="refresh"
  21. :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  22. >
  23. <template #default>
  24. <u-loading-page :loading="state.loading" fontSize="16" style="z-index: 99"></u-loading-page>
  25. <view class="content-area" v-for="(group, date) in proxy.$common.groupedItems(state.noticeList, 'createTime')" :key="date">
  26. <view class="content-area-time font14">{{ proxy.$time.jktTimes(date, "否") }}</view>
  27. <view
  28. class="content-area-center flex bg-white list-cell list-cell-arrow"
  29. :id="ind == noticeList.length - 1 ? 'bottomInfo' : ''"
  30. v-for="(el, ind) in group"
  31. :key="ind"
  32. v-show="noticeList.length > 0"
  33. @click="goContentDetails(el)"
  34. >
  35. <uni-swipe-action style="width: 100%;" ref="swipeAction">
  36. <uni-swipe-action-item :right-options="notice" @click="noticeDelete(el)">
  37. <view style="display: flex; align-items: center;">
  38. <view style="width: 82% !important;float:left;">
  39. <view class="content-area-center-title font16">{{ el.infoTitle }}</view>
  40. <rich-text :nodes="el.infoContent" class="content-area-center-cont font14"></rich-text>
  41. </view>
  42. <view class="sign">
  43. <view class="badge"><u-badge :isDot="el.readFlag == 0 ? true : false" type="error"></u-badge></view>
  44. <view class="time font14">{{ proxy.$time.jktTimes(el.createTime.replace("T", " ")) }}</view>
  45. </view>
  46. </view>
  47. </uni-swipe-action-item>
  48. </uni-swipe-action>
  49. </view>
  50. </view>
  51. </template>
  52. </oa-scroll>
  53. </template>
  54. <script setup>
  55. /*----------------------------------依赖引入-----------------------------------*/
  56. import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  57. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  58. /*----------------------------------接口引入-----------------------------------*/
  59. import { getMceList, updateMceReceiveStatus, mceDelete } from "@/api/mine/info.js";
  60. import { projectApi } from "@/api/business/project.js";
  61. /*----------------------------------组件引入-----------------------------------*/
  62. /*----------------------------------store引入-----------------------------------*/
  63. /*----------------------------------公共方法引入-----------------------------------*/
  64. /*----------------------------------公共变量-----------------------------------*/
  65. const { proxy } = getCurrentInstance();
  66. /*----------------------------------变量声明-----------------------------------*/
  67. const state = reactive({
  68. scrollIntoView: "",
  69. loading: false,
  70. noticeList: [],
  71. size: 10,
  72. current: 1,
  73. total: 0,
  74. options: {
  75. typeName: "",
  76. },
  77. });
  78. const notice = ref([
  79. {
  80. text: '删除',
  81. style: {
  82. backgroundColor: '#FF0000',
  83. },
  84. icon: 'trash', // 如果库支持图标,可以这样设置
  85. },
  86. ])
  87. const swipeAction = ref(null);
  88. const { scrollIntoView, noticeList } = toRefs(state);
  89. /**
  90. * @跳转相应类型系统
  91. */
  92. function goContentDetails(e) {
  93. //是否已读
  94. if (!e.readFlag) {
  95. updateMceReceiveStatus({ id: e.id });
  96. }
  97. if (e.infoType == 4) {
  98. proxy.$tab.navigateTo(`/pages/business/fireIot/alarmManage/alarmDetails/index?contentId=${e.contentId}`).then(() => {});
  99. } else if (e.infoType == 5) {
  100. if (e.readFlag != 1) {
  101. projectApi()
  102. .ReportRecordReadFlag({ reportId: e.id })
  103. .then((res) => {
  104. if (res.status == "SUCCESS") {
  105. proxy.$tab.navigateTo(`/pages/business/common/projectMange/record/details?reportId=${e.moduleId}`);
  106. } else {
  107. proxy.$modal.msgError("读取异常");
  108. }
  109. });
  110. } else {
  111. proxy.$tab.navigateTo(`/pages/business/common/projectMange/record/details?reportId=${e.moduleId}`);
  112. }
  113. //通知公告
  114. }else if(e.infoType == 1){
  115. proxy.$tab.navigateTo(`/pages/common/appMessage/nociteDetails?moduleId=${e.moduleId}`).then(() => {});
  116. }else if(e.infoType == 3){//OA消息
  117. if(e.infoContent){
  118. if(e.infoContent){
  119. if(e.infoContent.includes("新的审批任务")){
  120. proxy.$common.toPage(2,"todo")
  121. }else{
  122. proxy.$common.toPage(2,"me")
  123. }
  124. }else{
  125. proxy.$common.toPage(2,"todo")
  126. }
  127. }
  128. }else{
  129. proxy.$tab.navigateTo(`/pages/common/appMessage/details?contentId=${e.contentId}`).then(() => {});
  130. }
  131. }
  132. function noticeDelete(e) {
  133. mceDelete(e.contentId).then(() => {
  134. for(let i=0;i<noticeList.value.length;i++){
  135. if(noticeList.value[i].id == e.id){
  136. swipeAction.value[i].closeAll()
  137. noticeList.value.splice(i,1);
  138. }
  139. }
  140. proxy.$modal.msg("删除成功");
  141. })
  142. }
  143. /**
  144. * @通知公告列表
  145. * @api接口调用
  146. */
  147. function init(obj) {
  148. uni.setNavigationBarTitle({
  149. title: obj.typeName ? obj.typeName : "消息列表",
  150. });
  151. state.loading = true;
  152. if(obj.id){
  153. if(obj.type == 3){
  154. if(obj?.oaType){
  155. proxy.$common.toPage(2,obj.oaType)
  156. }
  157. }else{
  158. getMceList({
  159. size: 1,
  160. current: 1,
  161. infoId: obj.id,
  162. infoType: obj?.type,
  163. })
  164. .then((requset) => {
  165. goContentDetails(requset.data.records[0]);
  166. })
  167. .catch((err) => {
  168. state.loading = false;
  169. });
  170. }
  171. }else{
  172. getMceList({
  173. size: state.size,
  174. current: state.current,
  175. infoType: obj?.type,
  176. })
  177. .then((requset) => {
  178. if (requset.status === "SUCCESS") {
  179. state.noticeList = requset.data.records;
  180. state.total = requset.data.total;
  181. state.loading = false;
  182. }
  183. setTimeout(() => {
  184. scrollIntoView.value = "bottomInfo";
  185. }, 0);
  186. })
  187. .catch((err) => {
  188. state.loading = false;
  189. });
  190. }
  191. }
  192. /**
  193. * @scrollView加载数据
  194. */
  195. function load() {
  196. state.size += 10;
  197. init(state.options);
  198. }
  199. /**
  200. * @scrollView刷新数据
  201. */
  202. function refresh() {
  203. state.size = 10;
  204. init(state.options);
  205. }
  206. onLoad((options) => {
  207. state.options = options;
  208. init(state.options);
  209. uni.$on("projectMange_record", function (value) {
  210. delete state.options.id;
  211. init(state.options);
  212. });
  213. });
  214. onReady(() => {});
  215. onShow(() => {
  216. //调用系统主题颜色
  217. proxy.$settingStore.systemThemeColor([1]);
  218. });
  219. onUnload(() => {
  220. uni.$off("projectMange_record"); //将值删除监听器
  221. });
  222. // 自定义导航事件
  223. onNavigationBarButtonTap((e) => {
  224. if (e.float == "right") {
  225. proxy.$tab.navigateTo("/pages/mine/setting/index");
  226. }
  227. });
  228. </script>
  229. <style lang="scss" scoped>
  230. :deep(.uni-page-head__title) {
  231. opacity: 1 !important;
  232. }
  233. .content-area {
  234. padding: 0 10px;
  235. &-time {
  236. padding: 10px;
  237. text-align: left;
  238. color: #000000;
  239. font-weight: 600;
  240. }
  241. .content-area-center {
  242. margin: 0;
  243. padding: 15px;
  244. overflow: hidden;
  245. border-bottom: 1px solid #eaeef1;
  246. &:nth-child(2) {
  247. border-radius: 10px 10px 0 0;
  248. }
  249. &:last-child {
  250. border-radius: 0 0 10px 10px;
  251. border-bottom: 0px solid #eaeef1;
  252. }
  253. &-avatar {
  254. margin: auto 0;
  255. }
  256. &-title {
  257. margin: 0 0 10px 0;
  258. font-weight: 600;
  259. color: #000000;
  260. }
  261. &-cont {
  262. color: #666666;
  263. }
  264. .sign{
  265. width:18%;
  266. margin-right:4%;
  267. text-align: right;
  268. .badge {
  269. margin-right:6px;
  270. display: inline-block;
  271. }
  272. .time {
  273. display: inline-block;
  274. }
  275. }
  276. }
  277. }
  278. </style>
  279. <style>
  280. .uni-swipe_button-text,.uni-swipe_button .button-hock{
  281. font-size: 12px !important;
  282. }
  283. </style>