todo.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <div class="w-main todo">
  3. <v-title>{{$L('待办')}}-{{$L('轻量级的团队在线协作')}}</v-title>
  4. <w-header value="todo"></w-header>
  5. <div class="w-nav">
  6. <div class="nav-row">
  7. <div class="w-nav-left">
  8. <i class="ft icon">&#xE787;</i> {{$L('我的待办')}}
  9. </div>
  10. <div class="w-nav-flex"></div>
  11. <div class="w-nav-right">
  12. <span class="ft hover" @click="handleTodo('calendar')"><i class="ft icon">&#xE706;</i> {{$L('待办日程')}}</span>
  13. <span class="ft hover" @click="handleTodo('complete')"><i class="ft icon">&#xE73D;</i> {{$L('已完成的任务')}}</span>
  14. <span class="ft hover" @click="handleTodo('attention')"><i class="ft icon">&#xE748;</i> {{$L('我关注的任务')}}</span>
  15. <span class="ft hover" @click="handleTodo('report')"><i class="ft icon">&#xE743;</i> {{$L('周报/日报')}}</span>
  16. </div>
  17. </div>
  18. </div>
  19. <w-content>
  20. <div class="todo-main">
  21. <ul v-for="subs in [['1', '2'], ['3', '4']]">
  22. <li v-for="index in subs">
  23. <div class="todo-card">
  24. <div class="todo-card-head" :class="['p' + index]">
  25. <i class="ft icon flag">&#xE753;</i>
  26. <div class="todo-card-title">{{$L(pTitle(index))}}</div>
  27. <label class="todo-input-box" :class="{active: !!taskDatas[index].focus}" @click="()=>{$set(taskDatas[index],'focus',true)}">
  28. <div class="todo-input-ibox" @click.stop="">
  29. <Input v-model="taskDatas[index].title" class="todo-input-enter" :placeholder="$L('在这里输入事项,回车即可保存')" @on-enter="addTask(index)"></Input>
  30. <div class="todo-input-close" @click="()=>{$set(taskDatas[index],'focus',false)}"><i class="ft icon">&#xE710;</i></div>
  31. </div>
  32. <div class="todo-input-pbox">
  33. <div class="todo-input-placeholder">{{$L('点击可快速添加需要处理的事项')}}</div>
  34. <div class="todo-input-close"><i class="ft icon">&#xE740;</i></div>
  35. </div>
  36. </label>
  37. </div>
  38. <div class="todo-card-content">
  39. <ul v-if="taskDatas[index].lists.length > 0">
  40. <li v-for="task in taskDatas[index].lists" :key="task.id" :class="{complete:task.complete}">
  41. <Icon v-if="task.complete" class="task-check" type="md-checkbox-outline" />
  42. <Icon v-else class="task-check" type="md-square-outline" />
  43. <div v-if="task.overdue" class="task-overdue">[超期]</div>
  44. <div class="task-title">{{task.title}}</div>
  45. </li>
  46. <li v-if="taskDatas[index].hasMorePages === true" class="more" @click="getTask(index, true)">加载更多</li>
  47. </ul>
  48. <div v-else-if="taskDatas[index].loadIng == 0" class="content-empty">{{$L('恭喜你!已完成了所有待办')}}</div>
  49. <div v-if="taskDatas[index].loadIng > 0" class="content-loading"><w-loading></w-loading></div>
  50. </div>
  51. </div>
  52. </li>
  53. </ul>
  54. </div>
  55. </w-content>
  56. <Drawer v-model="todoDrawerShow" width="75%">
  57. <Tabs v-if="todoDrawerShow" v-model="todoDrawerTab">
  58. <TabPane :label="$L('待办日程')" name="calendar">
  59. <todo-calendar :canload="todoDrawerShow && todoDrawerTab == 'calendar'"></todo-calendar>
  60. </TabPane>
  61. <TabPane :label="$L('已完成的任务')" name="complete">
  62. <todo-complete :canload="todoDrawerShow && todoDrawerTab == 'complete'"></todo-complete>
  63. </TabPane>
  64. <TabPane :label="$L('我关注的任务')" name="attention">
  65. <todo-attention :canload="todoDrawerShow && todoDrawerTab == 'attention'"></todo-attention>
  66. </TabPane>
  67. </Tabs>
  68. </Drawer>
  69. </div>
  70. </template>
  71. <style lang="scss">
  72. .todo-input-enter {
  73. .ivu-input {
  74. border: 0;
  75. background-color: rgba(255, 255, 255, 0.9);
  76. }
  77. }
  78. </style>
  79. <style lang="scss" scoped>
  80. .todo {
  81. .todo-main {
  82. display: flex;
  83. flex-direction: column;
  84. align-items: center;
  85. justify-content: center;
  86. width: 100%;
  87. height: 100%;
  88. min-height: 500px;
  89. padding: 5px;
  90. ul {
  91. flex: 1;
  92. display: flex;
  93. flex-direction: row;
  94. align-items: center;
  95. justify-content: center;
  96. width: 100%;
  97. li {
  98. flex: 1;
  99. height: 100%;
  100. position: relative;
  101. .todo-card {
  102. position: absolute;
  103. top: 10px;
  104. left: 10px;
  105. right: 10px;
  106. bottom: 10px;
  107. display: flex;
  108. flex-direction: column;
  109. .todo-card-head {
  110. display: flex;
  111. align-items: center;
  112. padding: 0 10px;
  113. height: 38px;
  114. border-radius: 4px 4px 0 0;
  115. color: #ffffff;
  116. .ft.icon {
  117. transform: scale(1);
  118. }
  119. .flag {
  120. font-weight: bold;
  121. font-size: 14px;
  122. margin-right: 5px;
  123. min-width: 16px;
  124. }
  125. .todo-card-title {
  126. font-weight: bold;
  127. }
  128. .todo-input-box {
  129. flex: 1;
  130. display: flex;
  131. flex-direction: row;
  132. align-items: center;
  133. justify-content: flex-end;
  134. height: 100%;
  135. cursor: pointer;
  136. &:hover {
  137. .todo-input-placeholder {
  138. opacity: 1;
  139. }
  140. }
  141. &.active {
  142. .todo-input-pbox {
  143. display: none;
  144. }
  145. .todo-input-ibox {
  146. display: flex;
  147. }
  148. }
  149. .todo-input-placeholder {
  150. color: rgba(255, 255, 255, 0.6);
  151. padding-right: 6px;
  152. transition: all 0.2s;
  153. opacity: 0;
  154. }
  155. .todo-input-pbox,
  156. .todo-input-ibox {
  157. flex: 1;
  158. display: flex;
  159. flex-direction: row;
  160. align-items: center;
  161. justify-content: flex-end;
  162. padding-left: 14px;
  163. height: 100%;
  164. }
  165. .todo-input-ibox {
  166. display: none;
  167. }
  168. .todo-input-close {
  169. height: 100%;
  170. display: flex;
  171. align-items: center;
  172. padding-left: 8px;
  173. i {
  174. font-size: 18px;
  175. font-weight: normal;
  176. }
  177. }
  178. }
  179. &.p1 {
  180. background: rgba(248, 14, 21, 0.6);
  181. }
  182. &.p2 {
  183. background: rgba(236, 196, 2, 0.5);
  184. }
  185. &.p3 {
  186. background: rgba(0, 159, 227, 0.7);
  187. }
  188. &.p4 {
  189. background: rgba(121, 170, 28, 0.7);
  190. }
  191. }
  192. .todo-card-content {
  193. flex: 1;
  194. background-color: #f5f6f7;
  195. border-radius: 0 0 4px 4px;
  196. overflow: auto;
  197. transform: translateZ(0);
  198. ul {
  199. display: flex;
  200. flex-direction: column;
  201. li {
  202. display: flex;
  203. flex-direction: row;
  204. align-items: flex-start;
  205. width: 100%;
  206. padding: 8px;
  207. color: #444444;
  208. border-bottom: dotted 1px rgba(153, 153, 153, 0.25);
  209. position: relative;
  210. cursor: pointer;
  211. &.complete {
  212. color: #999999;
  213. .task-title {
  214. text-decoration: line-through;
  215. }
  216. }
  217. &.more {
  218. color: #666;
  219. justify-content: center;
  220. }
  221. .task-check {
  222. font-size: 16px;
  223. padding-right: 6px;
  224. padding-top: 2px;
  225. }
  226. .task-overdue {
  227. color: #ff0000;
  228. padding-right: 2px;
  229. }
  230. .task-title {
  231. flex: 1;
  232. word-break: break-all;
  233. &:hover {
  234. color: #000000;
  235. }
  236. }
  237. }
  238. }
  239. .content-loading {
  240. width: 100%;
  241. height: 22px;
  242. text-align: center;
  243. margin-top: 8px;
  244. margin-bottom: 8px;
  245. }
  246. .content-empty {
  247. margin: 20px auto;
  248. text-align: center;
  249. color: #666;
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. @media (max-width: 780px) {
  257. .todo-main {
  258. height: auto;
  259. ul {
  260. flex-direction: column;
  261. li {
  262. width: 100%;
  263. .todo-card {
  264. position: static;
  265. top: 0;
  266. right: 0;
  267. left: 0;
  268. bottom: 0;
  269. margin: 10px;
  270. display: flex;
  271. flex-direction: column;
  272. min-height: 320px;
  273. max-height: 520px;
  274. }
  275. }
  276. }
  277. }
  278. }
  279. }
  280. </style>
  281. <script>
  282. import WHeader from "../components/WHeader";
  283. import WContent from "../components/WContent";
  284. import WLoading from "../components/WLoading";
  285. import TodoCalendar from "../components/project/todo/calendar";
  286. import TodoComplete from "../components/project/todo/complete";
  287. import TodoAttention from "../components/project/todo/attention";
  288. export default {
  289. components: {TodoAttention, TodoComplete, TodoCalendar, WContent, WHeader, WLoading},
  290. data () {
  291. return {
  292. userInfo: {},
  293. taskDatas: {
  294. "1": {lists: [], hasMorePages: false},
  295. "2": {lists: [], hasMorePages: false},
  296. "3": {lists: [], hasMorePages: false},
  297. "4": {lists: [], hasMorePages: false},
  298. },
  299. todoDrawerShow: false,
  300. todoDrawerTab: 'calendar',
  301. }
  302. },
  303. mounted() {
  304. this.userInfo = $A.getUserInfo((res) => {
  305. this.userInfo = res;
  306. });
  307. for (let i = 1; i <= 4; i++) {
  308. this.getTask(i.toString());
  309. }
  310. },
  311. computed: {
  312. },
  313. watch: {
  314. },
  315. methods: {
  316. pTitle(p) {
  317. switch (p) {
  318. case "1":
  319. return "重要且紧急";
  320. case "2":
  321. return "重要不紧急";
  322. case "3":
  323. return "紧急不重要";
  324. case "4":
  325. return "不重要不紧急";
  326. }
  327. },
  328. getTask(index, isNext) {
  329. let taskData = this.taskDatas[index];
  330. let idlater = 0;
  331. if (isNext === true) {
  332. if (taskData.hasMorePages !== true) {
  333. return;
  334. }
  335. idlater = taskData.lists[taskData.lists.length - 1].id
  336. }
  337. this.$set(taskData, 'hasMorePages', false);
  338. this.$set(taskData, 'loadIng', $A.runNum(taskData.loadIng) + 1);
  339. $A.aAjax({
  340. url: 'project/task/lists',
  341. data: {
  342. level: index,
  343. idlater: idlater,
  344. page: 1,
  345. pagesize: 10,
  346. },
  347. complete: () => {
  348. this.$set(taskData, 'loadIng', $A.runNum(taskData.loadIng) - 1);
  349. },
  350. success: (res) => {
  351. if (res.ret === 1) {
  352. let inLists;
  353. res.data.lists.forEach((data) => {
  354. inLists = false;
  355. taskData.lists.some((item, i) => {
  356. if (item.id == data.id) {
  357. taskData.lists.splice(i, 1, data);
  358. return inLists = true;
  359. }
  360. });
  361. if (!inLists) {
  362. taskData.lists.push(data);
  363. }
  364. });
  365. this.$set(taskData, 'hasMorePages', res.data.hasMorePages);
  366. } else {
  367. this.$set(taskData, 'lists', []);
  368. this.$set(taskData, 'hasMorePages', false);
  369. }
  370. }
  371. });
  372. },
  373. addTask(index) {
  374. let taskData = this.taskDatas[index];
  375. let title = $A.trim(taskData.title);
  376. if ($A.count(title) == 0) {
  377. return;
  378. }
  379. this.$set(taskData, 'focus', false);
  380. this.$set(taskData, 'title', '');
  381. //
  382. let tempId = $A.randomString(16);
  383. taskData.lists.unshift({
  384. id: tempId,
  385. title: title,
  386. loadIng: true,
  387. });
  388. $A.aAjax({
  389. url: 'project/task/add',
  390. data: {
  391. title: title,
  392. level: index,
  393. },
  394. error: () => {
  395. taskData.lists.some((item, i) => {
  396. if (item.id == tempId) {
  397. taskData.lists.splice(i, 1);
  398. return true;
  399. }
  400. });
  401. alert(this.$L('网络繁忙,请稍后再试!'));
  402. },
  403. success: (res) => {
  404. if (res.ret === 1) {
  405. this.$Message.success(res.msg);
  406. } else {
  407. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  408. }
  409. taskData.lists.some((item, i) => {
  410. if (item.id == tempId) {
  411. if (res.ret === 1) {
  412. taskData.lists.splice(i, 1, res.data);
  413. } else {
  414. taskData.lists.splice(i, 1);
  415. }
  416. return true;
  417. }
  418. });
  419. }
  420. });
  421. },
  422. handleTodo(event) {
  423. switch (event) {
  424. case 'calendar':
  425. case 'complete':
  426. case 'attention': {
  427. this.todoDrawerShow = true;
  428. this.todoDrawerTab = event;
  429. break;
  430. }
  431. }
  432. }
  433. },
  434. }
  435. </script>