panel.vue 44 KB

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