Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
founder_vue
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
常超
founder_vue
Commits
968ef0c9
Commit
968ef0c9
authored
Mar 18, 2021
by
蔡嘉凯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编写了字典管理界面的功能
parent
b41ed50b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
51 deletions
+91
-51
src/api/test.js
+8
-3
src/views/test1.vue
+83
-48
No files found.
src/api/test.js
View file @
968ef0c9
import
{
get
,
post
}
from
"@/utils/http.js"
;
import
{
get
,
post
}
from
"@/utils/http.js"
;
import
base
from
"@/api/base"
export
const
getZdglList
=
params
=>
...
...
@@ -6,6 +6,11 @@ export const getZdglList = params =>
export
const
queryCodeByType
=
params
=>
get
(
`
${
base
.
alyIP
}
/queryCodeByType`
,
params
);
export
const
addZdm
=
params
=>
post
(
`
${
base
.
alyIP
}
/czzdgl/addZdm`
,
params
);
export
const
updatezdm
=
params
=>
post
(
`
${
base
.
alyIP
}
/czzdgl/updatezdm`
,
params
);
export
const
refreshCodeCache
=
params
=>
post
(
`
${
base
.
alyIP
}
/refreshCodeCache`
,
params
);
...
...
@@ -14,4 +19,4 @@ export const deletezdm= params =>
post
(
`
${
base
.
alyIP
}
/czzdgl/delectzdm`
,
params
);
export
const
reloadShceDict
=
params
=>
post
(
`
${
base
.
alyIP
}
/reloadShceDict`
,
params
);
\ No newline at end of file
get
(
`
${
base
.
alyIP
}
/reloadShceDict`
,
params
);
\ No newline at end of file
src/views/test1.vue
View file @
968ef0c9
...
...
@@ -10,13 +10,12 @@
>
</el-tree>
</div>
<div
id=
"codeContent"
>
<div
id=
"codeContent"
v-show=
"curCode.codeType"
>
<div
id=
"contentHeader"
>
{{
curCode
.
text
}}
下级类别列表
</div>
<div
id=
"tableOper"
>
<el-button
@
click=
"alterRow()"
>
添加
</el-button>
<el-button
@
click=
"alterRow(selectedRow)"
>
编辑
</el-button>
<el-button
@
click=
"deleteRow(selectedRow)"
>
删除
</el-button>
<el-button>
关联高危地区
</el-button>
<el-button
@
click=
"refreshCode(curCode.codeType)"
>
刷新缓存按钮
</el-button
>
...
...
@@ -56,7 +55,7 @@
</el-table>
</div>
<el-dialog
custom-class=
"codeForm"
:visible
.
sync=
"formVisible"
>
<template
#
title
>
添加字典
</
template
>
<template
#
title
>
{{
isAlter
?
"修改字典"
:
"添加字典"
}}
</
template
>
<el-form
label-width=
"80px"
:model=
"formData"
>
<el-form-item
label=
"字典名称"
>
<el-input
v-model=
"formData.text"
></el-input>
...
...
@@ -69,7 +68,7 @@
</el-form-item>
</el-form>
<
template
#
footer
class=
"dialog-footer"
>
<el-button
type=
"primary"
@
click=
"
formVisible = false
"
>
保存
</el-button>
<el-button
type=
"primary"
@
click=
"
saveCode(formData)
"
>
保存
</el-button>
</
template
>
</el-dialog>
</div>
...
...
@@ -80,6 +79,9 @@ import {
getZdglList
,
queryCodeByType
,
refreshCodeCache
,
reloadShceDict
,
addZdm
,
updatezdm
,
deletezdm
,
}
from
"@/api/test.js"
;
const
msgList
=
[
...
...
@@ -87,6 +89,7 @@ const msgList = [
"您选择了多条字典,一次只能对一条字典进行编辑!"
,
"有下级字典,不能删除"
,
];
const
curLoad
=
{
curNode
:
{},
curResolve
:
()
=>
{}
};
export
default
{
data
()
{
return
{
...
...
@@ -101,6 +104,7 @@ export default {
formVisible
:
false
,
selectedRow
:
[],
curCode
:
{},
isAlter
:
false
,
};
},
mounted
()
{
...
...
@@ -124,18 +128,21 @@ export default {
if
(
!
node
.
isLeaf
)
{
this
.
tableLoading
=
true
;
this
.
curCode
=
data
;
}
if
(
node
.
childNodes
.
length
!=
0
)
{
this
.
tableData
=
node
.
childNodes
.
map
((
item
)
=>
{
return
item
.
data
;
});
this
.
tableLoading
=
false
;
if
(
node
.
childNodes
.
length
!=
0
)
{
curLoad
.
curNode
=
node
;
this
.
tableData
=
node
.
childNodes
.
map
((
item
)
=>
{
return
item
.
data
;
});
this
.
tableLoading
=
false
;
}
}
},
loadNode
(
node
,
resolve
)
{
if
(
!
node
.
data
.
codeType
)
{
return
;
}
curLoad
.
curNode
=
node
;
curLoad
.
curResolve
=
resolve
;
refreshCodeCache
({
type
:
node
.
data
.
codeType
}).
then
((
res
)
=>
{
queryCodeByType
({
type
:
node
.
data
.
codeType
}).
then
((
res
)
=>
{
const
data
=
res
.
rows
;
...
...
@@ -158,32 +165,65 @@ export default {
this
.
tips
(
1
);
return
;
}
this
.
isAlter
=
true
;
this
.
formData
.
text
=
data
[
0
].
text
;
this
.
formData
.
description
=
data
[
0
].
description
;
}
else
{
this
.
isAlter
=
false
;
this
.
formData
.
text
=
""
;
this
.
formData
.
description
=
""
;
}
this
.
formData
.
parent
=
this
.
curCode
.
text
;
this
.
formVisible
=
true
;
},
saveCode
(
params
)
{
let
data
;
let
fun
;
let
msg
;
if
(
this
.
isAlter
)
{
data
=
{
id
:
this
.
selectedRow
[
0
].
ids
,
name
:
params
.
text
,
description
:
params
.
description
,
};
fun
=
updatezdm
;
msg
=
"修改"
;
}
else
{
fun
=
addZdm
;
msg
=
"添加"
;
data
=
{
name
:
params
.
text
,
groupid
:
this
.
curCode
.
codeType
,
groupname
:
this
.
curCode
.
text
,
description
:
params
.
description
,
};
}
this
.
tableLoading
=
true
;
fun
(
data
).
then
((
res
)
=>
{
this
.
resMsg
(
res
.
code
,
msg
);
this
.
refreshTable
();
this
.
formVisible
=
false
;
});
},
deleteRow
(
row
)
{
if
(
row
.
length
==
0
)
{
this
.
tips
(
0
);
}
else
{
let
parentData
=
[];
let
data
=
[];
let
textData
=
[];
let
idData
=
[];
row
.
forEach
((
item
)
=>
{
if
(
item
.
isParent
)
{
parentData
.
push
(
item
.
text
);
}
data
.
push
(
item
.
text
);
textData
.
push
(
item
.
text
);
idData
.
push
(
item
.
ids
);
});
if
(
parentData
.
length
!=
0
)
{
this
.
tips
(
2
,
parentData
.
toString
());
}
else
{
this
.
$confirm
(
`字典名称:
${
d
ata
.
toString
()}
上级字典名称:
${
`字典名称:
${
textD
ata
.
toString
()}
上级字典名称:
${
this
.
curCode
.
text
}
点击[是]删除,点击[否]取消!`
,
"提示"
,
...
...
@@ -194,18 +234,10 @@ export default {
}
)
.
then
(()
=>
{
deletezdm
({
zjid
:
data
.
toString
()
}).
then
((
res
)
=>
{
if
(
res
.
code
==
200
)
{
this
.
$message
({
type
:
"success"
,
message
:
"删除成功!"
,
});
}
else
{
this
.
$message
({
type
:
"error"
,
message
:
"删除失败!"
,
});
}
deletezdm
({
zjid
:
idData
.
toString
()
}).
then
((
res
)
=>
{
this
.
resMsg
(
res
.
code
,
"删除"
);
this
.
formVisible
=
false
;
this
.
refreshTable
();
});
})
.
catch
(()
=>
{
...
...
@@ -221,38 +253,28 @@ export default {
if
(
!
id
)
{
return
;
}
this
.
tableLoading
=
true
;
refreshCodeCache
({
type
:
id
}).
then
((
res
)
=>
{
if
(
res
.
code
==
200
)
{
this
.
$message
({
type
:
"success"
,
message
:
"刷新成功!"
,
});
}
else
{
this
.
$message
({
type
:
"error"
,
message
:
"刷新失败!"
,
});
}
this
.
resMsg
(
res
.
code
,
"刷新"
);
this
.
tableLoading
=
false
;
});
},
generateFile
(
id
)
{
if
(
!
id
)
{
return
;
}
reloadShceDict
({
type
:
id
}).
then
((
res
)
=>
{
if
(
res
.
code
==
200
)
{
this
.
$message
({
type
:
"success"
,
message
:
"生成成功!"
,
});
}
else
{
this
.
$message
({
type
:
"error"
,
message
:
"生成失败!"
,
});
}
this
.
tableLoading
=
true
;
reloadShceDict
({
type
:
id
}).
then
(()
=>
{
this
.
$message
({
type
:
"success"
,
message
:
"生成成功!"
,
});
this
.
tableLoading
=
false
;
});
},
refreshTable
()
{
this
.
loadNode
(
curLoad
.
curNode
,
curLoad
.
curResolve
);
},
tips
(
msg
,
data
)
{
this
.
$alert
(
msgList
[
msg
]
+
(
data
?
data
:
""
),
"注意"
,
{
confirmButtonText
:
"确定"
,
...
...
@@ -264,6 +286,19 @@ export default {
},
});
},
resMsg
(
code
,
msg
)
{
if
(
code
==
200
)
{
this
.
$message
({
type
:
"success"
,
message
:
`
${
msg
}
成功!`
,
});
}
else
{
this
.
$message
({
type
:
"error"
,
message
:
`
${
msg
}
失败!`
,
});
}
},
},
};
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment