panel.vue 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  1. <template>
  2. <div class="w-main project-panel">
  3. <v-title>{{$L('项目面板')}}-{{$L('轻量级的团队在线协作')}}</v-title>
  4. <div class="w-nav">
  5. <div class="nav-row">
  6. <div class="w-nav-left">
  7. <div class="page-nav-left">
  8. <span class="bold">{{projectDetail.title}}</span>
  9. <div v-if="loadIng > 0" class="page-nav-loading"><w-loading></w-loading></div>
  10. <div v-else class="page-nav-refresh"><em @click="getDetail(true)">{{$L('刷新')}}</em></div>
  11. </div>
  12. </div>
  13. <div class="w-nav-flex"></div>
  14. <div class="w-nav-right">
  15. <span class="ft hover" :class="{active:filtrTask!=''}">
  16. <Dropdown @on-click="(res)=>{filtrTask=res}" transfer>
  17. <Icon type="md-funnel" class="icon"/> {{$L('筛选')}}
  18. <DropdownMenu slot="list">
  19. <DropdownItem name="" :class="{'dropdown-active':filtrTask==''}">全部任务</DropdownItem>
  20. <DropdownItem name="persons" :class="{'dropdown-active':filtrTask=='persons'}">我负责的任务</DropdownItem>
  21. <DropdownItem name="follower" :class="{'dropdown-active':filtrTask=='follower'}">我关注的任务</DropdownItem>
  22. </DropdownMenu>
  23. </Dropdown>
  24. </span>
  25. <span class="ft hover" @click="openProjectDrawer('lists')"><i class="ft icon">&#xE89E;</i> {{$L('列表')}}</span>
  26. <span class="ft hover" :class="{active:projectGanttShow}" @click="projectGanttShow=!projectGanttShow"><i class="ft icon">&#59141;</i> {{$L('甘特图')}}</span>
  27. <span class="ft hover" @click="openProjectDrawer('files')"><i class="ft icon">&#xE701;</i> {{$L('文件')}}</span>
  28. <span class="ft hover" @click="openProjectDrawer('logs')"><i class="ft icon">&#xE753;</i> {{$L('动态')}}</span>
  29. <span class="ft hover" @click="openProjectSettingDrawer('setting')"><i class="ft icon">&#xE7A7;</i> {{$L('设置')}}</span>
  30. </div>
  31. </div>
  32. </div>
  33. <w-content>
  34. <draggable
  35. v-model="projectLabel"
  36. class="label-box"
  37. draggable=".label-draggable"
  38. :style="{visibility: projectGanttShow ? 'hidden' : 'visible'}"
  39. :animation="150"
  40. :disabled="projectSortDisabled"
  41. @sort="projectSortUpdate(true)">
  42. <div
  43. v-if="projectLabel.length > 0"
  44. v-for="label in projectLabel"
  45. :key="label.id"
  46. class="label-item label-draggable"
  47. :class="{'label-scroll': label.hasScroll === true && label.endScroll !== true}"
  48. @mouseenter="projectMouse(label)">
  49. <div class="label-body">
  50. <div class="title-box">
  51. <div v-if="label.loadIng === true" class="title-loading">
  52. <w-loading></w-loading>
  53. </div>
  54. <h2>{{label.title}}</h2>
  55. <Dropdown trigger="click" @on-click="handleLabel($event, label)" transfer>
  56. <Icon type="ios-more"/>
  57. <DropdownMenu slot="list">
  58. <Dropdown-item name="refresh">{{$L('刷新列表')}}</Dropdown-item>
  59. <Dropdown-item name="rename">{{$L('重命名')}}</Dropdown-item>
  60. <Dropdown-item name="delete">{{$L('删除')}}</Dropdown-item>
  61. </DropdownMenu>
  62. </Dropdown>
  63. </div>
  64. <ScrollerY
  65. :ref="'box_' + label.id"
  66. class="task-box"
  67. @on-scroll="projectBoxScroll($event, label)">
  68. <draggable
  69. v-model="label.taskLists"
  70. class="task-main"
  71. :class="[filtrTask ? 'filtr-' + filtrTask : '']"
  72. group="task"
  73. draggable=".task-draggable"
  74. :animation="150"
  75. :disabled="projectSortDisabled"
  76. @sort="projectSortUpdate(false)"
  77. @remove="projectSortUpdate(false)">
  78. <div v-for="task in label.taskLists"
  79. :key="task.id"
  80. class="task-item task-draggable"
  81. :class="{'persons-item':isPersonsTask(task), 'follower-item': isFollowerTask(task)}">
  82. <div class="task-shadow" :class="[
  83. 'p'+task.level,
  84. task.complete ? 'complete' : '',
  85. task.overdue ? 'overdue' : '',
  86. task.isNewtask === true ? 'newtask' : ''
  87. ]" @click="openTaskModal(task)">
  88. <div class="subtask-progress"><em :style="{width: subtaskProgress(task) + '%'}"></em></div>
  89. <div class="task-title">{{task.title}}<Icon v-if="task.desc" type="ios-list-box-outline" /></div>
  90. <div class="task-more">
  91. <div v-if="task.overdue" class="task-status">{{$L('已超期')}}</div>
  92. <div v-else-if="task.complete" class="task-status">{{$L('已完成')}}</div>
  93. <div v-else class="task-status">{{$L('未完成')}}</div>
  94. <div class="task-persons" :class="{'persons-more':task.persons.length > 1}">
  95. <Tooltip
  96. v-for="(person, iper) in task.persons"
  97. class="task-userimg"
  98. :key="iper"
  99. :content="person.nickname || person.username"
  100. transfer>
  101. <UserImg :info="person" class="avatar"/>
  102. </Tooltip>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. <div slot="footer">
  108. <project-add-task
  109. :ref="'add_' + label.id"
  110. :placeholder='`${$L("添加任务至")}"${label.title}"`'
  111. :projectid="label.projectid"
  112. :labelid="label.id"
  113. @on-add-success="addTaskSuccess($event, label)"></project-add-task>
  114. </div>
  115. </draggable>
  116. </ScrollerY>
  117. </div>
  118. <div class="label-bottom" @click="projectFocus(label)">
  119. <Icon class="label-bottom-icon" type="ios-add" />
  120. </div>
  121. </div>
  122. <div v-if="loadDetailed" slot="footer" class="label-item label-create" @click="addLabel">
  123. <div class="label-body">
  124. <div class="trigger-box ft hover"><i class="ft icon">&#xE8C8;</i>{{$L('添加一个新列表')}}</div>
  125. </div>
  126. </div>
  127. </draggable>
  128. <project-gantt v-if="projectGanttShow" @on-close="projectGanttShow=false" :projectLabel="projectLabel"></project-gantt>
  129. </w-content>
  130. <WDrawer v-model="projectDrawerShow" maxWidth="1080">
  131. <Tabs v-if="projectDrawerShow" v-model="projectDrawerTab">
  132. <TabPane :label="$L('任务列表')" name="lists">
  133. <project-task-lists :canload="projectDrawerShow && projectDrawerTab == 'lists'" :projectid="projectid" :labelLists="projectSimpleLabel"></project-task-lists>
  134. </TabPane>
  135. <TabPane :label="$L('文件列表')" name="files">
  136. <project-task-files :canload="projectDrawerShow && projectDrawerTab == 'files'" :projectid="projectid"></project-task-files>
  137. </TabPane>
  138. <TabPane :label="$L('项目动态')" name="logs">
  139. <project-task-logs :canload="projectDrawerShow && projectDrawerTab == 'logs'" :projectid="projectid"></project-task-logs>
  140. </TabPane>
  141. </Tabs>
  142. </WDrawer>
  143. <WDrawer v-model="projectSettingDrawerShow" maxWidth="1000">
  144. <Tabs v-if="projectSettingDrawerShow" v-model="projectSettingDrawerTab">
  145. <TabPane :label="$L('项目设置')" name="setting">
  146. <project-setting :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'setting'" :projectid="projectid" @on-change="getDetail"></project-setting>
  147. </TabPane>
  148. <TabPane :label="$L('已归档任务')" name="archived">
  149. <project-archived :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'archived'" :projectid="projectid"></project-archived>
  150. </TabPane>
  151. <TabPane :label="$L('项目统计')" name="statistics">
  152. <project-statistics ref="statistics" :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'statistics'" :projectid="projectid"></project-statistics>
  153. </TabPane>
  154. <TabPane :label="$L('成员管理')" name="member">
  155. <project-users :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'member'" :projectid="projectid"></project-users>
  156. </TabPane>
  157. </Tabs>
  158. </WDrawer>
  159. </div>
  160. </template>
  161. <style lang="scss">
  162. #project-panel-enter-textarea {
  163. background: transparent;
  164. background: none;
  165. outline: none;
  166. border: 0;
  167. resize: none;
  168. padding: 0;
  169. margin: 8px 0;
  170. line-height: 22px;
  171. border-radius: 0;
  172. color: rgba(0, 0, 0, 0.85);
  173. &:focus {
  174. border-color: transparent;
  175. box-shadow: none;
  176. }
  177. }
  178. </style>
  179. <style lang="scss" scoped>
  180. .project-panel {
  181. .label-box {
  182. display: flex;
  183. flex-direction: row;
  184. align-items: flex-start;
  185. justify-content: flex-start;
  186. flex-wrap: nowrap;
  187. overflow-x: auto;
  188. overflow-y: hidden;
  189. -webkit-overflow-scrolling: touch;
  190. width: 100%;
  191. height: 100%;
  192. padding: 15px;
  193. transform: translateZ(0);
  194. .label-item {
  195. flex-grow: 0;
  196. flex-shrink: 0;
  197. flex-basis: auto;
  198. position: relative;
  199. overflow: hidden;
  200. height: 100%;
  201. padding-right: 15px;
  202. &.label-create {
  203. cursor: pointer;
  204. &:hover {
  205. .trigger-box {
  206. transform: translate(0, -50%) scale(1.1);
  207. }
  208. }
  209. }
  210. &.label-scroll {
  211. &:hover {
  212. .label-bottom {
  213. transform: translate(-50%, 0);
  214. }
  215. }
  216. }
  217. .label-body {
  218. width: 300px;
  219. height: 100%;
  220. border-radius: 0.15rem;
  221. background-color: #ebecf0;
  222. overflow: hidden;
  223. position: relative;
  224. display: flex;
  225. flex-direction: column;
  226. .title-box {
  227. padding: 0 12px;
  228. font-weight: bold;
  229. color: #666666;
  230. position: relative;
  231. cursor: move;
  232. display: flex;
  233. align-items: center;
  234. width: 100%;
  235. height: 42px;
  236. .title-loading {
  237. width: 16px;
  238. height: 16px;
  239. margin-right: 6px;
  240. }
  241. h2 {
  242. flex: 1;
  243. font-size: 16px;
  244. overflow: hidden;
  245. text-overflow: ellipsis;
  246. white-space: nowrap;
  247. }
  248. i {
  249. font-weight: 500;
  250. font-size: 18px;
  251. height: 100%;
  252. line-height: 42px;
  253. width: 42px;
  254. text-align: right;
  255. cursor: pointer;
  256. }
  257. }
  258. .task-box {
  259. position: relative;
  260. flex: 1;
  261. width: 100%;
  262. padding: 0 12px 2px;
  263. transform: translateZ(0);
  264. .task-main {
  265. display: flex;
  266. flex-direction: column;
  267. &.filtr-persons {
  268. .task-item {
  269. display: none;
  270. &.persons-item {
  271. display: block;
  272. }
  273. }
  274. }
  275. &.filtr-follower {
  276. .task-item {
  277. display: none;
  278. &.follower-item {
  279. display: block;
  280. }
  281. }
  282. }
  283. }
  284. .task-item {
  285. width: 100%;
  286. &.task-draggable {
  287. .task-shadow {
  288. cursor: pointer;
  289. &:hover{
  290. box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.38);
  291. }
  292. }
  293. }
  294. .task-shadow {
  295. margin: 5px 0 4px;
  296. padding: 8px 10px 8px 8px;
  297. background-color: #ffffff;
  298. border-left: 2px solid #BF9F03;
  299. border-right: 0;
  300. color: #091e42;
  301. border-radius: 3px;
  302. box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  303. transition: all 0.3s;
  304. transform: scale(1);
  305. &.p1 {
  306. border-left-color: #ff0000;
  307. }
  308. &.p2 {
  309. border-left-color: #BB9F35;
  310. }
  311. &.p3 {
  312. border-left-color: #449EDD;
  313. }
  314. &.p4 {
  315. border-left-color: #84A83B;
  316. }
  317. &.complete {
  318. border-left-color: #c1c1c1;
  319. .task-title {
  320. color: #666666;
  321. text-decoration: line-through;
  322. }
  323. .task-more {
  324. .task-status {
  325. color: #666666;
  326. }
  327. }
  328. }
  329. &.overdue {
  330. .task-title {
  331. font-weight: bold;
  332. }
  333. .task-more {
  334. .task-status {
  335. color: #ff0000;
  336. }
  337. }
  338. }
  339. &.newtask {
  340. transform: scale(1.5);
  341. }
  342. .task-title {
  343. font-size: 12px;
  344. color: #091e42;
  345. word-break: break-all;
  346. .ivu-icon {
  347. font-size: 14px;
  348. color: #afafaf;
  349. vertical-align: top;
  350. padding: 2px 4px;
  351. transform: scale(0.94);
  352. }
  353. }
  354. .task-more {
  355. min-height: 30px;
  356. display: flex;
  357. align-items: flex-end;
  358. .task-status {
  359. color: #19be6b;
  360. font-size: 12px;
  361. flex: 1;
  362. }
  363. .task-persons {
  364. max-width: 150px;
  365. &.persons-more {
  366. text-align: right;
  367. .task-userimg {
  368. width: 20px;
  369. height: 20px;
  370. margin-left: 4px;
  371. margin-top: 4px;
  372. .avatar {
  373. width: 20px;
  374. height: 20px;
  375. font-size: 12px;
  376. line-height: 20px;
  377. }
  378. }
  379. }
  380. .task-userimg {
  381. width: 26px;
  382. height: 26px;
  383. vertical-align: bottom;
  384. .avatar {
  385. width: 26px;
  386. height: 26px;
  387. font-size: 14px;
  388. line-height: 26px;
  389. border-radius: 13px;
  390. }
  391. }
  392. }
  393. }
  394. .subtask-progress {
  395. position: absolute;
  396. top: 0;
  397. left: 0;
  398. width: 100%;
  399. height: 100%;
  400. z-index: -1;
  401. border-radius: 0 3px 3px 0;
  402. overflow: hidden;
  403. pointer-events: none;
  404. em {
  405. display: block;
  406. height: 100%;
  407. background-color: rgba(3, 150, 242, 0.07);
  408. }
  409. }
  410. }
  411. }
  412. }
  413. .trigger-box {
  414. text-align: center;
  415. font-size: 16px;
  416. color: #666;
  417. width: 100%;
  418. position: absolute;
  419. top: 50%;
  420. transform: translate(0, -50%) scale(1);
  421. transition: all 0.3s;
  422. }
  423. }
  424. .label-bottom {
  425. position: absolute;
  426. left: 50%;
  427. bottom: 14px;
  428. z-index: 1;
  429. width: 36px;
  430. height: 36px;
  431. border-radius: 50%;
  432. background-color: #2db7f5;
  433. display: flex;
  434. align-items: center;
  435. justify-content: center;
  436. transition: transform 0.2s;
  437. transform: translate(-50%, 200%);
  438. cursor: pointer;
  439. .label-bottom-icon {
  440. color: #ffffff;
  441. font-size: 36px;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. </style>
  448. <script>
  449. import draggable from 'vuedraggable'
  450. import WContent from "../../components/WContent";
  451. import ProjectAddTask from "../../components/project/task/add";
  452. import ProjectTaskLists from "../../components/project/task/lists";
  453. import ProjectTaskFiles from "../../components/project/task/files";
  454. import ProjectTaskLogs from "../../components/project/task/logs";
  455. import ProjectArchived from "../../components/project/archived";
  456. import ProjectUsers from "../../components/project/users";
  457. import ProjectStatistics from "../../components/project/statistics";
  458. import WDrawer from "../../components/iview/WDrawer";
  459. import ProjectGantt from "../../components/project/gantt/index";
  460. import ProjectSetting from "../../components/project/setting";
  461. import ScrollerY from "../../../_components/ScrollerY";
  462. import orderBy from "lodash/orderBy";
  463. export default {
  464. components: {
  465. ScrollerY,
  466. ProjectSetting,
  467. ProjectGantt,
  468. WDrawer,
  469. ProjectStatistics,
  470. ProjectUsers,
  471. ProjectArchived,
  472. ProjectTaskLogs,
  473. ProjectTaskFiles, ProjectTaskLists, ProjectAddTask, draggable, WContent},
  474. data () {
  475. return {
  476. loadIng: 0,
  477. loadDetailed: false,
  478. projectid: 0,
  479. projectDetail: {},
  480. projectLabel: [],
  481. projectSimpleLabel: [],
  482. projectSortData: '',
  483. projectSortDisabled: false,
  484. projectDrawerShow: false,
  485. projectDrawerTab: 'lists',
  486. projectSettingDrawerShow: false,
  487. projectSettingDrawerTab: 'setting',
  488. projectGanttShow: false,
  489. userInfo: {},
  490. filtrTask: '',
  491. routeName: '',
  492. }
  493. },
  494. mounted() {
  495. this.routeName = this.$route.name;
  496. this.userInfo = $A.getUserInfo((res) => {
  497. this.userInfo = res;
  498. }, false);
  499. $A.setOnTaskInfoListener('pages/project-panel',(act, detail) => {
  500. if (detail.projectid != this.projectid) {
  501. return;
  502. }
  503. //
  504. switch (act) {
  505. case 'addlabel': // 添加分类
  506. let tempLists = this.projectLabel.filter((res) => { return res.id == detail.labelid });
  507. if (tempLists.length == 0) {
  508. this.projectLabel.push(Object.assign(detail, {id: detail.labelid}));
  509. this.projectSortData = this.getProjectSort();
  510. }
  511. return;
  512. case 'deletelabel': // 删除分类
  513. this.projectLabel.some((label, index) => {
  514. if (label.id == detail.labelid) {
  515. this.projectLabel.splice(index, 1);
  516. this.projectSortData = this.getProjectSort();
  517. return true;
  518. }
  519. });
  520. return;
  521. case 'deleteproject': // 删除项目
  522. return;
  523. case "labelsort": // 调整分类排序
  524. case "tasksort": // 调整任务排序
  525. if (detail.__modifyUsername != $A.getUserName()) {
  526. if (this.routeName == this.$route.name) {
  527. this.$Modal.confirm({
  528. title: this.$L("更新提示"),
  529. content: this.$L('团队成员(%)调整了%,<br/>更新时间:%。<br/><br/>点击【确定】加载最新数据。', detail.nickname, this.$L(act == 'labelsort' ? '分类排序' : '任务排序'), $A.formatDate("Y-m-d H:i:s", detail.time)),
  530. onOk: () => {
  531. this.getDetail(true);
  532. }
  533. });
  534. } else {
  535. this.getDetail(true);
  536. }
  537. }
  538. return;
  539. }
  540. //
  541. this.projectLabel.forEach((label) => {
  542. label.taskLists.some((task, i) => {
  543. if (task.id == detail.id) {
  544. label.taskLists.splice(i, 1, detail);
  545. return true;
  546. }
  547. });
  548. });
  549. //
  550. switch (act) {
  551. case "delete": // 删除任务
  552. case "archived": // 归档
  553. this.projectLabel.forEach((label) => {
  554. label.taskLists.some((task, i) => {
  555. if (task.id == detail.id) {
  556. label.taskLists.splice(i, 1,);
  557. return true;
  558. }
  559. });
  560. });
  561. this.projectSortData = this.getProjectSort();
  562. break;
  563. case "create": // 创建任务
  564. this.projectLabel.some((label) => {
  565. if (label.id == detail.labelid) {
  566. let tempLists = label.taskLists.filter((res) => { return res.id == detail.id });
  567. if (tempLists.length == 0) {
  568. detail.isNewtask = true;
  569. if (detail.insertbottom) {
  570. label.taskLists.push(detail);
  571. } else {
  572. label.taskLists.unshift(detail);
  573. }
  574. this.$nextTick(() => {
  575. this.$set(detail, 'isNewtask', false);
  576. });
  577. }
  578. return true;
  579. }
  580. });
  581. break;
  582. case "unarchived": // 取消归档
  583. this.projectLabel.forEach((label) => {
  584. if (label.id == detail.labelid) {
  585. let index = label.taskLists.length;
  586. label.taskLists.some((task, i) => {
  587. if (detail.inorder > task.inorder || (detail.inorder == task.inorder && detail.id > task.id)) {
  588. index = i;
  589. return true;
  590. }
  591. });
  592. label.taskLists.splice(index, 0, detail);
  593. }
  594. });
  595. this.projectSortData = this.getProjectSort();
  596. break;
  597. case "complete": // 标记完成
  598. case "unfinished": // 标记未完成
  599. this.taskNewSort();
  600. break;
  601. }
  602. }, true);
  603. },
  604. activated() {
  605. this.projectid = this.$route.params.projectid;
  606. if (typeof this.$route.params.other === "object") {
  607. this.$set(this.projectDetail, 'title', $A.getObject(this.$route.params.other, 'title'));
  608. }
  609. if (this.$route.params.statistics === '已完成') {
  610. this.projectSettingDrawerTab = 'statistics';
  611. this.projectSettingDrawerShow = true;
  612. this.$nextTick(() => {
  613. this.$refs.statistics.setTaskType('已完成');
  614. });
  615. }
  616. },
  617. deactivated() {
  618. if ($A.getToken() === false) {
  619. this.projectid = 0;
  620. }
  621. this.projectGanttShow = false;
  622. this.projectDrawerShow = false;
  623. this.projectSettingDrawerShow = false;
  624. },
  625. watch: {
  626. projectid(val) {
  627. if ($A.runNum(val) <= 0) {
  628. return;
  629. }
  630. this.projectDetail = {};
  631. this.projectLabel = [];
  632. this.projectSimpleLabel = [];
  633. this.getDetail();
  634. }
  635. },
  636. methods: {
  637. getDetail(successTip) {
  638. this.loadIng++;
  639. $A.apiAjax({
  640. url: 'project/detail',
  641. data: {
  642. projectid: this.projectid,
  643. },
  644. complete: () => {
  645. this.loadIng--;
  646. this.loadDetailed = true;
  647. },
  648. error: () => {
  649. this.goBack({name:'project'});
  650. alert(this.$L('网络繁忙,请稍后再试!'));
  651. },
  652. success: (res) => {
  653. if (res.ret === 1) {
  654. this.projectLabel = res.data.label;
  655. this.taskNewSort();
  656. this.projectDetail = res.data.project;
  657. this.projectSimpleLabel = res.data.simpleLabel;
  658. this.projectSortData = this.getProjectSort();
  659. if (successTip === true) {
  660. this.$Message.success(this.$L('刷新成功!'));
  661. }
  662. } else {
  663. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  664. }
  665. }
  666. });
  667. },
  668. getProjectSort() {
  669. let sortData = "",
  670. taskData = "";
  671. this.projectLabel.forEach((label) => {
  672. taskData = "";
  673. label.taskLists.forEach((task) => {
  674. if (taskData) taskData+= "-";
  675. taskData+= task.id;
  676. });
  677. if (sortData) sortData+= ";";
  678. sortData+= label.id + ":" + taskData;
  679. });
  680. return sortData;
  681. },
  682. handleLabel(event, labelDetail) {
  683. switch (event) {
  684. case 'refresh': {
  685. this.refreshLabel(labelDetail);
  686. break;
  687. }
  688. case 'rename': {
  689. this.renameLabel(labelDetail);
  690. break;
  691. }
  692. case 'delete': {
  693. this.deleteLabel(labelDetail);
  694. break;
  695. }
  696. }
  697. },
  698. refreshLabel(item) {
  699. this.$set(item, 'loadIng', true);
  700. $A.apiAjax({
  701. url: 'project/task/lists',
  702. data: {
  703. projectid: this.projectid,
  704. labelid: item.id,
  705. },
  706. complete: () => {
  707. this.$set(item, 'loadIng', false);
  708. },
  709. error: () => {
  710. window.location.reload();
  711. },
  712. success: (res) => {
  713. if (res.ret === 1) {
  714. this.$set(item, 'taskLists', res.data.lists);
  715. } else {
  716. window.location.reload();
  717. }
  718. }
  719. });
  720. },
  721. renameLabel(item) {
  722. this.renameValue = "";
  723. this.$Modal.confirm({
  724. render: (h) => {
  725. return h('div', [
  726. h('div', {
  727. style: {
  728. fontSize: '16px',
  729. fontWeight: '500',
  730. marginBottom: '20px',
  731. }
  732. }, this.$L('重命名列表')),
  733. h('Input', {
  734. props: {
  735. value: this.renameValue,
  736. autofocus: true,
  737. placeholder: this.$L('请输入新的列表名称')
  738. },
  739. on: {
  740. input: (val) => {
  741. this.renameValue = val;
  742. }
  743. }
  744. })
  745. ])
  746. },
  747. loading: true,
  748. onOk: () => {
  749. if (this.renameValue) {
  750. this.$set(item, 'loadIng', true);
  751. let title = this.renameValue;
  752. $A.apiAjax({
  753. url: 'project/label/rename',
  754. data: {
  755. projectid: this.projectid,
  756. labelid: item.id,
  757. title: title,
  758. },
  759. complete: () => {
  760. this.$set(item, 'loadIng', false);
  761. },
  762. error: () => {
  763. this.$Modal.remove();
  764. alert(this.$L('网络繁忙,请稍后再试!'));
  765. },
  766. success: (res) => {
  767. this.$Modal.remove();
  768. this.$set(item, 'title', title);
  769. setTimeout(() => {
  770. if (res.ret === 1) {
  771. this.$Message.success(res.msg);
  772. } else {
  773. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  774. }
  775. }, 350);
  776. }
  777. });
  778. } else {
  779. this.$Modal.remove();
  780. }
  781. },
  782. });
  783. },
  784. deleteLabel(item) {
  785. let redTip = item.taskLists.length > 0 ? ('<div style="color:red;font-weight:500">' + this.$L('注:将同时删除列表下所有任务') + '</div>') : '';
  786. this.$Modal.confirm({
  787. title: this.$L('删除列表'),
  788. content: '<div>' + this.$L('你确定要删除此列表吗?') + '</div>' + redTip,
  789. loading: true,
  790. onOk: () => {
  791. $A.apiAjax({
  792. url: 'project/label/delete',
  793. data: {
  794. projectid: this.projectid,
  795. labelid: item.id,
  796. },
  797. error: () => {
  798. this.$Modal.remove();
  799. alert(this.$L('网络繁忙,请稍后再试!'));
  800. },
  801. success: (res) => {
  802. this.$Modal.remove();
  803. this.projectLabel.some((label, index) => {
  804. if (label.id == item.id) {
  805. this.projectLabel.splice(index, 1);
  806. this.projectSortData = this.getProjectSort();
  807. return true;
  808. }
  809. });
  810. setTimeout(() => {
  811. if (res.ret === 1) {
  812. this.$Message.success(res.msg);
  813. $A.triggerTaskInfoListener('deletelabel', {labelid: item.id, projectid: item.projectid});
  814. } else {
  815. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  816. }
  817. }, 350);
  818. }
  819. });
  820. }
  821. });
  822. },
  823. addLabel() {
  824. this.labelValue = "";
  825. this.$Modal.confirm({
  826. render: (h) => {
  827. return h('div', [
  828. h('div', {
  829. style: {
  830. fontSize: '16px',
  831. fontWeight: '500',
  832. marginBottom: '20px',
  833. }
  834. }, this.$L('添加列表')),
  835. h('Input', {
  836. props: {
  837. value: this.labelValue,
  838. autofocus: true,
  839. placeholder: this.$L('请输入列表名称')
  840. },
  841. on: {
  842. input: (val) => {
  843. this.labelValue = val;
  844. }
  845. }
  846. })
  847. ])
  848. },
  849. loading: true,
  850. onOk: () => {
  851. if (this.labelValue) {
  852. let data = {
  853. projectid: this.projectid,
  854. title: this.labelValue
  855. };
  856. $A.apiAjax({
  857. url: 'project/label/add',
  858. data: data,
  859. error: () => {
  860. this.$Modal.remove();
  861. alert(this.$L('网络繁忙,请稍后再试!'));
  862. },
  863. success: (res) => {
  864. this.$Modal.remove();
  865. this.projectLabel.push(res.data);
  866. this.projectSortData = this.getProjectSort();
  867. $A.triggerTaskInfoListener('addlabel', Object.assign(data, {labelid: res.data.id}));
  868. setTimeout(() => {
  869. if (res.ret === 1) {
  870. this.$Message.success(res.msg);
  871. } else {
  872. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  873. }
  874. }, 350);
  875. }
  876. });
  877. } else {
  878. this.$Modal.remove();
  879. }
  880. },
  881. });
  882. },
  883. addTaskSuccess(taskDetail, label) {
  884. if (label.taskLists instanceof Array) {
  885. taskDetail.isNewtask = true;
  886. if (taskDetail.insertbottom) {
  887. label.taskLists.push(taskDetail);
  888. } else {
  889. label.taskLists.unshift(taskDetail);
  890. }
  891. this.$nextTick(() => {
  892. this.$set(taskDetail, 'isNewtask', false);
  893. });
  894. } else {
  895. this.refreshLabel(label);
  896. }
  897. },
  898. openProjectDrawer(tab) {
  899. this.projectDrawerTab = tab;
  900. this.projectDrawerShow = true;
  901. },
  902. openProjectSettingDrawer(tab) {
  903. this.projectSettingDrawerTab = tab;
  904. this.projectSettingDrawerShow = true;
  905. },
  906. projectSortUpdate(isLabel) {
  907. let oldSort = this.projectSortData;
  908. let newSort = this.getProjectSort();
  909. if (oldSort == newSort) {
  910. return;
  911. }
  912. this.projectSortData = newSort;
  913. this.projectSortDisabled = true;
  914. this.loadIng++;
  915. $A.apiAjax({
  916. url: 'project/sort',
  917. data: {
  918. projectid: this.projectid,
  919. oldsort: oldSort,
  920. newsort: newSort,
  921. label: isLabel === true ? 1 : 0
  922. },
  923. complete: () => {
  924. this.projectSortDisabled = false;
  925. this.loadIng--;
  926. },
  927. error: () => {
  928. this.getDetail();
  929. alert(this.$L('网络繁忙,请稍后再试!'));
  930. },
  931. success: (res) => {
  932. if (res.ret === 1) {
  933. this.projectLabel.forEach((label) => {
  934. let length = label.taskLists.length;
  935. label.taskLists.forEach((task, index) => {
  936. task.inorder = length - index;
  937. });
  938. });
  939. this.taskNewSort();
  940. //
  941. this.$Message.success(res.msg);
  942. $A.triggerTaskInfoListener(isLabel ? 'labelsort' : 'tasksort', { projectid: this.projectid, nickname: $A.getNickName(), time: Math.round(new Date().getTime()/1000) });
  943. } else {
  944. this.getDetail();
  945. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  946. }
  947. }
  948. });
  949. },
  950. projectMouse(label) {
  951. let hasScroll = false;
  952. let el = this.$refs['box_' + label.id]
  953. if (el && el.length > 0) {
  954. el = el[0].$el;
  955. hasScroll = el.scrollHeight > el.offsetHeight;
  956. }
  957. this.$set(label, 'hasScroll', hasScroll)
  958. },
  959. projectBoxScroll(e, label) {
  960. this.$set(label, 'endScroll', e.scrollE < 50)
  961. },
  962. projectFocus(label) {
  963. let el = this.$refs['add_' + label.id];
  964. if (el && el.length > 0) {
  965. el[0].setFocus();
  966. }
  967. },
  968. subtaskProgress(task) {
  969. const {subtask, complete} = task;
  970. if (subtask.length === 0) {
  971. return complete ? 100 : 0;
  972. }
  973. const completeLists = subtask.filter((item) => { return item.status == 'complete'});
  974. return parseFloat(((completeLists.length / subtask.length) * 100).toFixed(2));
  975. },
  976. openTaskModal(taskDetail) {
  977. this.taskDetail(taskDetail);
  978. },
  979. taskNewSort() {
  980. this.$nextTick(() => {
  981. this.projectLabel.forEach((item) => { item.taskLists = this.taskReturnNewSort(item.taskLists) });
  982. })
  983. },
  984. taskReturnNewSort(lists) {
  985. let tmpLists = orderBy(lists, ['complete', 'inorder'], ['asc', 'desc']);
  986. let array = [];
  987. array.unshift(...tmpLists.filter(({complete}) => complete ));
  988. array.unshift(...tmpLists.filter(({complete}) => !complete ));
  989. return array;
  990. },
  991. isPersonsTask(task) {
  992. return task.persons && !!task.persons.find(({username}) => username == this.userInfo.username);
  993. },
  994. isFollowerTask(task) {
  995. return task.follower && task.follower.indexOf(this.userInfo.username) !== -1;
  996. }
  997. },
  998. }
  999. </script>