project.vue 29 KB

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