todo.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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" /></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. .subtask-progress {
  288. position: absolute;
  289. top: 0;
  290. left: 0;
  291. width: 100%;
  292. height: 100%;
  293. z-index: -1;
  294. overflow: hidden;
  295. pointer-events: none;
  296. em {
  297. display: block;
  298. height: 100%;
  299. background-color: rgba(3, 150, 242, 0.07);
  300. }
  301. }
  302. }
  303. }
  304. .content-loading {
  305. width: 100%;
  306. height: 22px;
  307. text-align: center;
  308. margin-top: 8px;
  309. margin-bottom: 8px;
  310. }
  311. .content-empty {
  312. margin: 6px auto;
  313. text-align: center;
  314. color: #666;
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. @media (max-width: 768px) {
  322. .todo-main {
  323. height: auto;
  324. .todo-ul {
  325. flex-direction: column;
  326. .todo-li {
  327. width: 100%;
  328. .todo-card {
  329. position: static;
  330. top: 0;
  331. right: 0;
  332. left: 0;
  333. bottom: 0;
  334. margin: 6px;
  335. display: flex;
  336. flex-direction: column;
  337. min-height: 320px;
  338. max-height: 520px;
  339. }
  340. }
  341. }
  342. }
  343. }
  344. }
  345. </style>
  346. <script>
  347. import draggable from 'vuedraggable'
  348. import WContent from "../components/WContent";
  349. import TodoCalendar from "../components/project/todo/calendar";
  350. import TodoComplete from "../components/project/todo/complete";
  351. import TodoAttention from "../components/project/todo/attention";
  352. import Task from "../mixins/task";
  353. import ReportMy from "../components/report/my";
  354. import ReportReceive from "../components/report/receive";
  355. import WDrawer from "../components/iview/WDrawer";
  356. export default {
  357. components: {
  358. WDrawer,
  359. ReportReceive,
  360. ReportMy, draggable, TodoAttention, TodoComplete, TodoCalendar, WContent},
  361. mixins: [
  362. Task
  363. ],
  364. data () {
  365. return {
  366. loadIng: 0,
  367. taskDatas: {
  368. "1": {lists: [], hasMorePages: false},
  369. "2": {lists: [], hasMorePages: false},
  370. "3": {lists: [], hasMorePages: false},
  371. "4": {lists: [], hasMorePages: false},
  372. },
  373. taskSortData: '',
  374. taskSortDisabled: false,
  375. todoDrawerShow: false,
  376. todoDrawerTab: 'calendar',
  377. todoReportDrawerShow: false,
  378. todoReportDrawerTab: 'my',
  379. }
  380. },
  381. mounted() {
  382. if ($A.getToken() === false) {
  383. window.location.replace($A.webUrl());
  384. return;
  385. }
  386. this.refreshTask();
  387. //
  388. $A.setOnTaskInfoListener('pages/todo',(act, detail) => {
  389. if (detail.username != this.usrName) {
  390. for (let level in this.taskDatas) {
  391. this.taskDatas[level].lists.some((task, i) => {
  392. if (task.id == detail.id) {
  393. this.taskDatas[level].lists.splice(i, 1);
  394. this.taskSortData = this.getTaskSort();
  395. return true;
  396. }
  397. });
  398. }
  399. return;
  400. }
  401. //特殊事件(非操作任务的)
  402. switch (act) {
  403. case 'deleteproject': // 删除项目
  404. case 'deletelabel': // 删除分类
  405. this.refreshTask();
  406. return;
  407. case 'addlabel': // 添加分类
  408. case "labelsort": // 调整分类排序
  409. case "tasksort": // 调整任务排序
  410. return;
  411. }
  412. //
  413. for (let level in this.taskDatas) {
  414. this.taskDatas[level].lists.some((task, i) => {
  415. if (task.id == detail.id) {
  416. this.taskDatas[level].lists.splice(i, 1, detail);
  417. return true;
  418. }
  419. });
  420. }
  421. //
  422. let addOrDelete = (isAdd) => {
  423. if (isAdd) {
  424. for (let level in this.taskDatas) {
  425. if (level == detail.level) {
  426. let index = this.taskDatas[level].lists.length;
  427. this.taskDatas[level].lists.some((task, i) => {
  428. if (detail.userorder > task.userorder || (detail.userorder == task.userorder && detail.id > task.id)) {
  429. index = i;
  430. return true;
  431. }
  432. });
  433. this.taskDatas[level].lists.splice(index, 0, detail);
  434. }
  435. }
  436. } else {
  437. for (let level in this.taskDatas) {
  438. this.taskDatas[level].lists.some((task, i) => {
  439. if (task.id == detail.id) {
  440. this.taskDatas[level].lists.splice(i, 1);
  441. return true;
  442. }
  443. });
  444. }
  445. }
  446. this.taskSortData = this.getTaskSort();
  447. };
  448. //
  449. switch (act) {
  450. case "title": // 标题
  451. case "desc": // 描述
  452. case "plannedtime": // 设置计划时间
  453. case "unplannedtime": // 取消计划时间
  454. case "complete": // 标记完成
  455. case "unfinished": // 标记未完成
  456. case "comment": // 评论
  457. // 这些都不用处理
  458. break;
  459. case "level": // 优先级
  460. for (let level in this.taskDatas) {
  461. this.taskDatas[level].lists.some((task, i) => {
  462. if (task.id == detail.id) {
  463. this.taskDatas[level].lists.splice(i, 1);
  464. return true;
  465. }
  466. });
  467. if (level == detail.level) {
  468. let index = this.taskDatas[level].lists.length;
  469. this.taskDatas[level].lists.some((task, i) => {
  470. if (detail.userorder > task.userorder || (detail.userorder == task.userorder && detail.id > task.id)) {
  471. index = i;
  472. return true;
  473. }
  474. });
  475. this.taskDatas[level].lists.splice(index, 0, detail);
  476. }
  477. }
  478. this.taskSortData = this.getTaskSort();
  479. break;
  480. case "create": // 创建任务
  481. case "username": // 负责人
  482. addOrDelete(detail.username == this.usrName);
  483. break;
  484. case "delete": // 删除任务
  485. case "archived": // 归档
  486. addOrDelete(false);
  487. break;
  488. case "unarchived": // 取消归档
  489. addOrDelete(true);
  490. break;
  491. }
  492. }, true);
  493. },
  494. deactivated() {
  495. this.todoDrawerShow = false;
  496. this.todoReportDrawerShow = false;
  497. },
  498. computed: {
  499. },
  500. watch: {
  501. usrName() {
  502. this.usrLogin && this.refreshTask();
  503. }
  504. },
  505. methods: {
  506. pTitle(p) {
  507. switch (p) {
  508. case "1":
  509. return this.$L("重要且紧急");
  510. case "2":
  511. return this.$L("重要不紧急");
  512. case "3":
  513. return this.$L("紧急不重要");
  514. case "4":
  515. return this.$L("不重要不紧急");
  516. }
  517. },
  518. refreshTask() {
  519. this.taskDatas = {
  520. "1": {lists: [], hasMorePages: false},
  521. "2": {lists: [], hasMorePages: false},
  522. "3": {lists: [], hasMorePages: false},
  523. "4": {lists: [], hasMorePages: false},
  524. };
  525. for (let i = 1; i <= 4; i++) {
  526. this.getTaskLists(i.toString());
  527. }
  528. },
  529. getTaskLists(index, isNext, withNextNum = 0) {
  530. let taskData = this.taskDatas[index];
  531. let currentPage = 1;
  532. let pagesize = 20;
  533. let withNextPage = false;
  534. //
  535. if (isNext === true) {
  536. if (taskData.hasMorePages !== true) {
  537. return;
  538. }
  539. currentPage = Math.max(1, $A.runNum(taskData['currentPage']));
  540. let tempLists = this.taskDatas[index].lists;
  541. if (tempLists.length >= currentPage * pagesize) {
  542. currentPage++;
  543. } else {
  544. withNextPage = true;
  545. }
  546. withNextNum = $A.runNum(withNextNum);
  547. }
  548. this.$set(taskData, 'hasMorePages', false);
  549. this.$set(taskData, 'loadIng', $A.runNum(taskData.loadIng) + 1);
  550. this.taskSortDisabled = true;
  551. this.loadIng++;
  552. $A.apiAjax({
  553. url: 'project/task/lists',
  554. data: {
  555. level: index,
  556. sorts: {key:'userorder', order:'desc'},
  557. page: currentPage,
  558. pagesize: pagesize,
  559. },
  560. complete: () => {
  561. this.loadIng--;
  562. this.taskSortDisabled = false;
  563. this.$set(taskData, 'loadIng', $A.runNum(taskData.loadIng) - 1);
  564. },
  565. success: (res) => {
  566. if (res.ret === 1) {
  567. let inLists;
  568. res.data.lists.forEach((data) => {
  569. inLists = false;
  570. taskData.lists.some((item, i) => {
  571. if (item.id == data.id) {
  572. taskData.lists.splice(i, 1, data);
  573. return inLists = true;
  574. }
  575. });
  576. if (!inLists) {
  577. taskData.lists.push(data);
  578. }
  579. });
  580. this.taskSortData = this.getTaskSort();
  581. this.$set(taskData, 'currentPage', res.data.currentPage);
  582. this.$set(taskData, 'hasMorePages', res.data.hasMorePages);
  583. if (res.data.currentPage && withNextPage && withNextNum < 5) {
  584. this.getTaskLists(index, true, withNextNum + 1);
  585. }
  586. } else {
  587. this.$set(taskData, 'lists', []);
  588. this.$set(taskData, 'hasMorePages', false);
  589. }
  590. }
  591. });
  592. },
  593. addTask(index) {
  594. let taskData = this.taskDatas[index];
  595. let title = $A.trim(taskData.title);
  596. if ($A.count(title) == 0) {
  597. return;
  598. }
  599. this.$set(taskData, 'focus', false);
  600. this.$set(taskData, 'title', '');
  601. //
  602. let tempId = $A.randomString(16);
  603. taskData.lists.unshift({
  604. id: tempId,
  605. title: title,
  606. loadIng: true,
  607. });
  608. this.taskSortDisabled = true;
  609. $A.apiAjax({
  610. url: 'project/task/add',
  611. data: {
  612. title: title,
  613. level: index,
  614. },
  615. complete: () => {
  616. this.taskSortDisabled = false;
  617. },
  618. error: () => {
  619. taskData.lists.some((item, i) => {
  620. if (item.id == tempId) {
  621. taskData.lists.splice(i, 1);
  622. return true;
  623. }
  624. });
  625. alert(this.$L('网络繁忙,请稍后再试!'));
  626. },
  627. success: (res) => {
  628. if (res.ret === 1) {
  629. this.$Message.success(res.msg);
  630. } else {
  631. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  632. }
  633. taskData.lists.some((item, i) => {
  634. if (item.id == tempId) {
  635. if (res.ret === 1) {
  636. taskData.lists.splice(i, 1, res.data);
  637. } else {
  638. taskData.lists.splice(i, 1);
  639. }
  640. return true;
  641. }
  642. });
  643. this.taskSortData = this.getTaskSort();
  644. }
  645. });
  646. },
  647. getTaskSort() {
  648. let sortData = "",
  649. taskData = "";
  650. for (let level in this.taskDatas) {
  651. taskData = "";
  652. this.taskDatas[level].lists.forEach((task) => {
  653. if (taskData) taskData += "-";
  654. taskData += task.id;
  655. });
  656. if (sortData) sortData += ";";
  657. sortData += level + ":" + taskData;
  658. }
  659. return sortData;
  660. },
  661. handleTodo(event) {
  662. switch (event) {
  663. case 'calendar':
  664. case 'complete':
  665. case 'attention': {
  666. this.todoDrawerShow = true;
  667. this.todoDrawerTab = event;
  668. break;
  669. }
  670. case 'report': {
  671. this.todoReportDrawerShow = true;
  672. break;
  673. }
  674. }
  675. },
  676. taskSortUpdate() {
  677. let oldSort = this.taskSortData;
  678. let newSort = this.getTaskSort();
  679. if (oldSort == newSort) {
  680. return;
  681. }
  682. this.taskSortData = newSort;
  683. this.taskSortDisabled = true;
  684. $A.apiAjax({
  685. url: 'project/sort/todo',
  686. data: {
  687. oldsort: oldSort,
  688. newsort: newSort,
  689. },
  690. complete: () => {
  691. this.taskSortDisabled = false;
  692. },
  693. error: () => {
  694. this.refreshTask();
  695. alert(this.$L('网络繁忙,请稍后再试!'));
  696. },
  697. success: (res) => {
  698. if (res.ret === 1) {
  699. this.$Message.success(res.msg);
  700. } else {
  701. this.refreshTask();
  702. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  703. }
  704. }
  705. });
  706. },
  707. subtaskProgress(task) {
  708. const {subtask, complete} = task;
  709. if (!subtask || subtask.length === 0) {
  710. return complete ? 100 : 0;
  711. }
  712. const completeLists = subtask.filter((item) => { return item.status == 'complete'});
  713. return parseFloat(((completeLists.length / subtask.length) * 100).toFixed(2));
  714. },
  715. openTaskModal(taskDetail) {
  716. this.taskDetail(taskDetail);
  717. },
  718. },
  719. }
  720. </script>