1 Star 0 Fork 0

唐心/JSPatternDesign

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Untitled-1.js 39.56 KB
一键复制 编辑 原始数据 按行查看 历史
唐心 提交于 2021-10-07 22:17 . Added Untitled-1.js
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
var UserGrid = 'userGrid';
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');
strategy_status_context.changeStrategy($('#Sign_status').val());//自动选择策略。
client = strategy_status_context.getStrategy();
//表體
$('#' + UserGrid).datagrid('loadData', data.lines);
//按鈕隱藏
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";
strategy_status_context.changeStrategy(status);
client = strategy_status_context.getStrategy();
// 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