// 当前时间
var now = new Date()


// 获取当前时间,格式'yyyy-mm-dd hh24-mm-ss'
export function toStandardDateString() {
  let dt = new Date()
  let month = dt.getMonth() + 1
  let date = dt.getDate()
  return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date)
}

// 待传入sql中的开始时间
export var startDate = ''
// 待传入sql中的结束时间
export var endDate = ''

export var param = ''
export var param1 = ''
export var param2 = ''


export var listparam = ''
export var listparam1 = ''


//获取钻取参数,title=所属钻取分类名,param1=一级钻取字段,param2=二级钻取字段,
export function getDrillParameter(title, idname, param1, param2) {

  console.log(title, idname, param1, param2, this.param, this.param1, '钻取参数获取条件')


  // sql配置,items=查询列名,tablename=表名,condition=条件,
  // label:钻取字段名称,name:拼接sql列名,echartsType:图表类型, barparamif: 钻取点击控制,listif: 列表sql控制拼接一级类型,
  // dateif: 时间选择控制,dateparam: 选择时间查询的字段,listparam：列表特殊条件
  //inputchildren:输入框默认内容,柱状图特有（yname:柱状图yname,xname:柱状图xname,seriename:单系列时显示数据的名称）
  var sql = {
    /********************用户*********************/
    //用户传递
    user: {
      usernum: [
        //用户类型
        {
          label: "用户类型",
          value: Math.random(),
          name: 'f_user_type',
          echartsType: 'pie',
          barparamif: true,
          listif: true,
          dateif: false,
          dateparam: "f_createfile_date",
          sqlcondition: 'usernum',
          children: [
            //子列表
            //按年分类
            {
              label: "按年分类", value: Math.random(), name: 'year', echartsType: 'bar', dateif: false, namesubif: false,
              xname: '年', yname: '数量', seriename: '', dateparam: "f_createfile_date",
              sqlcondition: 'useryear', listparam: '',
            },
            //按月分类
            {
              label: "按月分类", value: Math.random(), name: 'month', echartsType: 'bar', dateif: false, namesubif: false,
              xname: '月', yname: '数量', seriename: '', dateparam: "f_createfile_date",
              sqlcondition: 'usermonth', listparam: '',
            }],
          inputchildren: '',
        },
        //用气类型
        {
          label: "用气类型",
          value: Math.random(),
          name: 'f_gasproperties',
          echartsType: 'pie',
          barparamif: true,
          listif: true,
          dateif: false,
          xname: '',
          yname: '',
          dateparam: "f_createfile_date",
          sqlcondition: 'gasproperties',
          children: [
            //子列表
            //按年分类
            {
              label: "按年分类", value: Math.random(), name: 'year', echartsType: 'bar', dateif: false, namesubif: false,
              xname: '年', yname: '数量', seriename: '', dateparam: "f_createfile_date",
              sqlcondition: 'gaspropertiesyear', listparam: '',
            }
          ],
          inputchildren: '',
        }
      ],
      //主要用户
      mainuser: [
        {
          label: "全部",
          value: Math.random(),
          name: 'A.F_USER_TYPE is not null ',
          echartsType: 'bar',
          barparamif: true,
          listif: false,
          dateif: false, namesubif: true,
          xname: '', yname: '用气量',
          seriename: '用气量',
          dateparam: "a.f_delivery_date",
          sqlcondition: 'mainuser',
          children: [],
          inputchildren: ''
        },
        {
          label: "民用",
          value: Math.random(),
          name: 'A.F_USER_TYPE=\'民用\'',
          echartsType: 'bar',
          barparamif: true,
          listif: false,
          dateif: false, namesubif: true,
          xname: '', yname: '用气量',
          seriename: '用气量',
          dateparam: "a.f_delivery_date",
          sqlcondition: 'mainuser',
          children: [],
          inputchildren: ''
        },
        {
          label: "非民用",
          value: Math.random(),
          name: 'A.F_USER_TYPE=\'非民用\'',
          echartsType: 'bar',
          barparamif: true,
          listif: false,
          dateif: false, namesubif: true,
          xname: '', yname: '用气量', seriename: '用气量',

          dateparam: "a.f_delivery_date",
          sqlcondition: 'mainuser',
          children: [],
          inputchildren: '',
        }
        // {
        //   label: "民用锅炉",
        //   value: Math.random(),
        //   name: 'A.F_USER_TYPE=\'民用锅炉\'',
        //   echartsType: 'bar',
        //   barparamif: true,
        //   listif: false,
        //   dateif: false, namesubif: true,
        //   xname: '', yname: '用气量', seriename: '用气量',
        //   dateparam: "a.f_delivery_date",
        //   sqlcondition:'mainuser',
        //   children: [],
        //   inputchildren: ''
        // }
      ]
    },

    // /********************监控*********************/
    // 监控
    monitor: {
      // 钻取告警
      caveat: [
        {
          label: "磁干扰",
          value: Math.random(),
          name: 'tm.f_magneticinterference = \'1\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '月', yname: '客户数', seriename: '磁干扰',
          dateparam: "f_hand_date",
          sqlcondition: 'caveat',
          children: [],
          inputchildren: '',
        },
        {
          label: "报警关阀",
          value: Math.random(),
          name: 'tm.f_alarmshutvalve=\'1\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '月', yname: '客户数', seriename: '报警关阀',
          dateparam: "f_hand_date",
          sqlcondition: 'caveat',
          children: [],
          inputchildren: '',
        },
        {
          label: "周期关阀",
          value: Math.random(),
          name: 'tm.f_cycleshutvalue=\'1\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '月', yname: '客户数', seriename: '周期关阀',
          dateparam: "f_hand_date",
          sqlcondition: 'caveat',
          children: [],
          inputchildren: '',
        },
        {
          label: "过流保护关阀",
          value: Math.random(),
          name: 'tm.f_overcurrentprotection=\'1\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '月', yname: '客户数', seriename: '过流保护关阀',
          dateparam: "f_hand_date",
          sqlcondition: 'caveat',
          children: [],
          inputchildren: '',
        }, {
          label: "关阀走气",
          value: Math.random(),
          name: 'tm.f_leakageflag=\'1\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '月', yname: '客户数', seriename: '过流保护关阀',
          dateparam: "f_hand_date",
          sqlcondition: 'caveat',
          children: [],
          inputchildren: '',
        }
      ],
      // 钻取失联客户统计
      lossassociation: [
        {
          label: "全部",
          value: "全部",
          name: 'f_user_type is not null ',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '天', yname: '客户数', seriename: '客户数',
          dateparam: "slday",
          sqlcondition: 'lossassociation',
          children: [],
          inputchildren: '',
        },
        {
          label: "民用",
          value: "民用",
          name: 'f_user_type=\'民用\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '天', yname: '客户数', seriename: '民用',
          dateparam: "slday",
          sqlcondition: 'lossassociation',
          children: [
            //子列表
            {
              label: "居民用气",
              value: "居民用气",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              xname: '天', yname: '客户数', seriename: '客户数',
              name: 'f_gasproperties =\'居民用气\'',
              sqlcondition: 'lossassociation',
              dateparam: "f_gasproperties"
            },
            {
              label: "居民地暖",
              value: "居民地暖",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              xname: '天', yname: '客户数', seriename: '客户数',
              name: 'f_gasproperties =\'居民地暖\'',
              sqlcondition: 'lossassociation',
              dateparam: "f_gasproperties"

            }],
          inputchildren: '',
        },
        {
          label: "非民用",
          value: "非民用",
          name: 'f_user_type=\'非民用\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '天', yname: '客户数', seriename: '民用',
          dateparam: "slday",
          sqlcondition: 'lossassociation',
          children: [
            //子列表
            {
              label: "商业用气",
              value: "商业用气",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              xname: '天', yname: '客户数', seriename: '客户数',
              namesubif: false,
              name: 'f_gasproperties =\'商业用气\'',
              sqlcondition: 'lossassociation',
              dateparam: "f_gasproperties"
            },
            {
              label: "工业用气",
              value: "工业用气",
              echartsType: 'bar',
              barparamif: false,
              xname: '天', yname: '客户数', seriename: '客户数',
              listif: false,
              dateif: true,
              namesubif: false,
              name: 'f_gasproperties =\'工业用气\'',
              sqlcondition: 'lossassociation',
              dateparam: "f_gasproperties"

            }],
          inputchildren: '',
        }
      ],
      // 钻取长期未用气用户统计
      longnotusegas: [
        {
          label: "全部",
          value: "全部",
          name: 'a.f_user_type is not null',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '日', yname: '用户数', seriename: '用户数',
          dateparam: "f_hand_date",
          sqlcondition: 'longnotusegas',
          children: [],
          inputchildren: '',
        },
        {
          label: "民用",
          value: "民用",
          name: 'a.f_user_type=\'民用\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '日', yname: '用户数', seriename: '民用',
          dateparam: "f_hand_date",
          sqlcondition: 'longnotusegas',
          children: [
            //子列表
            {
              label: "居民用气",
              value: "居民用气",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              xname: '天', yname: '客户数', seriename: '客户数',
              name: 'a.f_gasproperties =\'居民用气\'',
              sqlcondition: 'longnotusegas',
              dateparam: "f_gasproperties"
            },
            {
              label: "居民地暖",
              value: "居民地暖",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              xname: '天', yname: '客户数', seriename: '客户数',
              name: 'a.f_gasproperties =\'居民地暖\'',
              sqlcondition: 'longnotusegas',
              dateparam: "f_gasproperties"

            }],
          inputchildren: '',
        },
        {
          label: "非民用",
          value: "非民用",
          name: 'a.f_user_type=\'非民用\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '月', yname: '用户数', seriename: '非民用',
          dateparam: "f_hand_date",
          sqlcondition: 'longnotusegas',
          children: [
            //子列表
            {
              label: "商业用气",
              value: "商业用气",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              name: 'a.f_gasproperties =\'商业用气\'',
              xname: '天', yname: '客户数', seriename: '客户数',
              sqlcondition: 'longnotbuygas',
              dateparam: "f_gasproperties"
            },
            {
              label: "工业用气",
              value: "工业用气",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              name: 'a.f_gasproperties =\'工业用气\'',
              xname: '天', yname: '客户数', seriename: '客户数',
              sqlcondition: 'longnotbuygas',
              dateparam: "f_gasproperties"

            }],
          inputchildren: '',
        },
      ],
      // 钻取长期未购气
      longnotbuygas: [
        {
          label: "全部",
          value: "全部",
          name: 'a.f_user_type is not null',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '日', yname: '用户数', seriename: '',
          dateparam: "f_delivery_date",
          sqlcondition: 'longnotbuygas',
          children: [],
          inputchildren: '',
        },
        {
          label: "民用",
          value: "民用",
          name: 'a.f_user_type=\'民用\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '日', yname: '用户数', seriename: '',
          dateparam: "f_delivery_date",
          sqlcondition: 'longnotbuygas',
          children: [
            //子列表
            {
              label: "居民用气",
              value: "居民用气",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              xname: '天', yname: '客户数', seriename: '客户数',
              name: 'a.f_gasproperties =\'居民用气\'',
              sqlcondition: 'longnotbuygas',
              dateparam: "f_gasproperties"
            },
            {
              label: "居民地暖",
              value: "居民地暖",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              xname: '天', yname: '客户数', seriename: '客户数',
              name: 'a.f_gasproperties =\'居民地暖\'',
              sqlcondition: 'longnotbuygas',
              dateparam: "f_gasproperties"

            }],
          inputchildren: '',
        },
        {
          label: "非民用",
          value: "非民用",
          name: 'a.f_user_type=\'非民用\'',
          echartsType: 'bar',
          barparamif: false,
          listif: false,
          dateif: true,
          namesubif: false,
          xname: '日', yname: '用户数', seriename: '',
          dateparam: "f_delivery_date",
          sqlcondition: 'longnotbuygas',
          children: [
            //子列表
            {
              label: "商业用气",
              value: "商业用气",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              xname: '天', yname: '客户数', seriename: '客户数',
              name: 'a.f_gasproperties =\'商业用气\'',
              sqlcondition: 'longnotbuygas',
              dateparam: "f_gasproperties"
            },
            {
              label: "工业用气",
              value: "工业用气",
              echartsType: 'bar',
              barparamif: false,
              listif: false,
              dateif: true,
              namesubif: false,
              xname: '天', yname: '客户数', seriename: '客户数',
              name: 'a.f_gasproperties =\'工业用气\'',
              sqlcondition: 'longnotbuygas',
              dateparam: "f_gasproperties"

            }],
          inputchildren: '',
        },
      ],


      // 钻取往期购气对比
      pastscale: [
        {
          label: "全部",
          value: Math.random(),
          name: 'ti.f_user_type is not null',
          echartsType: 'pie',
          barparamif: false,
          listif: false,
          dateif: true,
          dateparam: "f_delivery_date",
          sqlcondition: 'pastscaleall',
          children: [
            //子列表
            //高于往期购气量
            {
              label: "高于往期购气量",
              value: Math.random(),
              name: 'ti.f_user_type is not null',
              echartsType: 'bar',
              dateif: true,
              namesubif: false,
              xname: '月',
              yname: '用户数',
              seriename: '用户数',
              // sqlcondition: {
              //   items: '\'民用高于往期' + s1 + '%\' type,count(r) value,to_char(F_DELIVERY_DATE,\'yyyy-mm\') name,\'notparam\'  drilltype',
              //   tablename: '(SELECT (CASE when PASTSCALE>' + this.param + ' then F_USERINFO_ID end) r,F_DELIVERY_DATE ' +
              //   ' from (SELECT AAA.* from A_BUYGASCHANGE aaa,T_USERINFO bbb WHERE bbb.f_user_state=\'正常\' and AAA.F_USERINFO_ID=BBB.F_USERINFO_ID and BBB.F_USER_TYPE=\'民用\' ' +
              //   ' and aaa.f_last_pregas!=0) WHERE F_DELIVERY_DATE>=to_date(\'' + this.startDate + '\',\'yyyy-mm-dd hh24:mi;ss\') and ' +
              //   'F_DELIVERY_DATE<=to_date(\'' + this.endDate + '\',\'yyyy-mm-dd hh24:mi;ss\')  )qq',
              //   condition: 'qq.r is not null  GROUP BY to_char(F_DELIVERY_DATE,\'yyyy-mm\')',
              //   orderitem: '1'
              // },
              sqlcondition: 'pastscaledo',
              listparam: 'cast(PASTSCALE as NUMERIC) >' + this.param + ' and ',
              dateparam: "f_delivery_date",

            },
            //低于往期购气量
            {
              label: "低于往期购气量",
              value: Math.random(),
              name: 'ti.f_user_type is not null',
              echartsType: 'bar',
              dateif: true,
              namesubif: false,
              xname: '月',
              yname: '用户数',
              seriename: '用户数',
              // sqlcondition: {
              //   items: '\'民用低于往期' + s2 + '%\' type,count(r) value,to_char(F_DELIVERY_DATE,\'yyyy-mm\') name,\'notparam\'  drilltype',
              //   tablename: '(SELECT (CASE when PASTSCALE<' + this.param1 + ' then F_USERINFO_ID end) r,F_DELIVERY_DATE ' +
              //   'from (SELECT AAA.* from A_BUYGASCHANGE aaa,T_USERINFO bbb WHERE bbb.f_user_state=\'正常\' and AAA.F_USERINFO_ID=BBB.F_USERINFO_ID ' +
              //   ' and   aaa.f_last_pregas!=0) WHERE F_DELIVERY_DATE>=to_date(\'' + this.startDate + '\',\'yyyy-mm-dd hh24:mi;ss\') and ' +
              //   'F_DELIVERY_DATE<=to_date(\'' + this.endDate + '\',\'yyyy-mm-dd hh24:mi;ss\') )qq',
              //   condition: 'qq.r is not null  GROUP BY to_char(F_DELIVERY_DATE,\'yyyy-mm\')',
              //   orderitem: '1'
              // },
              sqlcondition: 'pastscaleup',
              listparam: 'cast(PASTSCALE as NUMERIC)  <' + this.param1 + ' and ',
              dateparam: "f_delivery_date",
            }
          ],
          inputchildren: '请输入对比比例!',
        },
        {
          label: "民用",
          value: Math.random(),
          name: 'ti.f_user_type=\'民用\'',
          echartsType: 'pie',
          barparamif: false,
          listif: false,
          dateif: true,
          dateparam: "f_delivery_date",
          sqlcondition: 'pastscaleall',
          children: [
            //子列表
            //高于往期购气量
            {
              label: "高于往期购气量",
              value: Math.random(),
              name: 'ti.f_user_type=\'民用\'',
              echartsType: 'bar',
              dateif: true,
              namesubif: false,
              xname: '月',
              yname: '用户数',
              seriename: '用户数',
              // sqlcondition: {
              //   items: '\'民用高于往期' + s1 + '%\' type,count(r) value,to_char(F_DELIVERY_DATE,\'yyyy-mm\') name,\'notparam\'  drilltype',
              //   tablename: '(SELECT (CASE when PASTSCALE>' + this.param + ' then F_USERINFO_ID end) r,F_DELIVERY_DATE ' +
              //   ' from (SELECT AAA.* from A_BUYGASCHANGE aaa,T_USERINFO bbb WHERE bbb.f_user_state=\'正常\' and AAA.F_USERINFO_ID=BBB.F_USERINFO_ID and BBB.F_USER_TYPE=\'民用\' ' +
              //   ' and aaa.f_last_pregas!=0) WHERE F_DELIVERY_DATE>=to_date(\'' + this.startDate + '\',\'yyyy-mm-dd hh24:mi;ss\') and ' +
              //   'F_DELIVERY_DATE<=to_date(\'' + this.endDate + '\',\'yyyy-mm-dd hh24:mi;ss\')  )qq',
              //   condition: 'qq.r is not null  GROUP BY to_char(F_DELIVERY_DATE,\'yyyy-mm\')',
              //   orderitem: '1'
              // },
              sqlcondition: 'pastscaledo',
              listparam: 'cast(PASTSCALE as NUMERIC) >' + this.param + ' and ',
              dateparam: "f_delivery_date",

            },
            //低于往期购气量
            {
              label: "低于往期购气量",
              value: Math.random(),
              name: 'ti.f_user_type=\'民用\'',
              echartsType: 'bar',
              dateif: true,
              namesubif: false,
              xname: '月',
              yname: '用户数',
              seriename: '用户数',
              // sqlcondition: {
              //   items: '\'民用低于往期' + s2 + '%\' type,count(r) value,to_char(F_DELIVERY_DATE,\'yyyy-mm\') name,\'notparam\'  drilltype',
              //   tablename: '(SELECT (CASE when PASTSCALE<' + this.param1 + ' then F_USERINFO_ID end) r,F_DELIVERY_DATE ' +
              //   'from (SELECT AAA.* from A_BUYGASCHANGE aaa,T_USERINFO bbb WHERE bbb.f_user_state=\'正常\' and AAA.F_USERINFO_ID=BBB.F_USERINFO_ID and BBB.F_USER_TYPE=\'民用\' ' +
              //   ' and   aaa.f_last_pregas!=0) WHERE F_DELIVERY_DATE>=to_date(\'' + this.startDate + '\',\'yyyy-mm-dd hh24:mi;ss\') and ' +
              //   'F_DELIVERY_DATE<=to_date(\'' + this.endDate + '\',\'yyyy-mm-dd hh24:mi;ss\') )qq',
              //   condition: 'qq.r is not null  GROUP BY to_char(F_DELIVERY_DATE,\'yyyy-mm\')',
              //   orderitem: '1'
              // },
              sqlcondition: 'pastscaleup',
              listparam: 'cast(PASTSCALE as NUMERIC)  <' + this.param1 + ' and ',
              dateparam: "f_delivery_date",
            }
          ],
          inputchildren: '请输入对比比例!',
        },
        {
          label: "非民用",
          value: Math.random(),
          name: 'ti.f_user_type=\'非民用\'',
          echartsType: 'pie',
          barparamif: false,
          listif: false,
          dateif: true,
          dateparam: "f_delivery_date",
          sqlcondition: 'pastscaleall',
          children: [
            //子列表
            //高于往期购气量
            {
              label: "高于往期购气量",
              value: Math.random(),
              name: 'ti.f_user_type=\'非民用\'',
              echartsType: 'bar',
              dateif: true,
              namesubif: false,
              xname: '月',
              yname: '用户数',
              seriename: '用户数',
              // sqlcondition: {
              //   items: '\'非民用高于往期' + s1 + '%\' type,count(r) value,to_char(F_DELIVERY_DATE,\'yyyy-mm\') name,\'notparam\'  drilltype',
              //   tablename: '(SELECT (CASE when PASTSCALE>' + this.param + ' then F_USERINFO_ID end) r,F_DELIVERY_DATE ' +
              //   ' from (SELECT AAA.* from A_BUYGASCHANGE aaa,T_USERINFO bbb WHERE bbb.f_user_state=\'正常\' and AAA.F_USERINFO_ID=BBB.F_USERINFO_ID and BBB.F_USER_TYPE=\'非民用\'' +
              //   ' and  aaa.f_last_pregas!=0) WHERE F_DELIVERY_DATE>=to_date(\'' + this.startDate + '\',\'yyyy-mm-dd hh24:mi;ss\') and ' +
              //   'F_DELIVERY_DATE<=to_date(\'' + this.endDate + '\',\'yyyy-mm-dd hh24:mi;ss\') )qq',
              //   condition: 'qq.r is not null  GROUP BY to_char(F_DELIVERY_DATE,\'yyyy-mm\')',
              //   orderitem: '1'
              // },
              sqlcondition: 'pastscaledo',
              listparam: 'cast(PASTSCALE as NUMERIC)  >' + this.param + ' and ',
              dateparam: "f_delivery_date",
              children: '请输入对比比例!',
            },
            //低于往期购气量
            {
              label: "低于往期购气量",
              value: Math.random(),
              name: 'ti.f_user_type=\'非民用\'',
              echartsType: 'bar',
              dateif: true,
              namesubif: false,
              xname: '月',
              yname: '用户数',
              seriename: '用户数',
              // sqlcondition: {
              //   items: '\'非民用低于往期' + s2 + '%\' type,count(r) value,to_char(F_DELIVERY_DATE,\'yyyy-mm\') name,\'notparam\'  drilltype',
              //   tablename: '(SELECT (CASE when PASTSCALE<' + this.param1 + ' then F_USERINFO_ID end) r,F_DELIVERY_DATE ' +
              //   'from (SELECT AAA.* from A_BUYGASCHANGE aaa,T_USERINFO bbb WHERE bbb.f_user_state=\'正常\' and AAA.F_USERINFO_ID=BBB.F_USERINFO_ID and BBB.F_USER_TYPE=\'非民用\'' +
              //   ' and  aaa.f_last_pregas!=0) WHERE F_DELIVERY_DATE>=to_date(\'' + this.startDate + '\',\'yyyy-mm-dd hh24:mi;ss\') and ' +
              //   'F_DELIVERY_DATE<=to_date(\'' + this.endDate + '\',\'yyyy-mm-dd hh24:mi;ss\') )qq',
              //   condition: 'qq.r is not null  GROUP BY to_char(F_DELIVERY_DATE,\'yyyy-mm\')',
              //   orderitem: '1'
              // },
              sqlcondition: 'jydpastscaleup',
              listparam: 'cast(PASTSCALE as NUMERIC)  <' + this.param1 + ' and ',
              dateparam: "f_delivery_date",
              children: '请输入对比比例!',
            }
          ],
          inputchildren: '请输入对比比例!',
        },
      ],
    }
  }

  //无param时，获取title配置列表
  if (param1 == '' && param2 == '') {
    var reslut = sql[title][idname]
    console.log(reslut, '返回钻取条件')
    return reslut
  } else {
    // 有param获取title配置列表的param所在列
    var reslut = {}
    for (var i = 0; i < sql[title][idname].length; i++) {
      if (sql[title][idname][i].label == param1 && param2 == '') {
        reslut = sql[title][idname][i]
        break
      }
      // 遍历子列表
      if (JSON.stringify(sql[title][idname][i].children) != '[]' && sql[title][idname][i].label == param1) {
        for (var j = 0; j < sql[title][idname][i].children.length; j++) {
          if (sql[title][idname][i].children[j].label == param2) {
            reslut = sql[title][idname][i].children[j]
            break
          }
        }
      }
    }
    console.log(reslut, '返回钻取条件')
    return reslut
  }
}


