Commit 83a8662c by 杨树贤

Merge branch 'master' into ysx-供应商新建-20220701

parents edad517f dffbb8ea
...@@ -61,9 +61,9 @@ class SupplierAttachmentService ...@@ -61,9 +61,9 @@ class SupplierAttachmentService
$attachments = []; $attachments = [];
foreach ($attachmentData['file_name'] as $key => $value) { foreach ($attachmentData['file_name'] as $key => $value) {
//最后一个跳过,因为是模板里的数据 //最后一个跳过,因为是模板里的数据
// if ($key == (count($attachmentData['file_name']) - 1)) { if ($key == (count($attachmentData['file_name']) - 1)) {
// continue; continue;
// } }
$attachment = [ $attachment = [
'supplier_id' => $supplierId, 'supplier_id' => $supplierId,
'file_name' => $attachmentData['file_name'][$key], 'file_name' => $attachmentData['file_name'][$key],
...@@ -76,6 +76,9 @@ class SupplierAttachmentService ...@@ -76,6 +76,9 @@ class SupplierAttachmentService
'description' => !empty($attachmentData['description'][$key]) ? $attachmentData['description'][$key] : ' ', 'description' => !empty($attachmentData['description'][$key]) ? $attachmentData['description'][$key] : ' ',
'type_name' => array_get(config('fixed.FileNameMapping'), $attachmentData['field_name'][$key]), 'type_name' => array_get(config('fixed.FileNameMapping'), $attachmentData['field_name'][$key]),
]; ];
if (empty($attachment['file_name'])) {
continue;
}
if (!empty($attachmentData['validity_period'][$key])) { if (!empty($attachmentData['validity_period'][$key])) {
$validityPeriod = explode('~', $attachmentData['validity_period'][$key]); $validityPeriod = explode('~', $attachmentData['validity_period'][$key]);
$attachment['validity_start'] = strtotime(trim($validityPeriod[0])); $attachment['validity_start'] = strtotime(trim($validityPeriod[0]));
......
...@@ -61,31 +61,41 @@ ...@@ -61,31 +61,41 @@
admin.closeThisTabs(); admin.closeThisTabs();
}); });
form.on('submit(addSupplier)', function (data) { function getAttachmentData(data) {
admin.showLoading({
type: 3,
});
let file_name = []; let file_name = [];
let file_url = []; let file_url = [];
let validity_type = []; let validity_type = [];
let field_name = []; let field_name = [];
let validity_period = []; let validity_period = [];
$('.single_file_div').each(function () { let description = [];
//只要寻找上传主区域的数据即可
$('#attachment_upload_div').find('.single_file_div').each(function () {
file_name.push($(this).find('#file_name').val()); file_name.push($(this).find('#file_name').val());
file_url.push($(this).find('#file_url').val()); file_url.push($(this).find('#file_url').val());
field_name.push($(this).find('#field_name').val()); field_name.push($(this).find('#field_name').val());
validity_type.push($(this).find('#validity_type').val()); validity_type.push($(this).find('#validity_type').val());
description.push($(this).find('#description').val());
validity_period.push($(this).find('#validity_period').val()); validity_period.push($(this).find('#validity_period').val());
}); });
data.field.file_name = file_name; data.field.file_name = file_name;
data.field.file_url = file_url; data.field.file_url = file_url;
data.field.field_name = field_name; data.field.field_name = field_name;
data.field.description = description;
data.field.validity_type = validity_type; data.field.validity_type = validity_type;
data.field.validity_period = validity_period; data.field.validity_period = validity_period;
data.field.apply_audit_reason = $('#apply_audit_reason').val(); data.field.apply_audit_reason = $('#apply_audit_reason').val();
return data;
}
form.on('submit(addSupplier)', function (data) {
admin.showLoading({
type: 3,
});
data = getAttachmentData(data);
let url = '/api/supplier/AddSupplier'; let url = '/api/supplier/AddSupplier';
let res = ajax(url, data.field); let res = ajax(url, data.field);
if (!res) { if (!res) {
admin.removeLoading();
layer.msg('网络错误,请重试', {icon: 6}); layer.msg('网络错误,请重试', {icon: 6});
} else { } else {
if (res.err_code === 0) { if (res.err_code === 0) {
...@@ -107,31 +117,9 @@ ...@@ -107,31 +117,9 @@
}); });
form.on('submit(addAndApplySupplier)', function (data) { form.on('submit(addAndApplySupplier)', function (data) {
data = getAttachmentData(data);
//去找出附件的所有数据 console.log(data.field.field_name);
let file_name = []; let fieldNameList = data.field.field_name ? data.field.field_name : [];
let file_url = [];
let validity_type = [];
let field_name = [];
let validity_period = [];
let description = [];
//只要寻找上传主区域的数据即可
$('#attachment_upload_div').find('.single_file_div').each(function () {
file_name.push($(this).find('#file_name').val());
file_url.push($(this).find('#file_url').val());
field_name.push($(this).find('#field_name').val());
validity_type.push($(this).find('#validity_type').val());
description.push($(this).find('#description').val());
validity_period.push($(this).find('#validity_period').val());
});
data.field.file_name = file_name;
data.field.file_url = file_url;
data.field.description = description;
data.field.field_name = field_name;
data.field.validity_type = validity_type;
data.field.validity_period = validity_period;
data.field.apply_audit_reason = $('#apply_audit_reason').val();
let fieldNameList = field_name;
//提交先提示是否要转换供应商类型 //提交先提示是否要转换供应商类型
let radioObj = $('input[name="supplier_type"]'); let radioObj = $('input[name="supplier_type"]');
//已经上传品质保证协议(代理商则提示为“已经上传代理证”),是否切换为正式供应商? //已经上传品质保证协议(代理商则提示为“已经上传代理证”),是否切换为正式供应商?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment