Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
account
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 1e567623
authored
Apr 11, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加省市区组件
1 parent
3529097f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
254 additions
and
47 deletions
html/merchant/add.html
js/common.js
html/merchant/add.html
View file @
1e56762
...
...
@@ -219,6 +219,21 @@
left
:
340px
;
top
:
0
;
}
.w-70
{
width
:
150px
!important
;
}
.address
{
display
:
inline-block
;
width
:
calc
(
100%
-
120px
);
}
.select-address
{
width
:
calc
(
100%
-
600px
)
!important
;
margin-left
:
20px
;
}
</style>
<title>
商户编辑
</title>
</head>
...
...
@@ -321,9 +336,23 @@
</div> -->
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
商户地址:
</label>
<div
class=
"layui-input-inline w-70"
>
<input
style=
"color: #333333 !important"
name=
"merchantAddress"
disabled
class=
"layui-input layui-btn-disabled"
id=
"addrEl"
placeholder=
"请选择商户地址"
/>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-bg-white padding10 padding-l20 layui-form"
>
<div
class=
"layui-input-inline margin-l10 w-70"
>
<div
class=
"searchBtn"
>
<select
name=
"select4"
id=
"startp"
lay-search
></select>
</div>
</div>
<div
class=
"layui-input-inline w-70"
style=
"margin-left: 20px;"
>
<div
class=
"searchBtn"
>
<select
name=
"select4"
id=
"startc"
lay-search
></select>
</div>
</div>
</div>
</div>
<div
class=
"layui-input-inline select-address"
>
<input
style=
"color: #333333 !important;"
name=
"merchantAddress"
disabled
class=
"layui-input layui-btn-disabled address"
id=
"addrEl"
placeholder=
"请选择商户地址"
/>
<!-- <div class="m-t-10" id="addrEl">请选择商户地址</div> -->
<button
type=
"button"
class=
"layui-btn"
data-type=
"handleSelectAddr"
style=
"margin-left: 20px"
>
选择地址
</button>
...
...
@@ -548,7 +577,8 @@
<script
src=
"/js/load.js"
></script>
<script
src=
"/js/validator.js"
></script>
<script>
layui
.
use
([
'gtree'
,
'request'
,
'helper'
,
'layer'
,
'laydate'
,
'element'
,
'xmSelect'
,
'laytpl'
,
'validator'
,
'util'
],
function
()
{
layui
.
use
([
'gtree'
,
'request'
,
'helper'
,
'layer'
,
'laydate'
,
'element'
,
'xmSelect'
,
'laytpl'
,
'validator'
,
'util'
,
'common'
],
function
()
{
var
com
=
layui
.
common
var
tree
=
layui
.
gtree
var
request
=
layui
.
request
var
form
=
layui
.
form
...
...
@@ -605,6 +635,57 @@
accountTypeList
:
[]
}
var
provinceInfoList
=
[]
var
cityInfo
=
[]
// 省市区
getProvinceList
()
com
.
getSelect
({
id
:
'startp'
,
name
:
'provinceName'
,
url
:
'/area/list'
,
value
:
'provinceId'
,
text
:
'provinceName'
,
param
:
{
provinceName
:
'广东'
,
cityName
:
'深圳'
},
select
:
function
(
data
)
{
const
{
value
}
=
data
if
(
value
)
{
var
province
=
provinceInfoList
.
find
(
item
=>
item
.
provinceId
==
value
)
cityInfo
=
province
.
cityInfoList
console
.
log
(
province
)
merchantForm
.
provinceCode
=
province
.
provinceId
merchantForm
.
provinceName
=
province
.
provinceName
}
else
{
cityInfo
=
[]
merchantForm
.
provinceCode
=
''
merchantForm
.
provinceName
=
''
}
merchantForm
.
cityCode
=
''
merchantForm
.
cityName
=
''
com
.
getSelect
({
id
:
'startc'
,
name
:
'cityName'
,
url
:
'/area/list'
,
value
:
'cityId'
,
text
:
'cityName'
,
data
:
cityInfo
,
link
:
'startp'
,
select
:
function
(
data
)
{
const
{
value
}
=
data
if
(
value
)
{
var
city
=
cityInfo
.
find
(
item
=>
item
.
cityId
==
value
)
merchantForm
.
cityCode
=
city
.
cityId
merchantForm
.
cityName
=
city
.
cityName
}
else
{
merchantForm
.
cityCode
=
''
merchantForm
.
cityName
=
''
}
}
})
console
.
log
(
merchantForm
)
}
})
// 禁用所有input框的回车事件
var
inputs
=
document
.
getElementsByTagName
(
'input'
)
for
(
let
i
=
0
;
i
<
inputs
.
length
;
i
++
)
{
...
...
@@ -777,7 +858,7 @@
'merchantLoginPassword'
,
'merchantAccountLevel'
,
'effectiveTime'
,
'merchantModel'
,
'merchantModel'
]
if
(
formData
.
isloginName
==
'on'
)
{
params
.
isloginName
=
1
...
...
@@ -862,7 +943,7 @@
let
getCheckedNodes
=
treeObj
.
getCheckedNodes
(
true
)
const
getCheckedKeys
=
treeObj
.
getCheckedNodes
(
true
).
map
(
item
=>
item
.
id
)
console
.
log
(
getCheckedKeys
)
getCheckedNodes
=
getCheckedNodes
.
filter
(
item
=>
item
.
children
)
getCheckedNodes
=
getCheckedNodes
.
filter
(
item
=>
item
.
children
)
merchantForm
.
merchantBrandList
=
getCheckedNodes
.
map
(
car
=>
{
let
merchantBrandId
=
[]
car
.
children
.
forEach
(
item
=>
{
...
...
@@ -902,40 +983,40 @@
params
.
status
=
1
}
console
.
log
(
params
)
request
(
params
,
function
(
res
)
{
if
(
res
.
code
==
'0'
)
{
if
(
editLevel
==
3
)
{
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
go
(
'merchant'
,
'index'
)
}
else
{
if
(
!
merchantId
)
{
merchantId
=
res
.
data
}
merchantForm
.
merchantAccountLevel
=
parseInt
(
merchantForm
.
merchantAccountLevel
)
getMerchantApi
(
merchantId
,
function
(
respone
)
{
form
.
val
(
'merchantForm'
,
respone
.
data
)
merchantForm
=
respone
.
data
if
(
merchantForm
.
merchantAddress
)
{
$
(
'#addrEl'
).
text
(
merchantForm
.
merchantAddress
)
}
accountTypeVisible
=
true
var
el
=
$
(
'#accountTypeEl'
)
el
.
empty
()
recoveryFile
()
getAccountType
()
baseIsShow
(
false
)
treeIsShow
(
true
)
if
(
isFreshSecond
)
{
getById
()
isFreshSecond
=
false
}
})
}
}
})
//
request(params, function (res) {
//
if (res.code == '0') {
//
if (editLevel == 3) {
//
layer.msg('操作成功', {
//
icon: 1
//
})
//
go('merchant', 'index')
//
} else {
//
if (!merchantId) {
//
merchantId = res.data
//
}
//
merchantForm.merchantAccountLevel = parseInt(merchantForm.merchantAccountLevel)
//
getMerchantApi(merchantId, function (respone) {
//
form.val('merchantForm', respone.data)
//
merchantForm = respone.data
//
if (merchantForm.merchantAddress) {
//
$('#addrEl').text(merchantForm.merchantAddress)
//
}
//
accountTypeVisible = true
//
var el = $('#accountTypeEl')
//
el.empty()
//
recoveryFile()
//
getAccountType()
//
baseIsShow(false)
//
treeIsShow(true)
//
if (isFreshSecond) {
//
getById()
//
isFreshSecond = false
//
}
//
})
//
}
//
}
//
})
return
false
})
...
...
@@ -1018,14 +1099,14 @@
var
checkAll
=
false
var
checkCarBrand
=
$
(
'#checkCarBrand'
)
// 主营品牌全选
checkCarBrand
.
on
(
'click'
,
function
()
{
checkCarBrand
.
on
(
'click'
,
function
()
{
checkAll
=
!
checkAll
treeObj
.
checkAllNodes
(
checkAll
)
if
(
checkAll
)
{
checkCarBrand
.
html
(
'全不选'
)
}
else
{
checkCarBrand
.
html
(
'全选'
)
}
if
(
checkAll
)
{
checkCarBrand
.
html
(
'全不选'
)
}
else
{
checkCarBrand
.
html
(
'全选'
)
}
})
$
(
'.layui-btn'
).
on
(
'click'
,
function
()
{
...
...
@@ -1323,7 +1404,7 @@
var
checkedList
=
[]
if
(
editLevel
==
3
&&
merchantForm
.
merchantBrandMain
)
{
// checkedList = merchantForm.merchantBrandMain.split(',')
checkedList
=
merchantForm
.
merchantBrandMain
.
replaceAll
(
';'
,
','
).
split
(
','
)
checkedList
=
merchantForm
.
merchantBrandMain
.
replaceAll
(
';'
,
','
).
split
(
','
)
$
.
each
(
checkedList
,
function
(
index
,
item
)
{
checkedList
[
index
]
=
parseInt
(
item
)
})
...
...
@@ -1504,6 +1585,20 @@
})
}
// 省市区
function
getProvinceList
()
{
var
ajax
=
layui
.
$
.
ajax
ajax
({
// url: 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/glsx-oss-account-config',
url
:
'http://oss-config.dev.glsx.com.cn/mock/617ba1df1072f92988f05a14/account/provinceList'
,
async
:
false
,
success
:
function
(
res
)
{
console
.
log
(
res
)
provinceInfoList
=
res
.
provinceInfoList
}
})
}
// 数 - start
var
check_arr
=
[]
var
requestList
=
[]
...
...
js/common.js
0 → 100644
View file @
1e56762
/*
* @Description: 省市组件
* @Author: huyue
* @Date: 2022-04-08 17:00:25
* @LastEditors: huyue
* @LastEditTime: 2022-04-11 17:01:39
*/
layui
.
define
([
'form'
,
'laydate'
,
'carousel'
,
'util'
],
function
(
exports
)
{
const
{
form
,
laydate
,
carousel
,
util
,
$
,
cache
}
=
layui
;
exports
(
'common'
,
{
/**
* 生成下拉选
* @param config:参数
* id:dom的id
* string:单个dom
* Array:多个dom
* url:获取地址
* value:<option>的value名
* text:<option>text
* getValue:自定义传输值
* getText:自定义显示文本
* param:url请求的额外参数
* initData:默认option
* link:需要联动的下拉选的dom id
* select:选中事件
* @return <option/>文本
*/
getSelect
(
config
)
{
console
.
log
(
config
)
let
f
=
{
id
:
undefined
,
url
:
undefined
,
name
:
''
,
value
:
'value'
,
text
:
'text'
,
getValue
:
function
(
v
)
{
return
v
[
this
.
value
]
},
getText
:
function
(
t
)
{
return
t
[
this
.
text
]
},
param
:
null
,
initData
:
[{
cityId
:
''
,
cityName
:
'请选择'
}],
link
:
false
,
select
:
false
,
data
:
[],
...
config
},
that
=
this
,
isArray
=
Array
.
isArray
(
f
.
id
);
if
(
isArray
)
{
f
.
id
.
forEach
(
id
=>
{
$
(
"#"
+
id
).
attr
(
"lay-filter"
,
'commonSelect'
+
id
);
$
(
"#"
+
id
).
attr
(
"name"
,
f
.
name
)
})
}
else
{
$
(
"#"
+
f
.
id
).
attr
(
"lay-filter"
,
'commonSelect'
+
f
.
id
);
$
(
"#"
+
f
.
id
).
attr
(
"name"
,
f
.
name
)
}
getProvinceList
()
//绑定选中事件
if
(
f
.
select
)
{
if
(
isArray
)
{
f
.
id
.
forEach
(
id
=>
{
form
.
on
(
'select(commonSelect'
+
id
+
')'
,
function
(
data
)
{
f
.
select
(
data
);
})
})
}
else
{
form
.
on
(
'select(commonSelect'
+
f
.
id
+
')'
,
function
(
data
)
{
f
.
select
(
data
);
})
}
}
//生成option
function
getOptions
()
{
if
(
!
f
.
link
)
{
f
.
data
=
that
.
provinceInfoList
}
console
.
log
(
f
.
data
)
let
h
=
''
;
$
.
each
(
f
.
initData
,
function
(
i
,
d
)
{
h
+=
'<option value="'
+
d
.
cityId
+
'">'
+
d
.
cityName
+
'</option>'
;
});
$
.
each
(
f
.
data
,
function
(
i
,
d
)
{
h
+=
'<option value="'
+
f
.
getValue
(
d
)
+
'">'
+
f
.
getText
(
d
)
+
'</option>'
;
});
if
(
isArray
)
{
f
.
id
.
forEach
(
d
=>
{
let
a
=
$
(
"#"
+
d
);
a
.
empty
();
a
.
append
(
h
);
})
}
else
{
let
a
=
$
(
"#"
+
f
.
id
);
a
.
empty
();
a
.
append
(
h
);
}
form
.
render
(
'select'
);
return
h
;
}
function
getProvinceList
()
{
var
ajax
=
layui
.
$
.
ajax
ajax
({
// url: 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/glsx-oss-account-config',
url
:
'http://oss-config.dev.glsx.com.cn/mock/617ba1df1072f92988f05a14/account/provinceList'
,
async
:
false
,
success
:
function
(
res
)
{
console
.
log
(
res
)
that
.
provinceInfoList
=
res
.
provinceInfoList
}
})
}
return
getOptions
();
}
})
})
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