panel.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  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. label.taskLists.unshift(detail);
  449. this.$nextTick(() => {
  450. this.$set(detail, 'isNewtask', false);
  451. });
  452. }
  453. return true;
  454. }
  455. });
  456. break;
  457. case "unarchived": // 取消归档
  458. this.projectLabel.forEach((label) => {
  459. if (label.id == detail.labelid) {
  460. let index = label.taskLists.length;
  461. label.taskLists.some((task, i) => {
  462. if (detail.inorder > task.inorder || (detail.inorder == task.inorder && detail.id > task.id)) {
  463. index = i;
  464. return true;
  465. }
  466. });
  467. label.taskLists.splice(index, 0, detail);
  468. }
  469. });
  470. this.projectSortData = this.getProjectSort();
  471. break;
  472. }
  473. }, true);
  474. },
  475. activated() {
  476. this.projectid = this.$route.params.projectid;
  477. if (typeof this.$route.params.other === "object") {
  478. this.$set(this.projectDetail, 'title', $A.getObject(this.$route.params.other, 'title'));
  479. }
  480. if (this.$route.params.statistics === '已完成') {
  481. this.projectSettingDrawerTab = 'statistics';
  482. this.projectSettingDrawerShow = true;
  483. this.$nextTick(() => {
  484. this.$refs.statistics.setTaskType('已完成');
  485. });
  486. }
  487. },
  488. deactivated() {
  489. if ($A.getToken() === false) {
  490. this.projectid = 0;
  491. }
  492. this.projectGanttShow = false;
  493. this.projectDrawerShow = false;
  494. this.projectSettingDrawerShow = false;
  495. },
  496. watch: {
  497. projectid(val) {
  498. if ($A.runNum(val) <= 0) {
  499. return;
  500. }
  501. this.projectDetail = {};
  502. this.projectLabel = [];
  503. this.projectSimpleLabel = [];
  504. this.getDetail();
  505. }
  506. },
  507. methods: {
  508. getDetail(successTip) {
  509. this.loadIng++;
  510. $A.apiAjax({
  511. url: 'project/detail',
  512. data: {
  513. projectid: this.projectid,
  514. },
  515. complete: () => {
  516. this.loadIng--;
  517. this.loadDetailed = true;
  518. },
  519. error: () => {
  520. this.goBack({name:'project'});
  521. alert(this.$L('网络繁忙,请稍后再试!'));
  522. },
  523. success: (res) => {
  524. if (res.ret === 1) {
  525. this.projectDetail = res.data.project;
  526. this.projectLabel = res.data.label;
  527. this.projectSimpleLabel = res.data.simpleLabel;
  528. this.projectSortData = this.getProjectSort();
  529. if (successTip === true) {
  530. this.$Message.success(this.$L('刷新成功!'));
  531. }
  532. } else {
  533. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  534. }
  535. }
  536. });
  537. },
  538. getProjectSort() {
  539. let sortData = "",
  540. taskData = "";
  541. this.projectLabel.forEach((label) => {
  542. taskData = "";
  543. label.taskLists.forEach((task) => {
  544. if (taskData) taskData+= "-";
  545. taskData+= task.id;
  546. });
  547. if (sortData) sortData+= ";";
  548. sortData+= label.id + ":" + taskData;
  549. });
  550. return sortData;
  551. },
  552. handleLabel(event, labelDetail) {
  553. switch (event) {
  554. case 'refresh': {
  555. this.refreshLabel(labelDetail);
  556. break;
  557. }
  558. case 'rename': {
  559. this.renameLabel(labelDetail);
  560. break;
  561. }
  562. case 'delete': {
  563. this.deleteLabel(labelDetail);
  564. break;
  565. }
  566. }
  567. },
  568. refreshLabel(item) {
  569. this.$set(item, 'loadIng', true);
  570. $A.apiAjax({
  571. url: 'project/task/lists',
  572. data: {
  573. projectid: this.projectid,
  574. labelid: item.id,
  575. },
  576. complete: () => {
  577. this.$set(item, 'loadIng', false);
  578. },
  579. error: () => {
  580. window.location.reload();
  581. },
  582. success: (res) => {
  583. if (res.ret === 1) {
  584. this.$set(item, 'taskLists', res.data.lists);
  585. } else {
  586. window.location.reload();
  587. }
  588. }
  589. });
  590. },
  591. renameLabel(item) {
  592. this.renameValue = "";
  593. this.$Modal.confirm({
  594. render: (h) => {
  595. return h('div', [
  596. h('div', {
  597. style: {
  598. fontSize: '16px',
  599. fontWeight: '500',
  600. marginBottom: '20px',
  601. }
  602. }, this.$L('重命名列表')),
  603. h('Input', {
  604. props: {
  605. value: this.renameValue,
  606. autofocus: true,
  607. placeholder: this.$L('请输入新的列表名称')
  608. },
  609. on: {
  610. input: (val) => {
  611. this.renameValue = val;
  612. }
  613. }
  614. })
  615. ])
  616. },
  617. loading: true,
  618. onOk: () => {
  619. if (this.renameValue) {
  620. this.$set(item, 'loadIng', true);
  621. let title = this.renameValue;
  622. $A.apiAjax({
  623. url: 'project/label/rename',
  624. data: {
  625. projectid: this.projectid,
  626. labelid: item.id,
  627. title: title,
  628. },
  629. complete: () => {
  630. this.$set(item, 'loadIng', false);
  631. },
  632. error: () => {
  633. this.$Modal.remove();
  634. alert(this.$L('网络繁忙,请稍后再试!'));
  635. },
  636. success: (res) => {
  637. this.$Modal.remove();
  638. this.$set(item, 'title', title);
  639. setTimeout(() => {
  640. if (res.ret === 1) {
  641. this.$Message.success(res.msg);
  642. } else {
  643. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  644. }
  645. }, 350);
  646. }
  647. });
  648. } else {
  649. this.$Modal.remove();
  650. }
  651. },
  652. });
  653. },
  654. deleteLabel(item) {
  655. let redTip = item.taskLists.length > 0 ? ('<div style="color:red;font-weight:500">' + this.$L('注:将同时删除列表下所有任务') + '</div>') : '';
  656. this.$Modal.confirm({
  657. title: this.$L('删除列表'),
  658. content: '<div>' + this.$L('你确定要删除此列表吗?') + '</div>' + redTip,
  659. loading: true,
  660. onOk: () => {
  661. $A.apiAjax({
  662. url: 'project/label/delete',
  663. data: {
  664. projectid: this.projectid,
  665. labelid: item.id,
  666. },
  667. error: () => {
  668. this.$Modal.remove();
  669. alert(this.$L('网络繁忙,请稍后再试!'));
  670. },
  671. success: (res) => {
  672. this.$Modal.remove();
  673. this.projectLabel.some((label, index) => {
  674. if (label.id == item.id) {
  675. this.projectLabel.splice(index, 1);
  676. this.projectSortData = this.getProjectSort();
  677. return true;
  678. }
  679. });
  680. setTimeout(() => {
  681. if (res.ret === 1) {
  682. this.$Message.success(res.msg);
  683. $A.triggerTaskInfoListener('deletelabel', {labelid: item.id, projectid: item.projectid});
  684. } else {
  685. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  686. }
  687. }, 350);
  688. }
  689. });
  690. }
  691. });
  692. },
  693. addLabel() {
  694. this.labelValue = "";
  695. this.$Modal.confirm({
  696. render: (h) => {
  697. return h('div', [
  698. h('div', {
  699. style: {
  700. fontSize: '16px',
  701. fontWeight: '500',
  702. marginBottom: '20px',
  703. }
  704. }, this.$L('添加列表')),
  705. h('Input', {
  706. props: {
  707. value: this.labelValue,
  708. autofocus: true,
  709. placeholder: this.$L('请输入列表名称')
  710. },
  711. on: {
  712. input: (val) => {
  713. this.labelValue = val;
  714. }
  715. }
  716. })
  717. ])
  718. },
  719. loading: true,
  720. onOk: () => {
  721. if (this.labelValue) {
  722. let data = {
  723. projectid: this.projectid,
  724. title: this.labelValue
  725. };
  726. $A.apiAjax({
  727. url: 'project/label/add',
  728. data: data,
  729. error: () => {
  730. this.$Modal.remove();
  731. alert(this.$L('网络繁忙,请稍后再试!'));
  732. },
  733. success: (res) => {
  734. this.$Modal.remove();
  735. this.projectLabel.push(res.data);
  736. this.projectSortData = this.getProjectSort();
  737. $A.triggerTaskInfoListener('addlabel', Object.assign(data, {labelid: res.data.id}));
  738. setTimeout(() => {
  739. if (res.ret === 1) {
  740. this.$Message.success(res.msg);
  741. } else {
  742. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  743. }
  744. }, 350);
  745. }
  746. });
  747. } else {
  748. this.$Modal.remove();
  749. }
  750. },
  751. });
  752. },
  753. addTaskSuccess(taskDetail, label) {
  754. if (label.taskLists instanceof Array) {
  755. taskDetail.isNewtask = true;
  756. label.taskLists.unshift(taskDetail);
  757. this.$nextTick(() => {
  758. this.$set(taskDetail, 'isNewtask', false);
  759. });
  760. } else {
  761. this.refreshLabel(label);
  762. }
  763. },
  764. openProjectDrawer(tab) {
  765. this.projectDrawerTab = tab;
  766. this.projectDrawerShow = true;
  767. },
  768. openProjectSettingDrawer(tab) {
  769. this.projectSettingDrawerTab = tab;
  770. this.projectSettingDrawerShow = true;
  771. },
  772. projectSortUpdate(isLabel) {
  773. let oldSort = this.projectSortData;
  774. let newSort = this.getProjectSort();
  775. if (oldSort == newSort) {
  776. return;
  777. }
  778. this.projectSortData = newSort;
  779. this.projectSortDisabled = true;
  780. this.loadIng++;
  781. $A.apiAjax({
  782. url: 'project/sort',
  783. data: {
  784. projectid: this.projectid,
  785. oldsort: oldSort,
  786. newsort: newSort,
  787. label: isLabel === true ? 1 : 0
  788. },
  789. complete: () => {
  790. this.projectSortDisabled = false;
  791. this.loadIng--;
  792. },
  793. error: () => {
  794. this.getDetail();
  795. alert(this.$L('网络繁忙,请稍后再试!'));
  796. },
  797. success: (res) => {
  798. if (res.ret === 1) {
  799. this.$Message.success(res.msg);
  800. $A.triggerTaskInfoListener(isLabel ? 'labelsort' : 'tasksort', { projectid: this.projectid, nickname: $A.getNickName(), time: Math.round(new Date().getTime()/1000) });
  801. } else {
  802. this.getDetail();
  803. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  804. }
  805. }
  806. });
  807. },
  808. subtaskProgress(subtask) {
  809. if (subtask.length === 0) {
  810. return 0;
  811. }
  812. const completeLists = subtask.filter((item) => { return item.status == 'complete'});
  813. return parseFloat(((completeLists.length / subtask.length) * 100).toFixed(2));
  814. },
  815. openTaskModal(taskDetail) {
  816. this.taskDetail(taskDetail);
  817. },
  818. },
  819. }
  820. </script>