panel.vue 39 KB

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