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.

618 lines
23 KiB
JavaScript

10 months ago
Ext.namespace('Shipping');
Shipping.MsCompanysEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCompanysEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCompanysEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
Editdata: null,
initUIComponents: function () {
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.storeAddDCType = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeAddDCType.add({ "DC": "1", "NAME": "启用" });
this.storeAddDCType.add({ "DC": "0", "NAME": "停止" });
this.comboxaddDCType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '启用消息提示',
store: this.storeAddDCType,
valueField: 'DC',
displayField: 'NAME',
forceSelection: true,
name: 'WORKFLOWMSG'
});
this.formHead = Ext.widget('form', {
region: 'north',
frame: true,
fieldDefaults: {
labelAlign: 'right',
flex: 1,
labelWidth: 80,
msgTarget: 'qtip'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '公司编码',
name: 'GID',
hidden: true
},
{
fieldLabel: '*公司代码',
name: 'CODENAME',
style: 'color:red',
allowBlank: false
},
{
fieldLabel: '*公司简称',
name: 'NAME',
style: 'color:red',
allowBlank: false
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '*公司全称',
name: 'FULLNAME',
style: 'color:red',
allowBlank: false
},
{
fieldLabel: '英文名称',
name: 'ENNAME'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '公司地址',
name: 'ADDRESS'
},
{
fieldLabel: '英文地址',
name: 'ENADDRESS'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '邮政编码',
name: 'POSTCODE'
},
{
fieldLabel: '办公电话',
name: 'OFFICEPHONE'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '传真号码',
name: 'FAX'
},
{
fieldLabel: '电子邮箱',
name: 'EMAIL'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '公司网址',
name: 'WEBSITEURL'
}, {
fieldLabel: '组织机构代码',
name: 'ORGANIZATIONCODE'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '工商登记号',
name: 'LICENSECODE'
},
{
fieldLabel: '税务登记号',
name: 'TAXCODE'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '发票抬头',
name: 'BILLRISES'
},
{
fieldLabel: '支票抬头',
name: 'CHEQUEPAYABLE'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '打印抬头1',
name: 'PRTHEADXML1'
},
{
fieldLabel: '打印抬头2',
name: 'PRTHEADXML2'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '打印抬头3',
name: 'PRTHEADXML3'
},
{
fieldLabel: '打印抬头4',
name: 'PRTHEADXML4'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '打印抬头5',
name: 'PRTHEADXML5'
},
{
fieldLabel: '*票号头字符',
name: 'BANKSHEAD',
flex: 0.5,
style: 'color:red',
allowBlank: false
}, {
fieldLabel: '本地货币',
flex: 0.5,
name: 'LOCALCURR'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '接口地址',
name: 'DISPATCHURL'
},
{
fieldLabel: '用户名称',
name: 'APPCODE',
flex: 0.5
}, {
fieldLabel: '秘钥',
flex: 0.5,
name: 'APPKEY'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{ xtype: 'hiddenfield', height: 10}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
xtype: 'box',
fieldLabel: "预览图片",
id: 'imageBrowse',
autoEl: {
width: 100,
height: 100,
tag: 'img',
type: 'image',
src: Ext.BLANK_IMAGE_URL,
style: 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);',
complete: 'off',
id: 'imageBrowse'
}
}, {
xtype: 'fileuploadfield',
fieldLabel: '徽标',
//id: 'LoadImage',
//name: 'LoadImage',
id: 'upload',
name: 'upload',
emptyText: '请选择图片',
buttonText: '选择文件',flex:3,
buttonCfg: { iconCls: 'uploaddialog' }
}, {
xtype : 'checkbox',
fieldLabel: '是否停用',
name: 'ISDISABLE',flex:1
},this.comboxaddDCType,{
fieldLabel: 'LOGOURL',
name: 'LOGOURL',
hidden: true
}, {
fieldLabel: 'MODIFIEDUSERNAME',
name: 'MODIFIEDUSERNAME',
hidden: true
}]
}],
listeners: {
'render': function (f) {
this.form.findField('upload').on('render', function () {
//通過change事件,图片也动态跟踪选择的图片变化
Ext.get('upload').on('change', function (field, newValue, oldValue) {
//得到选择的图片路径
var UserFilePath = Ext.getCmp('upload').getValue();
//是否是规定的图片类型
if (!CheckFileExt(UserFilePath, /.jpg|.gif|.png|.bmp/i)) {
Ext.Msg.show({ title: '错误', msg: '请确认你上传的文件为图片文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (Ext.isIE) {
var image = Ext.get('imageBrowse').dom;
image.src = Ext.BLANK_IMAGE_URL; // 覆盖原来的图片
image.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = "file://" + UserFilePath;
} // 支持FF
else {
Ext.get('imageBrowse').dom.src = window.URL.createObjectURL(newValue.files[0]);
}
Ext.getCmp('LOGOURL').setValue(UserFilePath);
}, this);
}, this);
}
}
});
//按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
id: 'btnESaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
}, {
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, {
text: "新建",
handler: function (button, event) {
this.LoadData('add', '');
},
scope: this
}, '-', {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}]
}); //end 按钮Toolbar
//根节点
this.treestore = new Ext.data.TreeStore({
model: 'DsShipping.ux.ModuleModel',
nodeParam: 'PARENTID',
proxy: {
type: 'ajax',
url: '/MvcShipping/MsBaseInfo/GetModuTreeRefList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
},
autoLoad: true,
root: {
name: '根节点',
expanded: true,
//id: '5E301DAB-1DC4-4635-85FC-711F3FD94D39'
//id: 'D6CBA24C-815D-47AE-BA22-47BF2819376C'
id: '0791bbcc-8079-49de-8175-6063b9826ac1'
}
});
this.tabtree = new Ext.tree.Panel({
region: 'west',
title: '企业信息管理',
split: true,
width: 180,
collapsible: true,
margins: '0 0 0 0',
store: this.treestore,
rootVisible: false,
hideHeaders: true,
animate: false,
lines: false,
columns: [{
xtype: 'treecolumn',
text: '模块名称',
width: 178,
dataIndex: 'DESCRIPTION'
}],
listeners: {
scope: this,
'itemclick': function (_this, record, item, index, e, eOpts) {
if (record.data.MODULEURL == '@') {
this.tabCompanysPanel.setActiveTab(0);
} else if (record.data.MODULEURL != '#') {
if (Ext.getCmp('pnl' + record.data.NAME)) {
var children = this.tabCompanysPanel.items;
if (children) {
for (var i = 0, len = children.length; i < len; i++) {
if (children.items[i].id) {
if (children.items[i].id == 'pnl' + record.data.NAME) {
this.tabCompanysPanel.setActiveTab(i);
}
}
}
}
} else {
if (this.formHead.getForm().findField('GID').getValue() == "") {
Ext.Msg.show({ title: '注意', msg: '请先保存企业信息后再打开其他模块!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
} else {
var paneltabitems = new Ext.Panel({
id: 'pnl' + record.data.NAME,
layout: "fit",
region: "center",
autoScroll: true,
frame: false,
closable: true,
title: record.data.DESCRIPTION,
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' + record.data.MODULEURL + '"> </iframe>'
});
this.tabCompanysPanel.add(paneltabitems);
this.tabCompanysPanel.setActiveTab(paneltabitems);
this.tabCompanysPanel.doLayout();
}
}
}
}
}
});
this.panelCompanys = new Ext.Panel({
title: '企业信息',
id: 'pnlmodCompanysInfo',
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
frame: false,
items: [this.panelBtn, this.formHead]
});
this.tabCompanysPanel = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
border: true,
frame: false,
region: 'center',
id: "tabCompanysPanel",
enableTabScroll: true,
items: [this.panelCompanys]
});
Ext.apply(this, {
items: [this.tabtree, this.tabCompanysPanel]
});
parentWin = window.parent.opener;
this.InitData();
}, //end initUIComponents
InitData: function () {
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];
}
if (this.opStatus == 'edit') {
condition = " GID='" + this.editRecord.get('GID') + "'";
}
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.bodyDel = [];
this.opStatus = opstatus;
if (this.opStatus == 'add') {
var basicForm = this.formHead.getForm();
basicForm.reset();
basicForm.findField('GID').setDisabled(false);
basicForm.findField('GID').setValue("*");
basicForm.findField('GID').setDisabled(true);
}
else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsCompanys/GetData',
params: {
handle: opstatus,
condition: condition
},
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;
if (data.ISDISABLE == true) {
data.ISDISABLE = '1';
} else { data.ISDISABLE = '0' };
this.formHead.getForm().reset();
this.formHead.getForm().setValues(data);
//
var sLOGOURL = data.LOGOURL.toString();
if (sLOGOURL != "") {
Ext.get('imageBrowse').dom.src = sLOGOURL;
}
//
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
}, // end LoadDate
GetEditStatus: function () {
var canedit = false;
var MODIFIEDUSERNAME = this.formHead.getForm().findField('MODIFIEDUSERNAME').getValue();
_this = this;
this.StoreOpRange.load({ params: { optype: "modCompanys" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var recordins = DsStoreQueryBy(_this.StoreOpRange, 'OPID', MODIFIEDUSERNAME);
if (recordins.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
} else { canedit = false; }
_this.setSaveBtnStatus(canedit);
}
}
});
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
}
},
Save: function (type) {
var basicForm2 = this.formHead.getForm();
if (!basicForm2.isValid()) {
return;
}
this.formHead.getForm().findField('GID').setDisabled(false);
var data = this.formHead.getForm().getValues(false, false, false);
this.formHead.getForm().findField('GID').setDisabled(true);
data.ISDISABLE = this.formHead.getForm().findField('ISDISABLE').getValue() ? 1 : 0;
Ext.Msg.wait('正在保存数据, 请稍侯..');
this.formHead.form.submit({
//Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCompanys/Save',
method: 'POST',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data)
},
success: function (form, action) {
Ext.MessageBox.hide();
Ext.Msg.show({ title: '提示', msg: '操作成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
failure: function (form, action) {
//if (action.failureType == Ext.form.Action.SERVER_INVALID) Ext.MessageBox.alert('警告', action.result.errors.msg);
if (action.success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(action.response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
//
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsCompanysEntity', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
//
this.opStatus = 'edit';
if (type == '0') {
Ext.Msg.show({ title: '提示', msg: '操作成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.LoadData('add', '');
}
} 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
});