project.vue 30 KB

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