project.vue 29 KB

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