project-panel.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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: this.$route.params.id,
  268. projectDetail: {},
  269. projectLabel: [],
  270. }
  271. },
  272. mounted() {
  273. if ($A.runNum(this.projectid) <= 0) {
  274. this.goBack();
  275. return;
  276. }
  277. this.getDetail();
  278. },
  279. computed: {
  280. },
  281. watch: {
  282. },
  283. methods: {
  284. getDetail() {
  285. this.loadIng++;
  286. $A.aAjax({
  287. url: 'project/detail',
  288. data: {
  289. projectid: this.projectid,
  290. },
  291. complete: () => {
  292. this.loadIng--;
  293. this.loadDetailed = true;
  294. },
  295. error: () => {
  296. this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
  297. this.goBack();
  298. },
  299. success: (res) => {
  300. if (res.ret === 1) {
  301. this.projectDetail = res.data.project;
  302. this.projectLabel = res.data.label;
  303. } else {
  304. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  305. this.goBack();
  306. }
  307. }
  308. });
  309. },
  310. handleLabel(event, labelDetail) {
  311. switch (event) {
  312. case 'rename': {
  313. this.renameLabel(labelDetail);
  314. break;
  315. }
  316. case 'delete': {
  317. this.deleteLabel(labelDetail);
  318. break;
  319. }
  320. }
  321. },
  322. renameLabel(item) {
  323. this.renameValue = "";
  324. this.$Modal.confirm({
  325. render: (h) => {
  326. return h('div', [
  327. h('div', {
  328. style: {
  329. fontSize: '16px',
  330. fontWeight: '500',
  331. marginBottom: '20px',
  332. }
  333. }, '重命名列表'),
  334. h('Input', {
  335. props: {
  336. value: this.renameValue,
  337. autofocus: true,
  338. placeholder: '请输入新的列表名称'
  339. },
  340. on: {
  341. input: (val) => {
  342. this.renameValue = val;
  343. }
  344. }
  345. })
  346. ])
  347. },
  348. loading: true,
  349. onOk: () => {
  350. if (this.renameValue) {
  351. this.$set(item, 'loadIng', true);
  352. let title = this.renameValue;
  353. $A.aAjax({
  354. url: 'project/label/rename',
  355. data: {
  356. projectid: this.projectid,
  357. labelid: item.id,
  358. title: title,
  359. },
  360. complete: () => {
  361. this.$set(item, 'loadIng', false);
  362. },
  363. error: () => {
  364. this.$Modal.remove();
  365. this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
  366. },
  367. success: (res) => {
  368. this.$Modal.remove();
  369. this.$set(item, 'title', title);
  370. setTimeout(() => {
  371. if (res.ret === 1) {
  372. this.$Message.success(res.msg);
  373. } else {
  374. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  375. }
  376. }, 350);
  377. }
  378. });
  379. } else {
  380. this.$Modal.remove();
  381. }
  382. },
  383. });
  384. },
  385. deleteLabel(item) {
  386. let redTip = item.taskLists.length > 0 ? '<div style="color:red;font-weight:500">注:将同时删除列表下所有任务</div>' : '';
  387. this.$Modal.confirm({
  388. title: '删除列表',
  389. content: '<div>你确定要删除此列表吗?</div>' + redTip,
  390. loading: true,
  391. onOk: () => {
  392. $A.aAjax({
  393. url: 'project/label/delete',
  394. data: {
  395. projectid: this.projectid,
  396. labelid: item.id,
  397. },
  398. error: () => {
  399. this.$Modal.remove();
  400. this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
  401. },
  402. success: (res) => {
  403. this.$Modal.remove();
  404. this.projectLabel.some((label, index) => {
  405. if (label.id == item.id) {
  406. this.projectLabel.splice(index, 1);
  407. return true;
  408. }
  409. });
  410. setTimeout(() => {
  411. if (res.ret === 1) {
  412. this.$Message.success(res.msg);
  413. } else {
  414. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  415. }
  416. }, 350);
  417. }
  418. });
  419. }
  420. });
  421. },
  422. addLabel() {
  423. this.labelValue = "";
  424. this.$Modal.confirm({
  425. render: (h) => {
  426. return h('div', [
  427. h('div', {
  428. style: {
  429. fontSize: '16px',
  430. fontWeight: '500',
  431. marginBottom: '20px',
  432. }
  433. }, '添加列表'),
  434. h('Input', {
  435. props: {
  436. value: this.labelValue,
  437. autofocus: true,
  438. placeholder: '请输入列表名称'
  439. },
  440. on: {
  441. input: (val) => {
  442. this.labelValue = val;
  443. }
  444. }
  445. })
  446. ])
  447. },
  448. loading: true,
  449. onOk: () => {
  450. if (this.labelValue) {
  451. $A.aAjax({
  452. url: 'project/label/add',
  453. data: {
  454. projectid: this.projectid,
  455. title: this.labelValue
  456. },
  457. error: () => {
  458. this.$Modal.remove();
  459. this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
  460. },
  461. success: (res) => {
  462. this.$Modal.remove();
  463. this.projectLabel.push(res.data);
  464. setTimeout(() => {
  465. if (res.ret === 1) {
  466. this.$Message.success(res.msg);
  467. } else {
  468. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  469. }
  470. }, 350);
  471. }
  472. });
  473. } else {
  474. this.$Modal.remove();
  475. }
  476. },
  477. });
  478. },
  479. addTaskSuccess(label) {
  480. this.$set(label, 'loadIng', true);
  481. $A.aAjax({
  482. url: 'project/task/lists',
  483. data: {
  484. projectid: this.projectid,
  485. labelid: label.id,
  486. levelsort: 1
  487. },
  488. complete: () => {
  489. this.$set(label, 'loadIng', false);
  490. },
  491. error: () => {
  492. window.location.reload();
  493. },
  494. success: (res) => {
  495. if (res.ret === 1) {
  496. this.$set(label, 'taskLists', res.data.lists);
  497. } else {
  498. window.location.reload();
  499. }
  500. }
  501. });
  502. }
  503. },
  504. }
  505. </script>