project-panel.vue 26 KB

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