panel.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  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" :key="task.id" class="task-item task-draggable">
  68. <div class="task-shadow" :class="[
  69. 'p'+task.level,
  70. task.complete ? 'complete' : '',
  71. task.overdue ? 'overdue' : '',
  72. task.isNewtask === true ? 'newtask' : ''
  73. ]" @click="openTaskModal(task)">
  74. <div v-if="task.subtask.length > 0" class="subtask-progress"><em :style="{width: subtaskProgress(task.subtask) + '%'}"></em></div>
  75. <div class="task-title">{{task.title}}<Icon v-if="task.desc" type="ios-list-box-outline" /></div>
  76. <div class="task-more">
  77. <div v-if="task.overdue" class="task-status">{{$L('已超期')}}</div>
  78. <div v-else-if="task.complete" class="task-status">{{$L('已完成')}}</div>
  79. <div v-else class="task-status">{{$L('未完成')}}</div>
  80. <Tooltip class="task-userimg" :content="task.nickname || task.username" transfer><UserImg :info="task" class="avatar"/></Tooltip>
  81. </div>
  82. </div>
  83. </div>
  84. <div slot="footer">
  85. <project-add-task
  86. :ref="'add_' + label.id"
  87. :placeholder='`${$L("添加任务至")}"${label.title}"`'
  88. :projectid="label.projectid"
  89. :labelid="label.id"
  90. @on-add-success="addTaskSuccess($event, label)"></project-add-task>
  91. </div>
  92. </draggable>
  93. </ScrollerY>
  94. </div>
  95. <div class="label-bottom" @click="projectFocus(label)">
  96. <Icon class="label-bottom-icon" type="ios-add" />
  97. </div>
  98. </div>
  99. <div v-if="loadDetailed" slot="footer" class="label-item label-create" @click="addLabel">
  100. <div class="label-body">
  101. <div class="trigger-box ft hover"><i class="ft icon">&#xE8C8;</i>{{$L('添加一个新列表')}}</div>
  102. </div>
  103. </div>
  104. </draggable>
  105. <project-gantt v-if="projectGanttShow" @on-close="projectGanttShow=false" :projectLabel="projectLabel"></project-gantt>
  106. </w-content>
  107. <WDrawer v-model="projectDrawerShow" maxWidth="1080">
  108. <Tabs v-if="projectDrawerShow" v-model="projectDrawerTab">
  109. <TabPane :label="$L('任务列表')" name="lists">
  110. <project-task-lists :canload="projectDrawerShow && projectDrawerTab == 'lists'" :projectid="projectid" :labelLists="projectSimpleLabel"></project-task-lists>
  111. </TabPane>
  112. <TabPane :label="$L('文件列表')" name="files">
  113. <project-task-files :canload="projectDrawerShow && projectDrawerTab == 'files'" :projectid="projectid"></project-task-files>
  114. </TabPane>
  115. <TabPane :label="$L('项目动态')" name="logs">
  116. <project-task-logs :canload="projectDrawerShow && projectDrawerTab == 'logs'" :projectid="projectid"></project-task-logs>
  117. </TabPane>
  118. </Tabs>
  119. </WDrawer>
  120. <WDrawer v-model="projectSettingDrawerShow" maxWidth="1000">
  121. <Tabs v-if="projectSettingDrawerShow" v-model="projectSettingDrawerTab">
  122. <TabPane :label="$L('项目设置')" name="setting">
  123. <project-setting :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'setting'" :projectid="projectid" @on-change="getDetail"></project-setting>
  124. </TabPane>
  125. <TabPane :label="$L('已归档任务')" name="archived">
  126. <project-archived :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'archived'" :projectid="projectid"></project-archived>
  127. </TabPane>
  128. <TabPane :label="$L('项目统计')" name="statistics">
  129. <project-statistics ref="statistics" :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'statistics'" :projectid="projectid"></project-statistics>
  130. </TabPane>
  131. <TabPane :label="$L('成员管理')" name="member">
  132. <project-users :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'member'" :projectid="projectid"></project-users>
  133. </TabPane>
  134. </Tabs>
  135. </WDrawer>
  136. </div>
  137. </template>
  138. <style lang="scss">
  139. #project-panel-enter-textarea {
  140. background: transparent;
  141. background: none;
  142. outline: none;
  143. border: 0;
  144. resize: none;
  145. padding: 0;
  146. margin: 8px 0;
  147. line-height: 22px;
  148. border-radius: 0;
  149. color: rgba(0, 0, 0, 0.85);
  150. &:focus {
  151. border-color: transparent;
  152. box-shadow: none;
  153. }
  154. }
  155. </style>
  156. <style lang="scss" scoped>
  157. .project-panel {
  158. .label-box {
  159. display: flex;
  160. flex-direction: row;
  161. align-items: flex-start;
  162. justify-content: flex-start;
  163. flex-wrap: nowrap;
  164. overflow-x: auto;
  165. overflow-y: hidden;
  166. -webkit-overflow-scrolling: touch;
  167. width: 100%;
  168. height: 100%;
  169. padding: 15px;
  170. transform: translateZ(0);
  171. .label-item {
  172. flex-grow: 0;
  173. flex-shrink: 0;
  174. flex-basis: auto;
  175. position: relative;
  176. overflow: hidden;
  177. height: 100%;
  178. padding-right: 15px;
  179. &.label-create {
  180. cursor: pointer;
  181. &:hover {
  182. .trigger-box {
  183. transform: translate(0, -50%) scale(1.1);
  184. }
  185. }
  186. }
  187. &.label-scroll {
  188. &:hover {
  189. .label-bottom {
  190. transform: translate(-50%, 0);
  191. }
  192. }
  193. }
  194. .label-body {
  195. width: 300px;
  196. height: 100%;
  197. border-radius: 0.15rem;
  198. background-color: #ebecf0;
  199. overflow: hidden;
  200. position: relative;
  201. display: flex;
  202. flex-direction: column;
  203. .title-box {
  204. padding: 0 12px;
  205. font-weight: bold;
  206. color: #666666;
  207. position: relative;
  208. cursor: move;
  209. display: flex;
  210. align-items: center;
  211. width: 100%;
  212. height: 42px;
  213. .title-loading {
  214. width: 16px;
  215. height: 16px;
  216. margin-right: 6px;
  217. }
  218. h2 {
  219. flex: 1;
  220. font-size: 16px;
  221. overflow: hidden;
  222. text-overflow: ellipsis;
  223. white-space: nowrap;
  224. }
  225. i {
  226. font-weight: 500;
  227. font-size: 18px;
  228. height: 100%;
  229. line-height: 42px;
  230. width: 42px;
  231. text-align: right;
  232. cursor: pointer;
  233. }
  234. }
  235. .task-box {
  236. position: relative;
  237. flex: 1;
  238. width: 100%;
  239. padding: 0 12px 2px;
  240. transform: translateZ(0);
  241. .task-main {
  242. display: flex;
  243. flex-direction: column;
  244. }
  245. .task-item {
  246. width: 100%;
  247. .task-shadow {
  248. margin: 5px 0 4px;
  249. padding: 8px 10px 8px 8px;
  250. background-color: #ffffff;
  251. border-left: 2px solid #BF9F03;
  252. border-right: 0;
  253. color: #091e42;
  254. border-radius: 3px;
  255. cursor: pointer;
  256. box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  257. transition: all 0.3s;
  258. transform: scale(1);
  259. &:hover{
  260. box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.38);
  261. }
  262. &.p1 {
  263. border-left-color: #ff0000;
  264. }
  265. &.p2 {
  266. border-left-color: #BB9F35;
  267. }
  268. &.p3 {
  269. border-left-color: #449EDD;
  270. }
  271. &.p4 {
  272. border-left-color: #84A83B;
  273. }
  274. &.complete {
  275. border-left-color: #c1c1c1;
  276. .task-title {
  277. color: #666666;
  278. text-decoration: line-through;
  279. }
  280. .task-more {
  281. .task-status {
  282. color: #666666;
  283. }
  284. }
  285. }
  286. &.overdue {
  287. .task-title {
  288. font-weight: bold;
  289. }
  290. .task-more {
  291. .task-status {
  292. color: #ff0000;
  293. }
  294. }
  295. }
  296. &.newtask {
  297. transform: scale(1.5);
  298. }
  299. .task-title {
  300. font-size: 12px;
  301. color: #091e42;
  302. word-break: break-all;
  303. .ivu-icon {
  304. font-size: 14px;
  305. color: #afafaf;
  306. vertical-align: top;
  307. padding: 2px 4px;
  308. transform: scale(0.94);
  309. }
  310. }
  311. .task-more {
  312. min-height: 30px;
  313. display: flex;
  314. align-items: flex-end;
  315. .task-status {
  316. color: #19be6b;
  317. font-size: 12px;
  318. flex: 1;
  319. }
  320. .task-userimg {
  321. width: 26px;
  322. height: 26px;
  323. .avatar {
  324. width: 26px;
  325. height: 26px;
  326. font-size: 14px;
  327. line-height: 26px;
  328. border-radius: 13px;
  329. }
  330. }
  331. }
  332. .subtask-progress {
  333. position: absolute;
  334. top: 0;
  335. left: 0;
  336. width: 100%;
  337. height: 100%;
  338. z-index: -1;
  339. border-radius: 0 3px 3px 0;
  340. overflow: hidden;
  341. pointer-events: none;
  342. em {
  343. display: block;
  344. height: 100%;
  345. background-color: rgba(3, 150, 242, 0.07);
  346. }
  347. }
  348. }
  349. }
  350. }
  351. .trigger-box {
  352. text-align: center;
  353. font-size: 16px;
  354. color: #666;
  355. width: 100%;
  356. position: absolute;
  357. top: 50%;
  358. transform: translate(0, -50%) scale(1);
  359. transition: all 0.3s;
  360. }
  361. }
  362. .label-bottom {
  363. position: absolute;
  364. left: 50%;
  365. bottom: 14px;
  366. z-index: 1;
  367. width: 36px;
  368. height: 36px;
  369. border-radius: 50%;
  370. background-color: #2db7f5;
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. transition: transform 0.2s;
  375. transform: translate(-50%, 200%);
  376. cursor: pointer;
  377. .label-bottom-icon {
  378. color: #ffffff;
  379. font-size: 36px;
  380. }
  381. }
  382. }
  383. }
  384. }
  385. </style>
  386. <script>
  387. import draggable from 'vuedraggable'
  388. import WContent from "../../components/WContent";
  389. import ProjectAddTask from "../../components/project/task/add";
  390. import ProjectTaskLists from "../../components/project/task/lists";
  391. import ProjectTaskFiles from "../../components/project/task/files";
  392. import ProjectTaskLogs from "../../components/project/task/logs";
  393. import ProjectArchived from "../../components/project/archived";
  394. import ProjectUsers from "../../components/project/users";
  395. import ProjectStatistics from "../../components/project/statistics";
  396. import WDrawer from "../../components/iview/WDrawer";
  397. import ProjectGantt from "../../components/project/gantt/index";
  398. import ProjectSetting from "../../components/project/setting";
  399. import ScrollerY from "../../../_components/ScrollerY";
  400. export default {
  401. components: {
  402. ScrollerY,
  403. ProjectSetting,
  404. ProjectGantt,
  405. WDrawer,
  406. ProjectStatistics,
  407. ProjectUsers,
  408. ProjectArchived,
  409. ProjectTaskLogs,
  410. ProjectTaskFiles, ProjectTaskLists, ProjectAddTask, draggable, WContent},
  411. data () {
  412. return {
  413. loadIng: 0,
  414. loadDetailed: false,
  415. projectid: 0,
  416. projectDetail: {},
  417. projectLabel: [],
  418. projectSimpleLabel: [],
  419. projectSortData: '',
  420. projectSortDisabled: false,
  421. projectDrawerShow: false,
  422. projectDrawerTab: 'lists',
  423. projectSettingDrawerShow: false,
  424. projectSettingDrawerTab: 'setting',
  425. projectGanttShow: false,
  426. routeName: '',
  427. }
  428. },
  429. mounted() {
  430. this.routeName = this.$route.name;
  431. $A.setOnTaskInfoListener('pages/project-panel',(act, detail) => {
  432. if (detail.projectid != this.projectid) {
  433. return;
  434. }
  435. //
  436. switch (act) {
  437. case 'addlabel': // 添加分类
  438. let tempLists = this.projectLabel.filter((res) => { return res.id == detail.labelid });
  439. if (tempLists.length == 0) {
  440. this.projectLabel.push(Object.assign(detail, {id: detail.labelid}));
  441. this.projectSortData = this.getProjectSort();
  442. }
  443. return;
  444. case 'deletelabel': // 删除分类
  445. this.projectLabel.some((label, index) => {
  446. if (label.id == detail.labelid) {
  447. this.projectLabel.splice(index, 1);
  448. this.projectSortData = this.getProjectSort();
  449. return true;
  450. }
  451. });
  452. return;
  453. case 'deleteproject': // 删除项目
  454. return;
  455. case "labelsort": // 调整分类排序
  456. case "tasksort": // 调整任务排序
  457. if (detail.__modifyUsername != $A.getUserName()) {
  458. if (this.routeName == this.$route.name) {
  459. this.$Modal.confirm({
  460. title: this.$L("更新提示"),
  461. content: this.$L('团队成员(%)调整了%,<br/>更新时间:%。<br/><br/>点击【确定】加载最新数据。', detail.nickname, this.$L(act == 'labelsort' ? '分类排序' : '任务排序'), $A.formatDate("Y-m-d H:i:s", detail.time)),
  462. onOk: () => {
  463. this.getDetail(true);
  464. }
  465. });
  466. } else {
  467. this.getDetail(true);
  468. }
  469. }
  470. return;
  471. }
  472. //
  473. this.projectLabel.forEach((label) => {
  474. label.taskLists.some((task, i) => {
  475. if (task.id == detail.id) {
  476. label.taskLists.splice(i, 1, detail);
  477. return true;
  478. }
  479. });
  480. });
  481. //
  482. switch (act) {
  483. case "delete": // 删除任务
  484. case "archived": // 归档
  485. this.projectLabel.forEach((label) => {
  486. label.taskLists.some((task, i) => {
  487. if (task.id == detail.id) {
  488. label.taskLists.splice(i, 1,);
  489. return true;
  490. }
  491. });
  492. });
  493. this.projectSortData = this.getProjectSort();
  494. break;
  495. case "create": // 创建任务
  496. this.projectLabel.some((label) => {
  497. if (label.id == detail.labelid) {
  498. let tempLists = label.taskLists.filter((res) => { return res.id == detail.id });
  499. if (tempLists.length == 0) {
  500. detail.isNewtask = true;
  501. if (detail.insertbottom) {
  502. label.taskLists.push(detail);
  503. } else {
  504. label.taskLists.unshift(detail);
  505. }
  506. this.$nextTick(() => {
  507. this.$set(detail, 'isNewtask', false);
  508. });
  509. }
  510. return true;
  511. }
  512. });
  513. break;
  514. case "unarchived": // 取消归档
  515. this.projectLabel.forEach((label) => {
  516. if (label.id == detail.labelid) {
  517. let index = label.taskLists.length;
  518. label.taskLists.some((task, i) => {
  519. if (detail.inorder > task.inorder || (detail.inorder == task.inorder && detail.id > task.id)) {
  520. index = i;
  521. return true;
  522. }
  523. });
  524. label.taskLists.splice(index, 0, detail);
  525. }
  526. });
  527. this.projectSortData = this.getProjectSort();
  528. break;
  529. }
  530. }, true);
  531. },
  532. activated() {
  533. this.projectid = this.$route.params.projectid;
  534. if (typeof this.$route.params.other === "object") {
  535. this.$set(this.projectDetail, 'title', $A.getObject(this.$route.params.other, 'title'));
  536. }
  537. if (this.$route.params.statistics === '已完成') {
  538. this.projectSettingDrawerTab = 'statistics';
  539. this.projectSettingDrawerShow = true;
  540. this.$nextTick(() => {
  541. this.$refs.statistics.setTaskType('已完成');
  542. });
  543. }
  544. },
  545. deactivated() {
  546. if ($A.getToken() === false) {
  547. this.projectid = 0;
  548. }
  549. this.projectGanttShow = false;
  550. this.projectDrawerShow = false;
  551. this.projectSettingDrawerShow = false;
  552. },
  553. watch: {
  554. projectid(val) {
  555. if ($A.runNum(val) <= 0) {
  556. return;
  557. }
  558. this.projectDetail = {};
  559. this.projectLabel = [];
  560. this.projectSimpleLabel = [];
  561. this.getDetail();
  562. }
  563. },
  564. methods: {
  565. getDetail(successTip) {
  566. this.loadIng++;
  567. $A.apiAjax({
  568. url: 'project/detail',
  569. data: {
  570. projectid: this.projectid,
  571. },
  572. complete: () => {
  573. this.loadIng--;
  574. this.loadDetailed = true;
  575. },
  576. error: () => {
  577. this.goBack({name:'project'});
  578. alert(this.$L('网络繁忙,请稍后再试!'));
  579. },
  580. success: (res) => {
  581. if (res.ret === 1) {
  582. this.projectDetail = res.data.project;
  583. this.projectLabel = res.data.label;
  584. this.projectSimpleLabel = res.data.simpleLabel;
  585. this.projectSortData = this.getProjectSort();
  586. if (successTip === true) {
  587. this.$Message.success(this.$L('刷新成功!'));
  588. }
  589. } else {
  590. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  591. }
  592. }
  593. });
  594. },
  595. getProjectSort() {
  596. let sortData = "",
  597. taskData = "";
  598. this.projectLabel.forEach((label) => {
  599. taskData = "";
  600. label.taskLists.forEach((task) => {
  601. if (taskData) taskData+= "-";
  602. taskData+= task.id;
  603. });
  604. if (sortData) sortData+= ";";
  605. sortData+= label.id + ":" + taskData;
  606. });
  607. return sortData;
  608. },
  609. handleLabel(event, labelDetail) {
  610. switch (event) {
  611. case 'refresh': {
  612. this.refreshLabel(labelDetail);
  613. break;
  614. }
  615. case 'rename': {
  616. this.renameLabel(labelDetail);
  617. break;
  618. }
  619. case 'delete': {
  620. this.deleteLabel(labelDetail);
  621. break;
  622. }
  623. }
  624. },
  625. refreshLabel(item) {
  626. this.$set(item, 'loadIng', true);
  627. $A.apiAjax({
  628. url: 'project/task/lists',
  629. data: {
  630. projectid: this.projectid,
  631. labelid: item.id,
  632. },
  633. complete: () => {
  634. this.$set(item, 'loadIng', false);
  635. },
  636. error: () => {
  637. window.location.reload();
  638. },
  639. success: (res) => {
  640. if (res.ret === 1) {
  641. this.$set(item, 'taskLists', res.data.lists);
  642. } else {
  643. window.location.reload();
  644. }
  645. }
  646. });
  647. },
  648. renameLabel(item) {
  649. this.renameValue = "";
  650. this.$Modal.confirm({
  651. render: (h) => {
  652. return h('div', [
  653. h('div', {
  654. style: {
  655. fontSize: '16px',
  656. fontWeight: '500',
  657. marginBottom: '20px',
  658. }
  659. }, this.$L('重命名列表')),
  660. h('Input', {
  661. props: {
  662. value: this.renameValue,
  663. autofocus: true,
  664. placeholder: this.$L('请输入新的列表名称')
  665. },
  666. on: {
  667. input: (val) => {
  668. this.renameValue = val;
  669. }
  670. }
  671. })
  672. ])
  673. },
  674. loading: true,
  675. onOk: () => {
  676. if (this.renameValue) {
  677. this.$set(item, 'loadIng', true);
  678. let title = this.renameValue;
  679. $A.apiAjax({
  680. url: 'project/label/rename',
  681. data: {
  682. projectid: this.projectid,
  683. labelid: item.id,
  684. title: title,
  685. },
  686. complete: () => {
  687. this.$set(item, 'loadIng', false);
  688. },
  689. error: () => {
  690. this.$Modal.remove();
  691. alert(this.$L('网络繁忙,请稍后再试!'));
  692. },
  693. success: (res) => {
  694. this.$Modal.remove();
  695. this.$set(item, 'title', title);
  696. setTimeout(() => {
  697. if (res.ret === 1) {
  698. this.$Message.success(res.msg);
  699. } else {
  700. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  701. }
  702. }, 350);
  703. }
  704. });
  705. } else {
  706. this.$Modal.remove();
  707. }
  708. },
  709. });
  710. },
  711. deleteLabel(item) {
  712. let redTip = item.taskLists.length > 0 ? ('<div style="color:red;font-weight:500">' + this.$L('注:将同时删除列表下所有任务') + '</div>') : '';
  713. this.$Modal.confirm({
  714. title: this.$L('删除列表'),
  715. content: '<div>' + this.$L('你确定要删除此列表吗?') + '</div>' + redTip,
  716. loading: true,
  717. onOk: () => {
  718. $A.apiAjax({
  719. url: 'project/label/delete',
  720. data: {
  721. projectid: this.projectid,
  722. labelid: item.id,
  723. },
  724. error: () => {
  725. this.$Modal.remove();
  726. alert(this.$L('网络繁忙,请稍后再试!'));
  727. },
  728. success: (res) => {
  729. this.$Modal.remove();
  730. this.projectLabel.some((label, index) => {
  731. if (label.id == item.id) {
  732. this.projectLabel.splice(index, 1);
  733. this.projectSortData = this.getProjectSort();
  734. return true;
  735. }
  736. });
  737. setTimeout(() => {
  738. if (res.ret === 1) {
  739. this.$Message.success(res.msg);
  740. $A.triggerTaskInfoListener('deletelabel', {labelid: item.id, projectid: item.projectid});
  741. } else {
  742. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  743. }
  744. }, 350);
  745. }
  746. });
  747. }
  748. });
  749. },
  750. addLabel() {
  751. this.labelValue = "";
  752. this.$Modal.confirm({
  753. render: (h) => {
  754. return h('div', [
  755. h('div', {
  756. style: {
  757. fontSize: '16px',
  758. fontWeight: '500',
  759. marginBottom: '20px',
  760. }
  761. }, this.$L('添加列表')),
  762. h('Input', {
  763. props: {
  764. value: this.labelValue,
  765. autofocus: true,
  766. placeholder: this.$L('请输入列表名称')
  767. },
  768. on: {
  769. input: (val) => {
  770. this.labelValue = val;
  771. }
  772. }
  773. })
  774. ])
  775. },
  776. loading: true,
  777. onOk: () => {
  778. if (this.labelValue) {
  779. let data = {
  780. projectid: this.projectid,
  781. title: this.labelValue
  782. };
  783. $A.apiAjax({
  784. url: 'project/label/add',
  785. data: data,
  786. error: () => {
  787. this.$Modal.remove();
  788. alert(this.$L('网络繁忙,请稍后再试!'));
  789. },
  790. success: (res) => {
  791. this.$Modal.remove();
  792. this.projectLabel.push(res.data);
  793. this.projectSortData = this.getProjectSort();
  794. $A.triggerTaskInfoListener('addlabel', Object.assign(data, {labelid: res.data.id}));
  795. setTimeout(() => {
  796. if (res.ret === 1) {
  797. this.$Message.success(res.msg);
  798. } else {
  799. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  800. }
  801. }, 350);
  802. }
  803. });
  804. } else {
  805. this.$Modal.remove();
  806. }
  807. },
  808. });
  809. },
  810. addTaskSuccess(taskDetail, label) {
  811. if (label.taskLists instanceof Array) {
  812. taskDetail.isNewtask = true;
  813. if (taskDetail.insertbottom) {
  814. label.taskLists.push(taskDetail);
  815. } else {
  816. label.taskLists.unshift(taskDetail);
  817. }
  818. this.$nextTick(() => {
  819. this.$set(taskDetail, 'isNewtask', false);
  820. });
  821. } else {
  822. this.refreshLabel(label);
  823. }
  824. },
  825. openProjectDrawer(tab) {
  826. this.projectDrawerTab = tab;
  827. this.projectDrawerShow = true;
  828. },
  829. openProjectSettingDrawer(tab) {
  830. this.projectSettingDrawerTab = tab;
  831. this.projectSettingDrawerShow = true;
  832. },
  833. projectSortUpdate(isLabel) {
  834. let oldSort = this.projectSortData;
  835. let newSort = this.getProjectSort();
  836. if (oldSort == newSort) {
  837. return;
  838. }
  839. this.projectSortData = newSort;
  840. this.projectSortDisabled = true;
  841. this.loadIng++;
  842. $A.apiAjax({
  843. url: 'project/sort',
  844. data: {
  845. projectid: this.projectid,
  846. oldsort: oldSort,
  847. newsort: newSort,
  848. label: isLabel === true ? 1 : 0
  849. },
  850. complete: () => {
  851. this.projectSortDisabled = false;
  852. this.loadIng--;
  853. },
  854. error: () => {
  855. this.getDetail();
  856. alert(this.$L('网络繁忙,请稍后再试!'));
  857. },
  858. success: (res) => {
  859. if (res.ret === 1) {
  860. this.$Message.success(res.msg);
  861. $A.triggerTaskInfoListener(isLabel ? 'labelsort' : 'tasksort', { projectid: this.projectid, nickname: $A.getNickName(), time: Math.round(new Date().getTime()/1000) });
  862. } else {
  863. this.getDetail();
  864. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  865. }
  866. }
  867. });
  868. },
  869. projectMouse(label) {
  870. let hasScroll = false;
  871. let el = this.$refs['box_' + label.id]
  872. if (el && el.length > 0) {
  873. el = el[0].$el;
  874. hasScroll = el.scrollHeight > el.offsetHeight;
  875. }
  876. this.$set(label, 'hasScroll', hasScroll)
  877. },
  878. projectBoxScroll(e, label) {
  879. this.$set(label, 'endScroll', e.scrollE < 50)
  880. },
  881. projectFocus(label) {
  882. let el = this.$refs['add_' + label.id];
  883. if (el && el.length > 0) {
  884. el[0].setFocus();
  885. }
  886. },
  887. subtaskProgress(subtask) {
  888. if (subtask.length === 0) {
  889. return 0;
  890. }
  891. const completeLists = subtask.filter((item) => { return item.status == 'complete'});
  892. return parseFloat(((completeLists.length / subtask.length) * 100).toFixed(2));
  893. },
  894. openTaskModal(taskDetail) {
  895. this.taskDetail(taskDetail);
  896. },
  897. },
  898. }
  899. </script>