功能变化: npm run lint
parent
8cd32c952e
commit
685ac0f5f0
|
@ -1,23 +1,6 @@
|
||||||
/*
|
import { request } from '@/api/service'
|
||||||
* @Author: H0nGzA1
|
import XEUtils from 'xe-utils'
|
||||||
* @Date: 2022-05-16 15:47:21
|
export const urlPrefix = '/api/system/dept/'
|
||||||
* @LastEditors: hongzai 2505811377@qq.com
|
|
||||||
* @LastEditTime: 2022-05-16 16:50:33
|
|
||||||
* @FilePath: /web/src/views/system/dept/api.js
|
|
||||||
* @Description:
|
|
||||||
* email:2505811377@qq.com
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* @创建文件时间: 2021-06-01 22:41:21
|
|
||||||
* @Auther: 猿小天
|
|
||||||
* @最后修改人: 猿小天
|
|
||||||
* @最后修改时间: 2021-09-26 21:17:30
|
|
||||||
* 联系Qq:1638245306
|
|
||||||
* @文件介绍: 部门管理接口
|
|
||||||
*/
|
|
||||||
import { request } from "@/api/service";
|
|
||||||
import XEUtils from "xe-utils";
|
|
||||||
export const urlPrefix = "/api/system/dept/";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表查询
|
* 列表查询
|
||||||
|
@ -26,16 +9,16 @@ export function GetList(query) {
|
||||||
// query.limit = 999;
|
// query.limit = 999;
|
||||||
return request({
|
return request({
|
||||||
url: urlPrefix,
|
url: urlPrefix,
|
||||||
method: "get",
|
method: 'get',
|
||||||
params: query,
|
params: query
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
// 将列表数据转换为树形数据
|
// 将列表数据转换为树形数据
|
||||||
res.data.data = XEUtils.toArrayTree(res.data.data, {
|
res.data.data = XEUtils.toArrayTree(res.data.data, {
|
||||||
parentKey: "parent",
|
parentKey: 'parent',
|
||||||
strict: false,
|
strict: false
|
||||||
});
|
})
|
||||||
return res;
|
return res
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 新增
|
* 新增
|
||||||
|
@ -43,9 +26,9 @@ export function GetList(query) {
|
||||||
export function createObj (obj) {
|
export function createObj (obj) {
|
||||||
return request({
|
return request({
|
||||||
url: urlPrefix,
|
url: urlPrefix,
|
||||||
method: "post",
|
method: 'post',
|
||||||
data: obj,
|
data: obj
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,113 +36,113 @@ export function createObj(obj) {
|
||||||
*/
|
*/
|
||||||
export function UpdateObj (obj) {
|
export function UpdateObj (obj) {
|
||||||
return request({
|
return request({
|
||||||
url: urlPrefix + obj.id + "/",
|
url: urlPrefix + obj.id + '/',
|
||||||
method: "put",
|
method: 'put',
|
||||||
data: obj,
|
data: obj
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
export function DelObj (id) {
|
export function DelObj (id) {
|
||||||
return request({
|
return request({
|
||||||
url: urlPrefix + id + "/",
|
url: urlPrefix + id + '/',
|
||||||
method: "delete",
|
method: 'delete',
|
||||||
data: { id },
|
data: { id }
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GetTreeChildrenByParentId (parentId) {
|
export function GetTreeChildrenByParentId (parentId) {
|
||||||
return TreeNodesLazyLoader.getChildren(parentId);
|
return TreeNodesLazyLoader.getChildren(parentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GetNodesByValues (values) {
|
export function GetNodesByValues (values) {
|
||||||
return TreeNodesLazyLoader.getNodesByValues(values);
|
return TreeNodesLazyLoader.getNodesByValues(values)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getPcasData = request({
|
const getPcasData = request({
|
||||||
url: "/api/system/dept_query/",
|
url: '/api/system/dept_query/',
|
||||||
method: "get",
|
method: 'get'
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
// 将列表数据转换为树形数据
|
// 将列表数据转换为树形数据
|
||||||
res.data.data = XEUtils.toArrayTree(res.data.data, {
|
res.data.data = XEUtils.toArrayTree(res.data.data, {
|
||||||
parentKey: "parent",
|
parentKey: 'parent',
|
||||||
strict: false,
|
strict: false
|
||||||
});
|
})
|
||||||
return res.data.data;
|
return res.data.data
|
||||||
});
|
})
|
||||||
export default getPcasData;
|
export default getPcasData
|
||||||
export const TreeNodesLazyLoader = {
|
export const TreeNodesLazyLoader = {
|
||||||
getNodesByValues (values) {
|
getNodesByValues (values) {
|
||||||
// console.log("getNodesByValues", values);
|
// console.log("getNodesByValues", values);
|
||||||
if (!(values instanceof Array)) {
|
if (!(values instanceof Array)) {
|
||||||
values = [values];
|
values = [values]
|
||||||
}
|
}
|
||||||
return getPcasData.then((data) => {
|
return getPcasData.then((data) => {
|
||||||
const nodes = [];
|
const nodes = []
|
||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
const found = this.getNode(data, value);
|
const found = this.getNode(data, value)
|
||||||
if (found) {
|
if (found) {
|
||||||
nodes.push(found);
|
nodes.push(found)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nodes;
|
return nodes
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
getNode (list, value) {
|
getNode (list, value) {
|
||||||
for (const item of list) {
|
for (const item of list) {
|
||||||
if (item.code === value) {
|
if (item.code === value) {
|
||||||
return item;
|
return item
|
||||||
}
|
}
|
||||||
if (item.children && item.children.length > 0) {
|
if (item.children && item.children.length > 0) {
|
||||||
const found = this.getNode(item.children, value);
|
const found = this.getNode(item.children, value)
|
||||||
if (found) {
|
if (found) {
|
||||||
return found;
|
return found
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getChildren (parent) {
|
getChildren (parent) {
|
||||||
return getPcasData.then((data) => {
|
return getPcasData.then((data) => {
|
||||||
const list = this.getChildrenByParent(parent, data);
|
const list = this.getChildrenByParent(parent, data)
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
return [];
|
return []
|
||||||
}
|
}
|
||||||
return this.cloneAndDeleteChildren(list);
|
return this.cloneAndDeleteChildren(list)
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
getChildrenByParent (parentId, tree) {
|
getChildrenByParent (parentId, tree) {
|
||||||
if (!parentId) {
|
if (!parentId) {
|
||||||
// 取第一级
|
// 取第一级
|
||||||
return tree;
|
return tree
|
||||||
} else {
|
} else {
|
||||||
for (const node of tree) {
|
for (const node of tree) {
|
||||||
if (node.code === parentId) {
|
if (node.code === parentId) {
|
||||||
return node.children;
|
return node.children
|
||||||
}
|
}
|
||||||
if (node.children && node.children.length > 0) {
|
if (node.children && node.children.length > 0) {
|
||||||
// 递归查找
|
// 递归查找
|
||||||
const list = this.getChildrenByParent(parentId, node.children);
|
const list = this.getChildrenByParent(parentId, node.children)
|
||||||
if (list) {
|
if (list) {
|
||||||
return list;
|
return list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cloneAndDeleteChildren (list) {
|
cloneAndDeleteChildren (list) {
|
||||||
const newList = [];
|
const newList = []
|
||||||
for (const node of list) {
|
for (const node of list) {
|
||||||
const newNode = {};
|
const newNode = {}
|
||||||
Object.assign(newNode, node);
|
Object.assign(newNode, node)
|
||||||
if (newNode.children == null || newNode.children.length === 0) {
|
if (newNode.children == null || newNode.children.length === 0) {
|
||||||
newNode.isLeaf = true;
|
newNode.isLeaf = true
|
||||||
newNode.leaf = true;
|
newNode.leaf = true
|
||||||
}
|
}
|
||||||
delete newNode.children;
|
delete newNode.children
|
||||||
newList.push(newNode);
|
newList.push(newNode)
|
||||||
}
|
}
|
||||||
// console.log("found children:", newList);
|
// console.log("found children:", newList);
|
||||||
return newList;
|
return newList
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,110 +1,107 @@
|
||||||
import { request } from "@/api/service";
|
import * as Api from './api'
|
||||||
import { urlPrefix as deptPrefix } from "./api";
|
|
||||||
import XEUtils from "xe-utils";
|
|
||||||
import * as Api from "./api";
|
|
||||||
export const crudOptions = (vm) => {
|
export const crudOptions = (vm) => {
|
||||||
return {
|
return {
|
||||||
// pagination: false,
|
// pagination: false,
|
||||||
pageOptions: {
|
pageOptions: {
|
||||||
compact: true,
|
compact: true
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
tableType: "vxe-table",
|
tableType: 'vxe-table',
|
||||||
rowKey: true, // 必须设置,true or false
|
rowKey: true, // 必须设置,true or false
|
||||||
rowId: "id",
|
rowId: 'id',
|
||||||
height: "100%", // 表格高度100%, 使用toolbar必须设置
|
height: '100%', // 表格高度100%, 使用toolbar必须设置
|
||||||
highlightCurrentRow: false,
|
highlightCurrentRow: false,
|
||||||
defaultExpandAll: true,
|
defaultExpandAll: true,
|
||||||
treeConfig: {
|
treeConfig: {
|
||||||
lazy: true,
|
lazy: true
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
rowHandle: {
|
rowHandle: {
|
||||||
width: 140,
|
width: 140,
|
||||||
view: {
|
view: {
|
||||||
thin: true,
|
thin: true,
|
||||||
text: "",
|
text: '',
|
||||||
disabled () {
|
disabled () {
|
||||||
return !vm.hasPermissions("Retrieve");
|
return !vm.hasPermissions('Retrieve')
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
edit: {
|
edit: {
|
||||||
thin: true,
|
thin: true,
|
||||||
text: "",
|
text: '',
|
||||||
disabled () {
|
disabled () {
|
||||||
return !vm.hasPermissions("Update");
|
return !vm.hasPermissions('Update')
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
remove: {
|
remove: {
|
||||||
thin: true,
|
thin: true,
|
||||||
text: "",
|
text: '',
|
||||||
disabled () {
|
disabled () {
|
||||||
return !vm.hasPermissions("Delete");
|
return !vm.hasPermissions('Delete')
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
indexRow: {
|
indexRow: {
|
||||||
// 或者直接传true,不显示title,不居中
|
// 或者直接传true,不显示title,不居中
|
||||||
title: "序号",
|
title: '序号',
|
||||||
align: "center",
|
align: 'center',
|
||||||
width: 100,
|
width: 100
|
||||||
},
|
},
|
||||||
|
|
||||||
viewOptions: {
|
viewOptions: {
|
||||||
componentType: "form",
|
componentType: 'form'
|
||||||
},
|
},
|
||||||
formOptions: {
|
formOptions: {
|
||||||
defaultSpan: 12, // 默认的表单 span
|
defaultSpan: 12 // 默认的表单 span
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
title: "关键词",
|
title: '关键词',
|
||||||
key: "search",
|
key: 'search',
|
||||||
show: false,
|
show: false,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
search: {
|
search: {
|
||||||
disabled: false,
|
disabled: false
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
disabled: true,
|
disabled: true,
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true
|
||||||
},
|
|
||||||
placeholder: "请输入关键词",
|
|
||||||
},
|
},
|
||||||
|
placeholder: '请输入关键词'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
view: {
|
view: {
|
||||||
// 查看对话框组件的单独配置
|
// 查看对话框组件的单独配置
|
||||||
disabled: true,
|
disabled: true
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "ID",
|
title: 'ID',
|
||||||
key: "id",
|
key: 'id',
|
||||||
show: false,
|
show: false,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
width: 90,
|
width: 90,
|
||||||
form: {
|
form: {
|
||||||
disabled: true,
|
disabled: true
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
show: false,
|
show: false,
|
||||||
title: "上级部门",
|
title: '上级部门',
|
||||||
key: "parent",
|
key: 'parent',
|
||||||
type: "tree-selector",
|
type: 'tree-selector',
|
||||||
dict: {
|
dict: {
|
||||||
isTree: true,
|
isTree: true,
|
||||||
label: "name",
|
label: 'name',
|
||||||
value: "code",
|
value: 'code',
|
||||||
getNodes (values) {
|
getNodes (values) {
|
||||||
// 配置行展示远程获取nodes
|
// 配置行展示远程获取nodes
|
||||||
return Api.GetNodesByValues(values);
|
return Api.GetNodesByValues(values)
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
helper: "默认留空为根节点",
|
helper: '默认留空为根节点',
|
||||||
component: {
|
component: {
|
||||||
span: 12,
|
span: 12,
|
||||||
props: {
|
props: {
|
||||||
|
@ -116,18 +113,18 @@ export const crudOptions = (vm) => {
|
||||||
// console.log("懒加载");
|
// console.log("懒加载");
|
||||||
if (node.level === 0) {
|
if (node.level === 0) {
|
||||||
Api.GetTreeChildrenByParentId().then((data) => {
|
Api.GetTreeChildrenByParentId().then((data) => {
|
||||||
resolve(data);
|
resolve(data)
|
||||||
});
|
})
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
Api.GetTreeChildrenByParentId(node.data.code).then((data) => {
|
Api.GetTreeChildrenByParentId(node.data.code).then((data) => {
|
||||||
resolve(data);
|
resolve(data)
|
||||||
});
|
})
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// title: '上级部门',
|
// title: '上级部门',
|
||||||
|
@ -170,120 +167,120 @@ export const crudOptions = (vm) => {
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
title: "部门名称",
|
title: '部门名称',
|
||||||
key: "name",
|
key: 'name',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
treeNode: true, // 设置为树形列
|
treeNode: true, // 设置为树形列
|
||||||
search: {
|
search: {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
width: 180,
|
width: 180,
|
||||||
type: "input",
|
type: 'input',
|
||||||
form: {
|
form: {
|
||||||
rules: [
|
rules: [
|
||||||
// 表单校验规则
|
// 表单校验规则
|
||||||
{ required: true, message: "部门名称必填项" },
|
{ required: true, message: '部门名称必填项' }
|
||||||
],
|
],
|
||||||
component: {
|
component: {
|
||||||
span: 12,
|
span: 12,
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true
|
||||||
},
|
},
|
||||||
placeholder: "请输入部门名称",
|
placeholder: '请输入部门名称'
|
||||||
},
|
},
|
||||||
itemProps: {
|
itemProps: {
|
||||||
class: { yxtInput: true },
|
class: { yxtInput: true }
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "负责人",
|
title: '负责人',
|
||||||
key: "owner",
|
key: 'owner',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
form: {
|
form: {
|
||||||
component: {
|
component: {
|
||||||
span: 12,
|
span: 12,
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true
|
||||||
},
|
|
||||||
placeholder: "请输入负责人",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
placeholder: '请输入负责人'
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "联系电话",
|
title: '联系电话',
|
||||||
key: "phone",
|
key: 'phone',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
form: {
|
form: {
|
||||||
component: {
|
component: {
|
||||||
span: 12,
|
span: 12,
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true
|
||||||
},
|
|
||||||
placeholder: "请输入联系电话",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
placeholder: '请输入联系电话'
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "邮箱",
|
title: '邮箱',
|
||||||
key: "email",
|
key: 'email',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
form: {
|
form: {
|
||||||
component: {
|
component: {
|
||||||
span: 12,
|
span: 12,
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true
|
||||||
},
|
},
|
||||||
placeholder: "请输入邮箱",
|
placeholder: '请输入邮箱'
|
||||||
},
|
},
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
type: "email",
|
type: 'email',
|
||||||
message: "请输入正确的邮箱地址",
|
message: '请输入正确的邮箱地址',
|
||||||
trigger: ["blur", "change"],
|
trigger: ['blur', 'change']
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "排序",
|
title: '排序',
|
||||||
key: "sort",
|
key: 'sort',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
width: 80,
|
width: 80,
|
||||||
type: "number",
|
type: 'number',
|
||||||
form: {
|
form: {
|
||||||
value: 1,
|
value: 1,
|
||||||
component: {
|
component: {
|
||||||
span: 12,
|
span: 12,
|
||||||
placeholder: "请选择序号",
|
placeholder: '请选择序号'
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "状态",
|
title: '状态',
|
||||||
key: "status",
|
key: 'status',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
search: {
|
search: {
|
||||||
disabled: false,
|
disabled: false
|
||||||
},
|
},
|
||||||
width: 90,
|
width: 90,
|
||||||
type: "radio",
|
type: 'radio',
|
||||||
dict: {
|
dict: {
|
||||||
data: vm.dictionary("button_status_bool"),
|
data: vm.dictionary('button_status_bool')
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
value: true,
|
value: true,
|
||||||
component: {
|
component: {
|
||||||
span: 12,
|
span: 12,
|
||||||
placeholder: "请选择状态",
|
placeholder: '请选择状态'
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
].concat(vm.commonEndColumns()),
|
].concat(vm.commonEndColumns())
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
<!--
|
|
||||||
* @创建文件时间: 2021-06-01 22:41:21
|
|
||||||
* @Auther: 猿小天
|
|
||||||
* @最后修改人: 猿小天
|
|
||||||
* @最后修改时间: 2021-07-31 22:35:15
|
|
||||||
* 联系Qq:1638245306
|
|
||||||
* @文件介绍: 部门管理
|
|
||||||
-->
|
|
||||||
<template>
|
<template>
|
||||||
<d2-container :class="{ 'page-compact': crud.pageOptions.compact }">
|
<d2-container :class="{ 'page-compact': crud.pageOptions.compact }">
|
||||||
<!-- <template slot="header">测试页面1</template>-->
|
<!-- <template slot="header">测试页面1</template>-->
|
||||||
|
|
Loading…
Reference in New Issue