Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
SunWuyuan committed Oct 2, 2024
1 parent d88dcce commit 94d8743
Show file tree
Hide file tree
Showing 11 changed files with 518 additions and 35 deletions.
98 changes: 98 additions & 0 deletions src/components/AddTolist.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<template>
<v-list>
<div v-for="item in lists" :key="item.id">
<v-list-item :append-icon="item.include == true ? 'mdi-minus-circle' : 'mdi-plus-circle'"
:active="item.include == true" color="primary"
@click="item.include == true ? ProjectlistDelete(item.id) : ProjectlistAdd(item.id)">

<v-list-item-title> {{ item.title }}</v-list-item-title>
<v-list-item-subtitle>{{ item.description }}</v-list-item-subtitle>
</v-list-item></div>
<v-list-item @click="NewProjectListDialog = true">新建列表</v-list-item>
</v-list>



<v-dialog v-model="NewProjectListDialog">
<NewProjectList :listid="editlistid" :close="() => NewProjectListDialog = false" :callback="getProjectList">
</NewProjectList>
</v-dialog>


</template>
<script>
import NewProjectList from '@/components/NewProjectList.vue'
import { localuser } from "@/stores/user";
import request from '../axios/axios'
export default {
components: { NewProjectList },
name: "projectlist",
data() {
return {
localuser: localuser,
userinfo: localuser.user,
NewProjectListDialog: false,
lists: [
],
};
},
methods: {
async getProjectList() {
this.lists = (await request({
url: '/projectlist/check?projectid=' + this.$route.params.id,
data: {
userid: this.userinfo.id,
projectid: this.$route.params.id,
},
method: 'get',
})).data
},
async ProjectlistAdd(id) {
await request({
url: '/projectlist/add',
data: {
userid: this.userinfo.id,
projectid: this.$route.params.id,
listid: id,
},
method: 'post',
}).then((res) => {
this.$toast.add({
severity: "info",
summary: "info",
detail: res.message,
life: 3000,
});
this.getProjectList()
})
},
async ProjectlistDelete(id) {
await request({
url: '/projectlist/delete',
data: {
userid: this.userinfo.id,
projectid: this.$route.params.id,
listid: id,
},
method: 'post',
}).then((res) => {
this.$toast.add({
severity: "info",
summary: "info",
detail: res.message,
life: 3000,
});
this.getProjectList()
})
}
},
mounted() {
this.getProjectList();
},
};
</script>
3 changes: 2 additions & 1 deletion src/components/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
<v-list-item rounded="xl" prepend-icon="mdi-cog" title="账户设置" value="account" to="/account"></v-list-item>
<v-list-item rounded="xl" prepend-icon="mdi-xml" title="我的项目" value="myprojects"
to="/projects/my"></v-list-item>

<v-list-item rounded="xl" prepend-icon="mdi-xml" title="我的列表" value="myprojectlist"
to="/projectlist"></v-list-item>
<v-list-item rounded="xl" prepend-icon="mdi-export" :title="logoutbutton" value="logout"
@click="trylogout"></v-list-item>

Expand Down
116 changes: 116 additions & 0 deletions src/components/EditProjectListConfig.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<template>
<v-card :title="`${listinfo.title}(#${listinfo.id})`">
<v-card-text>
<v-text-field v-model="newlistinfo.title" label="名称" required></v-text-field>
<v-text-field v-model="newlistinfo.description" label="简介" required></v-text-field>

<v-select v-model="newlistinfo.state" :items="liststates" item-title="state" item-value="abbr"
label="项目状态"></v-select>
</v-card-text>
<v-card-actions>
<v-btn text="删除" variant="plain" @click="deleteProjectList(listid);close()" color="red"></v-btn>

<v-spacer></v-spacer>
<v-btn text="回退" variant="plain" @click="newlistinfo = Object.assign({}, listinfo)"></v-btn>

<v-btn text="关闭" variant="plain" @click="close()"></v-btn>

<v-btn color="primary" text="保存" variant="tonal" @click="updateProjectList(listid)"></v-btn>
</v-card-actions>
</v-card>
</template>

