|
|
@@ -1,200 +0,0 @@
|
|
|
-Ext.define('saas.util.QueryUtil', {
|
|
|
-
|
|
|
- BaseUtil: Ext.create('saas.util.BaseUtil'),
|
|
|
-
|
|
|
- /**
|
|
|
- * 获得form的字段查询条件
|
|
|
- * @param form: form组件
|
|
|
- * @returns Mode: 字段模式,默认MAIN 当f.fieldMode = "DETAIL",Mode->"DETAIL"
|
|
|
- */
|
|
|
- getStoreMode: function(form,Mode){
|
|
|
- var Mode = "MAIN";
|
|
|
- if(form.items.items.find(function(item) {
|
|
|
- return !Ext.isEmpty(item.value)&&item.fieldMode == "DETAIL";
|
|
|
- })) {
|
|
|
- Mode = "DETAIL";
|
|
|
- }
|
|
|
- return Mode;
|
|
|
- },
|
|
|
- turnRelativeGrid:function(grid,queryForm,queryMoreForm){
|
|
|
- var me = this,
|
|
|
- Mode = me.getStoreMode(queryForm);
|
|
|
- if(queryMoreForm){//更多查询
|
|
|
- if(Mode=="MAIN"){
|
|
|
- me.getStoreMode(queryMoreForm);
|
|
|
- }
|
|
|
- }
|
|
|
- if(Mode=="MAIN"){
|
|
|
- grid.Mode = Mode;
|
|
|
- grid.reconfigure(grid.store, grid.baseColumn);
|
|
|
- grid.store.loadPage(1);
|
|
|
- }else{
|
|
|
- //若明细字段含明细字段注意切换数据源 grid.reconfigure(store, columns);
|
|
|
- //关联viewName = 关联viewName+"-RelativeGrid" selModel
|
|
|
- //grid.selModel = '';
|
|
|
- grid.Mode = Mode;
|
|
|
- grid.reconfigure(grid.store, grid.relativeColumn);
|
|
|
- grid.store.loadPage(1);
|
|
|
- }
|
|
|
- },
|
|
|
- /**
|
|
|
- * 获得form的字段查询条件
|
|
|
- * @param form: form组件
|
|
|
- */
|
|
|
- getFormCondition: function(form){
|
|
|
- var condition = "",
|
|
|
- me = this;
|
|
|
- Ext.each(form.items.items, function(f){
|
|
|
- if((f.xtype == 'checkbox' || f.xtype == 'radio')&&f.logic){
|
|
|
- if(f.value == true) {
|
|
|
- if(condition == ''){
|
|
|
- condition += "("+f.logic+")";
|
|
|
- } else {
|
|
|
- condition += ' AND (' + f.logic+')';
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (f.xtype == 'condatefield' && f.value != null ){
|
|
|
- if(f.value.from != null){
|
|
|
- if(condition == ''){
|
|
|
- condition += " ( date("+f.name+") between '"+Ext.Date.format(f.value.from,"Y-m-d H:i:s")+"' and '"+Ext.Date.format(f.value.to,"Y-m-d H:i:s")+"' )";
|
|
|
- } else {
|
|
|
- condition += " AND ( date("+f.name+") between '"+Ext.Date.format(f.value.from,"Y-m-d H:i:s")+"' and '"+Ext.Date.format(f.value.to,"Y-m-d H:i:s")+"' )";
|
|
|
- }
|
|
|
- }
|
|
|
- }else if(f.xtype == 'datefield' && f.value != null && f.value != '' ){
|
|
|
- var v = Ext.Date.format(new Date(f.value), 'Y-m-d');
|
|
|
- if(condition == ''){
|
|
|
- condition += "date("+f.name+")='"+v+"'";
|
|
|
- } else {
|
|
|
- condition += " AND date("+f.name+")='"+v+"'";
|
|
|
- }
|
|
|
- } else if(f.xtype == 'datetimefield' && f.value != null){
|
|
|
- var v = Ext.Date.format(new Date(f.value), 'Y-m-d H:i:s');
|
|
|
- if(condition == ''){
|
|
|
- condition += 'date('+f.name + ")= '" + v + "'";
|
|
|
- } else {
|
|
|
- condition += ' AND date('+f.name + ")= '" + v + "'";
|
|
|
- }
|
|
|
- } else if(f.xtype == 'numberfield' && f.value != null && f.value != ''){
|
|
|
- var endChar = '=';
|
|
|
- if(condition == ''){
|
|
|
- condition += f.name + endChar + f.value;
|
|
|
- } else {
|
|
|
- condition += ' AND ' + f.name + endChar + f.value;
|
|
|
- }
|
|
|
- } else if(f.xtype == 'combobox' ){
|
|
|
- if(f.value != '$ALL'&& f.value!=null){
|
|
|
- if(condition == ''){
|
|
|
- condition = f.name+" = '"+f.value+"' ";
|
|
|
- } else {
|
|
|
- condition += ' AND '+f.name+" = '"+f.value+"' ";
|
|
|
- }
|
|
|
- }
|
|
|
- } else if(f.xtype == 'multicombo' ){
|
|
|
- if(f.value && f.value.length > 0){
|
|
|
- var text = f.value.map(function(v) {
|
|
|
- return '\'' + v.value + '\'';
|
|
|
- }).join(',');
|
|
|
- if(condition == ''){
|
|
|
- condition = f.name + " in (" + text +")";
|
|
|
- } else {
|
|
|
- condition += ' AND ' + f.name + " in (" + text +")";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if(!Ext.isEmpty(f.value)){
|
|
|
- if(me.contains(f.value.toString(), 'BETWEEN', true) && me.contains(f.value.toString(), 'AND', true)){
|
|
|
- if(condition == ''){
|
|
|
- condition += f.name + " " + f.value;
|
|
|
- } else {
|
|
|
- condition += ' AND (' + f.name + " " + f.value + ")";
|
|
|
- }
|
|
|
- } else if(me.contains(f.value.toString(), '||', true)){
|
|
|
- var str = '';
|
|
|
- Ext.each(f.value.split('||'), function(v){
|
|
|
- if(v != null && v != ''){
|
|
|
- if(str == ''){
|
|
|
- str += f.name + "='" + v + "'";
|
|
|
- } else {
|
|
|
- str += ' OR ' + f.name + "='" + v + "'";
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- if(condition == ''){
|
|
|
- condition += "(" + str + ")";
|
|
|
- } else {
|
|
|
- condition += ' AND (' + str + ")";
|
|
|
- }
|
|
|
- } else if(f.value.toString().charAt(0) == '!'){
|
|
|
- if(condition == ''){
|
|
|
- condition += 'nvl(' + f.name + ",' ')<>'" + f.value.substr(1) + "'";
|
|
|
- } else {
|
|
|
- condition += ' AND (nvl(' + f.name + ",' ')<>'" + f.value.substr(1) + "')";
|
|
|
- }
|
|
|
- } else {
|
|
|
- if(f.value.toString().indexOf('%') >= 0) {
|
|
|
- if(condition == ''){
|
|
|
- condition += f.name + " like '" + f.value + "'";
|
|
|
- } else {
|
|
|
- condition += ' AND (' + f.name + " like '" + f.value + "')";
|
|
|
- }
|
|
|
- } else {
|
|
|
- if(f.queryType=='VAG'){
|
|
|
- if(condition == ''){
|
|
|
- if(me.contains(f.name.toString(), '#', true)){
|
|
|
- var nameArr = f.name.split("#");
|
|
|
- Ext.each(nameArr, function(nameItem,index) {
|
|
|
- if(index==0){
|
|
|
- condition = (nameItem+ " like '%" +f.value + "%'");
|
|
|
- }else{
|
|
|
- condition += " or "+nameItem+ " like '%" +f.value + "%' ";
|
|
|
- }
|
|
|
- });
|
|
|
- }else{
|
|
|
- condition += '('+ f.name + " like '%" + f.value + "%')";
|
|
|
- }
|
|
|
- } else {
|
|
|
- if(me.contains(f.name.toString(), '#', true)){
|
|
|
- var nameArr = f.name.split("#");
|
|
|
- Ext.each(nameArr, function(nameItem,index) {
|
|
|
- if(index==0){
|
|
|
- condition += ' AND ('+(nameItem+ " like '%" +f.value + "%'");
|
|
|
- }else{
|
|
|
- condition += " or "+nameItem+ " like '%" +f.value + "%' ";
|
|
|
- }
|
|
|
- });
|
|
|
- condition+=')';
|
|
|
- }else{
|
|
|
- condition += ' AND (' + f.name + " like '%" + f.value + "%')";
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(condition == ''){
|
|
|
- condition += '('+f.name + "='" + f.value + "')";
|
|
|
- } else {
|
|
|
- condition += ' AND (' + f.name + "='" + f.value + "')";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- return condition;
|
|
|
- },
|
|
|
- /**
|
|
|
- * string:原始字符串
|
|
|
- * substr:子字符串
|
|
|
- * isIgnoreCase:忽略大小写
|
|
|
- */
|
|
|
- contains: function(string, substr, isIgnoreCase){
|
|
|
- if (string == null || substr == null) return false;
|
|
|
- if (isIgnoreCase === undefined || isIgnoreCase === true) {
|
|
|
- string = string.toLowerCase();
|
|
|
- substr = substr.toLowerCase();
|
|
|
- }
|
|
|
- return string.indexOf(substr) > -1;
|
|
|
- }
|
|
|
-});
|