project.vue 26 KB

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