project.vue 28 KB

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