深圳全飞鸿
标题:
关于下拉框控件的设计与使用:nago_options
[打印本页]
作者:
zhgc
时间:
2019-9-7 14:38
标题:
关于下拉框控件的设计与使用:nago_options
关于下拉框控件的设计与使用:nago_options
作者:
zhgc
时间:
2021-4-22 21:04
面别的案例:
<tr>
<td nowrap style="WIDTH: 10%"> 面别 </td>
<td>
{nago_options name="PROCESS" reportid="SMT_PCB_SIDE" hasnull="yes"}
</td>
</tr>
复制代码
作者:
zhgc
时间:
2021-10-14 11:22
下拉框分几种处理方式,先直接看源代码的处理部分:
plugins\function.nago_options.php
处理逻辑:
$items=getSpecialValue($reportid);
if(empty($items)){ // 不符合特殊转化
//从xml中去找
$xmlfile="./XML/Condition.xml";
$report= new report($reportid);
reportXml::FillReport($xmlfile,$report);
$report->TransformSQL();
$sqlstr=$report->SQLStatment;
//__saveLog($sqlstr);
$myFetchMode=$db->fetchMode;
$db->fetchMode = ADODB_FETCH_ASSOC;
$data=$db->getall($sqlstr);
//__saveLog(print_r($data,true));
$db->fetchMode =$myFetchMode;
if(is_array($data)){
foreach($data as $vv){
//$items[$vv["TEXT"]] = $vv["VALUE"]; //syant觉得调换位置
$items[$vv["VALUE"]] = $vv["TEXT"];
}
}
//直接从数据库中获取?应该要加一下缓存!
if(empty($items)){
//重新从数据库中查询数据
$sql=getCommonData($reportid);
$data=$db->getall($sql);
/*
Array(
[0] => Array(
[VALUE] => P1
[TEXT] => P1)
[1] => Array(
[VALUE] => S1
[TEXT] => S1
)*/
//fix by syant 2020/02/27 于凤天
if(is_array($data)){
foreach($data as $vv){
//$items[$vv["TEXT"]] = $vv["VALUE"];
$items[$vv["VALUE"]] = $vv["TEXT"];
}
}
}
}
复制代码
特殊的处理:
function getSpecialValue($name){
$ret=array();
//add by syant 2020-07-23, $name="TURNPCB,INPUT,INSP";
if(strpos($name,",")>0){
$data=explode(",",$name);
foreach($data as $item){
$ret[$item]=$item;
}
return $ret;
}
//---
switch($name) {
case 'WORK_SECTION':
case 'WORK_SECTION_1':
case 'WORK_SECTION_2':
$ret=array( "00"=>"00","01"=>"01","02"=>"02","03"=>"03","04"=>"04","05"=>"05","06"=>"06",
"07"=>"07","08"=>"08","09"=>"09","10"=>"10","11"=>"11","12"=>"12",
"13"=>"13","14"=>"14","15"=>"15","16"=>"16","17"=>"17","18"=>"18",
"19"=>"19","20"=>"20","21"=>"21","22"=>"22","23"=>"23",);
break;
case 'MES_INPUT':
$ret=array( "SN"=>"SN","MAC"=>"MAC","MO"=>"MO",);
break;
case 'SMT_STATION_TYPE': //机台类型
$ret=array( "1"=>"SMT MACHINE","2"=>"STATION","3"=>"PRINTER MACHINE","4"=>"AOI MACHINE",);
break;
case 'SMT_PCB_SIDE': //机台类型
$ret=array( "A"=>"A","B"=>"B",);
break;
}
return $ret;
}
复制代码
通用的处理:
/*
* 约定的一些特殊SQL
*/
function getCommonData($name){
$sql="";
switch($name) {
case 'SMT_LINE':
$sql="SELECT DISTINCT LINE_NAME VALUE ,LINE_NAME TEXT
FROM smt.c_line_station
WHERE line_name NOT IN ('L_I_N_E')
ORDER BY line_name";
break;
default:
/*
此处引用一个通用表:
CREATE TABLE sfc.`c_options_item_t` (
`ITEM_TYPE` varchar(20) DEFAULT NULL,
`ITEM_NAME` varchar(50) DEFAULT NULL,
`ITEM_VALUE` varchar(50) DEFAULT NULL,
`ITEM_ORDER` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
*/
$sql="select ITEM_NAME TEXT,ITEM_VALUE VALUE
from c_options_item_t where ITEM_TYPE='{$name}'
order by ITEM_ORDER ";
break;
}
return $sql;
}
复制代码
作者:
zhgc
时间:
2021-10-14 13:30
使用方法一:常规用法
<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>
作者:
zhgc
时间:
2021-10-14 13:32
常用案例:>>>>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"}
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2