panel.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  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}}</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. }
  274. .task-more {
  275. min-height: 30px;
  276. display: flex;
  277. align-items: flex-end;
  278. .task-status {
  279. color: #19be6b;
  280. font-size: 12px;
  281. flex: 1;
  282. }
  283. .task-userimg {
  284. width: 26px;
  285. height: 26px;
  286. img {
  287. object-fit: cover;
  288. width: 100%;
  289. height: 100%;
  290. border-radius: 50%;
  291. }
  292. }
  293. }
  294. .subtask-progress {
  295. position: absolute;
  296. top: 0;
  297. left: 0;
  298. width: 100%;
  299. height: 100%;
  300. z-index: -1;
  301. border-radius: 0 3px 3px 0;
  302. overflow: hidden;
  303. pointer-events: none;
  304. em {
  305. display: block;
  306. height: 100%;
  307. background-color: rgba(3, 150, 242, 0.07);
  308. }
  309. }
  310. }
  311. }
  312. }
  313. .trigger-box {
  314. text-align: center;
  315. font-size: 16px;
  316. color: #666;
  317. width: 100%;
  318. position: absolute;
  319. top: 50%;
  320. transform: translate(0, -50%) scale(1);
  321. transition: all 0.3s;
  322. }
  323. }
  324. }
  325. }
  326. }
  327. </style>
  328. <script>
  329. import draggable from 'vuedraggable'
  330. import WContent from "../../components/WContent";
  331. import ProjectAddTask from "../../components/project/task/add";
  332. import ProjectTaskLists from "../../components/project/task/lists";
  333. import ProjectTaskFiles from "../../components/project/task/files";
  334. import ProjectTaskLogs from "../../components/project/task/logs";
  335. import ProjectArchived from "../../components/project/archived";
  336. import ProjectUsers from "../../components/project/users";
  337. import ProjectStatistics from "../../components/project/statistics";
  338. import WDrawer from "../../components/iview/WDrawer";
  339. import ProjectGantt from "../../components/project/gantt/index";
  340. import ProjectSetting from "../../components/project/setting";
  341. export default {
  342. components: {
  343. ProjectSetting,
  344. ProjectGantt,
  345. WDrawer,
  346. ProjectStatistics,
  347. ProjectUsers,
  348. ProjectArchived,
  349. ProjectTaskLogs,
  350. ProjectTaskFiles, ProjectTaskLists, ProjectAddTask, draggable, WContent},
  351. data () {
  352. return {
  353. loadIng: 0,
  354. loadDetailed: false,
  355. projectid: 0,
  356. projectDetail: {},
  357. projectLabel: [],
  358. projectSimpleLabel: [],
  359. projectSortData: '',
  360. projectSortDisabled: false,
  361. projectDrawerShow: false,
  362. projectDrawerTab: 'lists',
  363. projectSettingDrawerShow: false,
  364. projectSettingDrawerTab: 'setting',
  365. projectGanttShow: false,
  366. routeName: '',
  367. }
  368. },
  369. mounted() {
  370. this.routeName = this.$route.name;
  371. $A.setOnTaskInfoListener('pages/project-panel',(act, detail) => {
  372. if (detail.projectid != this.projectid) {
  373. return;
  374. }
  375. //
  376. switch (act) {
  377. case 'addlabel': // 添加分类
  378. let tempLists = this.projectLabel.filter((res) => { return res.id == detail.labelid });
  379. if (tempLists.length == 0) {
  380. this.projectLabel.push(Object.assign(detail, {id: detail.labelid}));
  381. this.projectSortData = this.getProjectSort();
  382. }
  383. return;
  384. case 'deletelabel': // 删除分类
  385. this.projectLabel.some((label, index) => {
  386. if (label.id == detail.labelid) {
  387. this.projectLabel.splice(index, 1);
  388. this.projectSortData = this.getProjectSort();
  389. return true;
  390. }
  391. });
  392. return;
  393. case 'deleteproject': // 删除项目
  394. return;
  395. case "labelsort": // 调整分类排序
  396. case "tasksort": // 调整任务排序
  397. if (detail.__modifyUsername != $A.getUserName()) {
  398. if (this.routeName == this.$route.name) {
  399. this.$Modal.confirm({
  400. title: this.$L("更新提示"),
  401. content: this.$L('团队成员(%)调整了%,<br/>更新时间:%。<br/><br/>点击【确定】加载最新数据。', detail.nickname, this.$L(act == 'labelsort' ? '分类排序' : '任务排序'), $A.formatDate("Y-m-d H:i:s", detail.time)),
  402. onOk: () => {
  403. this.getDetail(true);
  404. }
  405. });
  406. } else {
  407. this.getDetail(true);
  408. }
  409. }
  410. return;
  411. }
  412. //
  413. this.projectLabel.forEach((label) => {
  414. label.taskLists.some((task, i) => {
  415. if (task.id == detail.id) {
  416. label.taskLists.splice(i, 1, detail);
  417. return true;
  418. }
  419. });
  420. });
  421. //
  422. switch (act) {
  423. case "delete": // 删除任务
  424. case "archived": // 归档
  425. this.projectLabel.forEach((label) => {
  426. label.taskLists.some((task, i) => {
  427. if (task.id == detail.id) {
  428. label.taskLists.splice(i, 1,);
  429. return true;
  430. }
  431. });
  432. });
  433. this.projectSortData = this.getProjectSort();
  434. break;
  435. case "create": // 创建任务
  436. this.projectLabel.some((label) => {
  437. if (label.id == detail.labelid) {
  438. let tempLists = label.taskLists.filter((res) => { return res.id == detail.id });
  439. if (tempLists.length == 0) {
  440. detail.isNewtask = true;
  441. label.taskLists.unshift(detail);
  442. this.$nextTick(() => {
  443. this.$set(detail, 'isNewtask', false);
  444. });
  445. }
  446. return true;
  447. }
  448. });
  449. break;
  450. case "unarchived": // 取消归档
  451. this.projectLabel.forEach((label) => {
  452. if (label.id == detail.labelid) {
  453. let index = label.taskLists.length;
  454. label.taskLists.some((task, i) => {
  455. if (detail.inorder > task.inorder || (detail.inorder == task.inorder && detail.id > task.id)) {
  456. index = i;
  457. return true;
  458. }
  459. });
  460. label.taskLists.splice(index, 0, detail);
  461. }
  462. });
  463. this.projectSortData = this.getProjectSort();
  464. break;
  465. }
  466. }, true);
  467. },
  468. activated() {
  469. this.projectid = this.$route.params.projectid;
  470. if (typeof this.$route.params.other === "object") {
  471. this.$set(this.projectDetail, 'title', $A.getObject(this.$route.params.other, 'title'));
  472. }
  473. if (this.$route.params.statistics === '已完成') {
  474. this.projectSettingDrawerTab = 'statistics';
  475. this.projectSettingDrawerShow = true;
  476. this.$nextTick(() => {
  477. this.$refs.statistics.setTaskType('已完成');
  478. });
  479. }
  480. },
  481. deactivated() {
  482. if ($A.getToken() === false) {
  483. this.projectid = 0;
  484. }
  485. this.projectGanttShow = false;
  486. this.projectDrawerShow = false;
  487. this.projectSettingDrawerShow = false;
  488. },
  489. watch: {
  490. projectid(val) {
  491. if ($A.runNum(val) <= 0) {
  492. return;
  493. }
  494. this.projectDetail = {};
  495. this.projectLabel = [];
  496. this.projectSimpleLabel = [];
  497. this.getDetail();
  498. }
  499. },
  500. methods: {
  501. getDetail(successTip) {
  502. this.loadIng++;
  503. $A.apiAjax({
  504. url: 'project/detail',
  505. data: {
  506. projectid: this.projectid,
  507. },
  508. complete: () => {
  509. this.loadIng--;
  510. this.loadDetailed = true;
  511. },
  512. error: () => {
  513. this.goBack({name:'project'});
  514. alert(this.$L('网络繁忙,请稍后再试!'));
  515. },
  516. success: (res) => {
  517. if (res.ret === 1) {
  518. this.projectDetail = res.data.project;
  519. this.projectLabel = res.data.label;
  520. this.projectSimpleLabel = res.data.simpleLabel;
  521. this.projectSortData = this.getProjectSort();
  522. if (successTip === true) {
  523. this.$Message.success(this.$L('刷新成功!'));
  524. }
  525. } else {
  526. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  527. }
  528. }
  529. });
  530. },
  531. getProjectSort() {
  532. let sortData = "",
  533. taskData = "";
  534. this.projectLabel.forEach((label) => {
  535. taskData = "";
  536. label.taskLists.forEach((task) => {
  537. if (taskData) taskData+= "-";
  538. taskData+= task.id;
  539. });
  540. if (sortData) sortData+= ";";
  541. sortData+= label.id + ":" + taskData;
  542. });
  543. return sortData;
  544. },
  545. handleLabel(event, labelDetail) {
  546. switch (event) {
  547. case 'refresh': {
  548. this.refreshLabel(labelDetail);
  549. break;
  550. }
  551. case 'rename': {
  552. this.renameLabel(labelDetail);
  553. break;
  554. }
  555. case 'delete': {
  556. this.deleteLabel(labelDetail);
  557. break;
  558. }
  559. }
  560. },
  561. refreshLabel(item) {
  562. this.$set(item, 'loadIng', true);
  563. $A.apiAjax({
  564. url: 'project/task/lists',
  565. data: {
  566. projectid: this.projectid,
  567. labelid: item.id,
  568. },
  569. complete: () => {
  570. this.$set(item, 'loadIng', false);
  571. },
  572. error: () => {
  573. window.location.reload();
  574. },
  575. success: (res) => {
  576. if (res.ret === 1) {
  577. this.$set(item, 'taskLists', res.data.lists);
  578. } else {
  579. window.location.reload();
  580. }
  581. }
  582. });
  583. },
  584. renameLabel(item) {
  585. this.renameValue = "";
  586. this.$Modal.confirm({
  587. render: (h) => {
  588. return h('div', [
  589. h('div', {
  590. style: {
  591. fontSize: '16px',
  592. fontWeight: '500',
  593. marginBottom: '20px',
  594. }
  595. }, this.$L('重命名列表')),
  596. h('Input', {
  597. props: {
  598. value: this.renameValue,
  599. autofocus: true,
  600. placeholder: this.$L('请输入新的列表名称')
  601. },
  602. on: {
  603. input: (val) => {
  604. this.renameValue = val;
  605. }
  606. }
  607. })
  608. ])
  609. },
  610. loading: true,
  611. onOk: () => {
  612. if (this.renameValue) {
  613. this.$set(item, 'loadIng', true);
  614. let title = this.renameValue;
  615. $A.apiAjax({
  616. url: 'project/label/rename',
  617. data: {
  618. projectid: this.projectid,
  619. labelid: item.id,
  620. title: title,
  621. },
  622. complete: () => {
  623. this.$set(item, 'loadIng', false);
  624. },
  625. error: () => {
  626. this.$Modal.remove();
  627. alert(this.$L('网络繁忙,请稍后再试!'));
  628. },
  629. success: (res) => {
  630. this.$Modal.remove();
  631. this.$set(item, 'title', title);
  632. setTimeout(() => {
  633. if (res.ret === 1) {
  634. this.$Message.success(res.msg);
  635. } else {
  636. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  637. }
  638. }, 350);
  639. }
  640. });
  641. } else {
  642. this.$Modal.remove();
  643. }
  644. },
  645. });
  646. },
  647. deleteLabel(item) {
  648. let redTip = item.taskLists.length > 0 ? ('<div style="color:red;font-weight:500">' + this.$L('注:将同时删除列表下所有任务') + '</div>') : '';
  649. this.$Modal.confirm({
  650. title: this.$L('删除列表'),
  651. content: '<div>' + this.$L('你确定要删除此列表吗?') + '</div>' + redTip,
  652. loading: true,
  653. onOk: () => {
  654. $A.apiAjax({
  655. url: 'project/label/delete',
  656. data: {
  657. projectid: this.projectid,
  658. labelid: item.id,
  659. },
  660. error: () => {
  661. this.$Modal.remove();
  662. alert(this.$L('网络繁忙,请稍后再试!'));
  663. },
  664. success: (res) => {
  665. this.$Modal.remove();
  666. this.projectLabel.some((label, index) => {
  667. if (label.id == item.id) {
  668. this.projectLabel.splice(index, 1);
  669. this.projectSortData = this.getProjectSort();
  670. return true;
  671. }
  672. });
  673. setTimeout(() => {
  674. if (res.ret === 1) {
  675. this.$Message.success(res.msg);
  676. $A.triggerTaskInfoListener('deletelabel', {labelid: item.id, projectid: item.projectid});
  677. } else {
  678. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  679. }
  680. }, 350);
  681. }
  682. });
  683. }
  684. });
  685. },
  686. addLabel() {
  687. this.labelValue = "";
  688. this.$Modal.confirm({
  689. render: (h) => {
  690. return h('div', [
  691. h('div', {
  692. style: {
  693. fontSize: '16px',
  694. fontWeight: '500',
  695. marginBottom: '20px',
  696. }
  697. }, this.$L('添加列表')),
  698. h('Input', {
  699. props: {
  700. value: this.labelValue,
  701. autofocus: true,
  702. placeholder: this.$L('请输入列表名称')
  703. },
  704. on: {
  705. input: (val) => {
  706. this.labelValue = val;
  707. }
  708. }
  709. })
  710. ])
  711. },
  712. loading: true,
  713. onOk: () => {
  714. if (this.labelValue) {
  715. let data = {
  716. projectid: this.projectid,
  717. title: this.labelValue
  718. };
  719. $A.apiAjax({
  720. url: 'project/label/add',
  721. data: data,
  722. error: () => {
  723. this.$Modal.remove();
  724. alert(this.$L('网络繁忙,请稍后再试!'));
  725. },
  726. success: (res) => {
  727. this.$Modal.remove();
  728. this.projectLabel.push(res.data);
  729. this.projectSortData = this.getProjectSort();
  730. $A.triggerTaskInfoListener('addlabel', Object.assign(data, {labelid: res.data.id}));
  731. setTimeout(() => {
  732. if (res.ret === 1) {
  733. this.$Message.success(res.msg);
  734. } else {
  735. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  736. }
  737. }, 350);
  738. }
  739. });
  740. } else {
  741. this.$Modal.remove();
  742. }
  743. },
  744. });
  745. },
  746. addTaskSuccess(taskDetail, label) {
  747. if (label.taskLists instanceof Array) {
  748. taskDetail.isNewtask = true;
  749. label.taskLists.unshift(taskDetail);
  750. this.$nextTick(() => {
  751. this.$set(taskDetail, 'isNewtask', false);
  752. });
  753. } else {
  754. this.refreshLabel(label);
  755. }
  756. },
  757. openProjectDrawer(tab) {
  758. this.projectDrawerTab = tab;
  759. this.projectDrawerShow = true;
  760. },
  761. openProjectSettingDrawer(tab) {
  762. this.projectSettingDrawerTab = tab;
  763. this.projectSettingDrawerShow = true;
  764. },
  765. projectSortUpdate(isLabel) {
  766. let oldSort = this.projectSortData;
  767. let newSort = this.getProjectSort();
  768. if (oldSort == newSort) {
  769. return;
  770. }
  771. this.projectSortData = newSort;
  772. this.projectSortDisabled = true;
  773. this.loadIng++;
  774. $A.apiAjax({
  775. url: 'project/sort',
  776. data: {
  777. projectid: this.projectid,
  778. oldsort: oldSort,
  779. newsort: newSort,
  780. label: isLabel === true ? 1 : 0
  781. },
  782. complete: () => {
  783. this.projectSortDisabled = false;
  784. this.loadIng--;
  785. },
  786. error: () => {
  787. this.getDetail();
  788. alert(this.$L('网络繁忙,请稍后再试!'));
  789. },
  790. success: (res) => {
  791. if (res.ret === 1) {
  792. this.$Message.success(res.msg);
  793. $A.triggerTaskInfoListener(isLabel ? 'labelsort' : 'tasksort', { projectid: this.projectid, nickname: $A.getNickName(), time: Math.round(new Date().getTime()/1000) });
  794. } else {
  795. this.getDetail();
  796. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  797. }
  798. }
  799. });
  800. },
  801. subtaskProgress(subtask) {
  802. if (subtask.length === 0) {
  803. return 0;
  804. }
  805. const completeLists = subtask.filter((item) => { return item.status == 'complete'});
  806. return parseFloat(((completeLists.length / subtask.length) * 100).toFixed(2));
  807. },
  808. openTaskModal(taskDetail) {
  809. this.taskDetail(taskDetail);
  810. },
  811. },
  812. }
  813. </script>