UpdateSupplierScript.blade.php
8.26 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<script>
layui.use(['table', 'form', 'element', 'layer', 'admin', 'index', 'laydate', 'xmSelect'], function () {
let admin = layui.admin;
let form = layui.form;
let table = layui.table;
$('#supplierDetailUrl').click(function () {
admin.showLoading({
type: 3,
});
});
//点击芯链
form.on('checkbox(stockup_type_filter)', function (data) {
if (data.elem.checked && data.elem.name === "stockup_type[5]") {
let url = '/api/supplier/checkHasLadderPriceSetting?supplier_id=' + getQueryVariable('supplier_id');
let elem = data.elem;
let self = $(this);
$.ajax({
url: url,
type: 'POST',
async: true,
data: data.field,
dataType: 'json',
timeout: 20000,
success: function (res) {
if (res.err_code === 0) {
} else {
layer.msg('请先去魔方系统配置阶梯系数,再新建芯链账号', {icon: 5})
$('input[name="stockup_type[5]"]').next().click();
}
},
error: function () {
layer.msg('网络错误', {icon: 5});
}
});
}
});
form.on('submit(updateSupplier)', function (data) {
let confirmMessage = '';
if (data.field.status === '-2') {
confirmMessage = '确定要重新入驻吗,该供应商就会再次进入审核阶段'
} else if (data.field.status === '-1') {
confirmMessage = '确定要提交新增供应商信息吗?一旦提交,该供应商就会进入待复审阶段,审核过程中无法进行信息修改'
} else if (data.field.status === '3') {
confirmMessage = '确定要重新提交审核吗?一旦提交,该供应商就会再次进入审核中阶段,审核过程中无法进行信息修改';
} else {
//修改不需要进入审核了,有个单独提交审核的按钮
updateSupplier(data);
return;
}
layer.confirm(confirmMessage, function (index) {
updateSupplier(data);
});
})
form.on('select(apply_audit_reason_selector)', function (data) {
$('#apply_audit_reason').val(data.value);
});
form.on('submit(applyAuditSupplier)', function (data) {
$('input:disabled').attr('disabled', false);
let fieldNameList = [];
$('.attachment_fields').each(function () {
fieldNameList.push($(this).text());
});
//提交先提示是否要转换供应商类型
let radioObj = $('input[name="supplier_type"]');
//已经上传品质保证协议(代理商则提示为“已经上传代理证”),是否切换为正式供应商?
let supplierGroup = data.field.supplier_group;
let msg;
let obj1Checked = 0;
let obj2Checked = 0;
if (data.field.supplier_type === '2') {
//如果已经上传品质保证协议,并且供应商性质不是代理商(代理商要代理证)
if (inArray('quality_assurance_agreement', fieldNameList) && supplierGroup !== '1') {
msg = '已经上传品质保证协议,是否切换为正式供应商?'
obj1Checked = true;
obj2Checked = false;
}
if (inArray('proxy_certificate', fieldNameList) && supplierGroup === '1') {
msg = '该供应商为代理供应商,已经上传代理证,是否切换为正式供应商?'
obj1Checked = true;
obj2Checked = false;
}
} else {
if (!inArray('quality_assurance_agreement', fieldNameList) && !inArray(supplierGroup, ['1', '4'])) {
msg = '未上传品质保证协议,是否切换为临时供应商?'
obj1Checked = false;
obj2Checked = true;
}
if (!inArray('proxy_certificate', fieldNameList) && supplierGroup === '1') {
msg = '该供应商为代理供应商,但是未上传代理证,是否切换为临时供应商?'
obj1Checked = false;
obj2Checked = true;
}
}
@if ($ignore_supplier_type_change_tips)
msg = '';
@endif
if (msg) {
layer.confirm(msg, {btn: ["确认", "取消"]},
function (index) {
if (obj1Checked !== 0) {
radioObj.get(0).checked = obj1Checked;
radioObj.get(1).checked = obj2Checked;
layui.form.render('radio');
data.field.supplier_type = obj1Checked ? "1" : "2";
layer.closeAll();
}
auditAndUpdateSupplier(data);
},
function (index) {
auditAndUpdateSupplier(data);
}
);
} else {
auditAndUpdateSupplier(data);
}
return false;
});
//直接审核并且更新供应商
function auditAndUpdateSupplier(data) {
data.field.is_audit = 1;
if (data.field.supplier_type === '2') {
layer.open({
type: 1,
area: ['450px', '370px'], //宽高
content: $('#apply_audit_reason_div'),
btn: ['保存并申请审核', '取消'],
btn1: function (index, layero) {//点击保存按钮
let reason = $('#apply_audit_reason').val();
if (reason === '') {
layer.msg('请选择申请理由', {icon: 5})
return false;
}
data.field.apply_audit_reason = reason;
updateSupplier(data);
setTimeout(function () {
layer.close(index);
}, 1000);
},
});
} else {
layer.confirm('确定直接申请审核吗?确定后会直接进入审核中的状态,审核完成前无法进行二次修改', function (index) {
updateSupplier(data);
});
}
}
function updateSupplier(data) {
admin.showLoading();
admin.showLoading('.layui-layer-btn0');
$.ajax({
url: '/api/supplier/UpdateSupplier',
type: 'POST',
async: true,
data: data.field,
dataType: 'json',
timeout: 20000,
success: function (res) {
if (res.err_code === 0) {
admin.putTempData("needFreshList", 1)
table.reload('receiptList')
location.href = "/supplier/SupplierDetail?view=iframe&supplier_id={{$supplier['supplier_id']}}"
layer.msg(res.err_msg, {icon: 6})
} else {
let errMsg = res.err_msg;
let msg = '';
$.each(errMsg.split('|'), function (index, value) {
msg += "<span>" + value + "</span><br>"
});
layer.msg(msg, {icon: 5})
}
admin.removeLoading();
admin.showLoading('.layui-layer-btn0');
},
error: function () {
admin.removeLoading();
admin.showLoading('.layui-layer-btn0');
layer.msg('网络错误', {icon: 5});
}
});
}
});
</script>