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/Comm/DsExtjsEx.js

547 lines
15 KiB
JavaScript

2 years ago
//表参照的Combox
Ext.define('DsExt.ux.RefTableCombox', {
extend: 'Ext.form.field.ComboBox',
constructor: function (config) {
config = Ext.apply({
queryMode: 'local',
selectOnTab: true,
typeAhead: true,
triggerAction: 'all',
selectOnFocus: true,
editable: true
},
config);
this.callParent([config]);
}
});
//枚举参照的Combox
Ext.define('DsExt.ux.RefEnumCombox', {
extend: 'Ext.form.field.ComboBox',
constructor: function (config) {
config = Ext.apply({
queryMode: 'local',
triggerAction: 'all',
selectOnTab: true,
typeAhead: true,
selectOnFocus: true,
editable: true,
valueField: 'EnumValueId',
displayField: 'EnumValueName'
},
config);
this.callParent([config]);
}
});
//枚举参照的Combox
Ext.define('DsExt.ux.RefEnumComboxList', {
extend: 'Ext.form.field.ComboBox',
constructor: function (config) {
config = Ext.apply({
queryMode: 'local',
triggerAction: 'all',
selectOnTab: true,
typeAhead: true,
selectOnFocus: true,
editable: true,
valueField: 'EnumValueName',
displayField: 'EnumValueName'
},
config);
this.callParent([config]);
}
});
Ext.define('DsExtEnumModel', {
extend: 'Ext.data.Model',
fields: [{
name: 'EnumValueId',
type: 'string'
},
{
name: 'EnumValueName',
type: 'string'
},
{
name: 'EnumValueAndName',
type: 'string'
},
{
name: 'EnumValueName_2',
type: 'string'
}]
});
//枚举参照的Store
Ext.define('DsExt.ux.RefEnumStore', {
extend: 'Ext.data.Store',
model: 'DsExtEnumModel',
constructor: function (config) {
/* config = Ext.apply(
{
proxy: {
type: 'ajax',
url: '/CommMng/PubSys/GetEnumValueList',
reader: {
root: 'data'
}
}
},
config);*/
var proxy = {
type: 'ajax',
url: '/CommMng/PubSys/GetEnumValueList',
reader: {
root: 'data'
}
};
config.proxy = proxy;
this.callParent([config]);
}
});
Ext.define('DsExtEnum_AllModel', {
extend: 'Ext.data.Model',
fields: [{
name: 'EnumValueId',
type: 'string'
},
{
name: 'EnumValueName',
type: 'string'
},
{
name: 'EnumValueName_2',
type: 'string'
},
{
name: 'VerNo',
type: 'string'
}]
});
Ext.define('DsExt.ux.RefEnum_AllStore', {
extend: 'Ext.data.Store',
model: 'DsExtEnum_AllModel',
constructor: function (config) {
/* config = Ext.apply(
{
proxy: {
type: 'ajax',
url: '/CommMng/PubSys/GetEnumValueList',
reader: {
root: 'data'
}
}
},
config);*/
var proxy = {
type: 'ajax',
url: '/CommMng/PubSys/GetEnumValueList',
reader: {
root: 'data'
}
};
config.proxy = proxy;
this.callParent([config]);
}
});
//表参照的Store
Ext.define('DsExt.ux.RefTableStore', {
extend: 'Ext.data.Store',
constructor: function (config) {
var proxy = {
type: 'ajax',
timeout: 120000,
url: config.proxy.url,
reader: {
root: 'data'
}
};
config.proxy = proxy;
this.callParent([config]);
}
});
Ext.define('MsFeeOP', {
extend: 'Ext.data.Model',
idProperty: 'OPID',
fields: [{
name: 'OPID',
type: 'string'
}]
});
//Array.prototype.contains = function (obj) {
// var i = this.length;
// while (i--) {
// if (this[i] === obj) {
// return true;
// }
// }
// return false;
//};
///封装对模糊查询的支持、按tab/enter、未选择时按tab的默认操作
Ext.define('DsExt.ux.DCombox', {
extend: 'Ext.form.field.ComboBox',
constructor: function (config) {
config = Ext.apply({
queryMode: 'local',
triggerAction: 'all',
selectOnTab: true,
typeAhead: true,
selectOnFocus: true,
editable: true,
forceSelection: true,
listeners: {
beforequery: function (e) {
return FilterCombox(e);
},
specialkey: function (field, e) {
//将回车转义成tab
var combo = e.combo;
if (e.getKey() == e.ENTER) {
e.keyCode = 9;
}
if (e.keyCode == 9) {
//将combo
//alert(field.value);
if (field.value == null) {
_name = this.store.data.keys[0];
this.setValue(_name);
} else {
if (field.value.replace(/\s*/g, "") == "") {
_name = this.store.data.keys[0];
this.setValue(_name);
}
}
}
}
}
},
config);
this.callParent([config]);
}
});
//用于关联枚举类型combox的加载
function getEnumcombox(param) {
//调用方法
//this.getEnumcombox = getEnumCombox({ LABEL: '合同状态',NAME:'Mainstate', FLEX:5, enumTypeId: 3 });
BLANKVALUE = "";
TOOLTIP = "";
allowBlank = true;
if (!isNullorEmpty(param.ALLOWBLANK)) {
if (param.ALLOWBLANK == false) allowBlank = false;
}
readOnly = false;
if (!isNullorEmpty(param.readOnly)) {
if (param.readOnly == true) readOnly = true;
}
TOOLTIP = "";
if (!isNullorEmpty(param.TOOLTIP)) {
TOOLTIP = param.TOOLTIP;
}
var combox = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: param.LABEL,
flex: param.FLEX,
labelAlign: 'right',
//labelWidth: labelWidth,
//blankText: BLANKVALUE,
//value: param.DEFAULTVALUE,
forceSelection: true,
store: Ext.create('DsExt.ux.RefTableStore', {
model: 'DsExtEnumModel',
proxy: {
url: '/CommMng/PubSys/GetEnumValueList'
},
autoLoad: true,
listeners: {
'beforeload': function (store, op, options) {
Ext.apply(store.proxy.extraParams, {
enumTypeId: param.enumTypeId
});
}
}
}),
name: param.NAME,
valueField: 'EnumValueId',
displayField: 'EnumValueName',
id: param.id,
allowBlank: allowBlank,
listeners: param.listeners,
tooltip: TOOLTIP,
value: param.VALUE,
readOnly: readOnly
});
return combox;
}
function EnumcomboxAddRecord(combox, vf, df) {
combox.store.add({
EnumValueId: vf,
EnumValueName: df
});
return combox;
}
function comboxAddRecord(combox, Valuefield, displayfield) {
v = combox.valueField + "";
d = combox.displayField + "";
var record = {
v: Valuefield,
d: displayfield
};
combox.store.add(record);
//alert(combox.displayField);
}
///参数说明URLINFO保存文件url的表的主键值
//UrlType一个字串 程序内固化其内容,一个字串会对应一组数据 包括TableName表名 KeyName表主键字段名 UrlName表中保存文件路径的字段名
//ResultAction调用此方法的js实体需实现这个函数以便执行保存操作后操作。
//该函数需要两个参数参数1为一个传回的str参数2为this作用域函数体内容为【在这个函数内用str对this作用域的元素做xxx操作】
//_this:调用此方法的js实体的this作用域
function UpLoadFile(URLINFO, UrlType, ResultAction, _this) {
me = this;
var imgform = new Ext.FormPanel({
region: 'center',
labelWidth: 40,
frame: true,
//bodyStyle: 'padding:5px 5px 0',
//autoScroll: true,
border: false,
fileUpload: true,
items: [{
xtype: 'fileuploadfield',
id: 'LoadFile',
name: 'LoadFile',
emptyText: '请选择文件',
fieldLabel: '文件',
buttonText: '选择文件',
//20191008 对上传的文件扩展名暂时不做限制
//regex: /^.+\.(jpg|jpeg|png|pdf|gif|bmp|tiff)$/,
//regexText: "只能选择jpg|jpeg|png|pdf|gif|bmp|tiff格式的文件",
allowBlank: false,
buttonCfg: {
iconCls: 'uploaddialog'
},
anchor: '99%'
}],
buttons: [{
text: '上传',
type: 'submit',
handler: function (record) {
var UserFilePath = Ext.getCmp('LoadFile').getValue();
//if (!CheckFileExt(UserFilePath, /.frx/i)) {
// Ext.Msg.show({ title: '错误', msg: '请确认你上传的文件为frx文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// return;
//}
if (!imgform.form.isValid()) {
return;
}
imgform.form.submit({
url: '/CommMng/BasicDataRef/FileUpload',
waitMsg: '正在上传',
method: 'POST',
submitEmptyText: false,
async: false,
params: {
URLINFO: Ext.JSON.encode(URLINFO),
UrlType: UrlType
},
success: function (form, action) {
win.close(this);
Ext.Msg.show({
title: '提示',
msg: '上传成功!',
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
if (typeof ResultAction == 'function') {
ResultAction(action, _this);
}
},
failure: function (form, action) {
form.reset();
win.close(this);
if (action.failureType == Ext.form.Action.SERVER_INVALID) {
Ext.MessageBox.alert('警告', action.result.errors.msg);
}
}
});
}
},
{
text: '关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]
});
var win = new Ext.Window({
title: "上传文件",
width: 360,
height: 100,
modal: true,
resizable: false,
border: false,
items: imgform
});
win.show();
}
//枚举参照的Combox
Ext.define('DsExt.ux.TaskStateCombox', {
extend: 'Ext.form.field.ComboBox',
constructor: function (config) {
config = Ext.apply({
queryMode: 'local',
triggerAction: 'all',
selectOnTab: true,
typeAhead: true,
selectOnFocus: true,
editable: true,
valueField: 'STATEKEY',
displayField: 'NAME'
},
config);
this.callParent([config]);
}
});
//用于关联枚举类型combox的加载
function getTaskStateCombox(param) {
//调用方法
//this.TaskStateCombox = getTaskStateCombox({ LABEL: '押箱状态',NAME:'YXSTATE', FLEX:1, PROP5: 'MsOp_YAXIANG' });
BLANKVALUE = "";
TOOLTIP = "";
allowBlank = true;
if (!isNullorEmpty(param.ALLOWBLANK)) {
if (param.ALLOWBLANK == false) allowBlank = false;
}
readOnly = false;
if (!isNullorEmpty(param.readOnly)) {
if (param.readOnly == true) readOnly = true;
}
TOOLTIP = "";
if (!isNullorEmpty(param.TOOLTIP)) {
TOOLTIP = param.TOOLTIP;
}
var combox = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: param.LABEL,
flex: param.FLEX,
labelAlign: 'right',
//labelWidth: labelWidth,
//blankText: BLANKVALUE,
//value: param.DEFAULTVALUE,
forceSelection: true,
store: Ext.create('DsExt.ux.RefTableStore', {
model: 'SysTaskStatemb',
proxy: {
url: '/SysMng/SysTask/GetTaskState_Combox'
},
autoLoad: true,
listeners: {
'beforeload': function (store, op, options) {
Ext.apply(store.proxy.extraParams, {
PROP5: param.PROP5
});
}
}
}),
name: param.NAME,
valueField: 'STATEKEY',
displayField: 'NAME',
id: param.id,
allowBlank: allowBlank,
listeners: param.listeners,
tooltip: TOOLTIP,
value: param.VALUE,
readOnly: readOnly
});
return combox;
}
//将一个tab的id=itemname的tab设为active
function setTabActive(tab, itemname) {
var children = tab.items;
if (children) {
for (var i = 0, len = children.length; i < len; i++) {
if (children.items[i].id) {
if (children.items[i].id == itemname) {
tab.setActiveTab(i);
finded = true;
return finded;
}
}
}
}
return false;
}
Ext.define('XiaLaKuangModel', {
extend: 'Ext.data.Model',
idProperty: 'VALUE',
fields: [
{ name: 'VALUE', type: 'string' },
{ name: 'NAME', type: 'string' },
{ name: 'CodeAndName', type: 'string' }
]
});
function CheckAuthority(modname) {
var obj;
var value;
if (window.ActiveXObject) {
obj = new ActiveXObject('Microsoft.XMLHTTP');
} else if (window.XMLHttpRequest) {
obj = new XMLHttpRequest();
}
obj.open('POST', '/CommMng/BasicDataRef/CheckAuthority', false);
obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
obj.send('modname=' + modname);
var result = Ext.JSON.decode(obj.responseText);
return result.Success;
}