okrInform.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div class="box boxMinHeight">
  3. <PageHeadTwo title="目标通知"></PageHeadTwo>
  4. <div class="main flex-box">
  5. <div class="main-left">
  6. <ul class="ul scroll-bar" v-if="tabs.length > 0">
  7. <li class="flex-box-ce li" v-for="(item, index) in tabs" :key="index" :class="[selectIndex == index ? 'isActiveLi' : '']" @click="activeLi(item, index)">
  8. <div class="index-name font-flex-word">
  9. {{ item.name }}
  10. <span v-if="item.num" class="red">({{ item.num }})</span>
  11. </div>
  12. </li>
  13. </ul>
  14. <noData v-else content="暂无分类" imgW="120px" imgH="80px"></noData>
  15. </div>
  16. <div class="flex-1 main-right">
  17. <!-- <el-select class="select" style="margin-bottom: 20px;" size="small" v-model="has_follow" placeholder="类型">
  18. <el-option label="未读" :value="0"></el-option>
  19. <el-option label="已读" :value="1"></el-option>
  20. </el-select> -->
  21. <div v-if="messageList.length > 0" v-loading="loading">
  22. <div class="flex-box-ce item" v-for="(item, index) in messageList" :key="index" @click="openDetail(item)">
  23. <div class="flex-1 font-flex-word content" v-if="selectIndex == 0">{{ item.content }}</div>
  24. <div class="flex-1 font-flex-word content" v-else>{{ item.target_type == 1 ? '目标' : item.target_type == 2 ? 'KR' : item.target_type == 3 ? '任务': item.target_type == 4 ? '项目':'里程碑' }}“{{ item.title }}”,有人提到了你</div>
  25. <div class="fontColorB">
  26. {{ item.update_time }}
  27. <i class="el-icon-arrow-right"></i>
  28. </div>
  29. </div>
  30. <Pagination :page_size="page_size" :page="page" :total="total" @handleSizeChange="handleSizeChange" @handleCurrentChange="handleCurrentChange"></Pagination>
  31. </div>
  32. <NoData v-else content="暂无内容"></NoData>
  33. </div>
  34. <!-- 目标详情 -->
  35. <TargetDetail :type="showDetailType" :id="showDetailId" v-if="isShowTargetDetail" :showDrawer.sync="isShowTargetDetail" @confirm=""></TargetDetail>
  36. <TaskDetail :isApprove="true" :visible.sync="isShowTaskDetail" :taskId="showDetailId" @confirm=""></TaskDetail>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import EmployeeSelector from '@/components/EmployeeSelector';
  42. import PageHeadTwo from '@/performance/components/public/PageHeadTwo';
  43. import TargetDetail from '@/okr/components/public/TargetDetail'; //目标详情
  44. import TaskDetail from '@/okr/components/public/TaskDetail'; //目标详情
  45. export default {
  46. name: 'unread',
  47. components: { EmployeeSelector, PageHeadTwo, TargetDetail, TaskDetail },
  48. data() {
  49. return {
  50. total: 0,
  51. page: 1,
  52. page_size: 10,
  53. tabs: [{ name: '待办提醒', num: 0 }, { name: '@我的', num: '' }],
  54. loading: false,
  55. selectIndex: 0,
  56. messageList: [], //消息列表
  57. showDetailId: 0,
  58. isShowTargetDetail: false,
  59. isShowTaskDetail: false,
  60. showDetailType: 3,
  61. has_follow: 0
  62. };
  63. },
  64. watch: {
  65. has_follow(val) {
  66. this.page = 1;
  67. this.getMessage();
  68. }
  69. },
  70. created() {
  71. if (this.$route.query.selectIndex) {
  72. this.selectIndex = this.$route.query.selectIndex;
  73. }
  74. },
  75. mounted() {
  76. this.getMessage();
  77. this.getMessage2();
  78. },
  79. methods: {
  80. openDetail(item) {
  81. if (item.target_type == 1 || item.target_type == 2) {
  82. this.showDetailType = item.target_type;
  83. this.showDetailId = item.target_id; //打开详情的ID
  84. this.isShowTargetDetail = true;
  85. } else if (item.target_type == 3){
  86. this.showDetailId = item.target_id; //打开任务详情的ID
  87. this.isShowTaskDetail = true;
  88. } else if (item.target_type == 4){ //项目
  89. this.$router.push({path:'/projectDetail',query:{id:item.target_id}})
  90. }
  91. },
  92. //待办
  93. getMessage2() {
  94. this.$axiosUser('get', '/api/pro/okr/notice', { fb: 1, has_follow: 0, page: this.page, page_size: this.page_size }).then(res => {
  95. this.tabs[1].num = res.data.data.total;
  96. })
  97. },
  98. //待办
  99. getMessage() {
  100. this.loading = true;
  101. this.messageList = [];
  102. this.$axiosUser('get', '/api/pro/okr/notice', { fb: this.selectIndex, has_follow: this.has_follow, page: this.page, page_size: this.page_size })
  103. .then(res => {
  104. let list = res.data.data.list;
  105. list.forEach(item => {
  106. item.update_time = this.$moment(Number(item.update_time + '000')).format('YYYY-MM-DD HH:mm');
  107. });
  108. this.tabs[this.selectIndex].num = res.data.data.total;
  109. this.$nextTick(() => {
  110. this.messageList = list;
  111. this.total = res.data.data.total;
  112. });
  113. })
  114. .finally(() => {
  115. this.loading = false;
  116. });
  117. },
  118. activeLi(item, index) {
  119. this.selectIndex = index;
  120. this.page = 1;
  121. this.getMessage();
  122. },
  123. // 页面变更
  124. handleCurrentChange(val) {
  125. this.page = val;
  126. this.getMessage();
  127. },
  128. // 页面跳转
  129. handleSizeChange(val) {
  130. this.page_size = val;
  131. this.getMessage();
  132. }
  133. },
  134. beforeDestroy() {
  135. this.$store.dispatch('getSumTotal') //通知数量
  136. }
  137. };
  138. </script>
  139. <style scoped="scoped">
  140. .box {
  141. padding: 20px;
  142. font-size: 14px;
  143. box-sizing: border-box;
  144. background-color: #fff;
  145. position: relative;
  146. }
  147. .main {
  148. margin-top: 40px;
  149. }
  150. /* bug: 我在flex布局的元素中使用了elementui的table组件,饿了么的table上会被加一个动态的宽度, 当第一次改变flex元素宽度的时候。table的动态宽度会变化,第二次和以后就不会变化了。*/
  151. /* 给使用flex的元素加上 overflow-x:hidden */
  152. .main-right {
  153. margin-left: 20px;
  154. overflow-x: hidden;
  155. }
  156. .main-left {
  157. width: 200px;
  158. border-radius: 3px;
  159. box-sizing: border-box;
  160. }
  161. .main-left::after {
  162. position: absolute;
  163. content: '';
  164. width: 1px;
  165. height: auto;
  166. left: 220px;
  167. top: 0;
  168. bottom: 0;
  169. background-color: #f1f1f1;
  170. }
  171. ::v-deep .has-gutter {
  172. display: none;
  173. }
  174. .li {
  175. height: 53px;
  176. line-height: 53px;
  177. padding: 0 20px;
  178. border-bottom: 1px solid #f1f1f1;
  179. color: #777777;
  180. width: 100%;
  181. }
  182. .li:hover {
  183. background-color: #f5f7fa;
  184. }
  185. .li:hover .el-icon-more {
  186. display: block;
  187. }
  188. .index-name {
  189. width: 170px;
  190. }
  191. .ul {
  192. max-height: calc(100vh - 230px);
  193. overflow: auto;
  194. width: 200px;
  195. }
  196. .isActiveLi {
  197. background-color: #f5f7fa;
  198. color: #409eff !important;
  199. position: relative;
  200. }
  201. .isActiveLi::after {
  202. width: 3px;
  203. content: ' ';
  204. background-color: #409eff;
  205. left: 0;
  206. bottom: 0;
  207. top: 0;
  208. position: absolute;
  209. }
  210. .item {
  211. font-size: 14px;
  212. cursor: pointer;
  213. padding: 8px;
  214. border-bottom: 1px solid #e8e8e8;
  215. }
  216. .item:hover {
  217. background-color: #f5f7fa;
  218. }
  219. .content {
  220. padding: 0 10px;
  221. }
  222. </style>