Расчитывает нужное качество из двух представленых вариантов
当前为
// ==UserScript==
// @name iks: virtonomica покупка. Смеситель.
// @namespace virtonomica
// @description Расчитывает нужное качество из двух представленых вариантов
// @include http://*virtonomica*.*/*/window/unit/equipment/*
// @include http://*virtonomica*.*/*/window/unit/supply/create/*/step2
// @version 1.16
// @grant none
// ==/UserScript==
var strCss = '.blendingTable{ width:100%; text-align:left; background-color: #EEE; border-collapse: collapse }'
+' .blendingTable th{ border:2px solid #fff }'
+' .blendingTable input{ width: 100px; text-align:right; float:right }'
+' .blendingTable span{ float:right }'
+' .blendingTableBlue{ border-color: blue }'
+' .w100{ width: 100% }';
var run = function()
{
var p = ( ( window.location.href.indexOf('supply/create') + 1 ) ? 'goods' : 'rig' ),
val = {
'goods': 'div#supply_content > table > tbody > tr.wborder > td:nth-child(8).supply_data',
'rig': 'div.content > table#mainTable.list.main_table > tbody > tr > td:nth-child(9).digits'
},
work = function() {
// Требуемое
kol_t = parseFloat( $('#quantityCorner').val().replace(/\$/g, '') );
kach_t = parseFloat( $('#topRightQuality').val() );
// В наличии
kol_n = parseFloat( $('#quantityCorner1').val().replace(/\$/g, '') );
kach_n = parseFloat( $('#topRightQuality1').val().replace(/\$/g, '') );
// Продавцы
kach_p1 = parseFloat( $('#topRightQuality2').val().replace(/\$/g, '') );
kach_p2 = parseFloat( $('#topRightQuality3').val().replace(/\$/g, '') );
n = (kol_t * ( kach_t - kach_p1 ) - kol_n * ( kach_n - kach_p1 ) ) / ( kach_p2 - kach_p1 );
if(!n || n == 'Infinity') n = 0;
$('#quantityCorner3').html(n.toFixed(1));
n = ( kol_t * ( kach_t - kach_p2 ) - kol_n * ( kach_n - kach_p2 ) ) / ( kach_p1 - kach_p2 );
if(!n || n == 'Infinity') n = 0;
$('#quantityCorner2').html(n.toFixed(1));
},
str = '<table class="blendingTable" cellpadding="4"><tr style="text-align:center">'
+'<th></th>'
+'<th>Требуемое</th>'
+'<th>В наличии</th>'
+'<th>Продавец 1</th>'
+'<th>Продавец 2</th>'
+'</tr><tr>'
+'<th style="text-align:left">Количество:</th>'
+'<th><input type="text" value="0" id="quantityCorner" /></th>'
+'<th><input type="text" value="0" id="quantityCorner1" /></th>'
+'<th><span id="quantityCorner2">0</span></th>'
+'<th><span id="quantityCorner3">0</span></th>'
+'</tr><tr>'
+'<th style="text-align:left">Качество:</th>'
+'<th><input type="text" value="0.00" id="topRightQuality" /></th>'
+'<th><input type="text" value="0.00" id="topRightQuality1" /></th>'
+'<th><input type="text" value="0.00" id="topRightQuality2" class="blendingTableBlue" /></th>'
+'<th><input type="text" value="0.00" id="topRightQuality3" /></th>'
+'</tr></table>';
if( p == 'goods' ) $( 'div#supply_content > table' ).before( str + '<br>' );
else {
$('#headerWithSeparator').after( str + '<div class="headerSeparator w100"><img src="/img/1.gif" width="1" height="1" border="0"/></div>' );
$('#quantityCorner1').val( $('#quantity_corner').html().replace(/\s+/g, '') );
$('#topRightQuality1').val( $('#top_right_quality').html() );
}
$( val[ p ] ).each(function() {
if( parseFloat( $(this).html().replace(/\s+/g, '') ) > 0 ){
$(this).css('cursor', 'pointer').click(function() {
var n = parseFloat( $(this).html().replace(/\s+/g, '') ).toFixed(2);
if( $('#topRightQuality2').hasClass('blendingTableBlue') ) {
$('#topRightQuality2').removeClass('blendingTableBlue');
$('#topRightQuality2').val(n);
$('#topRightQuality3').addClass('blendingTableBlue');
} else {
$('#topRightQuality2').addClass('blendingTableBlue');
$('#topRightQuality3').removeClass('blendingTableBlue');
$('#topRightQuality3').val(n);
}
work();
});
}
});
$('table.blendingTable input').bind("change keyup input click", function() {
if( $(this).attr('id').indexOf('quantityCorner') + 1 ) $(this).val( parseInt( $(this).val().replace(/[^0-9]/g, '') ) | 0 );
else {
var n = parseFloat( $(this).val() );
if(!n) n = 0;
$(this).val( n.toFixed(2) );
}
work();
});
}
if(window.top == window) {
$('head').append( '<style type="text/css"> ' + strCss + ' </style>'
+'<script type="text/javascript"> (' + run.toString() + ')(); </script>' );
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址