project-panel.vue 22 KB

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