project.vue 28 KB

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