panel.vue 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974
  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 v-if="task.subtask.length > 0" class="subtask-progress"><em :style="{width: subtaskProgress(task.subtask) + '%'}"></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 cloneDeep from "lodash/cloneDeep";
  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. }
  565. }, true);
  566. },
  567. activated() {
  568. this.projectid = this.$route.params.projectid;
  569. if (typeof this.$route.params.other === "object") {
  570. this.$set(this.projectDetail, 'title', $A.getObject(this.$route.params.other, 'title'));
  571. }
  572. if (this.$route.params.statistics === '已完成') {
  573. this.projectSettingDrawerTab = 'statistics';
  574. this.projectSettingDrawerShow = true;
  575. this.$nextTick(() => {
  576. this.$refs.statistics.setTaskType('已完成');
  577. });
  578. }
  579. },
  580. deactivated() {
  581. if ($A.getToken() === false) {
  582. this.projectid = 0;
  583. }
  584. this.projectGanttShow = false;
  585. this.projectDrawerShow = false;
  586. this.projectSettingDrawerShow = false;
  587. },
  588. watch: {
  589. projectid(val) {
  590. if ($A.runNum(val) <= 0) {
  591. return;
  592. }
  593. this.projectDetail = {};
  594. this.projectLabel = [];
  595. this.projectSimpleLabel = [];
  596. this.getDetail();
  597. }
  598. },
  599. methods: {
  600. getDetail(successTip) {
  601. this.loadIng++;
  602. $A.apiAjax({
  603. url: 'project/detail',
  604. data: {
  605. projectid: this.projectid,
  606. },
  607. complete: () => {
  608. this.loadIng--;
  609. this.loadDetailed = true;
  610. },
  611. error: () => {
  612. this.goBack({name:'project'});
  613. alert(this.$L('网络繁忙,请稍后再试!'));
  614. },
  615. success: (res) => {
  616. if (res.ret === 1) {
  617. this.projectLabel = res.data.label;
  618. this.projectLabel.forEach((item) => { item.taskLists = this.taskNewSort(item.taskLists) });
  619. this.projectDetail = res.data.project;
  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. this.projectLabel.forEach((item) => { item.taskLists = this.taskNewSort(item.taskLists) });
  898. $A.triggerTaskInfoListener(isLabel ? 'labelsort' : 'tasksort', { projectid: this.projectid, nickname: $A.getNickName(), time: Math.round(new Date().getTime()/1000) });
  899. } else {
  900. this.getDetail();
  901. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  902. }
  903. }
  904. });
  905. },
  906. projectMouse(label) {
  907. let hasScroll = false;
  908. let el = this.$refs['box_' + label.id]
  909. if (el && el.length > 0) {
  910. el = el[0].$el;
  911. hasScroll = el.scrollHeight > el.offsetHeight;
  912. }
  913. this.$set(label, 'hasScroll', hasScroll)
  914. },
  915. projectBoxScroll(e, label) {
  916. this.$set(label, 'endScroll', e.scrollE < 50)
  917. },
  918. projectFocus(label) {
  919. let el = this.$refs['add_' + label.id];
  920. if (el && el.length > 0) {
  921. el[0].setFocus();
  922. }
  923. },
  924. subtaskProgress(subtask) {
  925. if (subtask.length === 0) {
  926. return 0;
  927. }
  928. const completeLists = subtask.filter((item) => { return item.status == 'complete'});
  929. return parseFloat(((completeLists.length / subtask.length) * 100).toFixed(2));
  930. },
  931. openTaskModal(taskDetail) {
  932. this.taskDetail(taskDetail);
  933. },
  934. taskNewSort(lists) {
  935. let array = [];
  936. array.unshift(...cloneDeep(lists.filter(({complete}) => complete )));
  937. array.unshift(...cloneDeep(lists.filter(({complete}) => !complete )));
  938. return array;
  939. }
  940. },
  941. }
  942. </script>