NotFinishedProjectTraces.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <template>
  2. <div>
  3. <Navbar :title="projectName" :is-go-back="true">
  4. <button v-if="adminUserShow" type="button" class="btn btn-link" style="padding: 5px;" @click="goAdminPersonList()">
  5. 编辑项目管理员({{ projectAdminUsers.length }})
  6. </button>
  7. <button v-if="userShow" type="button" class="btn btn-link" style="padding: 5px;" @click="goPersonList()">
  8. 编辑项目人员({{ projectUsers.length }})
  9. </button>
  10. </Navbar>
  11. <h4>
  12. 未完成的任务({{ pagination.total }})
  13. <div class="pull-right">
  14. <button v-if="timeShow" class="btn btn-link" style="padding: 0px;" @click="projectManagement(projectId)">项目任务</button>
  15. <button class="btn btn-link" style="padding: 0px;" @click="projectArchive(projectId)">项目归档</button>
  16. <button class="btn btn-link" style="padding: 0px;" @click="addTrace(projectId)">添加任务</button>
  17. </div>
  18. </h4>
  19. <div class="m-container">
  20. <div class="input-group">
  21. <input autocomplete="off" v-model="content" type="text" class="form-control" placeholder="任务名称、任务内容" @blur="listNotFinishedTask" @keyup.enter="listNotFinishedTask" />
  22. <span class="input-group-btn">
  23. <button style="width:100%;background-color: #007aff;color: white;" type="button" class="btn btn-blue search-button" @click="listNotFinishedTask()">
  24. 查询
  25. </button>
  26. </span>
  27. </div>
  28. </div>
  29. <div class="panel panel-default" style="margin-bottom: 10px;margin-top: 10px;">
  30. <div class="panel-body">
  31. <vuedraggable v-model="noFinishedTraces" item-key="id" class="wrapper" :delay="500" :delay-on-touch-only="true" @change="end">
  32. <template #item="{element}">
  33. <div style="margin-top: 5px; cursor: pointer;">
  34. <span>
  35. <span>
  36. <Checkbox
  37. :id="'trace-finish-' + element.id" v-model="element.finished" class-name="terms" class="trace-checkbox"
  38. @input="updateTracefinished(element)"
  39. />
  40. </span>
  41. <span @click="openLine(element)">
  42. <!-- eslint-disable-next-line -->
  43. <span class="trace-summary" :class="{'font-color': element.timeLineCompletion==true}" v-html="element.summary" />
  44. <span class="glyphicon glyphicon-option-vertical trace-icon" aria-hidden="true" />
  45. <span class="label trace-user" :class="{'label-danger' : element.overdue == true, 'label-primary' : element.overdue != true}">
  46. <!-- eslint-disable-next-line -->
  47. <span v-html="element.receiveUserName" />&nbsp;
  48. <span>{{ formatDate(element.planFinishedDate) }}</span>
  49. </span>
  50. </span>
  51. </span>
  52. <a class="fa-pull-right" style="color: blue;" @click="edit(element)">编辑</a>
  53. </div>
  54. </template>
  55. </vuedraggable>
  56. </div>
  57. </div>
  58. <div v-if="noFinishedTraces.length" class="row" style="margin-left:0px; margin-right: 0px;">
  59. <div class="pull-left">
  60. <span>第{{ (pagination.current_page-1)*pagination.per_page+1 }}-{{ pagination.current_page*pagination.per_page }}条,共计{{ pagination.total }}条,每页显示</span>
  61. <PageSizeSelect @page-size-changed="gridSizeSelect" />
  62. <span>条</span>
  63. </div>
  64. <div class="pull-right">
  65. <Pagination :pagination="pagination" :callback="listNotFinishedTask" @click="updateRouter" />
  66. </div>
  67. </div>
  68. <!-- <Pagination :pagination="pagination" :callback="listNotFinishedTask" v-if="noFinishedTraces.length"></Pagination> -->
  69. <hr />
  70. <button type="button" class="btn btn-link" style="color:green" @click="openFinishedProjectTraces">
  71. 查看已完成的任务
  72. </button>
  73. </div>
  74. </template>
  75. <script>
  76. var Common = require('../common/Common.js');
  77. var Uuid = require('pc-component-v3').default.Uuid;
  78. import TraceCommon from './TraceCommon.js';
  79. import TraceResource from './TraceResource.js';
  80. var Navbar = require('pc-component-v3').default.Navbar;
  81. var Pagination = require('pc-component-v3').default.VueBootstrapPagination;;
  82. var PageSizeSelect = require('pc-component-v3').default.PageSizeSelect;
  83. var Checkbox = require('pc-component-v3').default.Checkbox;
  84. import vuedraggable from 'vuedraggable';
  85. export default {
  86. components: {
  87. Navbar,
  88. Pagination,
  89. Checkbox,
  90. vuedraggable,
  91. PageSizeSelect,
  92. },
  93. data: function() {
  94. return {
  95. finishedTraces: [], //已完成的任务
  96. projectUsers: [],
  97. projectAdminUsers: [],
  98. projectName: '',
  99. projectId: '',
  100. noFinishedTraces: [], //未完成的任务
  101. pagination: {
  102. total: 0,
  103. per_page: 50, // 每页50条信息
  104. current_page: 1, // 当前页码
  105. last_page: 10, // 最后页码
  106. },
  107. formatDate: TraceCommon.formatDate,
  108. adminUserShow: false,
  109. userShow: false,
  110. timeShow: false,
  111. content: undefined,
  112. };
  113. },
  114. mounted: function() {
  115. var _self = this;
  116. this.projectId = _self.$route.params.projectId;
  117. this.projectName = _self.$route.query.projectName;
  118. this.pagination.current_page = this.$route.query.currentPage;
  119. this.pagination.per_page = this.$route.query.pageSize;
  120. this.personNumber();
  121. this.adminPersonNumber();
  122. this.listNotFinishedTask();
  123. this.personnelJurisdictionSet();
  124. },
  125. methods: {
  126. gridSizeSelect: function(newPageSize) {
  127. this.pagination.per_page = newPageSize;
  128. this.pagination.current_page = 1;
  129. // 刷新界面
  130. this.updateRouter();
  131. },
  132. end(evt) {
  133. var _self = this;
  134. $.ajax({
  135. url: Common.getApiURL('TraceResource/sortNotFinished'),
  136. type: 'get',
  137. dataType: 'json',
  138. contentType: 'application/json',
  139. data: {
  140. 'id': evt.moved.element.id,
  141. 'projectId': _self.projectId,
  142. 'oldIndex': evt.moved.oldIndex,
  143. 'newIndex': evt.moved.newIndex,
  144. 'currentPage': _self.pagination.current_page,
  145. 'pageSize': _self.pagination.per_page,
  146. 'content': _self.content,
  147. },
  148. beforeSend: function(request) {
  149. Common.addTokenToRequest(request);
  150. },
  151. success: function(data) {
  152. _self.listNotFinishedTask();
  153. },
  154. error: function(XMLHttpRequest, textStatus, errorThrown) {
  155. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  156. },
  157. });
  158. },
  159. /**
  160. * 编辑
  161. */
  162. edit: function(trace) {
  163. var _self = this;
  164. this.$router.push('/trace/traceUpdate/' + trace.id);
  165. },
  166. updateRouter: function () {
  167. this.$router.push({
  168. path: '/trace/notFinishedProjectTraces/' + this.projectId,
  169. query: {
  170. projectName: this.projectName,
  171. currentPage: this.pagination.current_page,
  172. pageSize: this.pagination.per_page,
  173. },
  174. });
  175. console.log(this.$route);
  176. // console.log(this.$router.query.currentPage);
  177. // console.log(this.$router.query.pageSize);
  178. this.listNotFinishedTask();
  179. },
  180. /**
  181. * 打开已完成的项目任务
  182. */
  183. openFinishedProjectTraces: function() {
  184. var _self = this;
  185. this.$router.push({
  186. path: '/trace/finishedProjectTraces/' + _self.projectId,
  187. query: {
  188. projectName: _self.projectName,
  189. currentPage: 1,
  190. pageSize: 10,
  191. },
  192. });
  193. },
  194. listNotFinishedTask: function() {
  195. var _self = this;
  196. _self.noFinishedTraces.splice(0, _self.noFinishedTraces.length);
  197. $.ajax({
  198. url: Common.getApiURL('TraceResource/listNotFinishedByProjectId'),
  199. type: 'get',
  200. dataType: 'json',
  201. contentType: 'application/json',
  202. data: {
  203. 'projectId': _self.projectId,
  204. 'currentPage': _self.pagination.current_page,
  205. 'pageSize': _self.pagination.per_page,
  206. 'content': _self.content,
  207. },
  208. beforeSend: function(request) {
  209. Common.addTokenToRequest(request);
  210. },
  211. success: function(data) {
  212. if(data == null) {
  213. return;
  214. }
  215. _self.pagination.total = data.totalSize;
  216. _self.pagination.last_page = Math.ceil(_self.pagination.total / _self.pagination.per_page);
  217. _self.noFinishedTraces = data.traceDtos;
  218. console.log(_self.noFinishedTraces);
  219. },
  220. error: function(XMLHttpRequest, textStatus, errorThrown) {
  221. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  222. },
  223. });
  224. },
  225. //查询登录用户权限
  226. personnelJurisdictionSet: function() {
  227. var _self = this;
  228. $.ajax({
  229. url: Common.getApiURL('TraceResource/queryPersonnelJurisdiction'),
  230. type: 'get',
  231. dataType: 'json',
  232. contentType: 'application/json',
  233. data: {
  234. 'projectId': _self.projectId,
  235. },
  236. beforeSend: function(request) {
  237. Common.addTokenToRequest(request);
  238. },
  239. success: function(data) {
  240. if(data == null) {
  241. return;
  242. }
  243. if(data.levelOfPerson == 1) {
  244. _self.timeShow = true;
  245. return;
  246. }
  247. if(data.levelOfPerson == 2) {
  248. _self.timeShow = true,
  249. _self.adminUserShow = false,
  250. _self.userShow = true;
  251. }
  252. if(data.levelOfPerson == 3) {
  253. _self.timeShow = true,
  254. _self.adminUserShow = true,
  255. _self.userShow = true;
  256. }
  257. },
  258. error: function(XMLHttpRequest, textStatus, errorThrown) {
  259. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  260. },
  261. });
  262. },
  263. /**
  264. * 初始化接收该项目的人数
  265. * @author ZhangTeng 20190212
  266. */
  267. personNumber: function() {
  268. var _self = this;
  269. _self.projectUsers.splice(0, _self.projectUsers.length);
  270. $.ajax({
  271. url: Common.getApiURL('TraceResource/listByProjectId'),
  272. type: 'get',
  273. dataType: 'json',
  274. contentType: 'application/json',
  275. data: {
  276. 'projectId': _self.projectId,
  277. },
  278. beforeSend: function(request) {
  279. Common.addTokenToRequest(request);
  280. },
  281. success: function(data) {
  282. if(data == null) {
  283. return;
  284. }
  285. console.log(data);
  286. for(var index = 0; index < data.length; index++) {
  287. _self.projectUsers[index] = data[index];
  288. // _self.$set(_self.projectUsers, index, data[index]);
  289. }
  290. },
  291. error: function(XMLHttpRequest, textStatus, errorThrown) {
  292. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  293. },
  294. });
  295. },
  296. /**
  297. * 初始化接收该项目的管理员人数
  298. * @author TangWenXiang 20191009
  299. */
  300. adminPersonNumber: function() {
  301. var _self = this;
  302. _self.projectAdminUsers.splice(0, _self.projectUsers.length);
  303. $.ajax({
  304. url: Common.getApiURL('TraceResource/listAdminByProjectId'),
  305. type: 'get',
  306. dataType: 'json',
  307. contentType: 'application/json',
  308. data: {
  309. 'projectId': _self.projectId,
  310. },
  311. beforeSend: function(request) {
  312. Common.addTokenToRequest(request);
  313. },
  314. success: function(data) {
  315. if(data == null) {
  316. return;
  317. }
  318. for(var index = 0; index < data.length; index++) {
  319. _self.projectAdminUsers[index] = data[index];
  320. // _self.$set(_self.projectAdminUsers, index, data[index]);
  321. }
  322. },
  323. error: function(XMLHttpRequest, textStatus, errorThrown) {
  324. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  325. },
  326. });
  327. },
  328. /**
  329. * 打开明细
  330. * @author ZhangTeng 20190131
  331. */
  332. openLine: function(obj) {
  333. this.$router.push({
  334. path: '/trace/trace/' + obj.id,
  335. });
  336. },
  337. /**
  338. * 添加任务
  339. * @author ZhangTeng 20190201
  340. */
  341. addTrace: function(projectId) {
  342. this.$router.push('/trace/traceCreate/' + projectId);
  343. },
  344. /**
  345. * 项目归档
  346. * @param {Object} projectId
  347. * @author GuoZhiBo 20190926
  348. */
  349. projectArchive: function(projectId) {
  350. var _self = this;
  351. this.$router.push({
  352. path: '/trace/projectArchive/' + projectId,
  353. query: {
  354. projectName: _self.projectName,
  355. },
  356. });
  357. },
  358. /**
  359. * 项目任务
  360. * @param {Object} projectId
  361. * @author GuoZhiBo 20190926
  362. */
  363. projectManagement: function(projectId) {
  364. var _self = this;
  365. this.$router.push({
  366. path: '/trace/projectManagement/' + projectId,
  367. query: {
  368. projectName: _self.projectName,
  369. },
  370. });
  371. },
  372. /**
  373. * 跳转到人员界面
  374. * @author ZhangTeng 20190212
  375. */
  376. goPersonList: function() {
  377. var _self = this;
  378. this.$router.push({
  379. path: '/trace/projectUserList/' + _self.projectId,
  380. query: {
  381. projectName: _self.projectName,
  382. },
  383. });
  384. },
  385. /**
  386. * 跳转到项目管理人员界面
  387. * @author ZhangTeng 20190212
  388. */
  389. goAdminPersonList: function() {
  390. var _self = this;
  391. this.$router.push({
  392. path: '/trace/projectAdminUserList/' + _self.projectId,
  393. query: {
  394. projectName: _self.projectName,
  395. },
  396. });
  397. },
  398. /**
  399. * 修改追踪单的状态
  400. * @author YangZhiJie 20171201
  401. */
  402. updateTracefinished: function(trace) {
  403. var _self = this;
  404. TraceResource.updateTraceFinished(trace.id).then(successData => {
  405. _self.listNotFinishedTask();
  406. }, errorData => {
  407. Common.processException(errorData);
  408. });
  409. },
  410. },
  411. };
  412. </script>
  413. <style scoped>
  414. .trace-summary {
  415. font-size: large;
  416. margin-left: 5px;
  417. margin-right: 5px;
  418. }
  419. .trace-icon {
  420. opacity: 0.5;
  421. }
  422. .trace-user {
  423. font-size: 100%;
  424. }
  425. .trace-checkbox {
  426. display: inline;
  427. font-size: large;
  428. }
  429. </style>