project.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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. <div v-if="loadIng > 0" class="page-nav-loading"><w-loading></w-loading></div>
  10. <span class="ft hover" @click="addShow=true"><i class="ft icon">&#xE740;</i> {{$L('新建项目')}}</span>
  11. <div class="page-nav-refresh" @click="getLists(true)">刷新</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('member', item)">
  57. <Icon class="project-iconbtn-icon2" type="md-people" size="24" />
  58. <div class="project-iconbtn-text">成员管理</div>
  59. </div>
  60. <div class="project-iconbtn" @click.stop="handleProject('statistics', item)">
  61. <Icon class="project-iconbtn-icon3" type="md-stats" 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="member">
  109. <project-users :canload="projectDrawerShow && projectDrawerTab == 'member'" :projectid="handleProjectId"></project-users>
  110. </TabPane>
  111. <TabPane :label="$L('项目统计')" name="statistics">
  112. <project-statistics :canload="projectDrawerShow && projectDrawerTab == 'statistics'" :projectid="handleProjectId"></project-statistics>
  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. .page-nav-left {
  134. display: flex;
  135. flex-direction: row;
  136. align-items: center;
  137. min-width: 138px;
  138. &:hover {
  139. .page-nav-refresh {
  140. display: block;
  141. }
  142. }
  143. .page-nav-loading {
  144. width: 18px;
  145. height: 18px;
  146. margin-right: 6px;
  147. display: flex;
  148. }
  149. .page-nav-refresh {
  150. display: none;
  151. padding-right: 12px;
  152. color: #048be0;
  153. cursor: pointer;
  154. &:hover {
  155. text-decoration: underline;
  156. }
  157. }
  158. }
  159. ul.project-list {
  160. padding: 5px;
  161. max-width: 2000px;
  162. li {
  163. float: left;
  164. width: 25%;
  165. display: flex;
  166. @media (max-width: 1400px) {
  167. width: 33.33%;
  168. }
  169. @media (max-width: 1080px) {
  170. width: 50%;
  171. }
  172. @media (max-width: 640px) {
  173. width: 100%;
  174. }
  175. .project-item {
  176. flex: 1;
  177. margin: 10px;
  178. width: 100%;
  179. height: 280px;
  180. padding: 20px;
  181. background-color: #ffffff;
  182. border-radius: 4px;
  183. display: flex;
  184. flex-direction: column;
  185. .project-head{
  186. display: flex;
  187. flex-direction: row;
  188. .project-loading {
  189. width: 18px;
  190. height: 18px;
  191. margin-right: 6px;
  192. margin-top: 3px;
  193. }
  194. .project-title{
  195. flex: 1;
  196. font-size: 16px;
  197. padding-right: 6px;
  198. overflow:hidden;
  199. text-overflow:ellipsis;
  200. white-space:nowrap;
  201. color: #333333;
  202. cursor: pointer;
  203. }
  204. .project-setting{
  205. width: 30px;
  206. text-align: right;
  207. .project-setting-icon {
  208. cursor: pointer;
  209. color: #333333;
  210. &:hover {
  211. color: #0396f2;
  212. }
  213. }
  214. }
  215. }
  216. .project-num {
  217. flex: 1;
  218. padding: 24px 0;
  219. display: flex;
  220. flex-direction: row;
  221. align-items: center;
  222. cursor: pointer;
  223. .project-complete,
  224. .project-unfinished {
  225. flex: 1;
  226. text-align: center;
  227. font-size: 14px;
  228. color: #999999;
  229. em {
  230. display: block;
  231. font-size: 32px;
  232. color: #0396f2;
  233. overflow: hidden;
  234. text-overflow: ellipsis;
  235. white-space: nowrap;
  236. max-width: 120px;
  237. margin: 0 auto;
  238. }
  239. }
  240. .project-num-line {
  241. width: 1px;
  242. height: 90%;
  243. background-color: #e8e8e8;
  244. }
  245. }
  246. .project-bottom {
  247. display: flex;
  248. flex-direction: row;
  249. align-items: center;
  250. border-top: 1px solid #efefef;
  251. padding: 6px 0;
  252. cursor: default;
  253. .project-iconbtn {
  254. flex: 1;
  255. text-align: center;
  256. cursor: pointer;
  257. &:hover {
  258. .project-iconbtn-text {
  259. color: #0396f2;
  260. }
  261. }
  262. .project-iconbtn-icon1 {
  263. margin: 12px 0;
  264. color: #ff7a7a;
  265. }
  266. .project-iconbtn-icon2 {
  267. margin: 12px 0;
  268. color: #764df8;
  269. }
  270. .project-iconbtn-icon3 {
  271. margin: 12px 0;
  272. color: #ffca65;
  273. }
  274. .project-iconbtn-text {
  275. color: #999999;
  276. }
  277. }
  278. }
  279. }
  280. }
  281. &:before,
  282. &:after {
  283. display: table;
  284. content: "";
  285. }
  286. &:after {
  287. clear: both;
  288. }
  289. }
  290. }
  291. </style>
  292. <script>
  293. import WHeader from "../components/WHeader";
  294. import WContent from "../components/WContent";
  295. import WLoading from "../components/WLoading";
  296. import ProjectArchived from "../components/project/archived";
  297. import ProjectUsers from "../components/project/users";
  298. import ProjectStatistics from "../components/project/statistics";
  299. import ProjectMyFavor from "../components/project/my/favor";
  300. import ProjectMyJoin from "../components/project/my/join";
  301. import ProjectMyManage from "../components/project/my/manage";
  302. import Project from "../mixins/project";
  303. export default {
  304. components: {
  305. ProjectMyManage,
  306. ProjectMyJoin,
  307. ProjectMyFavor, ProjectStatistics, ProjectUsers, ProjectArchived, WLoading, WContent, WHeader},
  308. mixins: [
  309. Project
  310. ],
  311. data () {
  312. return {
  313. loadIng: 0,
  314. addShow: false,
  315. formAdd: {
  316. title: '',
  317. labels: [],
  318. template: 0,
  319. },
  320. ruleAdd: {},
  321. labelLists: [{
  322. label: '空白模板',
  323. value: [],
  324. }, {
  325. label: '软件开发',
  326. value: ['产品规划','前端开发','后端开发','测试','发布','其它'],
  327. }, {
  328. label: '产品开发',
  329. value: ['产品计划', '正在设计', '正在研发', '测试', '准备发布', '发布成功'],
  330. }],
  331. lists: [],
  332. listPage: 1,
  333. listTotal: 0,
  334. projectDrawerShow: false,
  335. projectDrawerTab: 'archived',
  336. projectListDrawerShow: false,
  337. projectListDrawerTab: 'myjoin',
  338. handleProjectId: 0,
  339. }
  340. },
  341. created() {
  342. this.ruleAdd = {
  343. title: [
  344. { required: true, message: this.$L('请填写项目名称!'), trigger: 'change' },
  345. { type: 'string', min: 2, message: this.$L('项目名称至少2个字!'), trigger: 'change' }
  346. ]
  347. };
  348. },
  349. mounted() {
  350. this.getLists(true);
  351. $A.setOnTaskInfoListener('pages/project',(act, detail) => {
  352. switch (act) {
  353. case 'deleteproject': // 删除项目
  354. case 'deletelabel': // 删除分类
  355. this.getLists(true);
  356. break;
  357. case "complete": // 标记完成
  358. this.lists.some((item) => {
  359. if (item.id == detail.projectid) {
  360. item.complete++;
  361. item.unfinished--;
  362. return true;
  363. }
  364. });
  365. break;
  366. case "unfinished": // 标记未完成
  367. this.lists.some((item) => {
  368. if (item.id == detail.projectid) {
  369. item.complete--;
  370. item.unfinished++;
  371. return true;
  372. }
  373. });
  374. break;
  375. }
  376. }, true);
  377. },
  378. deactivated() {
  379. this.addShow = false;
  380. this.projectDrawerShow = false;
  381. this.projectListDrawerShow = false;
  382. },
  383. methods: {
  384. setPage(page) {
  385. this.listPage = page;
  386. this.getLists();
  387. },
  388. setPageSize(size) {
  389. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  390. this.listPageSize = size;
  391. this.getLists();
  392. }
  393. },
  394. getLists(resetLoad) {
  395. if (resetLoad === true) {
  396. this.listPage = 1;
  397. }
  398. this.loadIng++;
  399. $A.aAjax({
  400. url: 'project/lists',
  401. data: {
  402. page: Math.max(this.listPage, 1),
  403. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  404. },
  405. complete: () => {
  406. this.loadIng--;
  407. },
  408. success: (res) => {
  409. if (res.ret === 1) {
  410. this.lists = res.data.lists;
  411. this.listTotal = res.data.total;
  412. }else{
  413. this.lists = [];
  414. this.listTotal = 0;
  415. }
  416. }
  417. });
  418. },
  419. addLabels() {
  420. this.labelsValue = "";
  421. this.$Modal.confirm({
  422. render: (h) => {
  423. return h('div', [
  424. h('div', {
  425. style: {
  426. fontSize: '16px',
  427. fontWeight: '500',
  428. marginBottom: '20px',
  429. }
  430. }, '添加流程'),
  431. h('Input', {
  432. props: {
  433. value: this.labelsValue,
  434. autofocus: true,
  435. placeholder: '请输入流程名称,多个可用空格分隔。'
  436. },
  437. on: {
  438. input: (val) => {
  439. this.labelsValue = val;
  440. }
  441. }
  442. })
  443. ])
  444. },
  445. onOk: () => {
  446. if (this.labelsValue) {
  447. let array = $A.trim(this.labelsValue).split(" ");
  448. array.forEach((name) => {
  449. if ($A.trim(name)) {
  450. this.formAdd.labels.push($A.trim(name));
  451. }
  452. });
  453. }
  454. },
  455. })
  456. },
  457. onAdd() {
  458. this.$refs.add.validate((valid) => {
  459. if (valid) {
  460. this.loadIng++;
  461. $A.aAjax({
  462. url: 'project/add',
  463. data: this.formAdd,
  464. complete: () => {
  465. this.loadIng--;
  466. },
  467. success: (res) => {
  468. if (res.ret === 1) {
  469. this.addShow = false;
  470. this.$Message.success(res.msg);
  471. this.$refs.add.resetFields();
  472. this.$set(this.formAdd, 'template', 0);
  473. //
  474. this.getLists(true);
  475. } else {
  476. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  477. }
  478. }
  479. });
  480. }
  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. }, '重命名项目'),
  544. h('Input', {
  545. props: {
  546. value: this.renameValue,
  547. autofocus: true,
  548. placeholder: '请输入新的项目名称'
  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.aAjax({
  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. }, '移交项目'),
  606. h('UseridInput', {
  607. props: {
  608. value: this.transferValue,
  609. placeholder: '请输入昵称/用户名搜索'
  610. },
  611. on: {
  612. input: (val) => {
  613. this.transferValue = val;
  614. }
  615. }
  616. })
  617. ])
  618. },
  619. loading: true,
  620. onOk: () => {
  621. if (this.transferValue) {
  622. this.$set(item, 'loadIng', true);
  623. let username = this.transferValue;
  624. $A.aAjax({
  625. url: 'project/transfer',
  626. data: {
  627. projectid: item.id,
  628. username: username,
  629. },
  630. complete: () => {
  631. this.$set(item, 'loadIng', false);
  632. },
  633. error: () => {
  634. this.$Modal.remove();
  635. alert(this.$L('网络繁忙,请稍后再试!'));
  636. },
  637. success: (res) => {
  638. this.$Modal.remove();
  639. this.getLists();
  640. setTimeout(() => {
  641. if (res.ret === 1) {
  642. this.$Message.success(res.msg);
  643. } else {
  644. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  645. }
  646. }, 350);
  647. }
  648. });
  649. } else {
  650. this.$Modal.remove();
  651. }
  652. },
  653. });
  654. },
  655. },
  656. }
  657. </script>