深圳全飞鸿

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 752|回复: 4
打印 上一主题 下一主题

关于下拉框控件的设计与使用:nago_options

[复制链接]

800

主题

1379

帖子

7704

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7704
跳转到指定楼层
楼主
发表于 2019-9-7 14:38:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
关于下拉框控件的设计与使用:nago_options
回复

使用道具 举报

800

主题

1379

帖子

7704

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7704
沙发
 楼主| 发表于 2021-4-22 21:04:05 | 只看该作者
面别的案例:
  1.   <tr>
  2.           <td nowrap style="WIDTH: 10%">&nbsp;面别&nbsp;</td>
  3.           <td>
  4.                 {nago_options name="PROCESS" reportid="SMT_PCB_SIDE"  hasnull="yes"}
  5.                 </td>
  6.   </tr>       
复制代码
回复 支持 反对

使用道具 举报

800

主题

1379

帖子

7704

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7704
板凳
 楼主| 发表于 2021-10-14 11:22:25 | 只看该作者
下拉框分几种处理方式,先直接看源代码的处理部分:
plugins\function.nago_options.php

处理逻辑:
  1. $items=getSpecialValue($reportid);
  2.         if(empty($items)){                                // 不符合特殊转化
  3.                 //从xml中去找
  4.                 $xmlfile="./XML/Condition.xml";
  5.                 $report= new report($reportid);
  6.                 reportXml::FillReport($xmlfile,$report);
  7.                 $report->TransformSQL();
  8.                 $sqlstr=$report->SQLStatment;
  9.                 //__saveLog($sqlstr);
  10.                 $myFetchMode=$db->fetchMode;
  11.                 $db->fetchMode = ADODB_FETCH_ASSOC;
  12.                 $data=$db->getall($sqlstr);
  13.                 //__saveLog(print_r($data,true));
  14.                 $db->fetchMode =$myFetchMode;
  15.                 if(is_array($data)){
  16.                         foreach($data as $vv){
  17.                                 //$items[$vv["TEXT"]] = $vv["VALUE"];  //syant觉得调换位置
  18.                                 $items[$vv["VALUE"]] = $vv["TEXT"];
  19.                         }
  20.                 }        
  21.                 //直接从数据库中获取?应该要加一下缓存!               
  22.                 if(empty($items)){
  23.                         //重新从数据库中查询数据
  24.                         $sql=getCommonData($reportid);
  25.                         $data=$db->getall($sql);
  26.                         /*
  27.                         Array(
  28.                                 [0] => Array(
  29.                                         [VALUE] => P1
  30.                                         [TEXT] => P1)
  31.                                 [1] => Array(
  32.                                         [VALUE] => S1
  33.                                         [TEXT] => S1
  34.                         )*/               
  35.                         //fix by syant 2020/02/27 于凤天
  36.                         if(is_array($data)){
  37.                                 foreach($data as $vv){
  38.                                         //$items[$vv["TEXT"]] = $vv["VALUE"];
  39.                                         $items[$vv["VALUE"]] = $vv["TEXT"];
  40.                                 }
  41.                         }                        
  42.                 }  
  43.         }
复制代码


特殊的处理:
  1. function getSpecialValue($name){
  2.         $ret=array();
  3.         //add by syant 2020-07-23,   $name="TURNPCB,INPUT,INSP";
  4.         if(strpos($name,",")>0){
  5.                 $data=explode(",",$name);
  6.                 foreach($data as $item){
  7.                         $ret[$item]=$item;
  8.                 }
  9.                 return $ret;
  10.         }
  11.         //---
  12.     switch($name) {
  13.         case 'WORK_SECTION':
  14.                 case 'WORK_SECTION_1':
  15.                 case 'WORK_SECTION_2':
  16.                         $ret=array( "00"=>"00","01"=>"01","02"=>"02","03"=>"03","04"=>"04","05"=>"05","06"=>"06",
  17.                                                 "07"=>"07","08"=>"08","09"=>"09","10"=>"10","11"=>"11","12"=>"12",
  18.                                                 "13"=>"13","14"=>"14","15"=>"15","16"=>"16","17"=>"17","18"=>"18",
  19.                                                 "19"=>"19","20"=>"20","21"=>"21","22"=>"22","23"=>"23",);
  20.             break;
  21.         case 'MES_INPUT':
  22.                         $ret=array( "SN"=>"SN","MAC"=>"MAC","MO"=>"MO",);
  23.             break;        
  24.         case 'SMT_STATION_TYPE':  //机台类型
  25.                 $ret=array( "1"=>"SMT MACHINE","2"=>"STATION","3"=>"PRINTER MACHINE","4"=>"AOI MACHINE",);
  26.                 break;
  27.         case 'SMT_PCB_SIDE':  //机台类型
  28.                 $ret=array( "A"=>"A","B"=>"B",);
  29.                 break;
  30.     }
  31.         return $ret;
  32. }
