You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MsTemplet/LayShow4.js

534 lines
26 KiB
JavaScript

(function (window, undefined) {
var id = UrlParm.parm("id");
var cid = UrlParm.parm("cid");
var tid = UrlParm.parm("tid");
var page = UrlParm.parm("p");
var type = UrlParm.parm("t");
var _Quiry = window.Quiry,
_$ = window.$;
var Quiry = window.Quiry = window.$ = function () {
return new Quiry.fn.Init();
};
//defined variable
var _formData = "",
_url = "",
_yMax = 0,
_hasChildAccounting = false,
_storeCwAccitems = false,
_storeCodeCurrency = false,
_storeCustCode = false,
_storeDept = false,
_storeOpCode = false,
_storeCwItem = false;
Quiry.fn = Quiry.prototype = {
Init: function () {
if (page == "1") {
Quiry.ListForService();
}
else if (page == "2") {
document.getElementById("lblCust").style.display = "none";
document.getElementById("selCust").style.display = "none";
document.getElementById("lblDept").style.display = "none";
document.getElementById("selDept").style.display = "none";
document.getElementById("lblSale").style.display = "none";
document.getElementById("selSale").style.display = "none";
document.getElementById("lblItem").style.display = "none";
document.getElementById("selItems").style.display = "none";
Quiry.fn.CwAccitems();
Quiry.fn.CodeCurrency();
/*Quiry.fn.CustCode();
Quiry.fn.Dept();
Quiry.fn.OpCode();
Quiry.fn.CwItem();*/
}
},
Param: function () {
//得到LINKURL(图表查询的程序段)
Ext.Ajax.request({
async: false,
url: '/MvcShipping/MsTemplet/GetLinkInfo',
params: { id: id, templetid: tid },
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
var data = result.data;
//var _data = document.getElementById("img1");
Quiry.URL = data[0].LINKURL;
Quiry.TempletURL = data[0].TEMPLETURL;
}
},
scope: this
});
},
OnLoadForService: function (dateStr, objStr, dataStr) {
//store Ext.create('DsExt.ux.RefTableStore'
//定义数据集(根据不同类定义不同数据集)
switch (type) {
case "0":
Quiry.fn.Histogram(dateStr, objStr, dataStr);
break;
case "1":
Quiry.fn.Trend(dateStr, objStr, dataStr);
break;
}
},
OnLoadForAccounting: function (dataType, currency, accid, period, acctype, subjectAccount) {
//定义数据集(根据不同类定义不同数据集)
switch (type) {
case "0":
//总账管理-账簿-图表分析
Quiry.fn.Plot(dataType, currency, accid, period, acctype, subjectAccount);
break;
case "1":
break;
}
},
Quest: function () {
//Ext.Ajax.request
},
Histogram: function (dateStr, objStr, dataStr) {
var storeList = Ext.create('Ext.data.Store', {
fields: [
{ name: 'OBJNAME', type: 'string' },
{ name: 'OBJNUM', type: 'number' }
],
remoteSort: true,
proxy: {
type: 'ajax',
url: Quiry.URL
}
});
storeList.load({ params: { condition: dateStr, objname: objStr, sumfieldtype: dataStr} });
storeList.on("load", function (storeList) {
//画统计图
if (storeList.getCount() > 0) {
var g = new html5jp.graph.vbar("sample");
if (!g) { return }
var items = [];
var item = [""];
for (var iCount = 0; iCount < storeList.getCount(); iCount++) {
item.push(parseInt(storeList.getAt(iCount).get("OBJNUM")));
}
items.push(item);
var params = {
x: [""],
y: [""],
barShape: "line"
};
for (var iCount = 0; iCount < storeList.getCount(); iCount++) {
if (storeList.getAt(iCount).get("OBJNAME") == "") {
params.x.push(" ");
}
else {
params.x.push(storeList.getAt(iCount).get("OBJNAME"));
}
}
g.draw(items, params);
}
});
},
Plot: function (dataType, currency, accid, period, acctype, subjectAccount) {
var storeList = Ext.create('Ext.data.Store', {
fields: [
{ name: 'OBJNAME', type: 'string' },
{ name: 'OBJNUM', type: 'number' }
],
remoteSort: true,
proxy: {
type: 'ajax',
url: Quiry.URL
}
});
storeList.load({});
},
Trend: function (dateStr, objStr, dataStr) {
var dateArr = new Array();
var itemsArr = new Array();
//得到查询列
Ext.Ajax.request({
async: false,
url: Quiry.URL,
params: { condition: dateStr, objname: objStr, sumfieldtype: dataStr },
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
var data = result.data;
var fieldCollection = [{ name: 'MONTHNAME', type: 'date'}];
for (var iCount = 0; iCount < data.length; iCount++) {
fieldCollection.push({ name: data[iCount].OBJNAME, type: 'date' });
}
Quiry.URL = Quiry.URL.replace("DataListForColumn", "DataListForTable");
Ext.Ajax.request({
async: false,
url: Quiry.URL,
params: { condition: dateStr, objname: objStr, sumfieldtype: dataStr },
callback: function (options2, success2, response2) {
if (success2) {
var result2 = Ext.JSON.decode(response2.responseText);
var data2 = result2;
for (var iCount = 0; iCount < data2.length; iCount++) {
var itemArr = new Array();
dateArr.push(data2[iCount].MONTHNAME);
itemArr.push(data[iCount].OBJNAME);
for (var jCount = 0; jCount < data.length; jCount++) {
var columnValue = data[jCount].OBJNAME;
var monthValue = data2[iCount][columnValue];
itemArr.push(monthValue);
}
itemsArr.push(itemArr);
}
}
}
});
}
},
scope: this
});
var lg = new html5jp.graph.line("sample");
if (!lg) { return; }
var items = itemsArr;
var arr = Quiry.fn.Sequence(items);
var params = {
x: [""],
y: [""],
yMax: _yMax,
yMin: 0,
lineWidth: [], //1, 1, 1
dotRadius: [], //3, 3, 3
dotType: []//"square", "disc", "disc", "disc"
};
for (var iCount = 0; iCount < arr.length; iCount++) params.y.push(arr[iCount]); //y轴值
for (var iCount = 0; iCount < dateArr.length; iCount++) {
params.x.push(dateArr[iCount]); //x轴值
params.lineWidth.push(1);
params.dotRadius.push(3);
params.dotType.push("disc");
}
lg.draw(items, params);
},
Sequence: function (inputItems) {
var resultArr = new Array();
var limit = 0;
//求最大值
var max = inputItems[0][1];
for (var iCount = 0; iCount < inputItems.length; iCount++) {
for (var jCount = 0; jCount < inputItems[iCount].length; jCount++) {
var a = max;
var b = inputItems[iCount][jCount];
if (max < inputItems[iCount][jCount]) max = inputItems[iCount][jCount];
}
}
//求序列
if (max >= 0 && max < 10) for (var iCount = 0; iCount < max; iCount++) resultArr.push(iCount), limit = 1, _yMax = iCount;
else if (max >= 10 && max < 100) for (var iCount = 0; iCount < max; iCount = iCount + 10) resultArr.push(iCount), limit = 10, _yMax = iCount;
else if (max >= 100 && max < 1000) for (var iCount = 0; iCount < max; iCount = iCount + 100) resultArr.push(iCount), limit = 100, _yMax = iCount;
else if (max >= 1000 && max < 10000) for (var iCount = 0; iCount < max; iCount = iCount + 1000) resultArr.push(iCount), limit = 1000, _yMax = iCount;
else if (max >= 10000 && max < 100000) for (var iCount = 0; iCount < max; iCount = iCount + 10000) resultArr.push(iCount), limit = 10000, _yMax = iCount;
else if (max >= 100000 && max < 1000000) for (var iCount = 0; iCount < max; iCount = iCount + 100000) resultArr.push(iCount), limit = 100000, _yMax = iCount;
else if (max >= 1000000 && max < 10000000) for (var iCount = 0; iCount < max; iCount = iCount + 1000000) resultArr.push(iCount), limit = 1000000, _yMax = iCount;
else if (max >= 10000000 && max < 100000000) for (var iCount = 0; iCount < max; iCount = iCount + 10000000) resultArr.push(iCount), limit = 10000000, _yMax = iCount;
else if (max >= 100000000 && max < 1000000000) for (var iCount = 0; iCount < max; iCount = iCount + 100000000) resultArr.push(iCount), limit = 100000000, _yMax = iCount;
else if (max >= 1000000000 && max < 10000000000) for (var iCount = 0; iCount < max; iCount = iCount + 1000000000) resultArr.push(iCount), limit = 1000000000, _yMax = iCount;
else if (max >= 10000000000 && max < 100000000000) for (var iCount = 0; iCount < max; iCount = iCount + 10000000000) resultArr.push(iCount), limit = 10000000000, _yMax = iCount;
else if (max >= 100000000000 && max < 1000000000000) for (var iCount = 0; iCount < max; iCount = iCount + 100000000000) resultArr.push(iCount), limit = 100000000000, _yMax = iCount;
_yMax = _yMax + limit;
return resultArr;
},
CwAccitems: function () {
_storeCwAccitems = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwAccitemsGlModel',
proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' }
});
_storeCwAccitems.load({ params: { condition: "ISENABLE=1"} });
_storeCwAccitems.on("load", function (_storeCwAccitems) {
var strSubject = "";
document.getElementById("selSubject").length = 0;
strSubject = "<option value='default' selected='selected'>请选择科目</option>";
for (var i = 0; i < _storeCwAccitems.getCount(); i++) {
strSubject += "<option value='" + _storeCwAccitems.getAt(i).get("ACCID") + "' >" + _storeCwAccitems.getAt(i).get("ACCIDNAME") + "</option>";
}
document.getElementById("selSubject").innerHTML = strSubject;
});
},
CwAccitemChange: function () {
//判断是否显示核算项目
document.getElementById("selCustomer").length = 0;
document.getElementById("selDepartment").length = 0;
document.getElementById("selSaler").length = 0;
document.getElementById("selItem").length = 0;
document.getElementById("selProfession").value = "";
document.getElementById("lblCust").style.display = "none";
document.getElementById("selCust").style.display = "none";
document.getElementById("lblDept").style.display = "none";
document.getElementById("selDept").style.display = "none";
document.getElementById("lblSale").style.display = "none";
document.getElementById("selSale").style.display = "none";
document.getElementById("lblItem").style.display = "none";
document.getElementById("selItems").style.display = "none";
Ext.Ajax.request({
url: '/MvcShipping/RptCwGLDetailColumn/GetIsSubject',
params: {
condition: "ACCID='" + document.getElementById("selSubject").value + "'",
ACCDATEbgn: document.getElementById("txtPeriod").value
},
callback: function (options, success, response) {
var result = Ext.JSON.decode(response.responseText);
if (success) {
if (!result.Success) {
/*Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK });
_field.setValue("");*/
return;
}
//
var strItem = result.Message.toString();
if (strItem == "") {
_hasChildAccounting = false;
}
else {
_hasChildAccounting = true;
Ext.define('SubjectAccountModel', { extend: 'Ext.data.Model', fields: [{ name: 'DC', type: 'string' }, { name: 'NAME', type: 'string'}] });
var storeSubjectAccount = Ext.create('DsExt.ux.RefTableStore', {
model: 'SubjectAccountModel',
proxy: { url: '/MvcShipping/RptCwGLDetailColumn/GetSubjectAccount' }
});
storeSubjectAccount.load({ params: { condition: "ACCID='" + document.getElementById("selSubject").value + "'", ACCDATEbgn: document.getElementById("txtPeriod").value} });
var argItems = result.Message.toString().split(",");
strItem = argItems[0].toString();
//
if (strItem == "客户") {
Quiry.fn.CustCode();
document.getElementById("selProfession").value = "客户";
document.getElementById("lblCust").style.display = "block";
document.getElementById("selCust").style.display = "block";
}
else if (strItem == "部门") {
Quiry.fn.Dept();
document.getElementById("selProfession").value = "部门";
document.getElementById("lblDept").style.display = "block";
document.getElementById("selDept").style.display = "block";
}
else if (strItem == "人员") {
Quiry.fn.OpCode();
document.getElementById("selProfession").value = "人员";
document.getElementById("lblSale").style.display = "block";
document.getElementById("selSale").style.display = "block";
}
else if (strItem == "项目") {
Quiry.fn.CwItem();
document.getElementById("selProfession").value = "项目";
document.getElementById("lblItem").style.display = "block";
document.getElementById("selItems").style.display = "block";
}
}
/*this.onRefreshClick();*/
} else {
Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK });
_field.setValue("");
return;
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
CodeCurrency: function () {
_storeCodeCurrency = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCurrencyModel',
proxy: { url: '/MvcShipping/RptCwGLDetailColumn/GetCodeCurrencyList' }
});
_storeCodeCurrency.load();
_storeCodeCurrency.on("load", function (_storeCodeCurrency) {
var strCurrency = "";
document.getElementById("selCurrency").length = 0;
strCurrency = "<option value='default' selected='selected'>请选择币别</option>";
for (var i = 0; i < _storeCodeCurrency.getCount(); i++) {
strCurrency += "<option value='" + _storeCodeCurrency.getAt(i).get("CODENAME") + "' >" + _storeCodeCurrency.getAt(i).get("CODENAME") + "</option>";
}
document.getElementById("selCurrency").innerHTML = strCurrency;
});
},
CustCode: function () {
_storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
_storeCustCode.load({ params: { condition: ""} });
_storeCustCode.on("load", function (_storeCustCode) {
var strCustCode = "";
document.getElementById("selCustomer").length = 0;
strCustCode = "<option value='default' selected='selected'>请选择客户</option>";
for (var i = 0; i < _storeCustCode.getCount(); i++) {
strCustCode += "<option value='" + _storeCustCode.getAt(i).get("CustCode") + "' >" + _storeCustCode.getAt(i).get("CodeAndName") + "</option>";
}
document.getElementById("selCustomer").innerHTML = strCustCode;
});
},
Dept: function () {
_storeDept = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.DeptModel',
proxy: { url: '/CommMng/BasicDataRef/GetDeptList_All_Group' }//proxy: { url: '/CommMng/BasicDataRef/GetDeptList' }
});
_storeDept.load({ params: { condition: ""} });
_storeDept.on("load", function (_storeDept) {
var strDept = "";
document.getElementById("selDepartment").length = 0;
strDept = "<option value='default' selected='selected'>请选择部门</option>";
for (var i = 0; i < _storeDept.getCount(); i++) {
strDept += "<option value='" + _storeDept.getAt(i).get("GID") + "' >" + _storeDept.getAt(i).get("DEPTNAME") + "</option>";
}
document.getElementById("selDepartement").innerHTML = strDept;
});
},
OpCode: function () {
_storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
_storeOpCode.load();
_storeOpCode.on("load", function (_storeOpCode) {
var strOpCode = "";
document.getElementById("selSale").length = 0;
strOpCode = "<option value='default' selected='selected'>请选择人员</option>";
for (var i = 0; i < _storeOpCode.getCount(); i++) {
strOpCode += "<option value='" + _storeOpCode.getAt(i).get("UserCode") + "' >" + _storeOpCode.getAt(i).get("CodeAndName") + "</option>";
}
document.getElementById("selSale").innerHTML = strOpCode;
});
},
CwItem: function () {
_storeCwItem = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwItemModel',
proxy: { url: '/CommMng/BasicDataRef/GetCwItemList' }
});
_storeCwItem.load();
_storeCwItem.on("load", function (_storeCwItem) {
var strCwItem = "";
document.getElementById("selItem").length = 0;
strCwItem = "<option value='default' selected='selected'>请选择项目</option>";
for (var i = 0; i < _storeCwItem.getCount(); i++) {
strCwItem += "<option value='" + _storeCwItem.getAt(i).get("ITEMCODE") + "' >" + _storeCwItem.getAt(i).get("CodeAndName") + "</option>";
}
document.getElementById("selItem").innerHTML = strCwItem;
});
}
};
Quiry.fn.Init.prototype = Quiry.fn;
Quiry.extend = Quiry.fn.extend = function () {
var target = this, length = arguments.length, options;
for (var iCount = 0; iCount < length; iCount++) {
if ((options = arguments[iCount]) != null) {
for (var name in options) {
var copy = options[name];
target[name] = copy;
}
}
}
return target;
};
Quiry.extend({
Input: [],
Output: [],
IsEmpty: false,
URL: "",
TempletURL: "",
ListForService: function () {
var dateStr = document.getElementById("selDate").value;
var objStr = document.getElementById("selObj").value;
var dataStr = document.getElementById("selInquire").value;
document.getElementById("canvasContain").innerHTML = "";
document.getElementById("canvasContain").innerHTML = "<canvas class=\"canvas\" id=\"sample\" width=\"" + document.documentElement.clientWidth + "\" height=\"" + (document.documentElement.clientHeight - 20) + "\"></canvas><div id=\"sampleText\"></div>";
Quiry.fn.Param();
Quiry.fn.OnLoadForService(dateStr, objStr, dataStr);
},
ListForAccounting: function () {
//dataType, currency, accid, period, acctype, subjectAccount
var dataType = document.getElementById("selType").value;
var currency = document.getElementById("selCurrency").value;
var accid = document.getElementById("selSubject").value;
var period = document.getElementById("").value;
var acctype = ""; // document.getElementById("selProfession").value;
var subjectAccount = ""; // document.getElementById("").value;
if (document.getElementById("selProfession").value == "customer") {
acctype = "customer";
subjectAccount = document.getElementById("selCust").value;
}
else if (document.getElementById("selProfession").value = "department") {
acctype = "department";
subjectAccount = document.getElementById("selDept").value;
}
else if (document.getElementById("selProfession").value = "sale") {
acctype = "sale";
subjectAccount = document.getElementById("selSale").value;
}
else if (document.getElementById("selProfession").value = "item") {
acctype = "item";
subjectAccount = document.getElementById("selItem").value;
}
Quiry.fn.Param();
Quiry.fn.OnLoadForAccounting(dataType, currency, accid, period, acctype, subjectAccount);
},
CwAccitemChange: function () {
Quiry.fn.CwAccitemChange();
},
Info: function () { },
ShowParam: function () {
var searchWidth = document.getElementById("searchParamContain");
var width = document.documentElement.clientWidth;
var height = document.documentElement.clientHeight;
document.getElementById("searchParamContain").style.left = (document.documentElement.clientWidth / 2 - 130) + "px";
document.getElementById("searchParamContain").style.top = (document.documentElement.clientHeight / 2 - 80) + "px";
document.getElementById("mask").style.display = "block";
document.getElementById("searchParamContain").style.display = "block";
},
HideParam: function () {
document.getElementById("mask").style.display = "none";
document.getElementById("searchParamContain").style.display = "none";
Quiry.ListForService();
}
});
var rootQuiry = Quiry(document);
window.onresize = function () {
document.getElementById("sample").setAttribute("width", document.documentElement.clientWidth);
document.getElementById("sample").setAttribute("height", document.documentElement.clientHeight - 20);
}
} (window));