todo.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. <template>
  2. <div class="w-main todo">
  3. <v-title>{{$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><i class="ft icon">&#xE787;</i> {{$L('我的待办')}}</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="refreshTask">{{$L('刷新')}}</em></div>
  11. </div>
  12. </div>
  13. <div class="w-nav-flex"></div>
  14. <div class="w-nav-right m768-show">
  15. <Dropdown @on-click="handleTodo" trigger="click" transfer>
  16. <Icon type="md-menu" size="18"/>
  17. <DropdownMenu slot="list">
  18. <DropdownItem name="calendar">{{$L('待办日程')}}</DropdownItem>
  19. <DropdownItem name="complete">{{$L('已完成的任务')}}</DropdownItem>
  20. <DropdownItem name="attention">{{$L('我关注的任务')}}</DropdownItem>
  21. <DropdownItem name="report">{{$L('周报/日报')}}</DropdownItem>
  22. </DropdownMenu>
  23. </Dropdown>
  24. </div>
  25. <div class="w-nav-right m768-hide">
  26. <span class="ft hover" @click="handleTodo('calendar')"><i class="ft icon">&#xE706;</i> {{$L('待办日程')}}</span>
  27. <span class="ft hover" @click="handleTodo('complete')"><i class="ft icon">&#xE73D;</i> {{$L('已完成的任务')}}</span>
  28. <span class="ft hover" @click="handleTodo('attention')"><i class="ft icon">&#xE748;</i> {{$L('我关注的任务')}}</span>
  29. <span class="ft hover" @click="handleTodo('report')"><i class="ft icon">&#xE743;</i> {{$L('周报/日报')}}</span>
  30. </div>
  31. </div>
  32. </div>
  33. <w-content>
  34. <div class="todo-main">
  35. <div v-for="subs in [['1', '2'], ['3', '4']]" class="todo-ul">
  36. <div v-for="index in subs" class="todo-li">
  37. <div class="todo-card">
  38. <div class="todo-card-head" :class="['p' + index]">
  39. <i class="ft icon flag">&#xE753;</i>
  40. <div class="todo-card-title">{{pTitle(index)}}</div>
  41. <label class="todo-input-box" :class="{active: !!taskDatas[index].focus}" @click="()=>{$set(taskDatas[index],'focus',true)}">
  42. <div class="todo-input-ibox" @click.stop="">
  43. <Input v-model="taskDatas[index].title" class="todo-input-enter" :placeholder="$L('在这里输入事项,回车即可保存')" @on-enter="addTask(index)"></Input>
  44. <div class="todo-input-close" @click="()=>{$set(taskDatas[index],'focus',false)}"><i class="ft icon">&#xE710;</i></div>
  45. </div>
  46. <div class="todo-input-pbox">
  47. <div class="todo-input-placeholder">{{$L('点击可快速添加需要处理的事项')}}</div>
  48. <div class="todo-input-close"><i class="ft icon">&#xE740;</i></div>
  49. </div>
  50. </label>
  51. </div>
  52. <div class="todo-card-content">
  53. <draggable
  54. v-model="taskDatas[index].lists"
  55. class="content-ul"
  56. group="task"
  57. draggable=".task-draggable"
  58. :animation="150"
  59. :disabled="taskSortDisabled || windowMax768"
  60. @sort="taskSortUpdate"
  61. @remove="taskSortUpdate">
  62. <div v-for="task in taskDatas[index].lists" class="content-li task-draggable" :key="task.id" :class="{complete:task.complete}" @click="openTaskModal(task)">
  63. <div class="subtask-progress"><em :style="{width: subtaskProgress(task) + '%'}"></em></div>
  64. <Icon v-if="task.complete" class="task-check" type="md-checkbox-outline" @click.stop="taskComplete(task, false)"/>
  65. <Icon v-else class="task-check" type="md-square-outline" @click.stop="taskComplete(task, true)"/>
  66. <div v-if="!!task.loadIng" class="task-loading"><w-loading></w-loading></div>
  67. <div v-if="task.overdue" class="task-overdue">[{{$L('超期')}}]</div>
  68. <div class="task-title">{{task.title}}<Icon v-if="task.desc" type="ios-list-box-outline" /><span class="task-title-time">{{task.plantime}}</span></div>
  69. </div>
  70. <div v-if="taskDatas[index].hasMorePages === true" class="content-li more" @click="getTaskLists(index, true)">{{$L('加载更多')}}</div>
  71. </draggable>
  72. <div v-if="taskDatas[index].lists.length === 0 && taskDatas[index].loadIng == 0" class="content-empty">{{$L('恭喜你!已完成了所有待办')}}</div>
  73. <div v-if="taskDatas[index].loadIng > 0" class="content-loading"><w-loading></w-loading></div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </w-content>
  80. <WDrawer v-model="todoDrawerShow" maxWidth="1000">
  81. <Tabs v-if="todoDrawerShow" v-model="todoDrawerTab">
  82. <TabPane :label="$L('待办日程')" name="calendar">
  83. <todo-calendar :canload="todoDrawerShow && todoDrawerTab == 'calendar'"></todo-calendar>
  84. </TabPane>
  85. <TabPane :label="$L('已完成的任务')" name="complete">
  86. <todo-complete :canload="todoDrawerShow && todoDrawerTab == 'complete'"></todo-complete>
  87. </TabPane>
  88. <TabPane :label="$L('我关注的任务')" name="attention">
  89. <todo-attention :canload="todoDrawerShow && todoDrawerTab == 'attention'"></todo-attention>
  90. </TabPane>
  91. </Tabs>
  92. </WDrawer>
  93. <WDrawer v-model="todoReportDrawerShow" maxWidth="1000">
  94. <Tabs v-if="todoReportDrawerShow" v-model="todoReportDrawerTab">
  95. <TabPane :label="$L('我的汇报')" name="my">
  96. <report-my :canload="todoReportDrawerShow && todoReportDrawerTab == 'my'"></report-my>
  97. </TabPane>
  98. <TabPane :label="$L('收到的汇报')" name="receive">
  99. <report-receive :canload="todoReportDrawerShow && todoReportDrawerTab == 'receive'"></report-receive>
  100. </TabPane>
  101. </Tabs>
  102. </WDrawer>
  103. </div>
  104. </template>
  105. <style lang="scss">
  106. .todo-input-enter {
  107. .ivu-input {
  108. border: 0;
  109. background-color: rgba(255, 255, 255, 0.9);
  110. }
  111. }
  112. </style>
  113. <style lang="scss" scoped>
  114. .todo {
  115. .todo-main {
  116. display: flex;
  117. flex-direction: column;
  118. align-items: center;
  119. justify-content: center;
  120. width: 100%;
  121. height: 100%;
  122. min-height: 500px;
  123. padding: 5px;
  124. .todo-ul {
  125. flex: 1;
  126. display: flex;
  127. flex-direction: row;
  128. align-items: center;
  129. justify-content: center;
  130. width: 100%;
  131. .todo-li {
  132. flex: 1;
  133. height: 100%;
  134. position: relative;
  135. .todo-card {
  136. position: absolute;
  137. top: 10px;
  138. left: 10px;
  139. right: 10px;
  140. bottom: 10px;
  141. display: flex;
  142. flex-direction: column;
  143. .todo-card-head {
  144. flex-grow:0;
  145. flex-shrink:0;
  146. display: flex;
  147. align-items: center;
  148. padding: 0 10px;
  149. height: 38px;
  150. border-radius: 4px 4px 0 0;
  151. color: #ffffff;
  152. .ft.icon {
  153. transform: scale(1);
  154. }
  155. .flag {
  156. font-weight: bold;
  157. font-size: 14px;
  158. margin-right: 5px;
  159. min-width: 16px;
  160. }
  161. .todo-card-title {
  162. font-weight: bold;
  163. }
  164. .todo-input-box {
  165. flex: 1;
  166. display: flex;
  167. flex-direction: row;
  168. align-items: center;
  169. justify-content: flex-end;
  170. height: 100%;
  171. cursor: pointer;
  172. &:hover {
  173. .todo-input-placeholder {
  174. opacity: 1;
  175. }
  176. }
  177. &.active {
  178. .todo-input-pbox {
  179. display: none;
  180. }
  181. .todo-input-ibox {
  182. display: flex;
  183. }
  184. }
  185. .todo-input-placeholder {
  186. color: rgba(255, 255, 255, 0.6);
  187. padding-right: 6px;
  188. transition: all 0.2s;
  189. opacity: 0;
  190. }
  191. .todo-input-pbox,
  192. .todo-input-ibox {
  193. flex: 1;
  194. display: flex;
  195. flex-direction: row;
  196. align-items: center;
  197. justify-content: flex-end;
  198. padding-left: 14px;
  199. height: 100%;
  200. }
  201. .todo-input-ibox {
  202. display: none;
  203. }
  204. .todo-input-close {
  205. height: 100%;
  206. display: flex;
  207. align-items: center;
  208. padding-left: 8px;
  209. i {
  210. font-size: 18px;
  211. font-weight: normal;
  212. }
  213. }
  214. }
  215. &.p1 {
  216. background: rgba(248, 14, 21, 0.6);
  217. }
  218. &.p2 {
  219. background: rgba(236, 196, 2, 0.5);
  220. }
  221. &.p3 {
  222. background: rgba(0, 159, 227, 0.7);
  223. }
  224. &.p4 {
  225. background: rgba(121, 170, 28, 0.7);
  226. }
  227. }
  228. .todo-card-content {
  229. flex: 1;
  230. background-color: #f5f6f7;
  231. border-radius: 0 0 4px 4px;
  232. overflow: auto;
  233. transform: translateZ(0);
  234. .content-ul {
  235. display: flex;
  236. flex-direction: column;
  237. min-height: 20px;
  238. .content-li {
  239. display: flex;
  240. flex-direction: row;
  241. align-items: flex-start;
  242. width: 100%;
  243. padding: 8px;
  244. color: #444444;
  245. border-bottom: dotted 1px rgba(153, 153, 153, 0.25);
  246. position: relative;
  247. cursor: pointer;
  248. &.complete {
  249. color: #999999;
  250. .task-title {
  251. text-decoration: line-through;
  252. }
  253. }
  254. &.more {
  255. color: #666;
  256. justify-content: center;
  257. }
  258. .task-check {
  259. font-size: 16px;
  260. padding-right: 6px;
  261. padding-top: 3px;
  262. }
  263. .task-loading {
  264. width: 15px;
  265. height: 15px;
  266. margin-right: 6px;
  267. margin-top: 3px;
  268. }
  269. .task-overdue {
  270. color: #ff0000;
  271. padding-right: 2px;
  272. }
  273. .task-title {
  274. flex: 1;
  275. word-break: break-all;
  276. &:hover {
  277. color: #000000;
  278. }
  279. .ivu-icon {
  280. font-size: 16px;
  281. color: #afafaf;
  282. vertical-align: top;
  283. padding: 2px 6px;
  284. transform: scale(0.98);
  285. }
  286. }
  287. .task-title-time{
  288. display: inline-block;
  289. float: right;
  290. }
  291. .subtask-progress {
  292. position: absolute;
  293. top: 0;
  294. left: 0;
  295. width: 100%;
  296. height: 100%;
  297. z-index: -1;
  298. overflow: hidden;
  299. pointer-events: none;
  300. em {
  301. display: block;
  302. height: 100%;
  303. background-color: rgba(3, 150, 242, 0.07);
  304. }
  305. }
  306. }
  307. }
  308. .content-loading {
  309. width: 100%;
  310. height: 22px;
  311. text-align: center;
  312. margin-top: 8px;
  313. margin-bottom: 8px;
  314. }
  315. .content-empty {
  316. margin: 6px auto;
  317. text-align: center;
  318. color: #666;
  319. }
  320. }
  321. }
  322. }
  323. }
  324. }
  325. @media (max-width: 768px) {
  326. .todo-main {
  327. height: auto;
  328. .todo-ul {
  329. flex-direction: column;
  330. .todo-li {
  331. width: 100%;
  332. .todo-card {
  333. position: static;
  334. top: 0;
  335. right: 0;
  336. left: 0;
  337. bottom: 0;
  338. margin: 6px;
  339. display: flex;
  340. flex-direction: column;
  341. min-height: 320px;
  342. max-height: 520px;
  343. }
  344. }
  345. }
  346. }
  347. }
  348. }
  349. </style>
  350. <script>
  351. import draggable from 'vuedraggable'
  352. import WContent from "../components/WContent";
  353. import TodoCalendar from "../components/project/todo/calendar";
  354. import TodoComplete from "../components/project/todo/complete";
  355. import TodoAttention from "../components/project/todo/attention";
  356. import Task from "../mixins/task";
  357. import ReportMy from "../components/report/my";
  358. import ReportReceive from "../components/report/receive";
  359. import WDrawer from "../components/iview/WDrawer";
  360. export default {
  361. components: {
  362. WDrawer,
  363. ReportReceive,
  364. ReportMy, draggable, TodoAttention, TodoComplete, TodoCalendar, WContent},
  365. mixins: [
  366. Task
  367. ],
  368. data () {
  369. return {
  370. loadIng: 0,
  371. taskDatas: {
  372. "1": {lists: [], hasMorePages: false},
  373. "2": {lists: [], hasMorePages: false},
  374. "3": {lists: [], hasMorePages: false},
  375. "4": {lists: [], hasMorePages: false},
  376. },
  377. taskSortData: '',
  378. taskSortDisabled: false,
  379. todoDrawerShow: false,
  380. todoDrawerTab: 'calendar',
  381. todoReportDrawerShow: false,
  382. todoReportDrawerTab: 'my',
  383. }
  384. },
  385. mounted() {
  386. if ($A.getToken() === false) {
  387. window.location.replace($A.webUrl());
  388. return;
  389. }
  390. this.refreshTask();
  391. //
  392. $A.setOnTaskInfoListener('pages/todo',(act, detail) => {
  393. if (detail.username != this.usrName) {
  394. for (let level in this.taskDatas) {
  395. this.taskDatas[level].lists.some((task, i) => {
  396. if (task.id == detail.id) {
  397. this.taskDatas[level].lists.splice(i, 1);
  398. this.taskSortData = this.getTaskSort();
  399. return true;
  400. }
  401. });
  402. }
  403. return;
  404. }
  405. //特殊事件(非操作任务的)
  406. switch (act) {
  407. case 'deleteproject': // 删除项目
  408. case 'deletelabel': // 删除分类
  409. this.refreshTask();
  410. return;
  411. case 'addlabel': // 添加分类
  412. case "labelsort": // 调整分类排序
  413. case "tasksort": // 调整任务排序
  414. return;
  415. }
  416. //
  417. for (let level in this.taskDatas) {
  418. this.taskDatas[level].lists.some((task, i) => {
  419. if (task.id == detail.id) {
  420. this.taskDatas[level].lists.splice(i, 1, detail);
  421. return true;
  422. }
  423. });
  424. }
  425. //
  426. let addOrDelete = (isAdd) => {
  427. if (isAdd) {
  428. for (let level in this.taskDatas) {
  429. if (level == detail.level) {
  430. let index = this.taskDatas[level].lists.length;
  431. this.taskDatas[level].lists.some((task, i) => {
  432. if (detail.userorder > task.userorder || (detail.userorder == task.userorder && detail.id > task.id)) {
  433. index = i;
  434. return true;
  435. }
  436. });
  437. this.taskDatas[level].lists.splice(index, 0, detail);
  438. }
  439. }
  440. } else {
  441. for (let level in this.taskDatas) {
  442. this.taskDatas[level].lists.some((task, i) => {
  443. if (task.id == detail.id) {
  444. this.taskDatas[level].lists.splice(i, 1);
  445. return true;
  446. }
  447. });
  448. }
  449. }
  450. this.taskSortData = this.getTaskSort();
  451. };
  452. //
  453. switch (act) {
  454. case "title": // 标题
  455. case "desc": // 描述
  456. case "plannedtime": // 设置计划时间
  457. case "unplannedtime": // 取消计划时间
  458. case "complete": // 标记完成
  459. case "unfinished": // 标记未完成
  460. case "comment": // 评论
  461. // 这些都不用处理
  462. break;
  463. case "level": // 优先级
  464. for (let level in this.taskDatas) {
  465. this.taskDatas[level].lists.some((task, i) => {
  466. if (task.id == detail.id) {
  467. this.taskDatas[level].lists.splice(i, 1);
  468. return true;
  469. }
  470. });
  471. if (level == detail.level) {
  472. let index = this.taskDatas[level].lists.length;
  473. this.taskDatas[level].lists.some((task, i) => {
  474. if (detail.userorder > task.userorder || (detail.userorder == task.userorder && detail.id > task.id)) {
  475. index = i;
  476. return true;
  477. }
  478. });
  479. this.taskDatas[level].lists.splice(index, 0, detail);
  480. }
  481. }
  482. this.taskSortData = this.getTaskSort();
  483. break;
  484. case "create": // 创建任务
  485. case "username": // 负责人
  486. addOrDelete(detail.username == this.usrName);
  487. break;
  488. case "delete": // 删除任务
  489. case "archived": // 归档
  490. addOrDelete(false);
  491. break;
  492. case "unarchived": // 取消归档
  493. addOrDelete(true);
  494. break;
  495. }
  496. }, true);
  497. },
  498. deactivated() {
  499. this.todoDrawerShow = false;
  500. this.todoReportDrawerShow = false;
  501. },
  502. computed: {
  503. },
  504. watch: {
  505. usrName() {
  506. this.usrLogin && this.refreshTask();
  507. }
  508. },
  509. methods: {
  510. pTitle(p) {
  511. switch (p) {
  512. case "1":
  513. return this.$L("重要且紧急");
  514. case "2":
  515. return this.$L("重要不紧急");
  516. case "3":
  517. return this.$L("紧急不重要");
  518. case "4":
  519. return this.$L("不重要不紧急");
  520. }
  521. },
  522. refreshTask() {
  523. this.taskDatas = {
  524. "1": {lists: [], hasMorePages: false},
  525. "2": {lists: [], hasMorePages: false},
  526. "3": {lists: [], hasMorePages: false},
  527. "4": {lists: [], hasMorePages: false},
  528. };
  529. for (let i = 1; i <= 4; i++) {
  530. this.getTaskLists(i.toString());
  531. }
  532. },
  533. getTaskLists(index, isNext, withNextNum = 0) {
  534. let taskData = this.taskDatas[index];
  535. let currentPage = 1;
  536. let pagesize = 20;
  537. let withNextPage = false;
  538. //
  539. if (isNext === true) {
  540. if (taskData.hasMorePages !== true) {
  541. return;
  542. }
  543. currentPage = Math.max(1, $A.runNum(taskData['currentPage']));
  544. let tempLists = this.taskDatas[index].lists;
  545. if (tempLists.length >= currentPage * pagesize) {
  546. currentPage++;
  547. } else {
  548. withNextPage = true;
  549. }
  550. withNextNum = $A.runNum(withNextNum);
  551. }
  552. this.$set(taskData, 'hasMorePages', false);
  553. this.$set(taskData, 'loadIng', $A.runNum(taskData.loadIng) + 1);
  554. this.taskSortDisabled = true;
  555. this.loadIng++;
  556. $A.apiAjax({
  557. url: 'project/task/lists',
  558. data: {
  559. level: index,
  560. sorts: {key:'userorder', order:'desc'},
  561. page: currentPage,
  562. pagesize: pagesize,
  563. },
  564. complete: () => {
  565. this.loadIng--;
  566. this.taskSortDisabled = false;
  567. this.$set(taskData, 'loadIng', $A.runNum(taskData.loadIng) - 1);
  568. },
  569. success: (res) => {
  570. if (res.ret === 1) {
  571. let inLists;
  572. res.data.lists.forEach((data) => {
  573. inLists = false;
  574. taskData.lists.some((item, i) => {
  575. if (item.id == data.id) {
  576. taskData.lists.splice(i, 1, data);
  577. return inLists = true;
  578. }
  579. });
  580. if (!inLists) {
  581. taskData.lists.push(data);
  582. }
  583. });
  584. this.taskSortData = this.getTaskSort();
  585. this.$set(taskData, 'currentPage', res.data.currentPage);
  586. this.$set(taskData, 'hasMorePages', res.data.hasMorePages);
  587. if (res.data.currentPage && withNextPage && withNextNum < 5) {
  588. this.getTaskLists(index, true, withNextNum + 1);
  589. }
  590. } else {
  591. this.$set(taskData, 'lists', []);
  592. this.$set(taskData, 'hasMorePages', false);
  593. }
  594. }
  595. });
  596. },
  597. addTask(index) {
  598. let taskData = this.taskDatas[index];
  599. let title = $A.trim(taskData.title);
  600. if ($A.count(title) == 0) {
  601. return;
  602. }
  603. this.$set(taskData, 'focus', false);
  604. this.$set(taskData, 'title', '');
  605. //
  606. let tempId = $A.randomString(16);
  607. taskData.lists.unshift({
  608. id: tempId,
  609. title: title,
  610. loadIng: true,
  611. });
  612. this.taskSortDisabled = true;
  613. $A.apiAjax({
  614. url: 'project/task/add',
  615. data: {
  616. title: title,
  617. level: index,
  618. },
  619. complete: () => {
  620. this.taskSortDisabled = false;
  621. },
  622. error: () => {
  623. taskData.lists.some((item, i) => {
  624. if (item.id == tempId) {
  625. taskData.lists.splice(i, 1);
  626. return true;
  627. }
  628. });
  629. alert(this.$L('网络繁忙,请稍后再试!'));
  630. },
  631. success: (res) => {
  632. if (res.ret === 1) {
  633. this.$Message.success(res.msg);
  634. } else {
  635. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  636. }
  637. taskData.lists.some((item, i) => {
  638. if (item.id == tempId) {
  639. if (res.ret === 1) {
  640. taskData.lists.splice(i, 1, res.data);
  641. } else {
  642. taskData.lists.splice(i, 1);
  643. }
  644. return true;
  645. }
  646. });
  647. this.taskSortData = this.getTaskSort();
  648. }
  649. });
  650. },
  651. getTaskSort() {
  652. let sortData = "",
  653. taskData = "";
  654. for (let level in this.taskDatas) {
  655. taskData = "";
  656. this.taskDatas[level].lists.forEach((task) => {
  657. if (taskData) taskData += "-";
  658. taskData += task.id;
  659. });
  660. if (sortData) sortData += ";";
  661. sortData += level + ":" + taskData;
  662. }
  663. return sortData;
  664. },
  665. handleTodo(event) {
  666. switch (event) {
  667. case 'calendar':
  668. case 'complete':
  669. case 'attention': {
  670. this.todoDrawerShow = true;
  671. this.todoDrawerTab = event;
  672. break;
  673. }
  674. case 'report': {
  675. this.todoReportDrawerShow = true;
  676. break;
  677. }
  678. }
  679. },
  680. taskSortUpdate() {
  681. let oldSort = this.taskSortData;
  682. let newSort = this.getTaskSort();
  683. if (oldSort == newSort) {
  684. return;
  685. }
  686. this.taskSortData = newSort;
  687. this.taskSortDisabled = true;
  688. $A.apiAjax({
  689. url: 'project/sort/todo',
  690. data: {
  691. oldsort: oldSort,
  692. newsort: newSort,
  693. },
  694. complete: () => {
  695. this.taskSortDisabled = false;
  696. },
  697. error: () => {
  698. this.refreshTask();
  699. alert(this.$L('网络繁忙,请稍后再试!'));
  700. },
  701. success: (res) => {
  702. if (res.ret === 1) {
  703. this.$Message.success(res.msg);
  704. } else {
  705. this.refreshTask();
  706. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  707. }
  708. }
  709. });
  710. },
  711. subtaskProgress(task) {
  712. const {subtask, complete} = task;
  713. if (!subtask || subtask.length === 0) {
  714. return complete ? 100 : 0;
  715. }
  716. const completeLists = subtask.filter((item) => { return item.status == 'complete'});
  717. return parseFloat(((completeLists.length / subtask.length) * 100).toFixed(2));
  718. },
  719. openTaskModal(taskDetail) {
  720. this.taskDetail(taskDetail);
  721. },
  722. },
  723. }
  724. </script>