复制代码


通用的处理:
  1. /*
  2. * 约定的一些特殊SQL
  3. */
  4. function getCommonData($name){
  5.         $sql="";
  6.     switch($name) {
  7.         case 'SMT_LINE':
  8.                         $sql="SELECT DISTINCT  LINE_NAME VALUE ,LINE_NAME TEXT
  9.                         FROM smt.c_line_station
  10.                         WHERE line_name NOT IN ('L_I_N_E')
  11.                         ORDER BY line_name";
  12.             break;
  13.         default:
  14.                         /*
  15.                         此处引用一个通用表:
  16.                         CREATE TABLE sfc.`c_options_item_t` (
  17.                                 `ITEM_TYPE` varchar(20) DEFAULT NULL,
  18.                                 `ITEM_NAME` varchar(50) DEFAULT NULL,
  19.                                 `ITEM_VALUE` varchar(50) DEFAULT NULL,
  20.                                 `ITEM_ORDER` int(11) DEFAULT NULL
  21.                         ) ENGINE=InnoDB DEFAULT CHARSET=utf8
  22.                         */
  23.             $sql="select ITEM_NAME TEXT,ITEM_VALUE VALUE
  24.                                  from c_options_item_t where ITEM_TYPE='{$name}'
  25.                                  order by ITEM_ORDER ";
  26.             break;
  27.     }        
  28.         return $sql;        
  29. }
复制代码

回复 支持 反对

使用道具 举报

800

主题

1379

帖子

7704

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7704
地板
 楼主| 发表于 2021-10-14 13:30:06 | 只看该作者
使用方法一:常规用法

  <tr>
          <td nowrap style="WIDTH: 10%"> 面别 </td>
          <td>
                {nago_options name="PROCESS" reportid="SMT_PCB_SIDE"  hasnull="yes"}
                </td>
  </tr>      

其中SMT_PCB_SIDE定义在Condition.xml中



使用方法二:特殊的处理
          <td>
           {nago_options reportid="MES_INPUT" selected="SN" name="MES_INPUT" }
        </td>

其中MES_DATA定义在plugins\function.nago_options.php


使用方法三:在数据表中定义

select ITEM_NAME TEXT,ITEM_VALUE VALUE
                                 from c_options_item_t where ITEM_TYPE='{$name}'
                                 order by ITEM_ORDER

在表里建立数据


使用方法四:直接列出选项
  <td nowrap="nowrap"><font face="Microsoft YaHei">资产分类</font><td>
        {nago_options name="ZJTYPE" reportid="治具,设备" value="ALL" id="ZJTYPE" mode=0 width=200 layer="editlayer"}
  <td nowrap="nowrap"></td>




回复 支持 反对

使用道具 举报

800

主题

1379

帖子

7704

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7704
5#
 楼主| 发表于 2021-10-14 13:32:50 | 只看该作者
