project.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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, index) 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('complete', item)">
  53. <Icon class="project-iconbtn-icon1" type="md-checkmark-circle-outline" 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="complete">
  106. <project-complete :canload="projectDrawerShow && projectDrawerTab == 'complete'" :projectid="handleProjectId"></project-complete>
  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. &:hover {
  138. .page-nav-refresh {
  139. display: block;
  140. }
  141. }
  142. .page-nav-loading {
  143. width: 18px;
  144. height: 18px;
  145. margin-right: 6px;
  146. display: flex;
  147. }
  148. .page-nav-refresh {
  149. display: none;
  150. padding-right: 12px;
  151. color: #048be0;
  152. cursor: pointer;
  153. &:hover {
  154. text-decoration: underline;
  155. }
  156. }
  157. }
  158. ul.project-list {
  159. padding: 5px;
  160. max-width: 2000px;
  161. li {
  162. float: left;
  163. width: 25%;
  164. display: flex;
  165. @media (max-width: 1400px) {
  166. width: 33.33%;
  167. }
  168. @media (max-width: 1080px) {
  169. width: 50%;
  170. }
  171. @media (max-width: 640px) {
  172. width: 100%;
  173. }
  174. .project-item {
  175. flex: 1;
  176. margin: 10px;
  177. width: 100%;
  178. height: 280px;
  179. padding: 20px;
  180. background-color: #ffffff;
  181. border-radius: 4px;
  182. display: flex;
  183. flex-direction: column;
  184. .project-head{
  185. display: flex;
  186. flex-direction: row;
  187. .project-loading {
  188. width: 18px;
  189. height: 18px;
  190. margin-right: 6px;
  191. margin-top: 3px;
  192. }
  193. .project-title{
  194. flex: 1;
  195. font-size: 16px;
  196. padding-right: 6px;
  197. overflow:hidden;
  198. text-overflow:ellipsis;
  199. white-space:nowrap;
  200. color: #333333;
  201. cursor: pointer;
  202. }
  203. .project-setting{
  204. width: 30px;
  205. text-align: right;
  206. .project-setting-icon {
  207. cursor: pointer;
  208. color: #333333;
  209. &:hover {
  210. color: #0396f2;
  211. }
  212. }
  213. }
  214. }
  215. .project-num {
  216. flex: 1;
  217. padding: 24px 0;
  218. display: flex;
  219. flex-direction: row;
  220. align-items: center;
  221. cursor: pointer;
  222. .project-complete,
  223. .project-unfinished {
  224. flex: 1;
  225. text-align: center;
  226. font-size: 14px;
  227. color: #999999;
  228. em {
  229. display: block;
  230. font-size: 32px;
  231. color: #0396f2;
  232. overflow: hidden;
  233. text-overflow: ellipsis;
  234. white-space: nowrap;
  235. max-width: 120px;
  236. margin: 0 auto;
  237. }
  238. }
  239. .project-num-line {
  240. width: 1px;
  241. height: 90%;
  242. background-color: #e8e8e8;
  243. }
  244. }
  245. .project-bottom {
  246. display: flex;
  247. flex-direction: row;
  248. align-items: center;
  249. border-top: 1px solid #efefef;
  250. padding: 6px 0;
  251. cursor: default;
  252. .project-iconbtn {
  253. flex: 1;
  254. text-align: center;
  255. cursor: pointer;
  256. &:hover {
  257. .project-iconbtn-text {
  258. color: #0396f2;
  259. }
  260. }
  261. .project-iconbtn-icon1 {
  262. margin: 12px 0;
  263. color: #ff7a7a;
  264. }
  265. .project-iconbtn-icon2 {
  266. margin: 12px 0;
  267. color: #764df8;
  268. }
  269. .project-iconbtn-icon3 {
  270. margin: 12px 0;
  271. color: #ffca65;
  272. }
  273. .project-iconbtn-text {
  274. color: #999999;
  275. }
  276. }
  277. }
  278. }
  279. }
  280. &:before,
  281. &:after {
  282. display: table;
  283. content: "";
  284. }
  285. &:after {
  286. clear: both;
  287. }
  288. }
  289. }
  290. </style>
  291. <script>
  292. import WHeader from "../components/WHeader";
  293. import WContent from "../components/WContent";
  294. import WLoading from "../components/WLoading";
  295. import ProjectComplete from "../components/project/complete";
  296. import ProjectUsers from "../components/project/users";
  297. import ProjectStatistics from "../components/project/statistics";
  298. import ProjectMyFavor from "../components/project/my/favor";
  299. import ProjectMyJoin from "../components/project/my/join";
  300. import ProjectMyManage from "../components/project/my/manage";
  301. import Project from "../mixins/project";
  302. export default {
  303. components: {
  304. ProjectMyManage,
  305. ProjectMyJoin,
  306. ProjectMyFavor, ProjectStatistics, ProjectUsers, ProjectComplete, WLoading, WContent, WHeader},
  307. mixins: [
  308. Project
  309. ],
  310. data () {
  311. return {
  312. loadIng: 0,
  313. addShow: false,
  314. formAdd: {
  315. title: '',
  316. labels: [],
  317. template: 0,
  318. },
  319. ruleAdd: {},
  320. labelLists: [{
  321. label: '空白模板',
  322. value: [],
  323. }, {
  324. label: '软件开发',
  325. value: ['产品规划','前端开发','后端开发','测试','发布','其它'],
  326. }, {
  327. label: '产品开发',
  328. value: ['产品计划', '正在设计', '正在研发', '测试', '准备发布', '发布成功'],
  329. }],
  330. lists: [],
  331. listPage: 1,
  332. listTotal: 0,
  333. projectDrawerShow: false,
  334. projectDrawerTab: 'complete',
  335. projectListDrawerShow: false,
  336. projectListDrawerTab: 'myjoin',
  337. handleProjectId: 0,
  338. }
  339. },
  340. created() {
  341. this.ruleAdd = {
  342. title: [
  343. { required: true, message: this.$L('请填写项目名称!'), trigger: 'change' },
  344. { type: 'string', min: 2, message: this.$L('项目名称至少2个字!'), trigger: 'change' }
  345. ]
  346. };
  347. },
  348. mounted() {
  349. this.getLists(true);
  350. },
  351. deactivated() {
  352. this.addShow = false;
  353. this.projectDrawerShow = false;
  354. this.projectListDrawerShow = false;
  355. },
  356. methods: {
  357. setPage(page) {
  358. this.listPage = page;
  359. this.getLists();
  360. },
  361. setPageSize(size) {
  362. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  363. this.listPageSize = size;
  364. this.getLists();
  365. }
  366. },
  367. getLists(resetLoad) {
  368. if (resetLoad === true) {
  369. this.listPage = 1;
  370. }
  371. this.loadIng++;
  372. $A.aAjax({
  373. url: 'project/lists',
  374. data: {
  375. page: Math.max(this.listPage, 1),
  376. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  377. },
  378. complete: () => {
  379. this.loadIng--;
  380. },
  381. success: (res) => {
  382. if (res.ret === 1) {
  383. this.lists = res.data.lists;
  384. this.listTotal = res.data.total;
  385. }else{
  386. this.lists = [];
  387. this.listTotal = 0;
  388. }
  389. }
  390. });
  391. },
  392. addLabels() {
  393. this.labelsValue = "";
  394. this.$Modal.confirm({
  395. render: (h) => {
  396. return h('div', [
  397. h('div', {
  398. style: {
  399. fontSize: '16px',
  400. fontWeight: '500',
  401. marginBottom: '20px',
  402. }
  403. }, '添加流程'),
  404. h('Input', {
  405. props: {
  406. value: this.labelsValue,
  407. autofocus: true,
  408. placeholder: '请输入流程名称,多个可用空格分隔。'
  409. },
  410. on: {
  411. input: (val) => {
  412. this.labelsValue = val;
  413. }
  414. }
  415. })
  416. ])
  417. },
  418. onOk: () => {
  419. if (this.labelsValue) {
  420. let array = $A.trim(this.labelsValue).split(" ");
  421. array.forEach((name) => {
  422. if ($A.trim(name)) {
  423. this.formAdd.labels.push($A.trim(name));
  424. }
  425. });
  426. }
  427. },
  428. })
  429. },
  430. onAdd() {
  431. this.$refs.add.validate((valid) => {
  432. if (valid) {
  433. this.loadIng++;
  434. $A.aAjax({
  435. url: 'project/add',
  436. data: this.formAdd,
  437. complete: () => {
  438. this.loadIng--;
  439. },
  440. success: (res) => {
  441. if (res.ret === 1) {
  442. this.addShow = false;
  443. this.$Message.success(res.msg);
  444. this.$refs.add.resetFields();
  445. this.$set(this.formAdd, 'template', 0);
  446. //
  447. this.getLists(true);
  448. } else {
  449. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  450. }
  451. }
  452. });
  453. }
  454. });
  455. },
  456. handleProject(event, item) {
  457. if (item) {
  458. this.handleProjectId = item.id;
  459. }
  460. switch (event) {
  461. case 'favor': {
  462. this.favorProject('add', item.id);
  463. break;
  464. }
  465. case 'rename': {
  466. this.renameProject(item);
  467. break;
  468. }
  469. case 'transfer': {
  470. this.transferProject(item);
  471. break;
  472. }
  473. case 'delete': {
  474. this.deleteProject(item.id, () => {
  475. this.getLists();
  476. });
  477. break;
  478. }
  479. case 'out': {
  480. this.outProject(item.id, () => {
  481. this.getLists();
  482. });
  483. break;
  484. }
  485. case 'open': {
  486. this.openProject(item.id, item);
  487. break;
  488. }
  489. case 'complete':
  490. case 'member':
  491. case 'statistics': {
  492. this.projectDrawerShow = true;
  493. this.projectDrawerTab = event;
  494. break;
  495. }
  496. case 'myjoin':
  497. case 'myfavor':
  498. case 'mycreate': {
  499. this.projectListDrawerShow = true;
  500. this.projectListDrawerTab = event;
  501. break;
  502. }
  503. }
  504. },
  505. renameProject(item) {
  506. this.renameValue = "";
  507. this.$Modal.confirm({
  508. render: (h) => {
  509. return h('div', [
  510. h('div', {
  511. style: {
  512. fontSize: '16px',
  513. fontWeight: '500',
  514. marginBottom: '20px',
  515. }
  516. }, '重命名项目'),
  517. h('Input', {
  518. props: {
  519. value: this.renameValue,
  520. autofocus: true,
  521. placeholder: '请输入新的项目名称'
  522. },
  523. on: {
  524. input: (val) => {
  525. this.renameValue = val;
  526. }
  527. }
  528. })
  529. ])
  530. },
  531. loading: true,
  532. onOk: () => {
  533. if (this.renameValue) {
  534. this.$set(item, 'loadIng', true);
  535. let title = this.renameValue;
  536. $A.aAjax({
  537. url: 'project/rename',
  538. data: {
  539. projectid: item.id,
  540. title: title,
  541. },
  542. complete: () => {
  543. this.$set(item, 'loadIng', false);
  544. },
  545. error: () => {
  546. this.$Modal.remove();
  547. alert(this.$L('网络繁忙,请稍后再试!'));
  548. },
  549. success: (res) => {
  550. this.$Modal.remove();
  551. this.$set(item, 'title', title);
  552. setTimeout(() => {
  553. if (res.ret === 1) {
  554. this.$Message.success(res.msg);
  555. } else {
  556. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  557. }
  558. }, 350);
  559. }
  560. });
  561. } else {
  562. this.$Modal.remove();
  563. }
  564. },
  565. });
  566. },
  567. transferProject(item) {
  568. this.transferValue = "";
  569. this.$Modal.confirm({
  570. render: (h) => {
  571. return h('div', [
  572. h('div', {
  573. style: {
  574. fontSize: '16px',
  575. fontWeight: '500',
  576. marginBottom: '20px',
  577. }
  578. }, '移交项目'),
  579. h('UseridInput', {
  580. props: {
  581. value: this.transferValue,
  582. placeholder: '请输入昵称/用户名搜索'
  583. },
  584. on: {
  585. input: (val) => {
  586. this.transferValue = val;
  587. }
  588. }
  589. })
  590. ])
  591. },
  592. loading: true,
  593. onOk: () => {
  594. if (this.transferValue) {
  595. this.$set(item, 'loadIng', true);
  596. let username = this.transferValue;
  597. $A.aAjax({
  598. url: 'project/transfer',
  599. data: {
  600. projectid: item.id,
  601. username: username,
  602. },
  603. complete: () => {
  604. this.$set(item, 'loadIng', false);
  605. },
  606. error: () => {
  607. this.$Modal.remove();
  608. alert(this.$L('网络繁忙,请稍后再试!'));
  609. },
  610. success: (res) => {
  611. this.$Modal.remove();
  612. this.getLists();
  613. setTimeout(() => {
  614. if (res.ret === 1) {
  615. this.$Message.success(res.msg);
  616. } else {
  617. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  618. }
  619. }, 350);
  620. }
  621. });
  622. } else {
  623. this.$Modal.remove();
  624. }
  625. },
  626. });
  627. },
  628. },
  629. }
  630. </script>