BatchUpdateSkuStatus.blade.php
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<script>
layui.use(['table', 'form', 'laydate', 'layer', 'upload', 'element', 'admin'], function () {
let form = layui.form;
let admin = layui.admin;
let table = layui.table;
let element = layui.element;
let upload = layui.upload;
let layer = layui.layer;
let laydate = layui.laydate;
let $ = layui.$;
laydate.render({
elem: '#cp_time_selector', //指定元素
type: 'datetime'
});
form.render();
form.on('switch(is_long_term)', function (data) {
let element = $('#cp_time_selector');
if (data.elem.checked) {
element.addClass('layui-disabled');
element.attr('disabled', true);
form.render();
} else {
element.removeClass('layui-disabled');
element.attr('disabled', false);
form.render();
}
});
form.on('submit(batchUpdateSkuStatus)', function (data) {
let operate = data.field.operate_type > 0 ? '上架' : '下架';
layer.confirm('确定要' + operate + '商品吗', function (index) {
const url = '/api/sku/batchUpdateSkuStatus';
$.post(url, {
sku_ids: data.field.sku_ids,
is_long_term: data.field.is_long_term ? 1 : 0,
operate_type: data.field.operate_type,
cp_time: data.field.cp_time
}, function (res) {
if (res.code === 0) {
admin.closeThisDialog();
parent.layer.msg("修改成功", {icon: 6});
} else {
layer.msg(res.msg);
}
});
});
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>