Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-customization-system
/
system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bd6d3eb4
authored
Aug 24, 2021
by
jack
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
http://192.168.3.233:8090/micro-customization-system/system
2 parents
9acd1ca4
60ca16fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
511 deletions
src/views/vehicleTypeManage/vehicleAddUpadate.vue
src/views/vehicleTypeManage/vehicleAddUpadate.vue
deleted
100644 → 0
View file @
9acd1ca
<
template
>
<div
class=
"system-container"
>
<div
class=
"container"
>
<div
class=
"topform"
>
<rule-form
:ruleForm=
"addUpdateForm"
:rules=
"rules"
:ruleData=
"addUpdateData"
:labelWidth=
"'120px'"
ref=
"addUpdateForm"
>
<div
slot=
"select-type"
>
<el-select
v-model=
"addUpdateForm.initOrganize"
placeholder=
"请选择"
:disabled=
"this.$route.query.title == 'view' || this.$route.query.title=='edit'"
filterable
>
<el-option
v-for=
"i in tenantList"
:key=
"i.tenantId"
:label=
"i.departmentName"
:value=
"i.tenantId"
>
</el-option>
</el-select>
</div>
<!--
<div
slot=
"btns-type"
>
<el-button
type=
"primary"
round
@
click=
"checkAll"
>
全选
</el-button>
<el-button
round
@
click=
"reset"
>
重置
</el-button>
</div>
-->
</rule-form>
</div>
<div
class=
"treebox"
>
<!--
<span
class=
"el-icon-loading"
></span>
-->
<div
class=
"layer"
v-if=
"!showTree"
>
<i
class=
"el-icon-loading"
></i>
正在加载中...
</div>
<el-tree
v-if=
"showTree"
:data=
"treedata"
:default-expanded-keys=
"expandedKey"
:props=
"defaultProps"
show-checkbox
node-key=
"id"
ref=
"tree"
highlight-current
lazy
:load=
"loadNode"
>
</el-tree>
</div>
</div>
<div
class=
"pull-right"
>
<el-button
type=
"primary"
@
click=
"submitForm"
:loading=
"aloading"
v-if=
"!(setPageTitle == 'view')"
>
保存
</el-button>
<el-button
@
click=
"handCancle('addUpdateForm')"
>
取消
</el-button>
</div>
</div>
</
template
>
<
script
>
import
{
getTenantList
,
getMenuTree
,
addVehicleType
,
editVehicleType
,
GETVEHICLEINFO
,
}
from
"services/vehicletype"
;
export
default
{
name
:
"vehicleAddUpadate"
,
data
()
{
var
checkMenu
=
(
rule
,
value
,
callBack
)
=>
{
if
(
value
&&
value
.
length
==
0
)
{
return
callBack
(
new
Error
(
"请选择菜单列表"
));
}
else
{
return
callBack
();
}
};
return
{
addUpdateForm
:
{
name
:
""
,
initOrganize
:
""
,
enableStatus
:
true
,
// menuIdList: [],
},
addUpdateData
:
[
{
label
:
"车型库名称:"
,
prop
:
"name"
,
type
:
"input"
,
maxlength
:
50
,
disabled
:
this
.
$route
.
query
.
title
==
"view"
,
},
{
label
:
"组织:"
,
prop
:
"initOrganize"
,
type
:
"customize"
,
slotName
:
"select-type"
,
},
{
label
:
"状态:"
,
prop
:
"enableStatus"
,
type
:
"switch"
},
// { type: "customize", slotName: "btns-type" },
],
// {
// prop: "menuIdList",
// type: "customize",
// slotName: "menu-list",
// },
rules
:
{
name
:
[{
required
:
true
,
message
:
"请输入名称"
,
trigger
:
"blur"
}],
initOrganize
:
[
{
required
:
true
,
message
:
"请选择组织"
,
trigger
:
"change"
},
],
enableStatus
:
[{
required
:
true
}],
// menuIdList: [{ required: true, validator: checkMenu, trigger: "blur" }],
},
treedata
:
[],
treeLeafData
:
[],
tenantList
:
[],
defaultProps
:
{
children
:
"childs"
,
label
:
"name"
,
isLeaf
:
"leaf"
,
},
loading
:
true
,
newArr
:
[],
showTree
:
false
,
checkList
:
[],
aloading
:
false
,
expandedKey
:
[],
tenantListElement
:
{},
type
:
1
,
};
},
computed
:
{
setPageTitle
()
{
return
this
.
$route
.
query
.
title
==
"add"
?
"add"
:
this
.
$route
.
query
.
title
==
"edit"
?
"edit"
:
"view"
;
},
},
created
()
{
var
title
=
this
.
$route
.
query
.
title
;
var
id
=
this
.
$route
.
query
.
id
;
if
(
title
==
"add"
)
{
this
.
type
=
1
;
//后台要区分新增,和编辑,1:新增,2:编辑
}
else
if
(
title
==
"edit"
)
{
this
.
type
=
2
;
this
.
editVehicleType
({
tenantId
:
id
});
// this.getInfo({ tenantId: id });
}
else
if
(
title
==
"view"
)
{
this
.
rules
=
{};
this
.
editVehicleType
({
tenantId
:
id
});
// this.getInfo({ tenantId: id });
}
},
mounted
()
{
let
_this
=
this
;
let
o
=
_this
.
$route
.
query
;
let
n
=
_this
.
$store
.
getters
.
getTreeData
;
//判断
this
.
getTenantList
();
setTimeout
(
function
()
{
// let n = localStorage.getItem("carTree")
// ? JSON.parse(localStorage.getItem("carTree"))
// : [];
if
(
n
&&
n
.
length
>
0
)
{
// console.log(n,"浏览器存储");
//_this.flatData(n);
_this
.
mainWorker
(
n
).
then
((
res
)
=>
{
_this
.
showTree
=
true
;
_this
.
loading
=
false
;
if
(
o
.
id
)
{
_this
.
getInfo
(
o
.
id
);
}
});
return
false
;
}
_this
.
getMenuTree
();
},
10
);
},
activated
()
{
let
_this
=
this
;
let
o
=
_this
.
$route
.
query
;
if
(
o
.
id
)
{
this
.
getInfo
(
o
.
id
);
}
},
methods
:
{
// 获取页面详情的接口
editVehicleType
(
params
)
{
editVehicleType
(
params
).
then
((
res
)
=>
{
if
(
res
.
code
==
"200"
)
{
// console.log(res.data, "编辑、查看数据");
this
.
addUpdateForm
.
name
=
res
.
data
.
name
||
"暂无"
;
this
.
addUpdateForm
.
initOrganize
=
res
.
data
.
tenantId
;
this
.
addUpdateForm
.
enableStatus
=
res
.
data
.
enableStatus
==
2
?
false
:
true
;
// var _this = this;
// setTimeout(() => {
// _this.$refs.tree.setCheckedKeys(res.data.typeIds);
// }, 10000);
}
});
},
// 获取租户列表
getTenantList
(
params
)
{
getTenantList
(
params
).
then
((
res
)
=>
{
this
.
tenantList
=
res
.
data
||
[];
});
},
// 获取菜单权限列表
getMenuTree
()
{
let
_this
=
this
;
let
oParams
=
{};
oParams
.
full
=
true
;
getMenuTree
(
oParams
).
then
((
res
)
=>
{
localStorage
.
setItem
(
"carTree"
,
JSON
.
stringify
(
res
.
data
||
[]));
// 分线程处理数据
_this
.
mainWorker
(
res
.
data
).
then
((
e
)
=>
{
let
_obj
=
e
.
data
;
_this
.
$store
.
commit
(
"updateVehicleTree"
,
_obj
.
data
);
_this
.
showTree
=
true
;
_this
.
loading
=
false
;
});
this
.
showTree
=
true
;
this
.
loading
=
false
;
});
},
// 获取选中菜单数组
getCheckedKeys
()
{
//this.addUpdateForm.menuIdList = this.$refs.tree.getCheckedKeys();
},
//重置
reset
()
{
// this.$refs.tree.setCheckedKeys([]);
// this.getCheckedKeys();
},
// 异步加载树数据
loadNode
(
node
,
resolve
)
{
let
arr
=
[];
let
id
=
node
.
key
;
// console.log(node, "选中的node");
if
(
node
.
level
===
0
)
{
id
=
0
;
}
// 动态加载第四层数据
// if (node.level === 3) {
// let params = { seriesId: node.key };
// //请求第四层数据
// geMenuTreeLeaf(params).then((res) => {
// if (res.code != 200) {
// this.$message({
// type: "error",
// message: res.message,
// });
// return false;
// }
// console.log(res.data, "good");
// let forthList = res.data.map((item) => {
// return {
// ...item,
// id: item.carTypeId,
// };
// });
// //渲染第四层数据
// resolve(forthList);
// });
// }
arr
=
this
.
newArr
.
filter
((
item
)
=>
{
return
item
.
pid
==
id
;
});
// console.log(arr, "过滤之后");
resolve
(
arr
);
},
// 数据扁平化
flatData
(
arr
,
id
,
index
)
{
let
n
=
this
.
newArr
;
let
_this
=
this
;
let
i
=
index
||
0
;
(
arr
||
[]).
forEach
((
item
)
=>
{
item
.
pid
=
id
||
0
;
item
.
level
=
i
;
if
(
item
.
level
==
3
)
{
item
.
leaf
=
true
;
}
n
.
push
(
item
);
if
(
!
id
)
{
_this
.
treedata
.
push
(
item
);
}
item
.
childs
&&
item
.
childs
.
length
>
0
?
_this
.
flatData
(
item
.
childs
,
item
.
id
,
i
+
1
)
:
""
;
//item.childs = ""; //如果扁平化后的数组需要显示父子层级,可以把这一项删除
});
},
//保存按钮,提交当前表单
submitForm
()
{
let
_this
=
this
;
//this.getCheckedKeys();
_this
.
$refs
.
addUpdateForm
.
$children
[
0
].
validate
((
valid
)
=>
{
if
(
!
valid
)
{
return
false
;
}
_this
.
checkList
=
[];
let
_list
=
_this
.
$refs
.
tree
.
getCheckedNodes
();
_this
.
getChilds
(
_list
);
console
.
log
(
_this
.
checkList
);
if
(
_this
.
checkList
.
length
<=
0
)
{
_this
.
$message
.
warning
(
"菜单不能为空"
);
return
false
;
}
let
params
=
{
name
:
_this
.
addUpdateForm
.
name
,
};
this
.
tenantListElement
=
this
.
tenantList
.
find
(
(
item
)
=>
item
.
tenantId
==
this
.
addUpdateForm
.
initOrganize
);
params
.
from
=
this
.
type
;
params
.
tenantId
=
Number
(
_this
.
addUpdateForm
.
initOrganize
);
params
.
tenantName
=
this
.
tenantListElement
.
departmentName
;
params
.
enableStatus
=
_this
.
addUpdateForm
.
enableStatus
?
1
:
2
;
params
.
typeIds
=
_this
.
checkList
;
// 保存车型库
_this
.
aloading
=
true
;
addVehicleType
(
params
)
.
then
((
res
)
=>
{
_this
.
aloading
=
false
;
if
(
res
.
code
!=
200
)
{
_this
.
$message
.
error
(
res
.
message
||
res
.
msg
);
return
false
;
}
_this
.
$message
({
message
:
"提交成功"
,
type
:
"success"
,
});
_this
.
goBack
();
})
.
catch
((
error
)
=>
{
_this
.
aloading
=
false
;
});
});
},
// 取消保存
handCancle
(
formName
)
{
console
.
log
(
"66"
);
this
.
goBack
();
},
// 获取所有的子节点数据
getChilds
(
arr
)
{
if
(
!
arr
||
arr
.
length
<=
0
)
{
return
false
;
}
let
list
=
this
.
checkList
;
arr
.
map
((
k
)
=>
{
if
(
k
.
childs
&&
k
.
childs
.
length
>
0
)
{
this
.
getChilds
(
k
.
childs
);
}
else
{
list
.
push
(
k
.
id
);
}
});
},
// 返回上一页面
goBack
()
{
this
.
$refs
.
addUpdateForm
.
$children
[
0
].
resetFields
();
this
.
$router
.
go
(
-
1
);
this
.
$refs
.
tree
.
setCheckedKeys
([]);
},
// 获取车型库详情
getInfo
(
id
)
{
let
_this
=
this
;
let
oParams
=
{
tenantId
:
id
};
GETVEHICLEINFO
(
oParams
).
then
((
res
)
=>
{
if
(
res
.
code
!=
200
)
{
return
false
;
}
let
o
=
res
.
data
||
{};
let
typeList
=
o
.
typeIds
||
[];
let
_models
=
[];
//子节点
let
_brand
=
[];
// 品牌
let
_subBrand
=
[];
// 子品牌
let
_series
=
[];
// 车系
let
list
=
this
.
newArr
;
let
_earr
=
[];
// 默认展开的节点
// 半选数组
let
_half
=
[];
// 全选数组
let
_check
=
[];
typeList
.
map
((
k
)
=>
{
let
m
,
b
,
f
;
//寻找当前元素
let
n
=
list
.
find
((
j
)
=>
j
.
id
==
k
&&
j
.
level
==
3
);
// 找第三级
if
(
n
)
{
m
=
list
.
find
((
j
)
=>
j
.
id
==
n
.
pid
&&
j
.
level
==
2
);
//_series.push(m);
_earr
.
push
(
m
.
id
);
}
// 找第二级
if
(
m
)
{
b
=
list
.
find
((
j
)
=>
j
.
id
==
m
.
pid
&&
j
.
level
==
1
);
//_subBrand.push(b);
_earr
.
push
(
b
.
id
);
}
// 找第一级
if
(
b
)
{
f
=
list
.
find
((
j
)
=>
{
return
j
.
id
==
b
.
pid
&&
j
.
level
==
0
;
});
let
_idx
=
_brand
.
findIndex
((
v
)
=>
v
.
id
==
f
.
id
);
if
(
_idx
<
0
)
{
_brand
.
push
(
f
);
_earr
.
push
(
f
.
id
);
}
}
});
_this
.
expandedKey
=
_earr
;
_this
.
$refs
.
tree
.
setCheckedKeys
(
typeList
);
});
},
// 创建分线程
createWorker
()
{
let
myWorker
=
function
()
{
let
that
=
this
;
let
_tree
=
[];
let
_allTree
=
[];
that
.
addEventListener
(
"message"
,
function
(
e
)
{
if
(
e
.
data
)
{
flatData
(
e
.
data
);
that
.
postMessage
({
tree
:
_tree
,
data
:
_allTree
});
}
});
// 数据扁平化
let
flatData
=
function
(
arr
,
id
,
index
)
{
let
n
=
_allTree
;
let
i
=
index
||
0
;
(
arr
||
[]).
forEach
((
item
)
=>
{
item
.
pid
=
id
||
0
;
item
.
level
=
i
;
n
.
push
(
item
);
if
(
!
id
)
{
_tree
.
push
(
item
);
}
item
.
childs
&&
item
.
childs
.
length
>
0
?
flatData
(
item
.
childs
,
item
.
id
,
i
+
1
)
:
""
;
//item.childs = ""; //如果扁平化后的数组需要显示父子层级,可以把这一项删除
});
};
};
let
workerData
=
new
Blob
([
"("
+
myWorker
.
toString
()
+
")()"
],
{
type
:
"text/javascript"
,
});
return
workerData
;
},
// 主线程
mainWorker
(
data
)
{
let
_this
=
this
;
return
new
Promise
((
resolve
,
reject
)
=>
{
let
_workerJs
=
_this
.
createWorker
();
let
webWorker
=
new
Worker
(
window
.
URL
.
createObjectURL
(
_workerJs
));
webWorker
.
postMessage
(
data
);
webWorker
.
onmessage
=
function
(
e
)
{
let
_obj
=
e
.
data
;
_this
.
treedata
=
_obj
.
tree
;
_this
.
newArr
=
_obj
.
data
;
resolve
(
_obj
);
};
// 监听文件失败
webWorker
.
onmessageerror
=
function
(
e
)
{
reject
(
e
);
};
});
},
},
};
</
script
>
<
style
lang=
"scss"
scoped
>
.topform
{
width
:
40%
;
}
.treebox
{
height
:
385px
;
overflow-y
:
scroll
;
position
:
relative
;
.layer
{
width
:
100%
;
height
:
385px
;
text-align
:
center
;
line-height
:
385px
;
position
:
absolute
;
z-index
:
10
;
}
}
.pull-right
{
margin-top
:
20px
;
}
</
style
>
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment