代码拉取完成,页面将自动刷新
var UserGrid = 'dg';
var DialogForm = null;
var client = null;
var grid = null;
var editIndex = -1;
var Header_id = "0";
//擴展
var DicApplyAdd_Scrap = {
name: 'DicApplyAdd_Scrap',
//初始化
initialize: function () {
this.initializeDOM();
this.initializeEvent();
this.initializeServerData();
this.render();
this.initGrid();
},
//初始化DOM元素
initializeDOM: function () {
//採購人下拉框
$('#Buyer_name').combobox({
valueField: 'id',
textField: 'code',
showblank: true,
required: true,
url: '/Ajax/Lbip/CommForm.ashx?actions=BuyerList',
panelHeight: 100,
columns: [
[
{ field: 'id', title: 'id', width: 60 },
{ field: 'code', title: 'code', width: 100 }
]
],
onSelect: function () {
$('#Buyer_no').val($('#Buyer_name').combobox('getValue'));
},
onChange: function () {
$('#Buyer_no').val('');
}
});
//倉別
$('#Location_T').combobox({
valueField: 'id',
textField: 'code',
mode: 'remote',
required: true,
editable: false,
data: [
{ id: '3101', code: '3101' },
{ id: '3111', code: '3111' },
{ id: '3100', code: '3100' },
{ id: '3110', code: '3110' }
],
showblank: true
});
},
//初始化DOM事件
initializeEvent: function () {
},
// 初始化服务端数据
initializeServerData: function () {
},
render: function () {
},
//初始化表格
datagrid: {
width: '100%',
iconCls: 'icon-search',
rownumbers: true,
showFooter: true,
remoteSort: false,
height: $(document).height() - $('#condition').height() - 150,
//nowrap:false,
frozenColumns: [
[
{ field: 'ck', checkbox: true, height: 30 }, //勾選框
{ field: 'Line_id', title: 'Line_id', width: 120, height: 30, hidden: true },
{ field: 'Header_id', title: 'Header_id', width: 120, height: 30, hidden: true },
{ field: 'Gr_line_id', title: 'Gr_line_id', width: 50, height: 30 },
{ field: 'Item_no', title: '料號', width: 120, height: 30 }
]
],
columns: [
[
{ field: 'Gr_no', title: 'GR單號', width: 120, height: 30 },
{ field: 'Po_no', title: 'PO單號', width: 120, height: 30 },
{ field: 'Po_line', title: 'POline', width: 50, height: 10 },
{ field: 'Gr_line', title: 'GRitem', width: 50, height: 30 },
{ field: 'Invoice_no', title: '發票號', width: 120, height: 30 },
{ field: 'Left_qty', title: '可申請數量', width: 70, height: 15 },
{
field: 'Dic_qty', title: '申請數量', width: 70, height: 15,
editor: { type: 'numberbox', options: { min: 0, precision: 0, validType: 'checkNum' } },
formatter: function (value, row, index) {
return Number(value);
}
},
{ field: 'Left_amount', title: '可申請金額', width: 100, height: 15 },
{ field: 'Dic_pirce', title: '申請金額', width: 100, height: 15 },
{ field: 'Tax_amount', title: '申請稅額', width: 100, height: 15 },
{ field: 'Vat_rate', title: '增值稅%', width: 100, height: 15, hidden: true },//關稅率
{ field: 'Tariff_rate', title: '關稅%', width: 100, height: 15, hidden: true },//增值稅率
//add by xf.zhu增值稅、關稅 editor: { type: 'numberbox', options: { min: 0, precision: 4, validType: 'checkNum'} },
{
field: 'Vat_amount', title: '增值稅', width: 100, height: 15, hidden: false,
editor: { type: 'numberbox', options: { min: 0, precision: 2, validType: 'checkNum' } },
}, //add by xf.zhu增值稅、關稅 關稅率,增值稅率
{
field: 'Tariff_amount', title: '關稅', width: 100, height: 15, hidden: false,
editor: { type: 'numberbox', options: { min: 0, precision: 2, validType: 'checkNum' } },
}, //add by xf.zhu增值稅、關稅
{ field: 'Dic_amount', title: '總金額', width: 100, height: 15 },
{ field: 'Currency', title: '幣別', width: 50, height: 10 },
{ field: 'Billing_flag', title: '立賬標記', width: 120, height: 30 },
{ field: 'Billing_date', title: '立賬日期', width: 120, height: 30 },
{ field: 'Bincode', title: 'bincode', width: 120, height: 30, editor: 'text' },
{ field: 'Gr_qty', title: 'GR數量', width: 70, height: 15 },
{ field: 'Gr_price', title: 'GR單價', width: 70, height: 15 },
//{ field: 'Po_qty', title: 'PO數量', width: 70, height: 15 },
//{ field: 'Po_price', title: 'PO單價', width: 70, height: 15 },
{ field: 'Po_unit', title: 'PO單位', width: 50, height: 10 },
//{ field: 'Im_qty', title: '進口報關數量', width: 70, height: 15 },
{ field: 'Plant', title: 'Plant', width: 50, height: 10 },
{ field: 'Createid', title: 'CREATEID', width: 120, height: 30, hidden: true },
{ field: 'Createby', title: 'CREATEBY', width: 120, height: 30, hidden: true },
{ field: 'Createtime', title: 'CREATETIME', width: 120, height: 30, hidden: true },
{ field: 'Modifyid', title: 'MODIFYID', width: 120, height: 30, hidden: true },
{ field: 'Modifyby', title: 'MODIFYBY', width: 120, height: 30, hidden: true },
{ field: 'Modifytime', title: 'MODIFYTIME', width: 120, height: 30, hidden: true }
]
],
toolbar: [
{
//在dategrid表单的头部添加按钮
text: "添加",
iconCls: "icon-add",
handler: function () {
$('#div_Info').dialog("open");
}
},
'-',
{
text: "删除",
iconCls: "icon-remove",
handler: function () {
client.DeleteData();
}
},
'-',
{
text: "導出",
iconCls: "icon-redo",
handler: function () {
client.ToExcel();
}
}
// ,
// '-',
// {// add by xf.zhu
// text: "GW",
// iconCls: "icon-redo",
// handler: function () {
// var url = "/Form/Discount/Scrap/DicApplyScrapMaintain.aspx?Header_id=" + $('#Header_id').val();
// openDialogUrl_U(url, 'DicApplyScrapMaintain', 'maintain', 700, 500, 50, 50, '/Form/Discount/Scrap/DicApplyScrapMaintain.aspx');
//
// }
// }
],
onLoadSuccess: function (row) {
//加載成功時,更新加總欄
client.loadFooter();
},
onAfterEdit: function (rowIndex, rowData, changes) {
//退出編輯時,更新加總欄
if ($('#Sign_status').val() == "1") { $('#' + UserGrid).datagrid('rejectChanges'); return; }
if ($('#Sign_status').val() == "3") { $('#' + UserGrid).datagrid('rejectChanges'); return; }
if ($('#Sign_status').val() == "4") { $('#' + UserGrid).datagrid('rejectChanges'); return; }
if ($('#Sign_status').val() == "5") { $('#' + UserGrid).datagrid('rejectChanges'); return; }
var Dic_qty = 0;
if (rowData.Dic_qty == "") {
Dic_qty = 0;
} else {
Dic_qty = parseFloat(rowData.Dic_qty);
}
// $('#' + UserGrid).datagrid('refreshRow', rowIndex);
if (Dic_qty > parseFloat(rowData.Left_qty)) {
rowData.Dic_qty = 0;
showTipsMsg('數量不可超出剩餘數量', 3000, 5);
$('#' + UserGrid).datagrid('refreshRow', rowIndex);
return;
}
rowData.Dic_qty = Dic_qty;
rowData.Dic_pirce = (Dic_qty * parseFloat(rowData.Gr_price)).toFixed(4);
//calcu tax
if ($('#Sign_status').val() == "2" && changes.hasOwnProperty("Dic_qty")) { showTipsMsg('gw cant change dic_qty', 3000, 5); $('#' + UserGrid).datagrid('rejectChanges'); return; } //gw can't change dic_qty. //回滚自从创建以来或最后一次调用 acceptChanges 以来所有更改的数据。
if ($('#Sign_status').val() == "2" && !changes.hasOwnProperty("Dic_qty")) {
if (isNaN((parseFloat(rowData.Vat_amount) + parseFloat(rowData.Tariff_amount)).toFixed(4))) { $('#' + UserGrid).datagrid('rejectChanges'); return; }
console.log("gw hand key calc tax");
rowData.Tax_amount = (parseFloat(rowData.Vat_amount) + parseFloat(rowData.Tariff_amount)).toFixed(4);
}
else {
let tariff_rate = isNaN(rowData.Tariff_rate) ? 0 : parseFloat(rowData.Tariff_rate);
let value_Add_Rate = isNaN(rowData.Vat_rate) ? 0 : parseFloat(rowData.Vat_rate);
let ValueOfGoods = parseFloat(rowData.Dic_pirce);
let tariff_amount = ValueOfGoods * tariff_rate; rowData.Tariff_amount = tariff_amount.toFixed(2);
let Value_Add_amount = (ValueOfGoods + tariff_amount) * value_Add_Rate; rowData.Vat_amount = Value_Add_amount.toFixed(2);
rowData.Tax_amount = (tariff_amount + Value_Add_amount).toFixed(4);//modify by xf.zhu
//end tax
}
rowData.Dic_amount = (parseFloat(rowData.Dic_pirce) + parseFloat(rowData.Tax_amount)).toFixed(4);
if (parseFloat(rowData.Dic_amount) > parseFloat(rowData.Left_amount)) {
showTipsMsg('申請金額已超出', 3000, 5);
}
$('#' + UserGrid).datagrid('refreshRow', rowIndex);
client.loadFooter();
},
onClickRow: function (rowIndex, rowData) {
//單擊進入編輯狀態,重複單擊退出編輯
if (editIndex != rowIndex) {
$('#' + UserGrid).datagrid('endEdit', editIndex);
$('#' + UserGrid).datagrid('selectRow', rowIndex).datagrid('beginEdit', rowIndex);
editIndex = rowIndex;
} else {
$('#' + UserGrid).datagrid('endEdit', editIndex);
editIndex = -1;
}
},
singleSelect: false, //是否单选
pagination: false //分页控件
},
initGrid: function () {
var hd = $(document).height() - $('#condition').height() - 150;
$('#' + UserGrid).datagrid(this.datagrid);
$('#userTable_item').datagrid({
width: '100%',
iconCls: 'icon-search',
rownumbers: true,
showFooter: true,
remoteSort: false,
height: 450,
//nowrap:false,
frozenColumns: [
[
{ field: 'ck', checkbox: true, height: 30 } //勾選框
]
],
columns: [
[
{ field: 'Gr_line_id', title: 'Gr_line_id', width: 50, height: 30 },
{ field: 'Po_no', title: 'PO單號', width: 100, height: 30 },
{ field: 'Po_line', title: 'POline', width: 50, height: 30 },
{ field: 'Item_no', title: '料號', width: 120, height: 30 },
{ field: 'Left_qty', title: '可申請數量', width: 120, height: 30 },
{ field: 'Left_amount', title: '可申請金額', width: 120, height: 30 },
{ field: 'Gr_no', title: 'GR單號', width: 100, height: 30 },
{ field: 'Billing_flag', title: '是否AP立賬', width: 50, height: 30 },
{ field: 'Remark', title: '備註', width: 150, height: 30 },
{ field: 'Site', title: '廠別', width: 150, height: 30 }
]
],
singleSelect: false, //是否单选
pagination: false //分页控件
});
},
loadFooter: function () {
var Dic_qty = 0;
var Dic_pirce = 0;
var Dic_amount = 0;
var data = $('#' + UserGrid).datagrid('getData');
for (var i = 0; i < data.rows.length; i++) {
Dic_qty = parseFloat(Dic_qty) + parseFloat(data.rows[i].Dic_qty);
Dic_pirce = parseFloat(Dic_pirce) + parseFloat(data.rows[i].Dic_pirce);
Dic_amount = parseFloat(Dic_amount) + parseFloat(data.rows[i].Dic_amount);
}
$('#' + UserGrid).datagrid('reloadFooter',
[{ "Left_qty": "合计", "Dic_qty": Dic_qty.toFixed(4), "Dic_pirce": Dic_pirce.toFixed(4), "Dic_amount": Dic_amount.toFixed(4) }]
);
},
//查询数据
SelectData: function () {
var param = {
'Header_id': $('#Header_id').val()
};
var actions = {
'pageNum': '1',
'pageSize': '10',
'action': 'SelectData',
'tableId': UserGrid,
'url': '/Ajax/Discount/Return/DicApply_Return.ashx'
};
// var params = sc.MakeParams(JSON2.stringify(actions), JSON2.stringify(param));
// var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
// var data = {};
// getAjax(url, params, function (rs) {
// var rt = eval('(' + rs + ')');
// if (rt.success) {
// data = rt.record;
// } else {
// showTipsMsg(rt.message, 5000, 5);
// };
// });
// //表頭
// com.Assignment(data, 'condition');
// //表體
// $('#' + UserGrid).datagrid('loadData', data.lines);
$('#Sign_status').val(11).trigger('change');//test
//按鈕隱藏
// ["1","3","4","5","10"].includes( $('#Sign_status').val())
//!["2"].includes( $('#Sign_status').val())
// if (
// $('#Sign_status').val() == "1" ||
// // $('#Sign_status').val() == "2" || gw xf.zhu
// $('#Sign_status').val() == "3" ||
// $('#Sign_status').val() == "4" ||
// $('#Sign_status').val() == "5" ||
// $('#Sign_status').val() == "10"
// ) {
// com.HideButton('client.SaveData();');
// }
// if ($('#Sign_status').val() == "" ||
// $('#Sign_status').val() == "1" ||
// $('#Sign_status').val() == "2" ||
// $('#Sign_status').val() == "3" ||
// $('#Sign_status').val() == "4" ||
// $('#Sign_status').val() == "5" ||
// $('#Sign_status').val() == "10"
// ) {
// com.HideButton('client.ApplyData();');
// }
// if ($('#Sign_status').val() == "" ||
// $('#Sign_status').val() == "0" ||
// $('#Sign_status').val() == "2" ||
// $('#Sign_status').val() == "3" ||
// $('#Sign_status').val() == "4" ||
// $('#Sign_status').val() == "5" ||
// $('#Sign_status').val() == "-1" ||
// $('#Sign_status').val() == "10") {
// com.HideButton('client.MCAuditData();');
// } if ($('#Sign_status').val() == "" ||
// $('#Sign_status').val() == "0" ||
// $('#Sign_status').val() == "1" ||
// $('#Sign_status').val() == "2" ||
// $('#Sign_status').val() == "3" ||
// $('#Sign_status').val() == "5" ||
// $('#Sign_status').val() == "-1" ||
// $('#Sign_status').val() == "10") {
// com.HideButton('client.WHAuditData();');
// } if ($('#Sign_status').val() == "" ||
// $('#Sign_status').val() == "0" ||
// $('#Sign_status').val() == "1" ||
// $('#Sign_status').val() == "3" ||
// $('#Sign_status').val() == "4" ||
// $('#Sign_status').val() == "5" ||
// $('#Sign_status').val() == "-1" ||
// $('#Sign_status').val() == "10") {
// com.HideButton('client.GWAuditData();');
// }
// if ($('#Sign_status').val() == "" ||
// $('#Sign_status').val() == "0" ||
// $('#Sign_status').val() == "1" ||
// $('#Sign_status').val() == "2" ||
// $('#Sign_status').val() == "3" ||
// $('#Sign_status').val() == "4" ||
// $('#Sign_status').val() == "-1" ||
// $('#Sign_status').val() == "10") {
// com.HideButton('client.Closed();');
// }
},
//保存
SaveData: function () {
var flag = com.formValidate("#condition");
if (!flag) {
return;
}
//行编辑结束
if (editIndex != -1) {
$('#' + UserGrid).datagrid('endEdit', editIndex); //退出編輯狀態
editIndex = -1;
}
if ($('#Sign_status').val() == "2") {
let head = com.GetElement('condition', 'NA');
let actions = {
'action': 'UpdateScrapDataTax'
};
let data = $('#' + UserGrid).datagrid('getData');
let params = sc.MakeParams(JSON2.stringify(actions), JSON2.stringify(head), JSON2.stringify(data.rows));
let url = '/Ajax/Discount/Return/DicApply_Return.ashx';
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
showTipsMsg('保存成功', 3000, 4);
$('#Header_id').val(rt.message);
client.SelectData();
} else {
showTipsMsg(rt.message, 3000, 5);
};
});
return;
}
var Sign_status = $('#Sign_status').val();
if (Sign_status != undefined && (Sign_status == '0' || Sign_status == '-1')) {
// $('#' + UserGrid).datagrid({ onClickRow: grid.ended });
var data = $('#' + UserGrid).datagrid('getData');
for (var i = 0; i < data.rows.length; i++) {
if (data.rows[i].Dic_qty == "" || data.rows[i].Dic_qty == "NaN" || data.rows[i].Dic_qty == "0") {
showTipsMsg('數量不能為空', 3000, 5);
// $('#' + UserGrid).datagrid('selectRow', i).datagrid('beginEdit', i);
return;
}
if (parseFloat(data.rows[i].Left_amount) < parseFloat(data.rows[i].Dic_amount)) {
$('#Doc_mark').val('存在折讓金額大於待付款金額,請于備註欄註明後續入料時間!');
}
}
var head = com.GetElement('condition', 'NA');
var actions = {
'action': 'InsertScrapData'
};
var params = sc.MakeParams(JSON2.stringify(actions), JSON2.stringify(head), JSON2.stringify(data.rows));
var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
showTipsMsg('保存成功', 3000, 4);
$('#Header_id').val(rt.message);
client.SelectData();
} else {
showTipsMsg(rt.message, 3000, 5);
};
});
} else {
showTipsMsg('当前状态不可再保存', 3000, 3);
}
}
,
//導入明細
SelectItem: function () {
var flag = com.formValidate("#SelectItem");
if (!flag) {
return;
}
var param = com.GetElement('SelectItem', 'NA');
var actions = {
'action': 'SelectItemScrap',
'tableId': 'userTable_item'
};
//固定參數
var params = sc.MakeParams(JSON2.stringify(actions), JSON2.stringify(param));
var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
$('#userTable_item').datagrid("loadData", rt.record);
} else {
$('#userTable_item').datagrid("loadData", { total: 0, rows: [] });
showTipsMsg(rt.message, 3000, 5);
};
});
},
//選擇料號
PickItem: function () {
var rows = $('#userTable_item').datagrid('getSelections');
var old_data = $('#' + UserGrid).datagrid('getData');
var Plant;
for (var i = 0; i < rows.length; i++) {
if (rows[i].Site == 'MH01' || rows[i].Site == 'MH02' || rows[i].Site == 'MH03') {
Plant = 'MH01,MH02,MH03';
} else if (rows[i].Site == 'MH04' || rows[i].Site == 'MH05') {
Plant = 'MH04,MH05';
} else if (rows[i].Site == 'MH06') {
Plant = 'MH06';
} else if (rows[i].Site == 'WF01' || rows[i].Site == 'WF02') {
Plant = 'WF01,WF02';
} else if (rows[i].Site == 'WF03') {
Plant = 'WF03';
}
if (rows[i].Remark != null && rows[i].Remark != "") {
showTipsMsg(rows[i].Gr_line_id + ";該筆資料不可使用", 3000, 5);
return;
}
if (Plant != $('#Plant').val() && old_data.rows.length > 0) {
showTipsMsg(rows[i].Gr_line_id + ";該筆資料廠別不一致", 3000, 5);
return;
}
for (var j = 0; j < old_data.rows.length; j++) {
if (rows[i].Gr_line_id == old_data.rows[j].Gr_line_id && rows[i].Item_no.substr(0, 5) != "4301B") {
showTipsMsg(rows[i].Gr_line_id + ";該筆資料已導入", 3000, 5);
return;
}
}
$('#' + UserGrid).datagrid("insertRow", {
index: 0,
row: {
Gr_line_id: rows[i].Gr_line_id,
Conversion_rate: rows[i].Conversion_rate,
Item_no: rows[i].Item_no,
Merger_no: rows[i].Merger_no,
Hs_name: rows[i].Hs_name,
Gr_no: rows[i].Gr_no,
Po_no: rows[i].Po_no,
Po_line: rows[i].Po_line,
Gr_line: rows[i].Gr_line,
Import_no: rows[i].Import_no,
Invoice_no: rows[i].Invoice_no,
Site: rows[i].Site,
Left_qty: rows[i].Left_qty,
Dic_qty: rows[i].Dic_qty,
Qty: rows[i].Qty,
Dic_pirce: rows[i].Dic_pirce,
Currency: rows[i].Currency,
Net_weight: rows[i].Net_weight,
Cd_no: rows[i].Cd_no,
Weight: rows[i].Weight,
Pirce: rows[i].Pirce,
Billing_flag: rows[i].Billing_flag,
Billing_date: rows[i].Billing_date,
Country_origin: rows[i].Country_origin,
Gr_qty: rows[i].Gr_qty,
Gr_price: rows[i].Gr_price,
Po_qty: rows[i].Po_qty,
Po_price: rows[i].Po_price,
Po_unit: rows[i].Po_unit,
Im_qty: rows[i].Im_qty,
Im_price: rows[i].Im_price,
Model_name: rows[i].Model_name,
Unit: rows[i].Unit,
Sob_id: rows[i].Sob_id,
Createid: rows[i].Createid,
Createby: rows[i].Createby,
Modifyid: rows[i].Modifyid,
Modifyby: rows[i].Modifyby,
Plant: rows[i].Plant,
Left_amount: rows[i].Left_amount,
Vendor_merger: rows[i].Vendor_merger,
Bincode: rows[i].Bincode,
Tax_amount: rows[i].Tax_amount,
Dic_amount: rows[i].Dic_amount,
Gr_year: rows[i].Gr_year,
Gr_date: rows[i].Gr_date,
Tariff_rate: rows[i].Tariff_rate, //add by xf.zhu
Vat_rate: rows[i].Vat_rate //add by xf.zhu
}
});
$('#div_Info').dialog("close");
$('#Plant').val(Plant);
}
client.loadFooter();
},
//刪除明細
DeleteData: function () {
grid.deleterow();
}
,
//申請提交
ApplyData: function () {
if ($('#Sign_status').val() != '0' && $('#Sign_status').val() != '-1') {
showTipsMsg('該狀態不可提交', 3000, 5);
return;
}
if ($('#Header_id').val() > '0') {
} else {
showTipsMsg('請先保存資料', 3000, 5);
return;
}
if ($('#Doc_mark').val() != '') {
$.messager.confirm('Confirm', '折讓總金額大於待付款金額,是否繼續提交?', function (r) {
if (r) {
var paramH = {
'Header_id': $('#Header_id').val(),
'Doc_type': $('#Doc_type').val(),
'Sign_flag': 'Y',
'Sign_status': $('#Sign_status').val(),
'Buyer_name': $('#Buyer_name').combo('getText'),
'Buyer_no': $('#Buyer_no').val()
};
var action = {
// 'action': 'SendData' mark by xf.zhu
'action': 'CustomSend'
};
//固定參數
var params = sc.MakeParams(JSON2.stringify(action), JSON2.stringify(paramH));
var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
showTipsMsg('提交成功', 3000, 4);
client.SelectData();
} else {
showTipsMsg(rt.message, 3000, 5);
};
});
}
});
} else {
var paramH = {
'Header_id': $('#Header_id').val(),
'Doc_type': $('#Doc_type').val(),
'Sign_flag': 'Y',
'Sign_status': $('#Sign_status').val(),
'Buyer_name': $('#Buyer_name').combo('getText'),
'Buyer_no': $('#Buyer_no').val()
};
var action = {
// 'action': 'SendData' mark by xf.zhu
'action': 'CustomSend'
};
//固定參數
var params = sc.MakeParams(JSON2.stringify(action), JSON2.stringify(paramH));
var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
showTipsMsg('提交成功', 3000, 4);
client.SelectData();
} else {
showTipsMsg(rt.message, 3000, 5);
};
});
}
},
//簽核記錄
SignList: function () {
var url = "/Form/Discount/Return/DicApplySignList.aspx?Header_id=" + $('#Header_id').val();
openDialogUrl_U(url, 'DicApplySignList', '簽核記錄', 700, 500, 50, 50, '/Form/Discount/Return/DicApplyAdd_Return.aspx');
},
//MC 簽核
MCAuditData: function () {
$('#Doc_mark_T').html($('#Doc_mark').val());
$('#div_MC').dialog("open");
},
MCAudit: function (Sign_flag) {
var flag = com.formValidate("#div_MC");
if (!flag) {
return;
}
var param = {
'Header_id': $('#Header_id').val(),
'Doc_type': $('#Doc_type').val(),
'Sign_flag': Sign_flag,
'Sign_status': $('#Sign_status').val(),
'Location': $('#Location_T').combo('getText'),
'Sign_remark': $('#Sign_remark_mc').val()
};
var actions = {
//'action': 'SendData' mark by xf.zhu
'action': 'MCSendScrap'
};
//固定參數
var params = sc.MakeParams(JSON2.stringify(actions), JSON2.stringify(param));
var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
showTipsMsg('提交成功', 3000, 4);
$('#div_MC').dialog("close");
client.SelectData();
} else {
showTipsMsg(rt.message, 3000, 5);
};
});
},
//倉庫簽核
WHAuditData: function () {
$('#div_WH').dialog("open");
},
WHAudit: function (Sign_flag) {
var flag = com.formValidate("#div_WH");
if (!flag) {
return;
}
var param = {
'Header_id': $('#Header_id').val(),
'Doc_num': $('#Doc_num').val(),
'Doc_type': $('#Doc_type').val(),
'Sign_flag': Sign_flag,
'Sign_status': $('#Sign_status').val(),
'Sign_remark': $('#Sign_remark_wh').val()
};
var actions = {
//'action': 'SendData' mark by xf.zhu
'action': 'WHSendScrap' //modify by xf.zhu
};
//固定參數
var params = sc.MakeParams(JSON2.stringify(actions), JSON2.stringify(param));
var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
showTipsMsg('提交成功', 3000, 4);
$('#div_WH').dialog("close");
client.SelectData();
} else {
showTipsMsg(rt.message, 3000, 5);
};
});
}
,
//關務簽核
GWAuditData: function (Line_id) {
$('#div_GW').dialog("open");
},
GWAudit: function (Sign_flag) {
var flag = com.formValidate("#div_GW");
if (!flag) {
return;
}
var param = {
'Header_id': $('#Header_id').val(),
'Doc_type': $('#Doc_type').val(),
'Sign_flag': Sign_flag,
'Sign_status': $('#Sign_status').val(),
'Sign_remark': $('#Sign_remark_gw').val()
};
var actions = {
// 'action': 'SendData' mark by xf.zhu
'action': 'GWSendScrap'//modify by xf.zhu
};
//固定參數
var params = sc.MakeParams(JSON2.stringify(actions), JSON2.stringify(param));
var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
showTipsMsg('提交成功', 3000, 4);
$('#div_GW').dialog("close");
client.SelectData();
} else {
showTipsMsg(rt.message, 3000, 5);
};
});
}
,
//明細上傳
initUpload_item: function () {
$('#upload_item').fineUploader({
request: { endpoint: '/Ajax/postfile.ashx?actions=DicItemScrap' },
text: { uploadButton: '上传' },
autoUpload: true,
debug: true
}).on('upload', function (id, name) {
$.messager.progress({ title: '请稍等', msg: '正在上传...' });
}).on('complete', function (event, id, name, response) {
//alert(response);
//var rt_data = eval('(' + response + ')');
$.messager.progress('close');
if (response.success) {
$('#userTable_item').datagrid("loadData", response.record);
} else {
$('#userTable_item').datagrid("loadData", { total: 0, rows: [] });
showTipsMsg(response.message, 3000, 5);
}
}).on('progress', function (target, id, name, loaded, total) {
$.messager.progress('bar').progressbar('setValue', Math.ceil(loaded * 100 / total));
if (loaded >= total) {
$.messager.progress('close');
$.messager.progress({ title: '请稍等', msg: '上传完成,正在导入处理...', interval: 300, text: '' });
}
}).on('error', function (target, id, name, reason, maybeXhrOrXdr) {
//com.message('error', reason);
// console.log(reason);
showTipsMsg(reason, 3000, 5);
});
$("#upload_item").css("overflow", "hidden");
$(".qq-upload-button").css("overflow", "hidden");
$(".qq-drop-processing,.qq-upload-list").hide();
}
,
//獲取供應商
GetVendor: function () {
var actions = {
'action': 'GetVendor',
'url': '/Ajax/Discount/Return/DicApply_Return.ashx'
};
var params = sc.MakeParams(JSON2.stringify(actions));
var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
var data = {};
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
data = rt.record;
$('#Vendor_name').val(data.rows[0].Vendor_name);
$('#Vendor_code').val(data.rows[0].Vendor_code);
$('#Vendor_address').val(data.rows[0].Vendor_address);
$('#Contacts_name').val(data.rows[0].Contacts_name);
$('#Contacts_tel').val(data.rows[0].Contacts_tel);
$('#Contacts_mail').val(data.rows[0].Contacts_mail);
$('#Residual_amount').val(data.rows[0].Residual_amount);
} else {
showTipsMsg(rt.message, 5000, 5);
};
});
},
//結案 FI?
Closed: function () {
$('#div_Close').dialog("open");
},
ClosedData: function (Sign_flag) {
var flag = com.formValidate("#div_Close");
if (!flag) {
return;
}
var param = {
'Sign_remark': $('#Sign_remark_close').val(),
'Header_id': $('#Header_id').val(),
'Doc_num': $('#Doc_num').val(),
'Doc_type': $('#Doc_type').val(),
'Sign_flag': Sign_flag
};
var actions = {
'action': 'FiDicClose'
};
//固定參數
var params = sc.MakeParams(JSON2.stringify(actions), JSON2.stringify(param));
var url = '/Ajax/Discount/Return/DicApply_Return.ashx';
getAjax(url, params, function (rs) {
var rt = eval('(' + rs + ')');
if (rt.success) {
showTipsMsg('提交成功', 3000, 4);
$('#div_Close').dialog("close");
client.SelectData();
} else {
showTipsMsg(rt.message, 3000, 5);
};
});
}
,
//導出
ToExcel: function () {
if ($('#Header_id').val() == "") {
showTipsMsg('請先保存', 2000, 3);
return;
}
var param = {
'Header_id': $('#Header_id').val()
};
var actions = {
'action': 'DicApplyLine_Excel'
};
location = '/Form/BASE/Excel_Down.aspx?actions=' + JSON2.stringify(actions) + '¶m_header=' + JSON2.stringify(param);
},
FiToExcel: function () {
var param = {
'Header_id': $('#Header_id').val()
};
var actions = {
'action': 'DicFiData_Excel'
};
location = '/Form/BASE/Excel_Down.aspx?actions=' + JSON2.stringify(actions) + '¶m_header=' + JSON2.stringify(param);
},
// // maintain Dialog add by xf.zhu
DicApplyScrapMaintain: function () {
var url = "/Form/Discount/Scrap/DicApplyScrapMaintain.aspx?Header_id=" + $('#Header_id').val();
openDialogUrl_U(url, 'DicApplyScrapMaintain', 'maintain', 700, 500, 50, 50, '/Form/Discount/Scrap/DicApplyScrapMaintain.aspx');
},
}
// strategys
let default_s = function () {
this.initialize.apply(this, ["调用vendors_s的dosomething "]);//init when new default
}
let vendor_s = function () {
// this.datagrid = { ...this.datagrid, columns: [...this.datagrid.columns.map(x => [...x.filter(f=> {if (f.field in ("Vat_amount" ,"Tariff_amount")) {f.hidden=true; return f;} else return f; })])], };//返回修改定义具体的属性。 复制原型链上的datagrid.
this.datagrid = { ...this.datagrid}
for (const key in this.datagrid.columns[0]) {
if (Object.hasOwnProperty.call(this.datagrid.columns[0], key)) {
const element = this.datagrid.columns[0][key];
if ( ["Vat_amount" ,"Tariff_amount"].includes(element.field)) {
this.datagrid.columns[0][key].hidden=true;
}
}
}
this.initialize.apply(this, ["调用vendors_s的dosomething "]);
};
//直接copy columns是最快的。
let GW_s = function () {
this.datagrid = { ...this.datagrid, columns: [...this.datagrid.columns.map(x => [...x, { field: "unitcost", title: "unitcost ", width: 100, height: 30 }])], };//返回修改定义具体的属性。 复制原型链上的datagrid.
this.initialize.apply(this, ["调用GW_S的dosomething "]);
};
default_s.prototype = Object.create(DicApplyAdd_Scrap);
vendor_s.prototype = Object.create(DicApplyAdd_Scrap);// inherit dic。
GW_s.prototype = Object.create(DicApplyAdd_Scrap)
//context management
let Context = function () {
this.strategy = null;
};
Context.prototype = {
setStrategy: function (strategy) {
this.strategy = strategy;
},
exeStrategy: function (params) {
// this.strategy.doSomething();// when new do this init.
// this.params()??
},
getStrategy: function () {
return this.strategy;
},
changeStrategy: function (state) {//自动选择策略
let switch_obj = {//设置策略
"1":()=>{
this.strategy = new vendor_s();//
return this.strategy;
},
"-1":()=>{
this.strategy = new vendor_s();//
return this.strategy;
},
"2":()=>{
this.strategy = new GW_s();// only one strategy;
return this.strategy;
},
default_state:()=>{
this.strategy = new default_s();// only one strategy;
return this.strategy;
}
}
if(typeof(switch_obj[state]) !== 'function') {
return switch_obj["default_state"](); //default
} else {
return switch_obj[state]();// new and auto init.
}
}
};
// 实例相关具体策略 .....
const strategy_status_context = new Context(); //必须new 下面才去原型上找setStrategy这个方法。
//初始化
$(document).ready(function () {
let status = "default_state";
client = strategy_status_context.changeStrategy(status);
//must call trigger
$('#Sign_status').bind('change',function () {// 输入 或 属性改变时
client = strategy_status_context.changeStrategy($('#Sign_status').val())
} )
// //global function to force trigger call when input change
// (function ($) {
// var originalVal = $.fn.val;
// $.fn.val = function (value) {
// this.trigger("change");
// return originalVal.call(this, value);
// };
// })(jQuery);
// grid = new sc.editGrid($('#' + UserGrid));
// Header_id = com.getVarible('Header_id');
client.SelectData();
// if (Header_id != "0") {
// $('#Header_id').val(Header_id);
// client.SelectData();
// } else {
// client.GetVendor();
// }
// client.initUpload_item();
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。