project-panel.vue 27 KB

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