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/SysMng/ViewJs/SysRoleTaskQuery/SysRoleTaskQueryEdit.js

691 lines
22 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.SysRoleTaskQueryEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.SysRoleTaskQueryEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.SysRoleTaskQueryEdit, Ext.Panel, {
ParentWin: null,
2 years ago
opStatus: 'add',
StoreList: null,
EditRecord: null,
Editdata: null,
seaeop: "",
seaecustservice: "",
reason: "",
editype: '',
BALANCE: 0,
CargoFieldWidth: 235,
initUIComponents: function () {
this.serialNo = 0;
//this.bodyDel = [];
this.itemindex = 1;
//#region combox定义
var _this = this;
this.StoreSysModule = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.ModuleModel',
proxy: { url: '/MvcShipping/MsBaseInfo/GetSysModuleList' }
});
this.StoreSysModule.load({
params: { condition: "" },
waitMsg: '正在查询数据...',
callback: function (options, success, response) {
//if (success) {
// //判断是否显示总账凭证按钮
// if (options.length > 0) {
// Ext.getCmp('btnAddCwVouchers').show();
// this.isCwVouchers = true;
// } else {
// Ext.getCmp('btnAddCwVouchers').hide();
// this.isCwVouchers = false;
// }
// Ext.getCmp('btnSelCwVouchers').hide();
//}
},
scope: this
});
this.comboxSysModule = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreSysModule,
fieldLabel: '模块列表',
forceSelection: true,
id: 'sys_module',
name: 'MODNAME',
valueField: 'NAME',
displayField: 'DESCRIPTION',
//width: this.CargoFieldWidth,
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
//if (combo.value === 'R') {
//} else if (combo.value === 'D') {
//} else {
//}
//选中时设置MODCNNAME 和 URL 值
var _data = records[0].data;
//this.formHead.getForm().findField('MODCNNAME').setValue(_data.DESCRIPTION);
this.formHead.getForm().findField('URL').setValue(_data.MODULEURL);
}
//this.setWXPStatus();
}
}
});
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'companymb',
proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
//proxy: { url: '/MvcShipping/MsCompanys/GetNoPicDataList' }
});
this.storeCompany.load({ params: { condition: "" } });
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '分公司',
store: this.storeCompany,
labelWidth: 70,
name: 'companyid',
valueField: 'gid',
displayField: 'name'
});
this.storeISSTOP = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeISSTOP.add({ "DC": true, "NAME": "是" });
this.storeISSTOP.add({ "DC": false, "NAME": "否" });
this.comboxISSTOP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '是否停用',
store: this.storeISSTOP,
valueField: 'DC',
displayField: 'NAME',
name: 'ISSTOP'
});
this.storeRole = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.GeneralValue',
proxy: { url: '/CommMng/BasicDataRef/GetRoleList' }
});
this.storeRole.load({ params: { condition: "" } });
this.comboxRole = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: "角色", //'卸货港',
store: this.storeRole,
name: 'RoleId',
matchFieldWidth: false,
// forceSelection: true,
valueField: 'GID',
queryMode: 'local',
//queryMode: 'remote',
//minChars: 2,
//queryParam: 'RoleName',
displayField: 'GVALUE',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
//选中时设置RoleName
var _data = records[0].data;
this.formHead.getForm().findField('RoleName').setValue(_data.GVALUE);
}
//this.setWXPStatus();
}
}
});
//#endregion
//#region 编辑formHead 基本信息
this.formHead = Ext.widget('form', {
title: '工作台待办业务信息',
region: 'north',
frame: true,
bodyPadding: 2,
// collapsed: false,
// collapsible: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '1 1 1 1',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: 'GID',
name: 'GID', hidden: true
}
//, {
// fieldLabel: 'CompId',
// name: 'CompId', hidden: true
//}, {
// fieldLabel: Zi.LAN.CODENAME,
// name: 'CODENAME',flex:1
//}, {
// fieldLabel: Zi.LAN.SHORTNAME,
// name: 'SHORTNAME', flex: 1
//}, {
// fieldLabel: Zi.LAN.DESCRIPTION,
// name: 'DESCRIPTION', flex: 3
//}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '工作台项目名称',
name: 'BSTYPE', flex: 1
},
this.comboxRole,
this.comboxSysModule,
{
fieldLabel: 'RoleName',
name: 'RoleName', flex: 1, hidden: true
}, {
fieldLabel: 'FormName',
name: 'FormName', flex: 1
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxISSTOP,
this.comboxCompany,
{
fieldLabel: '顺序',
xtype: 'numberfield',
name: 'SORT', flex: 1
},
{
fieldLabel: 'URL',
name: 'URL', flex: 1, readOnly: true
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textareafield',
items: [
{
fieldLabel: 'SQLSTR',
height: 60, grow: true,
name: 'SQLSTR', flex: 1
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textareafield',
items: [
{
fieldLabel: '查询条件界面值',
height: 60, grow: true,
name: 'FIELDVALUES'
},
{
fieldLabel: '备注',
height: 60, grow: true,
name: 'REMARK'
}
]
}
, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textareafield',
items: [
{
xtype: 'textareafield',
grow: true,
fieldLabel: "查询条件值", //'备 注',
height: 60,
name: 'SQLCONTEXT',
anchor: '100%'
}
]
}
]//end items(fieldset 1)
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
_this = this;
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}]
}); //end 按钮Toolbar
//#endregion
//#region 框架结构
this.panelSeae = new Ext.Panel({
layout: "border",
region: 'center',
animate: true,
bodyStyle: 'border-width:0 0 0 0;',
// bodyStyle: 'overflow-x:hidden; overflow-y:scroll',
frame: false,
items: [this.panelBtn, this.formHead]
});
Ext.apply(this, {
items: [this.panelSeae]
});
//#endregion
//#region 其他
parentWin = window.parent.opener;
this.InitData('', '');
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function (pmfno, ops) {
this.opStatus = 'add';
var condition = '';
_this = this;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
var GID = getQueryString("GID");
this.opStatus = getQueryString("opstatus");
if (ops != '') {
this.opStatus = ops;
}
this.setBtnStatus(this.BillType);
this.LoadData(this.opStatus, GID);
}, //end InitData
LoadData: function (opstatus, GID) {
this.serialNo = 0;
//this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/SysMng/SysRoleTaskQuery/GetData',
params: {
handle: opstatus,
GID: GID
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
data = result.data;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(data);
this.LoadInit();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
//if (this.opStatus == 'edit') {
// this.storeBodyList.load({ params: { GID: GID} });
//} else {
// this.storeBodyList.load({ params: { GID: '' } });
//}
},
scope: this
});
}, // end LoadDate
//#endregion
//#region 保存
Save: function (type) {
var _this = this;
//var basicForm = this.formEdit.getForm();
var basicForm = this.formHead.getForm();
if (!basicForm.isValid()) {
return;
}
//if (!basicForm2.isValid()) {
// return;
//}
var bodydatas = [];
//for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
// var member = this.storeBodyList.getAt(i);
// bodydatas.push(member);
//}
//var jsonBody = ConvertRecordsToJson(bodydatas);
var data = this.formHead.getForm().getValues(false, false, false);
//var data2 = this.formEdit.getForm().getValues(false, false, false);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/SysMng/SysRoleTaskQuery/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
2 years ago
//this.formEdit.getForm().reset();
//this.formEdit.getForm().setValues(returnData);
this.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
if (type == '0') {
this.opStatus = 'edit';
this.LoadData(this.opStatus, returnData.GID);
} else if (type == '1') {
window.close();
} else if (type == '2') {
}
_IsSaved = true;
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({
title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
//#endregion
//#region 集装箱按钮事件
onAddDetailClick: function (button, event) {
this.addDetail();
}, //end onAddDetailClick
onDelDetailClick: function (button, event) {
this.deleteDetail();
}, //onDelDetailClick
addDetail: function () {
//
var record = Ext.create('InfoClientContactModel', {
GID: NewGuid(),
LINKID: '*',
JOB: '',
SHOWNAME: '',
EMAIL: '',
TEL: '',
MOBILE: '',
QQ: '',
REMARK: ''
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
DsGetNewNo: function (store) {
var result = store.getCount();
if (result == 0) {
return '01';
}
var record = store.getAt(result - 1).data.CTNCODE;
result = parseInt(record) + 1;
if (result.toString().length == 1) {
result = '0' + result;
}
return result;
},
onNextKeyClick: function (type, col) {
var rows = this.gridList.getSelectionModel().getSelection()[0];
var newSerialno = this.DsGetNewNo(this.storeBodyList);
this.serialNo = newSerialno;
// var copys = rows[0];
// copys.id = NewGuid();
// copys.internalId = NewGuid();
// copys.data.CTNCODE = newSerialno;
// copys.data.CTN_ID = NewGuid();
var record = Ext.create('MsSeaeEdiCtn', {
CTN_ID: NewGuid(),
MFNO: '*',
CTNCODE: newSerialno,
CTNALL: rows.data.CTNALL,
CNTRNO: rows.data.CNTRNO,
SEALNO: rows.data.SEALNO,
PKGS: rows.data.PKGS,
KGS: rows.data.KGS,
CBM: rows.data.CBM,
MARKS: rows.data.MARKS,
KINDPKGS: rows.data.KINDPKGS,
DESCRIPTION: rows.data.DESCRIPTION,
ShiFengRen: rows.data.ShiFengRen,
ZhongKongBiaoShi: rows.data.ZhongKongBiaoShi,
PIZHONG: rows.data.PIZHONG
,
ChengZhongFangShi: rows.data.ChengZhongFangShi,
ChengZhongZhongLiang: rows.data.ChengZhongZhongLiang,
ChengZhongShiJian: rows.data.ChengZhongShiJian
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 4 });
},
deleteDetail: function () {
var GID = this.formHead.getForm().findField('GID').getValue();
var selectedRecords = this.gridList.selModel.getSelection();
var GIDs = "";
var delrecList = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.LINKID == "" || rec.data.LINKID == "*")//如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeBodyList.remove(selectedRecords[i]);
}
else {
if (GIDs != "") {
GIDs += ",";
}
GIDs += rec.get("GID");
delrecList.push(rec);
}
}
var _this = this;
if (GIDs != "") {
Ext.MessageBox.confirm('提示', '确定删除这些记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/OPSeaeClient/DelDetail',
params: {
GID: GIDs
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
_this.LoadData(this.opStatus,GID);
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
},
//#endregion
LoadInit: function () {
},
setBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
//var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
if (enable == 2) {
btnESave.setVisible(false);;
//btnESaveAndClose.setVisible(false);
} else {
btnESave.setVisible(true);;
//btnESaveAndClose.setVisible(true);
}
}
});
/**
* 计算n天后的日期
* initDate开始日期默认为当天日期 格式yyyymmdd/yyyy-mm-dd
* days:天数
* flag返回值 年与日之间的分隔符 默认为xxxx年xx月xx日格式
*/
function getDateAfter_n(initDate, days, flag) {
if (!days) {
return initDate;
}
initDate = initDate.replace(/-/g, '');
var date;
var year = initDate.substring(0, 4);
var month = initDate.substring(4, 6);
var day = initDate.substring(6, 8);
date = new Date(year, month - 1, day); // 月份是从0开始的
date.setDate(date.getDate() + days);
var yearStr = date.getFullYear();
var monthStr = ("0" + (date.getMonth() + 1)).slice(-2, 8); // 拼接2位数月份
var dayStr = ("0" + date.getDate()).slice(-2, 8); // 拼接2位数日期
var result = "";
result = yearStr + "-" + monthStr + "-" + dayStr;
return result;
}
///获取QuertString
function getQueryString(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
function dateFormat(value) {
if (null != value) {
return Ext.Date.format(new Date(value), 'Y-m-d H:i:s');
} else {
return null;
}
}
function trim(str) {
return str.replace(/(^\s+)|(\s+$)/g, "");
}