project.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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" @click.stop="openComplete(item)"><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" :pageSize="listPageSize" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[20,40,60,100]" placement="top" transfer 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 Vue from 'vue'
  267. import TagInput from '../components/TagInput'
  268. Vue.component('TagInput', TagInput)
  269. import WContent from "../components/WContent";
  270. import ProjectArchived from "../components/project/archived";
  271. import ProjectUsers from "../components/project/users";
  272. import ProjectStatistics from "../components/project/statistics";
  273. import ProjectMyFavor from "../components/project/my/favor";
  274. import ProjectMyJoin from "../components/project/my/join";
  275. import ProjectMyManage from "../components/project/my/manage";
  276. import Project from "../mixins/project";
  277. import WDrawer from "../components/iview/WDrawer";
  278. export default {
  279. components: {
  280. WDrawer,
  281. ProjectMyManage,
  282. ProjectMyJoin,
  283. ProjectMyFavor, ProjectStatistics, ProjectUsers, ProjectArchived, WContent},
  284. mixins: [
  285. Project
  286. ],
  287. data () {
  288. return {
  289. loadIng: 0,
  290. userInfo: {},
  291. addShow: false,
  292. formAdd: {
  293. title: '',
  294. labels: [],
  295. template: 0,
  296. },
  297. ruleAdd: {},
  298. labelLists: [],
  299. lists: [],
  300. listPage: 1,
  301. listTotal: 0,
  302. listPageSize: 20,
  303. projectDrawerShow: false,
  304. projectDrawerTab: 'archived',
  305. projectListDrawerShow: false,
  306. projectListDrawerTab: 'myjoin',
  307. handleProjectId: 0,
  308. }
  309. },
  310. created() {
  311. this.labelLists = [{
  312. label: this.$L('空白模板'),
  313. value: [],
  314. }, {
  315. label: this.$L('软件开发'),
  316. value: [this.$L('产品规划'),this.$L('前端开发'),this.$L('后端开发'),this.$L('测试'),this.$L('发布'),this.$L('其它')],
  317. }, {
  318. label: this.$L('产品开发'),
  319. value: [this.$L('产品计划'), this.$L('正在设计'), this.$L('正在研发'), this.$L('测试'), this.$L('准备发布'), this.$L('发布成功')],
  320. }];
  321. this.ruleAdd = {
  322. title: [
  323. { required: true, message: this.$L('请填写项目名称!'), trigger: 'change' },
  324. { type: 'string', min: 2, message: this.$L('项目名称至少2个字!'), trigger: 'change' }
  325. ]
  326. };
  327. },
  328. mounted() {
  329. this.getLists(true);
  330. this.userInfo = $A.getUserInfo((res, isLogin) => {
  331. if (this.userInfo.id != res.id) {
  332. this.userInfo = res;
  333. isLogin && this.getLists(true);
  334. } else {
  335. this.userInfo = res;
  336. }
  337. }, false);
  338. //
  339. $A.setOnTaskInfoListener('pages/project',(act, detail) => {
  340. switch (act) {
  341. case 'deleteproject': // 删除项目
  342. case 'deletelabel': // 删除分类
  343. this.lists.some((item) => {
  344. if (item.id == detail.projectid) {
  345. this.getLists(true);
  346. return true;
  347. }
  348. });
  349. break;
  350. case "complete": // 标记完成
  351. this.lists.some((item) => {
  352. if (item.id == detail.projectid) {
  353. item.complete++;
  354. item.unfinished--;
  355. return true;
  356. }
  357. });
  358. break;
  359. case "unfinished": // 标记未完成
  360. this.lists.some((item) => {
  361. if (item.id == detail.projectid) {
  362. item.complete--;
  363. item.unfinished++;
  364. return true;
  365. }
  366. });
  367. break;
  368. }
  369. }, true);
  370. },
  371. deactivated() {
  372. this.addShow = false;
  373. this.projectDrawerShow = false;
  374. this.projectListDrawerShow = false;
  375. },
  376. methods: {
  377. setPage(page) {
  378. this.listPage = page;
  379. this.getLists();
  380. },
  381. setPageSize(size) {
  382. if (Math.max($A.runNum(this.listPageSize), 20) != size) {
  383. this.listPageSize = size;
  384. this.getLists();
  385. }
  386. },
  387. getLists(resetLoad) {
  388. if (resetLoad === true) {
  389. this.listPage = 1;
  390. }
  391. this.loadIng++;
  392. $A.apiAjax({
  393. url: 'project/lists',
  394. data: {
  395. page: Math.max(this.listPage, 1),
  396. pagesize: Math.max($A.runNum(this.listPageSize), 20),
  397. },
  398. complete: () => {
  399. this.loadIng--;
  400. },
  401. success: (res) => {
  402. if (res.ret === 1) {
  403. this.lists = res.data.lists;
  404. this.listTotal = res.data.total;
  405. }else{
  406. this.lists = [];
  407. this.listTotal = 0;
  408. }
  409. }
  410. });
  411. },
  412. addLabels() {
  413. this.labelsValue = "";
  414. this.$Modal.confirm({
  415. render: (h) => {
  416. return h('div', [
  417. h('div', {
  418. style: {
  419. fontSize: '16px',
  420. fontWeight: '500',
  421. marginBottom: '20px',
  422. }
  423. }, this.$L('添加流程')),
  424. h('TagInput', {
  425. props: {
  426. value: this.labelsValue,
  427. autofocus: true,
  428. placeholder: this.$L('请输入流程名称,多个可用英文逗号分隔。')
  429. },
  430. on: {
  431. input: (val) => {
  432. this.labelsValue = val;
  433. }
  434. }
  435. })
  436. ])
  437. },
  438. onOk: () => {
  439. if (this.labelsValue) {
  440. let array = $A.trim(this.labelsValue).split(",");
  441. array.forEach((name) => {
  442. if ($A.trim(name)) {
  443. this.formAdd.labels.push($A.trim(name));
  444. }
  445. });
  446. }
  447. },
  448. })
  449. },
  450. onAdd() {
  451. this.$refs.add.validate((valid) => {
  452. if (valid) {
  453. this.loadIng++;
  454. $A.apiAjax({
  455. url: 'project/add',
  456. data: this.formAdd,
  457. complete: () => {
  458. this.loadIng--;
  459. },
  460. success: (res) => {
  461. if (res.ret === 1) {
  462. this.addShow = false;
  463. this.$Message.success(res.msg);
  464. this.$refs.add.resetFields();
  465. this.$set(this.formAdd, 'template', 0);
  466. //
  467. this.getLists(true);
  468. } else {
  469. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  470. }
  471. }
  472. });
  473. }
  474. });
  475. },
  476. openComplete(item) {
  477. if (item.complete > 0) {
  478. this.openProject(item.id, item, '已完成')
  479. } else {
  480. this.handleProject('open', item);
  481. }
  482. },
  483. handleProject(event, item) {
  484. if (item) {
  485. this.handleProjectId = item.id;
  486. }
  487. switch (event) {
  488. case 'favor': {
  489. this.favorProject('add', item.id);
  490. break;
  491. }
  492. case 'rename': {
  493. this.renameProject(item);
  494. break;
  495. }
  496. case 'transfer': {
  497. this.transferProject(item);
  498. break;
  499. }
  500. case 'delete': {
  501. this.deleteProject(item.id, () => {
  502. this.getLists();
  503. });
  504. break;
  505. }
  506. case 'out': {
  507. this.outProject(item.id, () => {
  508. this.getLists();
  509. });
  510. break;
  511. }
  512. case 'open': {
  513. this.openProject(item.id, item);
  514. break;
  515. }
  516. case 'archived':
  517. case 'member':
  518. case 'statistics': {
  519. this.projectDrawerShow = true;
  520. this.projectDrawerTab = event;
  521. break;
  522. }
  523. case 'myjoin':
  524. case 'myfavor':
  525. case 'mycreate': {
  526. this.projectListDrawerShow = true;
  527. this.projectListDrawerTab = event;
  528. break;
  529. }
  530. }
  531. },
  532. renameProject(item) {
  533. this.renameValue = "";
  534. this.$Modal.confirm({
  535. render: (h) => {
  536. return h('div', [
  537. h('div', {
  538. style: {
  539. fontSize: '16px',
  540. fontWeight: '500',
  541. marginBottom: '20px',
  542. }
  543. }, this.$L('重命名项目')),
  544. h('Input', {
  545. props: {
  546. value: this.renameValue,
  547. autofocus: true,
  548. placeholder: this.$L('请输入新的项目名称')
  549. },
  550. on: {
  551. input: (val) => {
  552. this.renameValue = val;
  553. }
  554. }
  555. })
  556. ])
  557. },
  558. loading: true,
  559. onOk: () => {
  560. if (this.renameValue) {
  561. this.$set(item, 'loadIng', true);
  562. let title = this.renameValue;
  563. $A.apiAjax({
  564. url: 'project/rename',
  565. data: {
  566. projectid: item.id,
  567. title: title,
  568. },
  569. complete: () => {
  570. this.$set(item, 'loadIng', false);
  571. },
  572. error: () => {
  573. this.$Modal.remove();
  574. alert(this.$L('网络繁忙,请稍后再试!'));
  575. },
  576. success: (res) => {
  577. this.$Modal.remove();
  578. this.$set(item, 'title', title);
  579. setTimeout(() => {
  580. if (res.ret === 1) {
  581. this.$Message.success(res.msg);
  582. } else {
  583. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  584. }
  585. }, 350);
  586. }
  587. });
  588. } else {
  589. this.$Modal.remove();
  590. }
  591. },
  592. });
  593. },
  594. transferProject(item) {
  595. this.transferValue = "";
  596. this.$Modal.confirm({
  597. render: (h) => {
  598. return h('div', [
  599. h('div', {
  600. style: {
  601. fontSize: '16px',
  602. fontWeight: '500',
  603. marginBottom: '20px',
  604. }
  605. }, this.$L('移交项目')),
  606. h('UserInput', {
  607. props: {
  608. value: this.transferValue,
  609. nousername: item.username,
  610. placeholder: this.$L('请输入昵称/用户名搜索')
  611. },
  612. on: {
  613. input: (val) => {
  614. this.transferValue = val;
  615. }
  616. }
  617. })
  618. ])
  619. },
  620. loading: true,
  621. onOk: () => {
  622. if (this.transferValue) {
  623. this.$set(item, 'loadIng', true);
  624. let username = this.transferValue;
  625. $A.apiAjax({
  626. url: 'project/transfer',
  627. data: {
  628. projectid: item.id,
  629. username: username,
  630. },
  631. complete: () => {
  632. this.$set(item, 'loadIng', false);
  633. },
  634. error: () => {
  635. this.$Modal.remove();
  636. alert(this.$L('网络繁忙,请稍后再试!'));
  637. },
  638. success: (res) => {
  639. this.$Modal.remove();
  640. this.getLists();
  641. setTimeout(() => {
  642. if (res.ret === 1) {
  643. this.$Message.success(res.msg);
  644. } else {
  645. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  646. }
  647. }, 350);
  648. }
  649. });
  650. } else {
  651. this.$Modal.remove();
  652. }
  653. },
  654. });
  655. },
  656. },
  657. }
  658. </script>