project.vue 29 KB

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