panel.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  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. .task-title {
  245. color: #666666;
  246. text-decoration: line-through;
  247. }
  248. .task-more {
  249. .task-status {
  250. color: #666666;
  251. }
  252. }
  253. }
  254. &.overdue {
  255. .task-title {
  256. font-weight: bold;
  257. }
  258. .task-more {
  259. .task-status {
  260. color: #ff0000;
  261. }
  262. }
  263. }
  264. &.newtask {
  265. transform: scale(1.5);
  266. }
  267. .task-title {
  268. font-size: 12px;
  269. color: #091e42;
  270. word-break: break-all;
  271. }
  272. .task-more {
  273. min-height: 30px;
  274. display: flex;
  275. align-items: flex-end;
  276. .task-status {
  277. color: #19be6b;
  278. font-size: 12px;
  279. flex: 1;
  280. }
  281. .task-userimg {
  282. width: 26px;
  283. height: 26px;
  284. img {
  285. object-fit: cover;
  286. width: 100%;
  287. height: 100%;
  288. border-radius: 50%;
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. .trigger-box {
  296. text-align: center;
  297. font-size: 16px;
  298. color: #666;
  299. width: 100%;
  300. position: absolute;
  301. top: 50%;
  302. transform: translate(0, -50%) scale(1);
  303. transition: all 0.3s;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. </style>
  310. <script>
  311. import draggable from 'vuedraggable'
  312. import WContent from "../../components/WContent";
  313. import ProjectAddTask from "../../components/project/task/add";
  314. import ProjectTaskLists from "../../components/project/task/lists";
  315. import ProjectTaskFiles from "../../components/project/task/files";
  316. import ProjectTaskLogs from "../../components/project/task/logs";
  317. import ProjectArchived from "../../components/project/archived";
  318. import ProjectUsers from "../../components/project/users";
  319. import ProjectStatistics from "../../components/project/statistics";
  320. import WDrawer from "../../components/iview/WDrawer";
  321. import ProjectGantt from "../../components/project/gantt/index";
  322. import ProjectSetting from "../../components/project/setting";
  323. export default {
  324. components: {
  325. ProjectSetting,
  326. ProjectGantt,
  327. WDrawer,
  328. ProjectStatistics,
  329. ProjectUsers,
  330. ProjectArchived,
  331. ProjectTaskLogs,
  332. ProjectTaskFiles, ProjectTaskLists, ProjectAddTask, draggable, WContent},
  333. data () {
  334. return {
  335. loadIng: 0,
  336. loadDetailed: false,
  337. projectid: 0,
  338. projectDetail: {},
  339. projectLabel: [],
  340. projectSimpleLabel: [],
  341. projectSortData: '',
  342. projectSortDisabled: false,
  343. projectDrawerShow: false,
  344. projectDrawerTab: 'lists',
  345. projectSettingDrawerShow: false,
  346. projectSettingDrawerTab: 'setting',
  347. projectGanttShow: false,
  348. routeName: '',
  349. }
  350. },
  351. mounted() {
  352. this.routeName = this.$route.name;
  353. $A.setOnTaskInfoListener('pages/project-panel',(act, detail) => {
  354. if (detail.projectid != this.projectid) {
  355. return;
  356. }
  357. //
  358. switch (act) {
  359. case 'addlabel': // 添加分类
  360. let tempLists = this.projectLabel.filter((res) => { return res.id == detail.labelid });
  361. if (tempLists.length == 0) {
  362. this.projectLabel.push(Object.assign(detail, {id: detail.labelid}));
  363. this.projectSortData = this.getProjectSort();
  364. }
  365. return;
  366. case 'deletelabel': // 删除分类
  367. this.projectLabel.some((label, index) => {
  368. if (label.id == detail.labelid) {
  369. this.projectLabel.splice(index, 1);
  370. this.projectSortData = this.getProjectSort();
  371. return true;
  372. }
  373. });
  374. return;
  375. case 'deleteproject': // 删除项目
  376. return;
  377. case "labelsort": // 调整分类排序
  378. case "tasksort": // 调整任务排序
  379. if (detail.__modifyUsername != $A.getUserName()) {
  380. if (this.routeName == this.$route.name) {
  381. this.$Modal.confirm({
  382. title: this.$L("更新提示"),
  383. content: this.$L('团队成员(%)调整了%,<br/>更新时间:%。<br/><br/>点击【确定】加载最新数据。', detail.nickname, this.$L(act == 'labelsort' ? '分类排序' : '任务排序'), $A.formatDate("Y-m-d H:i:s", detail.time)),
  384. onOk: () => {
  385. this.getDetail(true);
  386. }
  387. });
  388. } else {
  389. this.getDetail(true);
  390. }
  391. }
  392. return;
  393. }
  394. //
  395. this.projectLabel.forEach((label) => {
  396. label.taskLists.some((task, i) => {
  397. if (task.id == detail.id) {
  398. label.taskLists.splice(i, 1, detail);
  399. return true;
  400. }
  401. });
  402. });
  403. //
  404. switch (act) {
  405. case "delete": // 删除任务
  406. case "archived": // 归档
  407. this.projectLabel.forEach((label) => {
  408. label.taskLists.some((task, i) => {
  409. if (task.id == detail.id) {
  410. label.taskLists.splice(i, 1,);
  411. return true;
  412. }
  413. });
  414. });
  415. this.projectSortData = this.getProjectSort();
  416. break;
  417. case "create": // 创建任务
  418. this.projectLabel.some((label) => {
  419. if (label.id == detail.labelid) {
  420. let tempLists = label.taskLists.filter((res) => { return res.id == detail.id });
  421. if (tempLists.length == 0) {
  422. detail.isNewtask = true;
  423. label.taskLists.unshift(detail);
  424. this.$nextTick(() => {
  425. this.$set(detail, 'isNewtask', false);
  426. });
  427. }
  428. return true;
  429. }
  430. });
  431. break;
  432. case "unarchived": // 取消归档
  433. this.projectLabel.forEach((label) => {
  434. if (label.id == detail.labelid) {
  435. let index = label.taskLists.length;
  436. label.taskLists.some((task, i) => {
  437. if (detail.inorder > task.inorder || (detail.inorder == task.inorder && detail.id > task.id)) {
  438. index = i;
  439. return true;
  440. }
  441. });
  442. label.taskLists.splice(index, 0, detail);
  443. }
  444. });
  445. this.projectSortData = this.getProjectSort();
  446. break;
  447. }
  448. }, true);
  449. },
  450. activated() {
  451. this.projectid = this.$route.params.projectid;
  452. if (typeof this.$route.params.other === "object") {
  453. this.$set(this.projectDetail, 'title', $A.getObject(this.$route.params.other, 'title'));
  454. }
  455. if (this.$route.params.statistics === '已完成') {
  456. this.projectSettingDrawerTab = 'statistics';
  457. this.projectSettingDrawerShow = true;
  458. this.$nextTick(() => {
  459. this.$refs.statistics.setTaskType('已完成');
  460. });
  461. }
  462. },
  463. deactivated() {
  464. if ($A.getToken() === false) {
  465. this.projectid = 0;
  466. }
  467. this.projectGanttShow = false;
  468. this.projectDrawerShow = false;
  469. this.projectSettingDrawerShow = false;
  470. },
  471. watch: {
  472. projectid(val) {
  473. if ($A.runNum(val) <= 0) {
  474. return;
  475. }
  476. this.projectDetail = {};
  477. this.projectLabel = [];
  478. this.projectSimpleLabel = [];
  479. this.getDetail();
  480. }
  481. },
  482. methods: {
  483. getDetail(successTip) {
  484. this.loadIng++;
  485. $A.apiAjax({
  486. url: 'project/detail',
  487. data: {
  488. projectid: this.projectid,
  489. },
  490. complete: () => {
  491. this.loadIng--;
  492. this.loadDetailed = true;
  493. },
  494. error: () => {
  495. this.goBack({name:'project'});
  496. alert(this.$L('网络繁忙,请稍后再试!'));
  497. },
  498. success: (res) => {
  499. if (res.ret === 1) {
  500. this.projectDetail = res.data.project;
  501. this.projectLabel = res.data.label;
  502. this.projectSimpleLabel = res.data.simpleLabel;
  503. this.projectSortData = this.getProjectSort();
  504. if (successTip === true) {
  505. this.$Message.success(this.$L('刷新成功!'));
  506. }
  507. } else {
  508. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  509. }
  510. }
  511. });
  512. },
  513. getProjectSort() {
  514. let sortData = "",
  515. taskData = "";
  516. this.projectLabel.forEach((label) => {
  517. taskData = "";
  518. label.taskLists.forEach((task) => {
  519. if (taskData) taskData+= "-";
  520. taskData+= task.id;
  521. });
  522. if (sortData) sortData+= ";";
  523. sortData+= label.id + ":" + taskData;
  524. });
  525. return sortData;
  526. },
  527. handleLabel(event, labelDetail) {
  528. switch (event) {
  529. case 'refresh': {
  530. this.refreshLabel(labelDetail);
  531. break;
  532. }
  533. case 'rename': {
  534. this.renameLabel(labelDetail);
  535. break;
  536. }
  537. case 'delete': {
  538. this.deleteLabel(labelDetail);
  539. break;
  540. }
  541. }
  542. },
  543. refreshLabel(item) {
  544. this.$set(item, 'loadIng', true);
  545. $A.apiAjax({
  546. url: 'project/task/lists',
  547. data: {
  548. projectid: this.projectid,
  549. labelid: item.id,
  550. },
  551. complete: () => {
  552. this.$set(item, 'loadIng', false);
  553. },
  554. error: () => {
  555. window.location.reload();
  556. },
  557. success: (res) => {
  558. if (res.ret === 1) {
  559. this.$set(item, 'taskLists', res.data.lists);
  560. } else {
  561. window.location.reload();
  562. }
  563. }
  564. });
  565. },
  566. renameLabel(item) {
  567. this.renameValue = "";
  568. this.$Modal.confirm({
  569. render: (h) => {
  570. return h('div', [
  571. h('div', {
  572. style: {
  573. fontSize: '16px',
  574. fontWeight: '500',
  575. marginBottom: '20px',
  576. }
  577. }, this.$L('重命名列表')),
  578. h('Input', {
  579. props: {
  580. value: this.renameValue,
  581. autofocus: true,
  582. placeholder: this.$L('请输入新的列表名称')
  583. },
  584. on: {
  585. input: (val) => {
  586. this.renameValue = val;
  587. }
  588. }
  589. })
  590. ])
  591. },
  592. loading: true,
  593. onOk: () => {
  594. if (this.renameValue) {
  595. this.$set(item, 'loadIng', true);
  596. let title = this.renameValue;
  597. $A.apiAjax({
  598. url: 'project/label/rename',
  599. data: {
  600. projectid: this.projectid,
  601. labelid: item.id,
  602. title: title,
  603. },
  604. complete: () => {
  605. this.$set(item, 'loadIng', false);
  606. },
  607. error: () => {
  608. this.$Modal.remove();
  609. alert(this.$L('网络繁忙,请稍后再试!'));
  610. },
  611. success: (res) => {
  612. this.$Modal.remove();
  613. this.$set(item, 'title', title);
  614. setTimeout(() => {
  615. if (res.ret === 1) {
  616. this.$Message.success(res.msg);
  617. } else {
  618. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  619. }
  620. }, 350);
  621. }
  622. });
  623. } else {
  624. this.$Modal.remove();
  625. }
  626. },
  627. });
  628. },
  629. deleteLabel(item) {
  630. let redTip = item.taskLists.length > 0 ? ('<div style="color:red;font-weight:500">' + this.$L('注:将同时删除列表下所有任务') + '</div>') : '';
  631. this.$Modal.confirm({
  632. title: this.$L('删除列表'),
  633. content: '<div>' + this.$L('你确定要删除此列表吗?') + '</div>' + redTip,
  634. loading: true,
  635. onOk: () => {
  636. $A.apiAjax({
  637. url: 'project/label/delete',
  638. data: {
  639. projectid: this.projectid,
  640. labelid: item.id,
  641. },
  642. error: () => {
  643. this.$Modal.remove();
  644. alert(this.$L('网络繁忙,请稍后再试!'));
  645. },
  646. success: (res) => {
  647. this.$Modal.remove();
  648. this.projectLabel.some((label, index) => {
  649. if (label.id == item.id) {
  650. this.projectLabel.splice(index, 1);
  651. this.projectSortData = this.getProjectSort();
  652. return true;
  653. }
  654. });
  655. setTimeout(() => {
  656. if (res.ret === 1) {
  657. this.$Message.success(res.msg);
  658. $A.triggerTaskInfoListener('deletelabel', {labelid: item.id, projectid: item.projectid});
  659. } else {
  660. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  661. }
  662. }, 350);
  663. }
  664. });
  665. }
  666. });
  667. },
  668. addLabel() {
  669. this.labelValue = "";
  670. this.$Modal.confirm({
  671. render: (h) => {
  672. return h('div', [
  673. h('div', {
  674. style: {
  675. fontSize: '16px',
  676. fontWeight: '500',
  677. marginBottom: '20px',
  678. }
  679. }, this.$L('添加列表')),
  680. h('Input', {
  681. props: {
  682. value: this.labelValue,
  683. autofocus: true,
  684. placeholder: this.$L('请输入列表名称')
  685. },
  686. on: {
  687. input: (val) => {
  688. this.labelValue = val;
  689. }
  690. }
  691. })
  692. ])
  693. },
  694. loading: true,
  695. onOk: () => {
  696. if (this.labelValue) {
  697. let data = {
  698. projectid: this.projectid,
  699. title: this.labelValue
  700. };
  701. $A.apiAjax({
  702. url: 'project/label/add',
  703. data: data,
  704. error: () => {
  705. this.$Modal.remove();
  706. alert(this.$L('网络繁忙,请稍后再试!'));
  707. },
  708. success: (res) => {
  709. this.$Modal.remove();
  710. this.projectLabel.push(res.data);
  711. this.projectSortData = this.getProjectSort();
  712. $A.triggerTaskInfoListener('addlabel', Object.assign(data, {labelid: res.data.id}));
  713. setTimeout(() => {
  714. if (res.ret === 1) {
  715. this.$Message.success(res.msg);
  716. } else {
  717. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  718. }
  719. }, 350);
  720. }
  721. });
  722. } else {
  723. this.$Modal.remove();
  724. }
  725. },
  726. });
  727. },
  728. addTaskSuccess(taskDetail, label) {
  729. if (label.taskLists instanceof Array) {
  730. taskDetail.isNewtask = true;
  731. label.taskLists.unshift(taskDetail);
  732. this.$nextTick(() => {
  733. this.$set(taskDetail, 'isNewtask', false);
  734. });
  735. } else {
  736. this.refreshLabel(label);
  737. }
  738. },
  739. openProjectDrawer(tab) {
  740. this.projectDrawerTab = tab;
  741. this.projectDrawerShow = true;
  742. },
  743. openProjectSettingDrawer(tab) {
  744. this.projectSettingDrawerTab = tab;
  745. this.projectSettingDrawerShow = true;
  746. },
  747. projectSortUpdate(isLabel) {
  748. let oldSort = this.projectSortData;
  749. let newSort = this.getProjectSort();
  750. if (oldSort == newSort) {
  751. return;
  752. }
  753. this.projectSortData = newSort;
  754. this.projectSortDisabled = true;
  755. this.loadIng++;
  756. $A.apiAjax({
  757. url: 'project/sort',
  758. data: {
  759. projectid: this.projectid,
  760. oldsort: oldSort,
  761. newsort: newSort,
  762. label: isLabel === true ? 1 : 0
  763. },
  764. complete: () => {
  765. this.projectSortDisabled = false;
  766. this.loadIng--;
  767. },
  768. error: () => {
  769. this.getDetail();
  770. alert(this.$L('网络繁忙,请稍后再试!'));
  771. },
  772. success: (res) => {
  773. if (res.ret === 1) {
  774. this.$Message.success(res.msg);
  775. $A.triggerTaskInfoListener(isLabel ? 'labelsort' : 'tasksort', { projectid: this.projectid, nickname: $A.getNickName(), time: Math.round(new Date().getTime()/1000) });
  776. } else {
  777. this.getDetail();
  778. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  779. }
  780. }
  781. });
  782. },
  783. openTaskModal(taskDetail) {
  784. this.taskDetail(taskDetail);
  785. },
  786. },
  787. }
  788. </script>