增加机构管理
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
export async function getOrganizationsCmmssn(params) {
|
||||
const res = await request.get('/system/organizationCmmssn', {
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
export async function updateOrganizationCmmssn(data) {
|
||||
const res = await request.put('/system/OrganizationCmmssn', data);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
@@ -1,23 +1,5 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
/**
|
||||
* 分页查询机构
|
||||
* @param params 查询条件
|
||||
*/
|
||||
export async function pageOrganizations(params) {
|
||||
const res = await request.get('/system/organization/page', {
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询机构列表
|
||||
* @param params 查询条件
|
||||
*/
|
||||
export async function listOrganizations(params) {
|
||||
const res = await request.get('/system/organization', {
|
||||
params
|
||||
@@ -28,36 +10,26 @@ export async function listOrganizations(params) {
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加机构
|
||||
* @param data 机构信息
|
||||
*/
|
||||
export async function addOrganization(data) {
|
||||
const res = await request.post('/system/organization', data);
|
||||
const res = await request.post('/system/Organization', data);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改机构
|
||||
* @param data 机构信息
|
||||
*/
|
||||
export async function updateOrganization(data) {
|
||||
const res = await request.put('/system/organization', data);
|
||||
const res = await request.put('/system/Organization', data);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除机构
|
||||
* @param id 机构id
|
||||
*/
|
||||
export async function removeOrganization(id) {
|
||||
const res = await request.delete('/system/organization/' + id);
|
||||
const res = await request.delete('/system/Organization', {
|
||||
data: { id }
|
||||
});
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="720px"
|
||||
:visible="visible"
|
||||
:close-on-click-modal="true"
|
||||
custom-class="ele-dialog-form"
|
||||
title="修改佣金"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
|
||||
<el-form-item label="一级线索佣金比例:">
|
||||
<el-input
|
||||
clearable
|
||||
v-model="form.cluesLevel1"
|
||||
type="number"
|
||||
placeholder="请输入一级线索佣金"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="二级线索佣金比例:">
|
||||
<el-input
|
||||
clearable
|
||||
v-model="form.cluesLevel2"
|
||||
type="number"
|
||||
placeholder="请输入二级线索佣金"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="三级线索佣金比例:">
|
||||
<el-input
|
||||
clearable
|
||||
v-model="form.cluesLevel3"
|
||||
type="number"
|
||||
placeholder="请输入三级线索佣金"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="四级线索佣金比例:">
|
||||
<el-input
|
||||
clearable
|
||||
v-model="form.cluesLevel4"
|
||||
type="number"
|
||||
placeholder="请输入四级线索佣金"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="一级订单佣金比例:">
|
||||
<el-input
|
||||
clearable
|
||||
v-model="form.orderLevel1"
|
||||
type="number"
|
||||
placeholder="请输入一订单索佣金"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="二级订单佣金比例:">
|
||||
<el-input
|
||||
clearable
|
||||
v-model="form.orderLevel2"
|
||||
type="number"
|
||||
placeholder="请输入二订单索佣金"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="三级订单佣金比例:">
|
||||
<el-input
|
||||
clearable
|
||||
v-model="form.orderLevel3"
|
||||
type="number"
|
||||
placeholder="请输入三级订单佣金"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="四级订单佣金比例:">
|
||||
<el-input
|
||||
clearable
|
||||
v-model="form.orderLevel4"
|
||||
type="number"
|
||||
placeholder="请输入四级订单佣金"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template v-slot:footer>
|
||||
<el-button @click="updateVisible(false)">取消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="save">
|
||||
保存
|
||||
</el-button>
|
||||
</template>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getOrganizationsCmmssn,
|
||||
updateOrganizationCmmssn
|
||||
} from '@/api/system/cmmssn';
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
props: {
|
||||
// 弹窗是否打开
|
||||
visible: Boolean,
|
||||
data: Object
|
||||
},
|
||||
data() {
|
||||
const defaultForm = {
|
||||
id: null,
|
||||
teamId: '',
|
||||
cluesLevel1: '',
|
||||
cluesLevel2: '',
|
||||
cluesLevel3: '',
|
||||
cluesLevel4: '',
|
||||
orderLevel1: '',
|
||||
orderLevel2: '',
|
||||
orderLevel3: '',
|
||||
orderLevel4: '',
|
||||
showLevel: 3
|
||||
};
|
||||
return {
|
||||
defaultForm,
|
||||
// 表单数据
|
||||
form: { ...defaultForm },
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
title: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
},
|
||||
// 提交状态
|
||||
loading: false,
|
||||
// 是否是修改
|
||||
isUpdate: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 是否开启响应式布局
|
||||
styleResponsive() {
|
||||
return this.$store.state.theme.styleResponsive;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
query() {
|
||||
if (!this.form.teamId) {
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
getOrganizationsCmmssn({ teamId: this.form.teamId })
|
||||
.then((data) => {
|
||||
this.loading = false;
|
||||
this.$util.assignObject(this.form, { ...data });
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
},
|
||||
/* 保存编辑 */
|
||||
save() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
this.loading = true;
|
||||
const data = {
|
||||
...this.form
|
||||
};
|
||||
updateOrganizationCmmssn(data)
|
||||
.then((msg) => {
|
||||
this.loading = false;
|
||||
this.$message.success(msg);
|
||||
this.updateVisible(false);
|
||||
// this.$emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
});
|
||||
},
|
||||
/* 更新visible */
|
||||
updateVisible(value) {
|
||||
this.$emit('update:visible', value);
|
||||
},
|
||||
/* 判断是否是目录 */
|
||||
isDirectory(d) {
|
||||
return !!d.children?.length && !d.component;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(visible) {
|
||||
if (visible) {
|
||||
if (this.data) {
|
||||
this.form.teamId = this.data.id;
|
||||
this.query();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,163 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="720px"
|
||||
:visible="visible"
|
||||
:close-on-click-modal="true"
|
||||
custom-class="ele-dialog-form"
|
||||
:title="isUpdate ? '修改机构' : '添加机构'"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="92px">
|
||||
<el-form-item label="上级菜单:">
|
||||
<ele-tree-select
|
||||
clearable
|
||||
v-model="form.parentId"
|
||||
:data="organizationList"
|
||||
label-key="title"
|
||||
value-key="id"
|
||||
default-expand-all
|
||||
placeholder="请选择上级菜单"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="名称:" prop="title">
|
||||
<el-input clearable v-model="form.title" placeholder="请输入名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="logo:" prop="logo">
|
||||
<upload-img
|
||||
v-model="form.logo"
|
||||
:images="form.logo"
|
||||
:limit="1"
|
||||
:multiple="true"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注:" prop="meta">
|
||||
<el-input
|
||||
:rows="4"
|
||||
type="textarea"
|
||||
:maxlength="200"
|
||||
v-model="form.remark"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template v-slot:footer>
|
||||
<el-button @click="updateVisible(false)">取消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="save">
|
||||
保存
|
||||
</el-button>
|
||||
</template>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
addOrganization,
|
||||
updateOrganization
|
||||
} from '@/api/system/organization';
|
||||
import UploadImg from '@/components/UploadImg/index.vue';
|
||||
|
||||
export default {
|
||||
components: { UploadImg },
|
||||
props: {
|
||||
// 弹窗是否打开
|
||||
visible: Boolean,
|
||||
// 修改回显的数据
|
||||
data: Object,
|
||||
// 上级菜单id
|
||||
parentId: Number,
|
||||
// 全部菜单数据
|
||||
organizationList: Array
|
||||
},
|
||||
data() {
|
||||
const defaultForm = {
|
||||
id: null,
|
||||
parentId: '',
|
||||
title: '',
|
||||
logo: [],
|
||||
remark: ''
|
||||
};
|
||||
return {
|
||||
defaultForm,
|
||||
// 表单数据
|
||||
form: { ...defaultForm },
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
title: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
},
|
||||
// 提交状态
|
||||
loading: false,
|
||||
// 是否是修改
|
||||
isUpdate: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 是否开启响应式布局
|
||||
styleResponsive() {
|
||||
return this.$store.state.theme.styleResponsive;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/* 保存编辑 */
|
||||
save() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
this.loading = true;
|
||||
const data = {
|
||||
...this.form,
|
||||
parentId: this.form.parentId || 0
|
||||
};
|
||||
const saveOrUpdate = this.isUpdate
|
||||
? updateOrganization
|
||||
: addOrganization;
|
||||
saveOrUpdate(data)
|
||||
.then((msg) => {
|
||||
this.loading = false;
|
||||
this.$message.success(msg);
|
||||
this.updateVisible(false);
|
||||
this.$emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
});
|
||||
},
|
||||
/* 更新visible */
|
||||
updateVisible(value) {
|
||||
this.$emit('update:visible', value);
|
||||
},
|
||||
/* 判断是否是目录 */
|
||||
isDirectory(d) {
|
||||
return !!d.children?.length && !d.component;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(visible) {
|
||||
if (visible) {
|
||||
if (this.data) {
|
||||
this.$util.assignObject(this.form, {
|
||||
...this.data,
|
||||
parentId: this.data.parentId === 0 ? '' : this.data.parentId ?? ''
|
||||
});
|
||||
this.isUpdate = true;
|
||||
} else {
|
||||
this.form.parentId = this.parentId ?? '';
|
||||
this.isUpdate = false;
|
||||
}
|
||||
} else {
|
||||
this.$refs.form.clearValidate();
|
||||
this.form = { ...this.defaultForm };
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,216 +0,0 @@
|
||||
<!-- 机构编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="680px"
|
||||
:visible="visible"
|
||||
:close-on-click-modal="true"
|
||||
custom-class="ele-dialog-form"
|
||||
:title="isUpdate ? '修改机构' : '添加机构'"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="82px">
|
||||
<el-row :gutter="15">
|
||||
<el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
||||
<el-form-item label="上级机构:">
|
||||
<org-select
|
||||
v-model="form.parentId"
|
||||
:data="organizationList"
|
||||
placeholder="请选择上级机构"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="机构名称:" prop="organizationName">
|
||||
<el-input
|
||||
clearable
|
||||
:maxlength="20"
|
||||
v-model="form.organizationName"
|
||||
placeholder="请输入机构名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="机构全称:" prop="organizationFullName">
|
||||
<el-input
|
||||
clearable
|
||||
:maxlength="100"
|
||||
v-model="form.organizationFullName"
|
||||
placeholder="请输入机构全称"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="机构代码:" prop="organizationCode">
|
||||
<el-input
|
||||
clearable
|
||||
:maxlength="20"
|
||||
v-model="form.organizationCode"
|
||||
placeholder="请输入机构代码"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
||||
<el-form-item label="机构类型:" prop="organizationType">
|
||||
<org-type-select v-model="form.organizationType" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序号:" prop="sortNumber">
|
||||
<el-input-number
|
||||
:min="0"
|
||||
:max="99999"
|
||||
v-model="form.sortNumber"
|
||||
controls-position="right"
|
||||
placeholder="请输入排序号"
|
||||
class="ele-fluid ele-text-left"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注:">
|
||||
<el-input
|
||||
:rows="4"
|
||||
type="textarea"
|
||||
:maxlength="200"
|
||||
v-model="form.comments"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template v-slot:footer>
|
||||
<el-button @click="updateVisible(false)">取消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="save">
|
||||
保存
|
||||
</el-button>
|
||||
</template>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OrgSelect from './org-select.vue';
|
||||
import OrgTypeSelect from './org-type-select.vue';
|
||||
import {
|
||||
addOrganization,
|
||||
updateOrganization
|
||||
} from '@/api/system/organization';
|
||||
|
||||
export default {
|
||||
components: { OrgSelect, OrgTypeSelect },
|
||||
props: {
|
||||
// 弹窗是否打开
|
||||
visible: Boolean,
|
||||
// 修改回显的数据
|
||||
data: Object,
|
||||
// 上级id
|
||||
parentId: Number,
|
||||
// 机构数据
|
||||
organizationList: Array
|
||||
},
|
||||
data() {
|
||||
const defaultForm = {
|
||||
organizationId: null,
|
||||
parentId: null,
|
||||
organizationName: '',
|
||||
organizationFullName: '',
|
||||
organizationCode: '',
|
||||
organizationType: null,
|
||||
sortNumber: null,
|
||||
comments: ''
|
||||
};
|
||||
return {
|
||||
defaultForm,
|
||||
// 表单数据
|
||||
form: { ...defaultForm },
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
organizationName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入机构名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
organizationFullName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入机构全称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
organizationCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入机构代码',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
organizationType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择机构类型',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
},
|
||||
// 提交状态
|
||||
loading: false,
|
||||
// 是否是修改
|
||||
isUpdate: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 是否开启响应式布局
|
||||
styleResponsive() {
|
||||
return this.$store.state.theme.styleResponsive;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/* 保存编辑 */
|
||||
save() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
this.loading = true;
|
||||
const data = {
|
||||
...this.form,
|
||||
parentId: this.form.parentId || 0
|
||||
};
|
||||
const saveOrUpdate = this.isUpdate
|
||||
? updateOrganization
|
||||
: addOrganization;
|
||||
saveOrUpdate(data)
|
||||
.then((msg) => {
|
||||
this.loading = false;
|
||||
this.$message.success(msg);
|
||||
this.updateVisible(false);
|
||||
this.$emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
});
|
||||
},
|
||||
/* 更新visible */
|
||||
updateVisible(value) {
|
||||
this.$emit('update:visible', value);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(visible) {
|
||||
if (visible) {
|
||||
if (this.data) {
|
||||
this.$util.assignObject(this.form, this.data);
|
||||
this.isUpdate = true;
|
||||
} else {
|
||||
this.form.parentId = this.parentId;
|
||||
this.isUpdate = false;
|
||||
}
|
||||
} else {
|
||||
this.$refs.form.clearValidate();
|
||||
this.form = { ...this.defaultForm };
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,35 +0,0 @@
|
||||
<!-- 机构选择下拉框 -->
|
||||
<template>
|
||||
<ele-tree-select
|
||||
clearable
|
||||
:value="value || ''"
|
||||
:data="data"
|
||||
label-key="organizationName"
|
||||
value-key="organizationId"
|
||||
default-expand-all
|
||||
:placeholder="placeholder"
|
||||
@input="updateValue"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
// 选中的数据(v-model)
|
||||
value: Number,
|
||||
// 提示信息
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请选择机构'
|
||||
},
|
||||
// 机构数据
|
||||
data: Array
|
||||
},
|
||||
methods: {
|
||||
/* 更新选中数据 */
|
||||
updateValue(value) {
|
||||
this.$emit('input', value);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,57 +0,0 @@
|
||||
<!-- 机构类型选择下拉框 -->
|
||||
<template>
|
||||
<el-select
|
||||
clearable
|
||||
:value="value"
|
||||
class="ele-fluid"
|
||||
:placeholder="placeholder"
|
||||
@input="updateValue"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in data"
|
||||
:key="item.dictDataId"
|
||||
:value="item.dictDataCode"
|
||||
:label="item.dictDataName"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listDictionaryData } from '@/api/system/dictionary-data';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
// 选中的数据(v-modal)
|
||||
value: String,
|
||||
// 提示信息
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请选择机构类型'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 机构类型数据
|
||||
data: []
|
||||
};
|
||||
},
|
||||
created() {
|
||||
/* 获取机构类型数据 */
|
||||
listDictionaryData({
|
||||
dictCode: 'organization_type'
|
||||
})
|
||||
.then((list) => {
|
||||
this.data = list;
|
||||
})
|
||||
.catch((e) => {
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/* 更新选中数据 */
|
||||
updateValue(value) {
|
||||
this.$emit('input', value);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,264 +0,0 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="680px"
|
||||
:visible="visible"
|
||||
:close-on-click-modal="true"
|
||||
custom-class="ele-dialog-form"
|
||||
:title="isUpdate ? '修改用户' : '添加用户'"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="82px">
|
||||
<el-row :gutter="15">
|
||||
<el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
||||
<el-form-item label="所属机构:">
|
||||
<org-select
|
||||
:data="organizationList"
|
||||
placeholder="请选择所属机构"
|
||||
v-model="form.organizationId"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户账号:" prop="username">
|
||||
<el-input
|
||||
clearable
|
||||
:maxlength="20"
|
||||
:disabled="isUpdate"
|
||||
v-model="form.username"
|
||||
placeholder="请输入账号"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户名:" prop="nickname">
|
||||
<el-input
|
||||
clearable
|
||||
:maxlength="20"
|
||||
v-model="form.nickname"
|
||||
placeholder="请输入用户名"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="性别:" prop="sex">
|
||||
<el-select
|
||||
clearable
|
||||
class="ele-block"
|
||||
v-model="form.sex"
|
||||
placeholder="请选择性别"
|
||||
>
|
||||
<el-option label="男" value="1" />
|
||||
<el-option label="女" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色:" prop="roleIds">
|
||||
<role-select v-model="form.roleIds" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
||||
<el-form-item label="手机号:" prop="phone">
|
||||
<el-input
|
||||
clearable
|
||||
:maxlength="11"
|
||||
v-model="form.phone"
|
||||
placeholder="请输入手机号"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱:" prop="email">
|
||||
<el-input
|
||||
clearable
|
||||
:maxlength="100"
|
||||
v-model="form.email"
|
||||
placeholder="请输入邮箱"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="!isUpdate" label="登录密码:" prop="password">
|
||||
<el-input
|
||||
show-password
|
||||
:maxlength="20"
|
||||
v-model="form.password"
|
||||
placeholder="请输入登录密码"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="个人简介:">
|
||||
<el-input
|
||||
:rows="4"
|
||||
type="textarea"
|
||||
:maxlength="200"
|
||||
v-model="form.introduction"
|
||||
placeholder="请输入个人简介"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template v-slot:footer>
|
||||
<el-button @click="updateVisible(false)">取消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="save">
|
||||
保存
|
||||
</el-button>
|
||||
</template>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { emailReg, phoneReg } from 'ele-admin';
|
||||
import OrgSelect from './org-select.vue';
|
||||
import RoleSelect from '@/views/system/user/components/role-select.vue';
|
||||
import { addUser, updateUser, checkExistence } from '@/api/system/user';
|
||||
|
||||
export default {
|
||||
components: { OrgSelect, RoleSelect },
|
||||
props: {
|
||||
// 弹窗是否打开
|
||||
visible: Boolean,
|
||||
// 修改回显的数据
|
||||
data: Object,
|
||||
// 全部机构
|
||||
organizationList: Array,
|
||||
// 机构id
|
||||
organizationId: Number
|
||||
},
|
||||
data() {
|
||||
const defaultForm = {
|
||||
userId: null,
|
||||
organizationId: null,
|
||||
username: '',
|
||||
nickname: '',
|
||||
sex: null,
|
||||
roleIds: [],
|
||||
email: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
introduction: ''
|
||||
};
|
||||
return {
|
||||
defaultForm,
|
||||
// 表单数据
|
||||
form: { ...defaultForm },
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
username: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
validator: (_rule, value, callback) => {
|
||||
if (!value) {
|
||||
return callback(new Error('请输入用户账号'));
|
||||
}
|
||||
checkExistence('username', value, this.data?.username)
|
||||
.then(() => {
|
||||
callback(new Error('账号已经存在'));
|
||||
})
|
||||
.catch(() => {
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
nickname: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入用户名',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sex: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择性别',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
roleIds: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择角色',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
email: [
|
||||
{
|
||||
pattern: emailReg,
|
||||
message: '邮箱格式不正确',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
password: [
|
||||
{
|
||||
required: true,
|
||||
pattern: /^[\S]{5,18}$/,
|
||||
message: '密码必须为5-18位非空白字符',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
phone: [
|
||||
{
|
||||
pattern: phoneReg,
|
||||
message: '手机号格式不正确',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
},
|
||||
// 提交状态
|
||||
loading: false,
|
||||
// 是否是修改
|
||||
isUpdate: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 是否开启响应式布局
|
||||
styleResponsive() {
|
||||
return this.$store.state.theme.styleResponsive;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/* 保存编辑 */
|
||||
save() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
this.loading = true;
|
||||
const data = {
|
||||
...this.form,
|
||||
roles: this.form.roleIds.map((d) => {
|
||||
return { roleId: d };
|
||||
})
|
||||
};
|
||||
const saveOrUpdate = this.isUpdate ? updateUser : addUser;
|
||||
saveOrUpdate(data)
|
||||
.then((msg) => {
|
||||
this.loading = false;
|
||||
this.$message.success(msg);
|
||||
this.updateVisible(false);
|
||||
this.$emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
});
|
||||
},
|
||||
/* 更新visible */
|
||||
updateVisible(value) {
|
||||
this.$emit('update:visible', value);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(visible) {
|
||||
if (visible) {
|
||||
if (this.data) {
|
||||
this.$util.assignObject(this.form, {
|
||||
...this.data,
|
||||
roleIds: this.data.roles.map((d) => d.roleId),
|
||||
password: ''
|
||||
});
|
||||
this.isUpdate = true;
|
||||
} else {
|
||||
this.form.organizationId = this.organizationId;
|
||||
this.isUpdate = false;
|
||||
}
|
||||
} else {
|
||||
this.$refs.form.clearValidate();
|
||||
this.form = { ...this.defaultForm };
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,233 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 数据表格 -->
|
||||
<ele-pro-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
height="calc(100vh - 265px)"
|
||||
full-height="calc(100vh - 116px)"
|
||||
tool-class="ele-toolbar-form"
|
||||
cache-key="systemOrgUserTable"
|
||||
>
|
||||
<!-- 表头工具栏 -->
|
||||
<template v-slot:toolbar>
|
||||
<org-user-search @search="reload">
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
class="ele-btn-icon"
|
||||
@click="openEdit()"
|
||||
>
|
||||
添加
|
||||
</el-button>
|
||||
</org-user-search>
|
||||
</template>
|
||||
<!-- 角色列 -->
|
||||
<template v-slot:roles="{ row }">
|
||||
<el-tag
|
||||
v-for="item in row.roles"
|
||||
:key="item.roleId"
|
||||
type="primary"
|
||||
size="mini"
|
||||
:disable-transitions="true"
|
||||
>
|
||||
{{ item.roleName }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<!-- 状态列 -->
|
||||
<template v-slot:status="{ row }">
|
||||
<el-switch
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
v-model="row.status"
|
||||
@change="editStatus(row)"
|
||||
/>
|
||||
</template>
|
||||
<!-- 操作列 -->
|
||||
<template v-slot:action="{ row }">
|
||||
<el-link
|
||||
type="primary"
|
||||
:underline="false"
|
||||
icon="el-icon-edit"
|
||||
@click="openEdit(row)"
|
||||
>
|
||||
修改
|
||||
</el-link>
|
||||
<el-popconfirm
|
||||
class="ele-action"
|
||||
title="确定要删除此用户吗?"
|
||||
@confirm="remove(row)"
|
||||
>
|
||||
<template v-slot:reference>
|
||||
<el-link type="danger" :underline="false" icon="el-icon-delete">
|
||||
删除
|
||||
</el-link>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
<!-- 编辑弹窗 -->
|
||||
<org-user-edit
|
||||
:data="current"
|
||||
:visible.sync="showEdit"
|
||||
:organization-list="organizationList"
|
||||
:organization-id="organizationId"
|
||||
@done="reload"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OrgUserSearch from './org-user-search.vue';
|
||||
import OrgUserEdit from './org-user-edit.vue';
|
||||
import { pageUsers, removeUser, updateUserStatus } from '@/api/system/user';
|
||||
|
||||
export default {
|
||||
components: { OrgUserSearch, OrgUserEdit },
|
||||
props: {
|
||||
// 机构id
|
||||
organizationId: Number,
|
||||
// 全部机构
|
||||
organizationList: Array
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 表格列配置
|
||||
columns: [
|
||||
{
|
||||
columnKey: 'index',
|
||||
type: 'index',
|
||||
width: 45,
|
||||
align: 'center',
|
||||
showOverflowTooltip: true,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
prop: 'username',
|
||||
label: '用户账号',
|
||||
sortable: 'custom',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 110
|
||||
},
|
||||
{
|
||||
prop: 'nickname',
|
||||
label: '用户名',
|
||||
sortable: 'custom',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 110
|
||||
},
|
||||
{
|
||||
prop: 'sexName',
|
||||
label: '性别',
|
||||
sortable: 'custom',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 80
|
||||
},
|
||||
{
|
||||
prop: 'phone',
|
||||
label: '手机号',
|
||||
sortable: 'custom',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 110
|
||||
},
|
||||
{
|
||||
columnKey: 'roles',
|
||||
label: '角色',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 110,
|
||||
slot: 'roles'
|
||||
},
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '创建时间',
|
||||
sortable: 'custom',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 110,
|
||||
formatter: (_row, _column, cellValue) => {
|
||||
return this.$util.toDateString(cellValue);
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
align: 'center',
|
||||
sortable: 'custom',
|
||||
width: 80,
|
||||
resizable: false,
|
||||
slot: 'status'
|
||||
},
|
||||
{
|
||||
columnKey: 'action',
|
||||
label: '操作',
|
||||
width: 130,
|
||||
align: 'center',
|
||||
resizable: false,
|
||||
slot: 'action',
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
],
|
||||
// 当前编辑数据
|
||||
current: null,
|
||||
// 是否显示编辑弹窗
|
||||
showEdit: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
/* 表格数据源 */
|
||||
datasource({ page, limit, where, order }) {
|
||||
return pageUsers({
|
||||
...where,
|
||||
...order,
|
||||
page,
|
||||
limit,
|
||||
organizationId: this.organizationId
|
||||
});
|
||||
},
|
||||
/* 刷新表格 */
|
||||
reload(where) {
|
||||
this.$refs.table.reload({ page: 1, where: where });
|
||||
},
|
||||
/* 显示编辑 */
|
||||
openEdit(row) {
|
||||
this.current = row;
|
||||
this.showEdit = true;
|
||||
},
|
||||
/* 删除 */
|
||||
remove(row) {
|
||||
const loading = this.$loading({ lock: true });
|
||||
removeUser(row.userId)
|
||||
.then((msg) => {
|
||||
loading.close();
|
||||
this.$message.success(msg);
|
||||
this.reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.close();
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
},
|
||||
/* 更改状态 */
|
||||
editStatus(row) {
|
||||
const loading = this.$loading({ lock: true });
|
||||
updateUserStatus(row.userId, row.status)
|
||||
.then((msg) => {
|
||||
loading.close();
|
||||
this.$message.success(msg);
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.close();
|
||||
row.status = !row.status ? 1 : 0;
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 监听机构id变化
|
||||
organizationId() {
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,79 +0,0 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<el-form
|
||||
size="small"
|
||||
class="ele-form-search"
|
||||
@keyup.enter.native="search"
|
||||
@submit.native.prevent
|
||||
>
|
||||
<el-row :gutter="10">
|
||||
<el-col v-bind="styleResponsive ? { md: 8 } : { span: 8 }">
|
||||
<el-form-item>
|
||||
<el-input
|
||||
clearable
|
||||
size="small"
|
||||
v-model="where.username"
|
||||
placeholder="请输入用户账号"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="styleResponsive ? { md: 8 } : { span: 8 }">
|
||||
<el-form-item>
|
||||
<el-input
|
||||
clearable
|
||||
size="small"
|
||||
v-model="where.nickname"
|
||||
placeholder="请输入用户名"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="styleResponsive ? { md: 8 } : { span: 8 }">
|
||||
<el-form-item>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
class="ele-btn-icon"
|
||||
@click="search"
|
||||
>
|
||||
查询
|
||||
</el-button>
|
||||
<slot></slot>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
// 默认表单数据
|
||||
const defaultWhere = {
|
||||
username: '',
|
||||
nickname: ''
|
||||
};
|
||||
return {
|
||||
// 表单数据
|
||||
where: { ...defaultWhere }
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 是否开启响应式布局
|
||||
styleResponsive() {
|
||||
return this.$store.state.theme.styleResponsive;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/* 搜索 */
|
||||
search() {
|
||||
this.$emit('search', this.where);
|
||||
},
|
||||
/* 重置 */
|
||||
reset() {
|
||||
this.where = { ...this.defaultWhere };
|
||||
this.search();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,82 +1,108 @@
|
||||
<template>
|
||||
<div class="ele-body">
|
||||
<el-card shadow="never" v-loading="loading">
|
||||
<ele-split-layout
|
||||
width="266px"
|
||||
allow-collapse
|
||||
:right-style="{ overflow: 'hidden' }"
|
||||
<el-card shadow="never">
|
||||
<!-- 数据表格 -->
|
||||
<ele-pro-table
|
||||
ref="table"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:default-expand-all="false"
|
||||
:need-page="false"
|
||||
:parse-data="parseData"
|
||||
cache-key="systemOrganizationTable"
|
||||
@done="onDone"
|
||||
>
|
||||
<div>
|
||||
<!-- 操作按钮 -->
|
||||
<ele-toolbar class="ele-toolbar-actions">
|
||||
<div style="margin: 5px 0">
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
class="ele-btn-icon"
|
||||
@click="openEdit()"
|
||||
>
|
||||
添加
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="warning"
|
||||
icon="el-icon-edit"
|
||||
class="ele-btn-icon"
|
||||
:disabled="!current"
|
||||
@click="openEdit(current)"
|
||||
>
|
||||
修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
class="ele-btn-icon"
|
||||
:disabled="!current"
|
||||
@click="remove"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</ele-toolbar>
|
||||
<div class="ele-border-lighter sys-organization-list">
|
||||
<el-tree
|
||||
ref="tree"
|
||||
:data="data"
|
||||
highlight-current
|
||||
node-key="organizationId"
|
||||
:props="{ label: 'organizationName' }"
|
||||
:expand-on-click-node="false"
|
||||
:default-expand-all="true"
|
||||
@node-click="onNodeClick"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<template v-slot:content>
|
||||
<org-user-list
|
||||
v-if="current"
|
||||
:organization-list="data"
|
||||
:organization-id="current.organizationId"
|
||||
/>
|
||||
<!-- 表头工具栏 -->
|
||||
<template v-slot:toolbar>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
class="ele-btn-icon"
|
||||
@click="openEdit()"
|
||||
>
|
||||
添加
|
||||
</el-button>
|
||||
<el-button class="ele-btn-icon" size="small" @click="expandAll">
|
||||
展开全部
|
||||
</el-button>
|
||||
<el-button class="ele-btn-icon" size="small" @click="foldAll">
|
||||
折叠全部
|
||||
</el-button>
|
||||
</template>
|
||||
</ele-split-layout>
|
||||
<!-- 标题列 -->
|
||||
<template v-slot:title="{ row }">
|
||||
<i :class="row.icon"></i> {{ row.title }}
|
||||
</template>
|
||||
<template v-slot:logo="{ row }">
|
||||
<template v-if="row.logo && row.logo[0]">
|
||||
<el-image
|
||||
style="width: 80px; height: 80px"
|
||||
:src="row.logo[0]['url']"
|
||||
:preview-src-list="[row.logo[0]['url']]"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
<!-- 操作列 -->
|
||||
<template v-slot:action="{ row }">
|
||||
<el-link
|
||||
v-if="row.level === 1"
|
||||
type="primary"
|
||||
:underline="false"
|
||||
@click="openEditCmmssn(row)"
|
||||
>
|
||||
佣金配置
|
||||
</el-link>
|
||||
<el-link
|
||||
type="primary"
|
||||
:underline="false"
|
||||
icon="el-icon-plus"
|
||||
@click="openEdit(null, row.id)"
|
||||
>
|
||||
添加
|
||||
</el-link>
|
||||
<el-link
|
||||
type="primary"
|
||||
:underline="false"
|
||||
icon="el-icon-edit"
|
||||
@click="openEdit(row)"
|
||||
>
|
||||
修改
|
||||
</el-link>
|
||||
<el-popconfirm
|
||||
class="ele-action"
|
||||
title="确定要删除吗?"
|
||||
@confirm="remove(row)"
|
||||
>
|
||||
<template v-slot:reference>
|
||||
<el-link type="danger" :underline="false" icon="el-icon-delete">
|
||||
删除
|
||||
</el-link>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</el-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<org-edit
|
||||
:visible.sync="showEdit"
|
||||
:data="editData"
|
||||
<edit
|
||||
:data="current"
|
||||
:parent-id="parentId"
|
||||
:organization-list="data"
|
||||
@done="query"
|
||||
:organization-list="organizationList"
|
||||
:visible.sync="showEdit"
|
||||
@done="reload"
|
||||
/>
|
||||
<edit-cmmssn
|
||||
:data="current"
|
||||
:visible.sync="showEditCmmssn"
|
||||
@done="reload"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OrgUserList from './components/org-user-list.vue';
|
||||
import OrgEdit from './components/org-edit.vue';
|
||||
import Edit from './components/edit.vue';
|
||||
import EditCmmssn from './components/edit-cmmssn.vue';
|
||||
import {
|
||||
listOrganizations,
|
||||
removeOrganization
|
||||
@@ -84,101 +110,127 @@
|
||||
|
||||
export default {
|
||||
name: 'SystemOrganization',
|
||||
components: { OrgUserList, OrgEdit },
|
||||
components: { Edit, EditCmmssn },
|
||||
data() {
|
||||
return {
|
||||
// 加载状态
|
||||
loading: true,
|
||||
// 列表数据
|
||||
data: [],
|
||||
// 选中数据
|
||||
// 表格列配置
|
||||
columns: [
|
||||
{
|
||||
columnKey: 'index',
|
||||
type: 'index',
|
||||
width: 45,
|
||||
align: 'center',
|
||||
showOverflowTooltip: true,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
prop: 'title',
|
||||
label: '名称',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 200
|
||||
},
|
||||
{
|
||||
prop: 'logo',
|
||||
label: 'logo',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 110,
|
||||
slot: 'logo'
|
||||
},
|
||||
{
|
||||
prop: 'remark',
|
||||
label: '备注',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 110
|
||||
},
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '创建时间',
|
||||
showOverflowTooltip: true,
|
||||
minWidth: 110,
|
||||
formatter: (_row, _column, cellValue) => {
|
||||
return this.$util.toDateString(cellValue);
|
||||
}
|
||||
},
|
||||
{
|
||||
columnKey: 'action',
|
||||
label: '操作',
|
||||
width: 250,
|
||||
align: 'center',
|
||||
resizable: false,
|
||||
slot: 'action',
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
],
|
||||
// 当前编辑数据
|
||||
current: null,
|
||||
// 是否显示表单弹窗
|
||||
// 是否显示编辑弹窗
|
||||
showEdit: false,
|
||||
// 编辑回显数据
|
||||
editData: null,
|
||||
// 上级id
|
||||
parentId: null
|
||||
// 全部菜单数据
|
||||
organizationList: [],
|
||||
// 上级菜单id
|
||||
parentId: null,
|
||||
showEditCmmssn: false
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.query();
|
||||
},
|
||||
methods: {
|
||||
/* 查询 */
|
||||
query() {
|
||||
this.loading = true;
|
||||
listOrganizations()
|
||||
.then((list) => {
|
||||
this.loading = false;
|
||||
this.data = this.$util.toTreeData({
|
||||
data: list,
|
||||
idField: 'organizationId',
|
||||
parentIdField: 'parentId'
|
||||
});
|
||||
this.$nextTick(() => {
|
||||
this.onNodeClick(this.data[0]);
|
||||
});
|
||||
/* 表格数据源 */
|
||||
datasource({ where }) {
|
||||
return listOrganizations({ ...where });
|
||||
},
|
||||
/* 数据转为树形结构 */
|
||||
parseData(data) {
|
||||
return this.$util.toTreeData({
|
||||
data: data,
|
||||
idField: 'id',
|
||||
parentIdField: 'parentId'
|
||||
});
|
||||
},
|
||||
/* 表格渲染完成回调 */
|
||||
onDone({ data }) {
|
||||
//if (!this.organizationList.length) {
|
||||
this.organizationList = data;
|
||||
//}
|
||||
},
|
||||
/* 刷新表格 */
|
||||
reload(where) {
|
||||
this.$refs.table.reload({ where: where });
|
||||
},
|
||||
/* 显示编辑 */
|
||||
openEdit(row, parentId) {
|
||||
this.current = row;
|
||||
this.parentId = parentId;
|
||||
this.showEdit = true;
|
||||
},
|
||||
openEditCmmssn(row) {
|
||||
this.current = row;
|
||||
this.showEditCmmssn = true;
|
||||
},
|
||||
/* 删除 */
|
||||
remove(row) {
|
||||
if (row.children?.length) {
|
||||
this.$message.error('请先删除子节点');
|
||||
return;
|
||||
}
|
||||
const loading = this.$loading({ lock: true });
|
||||
removeOrganization(row.id)
|
||||
.then((msg) => {
|
||||
loading.close();
|
||||
this.$message.success(msg);
|
||||
this.reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
loading.close();
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
},
|
||||
/* 选择数据 */
|
||||
onNodeClick(row) {
|
||||
if (row) {
|
||||
this.current = row;
|
||||
this.parentId = row.organizationId;
|
||||
this.$refs.tree.setCurrentKey(row.organizationId);
|
||||
} else {
|
||||
this.current = null;
|
||||
this.parentId = null;
|
||||
}
|
||||
/* 展开全部 */
|
||||
expandAll() {
|
||||
this.$refs.table.toggleRowExpansionAll(true);
|
||||
},
|
||||
/* 显示编辑 */
|
||||
openEdit(item) {
|
||||
this.editData = item;
|
||||
this.showEdit = true;
|
||||
},
|
||||
/* 删除 */
|
||||
remove() {
|
||||
this.$confirm('确定要删除选中的机构吗?', '提示', {
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
const loading = this.$loading({ lock: true });
|
||||
removeOrganization(this.current.organizationId)
|
||||
.then((msg) => {
|
||||
loading.close();
|
||||
this.$message.success(msg);
|
||||
this.query();
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.close();
|
||||
this.$message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
/* 折叠全部 */
|
||||
foldAll() {
|
||||
this.$refs.table.toggleRowExpansionAll(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sys-organization-list {
|
||||
height: calc(100vh - 264px);
|
||||
box-sizing: border-box;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.sys-organization-list :deep(.el-tree-node__content) {
|
||||
height: 40px;
|
||||
|
||||
& > .el-tree-node__expand-icon {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user