project.vue 28 KB

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