1 Star 0 Fork 0

唐心/JSPatternDesign

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Untitled-2.js 40.18 KB
一键复制 编辑 原始数据 按行查看 历史
唐心 提交于 2021-10-07 22:17 . Added Untitled-1.js
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
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) + '&param_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) + '&param_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();
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dangxin/jspattern-design.git
git@gitee.com:dangxin/jspattern-design.git
dangxin
jspattern-design
JSPatternDesign
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385