Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mes-ui
Project
Project
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
mes
mes-ui
Commits
90815ae9
Commit
90815ae9
authored
Oct 17, 2024
by
沈翠玲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shift多选增加mixin
parent
79d4ac33
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
10 deletions
+87
-10
shiftSelectMixin.js
src/utils/shiftSelectMixin.js
+59
-0
indexApply.vue
src/views/mes/pro/workorder/indexApply.vue
+28
-10
No files found.
src/utils/shiftSelectMixin.js
0 → 100644
View file @
90815ae9
export
default
{
data
()
{
return
{
keepDown
:
false
,
// 按shfit键实现多选
startIndex
:
null
}
},
mounted
()
{
this
.
_keydownBind
=
e
=>
{
if
(
e
.
keyCode
===
16
&&
e
.
shiftKey
)
{
this
.
keepDown
=
true
;
}
}
this
.
_keyupBind
=
e
=>
{
this
.
keepDown
=
false
;
}
window
.
addEventListener
(
'keydown'
,
this
.
_keydownBind
);
window
.
addEventListener
(
'keyup'
,
this
.
_keyupBind
);
},
deactivated
()
{
window
.
removeEventListener
(
'keydown'
,
this
.
_keydownBind
)
window
.
removeEventListener
(
'keyup'
,
this
.
_keyupBind
)
},
activated
()
{
window
.
addEventListener
(
'keydown'
,
this
.
_keydownBind
);
window
.
addEventListener
(
'keyup'
,
this
.
_keyupBind
);
},
beforeDestroy
()
{
window
.
removeEventListener
(
'keydown'
,
this
.
_keydownBind
)
window
.
removeEventListener
(
'keyup'
,
this
.
_keyupBind
)
},
methods
:
{
handleSelectionChange
(
selection
,
row
)
{
const
data
=
this
.
$refs
.
tableRef
.
tableData
;
// 获取table当前数据
const
startIdx
=
this
.
startIndex
;
// 获取首次选择对应列的索引
const
lastindex
=
data
.
findIndex
(
v
=>
v
===
selection
[
selection
.
length
-
1
])
this
.
selectedRows
=
selection
;
if
(
this
.
keepDown
&&
selection
.
includes
(
data
[
startIdx
]))
{
const
sum
=
Math
.
abs
(
startIdx
-
lastindex
)
+
1
;
// 用户可能反向选取,所以要取绝对值
const
min
=
Math
.
min
(
startIdx
,
lastindex
);
// 获取起点和终点较小的值
let
i
=
0
;
while
(
i
<
sum
)
{
const
index
=
min
+
i
;
if
(
!
this
.
selectedRows
.
includes
(
data
[
index
]))
{
this
.
$refs
.
tableRef
.
toggleRowSelection
(
data
[
index
],
true
);
}
i
++
;
}
}
else
{
this
.
startIndex
=
lastindex
}
this
.
ids
=
this
.
selectedRows
.
map
(
item
=>
item
.
workorderId
)
this
.
single
=
this
.
selectedRows
.
length
!==
1
this
.
multiple
=
!
this
.
selectedRows
.
length
}
}
}
src/views/mes/pro/workorder/indexApply.vue
View file @
90815ae9
...
@@ -216,7 +216,7 @@
...
@@ -216,7 +216,7 @@
</div>
</div>
</el-dialog>
</el-dialog>
<el-table
v-loading=
"loading"
:data=
"workorderList"
row-key=
"workorderId"
default-expand-all
:max-height=
"tableHeight"
<el-table
v-loading=
"loading"
:data=
"workorderList"
row-key=
"workorderId"
default-expand-all
:max-height=
"tableHeight"
ref=
"tableRef"
@
selection-change=
"handleSelectionChange"
:tree-props=
"
{ children: 'children', hasChildren: 'hasChildren' }">
@
selection-change=
"handleSelectionChange"
:tree-props=
"
{ children: 'children', hasChildren: 'hasChildren' }">
<!-- 新增复选框 -->
<!-- 新增复选框 -->
<el-table-column
type=
"selection"
width=
"55"
align=
"center"
/>
<el-table-column
type=
"selection"
width=
"55"
align=
"center"
/>
...
@@ -582,7 +582,7 @@ import {
...
@@ -582,7 +582,7 @@ import {
closeWorkorder
closeWorkorder
}
from
"@/api/mes/pro/workorder"
;
}
from
"@/api/mes/pro/workorder"
;
import
{
addProtaskList
}
from
"@/api/mes/pro/protask"
;
import
{
addProtaskList
}
from
"@/api/mes/pro/protask"
;
import
shiftSelectMixin
from
'@/utils/shiftSelectMixin'
import
Workorderbom
from
"./bom/bom.vue"
;
import
Workorderbom
from
"./bom/bom.vue"
;
import
WorkorderItemList
from
"./items/item.vue"
;
import
WorkorderItemList
from
"./items/item.vue"
;
import
ItemSelect
from
"@/components/itemSelect/single.vue"
;
import
ItemSelect
from
"@/components/itemSelect/single.vue"
;
...
@@ -607,6 +607,7 @@ export default {
...
@@ -607,6 +607,7 @@ export default {
"mes_workorder_sourcetype"
,
"mes_workorder_sourcetype"
,
"mes_workorder_type"
,
"mes_workorder_type"
,
],
],
mixins
:
[
shiftSelectMixin
],
components
:
{
components
:
{
productOrderDetail
,
productOrderDetail
,
productOrderSpecification
,
productOrderSpecification
,
...
@@ -771,6 +772,7 @@ export default {
...
@@ -771,6 +772,7 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
tableHeight
=
window
.
innerHeight
-
358
this
.
tableHeight
=
window
.
innerHeight
-
358
}
)
}
)
}
,
}
,
methods
:
{
methods
:
{
//筛选日期设置默认值
//筛选日期设置默认值
...
@@ -1140,19 +1142,35 @@ export default {
...
@@ -1140,19 +1142,35 @@ export default {
// this.optType = "view";
// this.optType = "view";
//
}
);
//
}
);
}
,
}
,
handleSelectionChange(selection) {
handleSelectionChange(selection, row) {
this.dict.type.mes_workorder_type
const data = this.$refs.tableRef.tableData; // 获取table当前数据
const startIdx = this.startIndex; // 获取首次选择对应列的索引
const lastindex = data.findIndex(v => v === selection[selection.length - 1])
this.selectedRows = selection;
if (this.keepDown && selection.includes(data[startIdx])) {
const sum = Math.abs(startIdx - lastindex) + 1; // 用户可能反向选取,所以要取绝对值
const min = Math.min(startIdx, lastindex); // 获取起点和终点较小的值
let i = 0;
while (i < sum) {
const index = min + i;
if (!this.selectedRows.includes(data[index])) {
this.$refs.tableRef.toggleRowSelection(data[index], true);
}
i++;
}
}
else {
this.startIndex = lastindex
}
this.ids = this.selectedRows.map(item => item.workorderId)
this.single = this.selectedRows.length !== 1
this.multiple = !this.selectedRows.length
this.combinationDisable = false
this.combinationDisable = false
selection
.forEach(item => {
this.selectedRows
.forEach(item => {
if (['complements', 'prototype'].indexOf(item.workorderType) > -1) {
if (['complements', 'prototype'].indexOf(item.workorderType) > -1) {
this.combinationDisable = true
this.combinationDisable = true
}
}
}
)
}
)
// this.selectedRows = val;
this.selectedRows = selection;
this.ids = selection.map(item => item.workorderId)
this.single = selection.length !== 1
this.multiple = !selection.length
}
,
}
,
// // 多选框选中数据
// // 多选框选中数据
// handleSelectionChange(selection) {
// handleSelectionChange(selection) {
...
...
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