Commit dffbb8ea by 杨树贤

附件bug,我操

parent 6a8a14a7
......@@ -61,9 +61,9 @@ class SupplierAttachmentService
$attachments = [];
foreach ($attachmentData['file_name'] as $key => $value) {
//最后一个跳过,因为是模板里的数据
// if ($key == (count($attachmentData['file_name']) - 1)) {
// continue;
// }
if ($key == (count($attachmentData['file_name']) - 1)) {
continue;
}
$attachment = [
'supplier_id' => $supplierId,
'file_name' => $attachmentData['file_name'][$key],
......@@ -76,6 +76,9 @@ class SupplierAttachmentService
'description' => !empty($attachmentData['description'][$key]) ? $attachmentData['description'][$key] : ' ',
'type_name' => array_get(config('fixed.FileNameMapping'), $attachmentData['field_name'][$key]),
];
if (empty($attachment['file_name'])) {
continue;
}
if (!empty($attachmentData['validity_period'][$key])) {
$validityPeriod = explode('~', $attachmentData['validity_period'][$key]);
$attachment['validity_start'] = strtotime(trim($validityPeriod[0]));
......
......@@ -61,31 +61,41 @@
admin.closeThisTabs();
});
form.on('submit(addSupplier)', function (data) {
admin.showLoading({
type: 3,
});
function getAttachmentData(data) {
let file_name = [];
let file_url = [];
let validity_type = [];
let field_name = [];
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_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.field_name = field_name;
data.field.description = description;
data.field.validity_type = validity_type;
data.field.validity_period = validity_period;
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 res = ajax(url, data.field);
if (!res) {
admin.removeLoading();
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
......@@ -107,31 +117,9 @@
});
form.on('submit(addAndApplySupplier)', function (data) {
//去找出附件的所有数据
let file_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;
data = getAttachmentData(data);
console.log(data.field.field_name);
let fieldNameList = data.field.field_name ? data.field.field_name : [];
//提交先提示是否要转换供应商类型
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