project-panel.vue 25 KB

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