project.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <template>
  2. <div class="w-main project">
  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="hover" @click="addShow=true"><i class="ft icon">&#xE740;</i> {{$L('新建项目')}}</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="getLists(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="handleProject('myjoin', null)"><i class="ft icon">&#xE75E;</i> {{$L('参与的项目')}}</span>
  16. <span class="ft hover" @click="handleProject('myfavor', null)"><i class="ft icon">&#xE720;</i> {{$L('收藏的项目')}}</span>
  17. <span class="ft hover" @click="handleProject('mycreate', null)"><i class="ft icon">&#xE764;</i> {{$L('我管理的项目')}}</span>
  18. </div>
  19. </div>
  20. </div>
  21. <w-content>
  22. <!-- 列表 -->
  23. <ul class="project-list">
  24. <li v-for="item in lists">
  25. <div class="project-item">
  26. <div class="project-head">
  27. <div v-if="item.loadIng === true" class="project-loading">
  28. <w-loading></w-loading>
  29. </div>
  30. <div class="project-title" @click="handleProject('open', item)">{{item.title}}</div>
  31. <div class="project-setting">
  32. <Dropdown class="right-info" trigger="click" @on-click="handleProject($event, item)" transfer>
  33. <Icon class="project-setting-icon" type="md-settings" size="16"/>
  34. <Dropdown-menu slot="list">
  35. <Dropdown-item name="open">{{$L('打开')}}</Dropdown-item>
  36. <Dropdown-item name="favor">{{$L('收藏')}}</Dropdown-item>
  37. <Dropdown-item v-if="item.isowner" name="rename">{{$L('重命名')}}</Dropdown-item>
  38. <Dropdown-item v-if="item.isowner" name="transfer">{{$L('移交项目')}}</Dropdown-item>
  39. <Dropdown-item v-if="item.isowner" name="delete">{{$L('删除')}}</Dropdown-item>
  40. <Dropdown-item v-else name="out">{{$L('退出')}}</Dropdown-item>
  41. </Dropdown-menu>
  42. </Dropdown>
  43. </div>
  44. </div>
  45. <div class="project-num" @click="handleProject('open', item)">
  46. <div class="project-complete"><em>{{item.complete}}</em>{{$L('已完成数')}}</div>
  47. <div class="project-num-line"></div>
  48. <div class="project-unfinished"><em>{{item.unfinished}}</em>{{$L('未完成数')}}</div>
  49. </div>
  50. <div class="project-bottom">
  51. <div class="project-iconbtn" @click.stop="handleProject('archived', item)">
  52. <Icon class="project-iconbtn-icon1" type="md-filing" size="24" />
  53. <div class="project-iconbtn-text">{{$L('已归档任务')}}</div>
  54. </div>
  55. <div class="project-iconbtn" @click.stop="handleProject('statistics', item)">
  56. <Icon class="project-iconbtn-icon3" type="md-stats" size="24" />
  57. <div class="project-iconbtn-text">{{$L('项目统计')}}</div>
  58. </div>
  59. <div class="project-iconbtn" @click.stop="handleProject('member', item)">
  60. <Icon class="project-iconbtn-icon2" type="md-people" size="24" />
  61. <div class="project-iconbtn-text">{{$L('成员管理')}}</div>
  62. </div>
  63. </div>
  64. </div>
  65. </li>
  66. </ul>
  67. <!-- 分页 -->
  68. <Page v-if="listTotal > 0" class="pageBox" :total="listTotal" :current="listPage" :disabled="loadIng > 0" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total></Page>
  69. </w-content>
  70. <Modal
  71. v-model="addShow"
  72. :title="$L('新建项目')"
  73. :closable="false"
  74. :mask-closable="false">
  75. <Form ref="add" :model="formAdd" :rules="ruleAdd" :label-width="80">
  76. <FormItem prop="title" :label="$L('项目名称')">
  77. <Input type="text" v-model="formAdd.title"></Input>
  78. </FormItem>
  79. <FormItem prop="labels" :label="$L('项目模板')">
  80. <Select v-model="formAdd.template" @on-change="(res) => {$set(formAdd, 'labels', labelLists[res].value)}">
  81. <Option v-for="(item, index) in labelLists" :value="index" :key="index">{{ item.label }}</Option>
  82. </Select>
  83. </FormItem>
  84. <FormItem :label="$L('项目流程')">
  85. <div style="line-height:38px">
  86. <span v-for="(item, index) in formAdd.labels">
  87. <span v-if="index > 0">&gt;</span>
  88. <Tag @on-close="() => { formAdd.labels.splice(index, 1)}" closable size="large" color="primary">{{item}}</Tag>
  89. </span>
  90. </div>
  91. <div v-if="formAdd.labels.length > 0" style="margin-top:4px;"></div>
  92. <div style="margin-bottom:-16px">
  93. <Button icon="ios-add" type="dashed" @click="addLabels">{{$L('添加流程')}}</Button>
  94. </div>
  95. </FormItem>
  96. </Form>
  97. <div slot="footer">
  98. <Button type="default" @click="addShow=false">{{$L('取消')}}</Button>
  99. <Button type="primary" :loading="loadIng > 0" @click="onAdd">{{$L('添加')}}</Button>
  100. </div>
  101. </Modal>
  102. <WDrawer v-model="projectDrawerShow" maxWidth="1000">
  103. <Tabs v-if="projectDrawerShow" v-model="projectDrawerTab">
  104. <TabPane :label="$L('已归档任务')" name="archived">
  105. <project-archived :canload="projectDrawerShow && projectDrawerTab == 'archived'" :projectid="handleProjectId"></project-archived>
  106. </TabPane>
  107. <TabPane :label="$L('项目统计')" name="statistics">
  108. <project-statistics :canload="projectDrawerShow && projectDrawerTab == 'statistics'" :projectid="handleProjectId"></project-statistics>
  109. </TabPane>
  110. <TabPane :label="$L('成员管理')" name="member">
  111. <project-users :canload="projectDrawerShow && projectDrawerTab == 'member'" :projectid="handleProjectId"></project-users>
  112. </TabPane>
  113. </Tabs>
  114. </WDrawer>
  115. <WDrawer v-model="projectListDrawerShow" maxWidth="740">
  116. <Tabs v-if="projectListDrawerShow" v-model="projectListDrawerTab">
  117. <TabPane :label="$L('参与的项目')" name="myjoin">
  118. <project-my-join :canload="projectListDrawerShow && projectListDrawerTab == 'myjoin'"></project-my-join>
  119. </TabPane>
  120. <TabPane :label="$L('收藏的项目')" name="myfavor">
  121. <project-my-favor :canload="projectListDrawerShow && projectListDrawerTab == 'myfavor'"></project-my-favor>
  122. </TabPane>
  123. <TabPane :label="$L('管理的项目')" name="mycreate">
  124. <project-my-manage :canload="projectListDrawerShow && projectListDrawerTab == 'mycreate'"></project-my-manage>
  125. </TabPane>
  126. </Tabs>
  127. </WDrawer>
  128. </div>
  129. </template>
  130. <style lang="scss" scoped>
  131. .project {
  132. ul.project-list {
  133. padding: 5px;
  134. max-width: 2000px;
  135. li {
  136. float: left;
  137. width: 25%;
  138. display: flex;
  139. @media (max-width: 1400px) {
  140. width: 33.33%;
  141. }
  142. @media (max-width: 1080px) {
  143. width: 50%;
  144. }
  145. @media (max-width: 640px) {
  146. width: 100%;
  147. }
  148. .project-item {
  149. flex: 1;
  150. margin: 10px;
  151. width: 100%;
  152. height: 280px;
  153. padding: 20px;
  154. background-color: #ffffff;
  155. border-radius: 4px;
  156. display: flex;
  157. flex-direction: column;
  158. .project-head{
  159. display: flex;
  160. flex-direction: row;
  161. .project-loading {
  162. width: 18px;
  163. height: 18px;
  164. margin-right: 6px;
  165. margin-top: 3px;
  166. }
  167. .project-title{
  168. flex: 1;
  169. font-size: 16px;
  170. padding-right: 6px;
  171. overflow:hidden;
  172. text-overflow:ellipsis;
  173. white-space:nowrap;
  174. color: #333333;
  175. cursor: pointer;
  176. }
  177. .project-setting{
  178. width: 30px;
  179. text-align: right;
  180. .project-setting-icon {
  181. cursor: pointer;
  182. color: #333333;
  183. &:hover {
  184. color: #0396f2;
  185. }
  186. }
  187. }
  188. }
  189. .project-num {
  190. flex: 1;
  191. padding: 24px 0;
  192. display: flex;
  193. flex-direction: row;
  194. align-items: center;
  195. cursor: pointer;
  196. .project-complete,
  197. .project-unfinished {
  198. flex: 1;
  199. text-align: center;
  200. font-size: 14px;
  201. color: #999999;
  202. em {
  203. display: block;
  204. font-size: 32px;
  205. color: #0396f2;
  206. overflow: hidden;
  207. text-overflow: ellipsis;
  208. white-space: nowrap;
  209. max-width: 120px;
  210. margin: 0 auto;
  211. }
  212. }
  213. .project-num-line {
  214. width: 1px;
  215. height: 90%;
  216. background-color: #e8e8e8;
  217. }
  218. }
  219. .project-bottom {
  220. display: flex;
  221. flex-direction: row;
  222. align-items: center;
  223. border-top: 1px solid #efefef;
  224. padding: 6px 0;
  225. cursor: default;
  226. .project-iconbtn {
  227. flex: 1;
  228. text-align: center;
  229. cursor: pointer;
  230. &:hover {
  231. .project-iconbtn-text {
  232. color: #0396f2;
  233. }
  234. }
  235. .project-iconbtn-icon1 {
  236. margin: 12px 0;
  237. color: #ff7a7a;
  238. }
  239. .project-iconbtn-icon2 {
  240. margin: 12px 0;
  241. color: #764df8;
  242. }
  243. .project-iconbtn-icon3 {
  244. margin: 12px 0;
  245. color: #ffca65;
  246. }
  247. .project-iconbtn-text {
  248. color: #999999;
  249. }
  250. }
  251. }
  252. }
  253. }
  254. &:before,
  255. &:after {
  256. display: table;
  257. content: "";
  258. }
  259. &:after {
  260. clear: both;
  261. }
  262. }
  263. }
  264. </style>
  265. <script>
  266. import WContent from "../components/WContent";
  267. import ProjectArchived from "../components/project/archived";
  268. import ProjectUsers from "../components/project/users";
  269. import ProjectStatistics from "../components/project/statistics";
  270. import ProjectMyFavor from "../components/project/my/favor";
  271. import ProjectMyJoin from "../components/project/my/join";
  272. import ProjectMyManage from "../components/project/my/manage";
  273. import Project from "../mixins/project";
  274. import WDrawer from "../components/iview/WDrawer";
  275. export default {
  276. components: {
  277. WDrawer,
  278. ProjectMyManage,
  279. ProjectMyJoin,
  280. ProjectMyFavor, ProjectStatistics, ProjectUsers, ProjectArchived, WContent},
  281. mixins: [
  282. Project
  283. ],
  284. data () {
  285. return {
  286. loadIng: 0,
  287. userInfo: {},
  288. addShow: false,
  289. formAdd: {
  290. title: '',
  291. labels: [],
  292. template: 0,
  293. },
  294. ruleAdd: {},
  295. labelLists: [],
  296. lists: [],
  297. listPage: 1,
  298. listTotal: 0,
  299. projectDrawerShow: false,
  300. projectDrawerTab: 'archived',
  301. projectListDrawerShow: false,
  302. projectListDrawerTab: 'myjoin',
  303. handleProjectId: 0,
  304. }
  305. },
  306. created() {
  307. this.labelLists = [{
  308. label: this.$L('空白模板'),
  309. value: [],
  310. }, {
  311. label: this.$L('软件开发'),
  312. value: [this.$L('产品规划'),this.$L('前端开发'),this.$L('后端开发'),this.$L('测试'),this.$L('发布'),this.$L('其它')],
  313. }, {
  314. label: this.$L('产品开发'),
  315. value: [this.$L('产品计划'), this.$L('正在设计'), this.$L('正在研发'), this.$L('测试'), this.$L('准备发布'), this.$L('发布成功')],
  316. }];
  317. this.ruleAdd = {
  318. title: [
  319. { required: true, message: this.$L('请填写项目名称!'), trigger: 'change' },
  320. { type: 'string', min: 2, message: this.$L('项目名称至少2个字!'), trigger: 'change' }
  321. ]
  322. };
  323. },
  324. mounted() {
  325. this.getLists(true);
  326. this.userInfo = $A.getUserInfo((res, isLogin) => {
  327. if (this.userInfo.id != res.id) {
  328. this.userInfo = res;
  329. isLogin && this.getLists(true);
  330. }
  331. }, false);
  332. //
  333. $A.setOnTaskInfoListener('pages/project',(act, detail) => {
  334. switch (act) {
  335. case 'deleteproject': // 删除项目
  336. case 'deletelabel': // 删除分类
  337. this.lists.some((item) => {
  338. if (item.id == detail.projectid) {
  339. this.getLists(true);
  340. return true;
  341. }
  342. });
  343. break;
  344. case "complete": // 标记完成
  345. this.lists.some((item) => {
  346. if (item.id == detail.projectid) {
  347. item.complete++;
  348. item.unfinished--;
  349. return true;
  350. }
  351. });
  352. break;
  353. case "unfinished": // 标记未完成
  354. this.lists.some((item) => {
  355. if (item.id == detail.projectid) {
  356. item.complete--;
  357. item.unfinished++;
  358. return true;
  359. }
  360. });
  361. break;
  362. }
  363. }, true);
  364. },
  365. deactivated() {
  366. this.addShow = false;
  367. this.projectDrawerShow = false;
  368. this.projectListDrawerShow = false;
  369. },
  370. methods: {
  371. setPage(page) {
  372. this.listPage = page;
  373. this.getLists();
  374. },
  375. setPageSize(size) {
  376. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  377. this.listPageSize = size;
  378. this.getLists();
  379. }
  380. },
  381. getLists(resetLoad) {
  382. if (resetLoad === true) {
  383. this.listPage = 1;
  384. }
  385. this.loadIng++;
  386. $A.aAjax({
  387. url: 'project/lists',
  388. data: {
  389. page: Math.max(this.listPage, 1),
  390. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  391. },
  392. complete: () => {
  393. this.loadIng--;
  394. },
  395. success: (res) => {
  396. if (res.ret === 1) {
  397. this.lists = res.data.lists;
  398. this.listTotal = res.data.total;
  399. }else{
  400. this.lists = [];
  401. this.listTotal = 0;
  402. }
  403. }
  404. });
  405. },
  406. addLabels() {
  407. this.labelsValue = "";
  408. this.$Modal.confirm({
  409. render: (h) => {
  410. return h('div', [
  411. h('div', {
  412. style: {
  413. fontSize: '16px',
  414. fontWeight: '500',
  415. marginBottom: '20px',
  416. }
  417. }, this.$L('添加流程')),
  418. h('Input', {
  419. props: {
  420. value: this.labelsValue,
  421. autofocus: true,
  422. placeholder: this.$L('请输入流程名称,多个可用空格分隔。')
  423. },
  424. on: {
  425. input: (val) => {
  426. this.labelsValue = val;
  427. }
  428. }
  429. })
  430. ])
  431. },
  432. onOk: () => {
  433. if (this.labelsValue) {
  434. let array = $A.trim(this.labelsValue).split(" ");
  435. array.forEach((name) => {
  436. if ($A.trim(name)) {
  437. this.formAdd.labels.push($A.trim(name));
  438. }
  439. });
  440. }
  441. },
  442. })
  443. },
  444. onAdd() {
  445. this.$refs.add.validate((valid) => {
  446. if (valid) {
  447. this.loadIng++;
  448. $A.aAjax({
  449. url: 'project/add',
  450. data: this.formAdd,
  451. complete: () => {
  452. this.loadIng--;
  453. },
  454. success: (res) => {
  455. if (res.ret === 1) {
  456. this.addShow = false;
  457. this.$Message.success(res.msg);
  458. this.$refs.add.resetFields();
  459. this.$set(this.formAdd, 'template', 0);
  460. //
  461. this.getLists(true);
  462. } else {
  463. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  464. }
  465. }
  466. });
  467. }
  468. });
  469. },
  470. handleProject(event, item) {
  471. if (item) {
  472. this.handleProjectId = item.id;
  473. }
  474. switch (event) {
  475. case 'favor': {
  476. this.favorProject('add', item.id);
  477. break;
  478. }
  479. case 'rename': {
  480. this.renameProject(item);
  481. break;
  482. }
  483. case 'transfer': {
  484. this.transferProject(item);
  485. break;
  486. }
  487. case 'delete': {
  488. this.deleteProject(item.id, () => {
  489. this.getLists();
  490. });
  491. break;
  492. }
  493. case 'out': {
  494. this.outProject(item.id, () => {
  495. this.getLists();
  496. });
  497. break;
  498. }
  499. case 'open': {
  500. this.openProject(item.id, item);
  501. break;
  502. }
  503. case 'archived':
  504. case 'member':
  505. case 'statistics': {
  506. this.projectDrawerShow = true;
  507. this.projectDrawerTab = event;
  508. break;
  509. }
  510. case 'myjoin':
  511. case 'myfavor':
  512. case 'mycreate': {
  513. this.projectListDrawerShow = true;
  514. this.projectListDrawerTab = event;
  515. break;
  516. }
  517. }
  518. },
  519. renameProject(item) {
  520. this.renameValue = "";
  521. this.$Modal.confirm({
  522. render: (h) => {
  523. return h('div', [
  524. h('div', {
  525. style: {
  526. fontSize: '16px',
  527. fontWeight: '500',
  528. marginBottom: '20px',
  529. }
  530. }, this.$L('重命名项目')),
  531. h('Input', {
  532. props: {
  533. value: this.renameValue,
  534. autofocus: true,
  535. placeholder: this.$L('请输入新的项目名称')
  536. },
  537. on: {
  538. input: (val) => {
  539. this.renameValue = val;
  540. }
  541. }
  542. })
  543. ])
  544. },
  545. loading: true,
  546. onOk: () => {
  547. if (this.renameValue) {
  548. this.$set(item, 'loadIng', true);
  549. let title = this.renameValue;
  550. $A.aAjax({
  551. url: 'project/rename',
  552. data: {
  553. projectid: item.id,
  554. title: title,
  555. },
  556. complete: () => {
  557. this.$set(item, 'loadIng', false);
  558. },
  559. error: () => {
  560. this.$Modal.remove();
  561. alert(this.$L('网络繁忙,请稍后再试!'));
  562. },
  563. success: (res) => {
  564. this.$Modal.remove();
  565. this.$set(item, 'title', title);
  566. setTimeout(() => {
  567. if (res.ret === 1) {
  568. this.$Message.success(res.msg);
  569. } else {
  570. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  571. }
  572. }, 350);
  573. }
  574. });
  575. } else {
  576. this.$Modal.remove();
  577. }
  578. },
  579. });
  580. },
  581. transferProject(item) {
  582. this.transferValue = "";
  583. this.$Modal.confirm({
  584. render: (h) => {
  585. return h('div', [
  586. h('div', {
  587. style: {
  588. fontSize: '16px',
  589. fontWeight: '500',
  590. marginBottom: '20px',
  591. }
  592. }, this.$L('移交项目')),
  593. h('UserInput', {
  594. props: {
  595. value: this.transferValue,
  596. nousername: item.username,
  597. placeholder: this.$L('请输入昵称/用户名搜索')
  598. },
  599. on: {
  600. input: (val) => {
  601. this.transferValue = val;
  602. }
  603. }
  604. })
  605. ])
  606. },
  607. loading: true,
  608. onOk: () => {
  609. if (this.transferValue) {
  610. this.$set(item, 'loadIng', true);
  611. let username = this.transferValue;
  612. $A.aAjax({
  613. url: 'project/transfer',
  614. data: {
  615. projectid: item.id,
  616. username: username,
  617. },
  618. complete: () => {
  619. this.$set(item, 'loadIng', false);
  620. },
  621. error: () => {
  622. this.$Modal.remove();
  623. alert(this.$L('网络繁忙,请稍后再试!'));
  624. },
  625. success: (res) => {
  626. this.$Modal.remove();
  627. this.getLists();
  628. setTimeout(() => {
  629. if (res.ret === 1) {
  630. this.$Message.success(res.msg);
  631. } else {
  632. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  633. }
  634. }, 350);
  635. }
  636. });
  637. } else {
  638. this.$Modal.remove();
  639. }
  640. },
  641. });
  642. },
  643. },
  644. }
  645. </script>