Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
cb5faccc
ShopXO
项目概览
starsw001
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cb5faccc
编写于
7月 21, 2019
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
商品规格新增扩展数据
上级
30601d42
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
418 addition
and
139 deletion
+418
-139
application/admin/controller/Goods.php
application/admin/controller/Goods.php
+4
-0
application/admin/view/default/goods/save_info.html
application/admin/view/default/goods/save_info.html
+147
-4
application/admin/view/default/payment/save_info.html
application/admin/view/default/payment/save_info.html
+1
-1
application/service/GoodsService.php
application/service/GoodsService.php
+60
-0
public/static/admin/default/css/goods.css
public/static/admin/default/css/goods.css
+3
-0
public/static/admin/default/js/answer.js
public/static/admin/default/js/answer.js
+16
-13
public/static/admin/default/js/goods.js
public/static/admin/default/js/goods.js
+31
-1
public/static/admin/default/js/goodscomments.js
public/static/admin/default/js/goodscomments.js
+3
-3
public/static/admin/default/js/link.js
public/static/admin/default/js/link.js
+16
-13
public/static/admin/default/js/navigation.js
public/static/admin/default/js/navigation.js
+23
-20
public/static/admin/default/js/orderaftersale.js
public/static/admin/default/js/orderaftersale.js
+4
-4
public/static/admin/default/js/power.js
public/static/admin/default/js/power.js
+68
-65
public/static/common/js/common.js
public/static/common/js/common.js
+42
-15
未找到文件。
application/admin/controller/Goods.php
浏览文件 @
cb5faccc
...
...
@@ -140,6 +140,10 @@ class Goods extends Common
// 品牌分类
$this
->
assign
(
'brand_list'
,
BrandService
::
CategoryBrand
());
// 规格扩展数据
$goods_spec_extends
=
GoodsService
::
GoodsSpecificationsExtends
();
$this
->
assign
(
'goods_specifications_extends'
,
$goods_spec_extends
[
'data'
]);
// 参数
$this
->
assign
(
'params'
,
$params
);
...
...
application/admin/view/default/goods/save_info.html
浏览文件 @
cb5faccc
...
...
@@ -181,12 +181,13 @@
<th>
规格编码
</th>
<th>
条形码
</th>
<th>
原价(元)
</th>
<th
class=
"extend-btn"
>
扩展
</th>
<th
class=
"operation-btn"
>
操作
</th>
</tr>
</thead>
<tbody>
{{if empty($specifications['value'])}}
<tr>
<tr
class=
"line-0"
data-line-tag=
".line-0"
>
<td
class=
"value-start"
>
<input
type=
"text"
name=
"specifications_price[]"
placeholder=
"价格"
class=
"am-radius"
pattern=
"^([0-9]{1}\d{0,6})(\.\d{1,2})?$"
data-validation-message=
"请填写有效的销售金额"
required
/>
</td>
...
...
@@ -203,7 +204,11 @@
<input
type=
"text"
name=
"specifications_barcode[]"
placeholder=
"条形码"
class=
"am-radius"
maxlength=
"80"
data-validation-message=
"条形码最多80个字符"
/>
</td>
<td>
<input
type=
"text"
name=
"specifications_original_price[]"
placeholder=
"原价"
class=
"am-radius"
pattern=
"^([0-9]{1}\d{0,6})(\.\d{1,2})?$"
data-validation-message=
"请填写有效的销售金额"
/>
<input
type=
"text"
name=
"specifications_original_price[]"
placeholder=
"原价"
class=
"am-radius"
pattern=
"^([0-9]{1}\d{0,6})(\.\d{1,2})?$"
data-validation-message=
"请填写有效的原价"
/>
</td>
<td>
<input
type=
"hidden"
name=
"specifications_extends[]"
value=
""
class=
"line-extend-input"
/>
<span
class=
"fs-12 cr-blue c-p line-extend-btn"
>
编辑
</span>
</td>
<td>
<!--operation-->
...
...
@@ -213,7 +218,7 @@
{{if !empty($specifications['value'])}}
{{foreach $specifications.value as $line_k=>$line_v}}
<tr
{{
if
$
line_k
gt
0}}
class=
"line-not-first"
{{/
if
}}
>
<tr
class=
"line-{{$line_k}} {{if $line_k gt 0}} line-not-first{{/if}}"
data-line-tag=
".line-{{$line_k}}"
>
{{foreach $line_v as $v}}
{{if isset($v['data_type'])}}
{{switch v.data_type}}
...
...
@@ -240,7 +245,11 @@
<input
type=
"text"
name=
"specifications_barcode[]"
placeholder=
"条形码"
class=
"am-radius"
maxlength=
"80"
data-validation-message=
"条形码最多80个字符"
value=
"{{$v.data.barcode}}"
/>
</td>
<td>
<input
type=
"text"
name=
"specifications_original_price[]"
placeholder=
"原价"
class=
"am-radius"
pattern=
"^([0-9]{1}\d{0,6})(\.\d{1,2})?$"
data-validation-message=
"请填写有效的销售金额"
value=
"{{if $v['data']['original_price'] gt 0}}{{$v.data.original_price}}{{/if}}"
/>
<input
type=
"text"
name=
"specifications_original_price[]"
placeholder=
"原价"
class=
"am-radius"
pattern=
"^([0-9]{1}\d{0,6})(\.\d{1,2})?$"
data-validation-message=
"请填写有效的原价"
value=
"{{if $v['data']['original_price'] gt 0}}{{$v.data.original_price}}{{/if}}"
/>
</td>
<td>
<input
type=
"hidden"
name=
"specifications_extends[]"
value=
""
class=
"line-extend-input"
/>
<span
class=
"fs-12 cr-blue c-p line-extend-btn"
>
编辑
</span>
</td>
<td>
{{if $line_k gt 0}}
...
...
@@ -384,12 +393,146 @@
</div>
<!-- right content end -->
<!-- 规格扩展数据弹层 -->
<div
class=
"am-popup"
id=
"specifications-extends-popup"
>
<div
class=
"am-popup-inner"
>
<div
class=
"am-popup-hd"
>
<h4
class=
"am-popup-title"
>
规格扩展数据
</h4>
<span
data-am-modal-close
class=
"am-close"
>
×
</span>
</div>
<div
class=
"am-popup-bd"
>
<form
class=
"am-form form-validation-specifications-extends view-save"
request-type=
"sync"
request-value=
"SpecificationsExtendsBack"
>
{{if !empty($goods_specifications_extends) and is_array($goods_specifications_extends)}}
{{foreach $goods_specifications_extends as $v}}
<div
class=
"am-alert am-alert-secondary"
>
<label
class=
"am-text-sm"
>
{{$v.name}}
</label>
{{if !empty($v['desc'])}}
<span
class=
"am-text-xs am-text-warning am-margin-left-xs"
>
{{$v.desc}}
</span>
{{/if}}
{{if !empty($v['element'])}}
{{foreach $v.element as $element}}
<div
class=
"am-form-group"
>
<label
class=
"block"
>
{{$element.title}}{{if !empty($element['desc'])}}
<span
class=
"am-form-group-label-tips"
>
{{$element.desc}}
</span>
{{/if}}
</label>
{{switch element.element}}
{{case input}}
{{if in_array($element['type'], ['radio', 'checkbox']) and !empty($element['element_data']) and is_array($element['element_data'])}}
{{foreach $element.element_data as $element_data_key=>$element_data}}
<label
class=
"{{if isset($element['is_block']) and $element['is_block'] eq 1}}am-{{$element.type}}{{else /}}am-{{$element.type}}-inline{{/if}}"
>
<input
type=
"{{$element.type}}"
name=
"{{$element.name}}"
value=
"{{$element_data.value}}"
{{
if
isset
($
data
['
config
'][$
element
['
name
']])
and
in_array
($
element_data
['
value
'],
explode
(',',
$
data
['
config
'][$
element
['
name
']]))}}
checked
{{/
if
}}
{{
if
isset
($
element
['
minchecked
'])
and
$
element
['
type
']
eq
'
checkbox
'}}
minchecked=
"{{$element.minchecked}}"
{{/
if
}}
{{
if
isset
($
element
['
maxchecked
'])
and
$
element
['
type
']
eq
'
checkbox
'}}
maxchecked=
"{{$element.maxchecked}}"
{{/
if
}}
{{
if
isset
($
element
['
message
'])}}
data-validation-message=
"{{$element.message}}"
{{/
if
}}
{{
if
$
element_data_key
eq
0
and
isset
($
element
['
is_required
'])
and
$
element
['
is_required
']
eq
1}}
required
{{/
if
}}
data-am-ucheck
/>
{{$element_data.name}}
</label>
{{/foreach}}
{{else /}}
<input
class=
"am-radius"
type=
"{{$element.type}}"
name=
"{{$element.name}}"
value=
"{{if isset($data['config'][$element['name']])}}{{$data['config'][$element['name']]}}{{else /}}{{if isset($element['default'])}}{{$element.default}}{{/if}}{{/if}}"
{{
if
isset
($
element
['
placeholder
'])}}
placeholder=
"{{$element.placeholder}}"
{{/
if
}}
{{
if
isset
($
element
['
message
'])}}
data-validation-message=
"{{$element.message}}"
{{/
if
}}
{{
if
isset
($
element
['
is_required
'])
and
$
element
['
is_required
']
eq
1}}
required
{{/
if
}}
/>
{{/if}}
{{/case}}
{{case select}}
{{if !empty($element['element_data']) and is_array($element['element_data'])}}
<select
class=
"chosen-select am-radius"
name=
"{{$element.name}}"
{{
if
isset
($
element
['
message
'])}}
data-validation-message=
"{{$element.message}}"
{{/
if
}}
{{
if
!
empty
($
element
['
placeholder
'])}}
data-placeholder=
"{{$element.placeholder}}"
{{/
if
}}
{{
if
isset
($
element
['
is_multiple
'])
and
$
element
['
is_multiple
']
eq
1}}
multiple
{{
if
isset
($
element
['
minchecked
'])}}
minchecked=
"{{$element.minchecked}}"
{{/
if
}}
{{
if
isset
($
element
['
maxchecked
'])}}
maxchecked=
"{{$element.maxchecked}}"
{{/
if
}}
{{/
if
}}
{{
if
isset
($
element
['
is_required
'])
and
$
element
['
is_required
']
eq
1}}
required
{{/
if
}}
>
{{if !isset($element['is_multiple']) or $element['is_multiple'] neq 1}}
{{if !empty($element['placeholder'])}}
<option
value=
""
>
{{$element.placeholder}}
</option>
{{/if}}
{{/if}}
{{foreach $element.element_data as $element_data_key=>$element_data}}
<option
value=
"{{$element_data.value}}"
{{
if
isset
($
data
['
config
'][$
element
['
name
']])
and
in_array
($
element_data
['
value
'],
explode
(',',
$
data
['
config
'][$
element
['
name
']]))}}
selected
{{/
if
}}
>
{{$element_data.name}}
</option>
{{/foreach}}
</select>
{{/if}}
{{/case}}
{{case textarea}}
<textarea
class=
"am-radius"
name=
"{{$element.name}}"
{{
if
isset
($
element
['
rows
'])}}
rows=
"{{$element.rows}}"
{{/
if
}}
{{
if
isset
($
element
['
placeholder
'])}}
placeholder=
"{{$element.placeholder}}"
{{/
if
}}
{{
if
isset
($
element
['
is_required
'])
and
$
element
['
is_required
']
eq
1}}
{{
if
isset
($
element
['
minlength
'])}}
minlength=
"{{$element.minlength}}"
{{/
if
}}
{{
if
isset
($
element
['
maxlength
'])}}
maxlength=
"{{$element.maxlength}}"
{{/
if
}}
required
{{/
if
}}
>
{{if isset($data['config'][$element['name']])}}{{$data['config'][$element['name']]}}{{else /}}{{if isset($element['default'])}}{{$element.default}}{{/if}}{{/if}}
</textarea>
{{/case}}
{{/switch}}
</div>
{{/foreach}}
{{/if}}
</div>
{{/foreach}}
<div
class=
"am-form-group am-form-group-refreshing"
>
<input
type=
"hidden"
name=
"specifications-tag"
value=
""
/>
<button
type=
"submit"
class=
"am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block"
>
确认
</button>
</div>
{{else /}}
<div
class=
"table-no"
><i
class=
"am-icon-warning"
></i>
没有扩展数据
</div>
{{/if}}
</form>
</div>
</div>
</div>
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->
<!-- 拖拽排序初始化 -->
<script
type=
"text/javascript"
>
// 规格扩展返回处理
function
SpecificationsExtendsBack
()
{
var
$extends_popup
=
$
(
'
#specifications-extends-popup
'
);
var
data
=
GetFormVal
(
'
#specifications-extends-popup
'
,
true
);
$
(
'
.specifications-table
'
).
find
(
$extends_popup
.
attr
(
'
data-line-extend
'
)).
find
(
'
.line-extend-input
'
).
val
(
JSON
.
stringify
(
data
));
$extends_popup
.
modal
(
'
close
'
);
}
$
(
function
()
{
{{
if
!
empty
(
$data
[
'
attribute
'
])}}
...
...
application/admin/view/default/payment/save_info.html
浏览文件 @
cb5faccc
...
...
@@ -42,7 +42,7 @@
<label
class=
"am-text-sm am-text-warning"
>
该区域为插件配置填写项,请按照插件文档填写相应的值。
</label>
{{foreach $data.element as $element}}
<div
class=
"am-form-group"
>
<label
class=
"block"
>
{{$element.title}}
</label>
<label
class=
"block"
>
{{$element.title}}
{{if !empty($element['desc'])}}
<span
class=
"am-form-group-label-tips"
>
{{$element.desc}}
</span>
{{/if}}
</label>
{{switch element.element}}
{{case input}}
{{if in_array($element['type'], ['radio', 'checkbox']) and !empty($element['element_data']) and is_array($element['element_data'])}}
...
...
application/service/GoodsService.php
浏览文件 @
cb5faccc
...
...
@@ -2218,5 +2218,65 @@ class GoodsService
$data
=
Db
::
name
(
'GoodsCategory'
)
->
alias
(
'gc'
)
->
join
([
'__GOODS_CATEGORY_JOIN__'
=>
'gci'
],
'gc.id=gci.category_id'
)
->
where
([
'gci.goods_id'
=>
$goods_id
])
->
column
(
'gc.name'
);
return
DataReturn
(
'获取成功'
,
0
,
$data
);
}
/**
* 商品规格扩展数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-07-21T16:08:34+0800
* @param [array] $params [输入参数]
*/
public
static
function
GoodsSpecificationsExtends
(
$params
=
[])
{
// 数据
$data
=
[];
// 规格扩展数据钩子
$hook_name
=
'plugins_service_goods_spec_extends_handle'
;
Hook
::
listen
(
$hook_name
,
[
'hook_name'
=>
$hook_name
,
'is_backend'
=>
true
,
'data'
=>
&
$data
,
]);
// 测试配置信息
$plugins
=
[
'name'
=>
'会员等级插件'
,
'desc'
=>
'按照会员等级设定不同金额'
,
'element'
=>
[
[
'element'
=>
'input'
,
'type'
=>
'text'
,
'name'
=>
'price'
,
'placeholder'
=>
'普通会员售价'
,
'title'
=>
'普通会员售价'
,
'is_required'
=>
0
,
'message'
=>
'请填写应用ID'
,
'desc'
=>
'请输入会员金额'
,
],
[
'element'
=>
'input'
,
'type'
=>
'text'
,
'name'
=>
'price2'
,
'placeholder'
=>
'高级会员售价'
,
'title'
=>
'高级会员售价'
,
'is_required'
=>
0
,
'message'
=>
'请填写应用公钥'
,
],
[
'element'
=>
'input'
,
'type'
=>
'text'
,
'name'
=>
'price3'
,
'placeholder'
=>
'至尊会员售价'
,
'title'
=>
'至尊会员售价'
,
'is_required'
=>
0
,
'message'
=>
'请填写应用公钥'
,
],
],
];
$data
[]
=
$plugins
;
return
DataReturn
(
'获取成功'
,
0
,
$data
);
}
}
?>
\ No newline at end of file
public/static/admin/default/css/goods.css
浏览文件 @
cb5faccc
...
...
@@ -58,6 +58,9 @@
.specifications-table
th
.operation-btn
{
width
:
80px
;
}
.specifications-table
th
.extend-btn
{
width
:
45px
;
}
.specifications-table
>
tbody
>
tr
>
td
{
vertical-align
:
middle
;
}
...
...
public/static/admin/default/js/answer.js
浏览文件 @
cb5faccc
// 表单初始化
FromInit
(
'
form.form-validation-reply
'
);
$
(
function
()
{
// 表单初始化
FromInit
(
'
form.form-validation-reply
'
);
$
(
function
()
{
// 处理
$
(
'
.submit-reply
'
).
on
(
'
click
'
,
function
()
{
...
...
@@ -15,4 +17,5 @@ $(function()
$popup
.
find
(
'
.user-info .user-base .mobile span
'
).
html
(
json
.
user
.
mobile
||
'
<span class="cr-ddd">未填写</span>
'
);
$popup
.
find
(
'
.user-info .user-base .email span
'
).
html
(
json
.
user
.
email
||
'
<span class="cr-ddd">未填写</span>
'
);
});
});
});
\ No newline at end of file
public/static/admin/default/js/goods.js
浏览文件 @
cb5faccc
$
(
function
()
{
// 表单初始化
FromInit
(
'
form.form-validation-specifications-extends
'
);
// 商品导航
$
(
'
.goods-nav li a
'
).
on
(
'
click
'
,
function
()
{
...
...
@@ -54,13 +57,15 @@ $(function()
return
false
;
}
var
index
=
parseInt
(
Math
.
random
()
*
1000001
);
var
html
=
$
(
'
.specifications-table
'
).
find
(
'
tbody tr:last
'
).
prop
(
'
outerHTML
'
);
if
(
html
.
indexOf
(
'
<!--operation-->
'
)
>=
0
)
{
html
=
html
.
replace
(
/<!--operation-->/ig
,
'
<span class="fs-12 cr-blue c-p m-r-5 line-copy">复制</span> <span class="fs-12 cr-red c-p line-remove">移除</span>
'
);
}
$
(
'
.specifications-table
'
).
append
(
html
);
$
(
'
.specifications-table
'
).
find
(
'
tbody tr:last
'
).
addClass
(
'
line-not-first
'
);
$
(
'
.specifications-table
'
).
find
(
'
tbody tr:last
'
).
attr
(
'
class
'
,
'
line-
'
+
index
+
'
line-not-first
'
);
$
(
'
.specifications-table
'
).
find
(
'
tbody tr:last
'
).
attr
(
'
data-line-tag
'
,
'
.line-
'
+
index
);
// 值赋空
$
(
'
.specifications-table
'
).
find
(
'
tbody tr:last
'
).
find
(
'
input
'
).
each
(
function
(
k
,
v
)
...
...
@@ -72,12 +77,15 @@ $(function()
// 规格行复制
$
(
document
).
on
(
'
click
'
,
'
.specifications-table .line-copy
'
,
function
()
{
var
index
=
parseInt
(
Math
.
random
()
*
1000001
);
var
$parent
=
$
(
this
).
parents
(
'
tr
'
);
$parent
.
find
(
'
input
'
).
each
(
function
(
k
,
v
)
{
$
(
this
).
attr
(
'
value
'
,
$
(
this
).
val
());
});
$parent
.
after
(
$parent
.
prop
(
'
outerHTML
'
));
$
(
'
.specifications-table
'
).
find
(
'
tbody tr:last
'
).
attr
(
'
class
'
,
'
line-
'
+
index
+
'
line-not-first
'
);
$
(
'
.specifications-table
'
).
find
(
'
tbody tr:last
'
).
attr
(
'
data-line-tag
'
,
'
.line-
'
+
index
);
});
// 规格行移除
...
...
@@ -176,4 +184,26 @@ $(function()
$
(
'
ul.content-app-items
'
).
dragsort
({
dragSelector
:
'
i.drag-sort-submit
'
,
placeHolderTemplate
:
'
<li class="drag-sort-dotted"></li>
'
});
$
(
'
ul.goods-attribute-items
'
).
dragsort
({
dragSelector
:
'
i.drag-sort-submit
'
,
placeHolderTemplate
:
'
<li class="drag-sort-dotted"></li>
'
});
// 规格扩展数据编辑
var
$extends_popup
=
$
(
'
#specifications-extends-popup
'
);
$
(
document
).
on
(
'
click
'
,
'
.specifications-table .line-extend-btn
'
,
function
()
{
$extends_popup
.
attr
(
'
data-line-extend
'
,
$
(
this
).
parents
(
'
tr
'
).
attr
(
'
data-line-tag
'
));
$extends_popup
.
find
(
'
input,select,textarea
'
).
val
(
''
);
var
json
=
$
(
this
).
prev
().
val
()
||
null
;
if
(
json
!=
null
)
{
FormDataFill
(
JSON
.
parse
(
json
),
'
#specifications-extends-popup
'
);
}
$extends_popup
.
modal
();
});
// 规格扩展数据
$
(
'
#specifications-extends-popup button[type="button"]
'
).
on
(
'
click
'
,
function
()
{
// var data = GetFormVal('#specifications-extends-popup', true);
// $('.specifications-table').find($extends_popup.attr('data-line-extend')).find('.line-extend-input').val(JSON.stringify(data));
// $extends_popup.modal('close');
});
});
\ No newline at end of file
public/static/admin/default/js/goodscomments.js
浏览文件 @
cb5faccc
// 表单初始化
FromInit
(
'
form.form-validation-reply
'
);
$
(
function
()
{
// 表单初始化
FromInit
(
'
form.form-validation-reply
'
);
// 处理
$
(
'
.submit-reply
'
).
on
(
'
click
'
,
function
()
{
...
...
public/static/admin/default/js/link.js
浏览文件 @
cb5faccc
/**
$
(
function
()
{
/**
* 添加
*/
$
(
'
.submit-add
'
).
on
(
'
click
'
,
function
()
{
$
(
'
.submit-add
'
).
on
(
'
click
'
,
function
()
{
// 更改窗口名称
$title
=
$
(
'
#data-save-win
'
).
find
(
'
.am-popup-title
'
);
$title
.
text
(
$title
.
data
(
'
add-title
'
));
...
...
@@ -15,4 +17,5 @@ $('.submit-add').on('click', function()
{
$
(
this
).
blur
();
});
});
});
\ No newline at end of file
public/static/admin/default/js/navigation.js
浏览文件 @
cb5faccc
// 表单初始化
FromInit
(
'
form.form-validation-article
'
);
FromInit
(
'
form.form-validation-customview
'
);
FromInit
(
'
form.form-validation-goods_category
'
);
$
(
function
()
{
// 表单初始化
FromInit
(
'
form.form-validation-article
'
);
FromInit
(
'
form.form-validation-customview
'
);
FromInit
(
'
form.form-validation-goods_category
'
);
/**
/**
* 添加
*/
$
(
'
.submit-add
'
).
on
(
'
click
'
,
function
()
{
$
(
'
.submit-add
'
).
on
(
'
click
'
,
function
()
{
// 获取标签
var
tag
=
$
(
this
).
data
(
'
tag
'
);
...
...
@@ -23,4 +25,5 @@ $('.submit-add').on('click', function()
{
$
(
this
).
blur
();
});
});
});
\ No newline at end of file
public/static/admin/default/js/orderaftersale.js
浏览文件 @
cb5faccc
// 表单初始化
FromInit
(
'
form.form-validation-audit
'
);
FromInit
(
'
form.form-validation-refuse
'
);
$
(
function
()
{
// 表单初始化
FromInit
(
'
form.form-validation-audit
'
);
FromInit
(
'
form.form-validation-refuse
'
);
// 弹窗数据初始化
function
PopupInit
(
$popup
,
data
)
{
...
...
public/static/admin/default/js/power.js
浏览文件 @
cb5faccc
/**
$
(
function
()
{
/**
* 展开/关闭
*/
$
(
'
.tree-list i
'
).
on
(
'
click
'
,
function
()
{
$
(
'
.tree-list i
'
).
on
(
'
click
'
,
function
()
{
if
(
$
(
this
).
hasClass
(
'
am-icon-plus
'
))
{
$
(
this
).
removeClass
(
'
am-icon-plus
'
);
...
...
@@ -12,38 +14,38 @@ $('.tree-list i').on('click', function()
$
(
this
).
addClass
(
'
am-icon-plus
'
);
}
$
(
this
).
parent
().
next
(
'
.list-find
'
).
toggle
(
100
);
});
});
/**
/**
* 全选/取消
*/
$
(
'
.node-choice
'
).
on
(
'
click
'
,
function
()
{
$
(
'
.node-choice
'
).
on
(
'
click
'
,
function
()
{
var
state
=
$
(
this
).
is
(
'
:checked
'
);
$
(
this
).
parents
(
'
li
'
).
next
(
'
.list-find
'
).
find
(
'
input[type="checkbox"]
'
).
each
(
function
()
{
this
.
checked
=
state
;
});
});
});
/**
/**
* 子元素选择/取消操作
*/
$
(
'
.list-find input[type="checkbox"]
'
).
on
(
'
click
'
,
function
()
{
$
(
'
.list-find input[type="checkbox"]
'
).
on
(
'
click
'
,
function
()
{
var
state
=
(
$
(
this
).
parents
(
'
.list-find
'
).
find
(
'
input[type="checkbox"]:checked
'
).
length
>
0
);
$
(
this
).
parents
(
'
ul
'
).
prev
().
find
(
'
label input
'
).
each
(
function
()
{
this
.
checked
=
state
;
});
});
});
/**
/**
* 添加
*/
$
(
'
.submit-add
'
).
on
(
'
click
'
,
function
()
{
$
(
'
.submit-add
'
).
on
(
'
click
'
,
function
()
{
// 更改窗口名称
$title
=
$
(
'
#power-save-win
'
).
find
(
'
.am-popup-title
'
);
$title
.
text
(
$title
.
data
(
'
add-title
'
));
...
...
@@ -59,13 +61,13 @@ $('.submit-add').on('click', function()
{
$
(
this
).
blur
();
});
});
});
/**
/**
* 编辑
*/
$
(
'
.submit-edit
'
).
on
(
'
click
'
,
function
()
{
$
(
'
.submit-edit
'
).
on
(
'
click
'
,
function
()
{
// 更改窗口名称
$title
=
$
(
'
#power-save-win
'
).
find
(
'
.am-popup-title
'
);
$title
.
text
(
$title
.
data
(
'
edit-title
'
));
...
...
@@ -77,4 +79,5 @@ $('.submit-edit').on('click', function()
}
else
{
$
(
'
form select[name="pid"]
'
).
removeAttr
(
'
disabled
'
);
}
});
});
\ No newline at end of file
public/static/common/js/common.js
浏览文件 @
cb5faccc
...
...
@@ -74,9 +74,10 @@ function ArrayTurnJson(all, object)
* @version 0.0.1
* @datetime 2016-12-10T14:31:19+0800
* @param {[string]} element [元素的class或id]
* @param {[boolean]} is_json [是否返回json对象(默认否)]
* @return {[object]} [josn对象]
*/
function
GetFormVal
(
element
)
function
GetFormVal
(
element
,
is_json
)
{
var
object
=
new
FormData
();
...
...
@@ -140,6 +141,14 @@ function GetFormVal(element)
}
});
object
=
ArrayTurnJson
(
tmp_all
,
object
);
// 是否需要返回json对象
if
(
is_json
===
true
)
{
var
json
=
{};
object
.
forEach
((
value
,
key
)
=>
json
[
key
]
=
value
);
return
json
;
}
return
object
;
}
...
...
@@ -341,40 +350,58 @@ function FromInit(form_name)
var
$button
=
$form
.
find
(
'
button[type="submit"]
'
);
$button
.
button
(
'
loading
'
);
// 开启进度条
$
.
AMUI
.
progress
.
start
();
// 获取表单数据
var
action
=
$form
.
attr
(
'
action
'
);
var
method
=
$form
.
attr
(
'
method
'
);
var
request_type
=
$form
.
attr
(
'
request-type
'
);
var
request_value
=
$form
.
attr
(
'
request-value
'
);
var
ajax_all
=
[
'
ajax-reload
'
,
'
ajax-url
'
,
'
ajax-fun
'
];
var
action
=
$form
.
attr
(
'
action
'
)
||
null
;
var
method
=
$form
.
attr
(
'
method
'
)
||
null
;
var
request_type
=
$form
.
attr
(
'
request-type
'
)
||
null
;
var
request_value
=
$form
.
attr
(
'
request-value
'
)
||
null
;
var
ajax_all
=
[
'
ajax-reload
'
,
'
ajax-url
'
,
'
ajax-fun
'
,
'
sync
'
];
//
不
是form表单直接通过
// 是form表单直接通过
if
(
request_type
==
'
form
'
)
{
return
true
;
}
// 参数校验
if
(
ajax_all
.
indexOf
(
request_type
)
==
-
1
||
action
==
undefined
||
action
==
''
||
method
==
undefined
||
method
==
''
)
if
(
ajax_all
.
indexOf
(
request_type
)
==
-
1
)
{
$
.
AMUI
.
progress
.
done
();
$button
.
button
(
'
reset
'
);
Prompt
(
'
表单参数配置有误
'
);
Prompt
(
'
表单
[类型]
参数配置有误
'
);
return
false
;
}
// 类型不等于刷新的时候,类型值必须填写
if
(
request_type
!=
'
ajax-reload
'
&&
(
request_value
==
undefined
||
request_value
==
''
)
)
if
(
request_type
!=
'
ajax-reload
'
&&
request_value
==
null
)
{
$
.
AMUI
.
progress
.
done
();
$button
.
button
(
'
reset
'
);
Prompt
(
'
表单[类型值]参数配置有误
'
);
return
false
;
}
// 同步调用方法
if
(
request_type
==
'
sync
'
)
{
$button
.
button
(
'
reset
'
);
if
(
IsExitsFunction
(
request_value
))
{
window
[
request_value
]();
}
else
{
Prompt
(
'
[
'
+
request_value
+
'
]表单定义的方法未定义
'
);
}
return
false
;
}
if
(
action
==
null
||
method
==
null
)
{
$button
.
button
(
'
reset
'
);
Prompt
(
'
表单[action或method]参数配置有误
'
);
return
false
;
}
// 开启进度条
$
.
AMUI
.
progress
.
start
();
// ajax请求
$
.
ajax
({
url
:
action
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录