mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-23 02:45:33 +08:00
94 lines
4.1 KiB
HTML
94 lines
4.1 KiB
HTML
<!--
|
|
Copyright 2026 ShopeX (https://www.shopex.cn)
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<div class="division" id="materialDataSync">
|
|
<table>
|
|
<tbody>
|
|
<tr>
|
|
<th width="5%">仓库:</th>
|
|
<td width="17%">
|
|
<select class="materialData" name="branch_id">
|
|
<option value="">请选择</option>
|
|
<{foreach from=$branches item=item}>
|
|
<option value="<{$item.branch_id}>"><{$item.name}></option>
|
|
<{/foreach}>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<input type="hidden" class="materialData" name="id" value="-1" />
|
|
<div>统计:<span id="curTotal" style="color: red;">0</span>/<span id="total">0</span></div>
|
|
<div id="processBarBg" style="border:1px solid #999999; width:98%; height:25px;line-height:25px;padding:1px; background:#EEEEEE;">
|
|
<div style=" background:#3366cc; width:0px; padding-bottom:1px;overflow:hidden;" id='processBar'> </div>
|
|
</div>
|
|
<div class="table-action">
|
|
<{button label="开始" id="sync_btn" type="button"}>
|
|
</div>
|
|
<div id='sync-error'></div>
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
(function(){
|
|
var materialData = JSON.decode('<{$material_data|json_encode}>');
|
|
$('total').set('text', materialData.length);
|
|
$('sync_btn').addEvent('click', function() {
|
|
var branch_id = $E('select[name=branch_id]').value;
|
|
if (!branch_id) return MessageBox.error('请选择仓库');
|
|
var _parent=this;
|
|
Ex_Loader('cmdrunner',function(){
|
|
new taskrunner(materialData.map(function(){return 'index.php?app=console&ctl=admin_goodssync&act=doSyncCombination'}), {
|
|
container: $('materialDataSync'),
|
|
dataClass: '.materialData',
|
|
onLoad: function() {
|
|
_parent.disabled = true;
|
|
_parent.set('html', '<span><span>同步中...</span></span>');
|
|
},
|
|
onStart: function() {
|
|
var rowData = materialData[this.prestep];
|
|
$E('#materialDataSync input[name=id]').set('value', rowData.inner_product_id);
|
|
},
|
|
onComplete:function() {
|
|
var num=this.step/this.num*100;
|
|
$('processBar').setStyle('width',num+'%');
|
|
$('curTotal').set('text', this.step);
|
|
},
|
|
onCheck:function(message) {
|
|
if(message != '|ok.') {
|
|
var strDiv = document.createElement('DIV');
|
|
strDiv.set('text', message.slice(0, -4));
|
|
$('sync-error').appendChild(strDiv);
|
|
}
|
|
},
|
|
onError:function(text) {
|
|
if (!text) {alert('未捕获到错误信息,可能执行超时');}
|
|
_parent.set('html', '<span><span>同步失败</span></span>');
|
|
_parent.disabled = false;
|
|
if (this.iframe) this.iframe.destroy();
|
|
if (this.form) this.form.destroy();
|
|
},
|
|
onSuccess:function() {
|
|
if (this.iframe) this.iframe.destroy();
|
|
_parent.set('html', '<span><span>处理已完成</span></span>');
|
|
}
|
|
}).run();
|
|
});
|
|
});
|
|
}());
|
|
</script>
|