project-panel.vue 25 KB

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