FinishedProjectTraces.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <div>
  3. <Navbar
  4. :title="projectName"
  5. :is-go-back="true"
  6. >
  7. <button
  8. type="button"
  9. class="btn btn-link"
  10. style="padding: 0px;"
  11. @click="goPersonList()"
  12. >
  13. 编辑人员({{ projectUsers.length }})
  14. </button>
  15. </Navbar>
  16. <h4>
  17. 已完成的任务({{ pagination2.total }})
  18. <div class="pull-right">
  19. <button
  20. class="btn btn-link"
  21. style="padding: 0px;"
  22. @click="projectManagement(projectId)"
  23. >
  24. 项目任务
  25. </button>
  26. <button
  27. class="btn btn-link"
  28. style="padding: 0px;"
  29. @click="projectArchive(projectId)"
  30. >
  31. 项目归档
  32. </button>
  33. <button
  34. class="btn btn-link"
  35. style="padding: 0px;"
  36. @click="addTrace(projectId)"
  37. >
  38. 添加任务
  39. </button>
  40. </div>
  41. </h4>
  42. <div class="input-group">
  43. <input v-model="content" type="text" class="form-control" placeholder="任务名称、任务内容" @blur="listFinishedTask" @keyup.enter="listFinishedTask" />
  44. <span class="input-group-btn">
  45. <button style="width:100%;background-color: #007aff;color: white;" type="button" class="btn btn-blue search-button" @click="listFinishedTask()">
  46. 查询
  47. </button>
  48. </span>
  49. </div>
  50. <div>
  51. <div
  52. class="panel panel-default"
  53. style="margin-bottom: 10px;margin-top: 10px;"
  54. >
  55. <div class="panel-body">
  56. <vuedraggable v-model="finishedTraces" item-key="id" class="wrapper" @change="end">
  57. <template #item="{element}">
  58. <div style="margin-top: 5px; cursor: pointer;">
  59. <span>
  60. <Checkbox
  61. :id="'trace-finish-' + element.id"
  62. v-model="element.finished"
  63. class-name="terms"
  64. class="trace-checkbox"
  65. @input="updateTracefinished(element)"
  66. />
  67. </span>
  68. <span @click="openLine(element)">
  69. <!-- eslint-disable-next-line -->
  70. <span class="trace-summary" :class="{'font-color': element.timeLineCompletion==true}" v-html="element.summary" />
  71. <span
  72. class="glyphicon glyphicon-option-vertical trace-icon"
  73. aria-hidden="true"
  74. />
  75. <span class="label label-primary trace-user">
  76. <!-- eslint-disable-next-line -->
  77. <span v-html="element.receiveUserName" />&nbsp;
  78. <span>{{ formatDate(element.planFinishedDate) }}</span>
  79. </span>
  80. <span class="badge">
  81. <span>完成时间:{{ formatDate(element.finishedDate) }}</span>
  82. </span>
  83. </span>
  84. </div>
  85. </template>
  86. </vuedraggable>
  87. </div>
  88. </div>
  89. <div v-if="finishedTraces.length" class="row">
  90. <div class="pull-left">
  91. <span>第{{ (pagination2.current_page-1)*pagination2.per_page+1 }}-{{ pagination2.current_page*pagination2.per_page }}条,共计{{ pagination2.total }}条,每页显示</span>
  92. <PageSizeSelect @page-size-changed="gridSizeSelect" />
  93. <span>条</span>
  94. </div>
  95. <div class="pull-right">
  96. <Pagination :pagination="pagination2" :callback="listFinishedTask" />
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </template>
  102. <script>
  103. var Common = require('../common/Common.js');
  104. var Uuid = require('pc-component-v3').default.Uuid;
  105. import TraceCommon from './TraceCommon.js';
  106. import TraceResource from './TraceResource.js';
  107. var Navbar = require('pc-component-v3').default.Navbar;
  108. var Pagination = require('pc-component-v3').default.VueBootstrapPagination;
  109. var PageSizeSelect = require('pc-component-v3').default.PageSizeSelect;
  110. var Checkbox = require('pc-component-v3').default.Checkbox;
  111. import vuedraggable from 'vuedraggable';
  112. export default {
  113. components: {
  114. Navbar, Pagination, Checkbox,vuedraggable,PageSizeSelect,
  115. },
  116. data: function () {
  117. return {
  118. finishedTraces: [], //已完成的任务
  119. isFinished: true, //显示 完成/未完成的任务
  120. projectUsers: [],
  121. obj: null,
  122. projectName: '',
  123. projectId: '',
  124. pagination2: {
  125. total: 0,
  126. per_page: 50, // 每页10条信息
  127. current_page: 1, // 当前页码
  128. last_page: 10, // 最后页码
  129. },
  130. formatDate: TraceCommon.formatDate,
  131. content:undefined,
  132. };
  133. },
  134. mounted: function () {
  135. var _self = this;
  136. this.projectId = _self.$route.params.projectId;
  137. this.projectName = _self.$route.query.projectName;
  138. this.personNumber();
  139. this.listFinishedTask();
  140. },
  141. methods: {
  142. gridSizeSelect: function(newPageSize) {
  143. this.pagination2.per_page = newPageSize;
  144. this.pagination2.current_page = 1;
  145. // 刷新界面
  146. this.listFinishedTask();
  147. },
  148. end(evt) {
  149. var _self = this;
  150. $.ajax({
  151. url: Common.getApiURL('TraceResource/sortFinished'),
  152. type: 'get',
  153. dataType: 'json',
  154. contentType: 'application/json',
  155. data: {
  156. 'id': evt.moved.element.id,
  157. 'projectId': _self.projectId,
  158. 'oldIndex': evt.moved.oldIndex,
  159. 'newIndex': evt.moved.newIndex,
  160. 'currentPage': _self.pagination2.current_page,
  161. 'pageSize': _self.pagination2.per_page,
  162. 'content': _self.content,
  163. },
  164. beforeSend: function(request) {
  165. Common.addTokenToRequest(request);
  166. },
  167. success: function(data) {
  168. _self.listFinishedTask();
  169. },
  170. error: function(XMLHttpRequest, textStatus, errorThrown) {
  171. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  172. },
  173. });
  174. },
  175. /**
  176. * 编辑
  177. */
  178. edit: function (trace) {
  179. var _self = this;
  180. this.$router.push('/trace/traceUpdate/' + trace.id);
  181. },
  182. /**
  183. * 初始化项目
  184. */
  185. listFinishedTask: function () {
  186. var _self = this;
  187. _self.finishedTraces.splice(0, _self.finishedTraces.length);
  188. TraceResource.listFinishedByProjectId(_self.projectId, _self.pagination2, _self.content).then(data => {
  189. if (data == null) {
  190. return;
  191. }
  192. _self.pagination2.total = data.totalSize;
  193. _self.pagination2.last_page = Math.ceil(_self.pagination2.total / _self.pagination2.per_page);
  194. _self.finishedTraces = data.traceDtos;
  195. }, error => {
  196. Common.processException(error);
  197. });
  198. },
  199. /**
  200. * 初始化接收该项目的人数
  201. * @author ZhangTeng 20190212
  202. */
  203. personNumber: function () {
  204. var _self = this;
  205. _self.projectUsers.splice(0, _self.projectUsers.length);
  206. $.ajax({
  207. url: Common.getApiURL('TraceResource/listByProjectId'),
  208. type: 'get',
  209. dataType: 'json',
  210. contentType: 'application/json',
  211. data: {
  212. 'projectId': _self.projectId,
  213. },
  214. beforeSend: function (request) {
  215. Common.addTokenToRequest(request);
  216. },
  217. success: function (data) {
  218. if (data == null) {
  219. return;
  220. }
  221. for (var index = 0; index < data.length; index++) {
  222. _self.projectUsers[index] = data[index];
  223. // _self.$set(_self.projectUsers, index, data[index]);
  224. }
  225. },
  226. error: function (XMLHttpRequest, textStatus, errorThrown) {
  227. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  228. },
  229. });
  230. },
  231. /**
  232. * 打开明细
  233. * @author ZhangTeng 20190131
  234. */
  235. openLine: function (obj) {
  236. this.$router.push({
  237. path: '/trace/trace/' + obj.id,
  238. });
  239. },
  240. /**
  241. * 添加任务
  242. * @author ZhangTeng 20190201
  243. */
  244. addTrace: function (projectId) {
  245. this.$router.push('/trace/traceCreate/' + projectId);
  246. },
  247. /**
  248. * 项目归档
  249. * @param {Object} projectId
  250. * @author GuoZhiBo 20190926
  251. */
  252. projectArchive: function (projectId) {
  253. var _self = this;
  254. this.$router.push({
  255. path: '/trace/projectArchive/' + projectId,
  256. query:
  257. {
  258. projectName: _self.projectName,
  259. },
  260. });
  261. },
  262. /**
  263. * 项目任务
  264. * @param {Object} projectId
  265. * @author GuoZhiBo 20190926
  266. */
  267. projectManagement: function (projectId) {
  268. var _self = this;
  269. this.$router.push({
  270. path: '/trace/projectManagement/' + projectId,
  271. query:
  272. {
  273. projectName: _self.projectName,
  274. },
  275. });
  276. },
  277. /**
  278. * 跳转到人员界面
  279. * @author ZhangTeng 20190212
  280. */
  281. goPersonList: function () {
  282. var _self = this;
  283. this.$router.push({
  284. path: '/trace/projectUserList/' + _self.projectId,
  285. query: {
  286. projectName: _self.projectName,
  287. },
  288. });
  289. },
  290. /**
  291. * 修改追踪单的状态
  292. * @author YangZhiJie 20171201
  293. */
  294. updateTracefinished: function (trace) {
  295. var _self = this;
  296. TraceResource.updateTraceFinished(trace.id).then(successData => {
  297. _self.listFinishedTask();
  298. }, errorData => {
  299. Common.processException(errorData);
  300. });
  301. },
  302. },
  303. };
  304. </script>
  305. <style scoped>
  306. .trace-summary {
  307. font-size: large;
  308. margin-left: 5px;
  309. margin-right: 5px;
  310. }
  311. .trace-icon {
  312. opacity: 0.5;
  313. }
  314. .trace-user {
  315. font-size: 100%;
  316. }
  317. .trace-checkbox {
  318. display: inline;
  319. font-size: large;
  320. }
  321. </style>