logs.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. created() {
  151. },
  152. mounted() {
  153. if (this.canload) {
  154. this.loadYet = true;
  155. this.getLists(true);
  156. }
  157. },
  158. watch: {
  159. projectid() {
  160. if (this.loadYet) {
  161. this.lists = {};
  162. this.getLists(true);
  163. }
  164. },
  165. taskid() {
  166. if (this.loadYet) {
  167. this.lists = {};
  168. this.getLists(true);
  169. }
  170. },
  171. logtype() {
  172. if (this.loadYet) {
  173. this.lists = {};
  174. this.getLists(true);
  175. }
  176. },
  177. canload(val) {
  178. if (val && !this.loadYet) {
  179. this.loadYet = true;
  180. this.getLists(true);
  181. }
  182. }
  183. },
  184. methods: {
  185. logDate(items) {
  186. let md = $A.formatDate("m-d");
  187. return md == items.ymd ? (items.ymd + ' ' + this.$L('今天')) : items.key;
  188. },
  189. getLists(resetLoad, noLoading) {
  190. if (resetLoad === true) {
  191. this.listPage = 1;
  192. }
  193. if (noLoading !== true) {
  194. this.loadIng++;
  195. }
  196. $A.apiAjax({
  197. url: 'project/log/lists',
  198. data: {
  199. projectid: this.projectid,
  200. taskid: this.taskid,
  201. type: this.logtype,
  202. page: Math.max(this.listPage, 1),
  203. pagesize: this.pagesize,
  204. },
  205. complete: () => {
  206. if (noLoading !== true) {
  207. this.loadIng--;
  208. }
  209. },
  210. success: (res) => {
  211. if (res.ret === 1) {
  212. let timeData,
  213. key;
  214. if (resetLoad === true) {
  215. this.lists = {};
  216. }
  217. this.$nextTick(() => {
  218. res.data.lists.forEach((item) => {
  219. timeData = item.timeData;
  220. key = timeData.ymd + " " + timeData.week;
  221. if (typeof this.lists[key] !== "object") {
  222. this.$set(this.lists, key, {
  223. key: key,
  224. ymd: timeData.ymd,
  225. lists: [],
  226. });
  227. }
  228. this.lists[key].lists.push(item);
  229. });
  230. this.hasMorePages = res.data.hasMorePages;
  231. this.totalNum = res.data.total;
  232. });
  233. } else {
  234. this.lists = {};
  235. this.hasMorePages = false;
  236. this.totalNum = 0;
  237. }
  238. }
  239. });
  240. },
  241. getMore() {
  242. if (!this.hasMorePages) {
  243. return;
  244. }
  245. this.hasMorePages = false;
  246. this.listPage++;
  247. this.getLists();
  248. },
  249. openChat(username) {
  250. if (typeof window.onChatOpenUserName === "function") {
  251. window.onChatOpenUserName(username);
  252. }
  253. },
  254. fileDownUrl(id) {
  255. return $A.apiUrl('project/files/download?fileid=' + id);
  256. }
  257. }
  258. }
  259. </script>