project-panel.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  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('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" :disabled="projectSortDisabled" @sort="projectSortUpdate(true)">
  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" draggable=".task-draggable" :animation="150" :disabled="projectSortDisabled" @sort="projectSortUpdate(false)" @remove="projectSortUpdate(false)">
  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. transform: translateZ(0);
  162. .label-item {
  163. flex-grow: 1;
  164. flex-shrink: 0;
  165. flex-basis: auto;
  166. height: 100%;
  167. padding-right: 15px;
  168. &.label-create {
  169. cursor: pointer;
  170. &:hover {
  171. .trigger-box {
  172. transform: translate(0, -50%) scale(1.1);
  173. }
  174. }
  175. }
  176. .label-body {
  177. width: 300px;
  178. height: 100%;
  179. border-radius: 0.15rem;
  180. background-color: #ebecf0;
  181. overflow: hidden;
  182. position: relative;
  183. display: flex;
  184. flex-direction: column;
  185. .title-box {
  186. padding: 0 12px;
  187. font-weight: bold;
  188. color: #666666;
  189. position: relative;
  190. cursor: move;
  191. display: flex;
  192. align-items: center;
  193. width: 100%;
  194. height: 42px;
  195. .title-loading {
  196. width: 16px;
  197. height: 16px;
  198. margin-right: 6px;
  199. }
  200. h2 {
  201. flex: 1;
  202. font-size: 16px;
  203. overflow: hidden;
  204. text-overflow: ellipsis;
  205. white-space: nowrap;
  206. }
  207. i {
  208. font-weight: 500;
  209. font-size: 18px;
  210. height: 100%;
  211. line-height: 42px;
  212. width: 42px;
  213. text-align: right;
  214. cursor: pointer;
  215. }
  216. }
  217. .task-box {
  218. flex: 1;
  219. width: 100%;
  220. overflow: auto;
  221. display: flex;
  222. flex-direction: column;
  223. padding: 0 12px 2px;
  224. transform: translateZ(0);
  225. .task-item {
  226. width: 100%;
  227. .task-shadow {
  228. margin: 5px 0 4px;
  229. padding: 8px;
  230. background-color: #ffffff;
  231. border-left: 2px solid #BF9F03;
  232. border-right: 2px solid #ffffff;
  233. color: #091e42;
  234. border-radius: 3px;
  235. cursor: pointer;
  236. box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  237. transition: all 0.3s;
  238. transform: scale(1);
  239. &:hover{
  240. box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.38);
  241. }
  242. &.p1 {
  243. border-left-color: #ff0000;
  244. }
  245. &.p2 {
  246. border-left-color: #BB9F35;
  247. }
  248. &.p3 {
  249. border-left-color: #449EDD;
  250. }
  251. &.p4 {
  252. border-left-color: #84A83B;
  253. }
  254. &.complete {
  255. .task-more {
  256. .task-status {
  257. color: #666666;
  258. }
  259. }
  260. }
  261. &.overdue {
  262. .task-title {
  263. font-weight: bold;
  264. }
  265. .task-more {
  266. .task-status {
  267. color: #ff0000;
  268. }
  269. }
  270. }
  271. &.newtask {
  272. transform: scale(1.5);
  273. }
  274. .task-title {
  275. font-size: 12px;
  276. color: #091e42;
  277. word-break: break-all;
  278. }
  279. .task-more {
  280. min-height: 30px;
  281. display: flex;
  282. align-items: flex-end;
  283. .task-status {
  284. color: #19be6b;
  285. font-size: 12px;
  286. flex: 1;
  287. }
  288. .task-userimg {
  289. width: 26px;
  290. height: 26px;
  291. img {
  292. object-fit: cover;
  293. width: 100%;
  294. height: 100%;
  295. border-radius: 50%;
  296. }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. .trigger-box {
  303. text-align: center;
  304. font-size: 16px;
  305. color: #666;
  306. width: 100%;
  307. position: absolute;
  308. top: 50%;
  309. transform: translate(0, -50%) scale(1);
  310. transition: all 0.3s;
  311. }
  312. }
  313. }
  314. }
  315. }
  316. </style>
  317. <script>
  318. import draggable from 'vuedraggable'
  319. import WHeader from "../components/WHeader";
  320. import WContent from "../components/WContent";
  321. import WLoading from "../components/WLoading";
  322. import ProjectAddTask from "../components/project/task/add";
  323. import ProjectTaskLists from "../components/project/task/lists";
  324. import ProjectTaskFiles from "../components/project/task/files";
  325. import ProjectTaskLogs from "../components/project/task/logs";
  326. import ProjectComplete from "../components/project/complete";
  327. import ProjectUsers from "../components/project/users";
  328. import ProjectStatistics from "../components/project/statistics";
  329. export default {
  330. components: {
  331. ProjectStatistics,
  332. ProjectUsers,
  333. ProjectComplete,
  334. ProjectTaskLogs,
  335. ProjectTaskFiles, ProjectTaskLists, ProjectAddTask, draggable, WLoading, WContent, WHeader},
  336. data () {
  337. return {
  338. loadIng: 0,
  339. loadDetailed: false,
  340. projectid: 0,
  341. projectDetail: {},
  342. projectLabel: [],
  343. projectSimpleLabel: [],
  344. projectSortData: '',
  345. projectSortDisabled: false,
  346. projectDrawerShow: false,
  347. projectDrawerTab: 'lists',
  348. projectSettingDrawerShow: false,
  349. projectSettingDrawerTab: 'complete',
  350. }
  351. },
  352. mounted() {
  353. },
  354. activated() {
  355. this.projectid = this.$route.params.projectid;
  356. if (typeof this.$route.params.other === "object") {
  357. this.$set(this.projectDetail, 'title', $A.getObject(this.$route.params.other, 'title'))
  358. }
  359. },
  360. watch: {
  361. projectid(val) {
  362. if ($A.runNum(val) <= 0) {
  363. this.goBack();
  364. return;
  365. }
  366. this.projectDetail = {};
  367. this.projectLabel = [];
  368. this.projectSimpleLabel = [];
  369. this.getDetail();
  370. }
  371. },
  372. methods: {
  373. getDetail(successTip) {
  374. this.loadIng++;
  375. $A.aAjax({
  376. url: 'project/detail',
  377. data: {
  378. projectid: this.projectid,
  379. },
  380. complete: () => {
  381. this.loadIng--;
  382. this.loadDetailed = true;
  383. },
  384. error: () => {
  385. this.goBack();
  386. alert(this.$L('网络繁忙,请稍后再试!'));
  387. },
  388. success: (res) => {
  389. if (res.ret === 1) {
  390. this.projectDetail = res.data.project;
  391. this.projectLabel = res.data.label;
  392. this.projectSimpleLabel = res.data.simpleLabel;
  393. this.projectSortData = this.getProjectSort();
  394. if (successTip === true) {
  395. this.$Message.success(this.$L('刷新成功!'));
  396. }
  397. } else {
  398. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  399. this.goBack();
  400. }
  401. }
  402. });
  403. },
  404. getProjectSort() {
  405. let sortData = "",
  406. taskData = "";
  407. this.projectLabel.forEach((label) => {
  408. taskData = "";
  409. label.taskLists.forEach((task) => {
  410. if (taskData) taskData+= "-";
  411. taskData+= task.id;
  412. });
  413. if (sortData) sortData+= ";";
  414. sortData+= label.id + ":" + taskData;
  415. });
  416. return sortData;
  417. },
  418. handleLabel(event, labelDetail) {
  419. switch (event) {
  420. case 'refresh': {
  421. this.refreshLabel(labelDetail);
  422. break;
  423. }
  424. case 'rename': {
  425. this.renameLabel(labelDetail);
  426. break;
  427. }
  428. case 'delete': {
  429. this.deleteLabel(labelDetail);
  430. break;
  431. }
  432. }
  433. },
  434. refreshLabel(item) {
  435. this.$set(item, 'loadIng', true);
  436. $A.aAjax({
  437. url: 'project/task/lists',
  438. data: {
  439. projectid: this.projectid,
  440. labelid: item.id,
  441. },
  442. complete: () => {
  443. this.$set(item, 'loadIng', false);
  444. },
  445. error: () => {
  446. window.location.reload();
  447. },
  448. success: (res) => {
  449. if (res.ret === 1) {
  450. this.$set(item, 'taskLists', res.data.lists);
  451. } else {
  452. window.location.reload();
  453. }
  454. }
  455. });
  456. },
  457. renameLabel(item) {
  458. this.renameValue = "";
  459. this.$Modal.confirm({
  460. render: (h) => {
  461. return h('div', [
  462. h('div', {
  463. style: {
  464. fontSize: '16px',
  465. fontWeight: '500',
  466. marginBottom: '20px',
  467. }
  468. }, '重命名列表'),
  469. h('Input', {
  470. props: {
  471. value: this.renameValue,
  472. autofocus: true,
  473. placeholder: '请输入新的列表名称'
  474. },
  475. on: {
  476. input: (val) => {
  477. this.renameValue = val;
  478. }
  479. }
  480. })
  481. ])
  482. },
  483. loading: true,
  484. onOk: () => {
  485. if (this.renameValue) {
  486. this.$set(item, 'loadIng', true);
  487. let title = this.renameValue;
  488. $A.aAjax({
  489. url: 'project/label/rename',
  490. data: {
  491. projectid: this.projectid,
  492. labelid: item.id,
  493. title: title,
  494. },
  495. complete: () => {
  496. this.$set(item, 'loadIng', false);
  497. },
  498. error: () => {
  499. this.$Modal.remove();
  500. alert(this.$L('网络繁忙,请稍后再试!'));
  501. },
  502. success: (res) => {
  503. this.$Modal.remove();
  504. this.$set(item, 'title', title);
  505. setTimeout(() => {
  506. if (res.ret === 1) {
  507. this.$Message.success(res.msg);
  508. } else {
  509. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  510. }
  511. }, 350);
  512. }
  513. });
  514. } else {
  515. this.$Modal.remove();
  516. }
  517. },
  518. });
  519. },
  520. deleteLabel(item) {
  521. let redTip = item.taskLists.length > 0 ? '<div style="color:red;font-weight:500">注:将同时删除列表下所有任务</div>' : '';
  522. this.$Modal.confirm({
  523. title: '删除列表',
  524. content: '<div>你确定要删除此列表吗?</div>' + redTip,
  525. loading: true,
  526. onOk: () => {
  527. $A.aAjax({
  528. url: 'project/label/delete',
  529. data: {
  530. projectid: this.projectid,
  531. labelid: item.id,
  532. },
  533. error: () => {
  534. this.$Modal.remove();
  535. alert(this.$L('网络繁忙,请稍后再试!'));
  536. },
  537. success: (res) => {
  538. this.$Modal.remove();
  539. this.projectLabel.some((label, index) => {
  540. if (label.id == item.id) {
  541. this.projectLabel.splice(index, 1);
  542. this.projectSortData = this.getProjectSort();
  543. return true;
  544. }
  545. });
  546. setTimeout(() => {
  547. if (res.ret === 1) {
  548. this.$Message.success(res.msg);
  549. } else {
  550. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  551. }
  552. }, 350);
  553. }
  554. });
  555. }
  556. });
  557. },
  558. addLabel() {
  559. this.labelValue = "";
  560. this.$Modal.confirm({
  561. render: (h) => {
  562. return h('div', [
  563. h('div', {
  564. style: {
  565. fontSize: '16px',
  566. fontWeight: '500',
  567. marginBottom: '20px',
  568. }
  569. }, '添加列表'),
  570. h('Input', {
  571. props: {
  572. value: this.labelValue,
  573. autofocus: true,
  574. placeholder: '请输入列表名称'
  575. },
  576. on: {
  577. input: (val) => {
  578. this.labelValue = val;
  579. }
  580. }
  581. })
  582. ])
  583. },
  584. loading: true,
  585. onOk: () => {
  586. if (this.labelValue) {
  587. $A.aAjax({
  588. url: 'project/label/add',
  589. data: {
  590. projectid: this.projectid,
  591. title: this.labelValue
  592. },
  593. error: () => {
  594. this.$Modal.remove();
  595. alert(this.$L('网络繁忙,请稍后再试!'));
  596. },
  597. success: (res) => {
  598. this.$Modal.remove();
  599. this.projectLabel.push(res.data);
  600. this.projectSortData = this.getProjectSort();
  601. setTimeout(() => {
  602. if (res.ret === 1) {
  603. this.$Message.success(res.msg);
  604. } else {
  605. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  606. }
  607. }, 350);
  608. }
  609. });
  610. } else {
  611. this.$Modal.remove();
  612. }
  613. },
  614. });
  615. },
  616. addTaskSuccess(taskDetail, label) {
  617. if (label.taskLists instanceof Array) {
  618. taskDetail.isNewtask = true;
  619. label.taskLists.unshift(taskDetail);
  620. this.$nextTick(() => {
  621. this.$set(taskDetail, 'isNewtask', false);
  622. });
  623. } else {
  624. this.refreshLabel(label);
  625. }
  626. },
  627. openProjectDrawer(tab) {
  628. this.projectDrawerTab = tab;
  629. this.projectDrawerShow = true;
  630. },
  631. openProjectSettingDrawer(tab) {
  632. this.projectSettingDrawerTab = tab;
  633. this.projectSettingDrawerShow = true;
  634. },
  635. projectSortUpdate(isLabel) {
  636. let oldSort = this.projectSortData;
  637. let newSort = this.getProjectSort();
  638. if (oldSort == newSort) {
  639. return;
  640. }
  641. this.projectSortData = newSort;
  642. this.projectSortDisabled = true;
  643. this.loadIng++;
  644. $A.aAjax({
  645. url: 'project/sort',
  646. data: {
  647. projectid: this.projectid,
  648. oldsort: oldSort,
  649. newsort: newSort,
  650. label: isLabel === true ? 1 : 0
  651. },
  652. complete: () => {
  653. this.projectSortDisabled = false;
  654. this.loadIng--;
  655. },
  656. error: () => {
  657. this.getDetail();
  658. alert(this.$L('网络繁忙,请稍后再试!'));
  659. },
  660. success: (res) => {
  661. if (res.ret === 1) {
  662. this.$Message.success(res.msg);
  663. } else {
  664. this.getDetail();
  665. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  666. }
  667. }
  668. });
  669. },
  670. },
  671. }
  672. </script>