project.vue 30 KB

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