information.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="box">
  3. <scroll-view scroll-y="true">
  4. <!-- 头部-->
  5. <cu-custom bgColor="bg-blue" :isBack="false">
  6. <block slot="backText">消息</block>
  7. <block slot="content"></block>
  8. <block slot="right">
  9. <view class=" flex justify-center round">
  10. <button v-if="btnshow" class="margin-top-ssm cu-btn round line-blue text-white">
  11. <button class="cu-btn line-blue" @click="read(1)">
  12. <text class="text-white">标记已读</text>
  13. </button>
  14. <text> | </text>
  15. <button class=" cu-btn line-blue" @click="btnshow=false">
  16. <text class="text-white">管理</text>
  17. </button>
  18. </button>
  19. <button v-else class="margin-top-ssm cu-btn round line-blue text-white">
  20. <button class="cu-btn line-blue" @click="chooseAll()">
  21. <text class="text-white">全选</text>
  22. </button>
  23. <text> | </text>
  24. <button class="cu-btn line-blue" @click="del()">
  25. <text class="text-white">删除选中</text>
  26. </button>
  27. <text> | </text>
  28. <button class=" cu-btn line-blue" @click="btnshow=true">
  29. <text class="text-white">取消管理</text>
  30. </button>
  31. </button>
  32. </view>
  33. </block>
  34. </cu-custom>
  35. <!-- 内容-->
  36. <view class="cu-card dynamic margin-top-sm">
  37. <view class="cu-list menu-avatar comment" v-for="(item,index) in list" :key="index" style="margin-top: 0;">
  38. <view class="cu-item_1">
  39. <view class="cu-item_left">
  40. <view v-if="btnshow==false" style="margin: 30rpx 20rpx 0 0;">
  41. <checkbox-group @change="choose(index,item)">
  42. <checkbox :class="item.checked?'checked':''" :checked="item.checked" class="round"></checkbox>
  43. </checkbox-group>
  44. </view>
  45. <view style="position: relative;">
  46. <view v-if="item.reading==0" class="cuIcon-title"style="color: red;position: absolute;top:0px; right: 0;z-index: 9;" ></view>
  47. <!-- <image class="menuImageTask" src="/static/information/information.png"></image> -->
  48. <image class="menuImageTask" :src="item.portrait"></image>
  49. </view>
  50. </view>
  51. <view :class="btnshow==false?'cu-item_right2':'cu-item_right'" >
  52. <view class="cu-item_right_1">
  53. <view>
  54. <!-- <view class="cu-item_right_name">系统通知</view> -->
  55. <view class="cu-item_right_name">{{item.sendName}}</view>
  56. </view>
  57. <view>
  58. <view class="cu-item_right_time">{{item.informationCreateTime | timeStamp}}</view>
  59. </view>
  60. </view>
  61. <view class="cu-item_right_value">
  62. <text>{{item.rulesContent}}</text>
  63. </view>
  64. <view class="cu-item_right_value2" @click="navToTaskDetails(item)">
  65. <view>{{item.name}}</view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view v-if="list.length==0 && prompt" class="bg-white text-center">
  72. <view>
  73. <image class="menuImageNoTask" src="../../static/task/noTask.png"></image>
  74. </view>
  75. <view style="padding:28rpx 0 132rpx;font-size: 26rpx;color: #8A8A8A;">暂时没有消息~</view>
  76. </view>
  77. <view v-if="list.length!=0 && prompt" style="padding: 60rpx 0 160rpx;text-align: center;font-size: 26rpx;color: #AEAEAE;">没有更多内容了~</view>
  78. </scroll-view>
  79. <!-- 引入底部导航栏 -->
  80. <tabBar v-if="show" :pagePath="'/pages/information/information'"></tabBar>
  81. </view>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. btnshow: true,
  88. list: [],
  89. all: false,
  90. show:false,
  91. prompt:false,
  92. clickData:[]
  93. };
  94. },
  95. onShow() {
  96. this.findInformationData();
  97. },
  98. methods: {
  99. //消息任务跳转
  100. navToTaskDetails(item) {
  101. var type;
  102. if (item.task_category == 2) {
  103. type = 2
  104. } else if (item.task_category == 3) {
  105. type = 3
  106. } else {
  107. type = 1
  108. }
  109. this.clickData.push(item);
  110. this.read(0);
  111. uni.navigateTo({
  112. url: "/pages/task/details/details?type=" + type + "&value=0"+"&taskId="+item.taskId+ "&contractid=" +item.contract_info_id
  113. })
  114. },
  115. choose(index, items) { //单选
  116. if (items.checked) {
  117. this.$set(items, 'checked', false)
  118. } else {
  119. this.$set(items, 'checked', true)
  120. }
  121. },
  122. chooseAll() {
  123. if (this.all) {
  124. this.list.forEach(item => {
  125. this.$set(item, 'checked', false)
  126. })
  127. this.all = false
  128. } else {
  129. this.list.forEach(item => {
  130. this.$set(item, 'checked', true)
  131. })
  132. this.all = true
  133. }
  134. },
  135. del() {
  136. var that=this;
  137. let selectData = [];
  138. that.list.forEach(item => {
  139. if (item.checked) {
  140. selectData.push(item)
  141. }
  142. });
  143. if(selectData.length>0){
  144. that.http.request("/app/task/informationDelete",selectData,'json',true).then((res)=>{
  145. that.show=false;
  146. that.findInformationData();
  147. that.$prompt.none("删除成功")
  148. })
  149. }else{
  150. that.$prompt.none("暂无选中数据");
  151. }
  152. that.prompt=true;
  153. },
  154. read(type){
  155. var that=this;
  156. if(type==1){
  157. if(that.list.length>0){
  158. that.http.request("/app/task/informationRead",that.list,'json',true).then((res)=>{
  159. that.show=false;
  160. that.$prompt.none("操作成功");
  161. setTimeout(function(){
  162. that.findInformationData();
  163. },4000)
  164. })
  165. }else{
  166. that.$prompt.none("暂无未读消息")
  167. }
  168. }else{
  169. that.http.request("/app/task/informationRead",that.clickData,'json',true).then((res)=>{
  170. that.clickData=[];
  171. })
  172. }
  173. },
  174. /**
  175. * 获取信息表的数据,判断该任务的规则是否已经到达提醒时间,然后进行通知
  176. */
  177. findInformationData(){
  178. var userId = uni.getStorageSync("userInfo").id;
  179. var porject = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
  180. var that =this;
  181. that.http.request("/app/task/findInformation",{userId:userId,contractId:porject.contractId,projectId:porject.id},false,true).then((res)=>{
  182. that.list=res.datas;
  183. var i=0;
  184. that.list.forEach((item)=>{
  185. //编辑通知信息
  186. var value;
  187. if(that.intervalTime.getTimeLeft(item.informationCreateTime)<=0){
  188. value ="您负责的任务:"+item.name+",已超过计划完成时间,请抓紧进度,及时完成任务,谢谢!(来自("+item.sendName+"))";
  189. }else{
  190. value ="距离您的工作:"+item.name+",计划完成时间还有"+that.intervalTime.getTimeLeft(item.informationCreateTime)+"天,请留意工作进度,谢谢!(来自("+item.sendName+"))";
  191. }
  192. item.rulesContent = value;
  193. if(item.reading==0){
  194. i=i+1;
  195. }
  196. })
  197. that.tabberData.newsNum=i;
  198. that.show= true;
  199. that.prompt=true;
  200. })
  201. }
  202. },
  203. onHide() {
  204. this.show= false;
  205. },
  206. filters: {
  207. timeStamp: function(value) {
  208. if (!value) return '';
  209. var now = new Date(value);
  210. var year = now.getFullYear();
  211. var month = now.getMonth() + 1;
  212. var hour = now.getHours() >=10 ? now.getHours() : "0"+now.getHours() ;
  213. var minutes = now.getMinutes() >=10 ? now.getMinutes() : "0"+now.getMinutes();
  214. var time = hour+":"+minutes;
  215. if (month < 10) {
  216. month = '0' + month
  217. }
  218. var date = now.getDate();
  219. if (date < 10) {
  220. date = '0' + date
  221. }
  222. return year + "-" + month + "-" + date+" "+time
  223. },
  224. },
  225. }
  226. </script>
  227. <style>
  228. page {
  229. background-color: white;
  230. }
  231. .margin-bottom-big {
  232. margin-bottom: 150rpx;
  233. }
  234. .bg_F {
  235. background-color: #F0F0F0;
  236. }
  237. .bg_b {
  238. background-color: #BADFF3;
  239. }
  240. .menuImageNoTask{width:162rpx;height: 105rpx;margin-top: 60rpx;}
  241. .cu-item_1{display: flex;padding: 26rpx 24rpx;border-bottom: 2rpx solid #E3E1E1;}
  242. .cu-item_left{margin-right: 14rpx;display: flex;}
  243. .cu-item_left .menuImageTask{width: 100rpx;height: 100rpx;border-radius: 50%;}
  244. .cu-item_right{width: 588rpx;}
  245. .cu-item_right2{width: 516rpx;}
  246. .cu-item_right_1{display: flex;justify-content: space-between;align-items: center;}
  247. .cu-item_right_name{font-size: 26rpx;color: #101010;font-weight: bold;}
  248. .cu-item_right_time{font-size: 26rpx;color:#8A8A8A}
  249. .cu-item_right_value{font-size: 30rpx;color: #101010;margin: 10rpx 0 14rpx;}
  250. .cu-item_right_value2{background-color: #F7F7F7;border-radius: 10rpx;padding: 26rpx 22rpx 30rpx;}
  251. .cu-item_right_value2 view{width: 100%;font-size: 30rpx;color: #8A8A8A;overflow: hidden;text-overflow: ellipsis; -o-text-overflow: ellipsis;white-space:nowrap;}
  252. .cu-btn{
  253. padding: 0px 5px !important;
  254. }
  255. </style>