project.vue 26 KB

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