project-panel.vue 23 KB

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