//获取列表参数,title=所属钻取分类名,param1=一级钻取字段,param2=二级钻取字段,
export function getDrillList(title, idname, param1, param2) {
  // listsql配置,items=查询列名,tablename=表名,condition=条件,dateparam=时间字段名,
  // (PageList进行查询，items,tablename,condition,前后增加\' ,负责报错)
  var List = {
    /********************用户*********************/
    //用户列表sql
    user: {
      //用户数量
      usernum: [
        'usernum',
        {headData: ["客户编号", "客户名称", "客户地址", "用户类型", "用气类型", "收费类型", "公司"]},
        {bodyData: ['f_userinfo_id', 'f_user_name', 'f_address', 'f_user_type', 'f_gasproperties', 'f_cost_type', 'f_filiale']},
        {dateparam: "f_createfile_date"}
      ],
      //主要用户
      mainuser: [
        'mainuser',
        {headData: ["客户编号", "客户名称", "客户地址", "用户类型", "用气量"]},
        {bodyData: ['f_userinfo_id', 'f_user_name', 'f_address', 'f_user_type', 'f_pregas']},
        {dateparam: "a.f_delivery_date"}
      ]
    },
    /********************监控*********************/
    //监控列表sql
    monitor: {
      //警告
      caveat: [
        // {
        //   items: "\'*\'",
        //   tablename: "\"(select tm.f_magneticInterference,tm.f_alarmShutValve,tm.f_cycleShutValue,tm.f_overCurrentProtection," +
        //   "tm.f_leakageFlag,ti.f_userinfo_id,ti.f_user_name,ti.f_address,ti.f_user_type,ti.f_gasproperties from T_METEREAD tm,t_userinfo ti where " +
        //   this.listparam + this.listparam1 + " tm.f_userinfo_id=ti.f_userinfo_id)\"",
        //   condition: "\'1=1\'",
        //   orderitem: "\'f_userinfo_id desc\'"
        // },
        'caveat',
        {headData: ["客户编号", "客户名称", "客户地址", "用户类型", "用气类型", "磁干扰", "报警关阀", "周期关阀", "过流保护关阀", "关阀走气"]},
        {bodyData: ['f_userinfo_id', 'f_user_name', 'f_address', 'f_user_type', 'f_gasproperties', 'f_magneticinterference', 'f_alarmshutvalve', 'f_cycleshutvalue', 'f_overcurrentprotection', 'f_leakageflag']},
        {dateparam: "tm.f_hand_date"}
      ],
      //长期未用气
      longnotusegas: [
        // {
        //   items: "\'*\'",
        //   tablename: "\"(select al.f_userinfo_id,al.f_user_id,al.f_hand_date,ti.f_user_name,ti.f_user_type,ti.f_gasproperties,ti.f_address," +
        //   "ROUND(TO_NUMBER (SYSDATE - 1 - al.f_hand_date)) duration from a_longnotusegas al,t_userinfo ti where " +
        //   this.listparam + this.listparam1 + " al.f_userinfo_id=ti.f_userinfo_id)\"",
        //   condition: "\'1=1\'",
        //   orderitem: "\'duration desc\'"
        // },
        'longnotusegas',
        {headData: ["客户编号", "客户名称", "客户地址", "用户类型", "用气类型", "表具编号", "最近抄表时间", "未用气时长(天)"]},
        {bodyData: ['f_userinfo_id', 'f_user_name', 'f_address', 'f_user_type', 'f_gasproperties', 'f_user_id', 'f_handplan_max_handdate', 'diffday']},
        {dateparam: "CAST(trunc(SYSDATE)- trunc(F_HANDPLAN_MAX_HANDDATE) as int)"}
      ],
      //失联
      lossassociation: [
        // {
        //   items: "\'*\'",
        //   tablename: "\"(select al.f_userinfo_id,al.f_user_id,al.f_hand_date,ti.f_user_name,ti.f_user_type,ti.f_gasproperties,ti.f_address," +
        //   "ROUND(TO_NUMBER (SYSDATE - 1 - al.f_hand_date)) duration from a_lossassociation al,t_userinfo ti where " +
        //   this.listparam + this.listparam1 + " al.f_userinfo_id=ti.f_userinfo_id)\"",
        //   condition: "\'1=1\'",
        //   orderitem: "\'duration desc\'"
        // },
        'lossassociation',
        {headData: ["客户编号", "客户名称", "客户地址", "用户类型", "用气类型", "表具编号", "最后上报时间", "最后表读数", "失联时长(天)"]},
        {bodyData: ['f_userinfo_id', 'f_user_name', 'f_address', 'f_user_type', 'f_gasproperties', 'f_user_id', 'f_meteread_max_ininsertdate', 'f_meter_base', 'slday']},
        {
          dateparam: "slday"
        }
      ],
      //往期对比
      pastscale: [
        // {
        //   items: "\'*\'",
        //   tablename: "\"(select ti.f_userinfo_id,ti.f_user_name,ti.f_address,ti.f_user_type,ti.f_gasproperties,ab.f_pregas,ab.f_last_pregas," +
        //   "ab.f_delivery_date,pastscale from t_userinfo ti,A_BUYGASCHANGE ab where " +
        //   this.listparam + this.listparam1 + " ti.f_user_state=\'正常\' and  ab.f_last_pregas!=0 and ti.f_userinfo_id=ab.f_userinfo_id) \"",
        //   condition: "\'1=1\'",
        //   orderitem: "\'pastscale desc\'"
        // },
        'pastscale',
        {headData: ["客户编号", "客户名称", "客户地址", "用户类型", "用气类型", "最近购气量", "往期购气均值", "最近购气时间", "往期购气比例"]},
        {bodyData: ['f_userinfo_id', 'f_user_name', 'f_address', 'f_user_type', 'f_gasproperties', 'f_pregas', 'f_last_pregas', 'f_delivery_date', 'pastscale']},
        {dateparam: "ab.f_delivery_date"}
      ],
      //长期未购气
      longnotbuygas: [
        {
          items: "\' * \'",
          tablename: "\"(select distinct(tu.f_userinfo_id),tu.f_user_name,tu.f_address,tu.f_user_type,tu.f_gasproperties, " +
          " al.f_delivery_date,ROUND(TO_NUMBER (SYSDATE \- 1 \- al.F_DELIVERY_DATE)) duration from t_userinfo tu,a_longnotbuygas al where " +
          this.listparam + this.listparam1 + " tu.f_user_state=\'正常\' and tu.f_userinfo_id=al.f_userinfo_id)\"",
          condition: "\'1=1\'",
          orderitem: "\'duration desc\'"
        },
        {headData: ["客户编号", "客户名称", "客户地址", "用户类型", "用气类型", "最近购气时间", "未购气时长(天)"]},
        {bodyData: ['f_userinfo_id', 'f_user_name', 'f_address', 'f_user_type', 'f_gasproperties', 'f_sellinggas_max_date', 'diffday']},
        {dateparam: "CAST(trunc(SYSDATE)- NVL(F_HANDPLAN_MAX_HANDDATE,a.f_input_date) as int)"}
      ],
    },
  }


  //返回PageList查询条件
  return [List[title][idname][1], List[title][idname][2], List[title][idname][3]]
}
