Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mes-ui
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
周远喜
mes-ui
Commits
9dc1f424
Commit
9dc1f424
authored
Nov 13, 2020
by
renjintao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.mes123.com:zhouyx/mes-ui into product-rjt
parents
695863e3
64d8735e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
993 additions
and
905 deletions
+993
-905
base.less
assets/css/base.less
+3
-1
iview-reset.less
assets/css/iview-reset.less
+0
-1
EditGrid.vue
components/page/treeGrid/EditGrid.vue
+989
-902
index.vue
pages/project/plan/index.vue
+1
-1
No files found.
assets/css/base.less
View file @
9dc1f424
...
@@ -21,7 +21,9 @@ ul,
...
@@ -21,7 +21,9 @@ ul,
li {
li {
list-style: none;
list-style: none;
}
}
.ivu-drawer-wrap{
z-index: 12000;
}
div::-webkit-scrollbar {
div::-webkit-scrollbar {
width: 10px;
width: 10px;
height: 10px;
height: 10px;
...
...
assets/css/iview-reset.less
View file @
9dc1f424
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
box-sizing: border-box;
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
-webkit-tap-highlight-color: transparent;
}
}
.ivu-btn-primary {
.ivu-btn-primary {
color: #fff;
color: #fff;
background-color: @primary-color;
background-color: @primary-color;
...
...
components/page/treeGrid/EditGrid.vue
View file @
9dc1f424
<
template
>
<
template
>
<div
class=
"table-content1"
>
<div
class=
"table-content1"
>
<div
class=
"table-tools"
>
<div
class=
"table-tools"
>
<div
class=
"table-search"
>
<div
class=
"table-search"
>
<slot
name=
"easySearch"
></slot>
<slot
name=
"easySearch"
></slot>
</div>
</div>
<div
class=
"btns"
>
<div
class=
"btns"
>
<slot
name=
"buttons"
></slot>
<slot
name=
"buttons"
></slot>
<!--
<Button
@
click=
"config=
!config"
>
<Button
@
click=
"config =
!config"
>
<Icon
type=
"md-build"
class=
"table-set"
size=
"14"
title=
"列设置"
/>
<Icon
type=
"md-build"
class=
"table-set"
size=
"14"
title=
"列设置"
/>
</Button>
-->
</Button>
</div>
</div>
</div>
</div>
<div
class=
"table-main"
ref=
"main"
>
<div
class=
"table-main"
ref=
"main"
>
<div>
<div>
<table
class=
"table-head"
>
<table
class=
"table-head"
>
<thead>
<thead>
<tr>
<tr>
<th
v-for=
"(column, index) in columns"
:key=
"index"
:style=
"tdStyle(column)"
>
<th
<label
v-if=
"column.type === 'selection'"
>
v-for=
"(column, index) in columns"
<Checkbox
v-model=
"checkAll"
@
on-change=
"checked"
:indeterminate=
"indeterminate"
></Checkbox>
:key=
"index"
</label>
:style=
"tdStyle(column)"
<label
v-else
>
>
{{
renderHeader
(
column
,
index
)
}}
<label
v-if=
"column.type === 'selection'"
>
<span
class=
"ivu-table-sort"
v-if=
"column.sortable"
>
<Checkbox
<Icon
type=
"arrow-up-b"
:class=
"
{ on: column._sortType === 'asc' }" @click.native="handleSort(index, 'asc')" />
v-model=
"checkAll"
<Icon
type=
"arrow-down-b"
:class=
"
{ on: column._sortType === 'desc' }" @click.native="handleSort(index, 'desc')" />
@
on-change=
"allChecked"
</span>
:indeterminate=
"indeterminate"
</label>
></Checkbox>
</th>
</label>
</tr>
<label
v-else
>
</thead>
{{
renderHeader
(
column
,
index
)
}}
<tbody>
<span
class=
"ivu-table-sort"
v-if=
"column.sortable"
>
<tr
v-for=
"(item, index) in trs"
:key=
"item.id"
class=
"treetr"
:id=
"'tr' + index"
v-show=
"show(item)"
:draggable=
"drag && !item._drag"
@
dragstart=
"dragstart($event, index, item)"
@
drop=
"dragdrop($event, index, item)"
@
dragenter=
"dragenter($event, index, item)"
@
dragover=
"dragover($event, index, item)"
@
dragleave=
"dragleave($event, index, item)"
>
<Icon
<!-- -->
type=
"arrow-up-b"
<td
v-for=
"(column, snum) in columns"
:key=
"column.key"
:style=
"tdStyle(column)"
>
:class=
"
{ on: column._sortType === 'asc' }"
<!-- 多选 -->
@click.native="handleSort(index, 'asc')"
<label
v-if=
"column.type === 'selection'"
@
click=
"rowChecked(item, index, $event)"
>
/>
<Checkbox
v-model=
"item._checked"
:indeterminate=
"item._indeterminate"
></Checkbox>
<Icon
</label>
type=
"arrow-down-b"
:class=
"
{ on: column._sortType === 'desc' }"
<Icon
v-if=
"column.type === 'drag'"
type=
"md-more"
class=
"drag"
/>
@click.native="handleSort(index, 'desc')"
<DTSpan
v-if=
"column.type == 'date'"
:value=
"item[column.key]"
/>
/>
<div
v-if=
"column.type == 'user'"
>
</span>
<User
:value=
"item[column.key]"
/>
</label>
</div>
</th>
<div
v-if=
"
</tr>
</thead>
<tbody>
<tr
v-for=
"(item, index) in trs"
:key=
"item.id"
class=
"treetr"
:id=
"'tr' + index"
v-show=
"show(item)"
:draggable=
"drag && !item._drag"
@
dragstart=
"dragstart($event, index, item)"
@
drop=
"dragdrop($event, index, item)"
@
dragenter=
"dragenter($event, index, item)"
@
dragover=
"dragover($event, index, item)"
@
dragleave=
"dragleave($event, index, item)"
>
<!-- -->
<td
v-for=
"(column, snum) in columns"
:key=
"column.key"
:style=
"tdStyle(column)"
>
<!-- 多选 -->
<label
v-if=
"column.type === 'selection'"
@
click=
"rowChecked(item, index, $event)"
>
<Checkbox
v-model=
"item._checked"
:indeterminate=
"item._indeterminate"
></Checkbox>
{{
item
.
_checked
}}
</label>
<Icon
v-if=
"column.type === 'drag'"
type=
"md-more"
class=
"drag"
/>
<DTSpan
v-if=
"column.type == 'date'"
:value=
"item[column.key]"
/>
<div
v-if=
"column.type == 'user'"
>
<User
:value=
"item[column.key]"
/>
</div>
<div
v-if=
"
column.type == 'users' &&
column.type == 'users' &&
item[column.key] &&
item[column.key] &&
item[column.key].length > 0
item[column.key].length > 0
"
>
"
<User
v-for=
"li in item[column.key]"
:value=
"li"
:key=
"li"
class=
"ml10"
/>
>
</div>
<User
<state
v-if=
"column.code"
:code=
"column.code"
:value=
"item[column.key]"
/>
v-for=
"li in item[column.key]"
<!-- 树图标 -->
:value=
"li"
<span
@
click=
"toggle(index, item)"
v-if=
"snum == treeColumn()"
>
:key=
"li"
<span
class=
"ib"
v-width=
"spaceWidth * item._level"
></span>
class=
"ml10"
<a
v-if=
"item._count > 0"
class=
"expand"
>
/>
<Icon
:type=
"!item._expanded ? 'ios-add' : 'ios-remove'"
/>
</div>
</a><i
v-else
class=
"ms-tree-space"
></i>
<state
</span>
v-if=
"column.code"
<!-- 菜单名称、排序、请求地址 -->
:code=
"column.code"
<label
v-if=
"
:value=
"item[column.key]"
/>
<!-- 树图标 -->
<span
@
click=
"toggle(index, item)"
v-if=
"snum == treeColumn()"
>
<span
class=
"ib"
v-width=
"spaceWidth * item._level"
></span>
<a
v-if=
"item._count > 0"
class=
"expand"
>
<Icon
:type=
"!item._expanded ? 'ios-add' : 'ios-remove'"
/>
</a
><i
v-else
class=
"ms-tree-space"
></i>
</span>
<!-- 菜单名称、排序、请求地址 -->
<label
v-if=
"
!column.type &&
!column.type &&
!column.code &&
!column.code &&
!column.render &&
!column.render &&
!column.slot
!column.slot
"
>
"
{{
renderBody
(
item
,
column
)
}}
>
</label>
{{
renderBody
(
item
,
column
)
}}
<table-expand
v-if=
"column.render && !column.type && !column.solt"
:row=
"item"
:column=
"column"
:index=
"snum"
:render=
"column.render"
></table-expand>
</label>
<column-slot
v-if=
"column.slot"
:row=
"item"
:column=
"column"
:index=
"snum"
></column-slot>
<table-expand
</td>
v-if=
"column.render && !column.type && !column.solt"
</tr>
:row=
"item"
</tbody>
:column=
"column"
</table>
:index=
"snum"
</div>
:render=
"column.render"
></table-expand>
<column-slot
v-if=
"column.slot"
:row=
"item"
:column=
"column"
:index=
"snum"
></column-slot>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div
class=
"table-footer"
>
<div
class=
"table-footer"
>
<slot
name=
"footer"
></slot>
<slot
name=
"footer"
></slot>
<Page
v-if=
"page"
:total=
"search.total"
:current=
"search.page"
class=
"fr"
show-total
size=
"small"
show-elevator
show-sizer
:page-size=
"search.pageSize"
:page-size-opts=
"pageSizeOpts"
@
on-change=
"pageChange"
@
on-page-size-change=
"pageSizeChange"
/>
<Page
v-if=
"page"
:total=
"search.total"
:current=
"search.page"
class=
"fr"
show-total
size=
"small"
show-elevator
show-sizer
:page-size=
"search.pageSize"
:page-size-opts=
"pageSizeOpts"
@
on-change=
"pageChange"
@
on-page-size-change=
"pageSizeChange"
/>
</div>
</div>
<Modal
v-if=
"high"
v-model=
"modalSearch"
title=
"高级搜索"
draggable
width=
"800"
ref=
"search"
>
<Modal
<slot
name=
"searchForm"
></slot>
v-if=
"high"
<div
slot=
"footer"
>
v-model=
"modalSearch"
<Button
@
click=
"modalSearch = false"
class=
"mr20"
>
取消
</Button>
title=
"高级搜索"
<Button
@
click=
"complexSearch"
type=
"primary"
class=
"mr20"
>
查询
</Button>
draggable
</div>
width=
"800"
ref=
"search"
>
<slot
name=
"searchForm"
></slot>
<div
slot=
"footer"
>
<Button
@
click=
"modalSearch = false"
class=
"mr20"
>
取消
</Button>
<Button
@
click=
"complexSearch"
type=
"primary"
class=
"mr20"
>
查询
</Button>
</div>
</Modal>
</Modal>
<Drawer
title=
"列设置"
v-if=
"set"
v-model=
"config"
:scrollable=
"true"
placement=
"left"
:mask=
"false"
>
<Drawer
<div
slot=
"header"
>
title=
"列设置"
列设置
v-if=
"set"
<a
@
click=
"undoConfig"
class=
"ml50"
>
v-model=
"config"
<Icon
type=
"md-refresh"
title=
"恢复初始设置"
/>
:scrollable=
"true"
</a>
placement=
"left"
</div>
:mask=
"false"
<ul
class=
"table-columns"
>
>
<li
v-for=
"(li, index) in columnsCur"
:key=
"index"
v-dragging=
"
{ item: li, list: columnsCur, group: 'li' }">
<div
slot=
"header"
>
<label
@
click=
"columnChange(li, index)"
:class=
"
{ dis: li.hide }">
列设置
<Icon
:type=
"li.hide ? 'md-eye-off' : 'md-eye'"
size=
"16"
class=
"mr10"
/>
<a
@
click=
"undoConfig"
class=
"ml50"
>
<span>
{{
li
.
title
}}
</span>
<Icon
type=
"md-refresh"
title=
"恢复初始设置"
/>
</label>
</a>
<Icon
type=
"ios-move"
class=
"move"
size=
"18"
/>
</div>
</li>
<ul
class=
"table-columns"
>
</ul>
<li
v-for=
"(li, index) in columnsCur"
:key=
"index"
v-dragging=
"
{ item: li, list: columnsCur, group: 'li' }"
>
<label
@
click=
"columnChange(li, index)"
:class=
"
{ dis: li.hide }">
<Icon
:type=
"li.hide ? 'md-eye-off' : 'md-eye'"
size=
"16"
class=
"mr10"
/>
<span>
{{
li
.
title
}}
</span>
</label>
<Icon
type=
"ios-move"
class=
"move"
size=
"18"
/>
</li>
</ul>
</Drawer>
</Drawer>
<FooterToolbar
v-if=
"batch"
v-show=
"footerToolbar"
class=
"ftball"
>
<FooterToolbar
v-if=
"batch"
v-show=
"footerToolbar"
class=
"ftball"
>
<div
class=
"tip
"
>
已选
{{
selectItems
.
length
}}
项
</div>
<div
class=
"ib
"
>
已选
{{
selectItems
.
length
}}
项
</div>
<slot
name=
"batch"
></slot>
<slot
name=
"batch"
></slot>
<Button
@
click=
"cancelBatch"
>
取消
</Button>
<Button
@
click=
"cancelBatch"
>
取消
</Button>
</FooterToolbar>
</FooterToolbar>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
TableExpand
from
"./expand"
;
import
TableExpand
from
"./expand"
;
import
ColumnSlot
from
"./columnSolt"
;
import
ColumnSlot
from
"./columnSolt"
;
export
default
{
export
default
{
name
:
"treeGrid"
,
name
:
"treeGrid"
,
components
:
{
components
:
{
TableExpand
,
TableExpand
,
ColumnSlot
ColumnSlot
,
},
},
props
:
{
props
:
{
mode
:
{
mode
:
{
type
:
[
String
,
Number
],
type
:
[
String
,
Number
],
default
:
0
,
default
:
0
,
validator
:
(
v
)
=>
{
validator
:
(
v
)
=>
{
var
modes
=
[
"read"
,
"column"
,
"row"
];
var
modes
=
[
"read"
,
"column"
,
"row"
];
if
(
/^
\d
+/
.
test
(
v
))
{
if
(
/^
\d
+/
.
test
(
v
))
{
return
v
>=
0
&&
v
<
modes
.
length
;
return
v
>=
0
&&
v
<
modes
.
length
;
}
}
return
modes
.
indexOf
(
v
)
>
-
1
;
return
modes
.
indexOf
(
v
)
>
-
1
;
},
},
},
},
border
:
{
border
:
{
//是否显示边框
//是否显示边框
type
:
Boolean
,
type
:
Boolean
,
default
:
true
,
default
:
true
,
},
},
batch
:
{
batch
:
{
//是否批量操作
//是否批量操作
type
:
Boolean
,
type
:
Boolean
,
default
:
true
,
default
:
true
,
},
},
format
:
{
format
:
{
type
:
Function
,
type
:
Function
,
default
:
null
,
default
:
null
,
},
},
initsearch
:
{
initsearch
:
{
type
:
Function
,
type
:
Function
,
default
:
null
,
default
:
null
,
},
lazy
:
{
//懒加载设置,设置为真时候,默认不加载数据。
type
:
Boolean
,
default
:
false
,
},
placeholder
:
{
type
:
String
,
default
:
"请输入关键字"
,
},
height
:
{
type
:
Number
,
default
:
0
,
},
tool
:
{
//是否显示工具栏
type
:
Boolean
,
default
:
true
,
},
easy
:
{
//是否显示简单搜索
type
:
Boolean
,
default
:
true
,
},
high
:
{
//是否显示高级搜索
type
:
Boolean
,
default
:
true
,
},
draggable
:
{
//是否可以拖拽
type
:
Boolean
,
default
:
false
,
},
set
:
{
//是否显示列设置
type
:
Boolean
,
default
:
true
,
},
page
:
{
//是否分页
type
:
Boolean
,
default
:
false
,
},
columns
:
Array
,
items
:
{
//接收树形数据
type
:
Array
,
default
()
{
return
[];
},
},
data
:
{
//接收UpId型数据
type
:
Array
,
default
()
{
return
[];
},
},
keyname
:
{
//默认行主键
type
:
[
String
],
default
:
"id"
,
},
upname
:
{
// 父级字段名称
type
:
String
,
default
:
"upId"
,
},
root
:
{
// 根级UpId的值.
type
:
[
String
,
Number
],
default
:
0
,
},
action
:
{
//接口地址
type
:
String
,
default
:
""
,
},
conditions
:
{
//查询条件
type
:
Object
,
default
:
function
()
{
return
{
keys
:
{
op
:
"name"
,
value
:
""
,
default
:
true
,
},
};
},
},
iconName
:
false
,
drag
:
{
//拖拽
type
:
Boolean
,
default
:
false
,
},
spaceWidth
:
{
//树形表格缩进距离
type
:
Number
,
default
:
20
,
},
exportTitle
:
{
type
:
String
,
default
:
""
,
},
},
provide
()
{
return
{
tableRoot
:
this
.
slots
,
};
},
},
data
()
{
lazy
:
{
//懒加载设置,设置为真时候,默认不加载数据。
type
:
Boolean
,
default
:
false
,
},
placeholder
:
{
type
:
String
,
default
:
"请输入关键字"
,
},
height
:
{
type
:
Number
,
default
:
0
,
},
tool
:
{
//是否显示工具栏
type
:
Boolean
,
default
:
true
,
},
easy
:
{
//是否显示简单搜索
type
:
Boolean
,
default
:
true
,
},
high
:
{
//是否显示高级搜索
type
:
Boolean
,
default
:
true
,
},
draggable
:
{
//是否可以拖拽
type
:
Boolean
,
default
:
false
,
},
set
:
{
//是否显示列设置
type
:
Boolean
,
default
:
true
,
},
page
:
{
//是否分页
type
:
Boolean
,
default
:
false
,
},
columns
:
Array
,
items
:
{
//接收树形数据
type
:
Array
,
default
()
{
return
[];
},
},
data
:
{
//接收UpId型数据
type
:
Array
,
default
()
{
return
[];
},
},
keyname
:
{
//默认行主键
type
:
[
String
],
default
:
"id"
,
},
upname
:
{
// 父级字段名称
type
:
String
,
default
:
"upId"
,
},
root
:
{
// 根级UpId的值.
type
:
[
String
,
Number
],
default
:
0
,
},
action
:
{
//接口地址
type
:
String
,
default
:
""
,
},
conditions
:
{
//查询条件
type
:
Object
,
default
:
function
()
{
return
{
return
{
color
:
"#19be6b"
,
keys
:
{
checkAll
:
false
,
op
:
"name"
,
keys
:
""
,
value
:
""
,
selectItems
:
[],
default
:
true
,
modalSearch
:
false
,
},
footerToolbar
:
false
,
search
:
{
pageIndex
:
1
,
pageSize
:
20
,
sortBy
:
"id"
,
isDesc
:
true
,
conditions
:
[],
},
searchConditions
:
this
.
search
,
pageSizeOpts
:
[
20
,
50
,
100
],
tableHeight
:
0
,
firstY
:
0
,
config
:
false
,
logs
:
[],
trs
:
[],
// 处理后数据数组
columnsCur
:
[],
// 处理后的表头数据
checkGroup
:
[],
// 复选框数组
checks
:
false
,
// 全选
tdsWidth
:
0
,
// td总宽
timer
:
false
,
// 控制监听时长
dataLength
:
0
,
// 树形数据长度
dragIndex
:
-
1
,
//拖拽开始的序号
allUser
:
[],
//所有user
};
};
},
},
},
computed
:
{
iconName
:
false
,
indeterminate
()
{
drag
:
{
var
checkeds
=
this
.
trs
.
filter
((
u
)
=>
{
//拖拽
return
u
.
_checked
;
type
:
Boolean
,
}).
length
;
default
:
false
,
return
0
<
checkeds
&&
checkeds
<
this
.
trs
.
length
;
},
},
watch
:
{
items
()
{
if
(
this
.
items
)
{
this
.
trs
=
this
.
treeToList
(
this
.
items
);
this
.
checkGroup
=
this
.
renderCheck
(
this
.
items
);
if
(
this
.
checkGroup
.
length
==
this
.
dataLength
)
{
this
.
checks
=
true
;
}
else
{
this
.
checks
=
false
;
}
}
},
data
(
v
)
{},
columns
:
{
handler
()
{
this
.
columnsCur
=
this
.
makeColumns
();
},
deep
:
true
,
},
checkGroup
(
data
)
{
this
.
checkAllGroupChange
(
data
);
},
exportTitle
(
v
)
{
this
.
exportTitle
=
v
}
},
},
mounted
()
{
spaceWidth
:
{
this
.
getAllUser
();
//获取所有用户
//树形表格缩进距离
if
(
this
.
items
&&
this
.
items
.
length
>
0
)
{
type
:
Number
,
this
.
trs
=
this
.
treeToList
(
this
.
items
);
default
:
20
,
this
.
columnsCur
=
this
.
makeColumns
();
this
.
checkGroup
=
this
.
renderCheck
(
this
.
items
);
if
(
this
.
checkGroup
.
length
==
this
.
dataLength
)
{
this
.
checks
=
true
;
}
else
{
this
.
checks
=
false
;
}
}
},
},
methods
:
{
exportTitle
:
{
load
()
{},
type
:
String
,
complexSearch
()
{
default
:
""
,
var
search
=
this
.
$refs
.
search
.
$children
.
filter
((
u
)
=>
{
},
return
u
.
condition
;
},
});
provide
()
{
if
(
search
)
{
return
{
var
conditions
=
search
[
0
].
condition
;
tableRoot
:
this
.
slots
,
this
.
reload
(
conditions
);
};
}
},
},
data
()
{
slots
()
{
return
{
return
this
.
$scopedSlots
;
color
:
"#19be6b"
,
},
checkAll
:
false
,
//拖拽开始
keys
:
""
,
dragstart
(
e
,
index
,
row
)
{
selectItems
:
[],
this
.
dragIndex
=
index
;
modalSearch
:
false
,
console
.
log
(
index
);
footerToolbar
:
false
,
},
search
:
{
//进入
pageIndex
:
1
,
dragenter
(
e
,
index
,
row
)
{
pageSize
:
20
,
var
tr
=
document
.
getElementById
(
"tr"
+
index
);
sortBy
:
"id"
,
if
(
this
.
dragIndex
>
index
)
{
isDesc
:
true
,
tr
.
className
+=
" move"
;
conditions
:
[],
}
else
if
(
this
.
dragIndex
<
index
)
{
},
tr
.
className
+=
" sort"
;
searchConditions
:
this
.
search
,
}
pageSizeOpts
:
[
20
,
50
,
100
],
},
tableHeight
:
0
,
// 悬浮
firstY
:
0
,
dragover
(
e
,
index
,
row
)
{
config
:
false
,
e
.
preventDefault
();
logs
:
[],
// 鼠标Y
trs
:
[],
// 处理后数据数组
var
my
=
e
.
offsetY
;
columnsCur
:
[],
// 处理后的表头数据
var
h
=
e
.
toElement
.
clientHeight
;
checkGroup
:
[],
// 复选框数组
var
tr
=
document
.
getElementById
(
"tr"
+
index
);
checks
:
false
,
// 全选
if
(
this
.
dragIndex
>
index
&&
my
/
h
<
0.5
)
{
tdsWidth
:
0
,
// td总宽
tr
.
className
=
tr
.
className
.
replace
(
" move"
,
" sort"
);
timer
:
false
,
// 控制监听时长
}
dataLength
:
0
,
// 树形数据长度
if
(
this
.
dragIndex
<
index
&&
my
/
h
>
0.5
)
{
dragIndex
:
-
1
,
//拖拽开始的序号
tr
.
className
=
tr
.
className
.
replace
(
" sort"
,
" move"
);
allUser
:
[],
//所有user
}
};
},
},
// 离开
computed
:
{
dragleave
(
e
,
index
,
row
)
{
indeterminate
()
{
var
tr
=
document
.
getElementById
(
"tr"
+
index
);
var
checkeds
=
this
.
trs
.
filter
((
u
)
=>
{
tr
.
className
=
tr
.
className
.
replace
(
" move"
,
""
).
replace
(
" sort"
,
""
);
return
u
.
_checked
;
},
}).
length
;
//放下
return
0
<
checkeds
&&
checkeds
<
this
.
trs
.
length
;
dragdrop
(
e
,
index
,
row
)
{
},
event
.
preventDefault
();
},
var
tr
=
document
.
getElementById
(
"tr"
+
index
);
watch
:
{
tr
.
className
=
tr
.
className
.
replace
(
" move"
,
""
).
replace
(
" sort"
,
""
);
items
()
{
if
(
index
!=
this
.
dragIndex
)
{
if
(
this
.
items
)
{
this
.
$emit
(
"on-drag-drop"
,
this
.
dragIndex
,
index
,
this
.
trs
,
e
);
this
.
trs
=
this
.
treeToList
(
this
.
items
);
}
}
},
},
/**
data
(
v
)
{},
columns
:
{
handler
()
{
this
.
columnsCur
=
this
.
makeColumns
();
},
deep
:
true
,
},
exportTitle
(
v
)
{
this
.
exportTitle
=
v
;
},
},
mounted
()
{
this
.
getAllUser
();
//获取所有用户
if
(
this
.
items
&&
this
.
items
.
length
>
0
)
{
this
.
trs
=
this
.
treeToList
(
this
.
items
);
this
.
columnsCur
=
this
.
makeColumns
();
}
},
methods
:
{
load
()
{},
complexSearch
()
{
var
search
=
this
.
$refs
.
search
.
$children
.
filter
((
u
)
=>
{
return
u
.
condition
;
});
if
(
search
)
{
var
conditions
=
search
[
0
].
condition
;
this
.
reload
(
conditions
);
}
},
slots
()
{
return
this
.
$scopedSlots
;
},
//拖拽开始
dragstart
(
e
,
index
,
row
)
{
this
.
dragIndex
=
index
;
console
.
log
(
index
);
},
//进入
dragenter
(
e
,
index
,
row
)
{
var
tr
=
document
.
getElementById
(
"tr"
+
index
);
if
(
this
.
dragIndex
>
index
)
{
tr
.
className
+=
" move"
;
}
else
if
(
this
.
dragIndex
<
index
)
{
tr
.
className
+=
" sort"
;
}
},
// 悬浮
dragover
(
e
,
index
,
row
)
{
e
.
preventDefault
();
// 鼠标Y
var
my
=
e
.
offsetY
;
var
h
=
e
.
toElement
.
clientHeight
;
var
tr
=
document
.
getElementById
(
"tr"
+
index
);
if
(
this
.
dragIndex
>
index
&&
my
/
h
<
0.5
)
{
tr
.
className
=
tr
.
className
.
replace
(
" move"
,
" sort"
);
}
if
(
this
.
dragIndex
<
index
&&
my
/
h
>
0.5
)
{
tr
.
className
=
tr
.
className
.
replace
(
" sort"
,
" move"
);
}
},
// 离开
dragleave
(
e
,
index
,
row
)
{
var
tr
=
document
.
getElementById
(
"tr"
+
index
);
tr
.
className
=
tr
.
className
.
replace
(
" move"
,
""
).
replace
(
" sort"
,
""
);
},
//放下
dragdrop
(
e
,
index
,
row
)
{
event
.
preventDefault
();
var
tr
=
document
.
getElementById
(
"tr"
+
index
);
tr
.
className
=
tr
.
className
.
replace
(
" move"
,
""
).
replace
(
" sort"
,
""
);
if
(
index
!=
this
.
dragIndex
)
{
this
.
$emit
(
"on-drag-drop"
,
this
.
dragIndex
,
index
,
this
.
trs
,
e
);
}
},
/**
* @dragover="dragover($event, index, item)"
* @dragover="dragover($event, index, item)"
@dragleave="dragleave($event,index,item)"
@dragleave="dragleave($event,index,item)"
*/
*/
// 有无多选框折叠位置优化
// 有无多选框折叠位置优化
treeColumn
()
{
treeColumn
()
{
var
num
=
0
;
var
num
=
0
;
for
(
let
i
=
0
,
len
=
this
.
columns
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
this
.
columns
.
length
;
i
<
len
;
i
++
)
{
if
(
this
.
columns
[
i
].
tree
)
{
if
(
this
.
columns
[
i
].
tree
)
{
num
=
i
;
num
=
i
;
}
}
}
}
return
num
;
return
num
;
},
},
// 设置td宽度,td的align
// 设置td宽度,td的align
tdStyle
(
column
)
{
tdStyle
(
column
)
{
const
style
=
{};
const
style
=
{};
if
(
column
.
align
)
{
if
(
column
.
align
)
{
style
[
"text-align"
]
=
column
.
align
;
style
[
"text-align"
]
=
column
.
align
;
}
}
if
(
column
.
width
)
{
if
(
column
.
width
)
{
style
[
"width"
]
=
`
${
column
.
width
}
px`
;
style
[
"width"
]
=
`
${
column
.
width
}
px`
;
}
}
if
(
column
.
hide
)
{
if
(
column
.
hide
)
{
style
[
"display"
]
=
`none`
;
style
[
"display"
]
=
`none`
;
}
}
return
style
;
return
style
;
},
},
// 排序事件
// 排序事件
handleSort
(
index
,
type
)
{
handleSort
(
index
,
type
)
{
this
.
columnsCur
.
forEach
((
col
)
=>
(
col
.
_sortType
=
"normal"
));
this
.
columnsCur
.
forEach
((
col
)
=>
(
col
.
_sortType
=
"normal"
));
if
(
this
.
columnsCur
[
index
].
_sortType
===
type
)
{
if
(
this
.
columnsCur
[
index
].
_sortType
===
type
)
{
this
.
columnsCur
[
index
].
_sortType
=
"normal"
;
this
.
columnsCur
[
index
].
_sortType
=
"normal"
;
}
else
{
}
else
{
this
.
columnsCur
[
index
].
_sortType
=
type
;
this
.
columnsCur
[
index
].
_sortType
=
type
;
}
}
this
.
$emit
(
this
.
$emit
(
"on-sort-change"
,
"on-sort-change"
,
this
.
columnsCur
[
index
].
key
,
this
.
columnsCur
[
index
].
key
,
this
.
columnsCur
[
index
].
_sortType
this
.
columnsCur
[
index
].
_sortType
);
);
},
},
// 点击某一行事件
// 点击某一行事件
RowClick
(
data
,
event
,
index
,
text
)
{
RowClick
(
data
,
event
,
index
,
text
)
{
this
.
$emit
(
"on-row-click"
,
data
,
event
,
index
,
text
);
this
.
$emit
(
"on-row-click"
,
data
,
event
,
index
,
text
);
},
},
// 点击事件 返回数据处理
// 点击事件 返回数据处理
// 处理表头数据
// 处理表头数据
makeColumns
()
{
makeColumns
()
{
const
columns
=
this
.
$u
.
clone
(
this
.
columns
);
const
columns
=
this
.
$u
.
clone
(
this
.
columns
);
this
.
tdsWidth
=
0
;
this
.
tdsWidth
=
0
;
columns
.
forEach
((
column
,
index
)
=>
{
columns
.
forEach
((
column
,
index
)
=>
{
column
.
_index
=
index
;
column
.
_index
=
index
;
column
.
_width
=
column
.
width
?
column
.
width
:
""
;
column
.
_width
=
column
.
width
?
column
.
width
:
""
;
column
.
_sortType
=
"normal"
;
column
.
_sortType
=
"normal"
;
this
.
tdsWidth
+=
column
.
width
?
parseFloat
(
column
.
width
)
:
0
;
this
.
tdsWidth
+=
column
.
width
?
parseFloat
(
column
.
width
)
:
0
;
});
});
return
columns
;
return
columns
;
},
},
// // 隐藏显示
// // 隐藏显示
toggle
(
index
,
item
)
{
toggle
(
index
,
item
)
{
if
(
item
.
_count
>
0
)
{
if
(
item
.
_count
>
0
)
{
this
.
$set
(
this
.
trs
[
index
],
"_expanded"
,
!
item
.
_expanded
);
this
.
$set
(
this
.
trs
[
index
],
"_expanded"
,
!
item
.
_expanded
);
this
.
trs
.
forEach
((
u
,
i
)
=>
{
this
.
trs
.
forEach
((
u
,
i
)
=>
{
if
(
u
[
this
.
upname
]
===
item
.
id
)
{
if
(
u
[
this
.
upname
]
===
item
.
id
)
{
this
.
$set
(
this
.
trs
[
i
],
"_show"
,
!
item
.
_expanded
);
this
.
$set
(
this
.
trs
[
i
],
"_show"
,
!
item
.
_expanded
);
}
}
});
});
}
},
show
(
item
)
{
if
(
item
.
_level
==
0
)
{
return
true
;
}
else
{
var
parents
=
this
.
getRoots
(
item
);
return
(
parents
.
filter
((
u
)
=>
{
return
!
u
.
_expanded
;
}).
length
==
0
);
}
},
getRoots
(
item
)
{
var
parents
=
[];
var
root
=
this
.
trs
.
filter
((
u
)
=>
{
return
u
[
this
.
keyname
]
==
item
[
this
.
upname
];
});
while
(
root
.
length
==
1
)
{
parents
.
push
(
root
[
0
]);
root
=
this
.
trs
.
filter
((
u
)
=>
{
return
u
[
this
.
keyname
]
===
root
[
0
][
this
.
upname
];
});
}
return
parents
;
},
open
(
index
,
item
)
{
if
(
item
.
children
)
{
item
.
children
.
forEach
((
child
,
childIndex
)
=>
{
child
.
isShow
=
true
;
if
(
child
.
children
&&
child
.
expanded
)
{
this
.
open
(
index
+
childIndex
+
1
,
child
);
}
});
}
},
close
(
index
,
item
)
{
if
(
item
.
children
)
{
item
.
children
.
forEach
((
child
,
childIndex
)
=>
{
child
.
isShow
=
false
;
child
.
expanded
=
false
;
if
(
child
.
children
)
{
this
.
close
(
index
+
childIndex
+
1
,
child
);
}
});
}
},
// 点击check勾选框,判断是否有children节点 如果有就一并勾选
rowChecked
(
data
,
index
,
event
)
{
// this.$set(this.trs, index, data);
var
boys
=
this
.
getChildrens
(
data
);
if
(
boys
.
length
){
}
this
.
trs
.
forEach
((
u
,
i
)
=>
{
var
items
=
boys
.
filter
((
b
)
=>
{
return
b
[
this
.
keyname
]
==
u
[
this
.
keyname
];
});
if
(
items
.
length
==
1
)
{
this
.
$set
(
this
.
trs
[
i
],
"_checked"
,
!
data
.
_checked
);
}
});
this
.
checkAll
=
this
.
trs
.
length
>
this
.
trs
.
filter
((
u
)
=>
{
return
!
u
.
_checked
;
}).
length
;
this
.
$nextTick
(()
=>
{
this
.
selectionChange
();
});
},
getChildrens
(
data
)
{
var
childrens
=
[];
var
that
=
this
;
getChildren
(
data
);
function
getChildren
(
f
)
{
that
.
trs
.
forEach
((
u
)
=>
{
if
(
u
[
that
.
upname
]
==
f
[
that
.
keyname
])
{
childrens
.
push
(
u
);
getChildren
(
u
);
}
});
}
return
childrens
;
},
// checkbox 全选 选择事件
allChecked
(
v
)
{
this
.
trs
.
forEach
((
u
,
i
)
=>
{
this
.
$set
(
this
.
trs
[
i
],
"_checked"
,
v
);
});
this
.
$nextTick
(()
=>
{
this
.
selectionChange
();
});
},
selectionChange
()
{
var
items
=
this
.
trs
.
filter
((
u
)
=>
{
return
u
.
_checked
===
true
;
});
this
.
selectItems
=
items
;
this
.
$emit
(
"on-selection-change"
,
items
,
this
.
trs
);
this
.
footerToolbar
=
items
.
length
>
0
;
console
.
log
(
"footerToolbar"
,
items
,
this
.
trs
);
},
// 数组去重
getArray
(
a
)
{
const
hash
=
{};
const
len
=
a
.
length
;
const
result
=
[];
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
if
(
!
hash
[
a
[
i
]])
{
hash
[
a
[
i
]]
=
true
;
result
.
push
(
a
[
i
]);
}
}
return
result
;
},
All
(
data
)
{
let
arr
=
[];
data
.
forEach
((
item
)
=>
{
arr
.
push
(
item
.
id
);
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
arr
=
arr
.
concat
(
this
.
All
(
item
.
children
));
}
});
return
arr
;
},
// 返回表头
renderHeader
(
column
,
$index
)
{
if
(
"renderHeader"
in
this
.
columns
[
$index
])
{
return
this
.
columns
[
$index
].
renderHeader
(
column
,
$index
);
}
return
column
.
title
||
"#"
;
},
treeToList
(
tree
)
{
var
that
=
this
;
let
list
=
[];
function
treeToList
(
data
,
level
)
{
data
.
map
((
u
)
=>
{
let
copy
=
that
.
$u
.
clone
(
u
);
copy
.
_count
=
0
;
copy
.
_level
=
level
;
copy
.
_expanded
=
copy
.
_expanded
||
that
.
level
>
level
;
copy
.
_show
=
true
;
copy
.
_indeterminate
=
false
;
copy
.
_checked
=
copy
.
_checked
||
false
;
list
.
push
(
copy
);
if
(
u
.
children
)
{
treeToList
(
u
.
children
,
level
+
1
);
copy
.
_count
=
u
.
children
.
length
;
delete
copy
.
children
;
}
});
}
treeToList
(
tree
,
0
);
return
list
;
},
// 返回内容
renderBody
(
row
,
column
,
index
)
{
return
row
[
column
.
key
];
},
//分页选择
pageChange
(
page
)
{
this
.
search
.
page
=
page
;
this
.
search
.
pageIndex
=
page
;
this
.
load
();
},
pageSizeChange
(
size
)
{
this
.
search
.
pageSize
=
size
;
this
.
search
.
pageIndex
=
1
;
this
.
load
();
},
columnChange
(
item
,
i
)
{
item
.
hide
=
!
item
.
hide
;
this
.
$set
(
this
.
columnsCur
,
item
,
i
);
this
.
saveUserconfig
();
},
onSelect
(
rows
,
row
)
{
this
.
$emit
(
"on-change"
,
rows
,
row
);
},
allChange
(
items
)
{
this
.
$emit
(
"all-change"
,
items
);
},
undoConfig
()
{
//列设置恢复初始化
this
.
columnsCur
=
this
.
$u
.
clone
(
this
.
columns
);
// this.saveUserconfig();
},
//批量取消
cancelBatch
()
{
this
.
footerToolbar
=
false
;
// this.$refs.table.selectAll(false);
},
//导出excel
export2Excel
()
{
//当前显示数据
let
list
=
[];
list
=
this
.
trs
;
const
tHeader
=
[];
// 设置Excel的表格第一行的标题
const
filterVal
=
[];
//list里对象的属性
var
tempCol
=
[];
var
tempCol1
=
[];
//存放物料相关表头
var
tempCol2
=
[];
//存放工艺规程相关表头
var
tempColUser
=
[];
//存放type=user的表头
var
tempColUsers
=
[];
//存放type=users的表头
var
columnsCur
=
this
.
$u
.
clone
(
this
.
columns
);
//导出列标题信息griddata this.$refs.grid.columnsCur
columnsCur
.
forEach
((
el
)
=>
{
if
(
el
.
export
)
{
if
(
el
.
code
)
{
tempCol
.
push
({
key
:
el
.
key
,
code
:
el
.
code
,
});
//临时存放code数据字典的字段及对应的数据字典code
}
if
(
el
.
materialKey
)
{
tempCol1
.
push
({
key
:
el
.
key
,
code
:
el
.
materialKey
,
});
//临时存放物料管理大类和子类列表
}
if
(
el
.
techKey
)
{
tempCol2
.
push
({
key
:
el
.
key
,
code
:
el
.
techKey
,
});
//临时存放工艺规程相关转换
}
if
(
el
.
type
&&
el
.
type
==
"user"
)
{
tempColUser
.
push
({
key
:
el
.
key
,
code
:
el
.
type
,
});
//临时存放user列
}
if
(
el
.
type
&&
el
.
type
==
"users"
)
{
tempColUsers
.
push
({
key
:
el
.
key
,
code
:
el
.
type
,
});
//临时存放user列
}
tHeader
.
push
(
el
.
title
);
filterVal
.
push
(
el
.
key
);
}
});
list
.
forEach
((
e
)
=>
{
tempCol
.
forEach
((
elem
)
=>
{
if
(
(
e
[
elem
.
key
]
&&
e
[
elem
.
key
]
!=
""
&&
e
[
elem
.
key
]
!=
null
)
||
e
[
elem
.
key
]
==
0
)
{
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值。
let
codeArr
=
[];
let
keyValue
=
e
[
elem
.
key
];
if
(
keyValue
.
length
>
0
&&
(
keyValue
.
indexOf
(
","
)
>
-
1
||
keyValue
.
indexOf
(
","
)
>
-
1
)
)
{
//如果对应的数据包含多个数据字典项,比如包含“,”或“,”
if
(
keyValue
.
indexOf
(
","
)
>
-
1
)
{
codeArr
=
keyValue
.
split
(
","
);
}
if
(
keyValue
.
indexOf
>
-
1
)
{
codeArr
=
keyValue
.
split
(
","
);
}
}
}
},
if
(
codeArr
.
length
<=
1
)
{
show
(
item
)
{
//对应的数据包含一个数据字典项
if
(
item
.
_level
==
0
)
{
e
[
elem
.
key
]
=
this
.
$u
.
dirName
(
return
true
;
this
.
$store
.
getters
.
dictionaryByKey
(
elem
.
code
),
e
[
elem
.
key
]
);
}
else
{
}
else
{
var
parents
=
this
.
getRoots
(
item
);
//对应的数据包含多个数据字典项
return
(
let
codeInfo
=
""
;
parents
.
filter
((
u
)
=>
{
codeArr
.
forEach
((
el
)
=>
{
return
!
u
.
_expanded
;
codeInfo
=
}).
length
==
0
codeInfo
+
);
this
.
$u
.
dirName
(
this
.
$store
.
getters
.
dictionaryByKey
(
elem
.
code
),
el
)
+
","
;
});
e
[
elem
.
key
]
=
codeInfo
.
substr
(
0
,
codeInfo
.
length
-
1
);
}
}
},
}
getRoots
(
item
)
{
});
var
parents
=
[];
//导出数据增加对应的物料管理信息 code: 1【rootCategoryId 大类】 2【categoryId 大类】 3【codeRuleId 编码名称】
var
root
=
this
.
trs
.
filter
((
u
)
=>
{
tempCol1
.
forEach
((
elcol1
)
=>
{
return
u
[
this
.
keyname
]
==
item
[
this
.
upname
];
if
(
elcol1
.
code
==
1
)
{
e
[
elcol1
.
key
]
=
this
.
getType1
(
e
[
elcol1
.
key
]);
}
else
if
(
elcol1
.
code
==
2
)
{
e
[
elcol1
.
key
]
=
this
.
getType2
(
e
[
elcol1
.
key
]);
}
else
if
(
elcol1
.
code
==
3
)
{
e
[
elcol1
.
key
]
=
this
.
getType3
(
e
[
elcol1
.
key
]);
}
});
//导出工艺规程相关转换表头信息
tempCol2
.
forEach
((
elcol2
)
=>
{
if
(
elcol2
.
code
==
1
)
{
e
[
elcol2
.
key
]
=
this
.
getRoutingHeaderName
(
e
[
elcol2
.
key
]);
}
});
//导出username相关信息
tempColUser
.
forEach
((
eluser
)
=>
{
if
(
Array
.
isArray
(
e
[
eluser
.
key
])
&&
e
[
eluser
.
key
].
length
>
0
)
{
let
temUsers
=
this
.
$u
.
clone
(
e
[
eluser
.
key
]);
let
temUserName
=
""
;
temUsers
.
forEach
((
u
)
=>
{
temUserName
=
temUserName
+
this
.
getUserName
(
u
);
});
});
while
(
root
.
length
==
1
)
{
e
[
eluser
.
key
]
=
temUserName
;
parents
.
push
(
root
[
0
]);
}
root
=
this
.
trs
.
filter
((
u
)
=>
{
if
(
return
u
[
this
.
keyname
]
===
root
[
0
][
this
.
upname
];
e
[
eluser
.
key
]
&&
});
typeof
e
[
eluser
.
key
]
==
"string"
&&
}
e
[
eluser
.
key
]
!=
""
&&
return
parents
;
e
[
eluser
.
key
]
!=
null
},
)
{
open
(
index
,
item
)
{
e
[
eluser
.
key
]
=
this
.
getUserName
(
e
[
eluser
.
key
]);
if
(
item
.
children
)
{
}
item
.
children
.
forEach
((
child
,
childIndex
)
=>
{
});
child
.
isShow
=
true
;
tempColUsers
.
forEach
((
elusers
)
=>
{
if
(
child
.
children
&&
child
.
expanded
)
{
if
(
e
[
elusers
.
key
].
length
>
0
)
{
this
.
open
(
index
+
childIndex
+
1
,
child
);
let
temUsers
=
this
.
$u
.
clone
(
e
[
elusers
.
key
]);
}
let
temUserName
=
""
;
});
temUsers
.
forEach
((
u
)
=>
{
}
temUserName
=
temUserName
+
this
.
getUserName
(
u
)
+
","
;
},
close
(
index
,
item
)
{
if
(
item
.
children
)
{
item
.
children
.
forEach
((
child
,
childIndex
)
=>
{
child
.
isShow
=
false
;
child
.
expanded
=
false
;
if
(
child
.
children
)
{
this
.
close
(
index
+
childIndex
+
1
,
child
);
}
});
}
},
// 点击check勾选框,判断是否有children节点 如果有就一并勾选
rowChecked
(
data
,
index
,
event
)
{
var
boys
=
this
.
getChildrens
(
data
);
this
.
trs
.
forEach
((
u
,
i
)
=>
{
var
items
=
boys
.
filter
((
b
)
=>
{
return
b
[
this
.
keyname
]
==
u
[
this
.
keyname
];
});
if
(
items
.
length
==
1
)
{
this
.
$set
(
this
.
trs
[
i
],
"_checked"
,
!
data
.
_checked
);
}
});
});
this
.
checkAll
=
e
[
elusers
.
key
]
=
temUserName
.
substr
(
0
,
temUserName
.
length
-
1
);
this
.
trs
.
length
>
}
this
.
trs
.
filter
((
u
)
=>
{
});
return
!
u
.
_checked
;
});
}).
length
;
},
getChildrens
(
data
)
{
var
childrens
=
[];
var
that
=
this
;
getChildren
(
data
);
function
getChildren
(
f
)
{
that
.
trs
.
forEach
((
u
)
=>
{
if
(
u
[
that
.
upname
]
==
f
[
that
.
keyname
])
{
childrens
.
push
(
u
);
getChildren
(
u
);
}
});
}
return
childrens
;
},
// checkbox 全选 选择事件
checked
(
v
)
{
this
.
trs
.
forEach
((
u
,
i
)
=>
{
this
.
$set
(
this
.
trs
[
i
],
"_checked"
,
v
);
});
// this.$emit('on-selection-change', this.checkGroup)
},
// 数组去重
getArray
(
a
)
{
const
hash
=
{};
const
len
=
a
.
length
;
const
result
=
[];
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
if
(
!
hash
[
a
[
i
]])
{
hash
[
a
[
i
]]
=
true
;
result
.
push
(
a
[
i
]);
}
}
return
result
;
},
checkAllGroupChange
(
data
)
{
if
(
this
.
dataLength
>
0
&&
data
.
length
===
this
.
dataLength
)
{
this
.
checks
=
true
;
}
else
{
this
.
checks
=
false
;
}
this
.
$emit
(
"on-selection-change"
,
this
.
checkGroup
);
},
All
(
data
)
{
let
arr
=
[];
data
.
forEach
((
item
)
=>
{
arr
.
push
(
item
.
id
);
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
arr
=
arr
.
concat
(
this
.
All
(
item
.
children
));
}
});
return
arr
;
},
// 返回表头
let
nowDate
=
this
.
$u
.
getNowTime
();
//年月日时分秒yyyyMMddhhmmss
renderHeader
(
column
,
$index
)
{
//获取导出数据结束
if
(
"renderHeader"
in
this
.
columns
[
$index
])
{
return
this
.
columns
[
$index
].
renderHeader
(
column
,
$index
);
}
return
column
.
title
||
"#"
;
},
treeToList
(
tree
)
{
var
that
=
this
;
let
list
=
[];
function
treeToList
(
data
,
level
)
{
data
.
map
((
u
)
=>
{
let
copy
=
that
.
$u
.
clone
(
u
);
copy
.
_count
=
0
;
copy
.
_level
=
level
;
copy
.
_expanded
=
copy
.
_expanded
||
that
.
level
>
level
;
copy
.
_show
=
true
;
copy
.
_indeterminate
=
false
;
copy
.
_checked
=
copy
.
_checked
||
false
;
list
.
push
(
copy
);
if
(
u
.
children
)
{
treeToList
(
u
.
children
,
level
+
1
);
copy
.
_count
=
u
.
children
.
length
;
delete
copy
.
children
;
}
});
}
treeToList
(
tree
,
0
);
return
list
;
},
// 返回内容
renderBody
(
row
,
column
,
index
)
{
return
row
[
column
.
key
];
},
// 默认选中
renderCheck
(
data
)
{
let
arr
=
[];
data
.
forEach
((
item
)
=>
{
if
(
item
.
_checked
)
{
arr
.
push
(
item
.
id
);
}
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
arr
=
arr
.
concat
(
this
.
renderCheck
(
item
.
children
));
}
});
return
arr
;
},
//分页选择
pageChange
(
page
)
{
this
.
search
.
page
=
page
;
this
.
search
.
pageIndex
=
page
;
this
.
load
();
},
pageSizeChange
(
size
)
{
this
.
search
.
pageSize
=
size
;
this
.
search
.
pageIndex
=
1
;
this
.
load
();
},
columnChange
(
item
,
i
)
{
item
.
hide
=
!
item
.
hide
;
this
.
$set
(
this
.
columnsCur
,
item
,
i
);
this
.
saveUserconfig
();
},
selectionChange
(
items
)
{
this
.
$emit
(
"on-selection-change"
,
items
);
this
.
selectItems
=
items
;
this
.
footerToolbar
=
items
.
length
>
0
;
},
onSelect
(
rows
,
row
)
{
this
.
$emit
(
"on-change"
,
rows
,
row
);
},
allChange
(
items
)
{
this
.
$emit
(
"all-change"
,
items
);
},
undoConfig
()
{
//列设置恢复初始化
this
.
columnsCur
=
this
.
$u
.
clone
(
this
.
columns
);
// this.saveUserconfig();
},
//批量取消
cancelBatch
()
{
this
.
footerToolbar
=
false
;
this
.
$refs
.
table
.
selectAll
(
false
);
},
//导出excel
export2Excel
()
{
//col
//list
//当前显示数据
let
list
=
[];
list
=
this
.
trs
;
const
tHeader
=
[];
// 设置Excel的表格第一行的标题
const
filterVal
=
[];
//list里对象的属性
var
tempCol
=
[];
var
tempCol1
=
[];
//存放物料相关表头
var
tempCol2
=
[];
//存放工艺规程相关表头
var
tempColUser
=
[];
//存放type=user的表头
var
tempColUsers
=
[];
//存放type=users的表头
var
columnsCur
=
this
.
$u
.
clone
(
this
.
columns
);
//导出列标题信息griddata this.$refs.grid.columnsCur
columnsCur
.
forEach
((
el
)
=>
{
if
(
el
.
export
)
{
if
(
el
.
code
)
{
tempCol
.
push
({
key
:
el
.
key
,
code
:
el
.
code
,
});
//临时存放code数据字典的字段及对应的数据字典code
}
if
(
el
.
materialKey
)
{
tempCol1
.
push
({
key
:
el
.
key
,
code
:
el
.
materialKey
,
});
//临时存放物料管理大类和子类列表
}
if
(
el
.
techKey
)
{
tempCol2
.
push
({
key
:
el
.
key
,
code
:
el
.
techKey
,
});
//临时存放工艺规程相关转换
}
if
(
el
.
type
&&
el
.
type
==
"user"
)
{
tempColUser
.
push
({
key
:
el
.
key
,
code
:
el
.
type
,
});
//临时存放user列
}
if
(
el
.
type
&&
el
.
type
==
"users"
)
{
tempColUsers
.
push
({
key
:
el
.
key
,
code
:
el
.
type
,
});
//临时存放user列
}
tHeader
.
push
(
el
.
title
);
filterVal
.
push
(
el
.
key
);
}
});
list
.
forEach
((
e
)
=>
{
tempCol
.
forEach
((
elem
)
=>
{
if
((
e
[
elem
.
key
]
&&
e
[
elem
.
key
]
!=
""
&&
e
[
elem
.
key
]
!=
null
)
||
e
[
elem
.
key
]
==
0
)
{
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值。
let
codeArr
=
[];
let
keyValue
=
e
[
elem
.
key
];
if
(
keyValue
.
length
>
0
&&
(
keyValue
.
indexOf
(
","
)
>
-
1
||
keyValue
.
indexOf
(
","
)
>
-
1
)
)
{
//如果对应的数据包含多个数据字典项,比如包含“,”或“,”
if
(
keyValue
.
indexOf
(
","
)
>
-
1
)
{
codeArr
=
keyValue
.
split
(
","
);
}
if
(
keyValue
.
indexOf
>
-
1
)
{
codeArr
=
keyValue
.
split
(
","
);
}
}
if
(
codeArr
.
length
<=
1
)
{
//对应的数据包含一个数据字典项
e
[
elem
.
key
]
=
this
.
$u
.
dirName
(
this
.
$store
.
getters
.
dictionaryByKey
(
elem
.
code
),
e
[
elem
.
key
]
);
}
else
{
//对应的数据包含多个数据字典项
let
codeInfo
=
""
;
codeArr
.
forEach
((
el
)
=>
{
codeInfo
=
codeInfo
+
this
.
$u
.
dirName
(
this
.
$store
.
getters
.
dictionaryByKey
(
elem
.
code
),
el
)
+
","
;
});
e
[
elem
.
key
]
=
codeInfo
.
substr
(
0
,
codeInfo
.
length
-
1
);
}
}
});
//导出数据增加对应的物料管理信息 code: 1【rootCategoryId 大类】 2【categoryId 大类】 3【codeRuleId 编码名称】
tempCol1
.
forEach
((
elcol1
)
=>
{
if
(
elcol1
.
code
==
1
)
{
e
[
elcol1
.
key
]
=
this
.
getType1
(
e
[
elcol1
.
key
]);
}
else
if
(
elcol1
.
code
==
2
)
{
e
[
elcol1
.
key
]
=
this
.
getType2
(
e
[
elcol1
.
key
]);
}
else
if
(
elcol1
.
code
==
3
)
{
e
[
elcol1
.
key
]
=
this
.
getType3
(
e
[
elcol1
.
key
]);
}
});
//导出工艺规程相关转换表头信息
tempCol2
.
forEach
((
elcol2
)
=>
{
if
(
elcol2
.
code
==
1
)
{
e
[
elcol2
.
key
]
=
this
.
getRoutingHeaderName
(
e
[
elcol2
.
key
]);
}
});
//导出username相关信息
tempColUser
.
forEach
((
eluser
)
=>
{
if
(
Array
.
isArray
(
e
[
eluser
.
key
])
&&
e
[
eluser
.
key
].
length
>
0
)
{
let
temUsers
=
this
.
$u
.
clone
(
e
[
eluser
.
key
])
let
temUserName
=
''
temUsers
.
forEach
(
u
=>
{
temUserName
=
temUserName
+
this
.
getUserName
(
u
);
})
e
[
eluser
.
key
]
=
temUserName
}
if
(
e
[
eluser
.
key
]
&&
typeof
(
e
[
eluser
.
key
])
==
'string'
&&
e
[
eluser
.
key
]
!=
""
&&
e
[
eluser
.
key
]
!=
null
)
{
e
[
eluser
.
key
]
=
this
.
getUserName
(
e
[
eluser
.
key
]);
}
});
tempColUsers
.
forEach
((
elusers
)
=>
{
if
(
e
[
elusers
.
key
].
length
>
0
)
{
let
temUsers
=
this
.
$u
.
clone
(
e
[
elusers
.
key
])
let
temUserName
=
''
temUsers
.
forEach
(
u
=>
{
temUserName
=
temUserName
+
this
.
getUserName
(
u
)
+
','
;
})
e
[
elusers
.
key
]
=
temUserName
.
substr
(
0
,
temUserName
.
length
-
1
)
}
});
});
let
nowDate
=
this
.
$u
.
getNowTime
();
//年月日时分秒yyyyMMddhhmmss
this
.
$nextTick
(()
=>
{
//获取导出数据结束
this
.
$u
.
outExcel
(
this
.
exportTitle
+
"("
+
nowDate
+
")"
,
this
.
$nextTick
(()
=>
{
tHeader
,
this
.
$u
.
outExcel
(
filterVal
,
this
.
exportTitle
+
"("
+
nowDate
+
")"
,
list
tHeader
,
);
filterVal
,
});
list
},
);
//获取所有用户信息
})
getAllUser
()
{
this
.
$api
},
.
post
(
`
${
systemUrl
}
/user/paged`
,
{
//获取所有用户信息
conditions
:
[],
getAllUser
()
{
pageIndex
:
1
,
this
.
$api
pageSize
:
100000
,
.
post
(
`
${
systemUrl
}
/user/paged`
,
{
})
conditions
:
[],
.
then
((
r
)
=>
{
pageIndex
:
1
,
if
(
r
.
success
)
{
pageSize
:
100000
,
let
tempUserInfo
=
r
.
result
.
items
;
})
tempUserInfo
.
forEach
((
ele
)
=>
{
.
then
((
r
)
=>
{
let
temObj
=
{
if
(
r
.
success
)
{
userId
:
ele
.
id
,
let
tempUserInfo
=
r
.
result
.
items
;
name
:
ele
.
userName
,
tempUserInfo
.
forEach
((
ele
)
=>
{
};
let
temObj
=
{
this
.
allUser
.
push
(
temObj
);
userId
:
ele
.
id
,
name
:
ele
.
userName
,
};
this
.
allUser
.
push
(
temObj
);
});
}
});
},
getUserName
(
id
)
{
let
name
=
""
;
this
.
allUser
.
forEach
((
ele
)
=>
{
if
(
id
==
ele
.
userId
)
{
name
=
ele
.
name
;
}
});
});
return
name
;
}
}
,
}
);
},
},
getUserName
(
id
)
{
let
name
=
""
;
this
.
allUser
.
forEach
((
ele
)
=>
{
if
(
id
==
ele
.
userId
)
{
name
=
ele
.
name
;
}
});
return
name
;
},
},
};
};
</
script
>
</
script
>
...
@@ -863,123 +951,122 @@ export default {
...
@@ -863,123 +951,122 @@ export default {
@table_line_height: 50px;
@table_line_height: 50px;
@table_hover: #f2f8fe;
@table_hover: #f2f8fe;
@table_border: #e8e9eb;
@table_border: #e8e9eb;
// @table_theme: #2680eb;
// @table_theme: #2680eb;
// @table_head: #e9f2fd;
// @table_head: #e9f2fd;
// @table_line_height: 50px;
// @table_line_height: 50px;
// @table_hover: #f2f8fe;
// @table_hover: #f2f8fe;
// @table_border: #accef7;
// @table_border: #accef7;
.table-content1 {
.table-content1 {
position: relative;
position: relative;
height: 100%;
height: 100%;
display: flex;
display: flex;
flex-direction: column;
flex-direction: column;
.table-tools {
line-height: 40px;
background: @right-header-bg;
.table-search {
float: left;
line-height: 40px;
min-width: 300px;
}
.btns {
.table-tools {
float: right;
line-height: 40px;
line-height: 40px;
background: @right-header-bg;
}
tr:hover {
.table-search {
background: #f7f7f7;
float: left;
}
line-height: 40px;
min-width: 300px;
}
}
.icon-set {
.btns {
font-size: 17px;
float: right;
margin-left: 5px;
line-height: 40px;
display: inline-block;
}
}
.icon-set .ivu-icon
{
tr:hover
{
cursor: pointer
;
background: #f7f7f7
;
}
}
}
table {
.icon-set {
border-spacing: 0;
font-size: 17px;
border-collapse: collapse;
margin-left: 5px;
margin: 0 auto;
display: inline-block;
width: 100%;
}
border: 1px solid @table_border;
th
{
.icon-set .ivu-icon
{
background: @table_head
;
cursor: pointer
;
}
}
td,
table {
th {
border-spacing: 0;
border: @table_border solid 1px;
border-collapse: collapse;
line-height: 40px;
margin: 0 auto;
padding: 0 5px;
width: 100%;
border: 1px solid @table_border;
.drag:hover
{
th
{
cursor: move
;
background: @table_head
;
}
}
.expand {
td,
width: 18px;
th {
height: 18px;
border: @table_border solid 1px;
border: 1px solid @table_border;
line-height: 40px;
text-align: center;
padding: 0 5px;
padding: 0 1px;
font-size: 14px;
font-weight: bold;
}
.expand:hover {
.drag:hover {
background: @table_theme;
cursor: move;
color: white;
}
}
.ib {
.expand {
display: inline-block;
width: 18px;
}
height: 18px;
}
border: 1px solid @table_border;
text-align: center;
padding: 0 1px;
font-size: 14px;
font-weight: bold;
}
th {
.expand:hover {
border-top: @table_border solid 1px;
background: @table_theme;
}
color: white;
}
tr.treetr:hover td {
.ib {
background: @table_hover;
display: inline-block;
}
}
}
tr.move {
th {
td {
border-top: @table_border solid 1px;
background-color: #d3e6fb;
}
}
}
tr.sort {
tr.treetr:hover td {
td {
background: @table_hover;
border-top: 2px solid #3b8ded;
}
}
}
tbody {
tr.move {
border-bottom: @table_border solid 1px;
td {
}
background-color: #d3e6fb;
}
}
.ms-tree-space {
tr.sort {
position: relative;
td {
top: 1px;
border-top: 2px solid #3b8ded;
display: inline-block;
}
font-style: normal;
}
font-weight: 400;
line-height: 1;
tbody {
width: 14px;
border-bottom: @table_border solid 1px;
height: 14px;
}
}
.ms-tree-space {
position: relative;
top: 1px;
display: inline-block;
font-style: normal;
font-weight: 400;
line-height: 1;
width: 14px;
height: 14px;
}
}
}
}
}
</
style
>
</
style
>
pages/project/plan/index.vue
View file @
9dc1f424
<
template
>
<
template
>
<div>
<div>
<Card>
<Card>
<EditGrid
:columns=
"columns"
ref=
"grid"
:items=
"list"
:level=
"8"
:drag=
"true"
:exportTitle=
"exportTl"
>
<EditGrid
:columns=
"columns"
ref=
"grid"
:
batch=
"true"
:
items=
"list"
:level=
"8"
:drag=
"true"
:exportTitle=
"exportTl"
>
<template
slot=
"easySearch"
>
<template
slot=
"easySearch"
>
<Form
ref=
"formInline"
:model=
"easySearch"
inline
>
<Form
ref=
"formInline"
:model=
"easySearch"
inline
>
<FormItem
prop=
"keys"
><Input
placeholder=
"请输入关键字标题"
v-model=
"easySearch.keys.value"
/>
<FormItem
prop=
"keys"
><Input
placeholder=
"请输入关键字标题"
v-model=
"easySearch.keys.value"
/>
...
...
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