FinishedProjectTraces.vue 9.7 KB

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