project-panel.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. <template>
  2. <div class="w-main project-panel">
  3. <v-title>{{$L('项目面板')}}-{{$L('轻量级的团队在线协作')}}</v-title>
  4. <w-header value="project"></w-header>
  5. <div class="w-nav">
  6. <div class="nav-row">
  7. <div class="w-nav-left">
  8. <div class="project-title">
  9. <div v-if="loadIng > 0" class="project-title-loading"><w-loading></w-loading></div>
  10. <h1>{{projectDetail.title}}</h1>
  11. <div class="project-title-refresh" @click="getDetail(true)">刷新</div>
  12. </div>
  13. </div>
  14. <div class="w-nav-flex"></div>
  15. <div class="w-nav-right">
  16. <span class="ft hover" @click="openProjectDrawer('lists')"><i class="ft icon">&#xE89E;</i> 任务列表</span>
  17. <span class="ft hover" @click="openProjectDrawer('files')"><i class="ft icon">&#xE701;</i> 文件列表</span>
  18. <span class="ft hover" @click="openProjectDrawer('logs')"><i class="ft icon">&#xE753;</i> 项目动态</span>
  19. <span class="ft hover" @click="openProjectSettingDrawer('archived')"><i class="ft icon">&#xE7A7;</i> 设置</span>
  20. </div>
  21. </div>
  22. </div>
  23. <w-content>
  24. <draggable
  25. v-if="projectLabel.length > 0"
  26. v-model="projectLabel"
  27. class="label-box"
  28. draggable=".label-draggable"
  29. :animation="150"
  30. :disabled="projectSortDisabled"
  31. @sort="projectSortUpdate(true)">
  32. <div 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. ]">
  64. <div class="task-title">{{task.title}}</div>
  65. <div class="task-more">
  66. <div v-if="task.overdue" class="task-status">已超期</div>
  67. <div v-else-if="task.complete" class="task-status">已完成</div>
  68. <div v-else class="task-status">未完成</div>
  69. <Tooltip class="task-userimg" :content="task.nickname || task.username" transfer><img :src="task.userimg"/></Tooltip>
  70. </div>
  71. </div>
  72. </div>
  73. <div slot="footer">
  74. <project-add-task :placeholder='`添加任务至"${label.title}"`' :projectid="label.projectid" :labelid="label.id" @on-add-success="addTaskSuccess($event, label)"></project-add-task>
  75. </div>
  76. </draggable>
  77. </div>
  78. </div>
  79. <div v-if="loadDetailed" slot="footer" class="label-item label-create" @click="addLabel">
  80. <div class="label-body">
  81. <div class="trigger-box ft hover"><i class="ft icon">&#xE8C8;</i>添加一个新列表</div>
  82. </div>
  83. </div>
  84. </draggable>
  85. </w-content>
  86. <Drawer v-model="projectDrawerShow" width="80%">
  87. <Tabs v-if="projectDrawerShow" v-model="projectDrawerTab">
  88. <TabPane :label="$L('任务列表')" name="lists">
  89. <project-task-lists :canload="projectDrawerShow && projectDrawerTab == 'lists'" :projectid="projectid" :labelLists="projectSimpleLabel"></project-task-lists>
  90. </TabPane>
  91. <TabPane :label="$L('文件列表')" name="files">
  92. <project-task-files :canload="projectDrawerShow && projectDrawerTab == 'files'" :projectid="projectid"></project-task-files>
  93. </TabPane>
  94. <TabPane :label="$L('项目动态')" name="logs">
  95. <project-task-logs :canload="projectDrawerShow && projectDrawerTab == 'logs'" :projectid="projectid"></project-task-logs>
  96. </TabPane>
  97. </Tabs>
  98. </Drawer>
  99. <Drawer v-model="projectSettingDrawerShow" width="75%">
  100. <Tabs v-if="projectSettingDrawerShow" v-model="projectSettingDrawerTab">
  101. <TabPane :label="$L('已归档任务')" name="archived">
  102. <project-archived :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'archived'" :projectid="projectid"></project-archived>
  103. </TabPane>
  104. <TabPane :label="$L('成员管理')" name="member">
  105. <project-users :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'member'" :projectid="projectid"></project-users>
  106. </TabPane>
  107. <TabPane :label="$L('项目统计')" name="statistics">
  108. <project-statistics :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'statistics'" :projectid="projectid"></project-statistics>
  109. </TabPane>
  110. </Tabs>
  111. </Drawer>
  112. </div>
  113. </template>
  114. <style lang="scss">
  115. #project-panel-enter-textarea {
  116. background: transparent;
  117. background: none;
  118. outline: none;
  119. border: 0;
  120. resize: none;
  121. padding: 0;
  122. margin: 8px 0;
  123. line-height: 22px;
  124. border-radius: 0;
  125. color: rgba(0, 0, 0, 0.85);
  126. &:focus {
  127. border-color: transparent;
  128. box-shadow: none;
  129. }
  130. }
  131. </style>
  132. <style lang="scss" scoped>
  133. .project-panel {
  134. .project-title {
  135. display: flex;
  136. flex-direction: row;
  137. align-items: center;
  138. &:hover {
  139. .project-title-refresh {
  140. display: block;
  141. }
  142. }
  143. .project-title-loading {
  144. width: 18px;
  145. height: 18px;
  146. margin-right: 6px;
  147. display: flex;
  148. }
  149. h1 {
  150. font-size: 14px;
  151. font-weight: 500;
  152. }
  153. .project-title-refresh {
  154. display: none;
  155. padding-left: 12px;
  156. padding-right: 12px;
  157. color: #048be0;
  158. cursor: pointer;
  159. &:hover {
  160. text-decoration: underline;
  161. }
  162. }
  163. }
  164. .label-box {
  165. display: flex;
  166. flex-direction: row;
  167. align-items: flex-start;
  168. justify-content: flex-start;
  169. flex-wrap: nowrap;
  170. overflow-x: auto;
  171. overflow-y: hidden;
  172. -webkit-overflow-scrolling: touch;
  173. width: 100%;
  174. height: 100%;
  175. padding: 15px;
  176. transform: translateZ(0);
  177. .label-item {
  178. flex-grow: 1;
  179. flex-shrink: 0;
  180. flex-basis: auto;
  181. height: 100%;
  182. padding-right: 15px;
  183. &.label-create {
  184. cursor: pointer;
  185. &:hover {
  186. .trigger-box {
  187. transform: translate(0, -50%) scale(1.1);
  188. }
  189. }
  190. }
  191. .label-body {
  192. width: 300px;
  193. height: 100%;
  194. border-radius: 0.15rem;
  195. background-color: #ebecf0;
  196. overflow: hidden;
  197. position: relative;
  198. display: flex;
  199. flex-direction: column;
  200. .title-box {
  201. padding: 0 12px;
  202. font-weight: bold;
  203. color: #666666;
  204. position: relative;
  205. cursor: move;
  206. display: flex;
  207. align-items: center;
  208. width: 100%;
  209. height: 42px;
  210. .title-loading {
  211. width: 16px;
  212. height: 16px;
  213. margin-right: 6px;
  214. }
  215. h2 {
  216. flex: 1;
  217. font-size: 16px;
  218. overflow: hidden;
  219. text-overflow: ellipsis;
  220. white-space: nowrap;
  221. }
  222. i {
  223. font-weight: 500;
  224. font-size: 18px;
  225. height: 100%;
  226. line-height: 42px;
  227. width: 42px;
  228. text-align: right;
  229. cursor: pointer;
  230. }
  231. }
  232. .task-box {
  233. flex: 1;
  234. width: 100%;
  235. overflow: auto;
  236. display: flex;
  237. flex-direction: column;
  238. padding: 0 12px 2px;
  239. transform: translateZ(0);
  240. .task-item {
  241. width: 100%;
  242. .task-shadow {
  243. margin: 5px 0 4px;
  244. padding: 8px;
  245. background-color: #ffffff;
  246. border-left: 2px solid #BF9F03;
  247. border-right: 2px solid #ffffff;
  248. color: #091e42;
  249. border-radius: 3px;
  250. cursor: pointer;
  251. box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  252. transition: all 0.3s;
  253. transform: scale(1);
  254. &:hover{
  255. box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.38);
  256. }
  257. &.p1 {
  258. border-left-color: #ff0000;
  259. }
  260. &.p2 {
  261. border-left-color: #BB9F35;
  262. }
  263. &.p3 {
  264. border-left-color: #449EDD;
  265. }
  266. &.p4 {
  267. border-left-color: #84A83B;
  268. }
  269. &.complete {
  270. .task-more {
  271. .task-status {
  272. color: #666666;
  273. }
  274. }
  275. }
  276. &.overdue {
  277. .task-title {
  278. font-weight: bold;
  279. }
  280. .task-more {
  281. .task-status {
  282. color: #ff0000;
  283. }
  284. }
  285. }
  286. &.newtask {
  287. transform: scale(1.5);
  288. }
  289. .task-title {
  290. font-size: 12px;
  291. color: #091e42;
  292. word-break: break-all;
  293. }
  294. .task-more {
  295. min-height: 30px;
  296. display: flex;
  297. align-items: flex-end;
  298. .task-status {
  299. color: #19be6b;
  300. font-size: 12px;
  301. flex: 1;
  302. }
  303. .task-userimg {
  304. width: 26px;
  305. height: 26px;
  306. img {
  307. object-fit: cover;
  308. width: 100%;
  309. height: 100%;
  310. border-radius: 50%;
  311. }
  312. }
  313. }
  314. }
  315. }
  316. }
  317. .trigger-box {
  318. text-align: center;
  319. font-size: 16px;
  320. color: #666;
  321. width: 100%;
  322. position: absolute;
  323. top: 50%;
  324. transform: translate(0, -50%) scale(1);
  325. transition: all 0.3s;
  326. }
  327. }
  328. }
  329. }
  330. }
  331. </style>
  332. <script>
  333. import draggable from 'vuedraggable'
  334. import WHeader from "../components/WHeader";
  335. import WContent from "../components/WContent";
  336. import WLoading from "../components/WLoading";
  337. import ProjectAddTask from "../components/project/task/add";
  338. import ProjectTaskLists from "../components/project/task/lists";
  339. import ProjectTaskFiles from "../components/project/task/files";
  340. import ProjectTaskLogs from "../components/project/task/logs";
  341. import ProjectArchived from "../components/project/archived";
  342. import ProjectUsers from "../components/project/users";
  343. import ProjectStatistics from "../components/project/statistics";
  344. export default {
  345. components: {
  346. ProjectStatistics,
  347. ProjectUsers,
  348. ProjectArchived,
  349. ProjectTaskLogs,
  350. ProjectTaskFiles, ProjectTaskLists, ProjectAddTask, draggable, WLoading, WContent, WHeader},
  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: 'archived',
  365. }
  366. },
  367. mounted() {
  368. },
  369. activated() {
  370. this.projectid = this.$route.params.projectid;
  371. if (typeof this.$route.params.other === "object") {
  372. this.$set(this.projectDetail, 'title', $A.getObject(this.$route.params.other, 'title'))
  373. }
  374. },
  375. watch: {
  376. projectid(val) {
  377. if ($A.runNum(val) <= 0) {
  378. this.goBack();
  379. return;
  380. }
  381. this.projectDetail = {};
  382. this.projectLabel = [];
  383. this.projectSimpleLabel = [];
  384. this.getDetail();
  385. }
  386. },
  387. methods: {
  388. getDetail(successTip) {
  389. this.loadIng++;
  390. $A.aAjax({
  391. url: 'project/detail',
  392. data: {
  393. projectid: this.projectid,
  394. },
  395. complete: () => {
  396. this.loadIng--;
  397. this.loadDetailed = true;
  398. },
  399. error: () => {
  400. this.goBack();
  401. alert(this.$L('网络繁忙,请稍后再试!'));
  402. },
  403. success: (res) => {
  404. if (res.ret === 1) {
  405. this.projectDetail = res.data.project;
  406. this.projectLabel = res.data.label;
  407. this.projectSimpleLabel = res.data.simpleLabel;
  408. this.projectSortData = this.getProjectSort();
  409. if (successTip === true) {
  410. this.$Message.success(this.$L('刷新成功!'));
  411. }
  412. } else {
  413. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  414. this.goBack();
  415. }
  416. }
  417. });
  418. },
  419. getProjectSort() {
  420. let sortData = "",
  421. taskData = "";
  422. this.projectLabel.forEach((label) => {
  423. taskData = "";
  424. label.taskLists.forEach((task) => {
  425. if (taskData) taskData+= "-";
  426. taskData+= task.id;
  427. });
  428. if (sortData) sortData+= ";";
  429. sortData+= label.id + ":" + taskData;
  430. });
  431. return sortData;
  432. },
  433. handleLabel(event, labelDetail) {
  434. switch (event) {
  435. case 'refresh': {
  436. this.refreshLabel(labelDetail);
  437. break;
  438. }
  439. case 'rename': {
  440. this.renameLabel(labelDetail);
  441. break;
  442. }
  443. case 'delete': {
  444. this.deleteLabel(labelDetail);
  445. break;
  446. }
  447. }
  448. },
  449. refreshLabel(item) {
  450. this.$set(item, 'loadIng', true);
  451. $A.aAjax({
  452. url: 'project/task/lists',
  453. data: {
  454. projectid: this.projectid,
  455. labelid: item.id,
  456. },
  457. complete: () => {
  458. this.$set(item, 'loadIng', false);
  459. },
  460. error: () => {
  461. window.location.reload();
  462. },
  463. success: (res) => {
  464. if (res.ret === 1) {
  465. this.$set(item, 'taskLists', res.data.lists);
  466. } else {
  467. window.location.reload();
  468. }
  469. }
  470. });
  471. },
  472. renameLabel(item) {
  473. this.renameValue = "";
  474. this.$Modal.confirm({
  475. render: (h) => {
  476. return h('div', [
  477. h('div', {
  478. style: {
  479. fontSize: '16px',
  480. fontWeight: '500',
  481. marginBottom: '20px',
  482. }
  483. }, '重命名列表'),
  484. h('Input', {
  485. props: {
  486. value: this.renameValue,
  487. autofocus: true,
  488. placeholder: '请输入新的列表名称'
  489. },
  490. on: {
  491. input: (val) => {
  492. this.renameValue = val;
  493. }
  494. }
  495. })
  496. ])
  497. },
  498. loading: true,
  499. onOk: () => {
  500. if (this.renameValue) {
  501. this.$set(item, 'loadIng', true);
  502. let title = this.renameValue;
  503. $A.aAjax({
  504. url: 'project/label/rename',
  505. data: {
  506. projectid: this.projectid,
  507. labelid: item.id,
  508. title: title,
  509. },
  510. complete: () => {
  511. this.$set(item, 'loadIng', false);
  512. },
  513. error: () => {
  514. this.$Modal.remove();
  515. alert(this.$L('网络繁忙,请稍后再试!'));
  516. },
  517. success: (res) => {
  518. this.$Modal.remove();
  519. this.$set(item, 'title', title);
  520. setTimeout(() => {
  521. if (res.ret === 1) {
  522. this.$Message.success(res.msg);
  523. } else {
  524. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  525. }
  526. }, 350);
  527. }
  528. });
  529. } else {
  530. this.$Modal.remove();
  531. }
  532. },
  533. });
  534. },
  535. deleteLabel(item) {
  536. let redTip = item.taskLists.length > 0 ? '<div style="color:red;font-weight:500">注:将同时删除列表下所有任务</div>' : '';
  537. this.$Modal.confirm({
  538. title: '删除列表',
  539. content: '<div>你确定要删除此列表吗?</div>' + redTip,
  540. loading: true,
  541. onOk: () => {
  542. $A.aAjax({
  543. url: 'project/label/delete',
  544. data: {
  545. projectid: this.projectid,
  546. labelid: item.id,
  547. },
  548. error: () => {
  549. this.$Modal.remove();
  550. alert(this.$L('网络繁忙,请稍后再试!'));
  551. },
  552. success: (res) => {
  553. this.$Modal.remove();
  554. this.projectLabel.some((label, index) => {
  555. if (label.id == item.id) {
  556. this.projectLabel.splice(index, 1);
  557. this.projectSortData = this.getProjectSort();
  558. return true;
  559. }
  560. });
  561. setTimeout(() => {
  562. if (res.ret === 1) {
  563. this.$Message.success(res.msg);
  564. $A.triggerTaskInfoListener('deletelabel', {labelid: item.id});
  565. } else {
  566. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  567. }
  568. }, 350);
  569. }
  570. });
  571. }
  572. });
  573. },
  574. addLabel() {
  575. this.labelValue = "";
  576. this.$Modal.confirm({
  577. render: (h) => {
  578. return h('div', [
  579. h('div', {
  580. style: {
  581. fontSize: '16px',
  582. fontWeight: '500',
  583. marginBottom: '20px',
  584. }
  585. }, '添加列表'),
  586. h('Input', {
  587. props: {
  588. value: this.labelValue,
  589. autofocus: true,
  590. placeholder: '请输入列表名称'
  591. },
  592. on: {
  593. input: (val) => {
  594. this.labelValue = val;
  595. }
  596. }
  597. })
  598. ])
  599. },
  600. loading: true,
  601. onOk: () => {
  602. if (this.labelValue) {
  603. $A.aAjax({
  604. url: 'project/label/add',
  605. data: {
  606. projectid: this.projectid,
  607. title: this.labelValue
  608. },
  609. error: () => {
  610. this.$Modal.remove();
  611. alert(this.$L('网络繁忙,请稍后再试!'));
  612. },
  613. success: (res) => {
  614. this.$Modal.remove();
  615. this.projectLabel.push(res.data);
  616. this.projectSortData = this.getProjectSort();
  617. setTimeout(() => {
  618. if (res.ret === 1) {
  619. this.$Message.success(res.msg);
  620. } else {
  621. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  622. }
  623. }, 350);
  624. }
  625. });
  626. } else {
  627. this.$Modal.remove();
  628. }
  629. },
  630. });
  631. },
  632. addTaskSuccess(taskDetail, label) {
  633. if (label.taskLists instanceof Array) {
  634. taskDetail.isNewtask = true;
  635. label.taskLists.unshift(taskDetail);
  636. this.$nextTick(() => {
  637. this.$set(taskDetail, 'isNewtask', false);
  638. });
  639. } else {
  640. this.refreshLabel(label);
  641. }
  642. },
  643. openProjectDrawer(tab) {
  644. this.projectDrawerTab = tab;
  645. this.projectDrawerShow = true;
  646. },
  647. openProjectSettingDrawer(tab) {
  648. this.projectSettingDrawerTab = tab;
  649. this.projectSettingDrawerShow = true;
  650. },
  651. projectSortUpdate(isLabel) {
  652. let oldSort = this.projectSortData;
  653. let newSort = this.getProjectSort();
  654. if (oldSort == newSort) {
  655. return;
  656. }
  657. this.projectSortData = newSort;
  658. this.projectSortDisabled = true;
  659. this.loadIng++;
  660. $A.aAjax({
  661. url: 'project/sort',
  662. data: {
  663. projectid: this.projectid,
  664. oldsort: oldSort,
  665. newsort: newSort,
  666. label: isLabel === true ? 1 : 0
  667. },
  668. complete: () => {
  669. this.projectSortDisabled = false;
  670. this.loadIng--;
  671. },
  672. error: () => {
  673. this.getDetail();
  674. alert(this.$L('网络繁忙,请稍后再试!'));
  675. },
  676. success: (res) => {
  677. if (res.ret === 1) {
  678. this.$Message.success(res.msg);
  679. } else {
  680. this.getDetail();
  681. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  682. }
  683. }
  684. });
  685. },
  686. },
  687. }
  688. </script>