Commit b99d7e89 by 杨树贤

fix

parent bacd100a
<div class="layui-side">
<div class="layui-side-scroll">
<ul class="layui-nav layui-nav-tree arrow2" lay-filter="admin-side-nav" lay-shrink="all">
<?php if(!empty($menus)): ?>
<?php foreach($menus as $k=>$v): ?>
<li class="layui-nav-item">
<?php if(!empty($v['title'])): ?>
<?php if(!empty($v['target'])): ?>
<a <?php if(!empty($v['href'])): ?> href="<?php echo e($v['href']); ?>" target="_blank" <?php endif; ?>>
<i class="layui-icon <?php echo e(isset($v['class']) ? $v['class'] : ''); ?>"></i>&emsp;<cite><?php echo e(isset($v['title']) ? $v['title'] : ''); ?></cite>
</a>
<?php else: ?>
<a <?php if(!empty($v['href'])): ?> lay-href="<?php echo e(iframeUrl($v['href'])); ?>" <?php endif; ?>>
<i class="layui-icon <?php echo e(isset($v['class']) ? $v['class'] : ''); ?>"></i>&emsp;<cite><?php echo e(isset($v['title']) ? $v['title'] : ''); ?></cite>
</a>
<?php endif; ?>
<?php endif; ?>
<?php echo $__env->make("layouts.menu", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>
</div>
<?php if(!empty($v['childs'])): ?>
<dl class="layui-nav-child">
<?php foreach($v['childs'] as $k=>$v): ?>
<dd>
<a class="layui-icon <?php echo e(isset($v['class']) ? $v['class'] : ''); ?>" ew-title="<?php echo e($v['title']); ?>" <?php if(!empty($v['href'])): ?> lay-href="<?php echo e(iframeUrl($v['href'])); ?>" <?php endif; ?>><?php echo e($v['title']); ?> <?php if($v['title'] == '供应商列表' && !empty($skuExpiredCount) && $skuExpiredCount > 0): ?> <span class="layui-badge layui-bg-red" style="margin-left: 5px;"><?php echo e($skuExpiredCount > 99 ? '99+' : $skuExpiredCount); ?></span> <?php endif; ?></a>
<?php /* <?php echo $__env->make("layouts.menu", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?> */ ?>
</dd>
<?php endforeach; ?>
</dl>
<?php endif; ?>
<script>
layui.use(['table', 'form', 'element', 'layer', 'Split', 'admin', 'index', 'xmSelect'], function () {
let $ = layui.jquery;
let Split = layui.Split;
// 水平分割,需要分割的元素(id)、默认大小(百分比)、最小值(单位px)
Split(['#s1', '#s6', '#s7', '#s8'], {sizes: [9, 12, 12, 12], minSize: 70});
// Split(['#s1', '#s2', '#s3', '#s4', '#s5', '#s6', '#s7','#s8'], {sizes: [9, 12, 12, 12, 12, 12, 12,19], minSize: 70});
let table = layui.table;
let form = layui.form;
let index = layui.index;
let admin = layui.admin;
let xmSelect = layui.xmSelect;
let initCondition = {source_type: 'all'};
let whereCondition = initCondition;
let type = 'all';
let currentPage = 1;
//一进来就去获取统计数据
function supplierStatistics(hasLoading = false) {
if (hasLoading) {
admin.showLoading({
elem: '#type_filter',
type: 3,
});
}
$.ajax({
url: '/api/supplier_statistics/GetSupplierStatistics',
type: 'post',
async: true,
dataType: 'json',
timeout: 20000,
success: function (res) {
if (res.err_code === 0) {
$.each(res.data, function (index, value) {
let menuObj = $('#' + index);
menuObj.text('');
menuObj.append(value);
});
if (getQueryVariable('source_type')) {
$('#' + getQueryVariable('source_type')).click();
}
}
if (hasLoading) {
admin.removeLoading('#type_filter');
}
}
})
}
supplierStatistics(true);
//罗盘隐藏
$('.hide_filter_type').click(function () {
$(this).hide();
$('#type_filter').hide();
$('.show_filter_type').show();
});
$('.show_filter_type').click(function () {
$(this).hide();
$('#type_filter').show();
$('.hide_filter_type').show();
});
$('#show_filter_row2').click(function () {
let isHidden = $('#filter_row2').is(':hidden');
if (isHidden) {
$('#filter_row2').show();
$('#show_filter_row2').text('隐藏');
} else {
$('#filter_row2').hide();
$('#show_filter_row2').text('展开');
}
});
$(function () {
$('.layui-form .layui-col-md5 .layui-edge').remove();
});
//这个是页面点击刷新方法,隐藏起来是为了页面切换回这个列表的时候触发的
$('#refreshWindow').click(function () {
//判断当前是否有layui弹窗窗口,有的话不刷新
let hasLayerIframe = $('.layui-layer').size() > 0;
if (!hasLayerIframe) {
$('#getSupplierListButton').click();
}
});
//点击罗盘筛选
$('.main_filter').click(function () {
clearTypeFilter();
$(this).attr('class', 'main_filter layui-badge layui-bg-green');
type = $(this).attr('id');
whereCondition.source_type = type
table.reload('list', {
page: {
curr: 1
}
, where: whereCondition
});
});
if (getQueryVariable('source_type')) {
whereCondition.source_type = getQueryVariable('source_type');
}
var createUserDepartmentSelector = xmSelect.render({
el: '#create_user_department',
autoRow: true,
name: 'create_user_department',
filterable: true,
direction: 'down',
tree: {
show: true,
showFolderIcon: true,
showLine: true,
indent: 20,
expandedKeys: true,
},
size: 'mini',
toolbar: {
show: true,
list: ['ALL', 'CLEAR']
},
height: 'auto',
data: function () {
//这个数据在对应的blade页面下面...
return <?php echo json_encode($createUserDepartmentList); ?>;
}
})
var agencyBrandsSelector = xmSelect.render({
el: '#agency_brands_filter',
filterable: true,
paging: true,
height: '250px',
size: 'mini',
direction: 'auto',
autoRow: true,
prop: {
name: 'brand_name',
value: 'brand_id',
},
remoteSearch: true,
pageRemote: true,
template({item, sels, name, value}) {
return item.brand_name + '<span style="position: absolute; right: 10px; color: #8799a3">' +
item.mapping_brand_names + '</span>'
},
filterMethod: function(val, item, index, prop) {},
pageSize: 30,
remoteMethod: function(val, cb, show, pageIndex) {
$.ajax({
url: '/api/common/getStandardBrandList',
type: 'post',
data: {
brand_name: val,
page: pageIndex
},
dataType: 'json',
timeout: 10000,
success: function(res) {
if (!res) return layer.msg('网络错误,请重试', {icon: 5});
if (res.err_code === 0) {
cb(res.data, res.last_page);
} else {
layer.msg(res.err_msg, {icon: 6});
}
},
error: function() {
return layer.msg('网络错误,请重试', {icon: 5});
}
});
},
on: function(data) {
let arr = data.arr;
let brandIds = '';
for (let i in arr) {
brandIds += arr[i].brand_id + ',';
}
$('#agency_brands_filter_value').val(brandIds);
},
})
let cols = [
{type: 'checkbox', fixed: true},
{
field: 'supplier_code', title: '供应商编码', align: 'center', width: 90, templet: function (data) {
return "<a ew-href='/supplier/SupplierDetail?view=iframe&supplier_id=" + data.supplier_id +
"' class='list-href' ew-title='供应商详情 - " + data.supplier_code + "'>" + data.supplier_code + "</a>"
}
},
{field: 'group_code', title: '集团编码', align: 'center', width: 90},
{
field: 'supplier_name', title: '供应商名称', align: 'left', width: 180, templet: function (data) {
let supplierName = data.supplier_name;
if (data.has_attachment_expired === 1) {
supplierName += " <i class='layui-icon layui-icon-notice' style='color: #FF5722;' title='存在已过期附件'></i>";
}
if (data.status === -3) {
return "<span title='" + data.block_reason + "'>" + supplierName + "</span>"
} else {
return supplierName;
}
}
},
{field: 'supplier_group', title: '供应商性质', align: 'center', width: 115},
{field: 'company_nature', title: '公司实际性质', align: 'center', width: 125},
{
field: 'level', title: '等级', align: 'center', width: 60, templet: function (d) {
return d.level ? d.level : '-';
}
},
{field: 'region_name', title: '区域', align: 'center', width: 60},
{
field: 'stockup_type', title: '合作类型', align: 'center', width: 120, templet: function (data) {
return "<span title='" + data.stockup_type + "'>" + data.stockup_type + "</span>"
}
},
{field: 'purchase_type_name', title: '代购类型', align: 'center', width: 80},
{
field: 'has_quality_assurance_agreement',
title: '品质协议',
align: 'center',
width: 80,
},
{
field: 'has_cooperation_agreement',
title: '平台合作协议',
align: 'center',
width: 120,
},
{
field: 'has_yunxin_agreement',
title: '采购合作框架协议',
align: 'center',
width: 140,
},
//启用芯链账号
{
field: 'has_supplier_account',
title: '启用芯链账号',
align: 'center',
width: 120,
templet: function (data) {
return data.yunxin_account ? ( data.yunxin_account.a_status == 1?'是':'否') : '否';
}
},
//通过芯链上传合同
{
field: 'has_order_contract',
title: '通过芯链上传合同',
align: 'center',
width: 120,
templet: function (data) {
return data.has_order_contract == 1 ? '是' : '否';
}
},
{
field: 'channel_username', title: '采购员', align: 'center', width: 130, templet: function (data) {
if (data.resign_channel_username) {
if (data.on_job_channel_username) {
return `<span>${data.on_job_channel_username}</span>` + `,<span style="color: #D7D7D7">${data.resign_channel_username}</span>`;
} else {
return `<span style="color: #D7D7D7">${data.resign_channel_username}</span>`
}
} else {
return `<span>${data.on_job_channel_username}</span>`;
}
}
},
{
field: 'is_entity', title: '实体名单', align: 'center', width: 80, templet: function (data) {
let color = '';
switch (data.is_entity) {
case 1:
color = '#FF0000';
break;
case 0:
color = '#FFA500';
break;
case -2:
color = '#ff0000';
break;
default:
color = '';
}
return '<span style="color: ' + color + ';" title="' + data.disable_reason + '">' + data.is_entity_name + '</span>';
}
},
{
field: 'status_name', title: '状态', align: 'center', width: 80, templet: function (data) {
let statusHtml = '';
let color = '';
let title = '';
switch (data.status) {
case 3:
color = 'red';
title = data.reject_reason;
break;
case -3:
color = 'red';
title = data.block_reason;
break;
case -2:
color = 'red';
title = data.disable_reason;
break;
}
statusHtml = '<span class="audit-status-hover" data-status="' + data.status + '" data-supplier-id="' + data.supplier_id + '" style="cursor: pointer; color: ' + color + ';" title="' + title + '">' + data.status_name + '</span>';
return statusHtml;
}
},
{field: 'supplier_source_name', title: '供应商来源', align: 'center', width: 120},
{field: 'reverse_purchaser', title: '逆向采购员', align: 'center', width: 100},
{field: 'last_update_name', title: '最新修改人', align: 'center', width: 110},
{field: 'sign_com_name', title: '签约公司', align: 'center', width: 150},
{
field: 'contact_num', title: '联系人', align: 'center', width: 70, templet: function (data) {
return "<a ew-href='/supplier/SupplierDetail?view=iframe&tab=contact&supplier_id=" + data.supplier_id +
"' class='list-href' ew-title='供应商详情 - " + data.supplier_code + "' title='点击跳转查看联系人列表'>" + data.contact_num + "</a>"
}
},
{field: 'purchase_username', title: '数据维护员', align: 'center', width: 110},
{field: 'yunxin_channel_username', title: '线上采购员', align: 'center', width: 110},
{
field: 'inventory_channel_username', title: '数据跟单员', align: 'center', width: 130, templet: function (data) {
if (data.inventory_resign_channel_username) {
if (data.inventory_on_job_channel_username) {
return `<span>${data.inventory_on_job_channel_username}</span>` + `,<span style="color: #D7D7D7">${data.inventory_resign_channel_username}</span>`;
} else {
return `<span style="color: #D7D7D7">${data.inventory_resign_channel_username}</span>`
}
} else {
return `<span>${data.inventory_on_job_channel_username}</span>`;
}
}
},
{field: 'has_sku', title: 'SKU上传', align: 'center', width: 80},
{
field: 'uploaded_sku', title: 'SKU合作', align: 'center', width: 80, templet: function (data) {
return data.uploaded_sku > 0 ? '是' : '否';
}
},
{field: 'average_sku_num', title: '日均上架数', align: 'center', width: 100},
{
field: 'is_sku_expire', title: '商品是否过期', align: 'center', width: 130, templet: function (data) {
if (Number(data.sku_expired_in_days) === 1000) {
return '无SKU';
}
return data.sku_expired_in_days > 0 ? '<span style="color: red;"></span>' : '否';
}
},
{
field: 'sku_expired_in_days', title: '商品过期天数', align: 'center', width: 130, templet: function (data) {
if (Number(data.sku_expired_in_days) === 1000) {
return '无SKU';
}
if (data.sku_expired_in_days > 0) {
return '<span style="color: red;">' + data.sku_expired_in_days + '</span>';
}
return data.sku_expired_in_days || 0;
}
},
{
field: 'cp_time_day', title: '有效期最高天数', align: 'center', width: 180, templet: function (data) {
let cpTime = data.cp_time_day == -1 ? '无限制' : data.cp_time_day + '天';
let futuresCpTime = data.futures_cp_time_day == -1 ? '无限制' : data.futures_cp_time_day + '天';
return '现货 : ' + cpTime + ' | 期货 : ' + futuresCpTime;
}
},
{field: 'create_name', title: '创建人', align: 'center', width: 70},
{field: 'create_user_department_name', title: '创建部门', align: 'center', width: 100},
{field: 'update_time', title: '最近修改时间', align: 'center', width: 145},
{field: 'supplier_type_name', title: '供应商类别', align: 'center', width: 110},
{field: 'create_time', title: '创建时间', align: 'center', width: 145},
{field: 'sku_create_time', title: '首次上传sku时间', align: 'center', width: 145},
{field: 'last_upload_sku_time', title: '最新上传sku时间', align: 'center', width: 145},
];
cols.push(
);
// 列显示设置 - 从后端Redis hash渲染
let colSettingsData = <?php echo $colSettings; ?>;
let colSettingsUserId = '<?php echo e(request()->user->userId); ?>';
let colSettingsPageKey = 'supplier_list';
function applyColSettings() {
if (colSettingsData && Object.keys(colSettingsData).length > 0) {
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && colSettingsData[field] !== undefined) {
cols[i].hide = !colSettingsData[field];
}
}
}
}
applyColSettings();
table.render({
elem: '#list'
, url: '/api/supplier/GetSupplierList'
, method: 'post'
, size: 'sm'
, limit: 20
, cellMinWidth: 50 //全局定义常规单元格的最小宽度
, where: whereCondition
, loading: true
, first: true //不显示首页
, last: false //不显示尾页
, cols: [cols]
, id: 'list'
, page: {}
, done: function (res, curr, count) {
//得到当前页码
currentPage = curr;
res.data.forEach(function (item, index) {
if (item.status === -3) {
//禁用复选框,设置不可选中标识,将该行设置为阴影色
var tr = $(".layui-table tr[data-index=" + index + "]");
tr.find("input[type='checkbox']").prop('disabled', true);
tr.find("input[type='checkbox']").next().addClass('layui-btn-disabled');
tr.find('.layui-form-checkbox').addClass('layui-hide');
tr.css("color", "#A9A5A5");
tr.addClass('block-class')
}
});
// 绑定审核状态悬停事件
bindAuditStatusHover();
}
});
// 点击行checkbox选中
$(document).on("click", ".layui-table-body table.layui-table tbody tr", function () {
let index = $(this).attr('data-index');
let tableBox = $(this).parents('.layui-table-box');
let tableDiv = null;
if (tableBox.find(".layui-table-fixed.layui-table-fixed-l").length > 0) {
tableDiv = tableBox.find(".layui-table-fixed.layui-table-fixed-l");
} else {
tableDiv = tableBox.find(".layui-table-body.layui-table-main");
}
let checkCell = tableDiv.find("tr[data-index=" + index + "]").find("td div.laytable-cell-checkbox div.layui-form-checkbox I");
if (checkCell.length > 0) {
checkCell.click();
}
});
$(document).on("click", "td div.laytable-cell-checkbox div.layui-form-checkbox", function (e) {
e.stopPropagation();
});
//监听复选框事件,被选中的行高亮显示
table.on('checkbox(list)', function (obj) {
//拉黑就不用变色了
if (obj.data.status === -3) {
return
}
if (obj.checked === true && obj.type === 'all') {
//点击全选,拉黑的不用选上
$('.layui-table-body table.layui-table tbody tr:not(.block-class)').addClass('layui-table-click');
$('.layui-table-body table.layui-table tbody').find('.block-class').find('.layui-form-checkbox').remove();
$('.layui-table-body table.layui-table tbody tr .block-class').addClass('layui-table-click');
} else if (obj.checked === false && obj.type === 'all') {
//点击全不选
$('.layui-table-body table.layui-table tbody tr').removeClass('layui-table-click');
} else if (obj.checked === true && obj.type === 'one') {
//点击单行
if (obj.checked === true) {
obj.tr.addClass('layui-table-click');
} else {
obj.tr.removeClass('layui-table-click');
}
} else if (obj.checked === false && obj.type === 'one') {
//点击全选之后点击单行
if (obj.tr.hasClass('layui-table-click')) {
obj.tr.removeClass('layui-table-click');
}
}
});
//保存需要刷新的页面数据
function saveRefreshData(type, supplierId = 0) {
admin.putTempData("needFreshDetail_supplier_id=" + supplierId, 1);
}
//列设置
$("#col_setting").click(function () {
let html = '<div style="padding: 15px;">';
html += '<div style="margin-bottom: 10px;">';
html += '<button type="button" class="layui-btn layui-btn-xs layui-btn-info" id="col_select_all">全选</button>';
html += '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="col_invert_select">反选</button>';
html += '</div>';
html += '<div style="max-height: 600px; overflow-y: auto;">';
html += '<form class="layui-form" lay-filter="colSettingForm">';
for (let i = 0; i < cols.length; i++) {
if (cols[i].type === 'checkbox') continue;
let field = cols[i].field;
let title = cols[i].title || '';
let checked = cols[i].hide ? '' : 'checked';
html += '<div class="layui-form-item" style="display:inline-block;width:33%;margin-bottom:5px;">';
html += '<input type="checkbox" name="' + field + '" lay-skin="primary" title="' + title + '" ' + checked + '>';
html += '</div>';
}
html += '</form></div></div>';
layer.open({
type: 1,
title: '显示列设置',
area: ['600px', '600px'],
content: html,
btn: ['确定', '取消'],
success: function (layero, index) {
form.render('checkbox', 'colSettingForm');
//全选
layero.find('#col_select_all').on('click', function () {
layero.find('input[type="checkbox"]').prop('checked', true);
form.render('checkbox', 'colSettingForm');
});
//反选
layero.find('#col_invert_select').on('click', function () {
layero.find('input[type="checkbox"]').each(function () {
$(this).prop('checked', !$(this).is(':checked'));
});
form.render('checkbox', 'colSettingForm');
});
},
yes: function (index, layero) {
let settings = {};
let checkboxes = layero.find('input[type="checkbox"]');
checkboxes.each(function () {
let name = $(this).attr('name');
let checked = $(this).is(':checked');
settings[name] = checked;
});
//保存到后端Redis
$.ajax({
url: '/api/external/SaveColSettings',
type: 'post',
data: {
user_id: colSettingsUserId,
page_key: colSettingsPageKey,
settings: JSON.stringify(settings)
},
dataType: 'json',
async: false
});
colSettingsData = settings;
for (let i = 0; i < cols.length; i++) {
let field = cols[i].field;
if (field && settings[field] !== undefined) {
cols[i].hide = !settings[field];
}
}
table.reload('list', {
cols: [cols],
page: {curr: currentPage},
where: whereCondition
});
layer.close(index);
}
});
});
//新增供应商弹窗
$("#add_supplier").click(function () {
index.openTab({
title: '新增供应商',
url: '/supplier/AddSupplier?view=iframe',
end: function () {
// insTb.reload();
}
});
})
//同步金蝶的手动操作
$("#sync_supplier_to_erp").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
let supplierId = data[0].supplier_id;
let res = ajax('/api/supplier/SyncToErp', {supplier_id: supplierId})
if (res.err_code === 0) {
table.reload('list')
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
} else {
layer.msg(res.err_msg, {icon: 5})
}
}
});
//同步一体化的手动操作
$("#sync_supplier_to_united").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
let supplierId = data[0].supplier_id;
let res = ajax('/api/supplier/SyncToUnited', {supplier_id: supplierId})
if (res.err_code === 0) {
table.reload('list')
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
} else {
layer.msg(res.err_msg, {icon: 5})
}
}
});
//审批供应商弹窗
$("#audit_supplier").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
let supplierId = data[0].supplier_id;
let status = data[0].status;
let canReviewSupplier = <?php echo e(checkPerm("ReviewSupplier")?1:0); ?>;
if (status === 4){
layer.msg('该供应商状态为待确认,需要先确认客户转化供应商', {icon: 5});
return;
}
if (canReviewSupplier === 0 && status === -1) {
layer.msg('你没有复审供应商的权限', {icon: 5})
return
}
if (status === 0) {
layer.msg('该供应商还没有申请审核', {icon: 5});
return;
}
if (status !== 1 && status !== -1) {
layer.msg('该供应商已经被审核', {icon: 5});
return;
}
let checkAuditMsg = checkCanAudit(supplierId);
if (checkAuditMsg !== '') {
layer.msg(checkAuditMsg, {icon: 5});
return
}
layer.open({
type: 2,
content: '/supplier/AuditSupplier?view=iframe&supplier_id=' + supplierId,
area: ['800px', '65%'],
title: '审核供应商',
end: function () {
table.reload('list');
saveRefreshData('detail', supplierId)
supplierStatistics();
}
});
}
})
//批量修改(分配)数据维护员
$("#batch_allocate_purchase_user").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
let supplierIds = Array.from(data, ({supplier_id}) => supplier_id);
supplierIds = supplierIds.join(',');
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
let status = Array.from(data, ({status}) => status);
//分配采购员的多选操作,需要先去判断是否存在审核中的供应商,存在的话,要提示
if (status.indexOf(1) !== -1 || status.indexOf(-3) !== -1 || status.indexOf(-1) !== -1) {
layer.msg('选择的供应商里,存在审核中/待复审/黑名单的供应商,无法分配数据维护员', {icon: 5})
return
}
layer.open({
type: 2,
content: '/supplier/BatchAllocatePurchaseUser?view=iframe&supplier_ids=' + supplierIds,
area: ['600px', '70%'],
title: '批量分配数据维护员',
end: function () {
table.reload('list');
supplierStatistics();
}
});
}
})
//申请进入审核中的状态
$("#batch_apply_in_review_supplier").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
let supplierIds = Array.from(data, ({supplier_id}) => supplier_id);
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
supplierIds = supplierIds.join(',');
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
let status = Array.from(data, ({status}) => status);
let canApplyInReview = true;
$.each(status, function (index, value) {
if (value !== 0) {
canApplyInReview = false;
}
});
if (!canApplyInReview) {
layer.msg('选择的供应商里,存在非待提审状态的供应商,无法申请审核', {icon: 5})
return;
}
//还要去事先检测供应商信息是否完整
let checkApplyMsg = checkCanApplyInReview(supplierIds);
if (checkApplyMsg !== '') {
return false;
}
layer.open({
type: 2,
content: '/supplier/BatchApplyInReviewSupplier?view=iframe&supplier_ids=' + supplierIds,
area: ['800px', '70%'],
title: '申请审核供应商',
end: function () {
table.reload('list');
supplierStatistics();
}
});
}
})
//分配采购员,现在改成可以批量的了
$("#allocate_channel_user").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
let status = Array.from(data, ({status}) => status);
let canApplyInReview = true;
$.each(status, function (index, value) {
console.log(value);
if (value === -1 || value === 1) {
canApplyInReview = false;
}
});
if (!canApplyInReview) {
layer.msg('选择的供应商里,存在 审核中/待复审 状态的供应商,无法分配采购员', {icon: 5})
} else {
let supplierIds = Array.from(data, ({supplier_id}) => supplier_id);
if (supplierIds.length > 20) {
layer.msg('最多一次操作20个供应商', {icon: 5})
return;
}
supplierIds = supplierIds.join(',');
layer.open({
type: 2,
content: '/supplier/AllocateChannelUser?view=iframe&supplier_ids=' + supplierIds,
area: ['80%', '80%'],
title: '新增采购员',
end: function () {
table.reload('list');
supplierStatistics();
}
});
}
}
})
$("#batch_allocate_reverse_purchaser").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
let supplierIds = Array.from(data, ({supplier_id}) => supplier_id);
supplierIds = supplierIds.join(',');
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
let hasCrmSupplier = data.some(function (item) {
return Number(item.supplier_source) === 2;
});
if (hasCrmSupplier) {
layer.msg('CRM来源的供应商不允许分配逆向采购员', {icon: 5})
return;
}
layer.open({
type: 2,
content: '/supplier/BatchAllocateReversePurchaser?view=iframe&supplier_ids=' + supplierIds,
area: ['700px', '70%'],
title: '批量分配逆向采购员',
end: function () {
table.reload('list');
supplierStatistics();
}
});
}
})
//禁用供应商
$("#disable_supplier").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
const status = data[0].status;
const hasSku = data[0].sku_num;
const needReview = data[0].need_review;
if (needReview === 1 && status !== 0) {
layer.msg("该供应商还没有进行复审,不能直接禁用;", {icon: 5})
return;
}
if ((status === 3 || status === 2 || status === 0) && !hasSku) {
let supplierId = data[0].supplier_id;
layer.open({
type: 2,
content: '/supplier/DisableSupplier?view=iframe&supplier_id=' + supplierId,
area: ['700px', '70%'],
title: '禁用供应商',
end: function () {
saveRefreshData('detail', supplierId)
table.reload('list');
supplierStatistics();
}
});
} else {
layer.msg('只有待提审,已通过或者未通过状态,并且没有sku的供应商才可以禁用', {'icon': 5});
}
}
});
//转正供应商
$("#change_supplier_is_type").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
const isType = data[0].is_type;
if (isType === 0) {
layer.msg('该供应商已经是正式供应商', {'icon': 5});
return
}
layer.confirm('如果转成正式供应商,会进入审核中状态,需要补全相关信息申请审核,确定要转正该供应商吗?', function (index) {
let supplierId = data[0].supplier_id;
let res = ajax('/api/supplier/ChangeSupplierIsType', {supplier_id: supplierId, is_type: 0})
if (res.err_code === 0) {
saveRefreshData('detail', supplierId)
table.reload('list')
supplierStatistics();
layer.closeAll();
layer.msg(res.err_msg, {icon: 6})
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
}
});
//加入黑名单
$("#block_supplier").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
const status = data[0].status;
if (status === -3) {
layer.msg('该供应商已经在黑名单', {icon: 5});
return false;
}
if ((status === -1 || status === 1)) {
layer.msg('审核中/待复审状态的供应商无法加入黑名单', {icon: 5});
return false;
} else {
let supplierId = data[0].supplier_id;
layer.open({
type: 2,
content: '/supplier/BlockSupplier?view=iframe&supplier_id=' + supplierId,
area: ['700px', '70%'],
title: '加入黑名单',
end: function () {
saveRefreshData('detail', supplierId)
table.reload('list');
supplierStatistics();
}
});
}
}
});
//共用供应商申请
$("#apply_supplier_share").click(function () {
layer.open({
type: 2,
content: '/supplier_share_apply/ApplySupplierShare?view=iframe',
area: ['700px', '80%'],
title: '申请共用供应商',
end: function () {
}
});
});
//共用供应商审核
$("#audit_supplier_share_apply").click(function () {
layer.open({
type: 2,
content: '/supplier_share_apply/AuditSupplierShareApply?view=iframe',
area: ['70%', '80%'],
title: '共用申请审核',
end: function () {
}
});
});
//批量修改供应商标签
$("#batch_add_tags").click(function () {
layer.open({
type: 2,
content: '/supplier_tag/BatchAddTag?view=iframe',
area: ['70%', '90%'],
title: '供应商标签添加',
end: function () {
}
});
});
//设置SKU采购
$("#batch_allocate_yunxin_channel_user").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
let supplierIds = Array.from(data, ({supplier_id}) => supplier_id);
supplierIds = supplierIds.join(',');
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
layer.open({
type: 2,
content: '/supplier/BatchAllocateYunxinChannelUser?view=iframe&supplier_ids=' + supplierIds,
area: ['80%', '80%'],
title: '批量配置线上采购员',
end: function () {
table.reload('list');
}
});
}
})
//查询供应商
$("#query_supplier").click(function () {
layer.open({
type: 2,
content: '/supplier/QuerySupplier?view=iframe',
area: ['70%', '30%'],
title: '查询供应商',
end: function () {
}
});
})
//交接供应商
$("#transfer_supplier").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
let supplierId = data[0].supplier_id;
layer.open({
type: 2,
content: '/supplier/TransferSupplier?view=iframe&supplier_id=' + supplierId,
area: ['50%', '70%'],
title: '交接供应商',
end: function () {
table.reload('list');
}
});
}
})
//确认客户转化供应商
$("#confirm_crm_supplier").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
if (data.length > 1) {
layer.msg('该操作不支持多选', {icon: 5})
return;
}
const status = data[0].status;
const source = data[0].supplier_source;
// 前置条件:供应商状态为待确认(4),供应商来源为CRM客户转化供应商(2)
if (status !== 4 || source !== 2) {
layer.msg('只有状态为"待确认"且来源为"CRM客户转化供应商"的供应商才可以操作', {icon: 5});
return;
}
let supplierId = data[0].supplier_id;
layer.open({
type: 2,
content: '/supplier/ConfirmCrmSupplier?view=iframe&supplier_id=' + supplierId,
area: ['70%', '720px'],
title: '转化供应商确认',
end: function () {
table.reload('list');
}
});
}
})
//判断是否要展示有全部离职采购员的供应商,有的话提示
if (!admin.getTempData('has_pop_up_all_channel_user_supplier_tips')) {
$.ajax({
url: '/api/supplier/checkHasAllResignedChannelUserSupplier',
type: 'POST',
async: true,
dataType: 'json',
timeout: 20000,
success: function (res) {
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
layer.confirm('<div style="width: 400px;height: 50px;"><p>属于你部门的正式供应商有 <span style="color: red;">' + res.data + '</span> 没有有效采购员(采购员全离职)<p><p>请尽快分配采购员进行维护</p></div>', {
btn: ['立即前往', '关闭提示'], //按钮
offset: 'rb',
}, function () {
admin.putTempData('has_pop_up_all_channel_user_supplier_tips', 1);
layer.closeAll();
index.openTab({
title: '供应商列表',
url: '/supplier/SupplierList?view=iframe&source_type=all_channel_user_resigned',
end: function () {
}
});
}, function () {
admin.putTempData('has_pop_up_all_channel_user_supplier_tips', 1);
layer.closeAll();
});
} else {
}
}
},
error: function () {
layer.msg('网络错误', {icon: 5});
}
});
}
let formValue = {};
$('#export_supplier').click(function () {
window.open('/api/supplier/exportSupplier', '_blank');
});
//点击查询按钮
form.on('submit(load)', function (data) {
formValue = data.field;
//罗盘选项会跳回全部
clearTypeFilter();
$('#total').attr('class', 'main_filter layui-badge layui-bg-green');
whereCondition.source_type = 'all';
initCondition.source_type = whereCondition.source_type;
whereCondition = $.extend(false, initCondition, data.field);
//执行重载
table.reload('list', {
page: {
curr: 1
}
, where: whereCondition
});
supplierStatistics();
return false;
});
//点击重置按钮
form.on('submit(reset)', function (data) {
layer.load(1);
location.reload();
});
})
;
//检查是否能够审核,因为审核人只能审自己相关部门人员修改的供应商记录
function checkCanAudit(supplierId) {
let url = '/api/supplier/CheckCanAuditSupplier?supplier_id=' + supplierId;
let res = ajax(url);
if (res.err_code !== 0) {
return res.err_msg;
} else {
return '';
}
}
function checkCanApplyInReview(supplierIds) {
let url = '/api/supplier/CheckCanApplyInReview?supplier_ids=' + supplierIds;
let res = ajax(url);
if (res.err_code !== 0) {
let errMsg = res.err_msg;
let msg = '';
$.each(errMsg.split('|'), function (index, value) {
msg += "<span>" + value + "</span><br>"
});
layer.msg(msg, {icon: 5})
return false;
} else {
return '';
}
}
function clearTypeFilter() {
$('.main_filter').attr('class', 'main_filter');
}
// 绑定审核状态悬停事件
function bindAuditStatusHover() {
let auditFlowCache = {}; // 缓存审核流程数据
$('.audit-status-hover').hover(
function() {
let $this = $(this);
let supplierId = $this.data('supplier-id');
let status = $this.data('status');
// 审核中(1)和待确认(4)状态显示审批节点
if (status !== 1 && status !== 4) {
return;
}
// 如果已经有缓存,直接显示
if (auditFlowCache[supplierId]) {
showAuditFlowTips($this, auditFlowCache[supplierId]);
return;
}
// 请求审核流程数据
$.ajax({
url: '/api/supplier/GetAuditFlow',
type: 'get',
data: {supplier_id: supplierId},
dataType: 'json',
success: function(res) {
if (res.err_code === 0 && res.data) {
auditFlowCache[supplierId] = res.data;
showAuditFlowTips($this, res.data);
}
}
});
},
function() {
// 鼠标移出时关闭tips
layer.closeAll('tips');
}
);
}
// 显示审核流程时间线
function showAuditFlowTips($element, auditData) {
if (auditData.length === 0) {
return;
}else{
let timelineHtml = buildAuditTimeline(auditData);
layer.tips(timelineHtml, $element, {
tips: [3, '#009688'],
time: 0,
area: ['auto', 'auto'],
maxWidth: 550
});
}
}
// 构建审核时间线HTML - 横向展示
function buildAuditTimeline(auditData) {
let nodeList = auditData.node_list || [];
let currentNodeId = auditData.current_node;
let approvalStatus = auditData.approval_status;
let html = '<div style="padding: 20px; background: #fff; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); min-width: 500px;">';
html += '<div style="display: flex; justify-content: space-between; align-items: flex-start;">';
nodeList.forEach(function(node, index) {
let isPassed = node.approval_status == 1;
let isRejected = node.approval_status == 2;
let isWaiting = node.approval_status == 0;
// 确定图标和颜色
let iconNumber = index + 1;
let iconBgColor = '';
let iconTextColor = '#fff';
let nodeTitle = '';
if (isPassed) {
iconBgColor = '#5FB878';
nodeTitle = '审核通过';
} else if (isRejected) {
iconBgColor = '#FF5722';
nodeTitle = '审核拒绝';
} else if (isWaiting) {
iconBgColor = '#D2D2D2';
nodeTitle = '待审核';
}
// 每个节点
html += '<div style="flex: 1; text-align: center; position: relative;">';
// 圆形图标
html += '<div style="width: 40px; height: 40px; border-radius: 50%; background: ' + iconBgColor + '; color: ' + iconTextColor + '; line-height: 40px; font-size: 18px; font-weight: bold; margin: 0 auto 10px;">';
html += iconNumber;
html += '</div>';
// 节点标题
html += '<div style="font-weight: bold; margin-bottom: 8px; font-size: 14px; color: #333;">' + nodeTitle + '</div>';
// 节点详情
html += '<div style="color: #666; font-size: 12px; line-height: 1.8; text-align: left; padding: 0 10px;">';
html += '<div>审核人:' + (node.approval_names || '-') + '</div>';
html += '<div>审核结果:' + (node.approval_status_text || '-') + '</div>';
html += '<div>审核时间:' + (node.update_time || '-') + '</div>';
if (node.remark) {
html += '<div>附加说明:' + node.remark + '</div>';
}
html += '</div>';
html += '</div>';
// 连接线(最后一个节点不需要)
if (index < nodeList.length - 1) {
let lineColor = isPassed ? '#5FB878' : '#D2D2D2';
html += '<div style="flex: 0 0 50px; padding-top: 20px;">';
html += '<div style="height: 2px; background: ' + lineColor + ';"></div>';
html += '</div>';
}
});
html += '</div>';
html += '</div>';
return html;
}
</script>
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