<script>
import request from "../axios/axios";
export default {
data() {
return {
liststates: [
{ state: "私密", abbr: "private" },
{ state: "公开", abbr: "public" },
],
created: false,
newid: 0,
isVisible: false,
listinfo: {},
newlistinfo: {},
};
},
props: {
listid: {
type: String,
required: true, // 可以根据需要设置为 true
},
callback: {
type: Function,
required: false, // 可以根据需要设置为 true
}, close: {
type: Function,
required: false, // 可以根据需要设置为 true
},
},
methods: {
show() {
this.created = false;
this.newid = 0;
this.isVisible = true;
},
async getProjectList(listid) {
await request.get("/projectlist/" + listid).then((res) => {
console.log(res);
this.$toast.add({
severity: "info",
summary: "info",
detail: res,
life: 3000,
});
if (res.status == "1") {
//this.created = true
this.listinfo = Object.assign({}, res.data);
this.newlistinfo = Object.assign({}, res.data);
}
});
this.callback();
},
async updateProjectList(listid) {
await request
.put("/projectlist/" + listid, this.newlistinfo)
.then((res) => {
console.log(res);
this.$toast.add({
severity: "info",
summary: "info",
detail: res,
life: 3000,
});
if (res.status == "1") {
//this.created = true
this.listinfo = Object.assign({}, res.data);
this.newlistinfo = Object.assign({}, res.data);
}
});
this.callback();
},
async deleteProjectList(listid) {
await request.delete("/projectlist/" + listid).then((res) => {
console.log(res);
this.$toast.add({
severity: "info",
summary: "info",
detail: res,
life: 3000,
});
});
this.callback();
},
},
mounted() {
this.getProjectList(this.listid);
},
};
</script>

<style scoped></style>
8 changes: 4 additions & 4 deletions src/components/NewProjectDialog.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-dialog v-model="this.showdialog" persistent max-width="500px">
<v-dialog v-model="this.isVisible" persistent max-width="500px">


<v-card prepend-icon="mdi-xml" title="新建作品">
Expand All @@ -26,7 +26,7 @@

<v-spacer></v-spacer>

<v-btn text="取消" variant="plain" @click="showdialog = false"></v-btn>
<v-btn text="取消" variant="plain" @click="isVisible = false"></v-btn>

<v-btn color="primary" text="创建" variant="tonal" @click="newProject()" :disabled="created"></v-btn>
</v-card-actions>
Expand All @@ -47,7 +47,7 @@ export default {
},
created: false,
newid: 0,
showdialog: false,
isVisible: false,
openEdit
};
},
Expand All @@ -59,7 +59,7 @@ export default {
},
this.created = false
this.newid = 0
this.showdialog = true
this.isVisible = true
},
async newProject() {
await request.post('/project/', this.projectinfo).then((res) => {
Expand Down
75 changes: 75 additions & 0 deletions src/components/NewProjectList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<template>


<v-card prepend-icon="mdi-xml" title="新建列表">
<v-card-text>
<v-row dense>
<v-col cols="12" md="12" sm="12">
<v-text-field label="标题" required hint="将便于查找" v-model="projectinfo.title" disabled></v-text-field>
</v-col>
</v-row>

</v-card-text>
<v-divider></v-divider>
<v-card-actions>

<v-spacer></v-spacer>

<v-btn text="关闭" variant="plain" @click="close()"></v-btn>

<v-btn color="primary" text="创建" variant="tonal" @click="newProjectList();close()" :disabled="created"></v-btn>
</v-card-actions>
</v-card>
</template>


<script>
import openEdit from "../stores/openEdit";
import request from "../axios/axios";
export default {
data() {
return {
projectinfo: {
title: '新建项目列表',
},
created: false,
newid: 0,
isVisible: false,
openEdit
};
},
props: {
callback: {
type: Function,
required: false, // 可以根据需要设置为 true
}, close: {
type: Function,
required: false, // 可以根据需要设置为 true
},
},
methods: {
show() {
this.projectinfo = {
title: '新建项目列表',
},
this.created = false
this.newid = 0
this.isVisible = true
},
async newProjectList() {
await request.post('/projectlist/', this.projectinfo).then((res) => {
console.log(res)
this.$toast.add({ severity: 'info', summary: 'info', detail: res, life: 3000 });
if (res.status == '1') {
//this.created = true
this.newid = res.id
}
})
this.callback()
}
},
};
</script>

<style scoped></style>
4 changes: 2 additions & 2 deletions src/components/ProjectsCards.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-row>
<v-col cols="12" xs="12" sm="6" md="4" lg="3" xl="2" xxl="2" v-for="info in projects.data" :key="info">
<ProjectCard :info="info" :user="projects.user.find((u) => u.id === info.authorid)" :actions="actions"></ProjectCard>
<v-col cols="12" xs="12" sm="6" md="4" lg="3" xl="2" xxl="2" v-for="info in projects.projects" :key="info">
<ProjectCard :info="info" :user="projects.users.find((u) => u.id === info.authorid)" :actions="actions"></ProjectCard>
</v-col></v-row>
</template>

Expand Down
Loading

0 comments on commit 94d8743

Please sign in to comment.