Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
self-support
Project
Project
Details
Activity
Releases
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
李俊赕
self-support
Commits
139255b7
Commit
139255b7
authored
Jun 16, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
封装配件组件
parent
6f49d738
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
194 additions
and
0 deletions
+194
-0
index.vue
src/components/parts/index.vue
+98
-0
readme.md
src/components/parts/readme.md
+96
-0
No files found.
src/components/parts/index.vue
0 → 100644
View file @
139255b7
<
template
>
<view
class=
"parts"
>
<view
class=
"u-flex u-col-center u-row-around lists"
v-if=
"showTitle"
>
<view
v-if=
"showChecked"
class=
"check"
>
</view>
<view
class=
"u-flex-1"
>
<text
class=
"txt"
>
配件名称
</text>
</view>
<view
class=
"num"
>
<text
class=
"txt"
>
数量
</text>
</view>
</view>
<view
class=
"u-flex u-col-center u-row-around lists"
v-for=
"(item, index) in val"
:key=
"index"
>
<view
v-if=
"showChecked"
class=
"check"
>
<u-checkbox
v-model=
"item.checked"
:name=
"index"
@
change=
"checkChange"
></u-checkbox>
</view>
<view
class=
"u-flex-1 name"
>
{{
item
.
name
}}
</view>
<view
class=
"num"
>
<u-number-box
v-model=
"item.num"
:min=
"item.min"
:max=
"item.max"
:index=
"index"
@
change=
"numChange"
></u-number-box>
</view>
</view>
</view>
</
template
>
<
script
>
export
default
{
props
:
{
lists
:
{
// 数据列表
default
()
{
return
[]
}
},
showChecked
:
{
// 是否需要勾选
type
:
Boolean
,
default
()
{
return
false
}
},
showTitle
:
{
// 是否显示标题
type
:
Boolean
,
default
()
{
return
false
}
}
},
data
()
{
return
{
val
:
[]
}
},
created
()
{
this
.
val
=
this
.
lists
.
map
(
v
=>
{
if
(
this
.
showChecked
)
v
.
checked
=
v
.
checked
||
false
return
v
})
},
methods
:
{
checkChange
(
event
)
{
this
.
$set
(
this
.
val
[
event
.
name
],
'checked'
,
event
.
value
)
this
.
valueChange
()
},
numChange
(
event
)
{
this
.
$set
(
this
.
val
[
event
.
index
],
'num'
,
event
.
value
)
this
.
valueChange
()
},
valueChange
()
{
const
lists
=
this
.
showChecked
?
this
.
val
.
filter
(
v
=>
v
.
checked
)
:
this
.
val
this
.
$emit
(
'change'
,
lists
)
}
}
}
</
script
>
<
style
scoped
lang=
"scss"
>
.parts
{
padding
:
0
20rpx
;
.lists
{
padding
:
10rpx
0
;
.txt
{
font-size
:
28rpx
;
color
:
#2271FF
;
}
.check
{
width
:
80rpx
;
text-align
:
center
;
}
.name
{
font-size
:
26rpx
;
}
.num
{
width
:
200rpx
;
text-align
:
center
;
}
}
}
</
style
>
src/components/parts/readme.md
0 → 100644
View file @
139255b7
## 配件组件使用说明
```
该组件用于仓库配件的选择与数量调整
```
## API
### Props
| 属性名 | 类型 | 默认值 | 可选值 | 说明 |
| :---------: | :-----: | :----: | :--------: | :---------------------: |
| showChecked | Boolean | false | true/false | 是否需要复选框 |
| showTitle | Boolean | false | true/false | 是否显示标题 |
| lists | Array |
[]
| - | 列表数据
**格式见下文**
|
### lists 格式
```
json
[
{
name
:
'正泰漏保'
,
//
配件名称
num
:
1
,
//
配件数量
min
:
1
,
//
数量最小值
max
:
100
,
//
数量最大值
checked
:
false
//
勾选状态,如果需要回显勾选状态需传
}
]
```
### Events
| 事件称名 | 说明 | 返回值 |
| :------: | :----------------------------------: | :-----------------------------------------------------: |
| @change | 数据发生改变时(勾选或改变数量)返回 | 改变后的数据(如有勾选,只返回勾选的数据)
**格式见下文**
|
### 返回数据格式
```
json
[
{
name
:
'正泰漏保'
,
num
:
1
,
min
:
1
,
max
:
100
,
checked
:
true
}
]
```
## 组件用法
### 基础用法
```
html
<select-parts
:lists=
"lists"
:show-checked=
"true"
:show-title=
"true"
@
change=
"partsChange"
></select-parts>
```
```
js
import
selectParts
from
"@/components/parts/index"
export
default
{
components
:
{
selectParts
},
data
()
{
return
{
lists
:
[
{
id
:
1
,
name
:
"正泰漏保"
,
num
:
1
,
min
:
1
,
max
:
100
,
},
{
id
:
1
,
name
:
"挚达广汽充电桩"
,
num
:
3
,
min
:
1
,
max
:
5
,
},
]
}
},
methods
:
{
partsChange
(
val
)
{
console
.
log
(
"val"
,
val
)
},
},
};
```
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