panel.vue 49 KB

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