project-panel.vue 25 KB

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