|
|
@@ -229,12 +229,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
}
|
|
|
});
|
|
|
try {
|
|
|
- table.bootstrapTable(stagePick ? 'showColumn' : 'hideColumn', 'state');
|
|
|
+ table.bootstrapTable((stagePick || stageAudit) ? 'showColumn' : 'hideColumn', 'state');
|
|
|
} catch (ignore) {
|
|
|
}
|
|
|
$('#btn-procuremen-pick-review').toggle(stagePick);
|
|
|
$('#btn-procuremen-pick-delete').toggle(stagePick);
|
|
|
$('#btn-procuremen-batch-finish').toggle(stagePick);
|
|
|
+ $('#btn-procuremen-audit-abandon').toggle(stageAudit);
|
|
|
|
|
|
$(document).off('click.procuremenYm', '.procuremen-ym-item').on('click.procuremenYm', '.procuremen-ym-item', function () {
|
|
|
var ym = $(this).data('ym');
|
|
|
@@ -314,7 +315,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
});
|
|
|
|
|
|
var indexInitWffTab = Controller.wffTab;
|
|
|
- var indexShowall = indexInitWffTab === 'pick';
|
|
|
+ var indexShowall = indexInitWffTab === 'pick' || indexInitWffTab === 'audit';
|
|
|
var indexShowIssued = indexInitWffTab === 'audit' || indexInitWffTab === 'confirm';
|
|
|
var indexShowPendingOnly = indexInitWffTab === 'confirm';
|
|
|
var indexShowPickedOnly = indexInitWffTab === 'confirm';
|
|
|
@@ -325,6 +326,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
.replace(/"/g, '"')
|
|
|
.replace(/'/g, ''');
|
|
|
}
|
|
|
+ function procuremenEscHtml(s) {
|
|
|
+ return String(s == null ? '' : s)
|
|
|
+ .replace(/&/g, '&')
|
|
|
+ .replace(/</g, '<')
|
|
|
+ .replace(/>/g, '>')
|
|
|
+ .replace(/"/g, '"');
|
|
|
+ }
|
|
|
+ function procuremenAutocontentCell(value, colWidth) {
|
|
|
+ if (value == null || value === '') {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ var text = String(value).replace(/\r\n/g, '\n').replace(/\n+/g, ';').trim();
|
|
|
+ if (text === '') {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ var width = colWidth != null && colWidth !== '' ? String(colWidth) : '250';
|
|
|
+ if (/^\d+$/.test(width)) {
|
|
|
+ width = width + 'px';
|
|
|
+ }
|
|
|
+ return "<div class='autocontent-item' style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:" + width + ";'>" + procuremenEscHtml(text) + '</div>';
|
|
|
+ }
|
|
|
var indexTableColumns = [
|
|
|
{checkbox: true, field: 'state', visible: indexShowall, align: 'center', width: 42, class: 'procuremen-col-checkbox'},
|
|
|
// {field: 'ID', title: __('ID'), operate: 'LIKE', table: 'a', width: 100, align: 'center',
|
|
|
@@ -348,7 +370,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
}
|
|
|
},
|
|
|
{field: 'CDW', title: __('单位'), operate: 'LIKE', table: 'a', width: 50, align: 'center'},
|
|
|
- {field: 'NGZL', title: __('工作量'), operate: 'LIKE', table: 'a', width: 80, align: 'center'},
|
|
|
+ {field: 'NGZL', title: __('工作量'), operate: 'LIKE', table: 'a', width: 80, align: 'center',
|
|
|
+ formatter: function (v) {
|
|
|
+ if (v == null || v === '') {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ var s = String(v).trim();
|
|
|
+ if (s === '') {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ var n = parseFloat(s);
|
|
|
+ if (!isNaN(n) && n === 0) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return s;
|
|
|
+ }
|
|
|
+ },
|
|
|
{field: 'This_quantity', title: '本次数量', operate: 'LIKE', table: 'a', width: 96, align: 'center',
|
|
|
visible: true,
|
|
|
formatter: function (v, row, index) {
|
|
|
@@ -386,10 +423,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
visible: indexShowAuditSuppliers,
|
|
|
class: 'autocontent',
|
|
|
formatter: function (v) {
|
|
|
- if (v == null || v === '') {
|
|
|
- return '';
|
|
|
- }
|
|
|
- return procuremenEscAttr(String(v));
|
|
|
+ return procuremenAutocontentCell(v, this.width || 240);
|
|
|
}
|
|
|
},
|
|
|
{field: 'po_detail_count',title: '已下发数量',operate: false,table: 'a',width: 96,align: 'center',
|
|
|
@@ -412,13 +446,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
},
|
|
|
{field: 'picked_supplier_name', title: '报价供应商', operate: 'LIKE', table: 'a', width: 260, align: 'left',
|
|
|
visible: indexShowPickedOnly,
|
|
|
+ class: 'autocontent',
|
|
|
formatter: function (v) {
|
|
|
- if (v == null || v === '') {
|
|
|
- return '';
|
|
|
- }
|
|
|
- return String(v).split('\n').map(function (line) {
|
|
|
- return procuremenEscAttr(line);
|
|
|
- }).join('<br>');
|
|
|
+ return procuremenAutocontentCell(v, this.width || 260);
|
|
|
}
|
|
|
},
|
|
|
{field: 'CDF', title: __('订法'), operate: 'LIKE', table: 'a', width: 100, align: 'center'},
|
|
|
@@ -427,7 +457,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
{field: 'cywyxm', title: __('业务员'), operate: 'LIKE', table: 'b', width: 80, align: 'center'},
|
|
|
{field: 'dStamp', title: __('操作日期'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, table: 'a', width: 165, align: 'center'},
|
|
|
{field: 'dputrecord', title: __('提交日期'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, table: 'b', width: 170, align: 'center'},
|
|
|
- {field: 'operate',title: '操作',width: 200,align: 'center',fixed: 'right', operate: false,
|
|
|
+ {field: 'operate',title: '操作',width: 220,align: 'center',fixed: 'right', operate: false,
|
|
|
visible: indexInitWffTab !== 'pick',
|
|
|
table: table,
|
|
|
formatter: function (value, row, index) {
|
|
|
@@ -446,7 +476,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
parts.push('<a class="btn btn-xs btn-primary procuremen-op-open procuremen-btn-audit-issue"' + areaAudit + ' href="procuremen/auditissue" data-row-index="' + index + '" title="确认供应商"><i class="fa fa-check"></i> 确认供应商</a>');
|
|
|
parts.push('<a class="btn btn-xs btn-info procuremen-op-open procuremen-btn-details"' + areaDetails + ' href="procuremen/details" data-row-index="' + index + '" title="详情"><i class="fa fa-file-text-o"></i> 详情</a>');
|
|
|
} else if (tab === 'confirm') {
|
|
|
- parts.push('<a class="btn btn-xs btn-success procuremen-op-open procuremen-btn-outward"' + areaConfirmOutward + ' href="procuremen/outward_detail?wff_tab=confirm" data-row-index="' + index + '" title="采购确认"><i class="fa fa-shopping-cart"></i> 采购确认</a>');
|
|
|
+ parts.push('<a class="btn btn-xs btn-success procuremen-op-open procuremen-btn-outward"' + areaConfirmOutward + ' href="procuremen/outward_detail?wff_tab=confirm" data-row-index="' + index + '" title="审批"><i class="fa fa-gavel"></i> 审批</a>');
|
|
|
parts.push('<a class="btn btn-xs btn-info procuremen-op-open procuremen-btn-details"' + areaDetails + ' href="procuremen/details" data-row-index="' + index + '" title="详情"><i class="fa fa-file-text-o"></i> 详情</a>');
|
|
|
}
|
|
|
return '<div class="btn-group">' + parts.join(' ') + '</div>';
|
|
|
@@ -630,6 +660,59 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
var selPick = procuremenRowsWithPoInputs(table.bootstrapTable('getSelections') || []);
|
|
|
procuremenOpenPickReview(selPick);
|
|
|
});
|
|
|
+ $(document).off('click.procuremenAuditAbandon', '#btn-procuremen-audit-abandon').on('click.procuremenAuditAbandon', '#btn-procuremen-audit-abandon', function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ if (Controller.wffTab !== 'audit') {
|
|
|
+ Toastr.warning('重新下发仅在外发审批下发列表可用');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var selAb = table.bootstrapTable('getSelections') || [];
|
|
|
+ if (!selAb.length) {
|
|
|
+ Toastr.warning('请先勾选至少 1 条订单');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var idSet = {};
|
|
|
+ var rowsHtml = '<table class="table table-bordered table-condensed" style="margin:8px 0 0;font-size:12px;">'
|
|
|
+ + '<thead><tr><th>订单号</th><th>工序名称</th><th>印件名称</th></tr></thead><tbody>';
|
|
|
+ $.each(selAb, function (ai, ra) {
|
|
|
+ var sid = ra && (ra.ID != null ? ra.ID : ra.id);
|
|
|
+ if (sid != null && sid !== '' && String(sid) !== '0') {
|
|
|
+ idSet[String(sid)] = true;
|
|
|
+ }
|
|
|
+ rowsHtml += '<tr><td>' + procuremenEscHtml(String(ra.CCYDH || '').trim() || '—') + '</td>'
|
|
|
+ + '<td>' + procuremenEscHtml(String(ra.CGYMC || '').trim() || '—') + '</td>'
|
|
|
+ + '<td>' + procuremenEscHtml(String(ra.CYJMC || '').trim() || '—') + '</td></tr>';
|
|
|
+ });
|
|
|
+ rowsHtml += '</tbody></table>';
|
|
|
+ var idList = Object.keys(idSet);
|
|
|
+ if (!idList.length) {
|
|
|
+ Toastr.warning('所选行无效,请重新勾选');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var abandonMsg = '<div style="text-align:left;line-height:1.65;font-size:13px;">'
|
|
|
+ + '<p style="margin:0 0 8px 0;">即将退回外发初选并重新下发以下 <strong>' + idList.length + '</strong> 个订单(历史下发与操作记录会保留):</p>'
|
|
|
+ + rowsHtml
|
|
|
+ + '<p style="margin:10px 0 0;color:#a94442;"><strong>提示:</strong>退回后需重新选择供应商下发。</p></div>';
|
|
|
+ Layer.confirm(abandonMsg, {
|
|
|
+ title: '重新下发确认',
|
|
|
+ area: ['560px', 'auto'],
|
|
|
+ icon: 3,
|
|
|
+ btn: ['确认重新下发', '取消']
|
|
|
+ }, function (idxAb) {
|
|
|
+ Layer.close(idxAb);
|
|
|
+ Fast.api.ajax({
|
|
|
+ url: 'procuremen/auditabandon',
|
|
|
+ type: 'POST',
|
|
|
+ data: {
|
|
|
+ scydgy_ids_json: JSON.stringify(idList),
|
|
|
+ __token__: $('input[name=\'__token__\']').val() || Config.token
|
|
|
+ }
|
|
|
+ }, function (data, ret) {
|
|
|
+ table.bootstrapTable('refresh');
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
$(document).off('click.procuremenPickDelete', '#btn-procuremen-pick-delete').on('click.procuremenPickDelete', '#btn-procuremen-pick-delete', function (e) {
|
|
|
e.preventDefault();
|
|
|
if (Controller.wffTab !== 'pick') {
|
|
|
@@ -874,7 +957,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
procuremenPoPopoverPosition($inp);
|
|
|
}
|
|
|
function procuremenSavePoRow(rowIdx) {
|
|
|
- if (Controller.wffTab !== 'pick') {
|
|
|
+ if (Controller.wffTab !== 'pick' && Controller.wffTab !== 'audit') {
|
|
|
return;
|
|
|
}
|
|
|
var v = procuremenPoRowValues(rowIdx);
|
|
|
@@ -945,7 +1028,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
procuremenSavePoRow(procuremenPoActiveRow);
|
|
|
});
|
|
|
$(document).off('mousedown.procuremenPoPopClose').on('mousedown.procuremenPoPopClose', function (e) {
|
|
|
- if (Controller.wffTab !== 'pick') {
|
|
|
+ if (Controller.wffTab !== 'pick' && Controller.wffTab !== 'audit') {
|
|
|
return;
|
|
|
}
|
|
|
var $t = $(e.target);
|
|
|
@@ -1136,7 +1219,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
});
|
|
|
table.on('post-body.bs.table', function () {
|
|
|
$('#procuremen-toolbar-host .btn-refresh .fa').removeClass('fa-spin');
|
|
|
- if (Controller.wffTab !== 'pick') {
|
|
|
+ if (Controller.wffTab !== 'pick' && Controller.wffTab !== 'audit') {
|
|
|
return;
|
|
|
}
|
|
|
/* FastAdmin 每次 post-body 会重复绑定复选框列拖拽,多次勾选后易错位/缺框 */
|
|
|
@@ -1154,7 +1237,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
});
|
|
|
if ($bt.length) {
|
|
|
$bt.off('click.procuremenCbTd', 'tbody td.bs-checkbox').on('click.procuremenCbTd', 'tbody td.bs-checkbox', function (e) {
|
|
|
- if (Controller.wffTab !== 'pick' || $(e.target).is('input[type="checkbox"]')) {
|
|
|
+ if ((Controller.wffTab !== 'pick' && Controller.wffTab !== 'audit') || $(e.target).is('input[type="checkbox"]')) {
|
|
|
return;
|
|
|
}
|
|
|
var $inp = $(this).find('input[name="btSelectItem"]:not(:disabled)').first();
|
|
|
@@ -1555,7 +1638,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
|
|
|
Lr.confirm(confirmHtml, {
|
|
|
icon: 3,
|
|
|
- title: '采购确认 — 短信通知',
|
|
|
+ title: '采购终审 — 审批通过',
|
|
|
area: ['480px', 'auto'],
|
|
|
offset: 'auto',
|
|
|
btn: ['确定提交', '取消'],
|
|
|
@@ -1598,6 +1681,51 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
+ $wrap.on('click.procuremenPurchaseConfirm', '#btn-pod-purchase-reject', function () {
|
|
|
+ var rejectPicks = requiredSids.map(function (sid) {
|
|
|
+ return {scydgy_id: String(sid)};
|
|
|
+ });
|
|
|
+ if (!rejectPicks.length) {
|
|
|
+ rejectPicks = [{scydgy_id: scydgyId}];
|
|
|
+ }
|
|
|
+ var Lr = procuremenLayerTop();
|
|
|
+ if (!Lr || typeof Lr.confirm !== 'function') {
|
|
|
+ Toastr.error('弹层组件未就绪,请刷新后重试');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Lr.confirm(
|
|
|
+ '驳回后本单将退回「外发审批下发」,并向相关供应商发送驳回短信。是否确认驳回?',
|
|
|
+ {
|
|
|
+ icon: 0,
|
|
|
+ title: '采购终审 — 审批驳回',
|
|
|
+ area: ['460px', 'auto'],
|
|
|
+ btn: ['确认驳回', '取消'],
|
|
|
+ zIndex: procuremenLayerNextZIndex()
|
|
|
+ },
|
|
|
+ function (idx) {
|
|
|
+ Lr.close(idx);
|
|
|
+ FastRef.api.ajax({
|
|
|
+ url: FastRef.api.fixurl('procuremen/purchaseApprovalReject'),
|
|
|
+ type: 'POST',
|
|
|
+ data: {
|
|
|
+ __token__: $('input[name=\'__token__\']').val() || $wrap.find('input[name=\'__token__\']').val(),
|
|
|
+ order_picks_json: JSON.stringify(rejectPicks)
|
|
|
+ }
|
|
|
+ }, function () {
|
|
|
+ if (typeof parent !== 'undefined' && parent.Layer) {
|
|
|
+ var ix = parent.Layer.getFrameIndex(window.name);
|
|
|
+ if (typeof ix !== 'undefined') {
|
|
|
+ parent.Layer.close(ix);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var p$ = (typeof parent !== 'undefined' && parent.jQuery) ? parent.jQuery : (typeof parent !== 'undefined' ? parent.$ : null);
|
|
|
+ if (p$ && p$('#table').length) {
|
|
|
+ p$('#table').bootstrapTable('refresh');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ });
|
|
|
$wrap.on('click.procuremenPurchaseConfirm', '#btn-pod-purchase-close', function () {
|
|
|
if (typeof parent !== 'undefined' && parent.Layer) {
|
|
|
var ixClose = parent.Layer.getFrameIndex(window.name);
|
|
|
@@ -1618,6 +1746,126 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
|
|
|
review: function () {
|
|
|
Controller.api.bindevent();
|
|
|
+ procuremenBindSysRqPicker('#review-sys-rq', 'reviewSysRq');
|
|
|
+
|
|
|
+ function procuremenReviewWarn(msg) {
|
|
|
+ if (typeof Toastr !== 'undefined') {
|
|
|
+ Toastr.warning(msg);
|
|
|
+ } else if (typeof Layer !== 'undefined') {
|
|
|
+ Layer.msg(msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function procuremenReviewIsPickMode() {
|
|
|
+ if (/pickreview/i.test((window.location.pathname || '') + (window.location.search || ''))) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ var $form = $('#review-form');
|
|
|
+ var pm = $form.attr('data-pick-mode');
|
|
|
+ if (pm === '1') {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ pm = $form.data('pickMode');
|
|
|
+ if (pm === 1 || pm === '1') {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ pm = $form.data('pick-mode');
|
|
|
+ return pm === 1 || pm === '1';
|
|
|
+ }
|
|
|
+
|
|
|
+ function procuremenReviewCollectSelected() {
|
|
|
+ var selected = [];
|
|
|
+ var seen = {};
|
|
|
+ $('#review-company-tbody .review-company-cb:checked').each(function () {
|
|
|
+ var c = $(this).data('company');
|
|
|
+ if (!c || typeof c !== 'object') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var k = [String(c.email || ''), String(c.phone || ''), String(c.name || c.company_name || '')].join('\x01');
|
|
|
+ if (k && seen[k]) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (k) {
|
|
|
+ seen[k] = true;
|
|
|
+ }
|
|
|
+ selected.push(c);
|
|
|
+ });
|
|
|
+ return selected;
|
|
|
+ }
|
|
|
+
|
|
|
+ $(document).off('click.procuremenReviewSubmit', '#btn-review-submit').on('click.procuremenReviewSubmit', '#btn-review-submit', function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ e.stopPropagation();
|
|
|
+ var $rq = $('#review-sys-rq');
|
|
|
+ if ($rq.length && $rq.data('DateTimePicker')) {
|
|
|
+ try {
|
|
|
+ $rq.data('DateTimePicker').hide();
|
|
|
+ } catch (ignoreHidePicker) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var isPickMode = procuremenReviewIsPickMode();
|
|
|
+ var selected = procuremenReviewCollectSelected();
|
|
|
+ if (!selected.length) {
|
|
|
+ procuremenReviewWarn(isPickMode ? '请至少选择一家合作供应商' : '请至少选择一个下发单位');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var sysRq = ($rq.val() || '').trim();
|
|
|
+ if (!sysRq) {
|
|
|
+ procuremenReviewWarn('请选择截止时间');
|
|
|
+ $rq.focus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var cons;
|
|
|
+ try {
|
|
|
+ cons = JSON.parse($('#c-row-json').val() || '{}');
|
|
|
+ } catch (ignoreParseRow) {
|
|
|
+ cons = {};
|
|
|
+ }
|
|
|
+ var mergePayload = ($('#c-merge-rows-json').val() || '').trim();
|
|
|
+ if (!mergePayload) {
|
|
|
+ mergePayload = JSON.stringify([cons]);
|
|
|
+ }
|
|
|
+ var $submitBtn = $('#btn-review-submit');
|
|
|
+ if ($submitBtn.prop('disabled')) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var submitBtnHtml = $submitBtn.html();
|
|
|
+ $submitBtn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> 提交中…');
|
|
|
+ Fast.api.ajax({
|
|
|
+ url: Fast.api.fixurl(isPickMode ? 'procuremen/picksubmit' : 'procuremen/review'),
|
|
|
+ type: 'POST',
|
|
|
+ data: {
|
|
|
+ __token__: $('input[name=\'__token__\']').val(),
|
|
|
+ row_json: JSON.stringify(cons),
|
|
|
+ merge_rows_json: mergePayload,
|
|
|
+ companies_json: JSON.stringify(selected),
|
|
|
+ sys_rq: sysRq
|
|
|
+ }
|
|
|
+ }, function (data, ret) {
|
|
|
+ var msg = (ret && ret.msg) ? ret.msg : '操作成功';
|
|
|
+ try {
|
|
|
+ sessionStorage.removeItem('procuremen_merge_rows');
|
|
|
+ } catch (ignoreClr) {
|
|
|
+ }
|
|
|
+ var index = parent.Layer.getFrameIndex(window.name);
|
|
|
+ if (typeof parent !== 'undefined' && parent.Layer && index) {
|
|
|
+ parent.Layer.close(index);
|
|
|
+ }
|
|
|
+ if (typeof parent !== 'undefined' && parent.Toastr) {
|
|
|
+ parent.Toastr.success(msg);
|
|
|
+ } else if (typeof Toastr !== 'undefined') {
|
|
|
+ Toastr.success(msg);
|
|
|
+ }
|
|
|
+ if (parent && parent.$ && parent.$('#table').length) {
|
|
|
+ parent.$('#table').bootstrapTable('refresh', {silent: true});
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }, function () {
|
|
|
+ $submitBtn.prop('disabled', false).html(submitBtnHtml);
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
function procuremenReviewCloseLayer() {
|
|
|
try {
|
|
|
if (typeof parent !== 'undefined' && parent.Layer) {
|
|
|
@@ -1653,82 +1901,35 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
e.preventDefault();
|
|
|
procuremenReviewCloseLayer();
|
|
|
});
|
|
|
- require(['bootstrap-datetimepicker'], function () {
|
|
|
- var $el = $('#review-sys-rq');
|
|
|
- if (!$el.length) {
|
|
|
- return;
|
|
|
- }
|
|
|
- var placePickerBesideInput = function () {
|
|
|
- var picker = $el.data('DateTimePicker');
|
|
|
- if (!picker || !picker.widget) {
|
|
|
- return;
|
|
|
- }
|
|
|
- var $w = picker.widget;
|
|
|
- var rect = $el[0].getBoundingClientRect();
|
|
|
- var gap = 12;
|
|
|
- var top = rect.top;
|
|
|
- var left = rect.right + gap;
|
|
|
- var widgetW = $w.outerWidth() || 300;
|
|
|
- var widgetH = $w.outerHeight() || 320;
|
|
|
- var vw = window.innerWidth || document.documentElement.clientWidth;
|
|
|
- var vh = window.innerHeight || document.documentElement.clientHeight;
|
|
|
- if (left + widgetW > vw - 8) {
|
|
|
- left = Math.max(8, rect.left);
|
|
|
- top = rect.bottom + 6;
|
|
|
- }
|
|
|
- if (top + widgetH > vh - 8) {
|
|
|
- top = Math.max(8, rect.top - widgetH - 6);
|
|
|
- }
|
|
|
- $w.appendTo(document.body).css({
|
|
|
- position: 'fixed',
|
|
|
- top: top + 'px',
|
|
|
- left: left + 'px',
|
|
|
- right: 'auto',
|
|
|
- bottom: 'auto',
|
|
|
- display: 'block',
|
|
|
- margin: 0
|
|
|
- });
|
|
|
- };
|
|
|
- var bindPickerFloat = function (attempt) {
|
|
|
- if ($el.data('DateTimePicker')) {
|
|
|
- $el.off('dp.show.reviewSysRq dp.update.reviewSysRq focus.reviewSysRq click.reviewSysRq')
|
|
|
- .on('dp.show.reviewSysRq dp.update.reviewSysRq', function () {
|
|
|
- setTimeout(placePickerBesideInput, 0);
|
|
|
- })
|
|
|
- .on('focus.reviewSysRq click.reviewSysRq', function () {
|
|
|
- var picker = $el.data('DateTimePicker');
|
|
|
- if (picker) {
|
|
|
- picker.show();
|
|
|
- }
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- if (attempt < 30) {
|
|
|
- setTimeout(function () {
|
|
|
- bindPickerFloat(attempt + 1);
|
|
|
- }, 50);
|
|
|
- }
|
|
|
- };
|
|
|
- bindPickerFloat(0);
|
|
|
- });
|
|
|
+ var isPickReviewEntry = /pickreview/i.test((window.location.pathname || '') + (window.location.search || ''));
|
|
|
var ids = window.Fast && Fast.api ? Fast.api.query('ids') : null;
|
|
|
if (ids === null || ids === '') {
|
|
|
Toastr.error('请刷新页面后重试');
|
|
|
return;
|
|
|
}
|
|
|
- var $ptable = parent.$('#table');
|
|
|
- if (!$ptable.length) {
|
|
|
+ var $ptable = $();
|
|
|
+ try {
|
|
|
+ if (typeof parent !== 'undefined' && parent.$) {
|
|
|
+ $ptable = parent.$('#table');
|
|
|
+ }
|
|
|
+ } catch (ignoreParentTable) {
|
|
|
+ $ptable = $();
|
|
|
+ }
|
|
|
+ if (!$ptable.length && !isPickReviewEntry) {
|
|
|
Toastr.error('请刷新页面后重试');
|
|
|
return;
|
|
|
}
|
|
|
- var pk = $ptable.bootstrapTable('getOptions').pk || 'ID';
|
|
|
+ var pk = 'ID';
|
|
|
var row = null;
|
|
|
- $.each($ptable.bootstrapTable('getData'), function (i, r) {
|
|
|
- if (String(r[pk]) === String(ids)) {
|
|
|
- row = r;
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
+ if ($ptable.length) {
|
|
|
+ pk = $ptable.bootstrapTable('getOptions').pk || 'ID';
|
|
|
+ $.each($ptable.bootstrapTable('getData'), function (i, r) {
|
|
|
+ if (String(r[pk]) === String(ids)) {
|
|
|
+ row = r;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
var mergeRows = [];
|
|
|
var mergeFlag = window.Fast && Fast.api ? String(Fast.api.query('merge') || '') : '';
|
|
|
if (mergeFlag === '1') {
|
|
|
@@ -1827,11 +2028,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
);
|
|
|
$tb.append($tr);
|
|
|
});
|
|
|
- var isPickModeUi = String($('#review-form').data('pickMode') || $('#review-form').data('pick-mode') || '') === '1';
|
|
|
+ var isPickModeUi = procuremenReviewIsPickMode();
|
|
|
if (isPickModeUi && list.length > 1) {
|
|
|
$('.procuremen-review-submit-tip').html(
|
|
|
'<i class="fa fa-exclamation-triangle"></i> '
|
|
|
- + '<strong>合并单:</strong>本步骤仅保存下发并勾选多家供应商,<strong>不发送短信或邮件</strong>;'
|
|
|
+ + '<strong>合并单:</strong>确认后将向所选供应商<strong>发送短信与邮件</strong>;'
|
|
|
+ '本单含 <strong>' + list.length + ' 道工序</strong>,请核对后再确认。'
|
|
|
);
|
|
|
}
|
|
|
@@ -1840,7 +2041,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
|
|
|
applyProcuremenMergeReviewUi(mergeRows.length ? mergeRows : (row ? [row] : []));
|
|
|
|
|
|
- var isPickMode = String($('#review-form').data('pickMode') || $('#review-form').data('pick-mode') || '') === '1';
|
|
|
+ var isPickMode = procuremenReviewIsPickMode();
|
|
|
|
|
|
$('#c-row-json').val(JSON.stringify(row));
|
|
|
|
|
|
@@ -2133,69 +2334,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- $('#btn-review-submit').off('click.reviewSubmit').on('click.reviewSubmit', function () {
|
|
|
- var selected = [];
|
|
|
- $.each(reviewSelectedMap, function (k, c) {
|
|
|
- if (c) {
|
|
|
- selected.push(c);
|
|
|
- }
|
|
|
- });
|
|
|
- if (!selected.length) {
|
|
|
- Toastr.warning(isPickMode ? '请至少选择一家合作供应商' : '请至少选择一个下发单位');
|
|
|
- return;
|
|
|
- }
|
|
|
- var sysRq = ($('#review-sys-rq').val() || '').trim();
|
|
|
- if (!sysRq) {
|
|
|
- Toastr.warning('请选择截止时间');
|
|
|
- $('#review-sys-rq').focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- var cons;
|
|
|
- try {
|
|
|
- cons = JSON.parse($('#c-row-json').val() || '{}');
|
|
|
- } catch (e) {
|
|
|
- cons = {};
|
|
|
- }
|
|
|
- var mergePayload = ($('#c-merge-rows-json').val() || '').trim();
|
|
|
- if (!mergePayload) {
|
|
|
- mergePayload = JSON.stringify([cons]);
|
|
|
- }
|
|
|
- var $submitBtn = $('#btn-review-submit');
|
|
|
- var submitBtnHtml = $submitBtn.html();
|
|
|
- $submitBtn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> 提交中…');
|
|
|
- Fast.api.ajax({
|
|
|
- url: isPickMode ? 'procuremen/picksubmit' : 'procuremen/review',
|
|
|
- type: 'POST',
|
|
|
- data: {
|
|
|
- __token__: $('input[name=\'__token__\']').val(),
|
|
|
- row_json: JSON.stringify(cons),
|
|
|
- merge_rows_json: mergePayload,
|
|
|
- companies_json: JSON.stringify(selected),
|
|
|
- sys_rq: sysRq
|
|
|
- }
|
|
|
- }, function (data, ret) {
|
|
|
- var msg = (ret && ret.msg) ? ret.msg : '操作成功';
|
|
|
- try {
|
|
|
- sessionStorage.removeItem('procuremen_merge_rows');
|
|
|
- } catch (ignoreClr) {
|
|
|
- }
|
|
|
- var index = parent.Layer.getFrameIndex(window.name);
|
|
|
- if (typeof parent !== 'undefined' && parent.Layer && index) {
|
|
|
- parent.Layer.close(index);
|
|
|
- }
|
|
|
- if (typeof parent !== 'undefined' && parent.Toastr) {
|
|
|
- parent.Toastr.success(msg);
|
|
|
- }
|
|
|
- if (parent && parent.$ && parent.$('#table').length) {
|
|
|
- parent.$('#table').bootstrapTable('refresh', {silent: true});
|
|
|
- }
|
|
|
- return false;
|
|
|
- }, function () {
|
|
|
- $submitBtn.prop('disabled', false).html(submitBtnHtml);
|
|
|
- return false;
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
/** 加载供应商列表(弹窗内勾选单位) */
|
|
|
function loadReviewCompaniesPanel() {
|
|
|
Fast.api.ajax({
|
|
|
@@ -2382,94 +2520,134 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
},
|
|
|
|
|
|
auditissue: function () {
|
|
|
- procuremenBindSysRqPicker('#audit-sys-rq', 'auditSysRq');
|
|
|
+ function auditIssueClose() {
|
|
|
+ var index = parent.Layer.getFrameIndex(window.name);
|
|
|
+ parent.Layer.close(index);
|
|
|
+ }
|
|
|
|
|
|
- var auditNotifyGroups = [];
|
|
|
- try {
|
|
|
- auditNotifyGroups = JSON.parse($('#audit-notify-groups-json').val() || '[]');
|
|
|
- } catch (ignoreAudNg) {
|
|
|
- auditNotifyGroups = [];
|
|
|
+ function auditIssueSysRq() {
|
|
|
+ return ($('#audit-sys-rq').val() || '').trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ function auditIssueValidateSysRq() {
|
|
|
+ var sysRq = auditIssueSysRq();
|
|
|
+ if (!sysRq) {
|
|
|
+ Toastr.warning('请选择报价截止时间');
|
|
|
+ $('#audit-sys-rq').focus();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ function auditIssueAjaxData(extra) {
|
|
|
+ var data = {
|
|
|
+ __token__: $('input[name=\'__token__\']').val(),
|
|
|
+ scydgy_id: $('input[name=\'scydgy_id\']').val(),
|
|
|
+ sys_rq: auditIssueSysRq()
|
|
|
+ };
|
|
|
+ if (extra) {
|
|
|
+ $.extend(data, extra);
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ procuremenBindSysRqPicker('#audit-sys-rq', 'auditIssue');
|
|
|
+
|
|
|
+ function auditIssueSelectedCompany() {
|
|
|
+ var $checked = $('input[name="audit_quote_pick"]:checked');
|
|
|
+ if (!$checked.length) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return $.trim($checked.val());
|
|
|
}
|
|
|
|
|
|
- function auditIssueSyncCheckAll() {
|
|
|
- var $rows = $('#audit-notify-tbody .audit-notify-pick');
|
|
|
- var $checked = $rows.filter(':checked');
|
|
|
- var $all = $('#audit-notify-check-all');
|
|
|
- if (!$all.length || !$rows.length) {
|
|
|
+ function auditIssuePostResendEmail(companies) {
|
|
|
+ if (!companies || !companies.length) {
|
|
|
+ Toastr.warning('请选择供应商');
|
|
|
return;
|
|
|
}
|
|
|
- $all.prop('checked', $rows.length > 0 && $checked.length === $rows.length);
|
|
|
- $all.prop('indeterminate', $checked.length > 0 && $checked.length < $rows.length);
|
|
|
+ if (!auditIssueValidateSysRq()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var company = companies[0];
|
|
|
+ Layer.confirm('向「' + company + '」发送邮件?', {icon: 3, title: '发邮件', btn: ['发送', '取消']}, function (layerIdx) {
|
|
|
+ Layer.close(layerIdx);
|
|
|
+ Fast.api.ajax({
|
|
|
+ url: 'procuremen/auditresendemail',
|
|
|
+ type: 'POST',
|
|
|
+ data: auditIssueAjaxData({
|
|
|
+ companies_json: JSON.stringify([company])
|
|
|
+ })
|
|
|
+ }, function (data, ret) {
|
|
|
+ var msg = (ret && ret.msg) ? ret.msg : '已发送';
|
|
|
+ if (typeof parent !== 'undefined' && parent.Toastr) {
|
|
|
+ parent.Toastr.success(msg);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- function auditIssueClose() {
|
|
|
- var index = parent.Layer.getFrameIndex(window.name);
|
|
|
- parent.Layer.close(index);
|
|
|
+ function auditIssuePostResendSms(company) {
|
|
|
+ if (!company) {
|
|
|
+ Toastr.warning('请选择供应商');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!auditIssueValidateSysRq()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Layer.confirm('向「' + company + '」发送短信?', {icon: 3, title: '发短信', btn: ['发送', '取消']}, function (layerIdx) {
|
|
|
+ Layer.close(layerIdx);
|
|
|
+ Fast.api.ajax({
|
|
|
+ url: 'procuremen/auditresendsms',
|
|
|
+ type: 'POST',
|
|
|
+ data: auditIssueAjaxData({
|
|
|
+ selected_company: company
|
|
|
+ })
|
|
|
+ }, function (data, ret) {
|
|
|
+ var msg = (ret && ret.msg) ? ret.msg : '已发送';
|
|
|
+ if (typeof parent !== 'undefined' && parent.Toastr) {
|
|
|
+ parent.Toastr.success(msg);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- $('#audit-notify-check-all').off('change.auditNotifyAll').on('change.auditNotifyAll', function () {
|
|
|
- var on = $(this).prop('checked');
|
|
|
- $('#audit-notify-tbody .audit-notify-pick').prop('checked', on);
|
|
|
- $(this).prop('indeterminate', false);
|
|
|
- });
|
|
|
- $('#audit-notify-tbody').off('change.auditNotifyPick', '.audit-notify-pick').on('change.auditNotifyPick', '.audit-notify-pick', auditIssueSyncCheckAll);
|
|
|
- $('#audit-notify-tbody').off('click.auditNotifyRow', 'tr').on('click.auditNotifyRow', 'tr', function (e) {
|
|
|
- if ($(e.target).is('input, label, a')) {
|
|
|
+ $('#audit-quote-tbody').off('click.auditQuoteRow', 'tr').on('click.auditQuoteRow', 'tr', function (e) {
|
|
|
+ if ($(e.target).closest('input, label, a, button').length) {
|
|
|
return;
|
|
|
}
|
|
|
- var $cb = $(this).find('.audit-notify-pick').first();
|
|
|
- if ($cb.length) {
|
|
|
- $cb.prop('checked', !$cb.prop('checked'));
|
|
|
- auditIssueSyncCheckAll();
|
|
|
+ var $radio = $(this).find('.audit-quote-pick').first();
|
|
|
+ if ($radio.length) {
|
|
|
+ $radio.prop('checked', true);
|
|
|
}
|
|
|
});
|
|
|
- auditIssueSyncCheckAll();
|
|
|
|
|
|
$('#btn-audit-issue-close').off('click.auditClose').on('click.auditClose', function () {
|
|
|
auditIssueClose();
|
|
|
});
|
|
|
+
|
|
|
$('#btn-audit-issue-submit').off('click.auditIssue').on('click.auditIssue', function () {
|
|
|
- var selected = [];
|
|
|
- $('#audit-notify-tbody .audit-notify-pick:checked').each(function () {
|
|
|
- var idx = parseInt($(this).val(), 10);
|
|
|
- if (!isNaN(idx) && auditNotifyGroups[idx]) {
|
|
|
- var co = auditNotifyGroups[idx];
|
|
|
- selected.push({
|
|
|
- name: co.name || co.company_name || '',
|
|
|
- company_name: co.name || co.company_name || '',
|
|
|
- email: co.email || '',
|
|
|
- phone: co.phone || '',
|
|
|
- username: co.username || ''
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- if (!selected.length) {
|
|
|
- Toastr.warning('请至少勾选一家供应商');
|
|
|
+ var company = auditIssueSelectedCompany();
|
|
|
+ if (!company) {
|
|
|
+ Toastr.warning('请选择一家供应商');
|
|
|
return;
|
|
|
}
|
|
|
- var sysRq = ($('#audit-sys-rq').val() || '').trim();
|
|
|
- if (!sysRq) {
|
|
|
- Toastr.warning('请选择截止时间');
|
|
|
- $('#audit-sys-rq').focus();
|
|
|
+ if (!auditIssueValidateSysRq()) {
|
|
|
return;
|
|
|
}
|
|
|
- var names = selected.map(function (c) {
|
|
|
- return c.name || c.company_name || '';
|
|
|
- }).filter(Boolean).join('、');
|
|
|
Layer.confirm(
|
|
|
- '确认向以下 <strong>' + selected.length + ' 家</strong>供应商发送短信与邮件?<br/><span style="color:#666;">' + names + '</span>',
|
|
|
- {icon: 3, title: '确认通知', btn: ['确认通知', '取消']},
|
|
|
+ '确认选定供应商「' + company + '」并进入采购终审?<br/><span style="color:#666;">本步不发送短信。</span>',
|
|
|
+ {icon: 3, title: '确认供应商', btn: ['确认', '取消']},
|
|
|
function (layerIdx) {
|
|
|
Layer.close(layerIdx);
|
|
|
Fast.api.ajax({
|
|
|
url: 'procuremen/auditsubmit',
|
|
|
type: 'POST',
|
|
|
- data: {
|
|
|
- __token__: $('input[name=\'__token__\']').val(),
|
|
|
- scydgy_id: $('input[name=\'scydgy_id\']').val(),
|
|
|
- notify_companies_json: JSON.stringify(selected),
|
|
|
- sys_rq: sysRq
|
|
|
- }
|
|
|
+ data: auditIssueAjaxData({
|
|
|
+ selected_company: company
|
|
|
+ })
|
|
|
}, function (data, ret) {
|
|
|
var msg = (ret && ret.msg) ? ret.msg : '操作成功';
|
|
|
if (typeof parent !== 'undefined' && parent.Toastr) {
|
|
|
@@ -2484,6 +2662,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
}
|
|
|
);
|
|
|
});
|
|
|
+
|
|
|
+ $('#audit-quote-tbody').off('click.auditRowEmail', '.audit-row-send-email').on('click.auditRowEmail', '.audit-row-send-email', function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ e.stopPropagation();
|
|
|
+ var company = $.trim($(this).attr('data-company') || '');
|
|
|
+ if (!company) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ auditIssuePostResendEmail([company]);
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#audit-quote-tbody').off('click.auditRowSms', '.audit-row-send-sms').on('click.auditRowSms', '.audit-row-send-sms', function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ e.stopPropagation();
|
|
|
+ var company = $.trim($(this).attr('data-company') || '');
|
|
|
+ if (!company) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ auditIssuePostResendSms(company);
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
api: {
|