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

306 lines
9.3 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]);
}
});
Ext.define('DsExtEnumModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'EnumValueId', type: 'string' },
{ name: 'EnumValueName', type: 'string' },
{ name: 'VerNo', type: 'string' },
{ name: 'EnumValueName_2', type: 'string' },
{ name: 'EnumValueAndName', 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]);
}
});
//用于关联枚举类型combox的加载
function getEnumcombox(param) {
//调用方法
//this.getEnumcombox = getEnumCombox({ LABEL: '合同状态',NAME:'Mainstate', FLEX:5, enumTypeId: 3 });
BLANKVALUE = "";
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,
listeners: param.listeners
//tooltip: TOOLTIP
});
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);
}
//表参照的Store
Ext.define('DsExt.ux.RefTableStore', {
extend: 'Ext.data.Store',
constructor: function (config) {
var proxy = {
type: 'ajax',
url: config.proxy.url,
reader: {
root: 'data'
}
};
config.proxy = proxy;
this.callParent([config]);
}
});
Ext.define('WorkFlowStepmb', {
extend: 'Ext.data.Model',
idProperty: 'GID',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'NAME', type: 'string' },
{ name: 'STEPNO', type: 'string' },
{ name: 'NEEDALLPASS', type: 'string' },
{ name: 'ISMUST', type: 'string' },
{ name: 'ISLAST', type: 'string' }
]
});
Ext.define('WorkFlowBSNOmb', {
extend: 'Ext.data.Model',
idProperty: 'BSNO',
fields: [
{ name: 'BSNO', type: 'string' }
]
});
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]);
}
});
///参数说明URLINFO保存文件url的表的主键值
//UrlType一个字串 程序内固化其内容,一个字串会对应一组数据 包括TableName表名 KeyName表主键字段名 UrlName表中保存文件路径的字段名
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();
}