project.vue 27 KB

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