-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Jinnrry/v2.1
v2.1
- Loading branch information
Showing
37 changed files
with
772 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<template> | ||
<div id="main"> | ||
<el-tree :expand-on-click-node="false" :data="data" :props="defaultProps" :defaultExpandAll="true" :class="node"> | ||
<template #default="{ node, data }"> | ||
<div> | ||
<span v-if="data.id != -1"> {{ data.label }}</span> | ||
<el-input v-if="data.id == -1" v-model="data.label" @blur="onInputBlur(data)"></el-input> | ||
<el-button v-if="data.id != 0" @click="del(node, data)" size="small" type="danger" circle> - | ||
</el-button> | ||
<el-button v-if="data.id != 0" @click="add(data)" size="small" type="primary" circle> + </el-button> | ||
</div> | ||
</template> | ||
</el-tree> | ||
|
||
<el-button @click="addRoot">{{ lang.add_group }}</el-button> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import $http from "../http/http"; | ||
import { reactive, ref } from 'vue' | ||
import lang from '../i18n/i18n'; | ||
const data = reactive([]) | ||
$http.get('/api/group').then(res => { | ||
data.push(...res.data) | ||
}) | ||
const del = function (node, data) { | ||
if (data.id != -1) { | ||
$http.post("/api/group/del", { "id": data.id }).then(res => { | ||
if (res.errorNo != 0) { | ||
ElMessage({ | ||
message: res.errorMsg, | ||
type: 'error', | ||
}) | ||
} else { | ||
const pc = node.parent.childNodes | ||
for (let i = 0; i < pc.length; i++) { | ||
if (pc[i].id == node.id) { | ||
pc.splice(i, 1) | ||
return | ||
} | ||
} | ||
} | ||
}) | ||
} else { | ||
const pc = node.parent.childNodes | ||
for (let i = 0; i < pc.length; i++) { | ||
if (pc[i].id == node.id) { | ||
pc.splice(i, 1) | ||
return | ||
} | ||
} | ||
} | ||
} | ||
const add = function (item) { | ||
if (item.children == null) { | ||
item.children = [] | ||
} | ||
item.children.push({ | ||
"children": [], | ||
"label": "", | ||
"id": "-1", | ||
"parent_id": item.id | ||
}) | ||
} | ||
const addRoot = function () { | ||
data.push({ | ||
"children": [], | ||
"label": "", | ||
"id": "-1", | ||
"parent_id": 0 | ||
}) | ||
} | ||
const onInputBlur = function (item) { | ||
if (item.label != "") { | ||
$http.post("/api/group/add", { "name": item.label, "parent_id": item.parent_id }).then(res => { | ||
if (res.errorNo != 0) { | ||
ElMessage({ | ||
message: res.errorMsg, | ||
type: 'error', | ||
}) | ||
} else { | ||
$http.get('/api/group').then(res => { | ||
data.splice(0, data.length) | ||
data.push(...res.data) | ||
}) | ||
} | ||
}) | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ export default defineConfig({ | |
proxy: { | ||
"/api": "http://127.0.0.1/", | ||
"/attachments":"http://127.0.0.1/" | ||
|
||
} | ||
} | ||
}) |
Oops, something went wrong.