panel.vue 48 KB

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