panel.vue 39 KB

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