panel.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. <template>
  2. <div class="w-main project-panel">
  3. <v-title>{{$L('项目面板')}}-{{$L('轻量级的团队在线协作')}}</v-title>
  4. <div class="w-nav">
  5. <div class="nav-row">
  6. <div class="w-nav-left">
  7. <div class="page-nav-left">
  8. <span class="bold">{{projectDetail.title}}</span>
  9. <div v-if="loadIng > 0" class="page-nav-loading"><w-loading></w-loading></div>
  10. <div v-else class="page-nav-refresh"><em @click="getDetail(true)">{{$L('刷新')}}</em></div>
  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> {{$L('任务列表')}}</span>
  16. <span class="ft hover" :class="{active:projectGanttShow}" @click="projectGanttShow=!projectGanttShow"><i class="ft icon">&#59141;</i> {{$L('甘特图')}}</span>
  17. <span class="ft hover" @click="openProjectDrawer('files')"><i class="ft icon">&#xE701;</i> {{$L('文件列表')}}</span>
  18. <span class="ft hover" @click="openProjectDrawer('logs')"><i class="ft icon">&#xE753;</i> {{$L('项目动态')}}</span>
  19. <span class="ft hover" @click="openProjectSettingDrawer('setting')"><i class="ft icon">&#xE7A7;</i> {{$L('设置')}}</span>
  20. </div>
  21. </div>
  22. </div>
  23. <w-content>
  24. <draggable
  25. v-model="projectLabel"
  26. class="label-box"
  27. draggable=".label-draggable"
  28. :style="{visibility: projectGanttShow ? 'hidden' : 'visible'}"
  29. :animation="150"
  30. :disabled="projectSortDisabled"
  31. @sort="projectSortUpdate(true)">
  32. <div v-if="projectLabel.length > 0" v-for="label in projectLabel" :key="label.id" class="label-item label-draggable">
  33. <div class="label-body">
  34. <div class="title-box">
  35. <div v-if="label.loadIng === true" class="title-loading">
  36. <w-loading></w-loading>
  37. </div>
  38. <h2>{{label.title}}</h2>
  39. <Dropdown trigger="click" @on-click="handleLabel($event, label)" transfer>
  40. <Icon type="ios-more"/>
  41. <DropdownMenu slot="list">
  42. <Dropdown-item name="refresh">{{$L('刷新列表')}}</Dropdown-item>
  43. <Dropdown-item name="rename">{{$L('重命名')}}</Dropdown-item>
  44. <Dropdown-item name="delete">{{$L('删除')}}</Dropdown-item>
  45. </DropdownMenu>
  46. </Dropdown>
  47. </div>
  48. <draggable
  49. v-model="label.taskLists"
  50. class="task-box"
  51. group="task"
  52. draggable=".task-draggable"
  53. :animation="150"
  54. :disabled="projectSortDisabled"
  55. @sort="projectSortUpdate(false)"
  56. @remove="projectSortUpdate(false)">
  57. <div v-for="task in label.taskLists" :key="task.id" class="task-item task-draggable">
  58. <div class="task-shadow" :class="[
  59. 'p'+task.level,
  60. task.complete ? 'complete' : '',
  61. task.overdue ? 'overdue' : '',
  62. task.isNewtask === true ? 'newtask' : ''
  63. ]" @click="openTaskModal(task)">
  64. <div class="task-title">{{task.title}}</div>
  65. <div class="task-more">
  66. <div v-if="task.overdue" class="task-status">{{$L('已超期')}}</div>
  67. <div v-else-if="task.complete" class="task-status">{{$L('已完成')}}</div>
  68. <div v-else class="task-status">{{$L('未完成')}}</div>
  69. <Tooltip class="task-userimg" :content="task.nickname || task.username" transfer><img :src="task.userimg"/></Tooltip>
  70. </div>
  71. </div>
  72. </div>
  73. <div slot="footer">
  74. <project-add-task :placeholder='`${$L("添加任务至")}"${label.title}"`' :projectid="label.projectid" :labelid="label.id" @on-add-success="addTaskSuccess($event, label)"></project-add-task>
  75. </div>
  76. </draggable>
  77. </div>
  78. </div>
  79. <div v-if="loadDetailed" slot="footer" class="label-item label-create" @click="addLabel">
  80. <div class="label-body">
  81. <div class="trigger-box ft hover"><i class="ft icon">&#xE8C8;</i>{{$L('添加一个新列表')}}</div>
  82. </div>
  83. </div>
  84. </draggable>
  85. <project-gantt v-if="projectGanttShow" @on-close="projectGanttShow=false" :projectLabel="projectLabel"></project-gantt>
  86. </w-content>
  87. <WDrawer v-model="projectDrawerShow" maxWidth="1080">
  88. <Tabs v-if="projectDrawerShow" v-model="projectDrawerTab">
  89. <TabPane :label="$L('任务列表')" name="lists">
  90. <project-task-lists :canload="projectDrawerShow && projectDrawerTab == 'lists'" :projectid="projectid" :labelLists="projectSimpleLabel"></project-task-lists>
  91. </TabPane>
  92. <TabPane :label="$L('文件列表')" name="files">
  93. <project-task-files :canload="projectDrawerShow && projectDrawerTab == 'files'" :projectid="projectid"></project-task-files>
  94. </TabPane>
  95. <TabPane :label="$L('项目动态')" name="logs">
  96. <project-task-logs :canload="projectDrawerShow && projectDrawerTab == 'logs'" :projectid="projectid"></project-task-logs>
  97. </TabPane>
  98. </Tabs>
  99. </WDrawer>
  100. <WDrawer v-model="projectSettingDrawerShow" maxWidth="1000">
  101. <Tabs v-if="projectSettingDrawerShow" v-model="projectSettingDrawerTab">
  102. <TabPane :label="$L('项目设置')" name="setting">
  103. <project-setting :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'setting'" :projectid="projectid" @on-change="getDetail"></project-setting>
  104. </TabPane>
  105. <TabPane :label="$L('已归档任务')" name="archived">
  106. <project-archived :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'archived'" :projectid="projectid"></project-archived>
  107. </TabPane>
  108. <TabPane :label="$L('项目统计')" name="statistics">
  109. <project-statistics ref="statistics" :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'statistics'" :projectid="projectid"></project-statistics>
  110. </TabPane>
  111. <TabPane :label="$L('成员管理')" name="member">
  112. <project-users :canload="projectSettingDrawerShow && projectSettingDrawerTab == 'member'" :projectid="projectid"></project-users>
  113. </TabPane>
  114. </Tabs>
  115. </WDrawer>
  116. </div>
  117. </template>
  118. <style lang="scss">
  119. #project-panel-enter-textarea {
  120. background: transparent;
  121. background: none;
  122. outline: none;
  123. border: 0;
  124. resize: none;
  125. padding: 0;
  126. margin: 8px 0;
  127. line-height: 22px;
  128. border-radius: 0;
  129. color: rgba(0, 0, 0, 0.85);
  130. &:focus {
  131. border-color: transparent;
  132. box-shadow: none;
  133. }
  134. }
  135. </style>
  136. <style lang="scss" scoped>
  137. .project-panel {
  138. .label-box {
  139. display: flex;
  140. flex-direction: row;
  141. align-items: flex-start;
  142. justify-content: flex-start;
  143. flex-wrap: nowrap;
  144. overflow-x: auto;
  145. overflow-y: hidden;
  146. -webkit-overflow-scrolling: touch;
  147. width: 100%;
  148. height: 100%;
  149. padding: 15px;
  150. transform: translateZ(0);
  151. .label-item {
  152. flex-grow: 0;
  153. flex-shrink: 0;
  154. flex-basis: auto;
  155. height: 100%;
  156. padding-right: 15px;
  157. &.label-create {
  158. cursor: pointer;
  159. &:hover {
  160. .trigger-box {
  161. transform: translate(0, -50%) scale(1.1);
  162. }
  163. }
  164. }
  165. .label-body {
  166. width: 300px;
  167. height: 100%;
  168. border-radius: 0.15rem;
  169. background-color: #ebecf0;
  170. overflow: hidden;
  171. position: relative;
  172. display: flex;
  173. flex-direction: column;
  174. .title-box {
  175. padding: 0 12px;
  176. font-weight: bold;
  177. color: #666666;
  178. position: relative;
  179. cursor: move;
  180. display: flex;
  181. align-items: center;
  182. width: 100%;
  183. height: 42px;
  184. .title-loading {
  185. width: 16px;
  186. height: 16px;
  187. margin-right: 6px;
  188. }
  189. h2 {
  190. flex: 1;
  191. font-size: 16px;
  192. overflow: hidden;
  193. text-overflow: ellipsis;
  194. white-space: nowrap;
  195. }
  196. i {
  197. font-weight: 500;
  198. font-size: 18px;
  199. height: 100%;
  200. line-height: 42px;
  201. width: 42px;
  202. text-align: right;
  203. cursor: pointer;
  204. }
  205. }
  206. .task-box {
  207. flex: 1;
  208. width: 100%;
  209. overflow: auto;
  210. display: flex;
  211. flex-direction: column;
  212. padding: 0 12px 2px;
  213. transform: translateZ(0);
  214. .task-item {
  215. width: 100%;
  216. .task-shadow {
  217. margin: 5px 0 4px;
  218. padding: 8px;
  219. background-color: #ffffff;
  220. border-left: 2px solid #BF9F03;
  221. border-right: 2px solid #ffffff;
  222. color: #091e42;
  223. border-radius: 3px;
  224. cursor: pointer;
  225. box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  226. transition: all 0.3s;
  227. transform: scale(1);
  228. &:hover{
  229. box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.38);
  230. }
  231. &.p1 {
  232. border-left-color: #ff0000;
  233. }
  234. &.p2 {
  235. border-left-color: #BB9F35;
  236. }
  237. &.p3 {
  238. border-left-color: #449EDD;
  239. }
  240. &.p4 {
  241. border-left-color: #84A83B;
  242. }
  243. &.complete {
  244. border-left-color: #c1c1c1;
  245. .task-title {
  246. color: #666666;
  247. text-decoration: line-through;
  248. }
  249. .task-more {
  250. .task-status {
  251. color: #666666;
  252. }
  253. }
  254. }
  255. &.overdue {
  256. .task-title {
  257. font-weight: bold;
  258. }
  259. .task-more {
  260. .task-status {
  261. color: #ff0000;
  262. }
  263. }
  264. }
  265. &.newtask {
  266. transform: scale(1.5);
  267. }
  268. .task-title {
  269. font-size: 12px;
  270. color: #091e42;
  271. word-break: break-all;
  272. }
  273. .task-more {
  274. min-height: 30px;
  275. display: flex;
  276. align-items: flex-end;
  277. .task-status {
  278. color: #19be6b;
  279. font-size: 12px;
  280. flex: 1;
  281. }
  282. .task-userimg {
  283. width: 26px;
  284. height: 26px;
  285. img {
  286. object-fit: cover;
  287. width: 100%;
  288. height: 100%;
  289. border-radius: 50%;
  290. }
  291. }
  292. }
  293. }
  294. }
  295. }
  296. .trigger-box {
  297. text-align: center;
  298. font-size: 16px;
  299. color: #666;
  300. width: 100%;
  301. position: absolute;
  302. top: 50%;
  303. transform: translate(0, -50%) scale(1);
  304. transition: all 0.3s;
  305. }
  306. }
  307. }
  308. }
  309. }
  310. </style>
  311. <script>
  312. import draggable from 'vuedraggable'
  313. import WContent from "../../components/WContent";
  314. import ProjectAddTask from "../../components/project/task/add";
  315. import ProjectTaskLists from "../../components/project/task/lists";
  316. import ProjectTaskFiles from "../../components/project/task/files";
  317. import ProjectTaskLogs from "../../components/project/task/logs";
  318. import ProjectArchived from "../../components/project/archived";
  319. import ProjectUsers from "../../components/project/users";
  320. import ProjectStatistics from "../../components/project/statistics";
  321. import WDrawer from "../../components/iview/WDrawer";
  322. import ProjectGantt from "../../components/project/gantt/index";
  323. import ProjectSetting from "../../components/project/setting";
  324. export default {
  325. components: {
  326. ProjectSetting,
  327. ProjectGantt,
  328. WDrawer,
  329. ProjectStatistics,
  330. ProjectUsers,
  331. ProjectArchived,
  332. ProjectTaskLogs,
  333. ProjectTaskFiles, ProjectTaskLists, ProjectAddTask, draggable, WContent},
  334. data () {
  335. return {
  336. loadIng: 0,
  337. loadDetailed: false,
  338. projectid: 0,
  339. projectDetail: {},
  340. projectLabel: [],
  341. projectSimpleLabel: [],
  342. projectSortData: '',
  343. projectSortDisabled: false,
  344. projectDrawerShow: false,
  345. projectDrawerTab: 'lists',
  346. projectSettingDrawerShow: false,
  347. projectSettingDrawerTab: 'setting',
  348. projectGanttShow: false,
  349. routeName: '',
  350. }
  351. },
  352. mounted() {
  353. this.routeName = this.$route.name;
  354. $A.setOnTaskInfoListener('pages/project-panel',(act, detail) => {
  355. if (detail.projectid != this.projectid) {
  356. return;
  357. }
  358. //
  359. switch (act) {
  360. case 'addlabel': // 添加分类
  361. let tempLists = this.projectLabel.filter((res) => { return res.id == detail.labelid });
  362. if (tempLists.length == 0) {
  363. this.projectLabel.push(Object.assign(detail, {id: detail.labelid}));
  364. this.projectSortData = this.getProjectSort();
  365. }
  366. return;
  367. case 'deletelabel': // 删除分类
  368. this.projectLabel.some((label, index) => {
  369. if (label.id == detail.labelid) {
  370. this.projectLabel.splice(index, 1);
  371. this.projectSortData = this.getProjectSort();
  372. return true;
  373. }
  374. });
  375. return;
  376. case 'deleteproject': // 删除项目
  377. return;
  378. case "labelsort": // 调整分类排序
  379. case "tasksort": // 调整任务排序
  380. if (detail.__modifyUsername != $A.getUserName()) {
  381. if (this.routeName == this.$route.name) {
  382. this.$Modal.confirm({
  383. title: this.$L("更新提示"),
  384. content: this.$L('团队成员(%)调整了%,<br/>更新时间:%。<br/><br/>点击【确定】加载最新数据。', detail.nickname, this.$L(act == 'labelsort' ? '分类排序' : '任务排序'), $A.formatDate("Y-m-d H:i:s", detail.time)),
  385. onOk: () => {
  386. this.getDetail(true);
  387. }
  388. });
  389. } else {
  390. this.getDetail(true);
  391. }
  392. }
  393. return;
  394. }
  395. //
  396. this.projectLabel.forEach((label) => {
  397. label.taskLists.some((task, i) => {
  398. if (task.id == detail.id) {
  399. label.taskLists.splice(i, 1, detail);
  400. return true;
  401. }
  402. });
  403. });
  404. //
  405. switch (act) {
  406. case "delete": // 删除任务
  407. case "archived": // 归档
  408. this.projectLabel.forEach((label) => {
  409. label.taskLists.some((task, i) => {
  410. if (task.id == detail.id) {
  411. label.taskLists.splice(i, 1,);
  412. return true;
  413. }
  414. });
  415. });
  416. this.projectSortData = this.getProjectSort();
  417. break;
  418. case "create": // 创建任务
  419. this.projectLabel.some((label) => {
  420. if (label.id == detail.labelid) {
  421. let tempLists = label.taskLists.filter((res) => { return res.id == detail.id });
  422. if (tempLists.length == 0) {
  423. detail.isNewtask = true;
  424. label.taskLists.unshift(detail);
  425. this.$nextTick(() => {
  426. this.$set(detail, 'isNewtask', false);
  427. });
  428. }
  429. return true;
  430. }
  431. });
  432. break;
  433. case "unarchived": // 取消归档
  434. this.projectLabel.forEach((label) => {
  435. if (label.id == detail.labelid) {
  436. let index = label.taskLists.length;
  437. label.taskLists.some((task, i) => {
  438. if (detail.inorder > task.inorder || (detail.inorder == task.inorder && detail.id > task.id)) {
  439. index = i;
  440. return true;
  441. }
  442. });
  443. label.taskLists.splice(index, 0, detail);
  444. }
  445. });
  446. this.projectSortData = this.getProjectSort();
  447. break;
  448. }
  449. }, true);
  450. },
  451. activated() {
  452. this.projectid = this.$route.params.projectid;
  453. if (typeof this.$route.params.other === "object") {
  454. this.$set(this.projectDetail, 'title', $A.getObject(this.$route.params.other, 'title'));
  455. }
  456. if (this.$route.params.statistics === '已完成') {
  457. this.projectSettingDrawerTab = 'statistics';
  458. this.projectSettingDrawerShow = true;
  459. this.$nextTick(() => {
  460. this.$refs.statistics.setTaskType('已完成');
  461. });
  462. }
  463. },
  464. deactivated() {
  465. if ($A.getToken() === false) {
  466. this.projectid = 0;
  467. }
  468. this.projectGanttShow = false;
  469. this.projectDrawerShow = false;
  470. this.projectSettingDrawerShow = false;
  471. },
  472. watch: {
  473. projectid(val) {
  474. if ($A.runNum(val) <= 0) {
  475. return;
  476. }
  477. this.projectDetail = {};
  478. this.projectLabel = [];
  479. this.projectSimpleLabel = [];
  480. this.getDetail();
  481. }
  482. },
  483. methods: {
  484. getDetail(successTip) {
  485. this.loadIng++;
  486. $A.apiAjax({
  487. url: 'project/detail',
  488. data: {
  489. projectid: this.projectid,
  490. },
  491. complete: () => {
  492. this.loadIng--;
  493. this.loadDetailed = true;
  494. },
  495. error: () => {
  496. this.goBack({name:'project'});
  497. alert(this.$L('网络繁忙,请稍后再试!'));
  498. },
  499. success: (res) => {
  500. if (res.ret === 1) {
  501. this.projectDetail = res.data.project;
  502. this.projectLabel = res.data.label;
  503. this.projectSimpleLabel = res.data.simpleLabel;
  504. this.projectSortData = this.getProjectSort();
  505. if (successTip === true) {
  506. this.$Message.success(this.$L('刷新成功!'));
  507. }
  508. } else {
  509. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  510. }
  511. }
  512. });
  513. },
  514. getProjectSort() {
  515. let sortData = "",
  516. taskData = "";
  517. this.projectLabel.forEach((label) => {
  518. taskData = "";
  519. label.taskLists.forEach((task) => {
  520. if (taskData) taskData+= "-";
  521. taskData+= task.id;
  522. });
  523. if (sortData) sortData+= ";";
  524. sortData+= label.id + ":" + taskData;
  525. });
  526. return sortData;
  527. },
  528. handleLabel(event, labelDetail) {
  529. switch (event) {
  530. case 'refresh': {
  531. this.refreshLabel(labelDetail);
  532. break;
  533. }
  534. case 'rename': {
  535. this.renameLabel(labelDetail);
  536. break;
  537. }
  538. case 'delete': {
  539. this.deleteLabel(labelDetail);
  540. break;
  541. }
  542. }
  543. },
  544. refreshLabel(item) {
  545. this.$set(item, 'loadIng', true);
  546. $A.apiAjax({
  547. url: 'project/task/lists',
  548. data: {
  549. projectid: this.projectid,
  550. labelid: item.id,
  551. },
  552. complete: () => {
  553. this.$set(item, 'loadIng', false);
  554. },
  555. error: () => {
  556. window.location.reload();
  557. },
  558. success: (res) => {
  559. if (res.ret === 1) {
  560. this.$set(item, 'taskLists', res.data.lists);
  561. } else {
  562. window.location.reload();
  563. }
  564. }
  565. });
  566. },
  567. renameLabel(item) {
  568. this.renameValue = "";
  569. this.$Modal.confirm({
  570. render: (h) => {
  571. return h('div', [
  572. h('div', {
  573. style: {
  574. fontSize: '16px',
  575. fontWeight: '500',
  576. marginBottom: '20px',
  577. }
  578. }, this.$L('重命名列表')),
  579. h('Input', {
  580. props: {
  581. value: this.renameValue,
  582. autofocus: true,
  583. placeholder: this.$L('请输入新的列表名称')
  584. },
  585. on: {
  586. input: (val) => {
  587. this.renameValue = val;
  588. }
  589. }
  590. })
  591. ])
  592. },
  593. loading: true,
  594. onOk: () => {
  595. if (this.renameValue) {
  596. this.$set(item, 'loadIng', true);
  597. let title = this.renameValue;
  598. $A.apiAjax({
  599. url: 'project/label/rename',
  600. data: {
  601. projectid: this.projectid,
  602. labelid: item.id,
  603. title: title,
  604. },
  605. complete: () => {
  606. this.$set(item, 'loadIng', false);
  607. },
  608. error: () => {
  609. this.$Modal.remove();
  610. alert(this.$L('网络繁忙,请稍后再试!'));
  611. },
  612. success: (res) => {
  613. this.$Modal.remove();
  614. this.$set(item, 'title', title);
  615. setTimeout(() => {
  616. if (res.ret === 1) {
  617. this.$Message.success(res.msg);
  618. } else {
  619. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  620. }
  621. }, 350);
  622. }
  623. });
  624. } else {
  625. this.$Modal.remove();
  626. }
  627. },
  628. });
  629. },
  630. deleteLabel(item) {
  631. let redTip = item.taskLists.length > 0 ? ('<div style="color:red;font-weight:500">' + this.$L('注:将同时删除列表下所有任务') + '</div>') : '';
  632. this.$Modal.confirm({
  633. title: this.$L('删除列表'),
  634. content: '<div>' + this.$L('你确定要删除此列表吗?') + '</div>' + redTip,
  635. loading: true,
  636. onOk: () => {
  637. $A.apiAjax({
  638. url: 'project/label/delete',
  639. data: {
  640. projectid: this.projectid,
  641. labelid: item.id,
  642. },
  643. error: () => {
  644. this.$Modal.remove();
  645. alert(this.$L('网络繁忙,请稍后再试!'));
  646. },
  647. success: (res) => {
  648. this.$Modal.remove();
  649. this.projectLabel.some((label, index) => {
  650. if (label.id == item.id) {
  651. this.projectLabel.splice(index, 1);
  652. this.projectSortData = this.getProjectSort();
  653. return true;
  654. }
  655. });
  656. setTimeout(() => {
  657. if (res.ret === 1) {
  658. this.$Message.success(res.msg);
  659. $A.triggerTaskInfoListener('deletelabel', {labelid: item.id, projectid: item.projectid});
  660. } else {
  661. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  662. }
  663. }, 350);
  664. }
  665. });
  666. }
  667. });
  668. },
  669. addLabel() {
  670. this.labelValue = "";
  671. this.$Modal.confirm({
  672. render: (h) => {
  673. return h('div', [
  674. h('div', {
  675. style: {
  676. fontSize: '16px',
  677. fontWeight: '500',
  678. marginBottom: '20px',
  679. }
  680. }, this.$L('添加列表')),
  681. h('Input', {
  682. props: {
  683. value: this.labelValue,
  684. autofocus: true,
  685. placeholder: this.$L('请输入列表名称')
  686. },
  687. on: {
  688. input: (val) => {
  689. this.labelValue = val;
  690. }
  691. }
  692. })
  693. ])
  694. },
  695. loading: true,
  696. onOk: () => {
  697. if (this.labelValue) {
  698. let data = {
  699. projectid: this.projectid,
  700. title: this.labelValue
  701. };
  702. $A.apiAjax({
  703. url: 'project/label/add',
  704. data: data,
  705. error: () => {
  706. this.$Modal.remove();
  707. alert(this.$L('网络繁忙,请稍后再试!'));
  708. },
  709. success: (res) => {
  710. this.$Modal.remove();
  711. this.projectLabel.push(res.data);
  712. this.projectSortData = this.getProjectSort();
  713. $A.triggerTaskInfoListener('addlabel', Object.assign(data, {labelid: res.data.id}));
  714. setTimeout(() => {
  715. if (res.ret === 1) {
  716. this.$Message.success(res.msg);
  717. } else {
  718. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  719. }
  720. }, 350);
  721. }
  722. });
  723. } else {
  724. this.$Modal.remove();
  725. }
  726. },
  727. });
  728. },
  729. addTaskSuccess(taskDetail, label) {
  730. if (label.taskLists instanceof Array) {
  731. taskDetail.isNewtask = true;
  732. label.taskLists.unshift(taskDetail);
  733. this.$nextTick(() => {
  734. this.$set(taskDetail, 'isNewtask', false);
  735. });
  736. } else {
  737. this.refreshLabel(label);
  738. }
  739. },
  740. openProjectDrawer(tab) {
  741. this.projectDrawerTab = tab;
  742. this.projectDrawerShow = true;
  743. },
  744. openProjectSettingDrawer(tab) {
  745. this.projectSettingDrawerTab = tab;
  746. this.projectSettingDrawerShow = true;
  747. },
  748. projectSortUpdate(isLabel) {
  749. let oldSort = this.projectSortData;
  750. let newSort = this.getProjectSort();
  751. if (oldSort == newSort) {
  752. return;
  753. }
  754. this.projectSortData = newSort;
  755. this.projectSortDisabled = true;
  756. this.loadIng++;
  757. $A.apiAjax({
  758. url: 'project/sort',
  759. data: {
  760. projectid: this.projectid,
  761. oldsort: oldSort,
  762. newsort: newSort,
  763. label: isLabel === true ? 1 : 0
  764. },
  765. complete: () => {
  766. this.projectSortDisabled = false;
  767. this.loadIng--;
  768. },
  769. error: () => {
  770. this.getDetail();
  771. alert(this.$L('网络繁忙,请稍后再试!'));
  772. },
  773. success: (res) => {
  774. if (res.ret === 1) {
  775. this.$Message.success(res.msg);
  776. $A.triggerTaskInfoListener(isLabel ? 'labelsort' : 'tasksort', { projectid: this.projectid, nickname: $A.getNickName(), time: Math.round(new Date().getTime()/1000) });
  777. } else {
  778. this.getDetail();
  779. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  780. }
  781. }
  782. });
  783. },
  784. openTaskModal(taskDetail) {
  785. this.taskDetail(taskDetail);
  786. },
  787. },
  788. }
  789. </script>