parent
fe898632d4
commit
ff78ab0a19
10 changed files with 1348 additions and 1136 deletions
@ -1,175 +1,206 @@ |
|||||||
<template> |
<template> |
||||||
|
<div> |
||||||
<div> |
<div> |
||||||
<div> |
<org-tree :data="orgList" |
||||||
<org-tree |
|
||||||
:data="orgList" |
|
||||||
default-expand-all |
default-expand-all |
||||||
ref="tree" |
ref="tree" |
||||||
node-key="id" |
node-key="id" |
||||||
highlight-current |
highlight-current |
||||||
:expand-on-click-node="false" |
:expand-on-click-node="false" |
||||||
@node-click="getSingle" |
@node-click="getSingle" |
||||||
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}" |
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}"> |
||||||
> |
<span class="custom-tree-node" |
||||||
<span class="custom-tree-node" slot-scope="{ node, data }"> |
slot-scope="{ node, data }"> |
||||||
<span style="display: inline-block; margin-right: 20px">{{ node.label }}</span> |
<span style="display: inline-block; margin-right: 20px">{{ node.label }}</span> |
||||||
<span> |
<span> |
||||||
<el-button |
<el-button v-if="node.level > 1" |
||||||
v-if="node.level > 1" |
type="text" |
||||||
type="text" |
icon="el-icon-edit-outline" |
||||||
icon="el-icon-edit-outline" |
@click="editType(data)"> |
||||||
@click="editType(data)"> |
</el-button> |
||||||
</el-button> |
<el-button type="text" |
||||||
<el-button |
icon="el-icon-circle-plus-outline" |
||||||
type="text" |
@click="addType(node, data)"> |
||||||
icon="el-icon-circle-plus-outline" |
</el-button> |
||||||
@click="addType(node, data)"> |
<el-button v-if="node.level > 1" |
||||||
</el-button> |
type="text" |
||||||
<el-button |
icon="el-icon-delete" |
||||||
v-if="node.level > 1" |
@click="delType(data)"> |
||||||
type="text" |
</el-button> |
||||||
icon="el-icon-delete" |
</span> |
||||||
@click="delType(data)"> |
</span> |
||||||
</el-button> |
</org-tree> |
||||||
</span> |
<div :class="['school-create', {active: schoolActive}]" |
||||||
</span> |
@click="schoolClick">院校创建</div> |
||||||
</org-tree> |
|
||||||
</div> |
|
||||||
|
|
||||||
<el-dialog :title="Form.id ? '编辑分类' : '新增分类'" :visible.sync="typeVisible" width="24%" center @close="closeDia" :close-on-click-modal="false"> |
|
||||||
<el-form ref="Form" :model="Form" :rules="rules"> |
|
||||||
<el-form-item prop="categoryName"> |
|
||||||
<el-input placeholder="请输入分类名称" v-model="Form.categoryName"></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-form> |
|
||||||
<span slot="footer" class="dialog-footer"> |
|
||||||
<el-button @click="typeVisible = false">取 消</el-button> |
|
||||||
<el-button type="primary" @click="submit">确 定</el-button> |
|
||||||
</span> |
|
||||||
</el-dialog> |
|
||||||
</div> |
</div> |
||||||
|
|
||||||
|
<el-dialog :title="Form.id ? '编辑分类' : '新增分类'" |
||||||
|
:visible.sync="typeVisible" |
||||||
|
width="24%" |
||||||
|
center |
||||||
|
@close="closeDia" |
||||||
|
:close-on-click-modal="false"> |
||||||
|
<el-form ref="Form" |
||||||
|
:model="Form" |
||||||
|
:rules="rules"> |
||||||
|
<el-form-item prop="categoryName"> |
||||||
|
<el-input placeholder="请输入分类名称" |
||||||
|
v-model="Form.categoryName"></el-input> |
||||||
|
</el-form-item> |
||||||
|
</el-form> |
||||||
|
<span slot="footer" |
||||||
|
class="dialog-footer"> |
||||||
|
<el-button @click="typeVisible = false">取 消</el-button> |
||||||
|
<el-button type="primary" |
||||||
|
@click="submit">确 定</el-button> |
||||||
|
</span> |
||||||
|
</el-dialog> |
||||||
|
</div> |
||||||
</template> |
</template> |
||||||
<script> |
<script> |
||||||
import OrgTree from "@/components/org-tree/src/tree"; |
import OrgTree from "@/components/org-tree/src/tree"; |
||||||
export default { |
export default { |
||||||
props: ["Data"], |
props: ["Data"], |
||||||
data() { |
data () { |
||||||
return { |
return { |
||||||
systemId: this.$route.query.systemId, |
systemId: this.$route.query.systemId, |
||||||
orgList: [], |
orgList: [], |
||||||
typeVisible: false, |
typeVisible: false, |
||||||
Form: { |
Form: { |
||||||
id: '', |
id: '', |
||||||
parentId: '', |
parentId: '', |
||||||
categoryName: '', |
categoryName: '', |
||||||
level: '' |
level: '' |
||||||
}, |
}, |
||||||
rules: { |
rules: { |
||||||
categoryName: [ |
categoryName: [ |
||||||
{ required: true, message: "请输入分类名称", trigger: "blur" } |
{ required: true, message: "请输入分类名称", trigger: "blur" } |
||||||
] |
] |
||||||
} |
}, |
||||||
}; |
schoolActive: 0 |
||||||
}, |
}; |
||||||
components: { |
}, |
||||||
OrgTree |
components: { |
||||||
}, |
OrgTree |
||||||
mounted() { |
}, |
||||||
this.getType() |
mounted () { |
||||||
}, |
this.getType() |
||||||
methods: { |
}, |
||||||
getType() { |
methods: { |
||||||
this.$post(this.api.sourceModelClassification).then(res => { |
// 查询全部分类 |
||||||
const { data } = res |
getType () { |
||||||
this.orgList = data |
this.$post(this.api.sourceModelClassification, { |
||||||
data.length && this.$nextTick(() => { |
founder: 0 |
||||||
const categoryId = this.$route.query.categoryId |
}).then(res => { |
||||||
this.$refs.tree.setCurrentKey(categoryId || data[0].id) |
const { data } = res |
||||||
this.$router.push({ |
this.orgList = data |
||||||
path: 'backstage', |
data.length && this.$nextTick(() => { |
||||||
query: { |
const categoryId = this.$route.query.categoryId |
||||||
...this.$route.query, |
this.$refs.tree.setCurrentKey(categoryId || data[0].id) |
||||||
categoryId: this.$refs.tree.getCurrentKey() |
|
||||||
} |
|
||||||
}).catch(err => {}) |
|
||||||
this.$emit('getData') |
|
||||||
}) |
|
||||||
}).catch(res => {}) |
|
||||||
}, |
|
||||||
getSingle() { |
|
||||||
this.$router.push({ |
this.$router.push({ |
||||||
path: 'backstage', |
path: 'backstage', |
||||||
query: { |
query: { |
||||||
...this.$route.query, |
...this.$route.query, |
||||||
categoryId: this.$refs.tree.getCurrentKey() |
categoryId: this.$refs.tree.getCurrentKey() |
||||||
} |
} |
||||||
}).catch(err => {}) |
}).catch(err => { }) |
||||||
this.$emit('initData') |
this.$emit('getData') |
||||||
}, |
}) |
||||||
// 添加分类 |
}).catch(res => { }) |
||||||
addType(node, data) { |
}, |
||||||
this.typeVisible = true |
// 分类点击回调 |
||||||
this.Form.parentId = data ? data.id : 0 |
getSingle () { |
||||||
this.Form.level = node ? node.level : 0 |
this.schoolActive = 0 |
||||||
}, |
this.$router.push({ |
||||||
// 编辑分类 |
path: 'backstage', |
||||||
editType(data) { |
query: { |
||||||
this.Form.id = data.id |
...this.$route.query, |
||||||
this.Form.parentId = data ? data.parentId : 0 |
categoryId: this.$refs.tree.getCurrentKey() |
||||||
this.Form.categoryName = data.categoryName |
} |
||||||
this.typeVisible = true |
}).catch(err => { }) |
||||||
}, |
this.$emit('initData') |
||||||
// 保存分类 |
}, |
||||||
submit() { |
// 院校创建点击回调 |
||||||
this.$refs['Form'].validate((valid) => { |
schoolClick () { |
||||||
if (valid) { |
this.schoolActive = 1 |
||||||
const form = this.Form |
this.$emit('initData', 1) |
||||||
const data = { |
}, |
||||||
id: form.id, |
// 添加分类 |
||||||
parentId: form.parentId, |
addType (node, data) { |
||||||
categoryName: form.categoryName, |
this.typeVisible = true |
||||||
systemId: this.systemId |
this.Form.parentId = data ? data.id : 0 |
||||||
} |
this.Form.level = node ? node.level : 0 |
||||||
if (data.id) { |
}, |
||||||
this.$post(this.api.updateSourceModelCategory, data).then(res => { |
// 编辑分类 |
||||||
this.$message.success("编辑成功") |
editType (data) { |
||||||
this.typeVisible = false |
this.Form.id = data.id |
||||||
this.getType() |
this.Form.parentId = data ? data.parentId : 0 |
||||||
}).catch(res => {}) |
this.Form.categoryName = data.categoryName |
||||||
} else { |
this.typeVisible = true |
||||||
data.level = form.level |
}, |
||||||
this.$post(this.api.categorySave, data).then(res => { |
// 保存分类 |
||||||
this.$message.success("添加成功") |
submit () { |
||||||
this.typeVisible = false |
this.$refs['Form'].validate((valid) => { |
||||||
this.getType() |
if (valid) { |
||||||
}).catch(res => {}) |
const form = this.Form |
||||||
} |
const data = { |
||||||
} |
id: form.id, |
||||||
}) |
parentId: form.parentId, |
||||||
}, |
categoryName: form.categoryName, |
||||||
closeDia() { |
systemId: this.systemId, |
||||||
this.$refs.Form.resetFields() |
founder: 0 |
||||||
this.Form = { |
} |
||||||
id: '', |
if (data.id) { |
||||||
parentId: '', |
this.$post(this.api.updateSourceModelCategory, data).then(res => { |
||||||
categoryName: '' |
this.$message.success("编辑成功") |
||||||
} |
this.typeVisible = false |
||||||
}, |
this.getType() |
||||||
// 删除分类 |
}).catch(res => { }) |
||||||
delType(item) { |
} else { |
||||||
this.$confirm("确定要删除分类吗?", "提示", { |
data.level = form.level |
||||||
type: "warning" |
this.$post(this.api.categorySave, data).then(res => { |
||||||
}).then(() => { |
this.$message.success("添加成功") |
||||||
this.$post(`${this.api.deleteSourceModelCategory}?categoryId=${item.id}`).then(res => { |
this.typeVisible = false |
||||||
this.$message.success("删除成功") |
this.getType() |
||||||
this.$emit('initData') |
}).catch(res => { }) |
||||||
this.getType() |
} |
||||||
}).catch(res => {}) |
|
||||||
}).catch(() => {}) |
|
||||||
} |
} |
||||||
|
}) |
||||||
|
}, |
||||||
|
closeDia () { |
||||||
|
this.$refs.Form.resetFields() |
||||||
|
this.Form = { |
||||||
|
id: '', |
||||||
|
parentId: '', |
||||||
|
categoryName: '' |
||||||
|
} |
||||||
|
}, |
||||||
|
// 删除分类 |
||||||
|
delType (item) { |
||||||
|
this.$confirm("确定要删除分类吗?", "提示", { |
||||||
|
type: "warning" |
||||||
|
}).then(() => { |
||||||
|
this.$post(`${this.api.deleteSourceModelCategory}?categoryId=${item.id}`).then(res => { |
||||||
|
this.$message.success("删除成功") |
||||||
|
this.$emit('initData') |
||||||
|
this.getType() |
||||||
|
}).catch(res => { }) |
||||||
|
}).catch(() => { }) |
||||||
} |
} |
||||||
|
} |
||||||
}; |
}; |
||||||
</script> |
</script> |
||||||
<style lang="scss" scoped> |
<style lang="scss" scoped> |
||||||
|
.school-create { |
||||||
|
padding: 3px 5px 3px 23px; |
||||||
|
margin-top: 5px; |
||||||
|
font-size: 14px; |
||||||
|
cursor: pointer; |
||||||
|
&.active { |
||||||
|
background-color: #f0f7ff; |
||||||
|
} |
||||||
|
&:hover { |
||||||
|
background-color: #f0f7ff; |
||||||
|
} |
||||||
|
} |
||||||
</style> |
</style> |
||||||
|
Loading…
Reference in new issue