panel.vue 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  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. '$route' (To) {
  636. if (To.name == 'project-panel') {
  637. this.projectid = To.params.projectid;
  638. }
  639. }
  640. },
  641. methods: {
  642. getDetail(successTip) {
  643. this.loadIng++;
  644. $A.apiAjax({
  645. url: 'project/detail',
  646. data: {
  647. projectid: this.projectid,
  648. },
  649. complete: () => {
  650. this.loadIng--;
  651. this.loadDetailed = true;
  652. },
  653. error: () => {
  654. this.goBack({name:'project'});
  655. alert(this.$L('网络繁忙,请稍后再试!'));
  656. },
  657. success: (res) => {
  658. if (res.ret === 1) {
  659. this.projectLabel = res.data.label;
  660. this.taskNewSort();
  661. this.projectDetail = res.data.project;
  662. this.projectSimpleLabel = res.data.simpleLabel;
  663. this.projectSortData = this.getProjectSort();
  664. if (successTip === true) {
  665. this.$Message.success(this.$L('刷新成功!'));
  666. }
  667. } else {
  668. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  669. }
  670. }
  671. });
  672. },
  673. getProjectSort() {
  674. let sortData = "",
  675. taskData = "";
  676. this.projectLabel.forEach((label) => {
  677. taskData = "";
  678. label.taskLists.forEach((task) => {
  679. if (taskData) taskData+= "-";
  680. taskData+= task.id;
  681. });
  682. if (sortData) sortData+= ";";
  683. sortData+= label.id + ":" + taskData;
  684. });
  685. return sortData;
  686. },
  687. handleLabel(event, labelDetail) {
  688. switch (event) {
  689. case 'refresh': {
  690. this.refreshLabel(labelDetail);
  691. break;
  692. }
  693. case 'rename': {
  694. this.renameLabel(labelDetail);
  695. break;
  696. }
  697. case 'delete': {
  698. this.deleteLabel(labelDetail);
  699. break;
  700. }
  701. }
  702. },
  703. refreshLabel(item) {
  704. this.$set(item, 'loadIng', true);
  705. $A.apiAjax({
  706. url: 'project/task/lists',
  707. data: {
  708. projectid: this.projectid,
  709. labelid: item.id,
  710. },
  711. complete: () => {
  712. this.$set(item, 'loadIng', false);
  713. },
  714. error: () => {
  715. window.location.reload();
  716. },
  717. success: (res) => {
  718. if (res.ret === 1) {
  719. this.$set(item, 'taskLists', res.data.lists);
  720. } else {
  721. window.location.reload();
  722. }
  723. }
  724. });
  725. },
  726. renameLabel(item) {
  727. this.renameValue = "";
  728. this.$Modal.confirm({
  729. render: (h) => {
  730. return h('div', [
  731. h('div', {
  732. style: {
  733. fontSize: '16px',
  734. fontWeight: '500',
  735. marginBottom: '20px',
  736. }
  737. }, this.$L('重命名列表')),
  738. h('Input', {
  739. props: {
  740. value: this.renameValue,
  741. autofocus: true,
  742. placeholder: this.$L('请输入新的列表名称')
  743. },
  744. on: {
  745. input: (val) => {
  746. this.renameValue = val;
  747. }
  748. }
  749. })
  750. ])
  751. },
  752. loading: true,
  753. onOk: () => {
  754. if (this.renameValue) {
  755. this.$set(item, 'loadIng', true);
  756. let title = this.renameValue;
  757. $A.apiAjax({
  758. url: 'project/label/rename',
  759. data: {
  760. projectid: this.projectid,
  761. labelid: item.id,
  762. title: title,
  763. },
  764. complete: () => {
  765. this.$set(item, 'loadIng', false);
  766. },
  767. error: () => {
  768. this.$Modal.remove();
  769. alert(this.$L('网络繁忙,请稍后再试!'));
  770. },
  771. success: (res) => {
  772. this.$Modal.remove();
  773. this.$set(item, 'title', title);
  774. setTimeout(() => {
  775. if (res.ret === 1) {
  776. this.$Message.success(res.msg);
  777. } else {
  778. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  779. }
  780. }, 350);
  781. }
  782. });
  783. } else {
  784. this.$Modal.remove();
  785. }
  786. },
  787. });
  788. },
  789. deleteLabel(item) {
  790. let redTip = item.taskLists.length > 0 ? ('<div style="color:red;font-weight:500">' + this.$L('注:将同时删除列表下所有任务') + '</div>') : '';
  791. this.$Modal.confirm({
  792. title: this.$L('删除列表'),
  793. content: '<div>' + this.$L('你确定要删除此列表吗?') + '</div>' + redTip,
  794. loading: true,
  795. onOk: () => {
  796. $A.apiAjax({
  797. url: 'project/label/delete',
  798. data: {
  799. projectid: this.projectid,
  800. labelid: item.id,
  801. },
  802. error: () => {
  803. this.$Modal.remove();
  804. alert(this.$L('网络繁忙,请稍后再试!'));
  805. },
  806. success: (res) => {
  807. this.$Modal.remove();
  808. this.projectLabel.some((label, index) => {
  809. if (label.id == item.id) {
  810. this.projectLabel.splice(index, 1);
  811. this.projectSortData = this.getProjectSort();
  812. return true;
  813. }
  814. });
  815. setTimeout(() => {
  816. if (res.ret === 1) {
  817. this.$Message.success(res.msg);
  818. $A.triggerTaskInfoListener('deletelabel', {labelid: item.id, projectid: item.projectid});
  819. } else {
  820. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  821. }
  822. }, 350);
  823. }
  824. });
  825. }
  826. });
  827. },
  828. addLabel() {
  829. this.labelValue = "";
  830. this.$Modal.confirm({
  831. render: (h) => {
  832. return h('div', [
  833. h('div', {
  834. style: {
  835. fontSize: '16px',
  836. fontWeight: '500',
  837. marginBottom: '20px',
  838. }
  839. }, this.$L('添加列表')),
  840. h('Input', {
  841. props: {
  842. value: this.labelValue,
  843. autofocus: true,
  844. placeholder: this.$L('请输入列表名称')
  845. },
  846. on: {
  847. input: (val) => {
  848. this.labelValue = val;
  849. }
  850. }
  851. })
  852. ])
  853. },
  854. loading: true,
  855. onOk: () => {
  856. if (this.labelValue) {
  857. let data = {
  858. projectid: this.projectid,
  859. title: this.labelValue
  860. };
  861. $A.apiAjax({
  862. url: 'project/label/add',
  863. data: data,
  864. error: () => {
  865. this.$Modal.remove();
  866. alert(this.$L('网络繁忙,请稍后再试!'));
  867. },
  868. success: (res) => {
  869. this.$Modal.remove();
  870. this.projectLabel.push(res.data);
  871. this.projectSortData = this.getProjectSort();
  872. $A.triggerTaskInfoListener('addlabel', Object.assign(data, {labelid: res.data.id}));
  873. setTimeout(() => {
  874. if (res.ret === 1) {
  875. this.$Message.success(res.msg);
  876. } else {
  877. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  878. }
  879. }, 350);
  880. }
  881. });
  882. } else {
  883. this.$Modal.remove();
  884. }
  885. },
  886. });
  887. },
  888. addTaskSuccess(taskDetail, label) {
  889. if (label.taskLists instanceof Array) {
  890. taskDetail.isNewtask = true;
  891. if (taskDetail.insertbottom) {
  892. label.taskLists.push(taskDetail);
  893. } else {
  894. label.taskLists.unshift(taskDetail);
  895. }
  896. this.$nextTick(() => {
  897. this.$set(taskDetail, 'isNewtask', false);
  898. });
  899. } else {
  900. this.refreshLabel(label);
  901. }
  902. },
  903. openProjectDrawer(tab) {
  904. this.projectDrawerTab = tab;
  905. this.projectDrawerShow = true;
  906. },
  907. openProjectSettingDrawer(tab) {
  908. this.projectSettingDrawerTab = tab;
  909. this.projectSettingDrawerShow = true;
  910. },
  911. projectSortUpdate(isLabel) {
  912. let oldSort = this.projectSortData;
  913. let newSort = this.getProjectSort();
  914. if (oldSort == newSort) {
  915. return;
  916. }
  917. this.projectSortData = newSort;
  918. this.projectSortDisabled = true;
  919. this.loadIng++;
  920. $A.apiAjax({
  921. url: 'project/sort',
  922. data: {
  923. projectid: this.projectid,
  924. oldsort: oldSort,
  925. newsort: newSort,
  926. label: isLabel === true ? 1 : 0
  927. },
  928. complete: () => {
  929. this.projectSortDisabled = false;
  930. this.loadIng--;
  931. },
  932. error: () => {
  933. this.getDetail();
  934. alert(this.$L('网络繁忙,请稍后再试!'));
  935. },
  936. success: (res) => {
  937. if (res.ret === 1) {
  938. this.projectLabel.forEach((label) => {
  939. let length = label.taskLists.length;
  940. label.taskLists.forEach((task, index) => {
  941. task.inorder = length - index;
  942. });
  943. });
  944. this.taskNewSort();
  945. //
  946. this.$Message.success(res.msg);
  947. $A.triggerTaskInfoListener(isLabel ? 'labelsort' : 'tasksort', { projectid: this.projectid, nickname: $A.getNickName(), time: Math.round(new Date().getTime()/1000) });
  948. } else {
  949. this.getDetail();
  950. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  951. }
  952. }
  953. });
  954. },
  955. projectMouse(label) {
  956. let hasScroll = false;
  957. let el = this.$refs['box_' + label.id]
  958. if (el && el.length > 0) {
  959. el = el[0].$el;
  960. hasScroll = el.scrollHeight > el.offsetHeight;
  961. }
  962. this.$set(label, 'hasScroll', hasScroll)
  963. },
  964. projectBoxScroll(e, label) {
  965. this.$set(label, 'endScroll', e.scrollE < 50)
  966. },
  967. projectFocus(label) {
  968. let el = this.$refs['add_' + label.id];
  969. if (el && el.length > 0) {
  970. el[0].setFocus();
  971. }
  972. },
  973. subtaskProgress(task) {
  974. const {subtask, complete} = task;
  975. if (subtask.length === 0) {
  976. return complete ? 100 : 0;
  977. }
  978. const completeLists = subtask.filter((item) => { return item.status == 'complete'});
  979. return parseFloat(((completeLists.length / subtask.length) * 100).toFixed(2));
  980. },
  981. openTaskModal(taskDetail) {
  982. this.taskDetail(taskDetail);
  983. },
  984. taskNewSort() {
  985. this.$nextTick(() => {
  986. this.projectLabel.forEach((item) => { item.taskLists = this.taskReturnNewSort(item.taskLists) });
  987. })
  988. },
  989. taskReturnNewSort(lists) {
  990. let tmpLists = orderBy(lists, ['complete', 'inorder'], ['asc', 'desc']);
  991. let array = [];
  992. array.unshift(...tmpLists.filter(({complete}) => complete ));
  993. array.unshift(...tmpLists.filter(({complete}) => !complete ));
  994. return array;
  995. },
  996. isPersonsTask(task) {
  997. return task.persons && !!task.persons.find(({username}) => username == this.userInfo.username);
  998. },
  999. isFollowerTask(task) {
  1000. return task.follower && task.follower.indexOf(this.userInfo.username) !== -1;
  1001. }
  1002. },
  1003. }
  1004. </script>