panel.vue 45 KB

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