logs.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="project-task-logs">
  4. <ul class="logs-activity" :class="`${taskid>0?'istaskid':''}`">
  5. <li v-for="items in lists">
  6. <div class="logs-date">{{logDate(items)}}</div>
  7. <div class="logs-section">
  8. <Timeline>
  9. <TimelineItem v-for="(item, index) in items.lists" :key="index">
  10. <div slot="dot" class="logs-dot">
  11. <UserImg :info="item" class="avatar"/>
  12. </div>
  13. <div class="log-summary">
  14. <span class="log-creator" @click="openChat(item.username)"><UserView :username="item.username"/></span>
  15. <span class="log-text-secondary">{{item.detail}}</span>
  16. <span v-if="item.other.type=='task' && taskid == 0" class="log-text-link" @click="taskDetail(item.other.id)">{{item.other.title}}</span>
  17. <span v-if="item.other.type=='username'" class="log-text-link" @click="openChat(item.other.username)"><UserView :username="item.other.username"/></span>
  18. <a v-if="item.other.type=='file'" class="log-text-link" target="_blank" :href="fileDownUrl(item.other.id)">{{item.other.name}}</a>
  19. <span class="log-text-info">{{item.timeData.ymd}} {{item.timeData.segment}} {{item.timeData.hi}}</span></div>
  20. </TimelineItem>
  21. </Timeline>
  22. </div>
  23. </li>
  24. <li v-if="loadIng > 0" class="logs-loading"><w-loading></w-loading></li>
  25. <li v-else-if="hasMorePages" class="logs-more" @click="getMore">{{$L('加载更多')}}</li>
  26. <li v-else-if="totalNum == 0" class="logs-none" @click="getLists(true)">{{$L('没有相关内容')}}</li>
  27. </ul>
  28. </div>
  29. </drawer-tabs-container>
  30. </template>
  31. <style lang="scss" scoped>
  32. .project-task-logs {
  33. margin: 0 12px;
  34. .logs-activity {
  35. position: relative;
  36. word-break: break-all;
  37. padding: 12px 12px;
  38. &.istaskid {
  39. > li {
  40. padding-top: 0;
  41. }
  42. }
  43. > li {
  44. padding-top: 22px;
  45. &.logs-loading {
  46. margin: 4px 0;
  47. width: 18px;
  48. height: 18px;
  49. display: flex;
  50. }
  51. &.logs-more {
  52. cursor: pointer;
  53. &:hover {
  54. color: #048be0;
  55. }
  56. }
  57. &.logs-none {
  58. cursor: pointer;
  59. color: #666666;
  60. line-height: 26px;
  61. }
  62. &:first-child {
  63. padding-top: 0;
  64. }
  65. &:last-child {
  66. .logs-section {
  67. margin-bottom: -8px;
  68. }
  69. }
  70. .logs-date {
  71. color: rgba(0, 0, 0, .36);
  72. padding-bottom: 14px;
  73. }
  74. .logs-section {
  75. .ivu-timeline-item {
  76. padding-bottom: 2px;
  77. }
  78. }
  79. .logs-dot {
  80. width: 18px;
  81. height: 18px;
  82. margin-left: 10px;
  83. .avatar {
  84. width: 18px;
  85. height: 18px;
  86. font-size: 12px;
  87. line-height: 18px;
  88. border-radius: 14px;
  89. overflow: hidden;
  90. }
  91. }
  92. .log-summary {
  93. > span,
  94. > a {
  95. padding-right: 6px;
  96. word-wrap: break-word;
  97. word-break: break-word;
  98. }
  99. .log-creator {
  100. color:rgba(0, 0, 0, 0.85)
  101. }
  102. .log-text-secondary {
  103. color: rgba(0,0,0,.54);
  104. }
  105. .log-text-link {
  106. color: #048be0;
  107. cursor: pointer;
  108. }
  109. .log-text-info {
  110. color: rgba(0,0,0,.36);
  111. }
  112. }
  113. }
  114. }
  115. }
  116. </style>
  117. <script>
  118. import DrawerTabsContainer from "../../DrawerTabsContainer";
  119. export default {
  120. name: 'ProjectTaskLogs',
  121. components: {DrawerTabsContainer},
  122. props: {
  123. projectid: {
  124. default: 0
  125. },
  126. taskid: {
  127. default: 0
  128. },
  129. pagesize: {
  130. default: 100
  131. },
  132. logtype: {
  133. default: '全部'
  134. },
  135. canload: {
  136. type: Boolean,
  137. default: true
  138. },
  139. },
  140. data() {
  141. return {
  142. loadYet: false,
  143. loadIng: 0,
  144. lists: {},
  145. listPage: 1,
  146. hasMorePages: false,
  147. totalNum: -1,
  148. }
  149. },
  150. mounted() {
  151. if (this.canload) {
  152. this.loadYet = true;
  153. this.getLists(true);
  154. }
  155. },
  156. watch: {
  157. projectid() {
  158. if (this.loadYet) {
  159. this.lists = {};
  160. this.getLists(true);
  161. }
  162. },
  163. taskid() {
  164. if (this.loadYet) {
  165. this.lists = {};
  166. this.getLists(true);
  167. }
  168. },
  169. logtype() {
  170. if (this.loadYet) {
  171. this.lists = {};
  172. this.getLists(true);
  173. }
  174. },
  175. canload(val) {
  176. if (val && !this.loadYet) {
  177. this.loadYet = true;
  178. this.getLists(true);
  179. }
  180. }
  181. },
  182. methods: {
  183. logDate(items) {
  184. let md = $A.formatDate("m-d");
  185. return md == items.ymd ? (items.ymd + ' ' + this.$L('今天')) : items.key;
  186. },
  187. getLists(resetLoad, noLoading) {
  188. if (resetLoad === true) {
  189. this.listPage = 1;
  190. }
  191. if (noLoading !== true) {
  192. this.loadIng++;
  193. }
  194. $A.apiAjax({
  195. url: 'project/log/lists',
  196. data: {
  197. projectid: this.projectid,
  198. taskid: this.taskid,
  199. type: this.logtype,
  200. page: Math.max(this.listPage, 1),
  201. pagesize: this.pagesize,
  202. },
  203. complete: () => {
  204. if (noLoading !== true) {
  205. this.loadIng--;
  206. }
  207. },
  208. success: (res) => {
  209. if (res.ret === 1) {
  210. let timeData,
  211. key;
  212. if (resetLoad === true) {
  213. this.lists = {};
  214. }
  215. this.$nextTick(() => {
  216. res.data.lists.forEach((item) => {
  217. timeData = item.timeData;
  218. key = timeData.ymd + " " + timeData.week;
  219. if (typeof this.lists[key] !== "object") {
  220. this.$set(this.lists, key, {
  221. key: key,
  222. ymd: timeData.ymd,
  223. lists: [],
  224. });
  225. }
  226. this.lists[key].lists.push(item);
  227. });
  228. this.hasMorePages = res.data.hasMorePages;
  229. this.totalNum = res.data.total;
  230. });
  231. } else {
  232. this.lists = {};
  233. this.hasMorePages = false;
  234. this.totalNum = 0;
  235. }
  236. }
  237. });
  238. },
  239. getMore() {
  240. if (!this.hasMorePages) {
  241. return;
  242. }
  243. this.hasMorePages = false;
  244. this.listPage++;
  245. this.getLists();
  246. },
  247. openChat(username) {
  248. if (typeof window.onChatOpenUserName === "function") {
  249. window.onChatOpenUserName(username);
  250. }
  251. },
  252. fileDownUrl(id) {
  253. return $A.apiUrl('project/files/download?fileid=' + id);
  254. }
  255. }
  256. }
  257. </script>