todo.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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"><i class="ft icon">&#xE706;</i> {{$L('待办日程')}}</span>
  13. <span class="ft hover"><i class="ft icon">&#xE73D;</i> {{$L('已完成的任务')}}</span>
  14. <span class="ft hover"><i class="ft icon">&#xE748;</i> {{$L('我关注的任务')}}</span>
  15. <span class="ft hover"><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. </div>
  57. </template>
  58. <style lang="scss">
  59. .todo-input-enter {
  60. .ivu-input {
  61. border: 0;
  62. background-color: rgba(255, 255, 255, 0.9);
  63. }
  64. }
  65. </style>
  66. <style lang="scss" scoped>
  67. .todo {
  68. .todo-main {
  69. display: flex;
  70. flex-direction: column;
  71. align-items: center;
  72. justify-content: center;
  73. width: 100%;
  74. height: 100%;
  75. min-height: 500px;
  76. padding: 5px;
  77. ul {
  78. flex: 1;
  79. display: flex;
  80. flex-direction: row;
  81. align-items: center;
  82. justify-content: center;
  83. width: 100%;
  84. li {
  85. flex: 1;
  86. height: 100%;
  87. position: relative;
  88. .todo-card {
  89. position: absolute;
  90. top: 10px;
  91. left: 10px;
  92. right: 10px;
  93. bottom: 10px;
  94. display: flex;
  95. flex-direction: column;
  96. .todo-card-head {
  97. display: flex;
  98. align-items: center;
  99. padding: 0 10px;
  100. height: 38px;
  101. border-radius: 4px 4px 0 0;
  102. color: #ffffff;
  103. .ft.icon {
  104. transform: scale(1);
  105. }
  106. .flag {
  107. font-weight: bold;
  108. font-size: 14px;
  109. margin-right: 5px;
  110. min-width: 16px;
  111. }
  112. .todo-card-title {
  113. font-weight: bold;
  114. }
  115. .todo-input-box {
  116. flex: 1;
  117. display: flex;
  118. flex-direction: row;
  119. align-items: center;
  120. justify-content: flex-end;
  121. height: 100%;
  122. cursor: pointer;
  123. &:hover {
  124. .todo-input-placeholder {
  125. opacity: 1;
  126. }
  127. }
  128. &.active {
  129. .todo-input-pbox {
  130. display: none;
  131. }
  132. .todo-input-ibox {
  133. display: flex;
  134. }
  135. }
  136. .todo-input-placeholder {
  137. color: rgba(255, 255, 255, 0.6);
  138. padding-right: 6px;
  139. transition: all 0.2s;
  140. opacity: 0;
  141. }
  142. .todo-input-pbox,
  143. .todo-input-ibox {
  144. flex: 1;
  145. display: flex;
  146. flex-direction: row;
  147. align-items: center;
  148. justify-content: flex-end;
  149. padding-left: 14px;
  150. height: 100%;
  151. }
  152. .todo-input-ibox {
  153. display: none;
  154. }
  155. .todo-input-close {
  156. height: 100%;
  157. display: flex;
  158. align-items: center;
  159. padding-left: 8px;
  160. i {
  161. font-size: 18px;
  162. font-weight: normal;
  163. }
  164. }
  165. }
  166. &.p1 {
  167. background: rgba(248, 14, 21, 0.6);
  168. }
  169. &.p2 {
  170. background: rgba(236, 196, 2, 0.5);
  171. }
  172. &.p3 {
  173. background: rgba(0, 159, 227, 0.7);
  174. }
  175. &.p4 {
  176. background: rgba(121, 170, 28, 0.7);
  177. }
  178. }
  179. .todo-card-content {
  180. flex: 1;
  181. background-color: #f5f6f7;
  182. border-radius: 0 0 4px 4px;
  183. overflow: auto;
  184. transform: translateZ(0);
  185. ul {
  186. display: flex;
  187. flex-direction: column;
  188. li {
  189. display: flex;
  190. flex-direction: row;
  191. align-items: flex-start;
  192. width: 100%;
  193. padding: 8px;
  194. color: #444444;
  195. border-bottom: dotted 1px rgba(153, 153, 153, 0.25);
  196. position: relative;
  197. cursor: pointer;
  198. &.complete {
  199. color: #999999;
  200. .task-title {
  201. text-decoration: line-through;
  202. }
  203. }
  204. &.more {
  205. color: #666;
  206. justify-content: center;
  207. }
  208. .task-check {
  209. font-size: 16px;
  210. padding-right: 6px;
  211. padding-top: 2px;
  212. }
  213. .task-overdue {
  214. color: #ff0000;
  215. padding-right: 2px;
  216. }
  217. .task-title {
  218. flex: 1;
  219. word-break: break-all;
  220. &:hover {
  221. color: #000000;
  222. }
  223. }
  224. }
  225. }
  226. .content-loading {
  227. width: 100%;
  228. height: 22px;
  229. text-align: center;
  230. margin-top: 8px;
  231. margin-bottom: 8px;
  232. }
  233. .content-empty {
  234. margin: 20px auto;
  235. text-align: center;
  236. color: #666;
  237. }
  238. }
  239. }
  240. }
  241. }
  242. }
  243. @media (max-width: 780px) {
  244. .todo-main {
  245. height: auto;
  246. ul {
  247. flex-direction: column;
  248. li {
  249. width: 100%;
  250. .todo-card {
  251. position: static;
  252. top: 0;
  253. right: 0;
  254. left: 0;
  255. bottom: 0;
  256. margin: 10px;
  257. display: flex;
  258. flex-direction: column;
  259. min-height: 320px;
  260. max-height: 520px;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. </style>
  268. <script>
  269. import WHeader from "../components/WHeader";
  270. import WContent from "../components/WContent";
  271. import WLoading from "../components/WLoading";
  272. export default {
  273. components: {WContent, WHeader, WLoading},
  274. data () {
  275. return {
  276. userInfo: {},
  277. taskDatas: {
  278. "1": {lists: [], hasMorePages: false},
  279. "2": {lists: [], hasMorePages: false},
  280. "3": {lists: [], hasMorePages: false},
  281. "4": {lists: [], hasMorePages: false},
  282. },
  283. }
  284. },
  285. mounted() {
  286. this.userInfo = $A.getUserInfo((res) => {
  287. this.userInfo = res;
  288. });
  289. for (let i = 1; i <= 4; i++) {
  290. this.getTask(i.toString());
  291. }
  292. },
  293. computed: {
  294. },
  295. watch: {
  296. },
  297. methods: {
  298. pTitle(p) {
  299. switch (p) {
  300. case "1":
  301. return "重要且紧急";
  302. case "2":
  303. return "重要不紧急";
  304. case "3":
  305. return "紧急不重要";
  306. case "4":
  307. return "不重要不紧急";
  308. }
  309. },
  310. getTask(index, isNext) {
  311. let taskData = this.taskDatas[index];
  312. let idlater = 0;
  313. if (isNext === true) {
  314. if (taskData.hasMorePages !== true) {
  315. return;
  316. }
  317. idlater = taskData.lists[taskData.lists.length - 1].id
  318. }
  319. this.$set(taskData, 'hasMorePages', false);
  320. this.$set(taskData, 'loadIng', $A.runNum(taskData.loadIng) + 1);
  321. $A.aAjax({
  322. url: 'project/task/lists',
  323. data: {
  324. level: index,
  325. idlater: idlater,
  326. page: 1,
  327. pagesize: 10,
  328. },
  329. complete: () => {
  330. this.$set(taskData, 'loadIng', $A.runNum(taskData.loadIng) - 1);
  331. },
  332. success: (res) => {
  333. if (res.ret === 1) {
  334. let inLists;
  335. res.data.lists.forEach((data) => {
  336. inLists = false;
  337. taskData.lists.some((item, i) => {
  338. if (item.id == data.id) {
  339. taskData.lists.splice(i, 1, data);
  340. return inLists = true;
  341. }
  342. });
  343. if (!inLists) {
  344. taskData.lists.push(data);
  345. }
  346. });
  347. this.$set(taskData, 'hasMorePages', res.data.hasMorePages);
  348. } else {
  349. this.$set(taskData, 'lists', []);
  350. this.$set(taskData, 'hasMorePages', false);
  351. }
  352. }
  353. });
  354. },
  355. addTask(index) {
  356. let taskData = this.taskDatas[index];
  357. let title = $A.trim(taskData.title);
  358. if ($A.count(title) == 0) {
  359. return;
  360. }
  361. this.$set(taskData, 'focus', false);
  362. this.$set(taskData, 'title', '');
  363. //
  364. let tempId = $A.randomString(16);
  365. taskData.lists.unshift({
  366. id: tempId,
  367. title: title,
  368. loadIng: true,
  369. });
  370. $A.aAjax({
  371. url: 'project/task/add',
  372. data: {
  373. title: title,
  374. level: index,
  375. },
  376. error: () => {
  377. taskData.lists.some((item, i) => {
  378. if (item.id == tempId) {
  379. taskData.lists.splice(i, 1);
  380. return true;
  381. }
  382. });
  383. alert(this.$L('网络繁忙,请稍后再试!'));
  384. },
  385. success: (res) => {
  386. if (res.ret === 1) {
  387. this.$Message.success(res.msg);
  388. } else {
  389. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  390. }
  391. taskData.lists.some((item, i) => {
  392. if (item.id == tempId) {
  393. if (res.ret === 1) {
  394. taskData.lists.splice(i, 1, res.data);
  395. } else {
  396. taskData.lists.splice(i, 1);
  397. }
  398. return true;
  399. }
  400. });
  401. }
  402. });
  403. }
  404. },
  405. }
  406. </script>