panel.vue 49 KB

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