常用案例:>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\l1\l1_62.php<<<<<
                           {nago_options reportid="SFC_MOVE_TYPE" name="MOVE_TYPE" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\oqc\repair_03.php<<<<<
                           {nago_options reportid="SFC_MOVE_TYPE" name="MOVE_TYPE" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\repair\repair_03.php<<<<<
                           {nago_options reportid="SFC_MOVE_TYPE" name="MOVE_TYPE" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\k2\k2_32.php<<<<<
                {nago_options name="PROCESS" reportid="SMT_PCB_SIDE"  hasnull="yes"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\l1\l1_62.php<<<<<
                           {nago_options reportid="SFC_MOVE_TYPE" name="MOVE_TYPE" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\c1\c1_17_insert--.html<<<<<
                {nago_options name="STATION_FLAG" reportid="SMT_STATION_TYPE" hasnull="yes" width=200 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\c1\c1_17_update.html<<<<<
                {nago_options name="STATION_FLAG" reportid="SMT_STATION_TYPE" width=200 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\c2\c2_15_insert.html<<<<<
        {nago_options name="PANEL_TYPE" reportid="SMT_PANEL" value=""  width=173 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\c2\c2_15_update.html<<<<<
        {nago_options name="PANEL_TYPE" reportid="SMT_PANEL" width=173 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\datainput\query.html<<<<<
           {nago_options reportid="MES_INPUT" selected="SN" name="MES_INPUT" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\k2\k2_07.html<<<<<
                {nago_options name="PROCESS" reportid="SMT_PCB_SIDE"  hasnull="yes" width=150}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\k2\k2_32.html<<<<<
                {nago_options name="PROCESS" reportid="SMT_PCB_SIDE"  hasnull="yes"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\ntf\ntfreport.html<<<<<
           {nago_options value="WORK_SECTION" selected="00" name="WORK_SECTION_1"  id="WORK_SECTION_1" }
           {nago_options value="WORK_SECTION" selected="23" name="WORK_SECTION_2"  id="WORK_SECTION_2" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\qm\model.html<<<<<
           {nago_options value="WORK_SECTION" selected="00" name="WORK_SECTION_1"  id="WORK_SECTION_1" }
           {nago_options value="WORK_SECTION" selected="23" name="WORK_SECTION_2"  id="WORK_SECTION_2" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\smo\setup_insert.html<<<<<
        {nago_options name="STATION_TYPE" reportid="XINWEN" width=200  hasnull="yes" layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\smo\setup_update.html<<<<<
        {nago_options name="STATION_TYPE" reportid="XINWEN" width=200  hasnull="yes" layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\smt_line\kpchange.html<<<<<
                {nago_options name="SMT_LINE" reportid="SMT_LINE"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\smt_line\model.html<<<<<
           {nago_options value="WORK_SECTION" selected="00" name="WORK_SECTION_1"  id="WORK_SECTION_1" }
           {nago_options value="WORK_SECTION" selected="23" name="WORK_SECTION_2"  id="WORK_SECTION_2" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\smt_line\wip.html<<<<<
                {nago_options name="SMT_LINE" reportid="SMT_LINE"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\zju\zjsn_insert.html<<<<<
        {nago_options name="ZJTYPE" reportid="娌诲叿,璁惧?" value="ALL" id="ZJTYPE" mode=0 width=200 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates\zju\zjtype_insert.html<<<<<
        {nago_options name="ZJTYPE" reportid="娌诲叿,璁惧?" value="ALL" id="ZJTYPE" mode=0 width=200 layer="editlayer"}
        {nago_options name="ZJ_TYPE" reportid="娌诲叿,璁惧?" value="ALL" id="ZJ_TYPE" mode=0 width=200 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\c1\c1_17_insert.html<<<<<
                {nago_options name="STATION_FLAG" reportid="SMT_STATION_TYPE" hasnull="yes" width=200 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\c1\c1_17_update.html<<<<<
                {nago_options name="STATION_FLAG" reportid="SMT_STATION_TYPE" width=200 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\c2\c2_15_insert.html<<<<<
        {nago_options name="PANEL_TYPE" reportid="SMT_PANEL" value=""  width=173 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\c2\c2_15_update.html<<<<<
        {nago_options name="PANEL_TYPE" reportid="SMT_PANEL" width=173 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\datainput\query.html<<<<<
           {nago_options reportid="MES_INPUT" selected="SN" name="MES_INPUT" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\qm\model.html<<<<<
           {nago_options value="WORK_SECTION" selected="00" name="WORK_SECTION_1"  id="WORK_SECTION_1" }
           {nago_options value="WORK_SECTION" selected="23" name="WORK_SECTION_2"  id="WORK_SECTION_2" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\smo\setup_insert.html<<<<<
        {nago_options name="STATION_TYPE" reportid="XINWEN" width=200  hasnull="yes" layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\smo\setup_update.html<<<<<
        {nago_options name="STATION_TYPE" reportid="XINWEN" width=200  hasnull="yes" layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\smt_line\kpchange.html<<<<<
                {nago_options name="SMT_LINE" reportid="SMT_LINE"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\smt_line\model.html<<<<<
           {nago_options value="WORK_SECTION" selected="00" name="WORK_SECTION_1"  id="WORK_SECTION_1" }
           {nago_options value="WORK_SECTION" selected="23" name="WORK_SECTION_2"  id="WORK_SECTION_2" }
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\smt_line\wip.html<<<<<
                {nago_options name="SMT_LINE" reportid="SMT_LINE"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\zju\zjsn_insert.html<<<<<
        {nago_options name="ZJTYPE" reportid="娌诲叿,璁惧?" value="ALL" id="ZJTYPE" mode=0 width=200 layer="editlayer"}
>>>>d:\project.syant\0005php\htdocs\sfc-source\templates_en\zju\zjtype_insert.html<<<<<
        {nago_options name="ZJTYPE" reportid="娌诲叿,璁惧?" value="ALL" id="ZJTYPE" mode=0 width=200 layer="editlayer"}
        {nago_options name="ZJ_TYPE" reportid="娌诲叿,璁惧?" value="ALL" id="ZJ_TYPE" mode=0 width=200 layer="editlayer"}


回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|nagomes  

GMT+8, 2025-5-4 17:55 , Processed in 0.029874 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表