project.vue 29 KB

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