|
@@ -1,149 +1,149 @@
|
|
|
-<template>
|
|
|
- <div class="hui-flex hui-content">
|
|
|
- <div class="hui-content-title">
|
|
|
- <div class="hui-title-item active">项目列表</div>
|
|
|
- </div>
|
|
|
- <div class="hui-flex-box hui-flex hui-table">
|
|
|
- <div class="hui-content-insert">
|
|
|
- <el-button type="primary" size="medium" @click="insertProject">新增项目</el-button>
|
|
|
- </div>
|
|
|
- <div class="hui-flex-box">
|
|
|
- <el-table :data="tableData" row-key="id" border height="100%">
|
|
|
- <el-table-column label="序号" width="50">
|
|
|
- <template slot-scope="scope">
|
|
|
- <div style="text-align: center;">{{scope.$index + 1}}</div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="项目名称" prop="name"></el-table-column>
|
|
|
- <el-table-column label="项目描述" prop="comment"></el-table-column>
|
|
|
- <el-table-column label="操作" width="150">
|
|
|
- <template slot-scope="scope">
|
|
|
- <div class="hui-table-operation">
|
|
|
- <span class="table-operation" @click="lookProject(scope.row)">详情</span>
|
|
|
- <span class="table-operation" @click="updateProject(scope.row)">编辑</span>
|
|
|
- <span class="table-operation" @click="deleteProject(scope.row)">删除</span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <template slot="empty">
|
|
|
- <empty description="暂无数据"></empty>
|
|
|
- </template>
|
|
|
- </el-table>
|
|
|
- </div>
|
|
|
- <div class="hui-content-pagination">
|
|
|
- <el-pagination :page-size="pageSize" :pager-count="9" layout="prev, pager, next" :total="totalCount"
|
|
|
- @current-change="currentChange">
|
|
|
- </el-pagination>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <el-dialog :title="isUpdate?'编辑':'新增'" :visible.sync="visible" width="900px" :append-to-body="true">
|
|
|
- <edit v-if="visible" @callback="callback" :isUpdate="isUpdate" :detailId="detailId"></edit>
|
|
|
- </el-dialog>
|
|
|
- <el-drawer title="项目详情" :visible.sync="drawer" :size="400" :append-to-body="true">
|
|
|
- <detail v-if="drawer" :detailId="detailId"></detail>
|
|
|
- </el-drawer>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
- import {
|
|
|
- getProjectListByPage,
|
|
|
- deleteProjectById
|
|
|
- } from '@/httpApi/space'
|
|
|
- import edit from '@/components/work/space/project/edit'
|
|
|
- import detail from '@/components/work/space/project/detail'
|
|
|
- import {
|
|
|
- selectProject
|
|
|
- } from '@/httpApi/loginRegister'
|
|
|
- import {
|
|
|
- setComment
|
|
|
- } from '@/uitls/auth';
|
|
|
- export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- tableData: [],
|
|
|
- currPage: 1,
|
|
|
- pageSize: 10,
|
|
|
- totalCount: 0,
|
|
|
- visible: false,
|
|
|
- detailId: '',
|
|
|
- isUpdate: false,
|
|
|
- drawer: false
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.init();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- init() {
|
|
|
- getProjectListByPage({
|
|
|
- currPage: this.currPage,
|
|
|
- pageSize: this.pageSize,
|
|
|
- organizationId: this.$store.getters.organization.id
|
|
|
- }).then(res => {
|
|
|
- if (res.state) {
|
|
|
- this.tableData = res.data.dataList;
|
|
|
- this.totalCount = res.data.totalCount;
|
|
|
- if (this.$store.getters.project.id) return;
|
|
|
- this.changeProject(this.tableData[0]);
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- changeProject(data) {
|
|
|
- if (!data) return;
|
|
|
- data.projectItemList = data.projectItemList || [];
|
|
|
- data.projectItemList.sort((a, b) => {
|
|
|
- return a.id - b.id;
|
|
|
- });
|
|
|
- selectProject(data.id).then(res => {
|
|
|
- if (res.state) {
|
|
|
- let user = res.data;
|
|
|
- localStorage.setItem('projectId', data.id);
|
|
|
- this.$store.dispatch('app/changeUser', user);
|
|
|
- this.$store.dispatch('app/changeMenuData', user.resource ? JSON.parse(user.resource) : []);
|
|
|
- setComment(user.menu ? user.menu : JSON.stringify([]));
|
|
|
- this.$store.dispatch('projectBase/changeProject', data);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- currentChange(currPage) {
|
|
|
- this.currPage = currPage;
|
|
|
- this.init();
|
|
|
- },
|
|
|
- insertProject() {
|
|
|
- this.isUpdate = false;
|
|
|
- this.visible = true;
|
|
|
- },
|
|
|
- updateProject(val) {
|
|
|
- this.detailId = val.id;
|
|
|
- this.isUpdate = true;
|
|
|
- this.visible = true;
|
|
|
- },
|
|
|
- lookProject(val) {
|
|
|
- this.detailId = val.id;
|
|
|
- this.drawer = true;
|
|
|
- },
|
|
|
- deleteProject(val) {
|
|
|
- if (this.$store.getters.project.id === val.id) return this.$message.warning('不能删除当前项目,请切换项目后删除');
|
|
|
- this.$confirm('确定要删除该项目?', () => {
|
|
|
- deleteProjectById(val.id).then(res => {
|
|
|
- if (res.state) {
|
|
|
- this.init();
|
|
|
- this.$message.success('操作成功');
|
|
|
- }
|
|
|
- })
|
|
|
- });
|
|
|
- },
|
|
|
- callback(type) {
|
|
|
- if (type === 'init') this.init();
|
|
|
- this.visible = false;
|
|
|
- }
|
|
|
- },
|
|
|
- components: {
|
|
|
- edit,
|
|
|
- detail
|
|
|
- },
|
|
|
- }
|
|
|
-</script>
|
|
|
-
|
|
|
+<template>
|
|
|
+ <div class="hui-flex hui-content">
|
|
|
+ <div class="hui-content-title">
|
|
|
+ <div class="hui-title-item active">项目列表</div>
|
|
|
+ </div>
|
|
|
+ <div class="hui-flex-box hui-flex hui-table">
|
|
|
+ <div class="hui-content-insert">
|
|
|
+ <el-button type="primary" size="medium" @click="insertProject">新增项目</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="hui-flex-box">
|
|
|
+ <el-table :data="tableData" row-key="id" border height="100%">
|
|
|
+ <el-table-column label="序号" width="50">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <div style="text-align: center;">{{scope.$index + 1}}</div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="项目名称" prop="name"></el-table-column>
|
|
|
+ <el-table-column label="项目描述" prop="comment"></el-table-column>
|
|
|
+ <el-table-column label="操作" width="150">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <div class="hui-table-operation">
|
|
|
+ <span class="table-operation" @click="lookProject(scope.row)">详情</span>
|
|
|
+ <span class="table-operation" @click="updateProject(scope.row)">编辑</span>
|
|
|
+ <span class="table-operation" @click="deleteProject(scope.row)">删除</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <template slot="empty">
|
|
|
+ <empty description="暂无数据"></empty>
|
|
|
+ </template>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <div class="hui-content-pagination">
|
|
|
+ <el-pagination :page-size="pageSize" :pager-count="9" layout="prev, pager, next" :total="totalCount"
|
|
|
+ @current-change="currentChange">
|
|
|
+ </el-pagination>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-dialog :title="isUpdate?'编辑':'新增'" :visible.sync="visible" width="900px" :append-to-body="true">
|
|
|
+ <edit v-if="visible" @callback="callback" :isUpdate="isUpdate" :detailId="detailId"></edit>
|
|
|
+ </el-dialog>
|
|
|
+ <el-drawer title="项目详情" :visible.sync="drawer" :size="400" :append-to-body="true">
|
|
|
+ <detail v-if="drawer" :detailId="detailId"></detail>
|
|
|
+ </el-drawer>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import {
|
|
|
+ getProjectListByPage,
|
|
|
+ deleteProjectById
|
|
|
+ } from '@/httpApi/space'
|
|
|
+ import edit from '@/components/work/space/project/edit'
|
|
|
+ import detail from '@/components/work/space/project/detail'
|
|
|
+ import {
|
|
|
+ selectProject
|
|
|
+ } from '@/httpApi/loginRegister'
|
|
|
+ import {
|
|
|
+ setComment
|
|
|
+ } from '@/uitls/auth';
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableData: [],
|
|
|
+ currPage: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ totalCount: 0,
|
|
|
+ visible: false,
|
|
|
+ detailId: '',
|
|
|
+ isUpdate: false,
|
|
|
+ drawer: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init() {
|
|
|
+ getProjectListByPage({
|
|
|
+ currPage: this.currPage,
|
|
|
+ pageSize: this.pageSize,
|
|
|
+ organizationId: this.$store.getters.organization.id
|
|
|
+ }).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ this.tableData = res.data.dataList;
|
|
|
+ this.totalCount = res.data.totalCount;
|
|
|
+ if (this.$store.getters.project.id) return;
|
|
|
+ if (this.tableData.length > 0) this.changeProject(this.tableData[0]);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ changeProject(data) {
|
|
|
+ if (!data) return;
|
|
|
+ data.projectItemList = data.projectItemList || [];
|
|
|
+ data.projectItemList.sort((a, b) => {
|
|
|
+ return a.id - b.id;
|
|
|
+ });
|
|
|
+ selectProject(data.id).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ let user = res.data;
|
|
|
+ localStorage.setItem('projectId', data.id);
|
|
|
+ this.$store.dispatch('app/changeUser', user);
|
|
|
+ this.$store.dispatch('app/changeMenuData', user.resource ? JSON.parse(user.resource) : []);
|
|
|
+ setComment(user.menu ? user.menu : JSON.stringify([]));
|
|
|
+ this.$store.dispatch('projectBase/changeProject', data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ currentChange(currPage) {
|
|
|
+ this.currPage = currPage;
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ insertProject() {
|
|
|
+ this.isUpdate = false;
|
|
|
+ this.visible = true;
|
|
|
+ },
|
|
|
+ updateProject(val) {
|
|
|
+ this.detailId = val.id;
|
|
|
+ this.isUpdate = true;
|
|
|
+ this.visible = true;
|
|
|
+ },
|
|
|
+ lookProject(val) {
|
|
|
+ this.detailId = val.id;
|
|
|
+ this.drawer = true;
|
|
|
+ },
|
|
|
+ deleteProject(val) {
|
|
|
+ if (this.$store.getters.project.id === val.id) return this.$message.warning('不能删除当前项目,请切换项目后删除');
|
|
|
+ this.$confirm('确定要删除该项目?', () => {
|
|
|
+ deleteProjectById(val.id).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ this.init();
|
|
|
+ this.$message.success('操作成功');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ callback(type) {
|
|
|
+ if (type === 'init') this.init();
|
|
|
+ this.visible = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ edit,
|
|
|
+ detail
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
<style lang="scss"></style>
|