FinishedProjectTraces.vue 10 KB

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