validPeriodForm.html
4.49 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="修改有效期" />
<meta name="author" content="GLSX Web Team" />
<meta name="keywords" itemprop="keywords" content="广联,商户管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<style>
.valid-period {
text-align: center;
padding: 20px 20px;
background-color: #ffffff;
}
</style>
<title>修改有效期</title>
</head>
<body>
<div id="app">
<main class="valid-period">
<form class="layui-form" lay-filter="periodFilter">
<div class="layui-form-item">
<div class="layui-form-label required" style="width: 120px;">账户有效期:</div>
<div class="layui-input-inline" style="width: auto;">
<select name="effectiveTime" id="periodSelect" required lay-verify="required">
<option value="">请选择</option>
</select>
<p class="input-downtips">(注:永久有效不超过所属工厂商户的有效期)</p>
</div>
<button id="periodVerifyBtn" lay-submit lay-filter="periodSubmit" style="display: none;"></button>
</div>
</form>
</main>
</div>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script>
layui.use(['form', 'helper', 'request'], function () {
var form = layui.form
var request = layui.request
var $ = layui.$
var helper = layui.helper
var currLayerIdx = parent.layer.getFrameIndex(window.name)
var baseData = {}
var vaildData = {
id: getQueryString('id'),
effectiveTime: getQueryString('effectiveTime')
}
// 1-工厂;2-省代;3-市代;4-门店
var merchantAccountLevel = getQueryString('merchantAccountLevel')
// 1-草稿;2-正常;3-注销;4-过期
var status = getQueryString('status')
getVaildPeriod()
form.on('submit(periodSubmit)', function (data) {
var params = {
method: 'cn.com.glsx.merchants.merchant.updateValPerByMerId',
id: vaildData.id,
effectiveTime: data.field.effectiveTime
}
request(params, function (res) {
if (res.code == '0') {
helper.store.set('isRefresh', true)
parent.layer.close(currLayerIdx)
}
})
return false
})
// 获取参数
function getQueryString(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
var r = window.location.search.substr(1).match(reg)
if (r != null) {
return unescape(r[2])
}
return null
}
// 获取有效期
function getVaildPeriod() {
request({
method: 'cn.com.glsx.merchants.menu.findAllDictData',
dictType: 'account_validity_period'
}, function (res) {
if (res.code === '0') {
baseData.effectiveTimeList = res.data
var periodSelect = $('#periodSelect')
$.each(baseData.effectiveTimeList, function (index, item) {
// 工厂
if (merchantAccountLevel == 1) {
// 状态 - 正常
if (status == 2) {
// 永久有效
if (vaildData.effectiveTime == 0) {
if (item.dictValue == -1) {
periodSelect.append(new Option(item.dictLabel, item.dictValue))
}
} else if ((item.dictValue == 0) ||
(item.dictValue == -1) ||
(vaildData.effectiveTime < item.dictValue)) {
periodSelect.append(new Option(item.dictLabel, item.dictValue))
}
} else {
// 状态 - 过期/注销
if (vaildData.effectiveTime != item.dictValue) {
periodSelect.append(new Option(item.dictLabel, item.dictValue))
}
}
} else {
if ((item.dictValue == 0) || (item.dictValue == -1)) {
periodSelect.append(new Option(item.dictLabel, item.dictValue))
}
}
})
form.val('periodFilter', {
effectiveTime: vaildData.effectiveTime
})
form.render('select')
}
})
}
})
</script>
</body>
</html>