✨ feat: 部门选择组件添加快捷二次菜单
This commit is contained in:
parent
9568f7b59c
commit
1a8bffc97a
|
@ -8,6 +8,11 @@
|
||||||
placeholder="请选择组织部门"
|
placeholder="请选择组织部门"
|
||||||
@select="handleDeptSelect"
|
@select="handleDeptSelect"
|
||||||
/>
|
/>
|
||||||
|
<el-button-group v-if="showQuickGroup">
|
||||||
|
<el-button v-for="child in firstChildList" :key="child.deptName" plain @click="quickSelect(child)">
|
||||||
|
{{ child.deptName }}
|
||||||
|
</el-button>
|
||||||
|
</el-button-group>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -15,18 +20,25 @@
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
import to from "@/utils/await-to.js";
|
import to from "@/utils/await-to.js";
|
||||||
import { listDept} from "@/api/system/dept";
|
import { listDept } from "@/api/system/dept";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "DeptTree",
|
name: "DeptTree",
|
||||||
components: {
|
components: {
|
||||||
Treeselect,
|
Treeselect,
|
||||||
},
|
},
|
||||||
|
props: {
|
||||||
|
showQuickGroup: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
deptId: "",
|
deptId: "",
|
||||||
// 部门树数据
|
// 部门树数据
|
||||||
deptList: [],
|
deptList: [],
|
||||||
|
firstChildList: [],
|
||||||
normalizer(node) {
|
normalizer(node) {
|
||||||
return {
|
return {
|
||||||
id: node.deptId,
|
id: node.deptId,
|
||||||
|
@ -56,11 +68,14 @@ export default {
|
||||||
// this.$message.error("默认企业配置错误,请配置sys.user.defaultFactoryId");
|
// this.$message.error("默认企业配置错误,请配置sys.user.defaultFactoryId");
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
|
quickSelect(child) {
|
||||||
|
this.deptId = child.deptId;
|
||||||
|
this.$emit("deptChange", child);
|
||||||
|
},
|
||||||
async initDeptList() {
|
async initDeptList() {
|
||||||
const [err, response] = await to(
|
const [err, response] = await to(
|
||||||
listDept({
|
listDept({
|
||||||
deptName: undefined,
|
deptName: undefined,
|
||||||
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -71,7 +86,8 @@ export default {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.deptList = this.handleTree(response.data, "deptId");
|
this.deptList = this.handleTree(response.data, "deptId");
|
||||||
this.deptId = this.deptList[0].deptId;
|
this.deptId = this.deptList[0].deptId;
|
||||||
this.$emit("deptChange", this.deptList[0]);
|
this.firstChildList = this.deptList[0].children;
|
||||||
|
this.$emit("deptChange", this.deptList[0]);
|
||||||
} else {
|
} else {
|
||||||
console.error(response);
|
console.error(response);
|
||||||
this.$message.error(response.msg);
|
this.$message.error(response.msg);
|
||||||
|
@ -85,4 +101,14 @@ export default {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
.dept-tree {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
.el-button-group {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="data-monitor">
|
<div class="data-monitor">
|
||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col :span="6" style="margin-top: 10px; margin-bottom: 10px">
|
<el-col :span="10" style="margin-top: 10px; margin-bottom: 10px">
|
||||||
<dept-tree @deptChange="handleDeptChange" />
|
<dept-tree @deptChange="handleDeptChange" :showQuickGroup="true" />
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6" style="margin-top: 10px; margin-bottom: 10px">
|
<el-col :span="6" style="margin-top: 10px; margin-bottom: 10px">
|
||||||
<!-- 时间范围选择 -->
|
<!-- 时间范围选择 -->
|
||||||
<el-date-picker v-model="dateValue" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期"
|
<el-date-picker
|
||||||
:default-time="['00:00:00', '23:59:59']" @change="handleDateChange">
|
v-model="dateValue"
|
||||||
|
type="daterange"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
:default-time="['00:00:00', '23:59:59']"
|
||||||
|
@change="handleDateChange"
|
||||||
|
>
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col>
|
|
||||||
<el-radio-group v-model="deptId" @change="handleRadioDeptChange">
|
|
||||||
<el-radio-button :label="229">青岛港</el-radio-button>
|
|
||||||
<el-radio-button :label="230">日照港</el-radio-button>
|
|
||||||
<el-radio-button :label="231">烟台港</el-radio-button>
|
|
||||||
<el-radio-button :label="232">渤海湾港</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -36,13 +33,6 @@ export default {
|
||||||
// chooseDept:null,
|
// chooseDept:null,
|
||||||
deptId: "",
|
deptId: "",
|
||||||
dateValue: [],
|
dateValue: [],
|
||||||
normalizer(node) {
|
|
||||||
return {
|
|
||||||
id: node.deptId,
|
|
||||||
label: node.deptName,
|
|
||||||
children: node.children,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -64,8 +54,8 @@ export default {
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
handleRadioDeptChange(value) {
|
handleRadioDeptChange(value) {
|
||||||
this.deptId = value
|
this.deptId = value;
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
},
|
},
|
||||||
handleDeptChange(value) {
|
handleDeptChange(value) {
|
||||||
this.deptId = value.deptId;
|
this.deptId = value.deptId;
|
||||||
|
|
Loading…
Reference in New Issue