panel.vue 41 KB

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