Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kwell-mes
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
gavelinfo
kwell-mes
Commits
fec40c4d
Commit
fec40c4d
authored
Mar 25, 2022
by
周毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bom页面移到标准
parent
1277a000
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
671 deletions
+0
-671
edit.html
gavel/src/main/resources/templates/views/bom/bom/edit.html
+0
-173
index.html
gavel/src/main/resources/templates/views/bom/bom/index.html
+0
-498
No files found.
gavel/src/main/resources/templates/views/bom/bom/edit.html
deleted
100644 → 0
View file @
1277a000
<div
id=
"bomBomEdit"
class=
"e-dialog-container"
data-options=
"width:720,height:320"
>
<div
class=
"e-single-dialog"
>
<input
type=
"hidden"
name=
"flag"
>
<input
type=
"hidden"
name=
"id"
>
<input
type=
"hidden"
name=
"xh"
>
<input
type=
"hidden"
name=
"bomid"
>
<!-- <div class="gui-row" style="display: none">
<div class="gui-col-sm12">
<label class="gui-form-label">产品结构:</label>
<div class="gui-input-block">
<input type="text" name="bomid" data-toggle="gui-textbox" data-options="required:true" disabled >
</div>
</div>
</div>-->
<div
class=
"gui-row"
>
<div
class=
"gui-col-sm6"
>
<label
class=
"gui-form-label"
>
物料:
</label>
<div
class=
"gui-input-block"
>
<input
type=
"text"
name=
"wlid"
data-toggle=
"gui-textbox"
data-title=
"wlxxName"
data-options=
"required:true"
>
</div>
</div>
<div
class=
"gui-col-sm6"
>
<label
class=
"gui-form-label"
>
单位用量:
</label>
<div
class=
"gui-input-block"
>
<input
type=
"text"
name=
"dwyl"
data-toggle=
"gui-textbox"
data-options=
"required:true"
>
</div>
</div>
</div>
<div
class=
"gui-row"
>
<!-- <div class="gui-col-sm4">
<label class="gui-form-label">工厂:</label>
<div class="gui-input-block">
<input type="text" name="gcid" data-toggle="gui-textbox" >
</div>
</div>-->
<!-- <div class="gui-col-sm4">
<label class="gui-form-label">序号:</label>
<div class="gui-input-block">
<input type="text" name="xh" data-toggle="gui-textbox" data-options="" >
</div>
</div>-->
</div>
<div
class=
"gui-row"
>
<div
class=
"gui-col-sm6"
>
<label
class=
"gui-form-label"
>
损耗率:
</label>
<div
class=
"gui-input-block"
>
<input
type=
"text"
name=
"shl"
data-toggle=
"gui-textbox"
data-options=
""
>
</div>
</div>
<div
class=
"gui-col-sm6"
>
<label
class=
"gui-form-label"
>
损耗值:
</label>
<div
class=
"gui-input-block"
>
<input
type=
"text"
name=
"shz"
data-toggle=
"gui-textbox"
data-options=
""
>
</div>
</div>
</div>
<div
class=
"gui-row"
>
<div
class=
"gui-col-sm6"
>
<label
class=
"gui-form-label"
>
发放原则:
</label>
<div
class=
"gui-input-block"
>
<input
type=
"text"
name=
"ffyz"
data-toggle=
"gui-textbox"
data-options=
"required:true"
>
</div>
</div>
<div
class=
"gui-col-sm6"
>
<label
class=
"gui-form-label"
>
发放工序:
</label>
<div
class=
"gui-input-block"
>
<input
type=
"text"
name=
"ffgx"
data-toggle=
"gui-textbox"
data-title=
"gylxName"
data-options=
""
>
<input
type=
"hidden"
name=
"gylxName"
>
</div>
</div>
</div>
<div
class=
"gui-row"
>
<div
class=
"gui-col-sm12"
>
<label
class=
"gui-form-label"
>
备注:
</label>
<div
class=
"gui-input-block"
>
<input
type=
"text"
name=
"bz"
data-toggle=
"gui-textbox"
data-options=
""
>
</div>
</div>
</div>
</div>
<div
class=
"e-dialog-footer"
>
<a
href=
"javascript:void(0);"
class=
"e-dialog-ok"
></a>
<a
href=
"javascript:void(0);"
class=
"e-dialog-cancel"
></a>
</div>
</div>
<script>
$
(
function
()
{
var
$dialog
=
$
(
'#bomBomEdit'
);
var
$edtbomid
=
$dialog
.
find
(
"input[name='bomid']"
);
var
$edtWlid
=
$dialog
.
find
(
"input[name='wlid']"
);
var
$edtFfgx
=
$dialog
.
find
(
"input[name='ffgx']"
);
var
$edtFfyz
=
$dialog
.
find
(
"input[name='ffyz']"
);
var
$inputXh
=
$dialog
.
find
(
"input[name='xh']"
);
var
parmas
=
$dialog
.
parent
().
dialog
(
"options"
).
params
;
var
xh
=
parmas
.
xh
;
var
tag
=
$dialog
.
closest
(
"form"
).
attr
(
"tag"
);
function
paramsInit
(){
}
function
pageInit
(){
$edtFfyz
.
iCombobox
({
valueField
:
'id'
,
textField
:
'name'
,
allowNull
:
false
,
allowEdit
:
false
});
if
(
tag
==
"add"
){
$edtbomid
.
val
(
parmas
.
bomid
);
}
Auxiliary
.
box
(
$edtWlid
,{
code
:
'WLID'
});
Auxiliary
.
box
(
$edtFfgx
,{
code
:
'FFGX'
,
onBeforeLoad
:
function
(){
return
{
wlid
:
$edtbomid
.
val
()};
}});
}
function
dataInit
(
ops
)
{
gas
.
postHTTP
(
"bom/bom/init/ffyz"
,{},
function
(
res
)
{
if
(
res
.
success
){
$edtFfyz
.
combobox
(
"loadData"
,
res
.
data
.
records
||
[])
}
},
ops
);
$inputXh
.
val
(
xh
);
}
function
run
(){
}
gas
.
load
(
paramsInit
,
pageInit
,
dataInit
,
run
);
$dialog
.
find
(
".e-dialog-ok"
).
iMenubutton
({
text
:
"确定"
,
iconCls
:
"fa fa-save"
,
btnCls
:
"gui-btn-save"
,
onClick
:
function
(){
var
data
=
DataBind
.
collectData
(
$dialog
);
var
queryUrl
=
"bom/bom/add"
;
if
(
tag
==
'add'
){
HTTP
.
post
(
queryUrl
,{
master
:
data
},
function
(
res
)
{
if
(
res
.
success
){
$dialog
.
closest
(
".panel-body"
).
iDialog
(
"setStatus"
,{
"state"
:
"ok"
,
data
:{
data
:
$
.
extend
({},
data
,{
id
:
res
.
data
.
id
,
bomid
:
data
.
bomid
,
wlid
:
data
.
wlid
}),
type
:
tag
}});
gas
.
showTips
(
"操作成功"
)
}
else
{
gas
.
showWarning
(
res
,
"操作失败"
)
}
})
}
else
if
(
tag
==
"edit"
){
queryUrl
=
"bom/bom/update"
;
HTTP
.
post
(
queryUrl
,{
master
:
data
},
function
(
res
)
{
if
(
res
.
success
){
$dialog
.
closest
(
".panel-body"
).
iDialog
(
"setStatus"
,{
"state"
:
"ok"
,
data
:{
data
:
data
,
type
:
tag
}});
gas
.
showTips
(
"操作成功"
);
}
else
{
gas
.
showWarning
(
res
,
"操作失败"
)
}
})
}
}
});
})
</script>
\ No newline at end of file
gavel/src/main/resources/templates/views/bom/bom/index.html
deleted
100644 → 0
View file @
1277a000
<div
id=
"bomBom"
class=
"gui-div"
>
<table
class=
"toolbar-table"
data-options=
"id: 'bomBomTable',herf:'kzzx/gridset/query'"
></table>
<!-- 表格工具栏开始 -->
<div
id=
"bomBomTable-toolbar"
class=
"gui-toolbar"
data-options=
"grid:{type:'treegrid',id:'bomBomTable'}"
>
<div
class=
"navbar-toolbar"
>
<a
class=
"toolbar-print toolbar"
href=
"javascript:void(0)"
></a>
<a
class=
"toolbar-export toolbar"
href=
"javascript:void(0)"
></a>
<a
class=
"toolbar-review toolbar"
href=
"javascript:void(0)"
></a>
<a
class=
"toolbar-add toolbar"
href=
"javascript:void(0)"
></a>
<a
class=
"toolbar-edit toolbar"
href=
"javascript:void(0)"
></a>
<a
class=
"toolbar-deleteNode toolbar"
href=
"javascript:void(0)"
></a>
<a
class=
"toolbar-moveup toolbar"
href=
"javascript:void(0)"
></a>
<a
class=
"toolbar-movedown toolbar"
href=
"javascript:void(0)"
></a>
</div>
<div
class=
"form-sub"
>
<form
class=
"query-criteria"
>
<ul>
<li
class=
"gui-form-row"
>
<!--<div class="gui-col-sm4">
<label class="gui-form-label">工厂:</label>
<div class="gui-input-block">
<input type="text" name="gcid" class="gui-textbox">
</div>
</div>-->
<div
class=
"gui-col-sm4"
>
<label
class=
"gui-form-label"
>
产品结构号:
</label>
<div
class=
"gui-input-block"
>
<input
type=
"text"
name=
"bomid"
class=
"gui-textbox"
>
</div>
</div>
</li>
</ul>
<span
class=
"toolbar-search-span"
><a
id=
"bomsearch"
class=
"toolbar-search"
href=
"javascript:void(0)"
></a></span>
</form>
</div>
</div>
</div>
<!-- 表格工具栏结束 -->
<script>
$
(
function
()
{
/*js初始化*/
var
opentype
=
"add"
;
var
$add
=
$
(
".toolbar-add"
)
var
$edit
=
$
(
".toolbar-edit"
)
var
$div
=
$
(
'#bomBom'
);
var
$datagrid
=
$div
.
find
(
".toolbar-table"
);
var
$edtBomid
=
$div
.
find
(
'input[name="bomid"]'
);
var
$wlsxColumns
=
[];
var
xh
=
10
;
var
vidTotal
=
0
;
var
$typeMap
=
{};
var
theDataPool
=
[];
let
expandedKeys
=
[]
//是一个树结构的数据
function
paramInit
(
ops
){
initWlsxColumns
(
$wlsxColumns
);
gas
.
postHTTP
(
"bom/bom/init/ffyz"
,{},
function
(
res
)
{
if
(
res
.
success
){
var
data
=
res
[
'data'
][
'records'
];
for
(
var
i
in
data
){
$typeMap
[
data
[
i
].
id
]
=
data
[
i
].
name
}
}
},
ops
);
}
function
pageInit
()
{
var
options
=
{
url
:
'bom/bom'
,
noRequest
:
true
,
columns
:
[[
{
title
:
"物料编码"
,
field
:
"wlxxCode"
,
fieldType
:
"ftString"
,
width
:
140
},
{
title
:
"物料名称"
,
field
:
"wlxxName"
,
fieldType
:
"ftString"
,
width
:
160
},
{
title
:
"单位用量"
,
field
:
"dwyl"
,
fieldType
:
"float"
},
{
title
:
"损耗率"
,
field
:
"shl"
,
fieldType
:
"float"
},
{
title
:
"损耗值"
,
field
:
"shz"
,
fieldType
:
"float"
},
{
title
:
"发放原则"
,
field
:
"ffyz"
,
fieldType
:
"ftString"
,
width
:
80
,
formatter
:
function
(
value
,
index
,
row
)
{
var
text
=
$typeMap
[
value
];
return
text
||
""
;
}},
{
title
:
"发放工序"
,
field
:
"gylxName"
,
fieldType
:
"ftString"
,
width
:
140
},
{
title
:
"备注"
,
field
:
"bz"
,
fieldType
:
"ftString"
,
width
:
240
},
{
title
:
"状态"
,
field
:
"tybz"
,
fieldType
:
"ftString"
,
width
:
80
},
{
title
:
"停用日期"
,
field
:
"tyrq"
,
fieldType
:
"ftDateTime"
},
{
title
:
"维护人"
,
field
:
"whr"
,
fieldType
:
"ftString"
},
{
title
:
"维护时间"
,
field
:
"whsj"
,
fieldType
:
"ftDateTime"
}
].
concat
(
$wlsxColumns
)],
type
:
"treegrid"
,
treeOption
:{
idField
:
'vid'
,
treeField
:
'wlxxCode'
,
fitColumns
:
false
,
rownumbers
:
true
,
onLoadSuccess
:
function
(
row
){
$
(
this
).
treegrid
(
'enableDnd'
,
row
?
row
.
vid
:
null
);
},
onStopDrag
:
function
(
a
,
b
)
{
},
onBeforeDrop
:
function
(
targetRow
,
sourceRow
,
point
)
{
var
bomid
=
targetRow
[
"wlid"
];
var
vid
=
targetRow
[
"vid"
];
var
targetVid
=
sourceRow
[
"vid"
];
sourceRow
[
"bomid"
]
=
bomid
;
if
(
point
==
"append"
){
appendNode
(
sourceRow
,
targetVid
,
targetRow
)
}
},
onDragLeave
:
function
(
targetRow
,
sourceRow
)
{
}
},
delimitingRun
:
run
,
dialog
:
{
footerIn
:
true
,
href
:
'bom/bom/edit'
,
onBeforeLoad
:
function
()
{
var
selectedRow
=
$datagrid
.
treegrid
(
"getSelected"
);
var
children
=
$datagrid
.
treegrid
(
"getChildren"
,
selectedRow
.
vid
);
if
(
children
.
length
>
0
){
xh
=
parseFloat
(
children
[
children
.
length
-
1
][
"xh"
])
+
10
}
$
(
this
).
dialog
(
"options"
).
params
=
{
bomid
:
selectedRow
?
selectedRow
.
wlid
:
""
,
xh
:
xh
}
},
onSaveCallback
:
function
(
el
,
params
)
{
var
data
=
params
[
"data"
];
var
saveType
=
params
[
"type"
]
var
selectedNode
=
$datagrid
.
treegrid
(
"getSelected"
);
expandedKeys
=
[];
setName
(
$datagrid
.
treegrid
(
"getData"
));
var
treeData
=
[...
expandedKeys
];
var
wlxxData
=
[];
$
(
"#bomsearch"
).
click
()
if
(
saveType
==
"add"
){
/*新增回调*/
gas
.
post
(
"bom/bom/query"
,{
bomid
:
data
.
bomid
},
function
(
res
)
{
if
(
res
.
success
){
wlxxData
=
[...
res
.
data
.
records
];
wlxxData
[
0
]
=
$
.
extend
(
wlxxData
[
0
],
data
);
var
rows
=
findFormWlid
(
treeData
,
data
.
bomid
);
$
.
each
(
rows
,
function
(
i
,
item
)
{
var
wlxxRoot
=
buildTree
(
wlxxData
,
data
.
bomid
);
$datagrid
.
treegrid
(
"append"
,{
parent
:
item
.
vid
,
data
:[...
wlxxRoot
]
});
$datagrid
.
treegrid
(
"refresh"
,
item
.
vid
);
});
$datagrid
.
treegrid
(
'enableDnd'
,
null
);
}
else
{
gas
.
showError
(
res
,
"查询失败"
)
}
})
}
else
if
(
saveType
==
"edit"
){
gas
.
post
(
"bom/bom/query"
,{
bomid
:
data
.
bomid
},
function
(
res
)
{
if
(
res
.
success
){
wlxxData
=
[...
res
.
data
.
records
];
wlxxData
[
0
]
=
$
.
extend
(
wlxxData
[
0
],
data
);
var
rows
=
findFormId
(
treeData
,
selectedNode
.
id
);
$
.
each
(
rows
,
function
(
i
,
item
)
{
var
wlxxRoot
=
buildTree
(
wlxxData
,
data
.
bomid
);
var
children
=
$datagrid
.
treegrid
(
"getChildren"
,
item
.
vid
);
$
.
each
(
children
,
function
(
i
,
item
)
{
$datagrid
.
treegrid
(
"remove"
,
item
.
vid
)
});
$datagrid
.
treegrid
(
"update"
,{
id
:
item
.
vid
,
row
:
wlxxRoot
[
0
]
});
$datagrid
.
treegrid
(
"refresh"
,
item
.
vid
);
if
(
wlxxRoot
[
0
][
"children"
]
&&
wlxxRoot
[
0
][
"children"
].
length
>
0
){
$datagrid
.
treegrid
(
"append"
,{
parent
:
item
.
vid
,
data
:[...
wlxxRoot
[
0
][
"children"
]]
});
}
});
}
else
{
gas
.
showError
(
res
,
"查询失败!"
)
}
})
}
},
messager
:
function
(
e
)
{
var
selectedRow
=
$datagrid
.
treegrid
(
"getSelected"
);
if
(
!
selectedRow
){
gas
.
showWarning
(
"请选择一条数据!"
);
return
true
}
if
(
selectedRow
.
bomid
==
"root"
&&
opentype
==
"edit"
){
gas
.
showWarning
(
"无法操作根节点!"
);
return
true
}
else
{
HTTP
.
post
(
'editValue'
,{
id
:
selectedRow
.
bomid
},
function
(
result
)
{
if
(
result
[
"success"
]){
var
data
=
result
.
data
.
records
}
else
{
gas
.
showWarning
(
"无法操作根节点!"
);
return
true
}
})
}
}
}
};
$edit
.
click
(
function
(){
opentype
=
"edit"
})
$add
.
click
(
function
(){
opentype
=
"add"
})
$div
.
Holder
(
options
);
Auxiliary
.
box
(
$edtBomid
,{
code
:
'WLID'
,
callback
:
function
(
res
)
{
$edtBomid
.
textbox
(
"setValue"
,
res
.
id
);
$edtBomid
.
textbox
(
"setText"
,
res
.
name
);
run
()
}});
$div
.
find
(
".toolbar-moveup"
).
iMenubutton
({
iconCls
:
'fa fa-long-arrow-up'
,
text
:
'上移'
,
onClick
:
bomMoveUp
});
$div
.
find
(
".toolbar-movedown"
).
iMenubutton
({
iconCls
:
'fa fa-long-arrow-up'
,
text
:
'下移'
,
onClick
:
bomMoveDown
});
$div
.
find
(
".toolbar-deleteNode"
).
iMenubutton
({
iconCls
:
"fa fa-trash"
,
text
:
"删除"
,
onClick
:
bomDelete
})
}
function
bomMoveUp
()
{
var
n
=
$datagrid
.
treegrid
(
"getSelected"
);
if
(
n
==
null
){
gas
.
showWarning
(
"无法移动!"
);
return
;}
var
parentNode
=
$datagrid
.
treegrid
(
"getParent"
,
n
.
vid
);
var
index
=
parentNode
.
children
.
findIndex
(
function
(
item
)
{
return
item
.
vid
==
n
.
vid
});
if
(
index
==
0
)
{
gas
.
showWarning
(
"无法移动!"
);
return
;}
HTTP
.
post
(
'bom/bom/moveup'
,{
id
:
n
.
id
},
function
(
result
)
{
if
(
result
.
success
){
expandedKeys
=
[];
setName
(
$datagrid
.
treegrid
(
"getData"
));
var
treeData
=
[...
expandedKeys
];
var
preId
=
parentNode
[
"children"
][
index
-
1
][
"vid"
];
var
n2
=
$datagrid
.
treegrid
(
"pop"
,
n
.
vid
);
$datagrid
.
treegrid
(
"insert"
,{
before
:
preId
,
data
:
n2
});
$datagrid
.
treegrid
(
"select"
,
n
.
vid
);
var
rows
=
findFormId
(
treeData
,
n
.
id
);
$
.
each
(
rows
,
function
(
i
,
row
)
{
if
(
row
.
vid
!=
n
.
vid
){
replaceMoveup
(
$div
,
row
.
vid
)
}
})
}
else
{
gas
.
showError
(
result
,
"操作失败"
);
}
})
}
function
replaceMoveup
(
$div
,
vid
)
{
var
parentNode
=
$datagrid
.
treegrid
(
"getParent"
,
vid
);
var
index
=
parentNode
.
children
.
findIndex
(
function
(
item
)
{
return
item
.
vid
==
vid
});
var
preId
=
parentNode
[
"children"
][
index
-
1
][
"vid"
];
var
n2
=
$datagrid
.
treegrid
(
"pop"
,
vid
);
$datagrid
.
treegrid
(
"insert"
,{
before
:
preId
,
data
:
n2
});
}
function
replaceMovedown
(
$div
,
vid
)
{
var
parentNode
=
$datagrid
.
treegrid
(
"getParent"
,
vid
);
var
index
=
parentNode
.
children
.
findIndex
(
function
(
item
)
{
return
item
.
vid
==
vid
});
var
preId
=
parentNode
[
"children"
][
index
+
1
][
"vid"
];
var
n2
=
$datagrid
.
treegrid
(
"pop"
,
preId
);
$datagrid
.
treegrid
(
"insert"
,{
before
:
vid
,
data
:
n2
});
}
function
bomMoveDown
()
{
var
n
=
$datagrid
.
treegrid
(
"getSelected"
);
if
(
n
==
null
){
gas
.
showWarning
(
"无法移动!"
);
return
;}
var
s
=
$datagrid
.
prev
().
find
(
'.datagrid-btable:eq(0) tr:eq(0)'
).
attr
(
'id'
),
id
=
s
.
substring
(
0
,
s
.
length
-
1
);
var
parentNode
=
$datagrid
.
treegrid
(
"getParent"
,
n
.
vid
);
var
index
=
parentNode
.
children
.
findIndex
(
function
(
item
)
{
return
item
.
vid
==
n
.
vid
});
if
(
index
==
parentNode
.
children
.
length
-
1
)
{
gas
.
showWarning
(
"无法移动!"
);
return
;}
HTTP
.
post
(
'bom/bom/movedown'
,{
id
:
n
.
id
},
function
(
result
)
{
if
(
result
.
success
){
expandedKeys
=
[];
setName
(
$datagrid
.
treegrid
(
"getData"
));
var
treeData
=
[...
expandedKeys
];
var
preId
=
parentNode
[
"children"
][
index
+
1
][
"vid"
];
var
n2
=
$datagrid
.
treegrid
(
"pop"
,
preId
);
$datagrid
.
treegrid
(
"insert"
,{
before
:
n
.
vid
,
data
:
n2
});
$datagrid
.
treegrid
(
"select"
,
n
.
vid
);
var
rows
=
findFormId
(
treeData
,
n
.
id
);
$
.
each
(
rows
,
function
(
i
,
row
)
{
if
(
row
.
vid
!=
n
.
vid
){
replaceMovedown
(
$div
,
row
.
vid
)
}
})
}
else
{
gas
.
showError
(
result
,
"操作失败!"
);
}
})
}
function
bomDelete
()
{
var
selectedNode
=
$datagrid
.
treegrid
(
"getSelected"
);
if
(
!
selectedNode
){
gas
.
showWarning
(
"请选择一条数据进行删除操作!"
);
return
false
}
if
(
selectedNode
.
bomid
==
"root"
){
gas
.
showWarning
(
"产品结构不允许删除!"
);
return
false
}
var
s
=
$datagrid
.
prev
().
find
(
'.datagrid-btable:eq(0) tr:eq(0)'
).
attr
(
'id'
),
id
=
s
.
substring
(
0
,
s
.
length
-
1
);
var
selectRow
=
$div
.
find
(
'#'
+
id
+
selectedNode
.
vid
);
var
cloestEl
=
selectRow
.
closest
(
".treegrid-tr-tree"
).
siblings
(
"tr[node-id]"
);
var
parentVid
=
null
;
if
(
cloestEl
){
parentVid
=
cloestEl
.
attr
(
"node-id"
);
}
gas
.
confirm
(
"是否删除该节点及其子结构"
,
function
(
r
)
{
if
(
r
){
gas
.
post
(
"bom/bom/delete"
,{
id
:
selectedNode
.
id
},
function
(
res
)
{
if
(
res
.
success
){
expandedKeys
=
[];
setName
(
$datagrid
.
treegrid
(
"getData"
));
var
treeData
=
[...
expandedKeys
];
var
rows
=
findFormWlid
(
treeData
,
selectedNode
.
wlid
);
$
.
each
(
rows
,
function
(
i
,
item
)
{
if
(
item
.
id
==
selectedNode
.
id
){
$datagrid
.
treegrid
(
"remove"
,
item
.
vid
);
}
});
if
(
parentVid
){
$datagrid
.
treegrid
(
"select"
,
parentVid
);
// $datagrid.treegrid("refresh",parentVid);
}
}
else
{
gas
.
showError
(
res
,
"删除失败!"
);
}
})
}
})
}
/*拖拽添加节点*/
function
appendNode
(
data
,
vid
,
target
){
expandedKeys
=
[];
setName
(
$datagrid
.
treegrid
(
"getData"
));
var
treeData
=
[...
expandedKeys
];
var
wlxxData
=
[];
gas
.
post
(
"bom/bom/query"
,{
bomid
:
data
.
wlid
},
function
(
res
)
{
if
(
res
.
success
){
wlxxData
=
[...
res
.
data
.
records
];
wlxxData
[
0
]
=
$
.
extend
(
wlxxData
[
0
],
data
);
var
rows
=
findFormWlid
(
treeData
,
data
.
bomid
);
var
oldTarget
=
findFormWlid
(
treeData
,
data
.
wlid
);
$
.
each
(
oldTarget
,
function
(
i
,
item
)
{
if
(
item
.
vid
!=
vid
){
$datagrid
.
treegrid
(
"remove"
,
item
.
vid
);
}
});
$
.
each
(
rows
,
function
(
i
,
item
)
{
if
(
item
.
vid
!=
target
.
vid
){
var
wlxxRoot
=
buildTree
(
wlxxData
,
data
.
bomid
);
$datagrid
.
treegrid
(
"append"
,{
parent
:
item
.
vid
,
data
:[...
wlxxRoot
]
});
$datagrid
.
treegrid
(
"refresh"
,
item
.
vid
);
}
});
$datagrid
.
treegrid
(
'enableDnd'
,
null
);
gas
.
post
(
"bom/bom/moveParent"
,{
id
:
data
.
id
,
pid
:
target
.
id
,
bomid
:
target
.
wlid
},
function
(
response
)
{
if
(
response
.
success
){
gas
.
showMessage
(
response
,
"操作成功!"
)
}
else
{
gas
.
showError
(
response
,
"操作失败!"
)
}
})
}
})
}
/*数据初始化*/
function
dataInit
(
ops
){
}
/*用户操作*/
function
run
(){
vidTotal
=
0
;
HTTP
.
post
(
"bom/bom/query"
,
DataBind
.
collectData
(
$div
),
function
(
res
)
{
if
(
res
.
success
){
var
rows
=
res
.
data
.
records
;
theDataPool
=
[];
var
data2
=
{
total
:
rows
.
length
,
"rows"
:
buildTree
(
rows
,
"root"
)};
$datagrid
.
treegrid
(
'loadData'
,
data2
);
}
else
{
gas
.
showError
(
res
,
"请求失败"
);
}
});
}
function
transDataChildren
(
a
,
idStr
,
pidStr
,
chindrenStr
){
var
r
=
[],
hash
=
{},
id
=
idStr
,
pid
=
pidStr
,
children
=
chindrenStr
,
i
=
0
,
j
=
0
,
len
=
a
.
length
;
for
(;
i
<
len
;
i
++
){
hash
[
a
[
i
][
id
]]
=
a
[
i
];
}
for
(;
j
<
len
;
j
++
){
var
aVal
=
a
[
j
],
hashVP
=
hash
[
aVal
[
pid
]];
if
(
hashVP
){
!
hashVP
[
children
]
&&
(
hashVP
[
children
]
=
[]);
hashVP
[
children
].
push
(
aVal
);
// hashVP["state"]="closed"
}
else
{
r
.
push
(
aVal
);
}
}
return
r
;
}
//递归
function
buildTree
(
data
,
bomid
){
var
list
=
findFormData
(
data
,
bomid
);
var
itemArr
=
[];
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
){
var
item
=
list
[
i
];
var
child
=
{};
vidTotal
++
;
if
(
item
.
wlid
==
"root"
){
item
[
"vid"
]
=
"root"
}
child
=
$
.
extend
({},
item
,{
vid
:
vidTotal
});
child
[
"children"
]
=
buildTree
(
data
,
item
.
wlid
);
$
.
each
(
child
[
"children"
],
function
(
a
,
b
)
{
b
[
"_parentId"
]
=
child
[
"vid"
]
});
itemArr
.
push
(
child
);
}
return
itemArr
}
function
findFormData
(
data
,
bomid
){
var
arry
=
[];
$
.
each
(
data
,
function
(
i
,
item
)
{
if
(
item
.
bomid
==
bomid
){
arry
.
push
(
item
)
}
});
return
arry
}
function
findFormWlid
(
data
,
wlid
){
var
arry
=
[];
$
.
each
(
data
,
function
(
i
,
item
)
{
if
(
item
.
wlid
==
wlid
){
arry
.
push
(
item
)
}
});
return
arry
}
function
findFormId
(
data
,
id
)
{
var
arry
=
[];
$
.
each
(
data
,
function
(
i
,
item
)
{
if
(
item
.
id
==
id
){
arry
.
push
(
item
)
}
});
return
arry
}
function
setName
(
datas
){
//遍历树 获取id数组
$
.
each
(
datas
,
function
(
i
,
item
)
{
expandedKeys
.
push
(
datas
[
i
])
if
(
datas
[
i
].
children
&&
datas
[
i
].
children
.
length
>
0
){
setName
(
datas
[
i
].
children
);
}
})
}
gas
.
load
(
paramInit
,
pageInit
,
dataInit
);
});
</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