project.vue 28 KB

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