Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CRM
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
xinzhedeai
CRM
Commits
80aaf3aa
Commit
80aaf3aa
authored
1 week ago
by
lei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:权重
parent
3ec57629
master
No related merge requests found
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
569 additions
and
466 deletions
+569
-466
user.js
src/api/user.js
+2
-2
Classification.vue
src/views/class/Classification.vue
+436
-445
classify.vue
src/views/lookupClass/classify.vue
+47
-2
index.vue
src/views/system/user/index.vue
+84
-17
No files found.
src/api/user.js
View file @
80aaf3aa
...
...
@@ -2,7 +2,7 @@ import request from '@/utils/request'
// 获取信息分类数据
export
function
getAllCategory
(
params
)
{
return
request
({
url
:
'
/api/informationClass/find
AllInformationClass
'
,
url
:
'
/api/informationClass/find
InformationClassByPidTree
'
,
method
:
'
get
'
,
params
})
...
...
@@ -12,7 +12,7 @@ export function addAssignWeight(data) {
return
request
({
url
:
'
/api/tabAssignWeight/insertWeight
'
,
method
:
'
post
'
,
data
,
data
})
}
export
function
showAssignWeight
(
params
)
{
...
...
This diff is collapsed.
Click to expand it.
src/views/class/Classification.vue
View file @
80aaf3aa
This diff is collapsed.
Click to expand it.
src/views/lookupClass/classify.vue
View file @
80aaf3aa
...
...
@@ -191,9 +191,44 @@ import {
import
{
reqInformationTreeList
,
reqAllInfoTreeList
}
from
'
@/api/treeMenus.js
'
import
Treeselect
from
'
@riophae/vue-treeselect
'
import
'
@riophae/vue-treeselect/dist/vue-treeselect.css
'
function
deepHasValue
(
data
,
targetValue
)
{
const
items
=
Array
.
isArray
(
data
)
?
data
:
[
data
]
for
(
const
item
of
items
)
{
// 直接匹配基本类型
if
(
item
===
targetValue
)
return
true
// 处理对象类型
if
(
typeof
item
===
'
object
'
&&
item
!==
null
)
{
// 深度遍历所有属性值
for
(
const
value
of
Object
.
values
(
item
))
{
if
(
value
===
targetValue
||
deepHasValue
(
value
,
targetValue
))
{
return
true
}
}
}
}
return
false
}
export
default
{
components
:
{
Treeselect
},
data
()
{
let
self
=
this
var
checkRepeat
=
(
rule
,
value
,
callback
)
=>
{
var
onOf
=
deepHasValue
(
self
.
infoTree
.
menus
,
value
)
if
(
onOf
)
{
self
.
typeManage
.
flag
=
1
self
.
typeManage
.
flag
=
1
return
callback
(
new
Error
(
'
分类名称重复
'
))
}
else
{
self
.
typeManage
.
flag
=
1
self
.
typeManage
.
flag
=
1
callback
()
}
}
return
{
// 1.获取全部信息分类
typeManage
:
{
...
...
@@ -209,6 +244,9 @@ export default {
addname
:
''
,
test
:
[]
// 默认选项,要在el-checkbox-group里绑定一个空数组
},
rules
:
{
addname
:
[]
},
editDialog
:
false
,
fromData
:
[]
},
...
...
@@ -267,11 +305,17 @@ export default {
newval
:
[],
// 验证
formrules
:
{
addname
:
[{
required
:
true
,
message
:
'
请输入类别
'
,
trigger
:
'
blur
'
}],
addname
:
[
{
required
:
true
,
message
:
'
请输入类别
'
,
trigger
:
'
blur
'
},
{
validator
:
checkRepeat
,
trigger
:
'
blur
'
}
],
test
:
[{
required
:
true
,
message
:
'
请选择推送信息
'
,
trigger
:
'
change
'
}]
},
rules
:
{
type
:
[{
required
:
true
,
message
:
'
请输入类别
'
,
trigger
:
'
blur
'
}],
type
:
[
{
required
:
true
,
message
:
'
请输入类别
'
,
trigger
:
'
blur
'
},
{
validator
:
checkRepeat
,
trigger
:
'
blur
'
}
],
choose
:
[{
required
:
true
,
message
:
'
请选择推送信息
'
,
trigger
:
'
change
'
}]
},
infoTree
:
{
...
...
@@ -376,6 +420,7 @@ export default {
determine
()
{
if
(
this
.
typeManage
.
flag
)
{
this
.
typeManage
.
flag
=
0
this
.
chooseString
=
this
.
typeManage
.
from
.
test
.
join
()
this
.
$refs
.
addDataForm
.
validate
((
valid
)
=>
{
if
(
valid
)
{
...
...
This diff is collapsed.
Click to expand it.
src/views/system/user/index.vue
View file @
80aaf3aa
...
...
@@ -199,15 +199,31 @@
<div
v-for=
"(item, i) in typeList"
>
<el-form
ref=
"addDataForm"
:model=
"typeList[i]"
:rules=
"fromrules"
>
<el-form-item
prop=
"infoClass"
label=
"信息分类"
:label-width=
"'120px'"
>
<el-select
clearable
v-model=
"typeList[i].infoClass"
placeholder=
"请选择类别"
filterable
allow-create
>
<el-option
v-for=
"(item, index) in listType"
:key=
"index"
:label=
"item.type"
:value=
"item.typeId"
/>
</el-select>
<el-cascader
clearable
v-model=
"typeList[i].infoClass"
:options=
"listType"
:show-all-levels=
"false"
:props=
"{
emitPath: false,
checkStrictly: true,
value: 'id',
label: 'label',
children: 'children',
disabled: 'disabled'
}"
placeholder=
"请选择类别"
filterable
allow-create
>
<!-- <el-option v-for="(item, index) in listType" :key="index" :label="item.type" :value="item.typeId" /> -->
</el-cascader>
</el-form-item>
<el-form-item
prop=
"value"
label=
"权重值:"
:label-width=
"'120px'"
>
<el-input-number
v-model=
"typeList[i].value"
:min=
"1"
:max=
"
5
"
label=
"描述文字"
></el-input-number>
<el-input-number
v-model=
"typeList[i].value"
:min=
"1"
:max=
"
3
"
label=
"描述文字"
></el-input-number>
</el-form-item>
<el-button
circle
icon=
"el-icon-plus"
@
click=
"addList()"
></el-button>
<el-button
circle
icon=
"el-icon-minus"
@
click=
"subList(i)"
v-if=
"i > 0"
></el-button>
<el-button
circle
icon=
"el-icon-plus"
@
click=
"addList(
item
)"
></el-button>
<el-button
circle
icon=
"el-icon-minus"
@
click=
"subList(i
tem, i
)"
v-if=
"i > 0"
></el-button>
</el-form>
</div>
<div
slot=
"footer"
>
...
...
@@ -315,7 +331,7 @@ export default {
//
newManage
:
{
page
:
1
,
size
:
10
,
size
:
''
,
total
:
0
},
// 获取信息分类数据
...
...
@@ -347,20 +363,22 @@ export default {
},
methods
:
{
//加号
addList
()
{
console
.
log
(
this
.
typeList
.
length
)
console
.
log
(
this
.
totalTypeNumber
)
addList
(
i
)
{
if
(
this
.
typeList
.
length
<=
this
.
totalTypeNumber
)
{
this
.
typeList
.
push
({
infoClass
:
''
,
value
:
''
})
this
.
typeList
.
forEach
((
el
)
=>
{
this
.
listType
=
this
.
disableByField
(
this
.
listType
,
'
id
'
,
el
.
infoClass
,
true
)
})
console
.
log
(
this
.
listType
,
i
.
infoClass
)
}
else
{
this
.
$message
.
error
(
'
已超过权重总数
'
)
return
}
},
//减号
subList
(
index
)
{
console
.
log
(
index
)
subList
(
item
,
index
)
{
this
.
typeList
.
splice
(
index
,
1
)
this
.
listType
=
this
.
disableByField
(
this
.
listType
,
'
id
'
,
item
.
infoClass
,
false
)
},
// 获取信息分类
classification
(
params
)
{
...
...
@@ -372,12 +390,25 @@ export default {
getAllCategory
(
params
).
then
((
res
)
=>
{
var
newlist
=
res
.
object
.
records
||
[]
this
.
totalTypeNumber
=
newlist
.
length
console
.
log
(
this
.
totalTypeNumber
,
'
this.totalTypeNumber
'
)
for
(
var
i
=
0
;
i
<
newlist
.
length
;
i
++
)
{
this
.
listType
.
push
({
type
:
newlist
[
i
].
name
,
typeId
:
newlist
[
i
].
id
})
console
.
log
(
this
.
listType
,
'
this.listType
'
)
console
.
log
(
newlist
)
newlist
.
forEach
((
e
)
=>
{
console
.
log
(
e
.
id
)
if
(
e
.
children
.
length
!==
0
)
{
this
.
listType
.
push
({
...
e
,
disabled
:
true
})
}
else
{
this
.
listType
.
push
({
...
e
})
}
})
console
.
log
(
this
.
listType
,
'
huoqu
'
)
// console.log(this.totalTypeNumber, 'this.totalTypeNumber')
// for (var i = 0; i
<
newlist
.
length
;
i
++
)
{
// this.listType.push({ type: newlist[i].name, typeId: newlist[i].id })
// console.log(this.listType, 'this.listType')
// }
})
},
handleChange
(
value
)
{},
// 权重弹窗
...
...
@@ -625,6 +656,42 @@ export default {
})
.
catch
(()
=>
{})
},
/**
* 根据指定字段值标记嵌套结构中的对象
* @param {Array} nestedArray - 包含 children 的多层嵌套数据
* @param {string} field - 目标字段名
* @param {*} value - 要匹配的字段值
* @returns {Array} 标记后的新数据结构
*/
disableByField
(
nestedArray
,
field
,
value
,
tf
)
{
return
nestedArray
.
map
((
item
)
=>
{
// 处理数组元素
if
(
Array
.
isArray
(
item
))
{
return
this
.
disableByField
(
item
,
field
,
value
,
tf
)
}
// 处理对象元素
if
(
typeof
item
===
'
object
'
&&
item
!==
null
)
{
// 创建新对象(保持不可变性)
const
newItem
=
{
...
item
}
// 标记匹配元素
if
(
newItem
[
field
]
===
value
)
{
newItem
.
disabled
=
tf
}
// 递归处理 children
if
(
Array
.
isArray
(
newItem
.
children
))
{
newItem
.
children
=
this
.
disableByField
(
newItem
.
children
,
field
,
value
,
tf
)
}
return
newItem
}
// 其他类型直接返回
return
item
})
},
checkboxT
(
row
,
rowIndex
)
{
return
row
.
id
!==
this
.
user
.
id
}
...
...
This diff is collapsed.
Click to expand it.
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