project.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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 :projectid="handleProjectId"></project-complete>
  102. </TabPane>
  103. <TabPane :label="$L('成员管理')" name="member">
  104. <project-users :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.listPage = 1;
  287. this.getLists();
  288. },
  289. computed: {
  290. },
  291. watch: {
  292. },
  293. methods: {
  294. setPage(page) {
  295. this.listPage = page;
  296. this.getLists();
  297. },
  298. setPageSize(size) {
  299. if (Math.max($A.runNum(this.listPageSize), 10) != size) {
  300. this.listPageSize = size;
  301. this.getLists();
  302. }
  303. },
  304. getLists() {
  305. this.loadIng++;
  306. $A.aAjax({
  307. url: 'project/lists',
  308. data: {
  309. page: Math.max(this.listPage, 1),
  310. pagesize: Math.max($A.runNum(this.listPageSize), 10),
  311. },
  312. complete: () => {
  313. this.loadIng--;
  314. },
  315. success: (res) => {
  316. if (res.ret === 1) {
  317. this.lists = res.data.lists;
  318. this.listTotal = res.data.total;
  319. }else{
  320. this.lists = [];
  321. this.listTotal = 0;
  322. }
  323. }
  324. });
  325. },
  326. addLabels() {
  327. this.labelsValue = "";
  328. this.$Modal.confirm({
  329. render: (h) => {
  330. return h('div', [
  331. h('div', {
  332. style: {
  333. fontSize: '16px',
  334. fontWeight: '500',
  335. marginBottom: '20px',
  336. }
  337. }, '添加流程'),
  338. h('Input', {
  339. props: {
  340. value: this.labelsValue,
  341. autofocus: true,
  342. placeholder: '请输入流程名称,多个请用空格分隔。'
  343. },
  344. on: {
  345. input: (val) => {
  346. this.labelsValue = val;
  347. }
  348. }
  349. })
  350. ])
  351. },
  352. onOk: () => {
  353. if (this.labelsValue) {
  354. let array = $A.trim(this.labelsValue).split(" ");
  355. array.forEach((name) => {
  356. if ($A.trim(name)) {
  357. this.formAdd.labels.push($A.trim(name));
  358. }
  359. });
  360. }
  361. },
  362. })
  363. },
  364. onAdd() {
  365. this.$refs.add.validate((valid) => {
  366. if (valid) {
  367. this.loadIng++;
  368. $A.aAjax({
  369. url: 'project/add',
  370. data: this.formAdd,
  371. complete: () => {
  372. this.loadIng--;
  373. },
  374. success: (res) => {
  375. if (res.ret === 1) {
  376. this.addShow = false;
  377. this.$Message.success(res.msg);
  378. this.$refs.add.resetFields();
  379. this.$set(this.formAdd, 'template', 0);
  380. //
  381. this.listPage = 1;
  382. this.getLists();
  383. }else{
  384. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  385. }
  386. }
  387. });
  388. }
  389. });
  390. },
  391. handleProject(event, item) {
  392. this.handleProjectId = item.id;
  393. switch (event) {
  394. case 'favor': {
  395. this.favorProject(item);
  396. break;
  397. }
  398. case 'rename': {
  399. this.renameProject(item);
  400. break;
  401. }
  402. case 'transfer': {
  403. this.transferProject(item);
  404. break;
  405. }
  406. case 'delete': {
  407. this.deleteProject(item);
  408. break;
  409. }
  410. case 'out': {
  411. this.outProject(item);
  412. break;
  413. }
  414. case 'open': {
  415. break;
  416. }
  417. case 'complete':
  418. case 'member':
  419. case 'statistics':
  420. case 'myfavor':
  421. case 'myjoin':
  422. case 'mycreate': {
  423. this.projectDrawerShow = true;
  424. this.projectDrawerTab = event;
  425. break;
  426. }
  427. }
  428. },
  429. favorProject(item) {
  430. this.$set(item, 'loadIng', true);
  431. $A.aAjax({
  432. url: 'project/favor',
  433. data: {
  434. id: item.id,
  435. },
  436. complete: () => {
  437. this.$set(item, 'loadIng', false);
  438. },
  439. success: (res) => {
  440. if (res.ret === 1) {
  441. this.$Message.success(res.msg);
  442. }else{
  443. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  444. }
  445. }
  446. });
  447. },
  448. renameProject(item) {
  449. this.renameValue = "";
  450. this.$Modal.confirm({
  451. render: (h) => {
  452. return h('div', [
  453. h('div', {
  454. style: {
  455. fontSize: '16px',
  456. fontWeight: '500',
  457. marginBottom: '20px',
  458. }
  459. }, '重命名项目'),
  460. h('Input', {
  461. props: {
  462. value: this.renameValue,
  463. autofocus: true,
  464. placeholder: '请输入新的项目名称'
  465. },
  466. on: {
  467. input: (val) => {
  468. this.renameValue = val;
  469. }
  470. }
  471. })
  472. ])
  473. },
  474. loading: true,
  475. onOk: () => {
  476. if (this.renameValue) {
  477. this.$set(item, 'loadIng', true);
  478. let title = this.renameValue;
  479. $A.aAjax({
  480. url: 'project/rename',
  481. data: {
  482. projectid: item.id,
  483. title: title,
  484. },
  485. complete: () => {
  486. this.$set(item, 'loadIng', false);
  487. },
  488. error: () => {
  489. this.$Modal.remove();
  490. this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
  491. },
  492. success: (res) => {
  493. this.$Modal.remove();
  494. setTimeout(() => {
  495. if (res.ret === 1) {
  496. this.$Message.success(res.msg);
  497. this.$set(item, 'title', title);
  498. } else {
  499. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  500. }
  501. }, 350);
  502. }
  503. });
  504. } else {
  505. this.$Modal.remove();
  506. }
  507. },
  508. });
  509. },
  510. transferProject(item) {
  511. this.transferValue = "";
  512. this.$Modal.confirm({
  513. render: (h) => {
  514. return h('div', [
  515. h('div', {
  516. style: {
  517. fontSize: '16px',
  518. fontWeight: '500',
  519. marginBottom: '20px',
  520. }
  521. }, '移交项目'),
  522. h('UseridInput', {
  523. props: {
  524. value: this.transferValue,
  525. autofocus: true,
  526. placeholder: '请输入昵称/用户名搜索'
  527. },
  528. on: {
  529. input: (val) => {
  530. this.transferValue = val;
  531. }
  532. }
  533. })
  534. ])
  535. },
  536. loading: true,
  537. onOk: () => {
  538. if (this.transferValue) {
  539. this.$set(item, 'loadIng', true);
  540. let username = this.transferValue;
  541. $A.aAjax({
  542. url: 'project/transfer',
  543. data: {
  544. projectid: item.id,
  545. username: username,
  546. },
  547. complete: () => {
  548. this.$set(item, 'loadIng', false);
  549. },
  550. error: () => {
  551. this.$Modal.remove();
  552. this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
  553. },
  554. success: (res) => {
  555. this.$Modal.remove();
  556. setTimeout(() => {
  557. if (res.ret === 1) {
  558. this.$Message.success(res.msg);
  559. this.getLists();
  560. } else {
  561. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  562. }
  563. }, 350);
  564. }
  565. });
  566. } else {
  567. this.$Modal.remove();
  568. }
  569. },
  570. });
  571. },
  572. deleteProject(item) {
  573. this.$Modal.confirm({
  574. title: '删除项目',
  575. content: '你确定要删除此项目吗?',
  576. loading: true,
  577. onOk: () => {
  578. $A.aAjax({
  579. url: 'project/delete?projectid=' + item.id,
  580. error: () => {
  581. this.$Modal.remove();
  582. this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
  583. },
  584. success: (res) => {
  585. this.$Modal.remove();
  586. setTimeout(() => {
  587. if (res.ret === 1) {
  588. this.$Message.success(res.msg);
  589. //
  590. this.getLists();
  591. }else{
  592. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  593. }
  594. }, 350);
  595. }
  596. });
  597. }
  598. });
  599. },
  600. outProject(item) {
  601. this.$Modal.confirm({
  602. title: '退出项目',
  603. content: '你确定要退出此项目吗?',
  604. loading: true,
  605. onOk: () => {
  606. $A.aAjax({
  607. url: 'project/out?projectid=' + item.id,
  608. error: () => {
  609. this.$Modal.remove();
  610. this.$Message.error(this.$L('网络繁忙,请稍后再试!'));
  611. },
  612. success: (res) => {
  613. this.$Modal.remove();
  614. setTimeout(() => {
  615. if (res.ret === 1) {
  616. this.$Message.success(res.msg);
  617. //
  618. this.getLists();
  619. }else{
  620. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  621. }
  622. }, 350);
  623. }
  624. });
  625. }
  626. });
  627. }
  628. },
  629. }
  630. </script>