project-panel.vue 23 KB

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