|
|
@@ -35,11 +35,19 @@
|
|
|
.sch-drag{width:36px;text-align:center;color:#c2cad6;cursor:move;-webkit-user-select:none;-ms-user-select:none;user-select:none;}
|
|
|
.sch-drag i{font-size:14px;}
|
|
|
.sch-drag:hover{color:#2f6feb;}
|
|
|
+.sch-drag.is-locked{color:#dde3ec;cursor:default;}
|
|
|
+.sch-drag.is-locked:hover{color:#dde3ec;}
|
|
|
+/* 已完成计划沉底:整行淡化,并与未完成区隔开 */
|
|
|
+.sch-table tbody tr.row-done{background:#fcfcfd;}
|
|
|
+.sch-table tbody tr.row-done:hover{background:#f7f9fc;}
|
|
|
+.sch-table tbody tr.row-done .order-sn{color:#7d8797;font-weight:400;}
|
|
|
+.sch-table tbody tr.row-done .seq-badge{background:#eef1f6;color:#c3cbd7;}
|
|
|
+.sch-table tbody tr.done-first td{border-top:2px solid #e6eaf0;}
|
|
|
.drag-place{height:42px;background:#f2f7ff;border:1px dashed #a9c3f5;}
|
|
|
.seq-badge{display:inline-block;min-width:24px;height:24px;line-height:24px;padding:0 6px;border-radius:12px;background:#eef2f8;color:#5b6472;font-size:12px;font-weight:600;text-align:center;}
|
|
|
.is-head .seq-badge{background:#2f6feb;color:#fff;}
|
|
|
.order-sn{font-weight:600;color:#2c3444;}
|
|
|
-.order-sn .cur{display:inline-block;margin-left:8px;padding:0 7px;line-height:18px;border-radius:9px;background:#dfeaff;color:#2f6feb;font-size:11px;font-weight:400;vertical-align:1px;}
|
|
|
+.order-sn + .cur{display:inline-block;margin-left:8px;padding:0 7px;line-height:18px;border-radius:9px;background:#dfeaff;color:#2f6feb;font-size:11px;font-weight:400;vertical-align:1px;}
|
|
|
.qty-num{position:relative;height:17px;line-height:17px;font-size:12px;color:#98a2b3;}
|
|
|
.qty-num b{font-size:14px;font-weight:600;color:#2c3444;}
|
|
|
.qty-num span{margin-left:2px;}
|
|
|
@@ -55,7 +63,6 @@
|
|
|
.st-wait{background:#f2f4f8;color:#8a94a6;}
|
|
|
.st-doing{background:#eaf2ff;color:#2f6feb;}
|
|
|
.st-done{background:#e8f7ef;color:#1f9d63;}
|
|
|
-.st-none{background:#f2f4f8;color:#b6bfcc;}
|
|
|
.sch-op a{display:inline-block;width:26px;height:26px;line-height:26px;border-radius:4px;text-align:center;color:#8a94a6;}
|
|
|
.sch-op a:hover{background:#fff1f0;color:#e5484d;}
|
|
|
#btnSave.sch-save-dirty{box-shadow:0 0 0 3px rgba(47,111,235,.18);}
|
|
|
@@ -83,7 +90,7 @@
|
|
|
<div class="sch-panel">
|
|
|
<div class="sch-panel-head">
|
|
|
<span class="title"><i class="fa fa-list-ol"></i>${text('生产队列')}</span>
|
|
|
- <span class="tip">${text('按住左侧手柄拖动,越靠上越先生产,与计划日期无关;未排产的计划不投入生产,需先「新增排产」加入队列')}</span>
|
|
|
+ <span class="tip">${text('按住左侧手柄拖动,越靠上越先生产,与计划日期无关;已完成的计划自动沉到队尾(按完成先后排列、不参与排序);未排产的计划不投入生产,需先「新增排产」加入队列')}</span>
|
|
|
<span class="dirty" id="dirtyTip" style="display:none;">
|
|
|
<i class="fa fa-exclamation-circle"></i> ${text('排序未保存')}</span>
|
|
|
</div>
|
|
|
@@ -248,13 +255,19 @@ function inQueue(id){
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-function planStatus(r){
|
|
|
+// 状态按队列位置说话:只有队头那一条在产 → 生产中;
|
|
|
+// 其余没做满的一律待生产(不管它已经做了几件、是不是 0);做满的 → 已完成。
|
|
|
+// idx 为该行在队列中的下标,不传时按“非队头”处理。
|
|
|
+function planStatus(r, idx){
|
|
|
var nums = schNum(r.nums), done = schNum(r.produced);
|
|
|
- if(nums <= 0){ return {key: 'none', text: '${text("未定量")}'}; }
|
|
|
- if(done >= nums){ return {key: 'done', text: '${text("已完成")}'}; }
|
|
|
- if(done > 0){ return {key: 'doing', text: '${text("生产中")}'}; }
|
|
|
+ if(nums > 0 && done >= nums){ return {key: 'done', text: '${text("已完成")}'}; }
|
|
|
+ if(idx === 0){ return {key: 'doing', text: '${text("生产中")}'}; }
|
|
|
return {key: 'wait', text: '${text("待生产")}'};
|
|
|
}
|
|
|
+// 计划是否已做完:做满的计划统一沉到队尾
|
|
|
+function planDone(r){
|
|
|
+ return planStatus(r).key === 'done';
|
|
|
+}
|
|
|
function markDirty(flag){
|
|
|
isDirty = !!flag;
|
|
|
$('#dirtyTip').toggle(isDirty);
|
|
|
@@ -291,7 +304,7 @@ function loadSchedule(){
|
|
|
function renderCards(){
|
|
|
var total = scheduleState.length, done = 0, doing = 0;
|
|
|
for(var i = 0; i < scheduleState.length; i++){
|
|
|
- var s = planStatus(scheduleState[i]);
|
|
|
+ var s = planStatus(scheduleState[i], i);
|
|
|
if(s.key === 'done'){ done++; }
|
|
|
if(s.key === 'doing'){ doing++; }
|
|
|
}
|
|
|
@@ -318,7 +331,7 @@ function qtyHtml(r){
|
|
|
}
|
|
|
|
|
|
function renderSchedule(){
|
|
|
- var rows = [];
|
|
|
+ var rows = [], doneSeen = false;
|
|
|
if(!scheduleState.length){
|
|
|
$('#queueBody').empty();
|
|
|
$('#schEmpty').show().html('<div class="sch-empty"><i class="fa fa-inbox"></i>'
|
|
|
@@ -326,9 +339,19 @@ function renderSchedule(){
|
|
|
}else{
|
|
|
$('#schEmpty').hide();
|
|
|
for(var i = 0; i < scheduleState.length; i++){
|
|
|
- var r = scheduleState[i], st = planStatus(r), isHead = (i === 0);
|
|
|
- rows.push('<tr data-id="' + schEsc(r.id) + '"' + (isHead ? ' class="is-head"' : '') + '>');
|
|
|
- rows.push('<td class="sch-drag" title="${text("按住拖动排序")}"><i class="fa fa-bars"></i></td>');
|
|
|
+ var r = scheduleState[i], st = planStatus(r, i), isHead = (i === 0);
|
|
|
+ var isDone = (st.key === 'done');
|
|
|
+ var cls = [];
|
|
|
+ if(isHead){ cls.push('is-head'); }
|
|
|
+ if(isDone){
|
|
|
+ cls.push('row-done');
|
|
|
+ if(!doneSeen){ cls.push('done-first'); doneSeen = true; }
|
|
|
+ }
|
|
|
+ rows.push('<tr data-id="' + schEsc(r.id) + '"'
|
|
|
+ + (cls.length ? ' class="' + cls.join(' ') + '"' : '') + '>');
|
|
|
+ rows.push(isDone
|
|
|
+ ? '<td class="sch-drag is-locked" title="${text("已完成,不参与排序")}"><i class="fa fa-lock"></i></td>'
|
|
|
+ : '<td class="sch-drag" title="${text("按住拖动排序")}"><i class="fa fa-bars"></i></td>');
|
|
|
rows.push('<td style="text-align:center;"><span class="seq-badge">' + (i + 1) + '</span></td>');
|
|
|
rows.push('<td><span class="order-sn">' + schEsc(r.orderSn) + '</span>'
|
|
|
+ (isHead ? '<span class="cur">${text("当前计划")}</span>' : '') + '</td>');
|
|
|
@@ -364,7 +387,8 @@ function initSortable(){
|
|
|
return;
|
|
|
}
|
|
|
$body.sortable({
|
|
|
- items: '> tr',
|
|
|
+ // 已完成的行不参与拖拽,永远留在队尾
|
|
|
+ items: '> tr:not(.row-done)',
|
|
|
handle: '.sch-drag',
|
|
|
axis: 'y',
|
|
|
cursor: 'move',
|
|
|
@@ -386,17 +410,23 @@ function initSortable(){
|
|
|
$body.children('tr').each(function(){
|
|
|
order.push($(this).attr('data-id'));
|
|
|
});
|
|
|
- var next = [];
|
|
|
+ var byId = {};
|
|
|
+ for(var k = 0; k < scheduleState.length; k++){
|
|
|
+ byId[scheduleState[k].id] = scheduleState[k];
|
|
|
+ }
|
|
|
+ var next = [], doneRows = [];
|
|
|
for(var i = 0; i < order.length; i++){
|
|
|
- for(var j = 0; j < scheduleState.length; j++){
|
|
|
- if(scheduleState[j].id === order[i]){
|
|
|
- next.push(scheduleState[j]);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ var item = byId[order[i]];
|
|
|
+ if(!item){ return; }
|
|
|
+ if(planDone(item)){ doneRows.push(item); }else{ next.push(item); }
|
|
|
+ }
|
|
|
+ // 万一被拖到已完成区之后,统一收回队尾,保持已完成之间的原有先后
|
|
|
+ for(var j = 0; j < scheduleState.length; j++){
|
|
|
+ var it = scheduleState[j];
|
|
|
+ if(planDone(it) && doneRows.indexOf(it) < 0){ doneRows.push(it); }
|
|
|
}
|
|
|
- if(next.length !== scheduleState.length){ return; }
|
|
|
- scheduleState = next;
|
|
|
+ if(next.length + doneRows.length !== scheduleState.length){ return; }
|
|
|
+ scheduleState = next.concat(doneRows);
|
|
|
markDirty(true);
|
|
|
renderSchedule();
|
|
|
}
|
|
|
@@ -435,7 +465,12 @@ function openAddDialog(){
|
|
|
if(dlgRows[j].id === ids[i]){ row = dlgRows[j]; break; }
|
|
|
}
|
|
|
if(!row || inQueue(row.id)){ continue; }
|
|
|
- scheduleState.push(row);
|
|
|
+ // 插到「已完成」区之前,保证未完成的计划始终排在前面
|
|
|
+ var at = scheduleState.length;
|
|
|
+ for(var k = 0; k < scheduleState.length; k++){
|
|
|
+ if(planDone(scheduleState[k])){ at = k; break; }
|
|
|
+ }
|
|
|
+ scheduleState.splice(at, 0, row);
|
|
|
scheduleAdded[row.id] = true;
|
|
|
delete scheduleRemoved[row.id];
|
|
|
}
|