From b019a088d4eca37207a45731c3201eaf745b64ff Mon Sep 17 00:00:00 2001 From: boi Date: Mon, 30 Jun 2025 15:08:46 +0800 Subject: [PATCH] update --- web/admin/ap/demo.html | 88 +++++++++++++++++++++++++- web/admin/ap/demo.php | 98 ++++++++++++++++++++++++++++- web/admin/demo/form_inputbet.html | 20 ++++-- web/admin/develop/code_common.php | 5 +- web/admin/develop/code_create.html | 2 +- web/admin/develop/code_pc_html.php | 19 +++++- web/admin/develop/code_pc_php.php | 32 +++++++++- web/jscss/ciy.js | 11 +++- web/jscss/ciycmp.js | 92 +++++++++++++++++++++++++++ web/jscss/ciycmp2.js | 43 ------------- web/jscss/ciytable.js | 99 +++++++++++++++++++++--------- 11 files changed, 418 insertions(+), 91 deletions(-) diff --git a/web/admin/ap/demo.html b/web/admin/ap/demo.html index 35dd87c..289f415 100644 --- a/web/admin/ap/demo.html +++ b/web/admin/ap/demo.html @@ -243,6 +243,36 @@ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
@@ -278,9 +308,6 @@ dom: '.table' , url: 'list' , pagecount: 10 - , help: { - 'name': '列帮助
第二行' - } , fn_beforedata: function (json) { ciyfn.fillsearch({ searchdom: '.search' @@ -383,6 +410,11 @@ $5('[name=url]', dom).val(dat.url); ciycmp({ dom: $5('[com=weightg]', dom), value: dat.weightg }); ciycmp({ dom: $5('[com=eartmpr]', dom), value: dat.eartmpr }); + ciycmp({ dom: $5('[com=qian]', dom), value: dat.qian }); + ciycmp({ dom: $5('[com=meishi]', dom), value: dat.meishi }); + ciycmp({ dom: $5('[com=weight]', dom), value: dat.weight }); + ciycmp({ dom: $5('[com=height]', dom), value: dat.height }); + ciycmp({ dom: $5('[com=skt]', dom), value: dat.skt }); $5('[name=idcard]', dom).val(dat.idcard); ciycmp({ dom: $5('[com=content]', dom), value: dat.content }); ciycmp({ dom: $5('[com=md]', dom), value: dat.md, path: path }); @@ -593,6 +625,31 @@ html += ciyfn.tdshow(dat.eartmpr, table.field.eartmpr.ext, dat, table.once, table.json, true); html += '
'; + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.qian, table.field.qian.ext, dat, table.once, table.json, true); + html += '
'; + + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.meishi, table.field.meishi.ext, dat, table.once, table.json, true); + html += '
'; + + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.weight, table.field.weight.ext, dat, table.once, table.json, true); + html += '
'; + + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.height, table.field.height.ext, dat, table.once, table.json, true); + html += '
'; + + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.skt, table.field.skt.ext, dat, table.once, table.json, true); + html += '
'; + html += '
'; html += '
'; html += ciyfn.tdshow(dat.idcard, table.field.idcard.ext, dat, table.once, table.json, true); @@ -781,6 +838,31 @@ html += ciyfn.tdshow(dat.eartmpr, table.field.eartmpr.ext, dat, table.once, table.json, true); html += '
'; + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.qian, table.field.qian.ext, dat, table.once, table.json, true); + html += '
'; + + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.meishi, table.field.meishi.ext, dat, table.once, table.json, true); + html += '
'; + + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.weight, table.field.weight.ext, dat, table.once, table.json, true); + html += '
'; + + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.height, table.field.height.ext, dat, table.once, table.json, true); + html += '
'; + + html += '
'; + html += '
'; + html += ciyfn.tdshow(dat.skt, table.field.skt.ext, dat, table.once, table.json, true); + html += '
'; + html += '
'; html += '
'; html += ciyfn.tdshow(dat.idcard, table.field.idcard.ext, dat, table.once, table.json, true); diff --git a/web/admin/ap/demo.php b/web/admin/ap/demo.php index fde1dfd..7692086 100644 --- a/web/admin/ap/demo.php +++ b/web/admin/ap/demo.php @@ -157,6 +157,11 @@ class demo { $url = $post->get('url'); $weightg = $post->getint('weightg'); $eartmpr = $post->getint('eartmpr'); + $qian = $post->getint('qian'); + $meishi = $post->getint('meishi'); + $weight = $post->getint('weight'); + $height = $post->getint('height'); + $skt = $post->getint('skt'); $idcard = $post->get('idcard'); $content = $post->get('content'); $md = $post->get('md'); @@ -205,6 +210,11 @@ class demo { $updata['url'] = $url; $updata['weightg'] = $weightg; $updata['eartmpr'] = $eartmpr; + $updata['qian'] = $qian; + $updata['meishi'] = $meishi; + $updata['weight'] = $weight; + $updata['height'] = $height; + $updata['skt'] = $skt; $updata['idcard'] = $idcard; $updata['addtimes'] = tostamp(); $updata['content'] = $content; @@ -215,14 +225,18 @@ class demo { if ($db->update($csql, $updata) === false) throw new \Exception('更新失败:' . $db->error); } else { - $updata['auditstatus'] = 20; + $updata['id'] = 0; + $updata['auditstatus'] = 0; + $updata['audituser'] = 0; + $updata['audittimes'] = 0; + $updata['auditmsg'] = ''; $updata['addtimes'] = tostamp(); if ($db->insert($csql, $updata) === false) throw new \Exception('新增失败:' . $db->error); $id = $db->insert_id(); } $updata['id'] = $id; - savelogdb($db, $rsuser['id'], 'ap_demo', $datarow, $updata); + //savelogdb($db, $rsuser['id'], 'ap_demo', $datarow, $updata); $db->commit(); } catch (\Exception $ex) { $db->rollback(); @@ -358,6 +372,11 @@ class demo { $fields[] = array('style' => 'l', 'width' => 150, 'field' => 'url', 'name' => '链接'); $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'weightg', 'name' => '体重'); $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'eartmpr', 'name' => '耳温'); + $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'qian', 'name' => '中式钱'); + $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'meishi', 'name' => '美式钱'); + $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'weight', 'name' => '重量'); + $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'height', 'name' => '长度'); + $fields[] = array('style' => 'r', 'width' => 100, 'field' => 'skt', 'name' => '科学数'); $fields[] = array('style' => 'l', 'width' => 150, 'field' => 'idcard', 'name' => '身份证号'); $fields[] = array('style' => 'l', 'width' => 100, 'field' => 'addtimes', 'name' => '添加时间'); $fields[] = array('style' => 'l', 'width' => 150, 'field' => 'content', 'name' => '介绍'); @@ -432,6 +451,14 @@ class demo { $val = number_format($val / 1000, 3) . 'KG'; if ($field == 'eartmpr') $val = number_format($val / 1000, 1) . '℃'; + if ($field == 'qian') + $val = number_format($val / 100, 2) . '元'; + if ($field == 'weight') + $val = number_format($val / 1000, 3) . 'KG'; + if ($field == 'height') + $val = number_format($val / 1000, 3) . '米'; + if ($field == 'skt') + $val = number_format($val / 1000, 3) . 'SKT'; if ($field == 'addtimes') $val = ($val == 0 ? '--' : date('Y-m-d H:i', $val)); $dat[] = $val; @@ -445,7 +472,7 @@ class demo { $param['titleheight'] = '25'; //列头高度 $param['landscape'] = true; //横向打印 $param['fixtopage'] = true; //打印整个工作表 - $param['toptitle'] = 'Demo数据报表'; + $param['toptitle'] = '复杂功能数据报表'; $str = \ciy\excel::general_excel_xml($param); $filename = ''; if (empty($filename)) @@ -502,6 +529,11 @@ class demo { $headsn[] = '链接.url'; $headsn[] = '体重.weightg'; $headsn[] = '耳温.eartmpr'; + $headsn[] = '中式钱.qian'; + $headsn[] = '美式钱.meishi'; + $headsn[] = '重量.weight'; + $headsn[] = '长度.height'; + $headsn[] = '科学数.skt'; $headsn[] = '身份证号.idcard'; $headsn[] = '介绍.content'; $xlsidx = 1; @@ -886,6 +918,61 @@ class demo { $value = (int)((float)$showdat * 1000); $showdat .= '℃'; } + } else if ($name == '中式钱') { + if (empty($showdat)) { + $value = 0; + } else { + $showdat = str_replace(',', '', str_replace('元', '', $showdat)); + if (!is_numeric($showdat)) + $errmsg = $name . '不是数字'; + else + $value = (int)((float)$showdat * 100); + $showdat .= '元'; + } + } else if ($name == '美式钱') { + if (empty($showdat)) { + $value = 0; + } else { + $showdat = str_replace(',', '', str_replace('¤', '', $showdat)); + if (!is_numeric($showdat)) + $errmsg = $name . '不是数字'; + else + $value = (int)((float)$showdat * 100); + $showdat .= '¤'; + } + } else if ($name == '重量') { + if (empty($showdat)) { + $value = 0; + } else { + $showdat = str_replace(',', '', str_replace('KG', '', $showdat)); + if (!is_numeric($showdat)) + $errmsg = $name . '不是数字'; + else + $value = (int)((float)$showdat * 1000); + $showdat .= 'KG'; + } + } else if ($name == '长度') { + if (empty($showdat)) { + $value = 0; + } else { + $showdat = str_replace(',', '', str_replace('米', '', $showdat)); + if (!is_numeric($showdat)) + $errmsg = $name . '不是数字'; + else + $value = (int)((float)$showdat * 1000); + $showdat .= '米'; + } + } else if ($name == '科学数') { + if (empty($showdat)) { + $value = 0; + } else { + $showdat = str_replace(',', '', str_replace('SKT', '', $showdat)); + if (!is_numeric($showdat)) + $errmsg = $name . '不是数字'; + else + $value = (int)((float)$showdat * 1000); + $showdat .= 'SKT'; + } } else if ($name == '身份证号') { if (empty($showdat)) { $value = ''; @@ -967,6 +1054,11 @@ class demo { $updata['url'] = $post->get('url_' . $i); $updata['weightg'] = $post->get('weightg_' . $i); $updata['eartmpr'] = $post->get('eartmpr_' . $i); + $updata['qian'] = $post->get('qian_' . $i); + $updata['meishi'] = $post->get('meishi_' . $i); + $updata['weight'] = $post->get('weight_' . $i); + $updata['height'] = $post->get('height_' . $i); + $updata['skt'] = $post->get('skt_' . $i); $updata['idcard'] = $post->get('idcard_' . $i); $updata['content'] = $post->get('content_' . $i); $csql = new \ciy\sql('ap_demo'); diff --git a/web/admin/demo/form_inputbet.html b/web/admin/demo/form_inputbet.html index fded088..e6e8d81 100644 --- a/web/admin/demo/form_inputbet.html +++ b/web/admin/demo/form_inputbet.html @@ -26,6 +26,14 @@
+
+ +
+
+
+ +
+
改变值 @@ -44,10 +52,12 @@ 'use strict'; var c; ciyfn.pageload(function () { - c = ciycmp({ dom: '[com=a]' }); - c.onchange = function (d) { console.log(d) }; - ciycmp({ dom: '[com=b]', onchange: function (d) { console.log(d) } }); - ciycmp({ dom: '[com=c]', value: 100, onchange: function (d) { console.log(d) } }); + // c = ciycmp({ dom: '[com=a]' }); + // c.onchange = function (d) { console.log(d) }; + // ciycmp({ dom: '[com=b]', onchange: function (d) { console.log(d) } }); + // ciycmp({ dom: '[com=c]', value: 100, onchange: function (d) { console.log(d) } }); + // ciycmp({ dom: '[com=d]', value: "0", onchange: function (d) { console.log(d) } }); + ciycmp({ dom: '[com=e]', value: "023", onchange: function (d) { console.log(d) } }); }); function formsubmit(event) { event.preventDefault(); @@ -55,7 +65,7 @@ console.log(postparam); } function chg() { - c.setvalue(2000); + c.setvalue(220); } diff --git a/web/admin/develop/code_common.php b/web/admin/develop/code_common.php index bd3e75a..3023fe7 100644 --- a/web/admin/develop/code_common.php +++ b/web/admin/develop/code_common.php @@ -53,8 +53,11 @@ function calfld($post) { } function flddata($data, $idx, $def) { $strs = explode(',', $data); - if($idx < count($strs)) + if($idx < count($strs)){ + if(empty($strs[$idx])) + return $def; return $strs[$idx]; + } return $def; } function json_createphp() { diff --git a/web/admin/develop/code_create.html b/web/admin/develop/code_create.html index a8638ef..c7cf3b6 100644 --- a/web/admin/develop/code_create.html +++ b/web/admin/develop/code_create.html @@ -207,7 +207,7 @@ if (!cc.bcod.saascode) cc.bcod.saascode = ciyfn.getstorage('_ccode_saascode', ''); if (!cc.bcod.savepc) - cc.bcod.savepc = ciyfn.getstorage('_ccode_savepc', 'd:\\') + cc.bcod.tabname.substring(cc.bcod.tabname.indexOf('_') + 1); + cc.bcod.savepc = ciyfn.getstorage('_ccode_savepc', 'web\\*\\') + cc.bcod.tabname.substring(cc.bcod.tabname.indexOf('_') + 1); $5('[name=_bcod_verifyfunc]').val(cc.bcod.verifyfunc); $5('[name=_bcod_titname]').val(cc.bcod.titname); diff --git a/web/admin/develop/code_pc_html.php b/web/admin/develop/code_pc_html.php index 5fd0480..0fafef0 100644 --- a/web/admin/develop/code_pc_html.php +++ b/web/admin/develop/code_pc_html.php @@ -55,8 +55,8 @@ function code_pc_html($post) { $chk_getupdate = true; $cate = $fld['cate']; if ( - $cate == 'CATM' || $cate == 'CATS' || $cate == 'MD' || $cate == 'CYC' || $cate == 'LOC' || $cate == 'UNIT' || $cate == 'TIME' - || $cate == 'FSIZE' || $cate == 'METRE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'BET' || $cate == 'PCT' || $cate == 'CNY' || $cate == 'KG' || $cate == 'TC' + $cate == 'CATM' || $cate == 'CATS' || $cate == 'MD' || $cate == 'CYC' || $cate == 'LOC' || $cate == 'UNIT' + || $cate == 'TIME' || $cate == 'SEC' || $cate == 'IMG1' || $cate == 'IMG' || $cate == 'DOWN' || $cate == 'AV' ) $ciycmp2 = true; list($dicttype, $dictname) = splitdict($fld['data']); @@ -371,6 +371,18 @@ if($hasedit){ $unit = flddata($fld['data'], 0, ''); $bet = flddata($fld['data'], 1, 100); $codex .= "\n{$pspec} "; + } else if ($cate == 'LNY') { + $unit = flddata($fld['data'], 0, '元.万元.亿元'); + $codex .= "\n{$pspec} "; + } else if ($cate == 'SNY') { + $unit = flddata($fld['data'], 0, '¤.K¤.M¤.B¤.T¤.Q¤'); + $codex .= "\n{$pspec} "; + } else if ($cate == 'WGT') { + $unit = flddata($fld['data'], 0, '克.*千克.吨'); + $codex .= "\n{$pspec} "; + } else if ($cate == 'LGH') { + $unit = flddata($fld['data'], 0, '厘米.*米.公里'); + $codex .= "\n{$pspec} "; } else if ($cate == 'PCT') { $codex .= "\n{$pspec} "; } else if ($cate == 'CNY') { @@ -622,7 +634,8 @@ if($hasedit){ } else if ( $cate == 'FSIZE' || $cate == 'METRE' || $cate == 'DATE' || $cate == 'TIME' || $cate == 'BOOL' || $cate == 'WCNY' || $cate == 'UNIT' || $cate == 'CYC' || $cate == 'SEC' || $cate == 'TON' - || $cate == 'PCT' || $cate == 'CNY' || $cate == 'KG' || $cate == 'TC' || $cate == 'BR' || $cate == 'BET' + || $cate == 'PCT' || $cate == 'CNY' || $cate == 'KG' || $cate == 'TC' || $cate == 'BR' + || $cate == 'BET' || $cate == 'LNY' || $cate == 'SNY' || $cate == 'WGT' || $cate == 'LGH' ) { $codex .= "\n ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col} });"; } else if ($cate == 'CATA' || $cate == 'CATU' || $cate == 'CATM' || $cate == 'CATS' || $cate == 'TINT' || $cate == 'DB') { diff --git a/web/admin/develop/code_pc_php.php b/web/admin/develop/code_pc_php.php index b9b3a64..d414c96 100644 --- a/web/admin/develop/code_pc_php.php +++ b/web/admin/develop/code_pc_php.php @@ -148,6 +148,7 @@ function code_pc_php($post) { } else if ( $cate == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'BET' || $cate == 'PCT' || $cate == 'CNY' || $cate == 'NUM' || $cate == 'KG' || $cate == 'TC' || $cate == 'INT' + || $cate == 'LNY' || $cate == 'SNY' || $cate == 'WGT' || $cate == 'LGH' ) { $bet = 1000; if ($cate == 'FSIZE') @@ -156,9 +157,9 @@ function code_pc_php($post) { $bet = 1000000; else if ($cate == 'SEC' || $cate == 'NUM' || $cate == 'INT') $bet = 1; - else if ($cate == 'PCT' || $cate == 'CNY') + else if ($cate == 'PCT' || $cate == 'CNY' || $cate == 'LNY' || $cate == 'SNY') $bet = 100; - else if ($cate == 'BET'){ + else if ($cate == 'BET') { $bet = flddata($fld['data'], 1, 100); } $codex .= "\n \$csql->wherenumrange('{$col}', objstr(\$query, '{$col}_1'), objstr(\$query, '{$col}_2'), {$bet});"; @@ -267,8 +268,9 @@ function code_pc_php($post) { else $codex .= "\n \$input[] = array('type' => 'daterange', 'form' => '{$col}', 'name' => '{$fld['name']}');"; } else if ( - $cate == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'BET' + $cate == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'PCT' || $cate == 'CNY' || $cate == 'NUM' || $cate == 'KG' || $cate == 'TC' || $cate == 'INT' + || $cate == 'BET' || $cate == 'LNY' || $cate == 'SNY' || $cate == 'WGT' || $cate == 'LGH' ) { $codex .= "\n \$input[] = array('type' => 'num', 'form' => '{$col}', 'name' => '{$fld['name']}', 'prop' => ' style=\"width:4em;\"');"; } else { @@ -816,6 +818,18 @@ function code_pc_php($post) { $bet = flddata($fld['data'], 1, 100); $codex .= "\n if (\$field == '{$col}')"; $codex .= "\n \$val = number_format(\$val / {$bet}, 3) . '{$unit}';"; + } else if ($cate == 'LNY') { + $codex .= "\n if (\$field == '{$col}')"; + $codex .= "\n \$val = number_format(\$val / 100, 2) . '元';"; + } else if ($cate == 'LNY') { + $codex .= "\n if (\$field == '{$col}')"; + $codex .= "\n \$val = number_format(\$val / 100, 2) . '¤';"; + } else if ($cate == 'WGT') { + $codex .= "\n if (\$field == '{$col}')"; + $codex .= "\n \$val = number_format(\$val / 1000, 3) . 'KG';"; + } else if ($cate == 'LGH') { + $codex .= "\n if (\$field == '{$col}')"; + $codex .= "\n \$val = number_format(\$val / 1000, 3) . '米';"; } else if ($cate == 'TON') { $codex .= "\n if (\$field == '{$col}')"; $codex .= "\n \$val = number_format(\$val / 1000000, 3) . '吨';"; @@ -1111,6 +1125,18 @@ function code_pc_php($post) { } else if ($cate == 'BET') { $unit = flddata($fld['data'], 0, ''); $bet = flddata($fld['data'], 1, 100); + } else if ($cate == 'LGH') { + $unit = '米'; + $bet = 1000; + } else if ($cate == 'WGT') { + $unit = 'KG'; + $bet = 1000; + } else if ($cate == 'LNY') { + $unit = '元'; + $bet = 100; + } else if ($cate == 'SNY') { + $unit = '¤'; + $bet = 100; } else if ($cate == 'TON') { $unit = '吨'; $bet = 1000000; diff --git a/web/jscss/ciy.js b/web/jscss/ciy.js index 07fb00f..ec46bfa 100644 --- a/web/jscss/ciy.js +++ b/web/jscss/ciy.js @@ -804,6 +804,15 @@ ciyfn.isemptyobj = function (obj) { } return true; } +ciyfn.split = function (str, sep) { + if (!str) + return []; + str = str + ''; + var arr = str.split(sep); + for (var i = 0; i < arr.length; i++) + arr[i] = arr[i].trim(); + return arr; +} ciyfn.getdictdata = function (datakey, once, reldata) { //直接数组(直传,once数据),字典缓存,静态引用,字符串拼接 if (isarray(datakey)) @@ -821,7 +830,7 @@ ciyfn.getdictdata = function (datakey, once, reldata) { return window[datakey]; if (datakey.indexOf('.') == -1) return new Array(); - var svs = datakey.split('.'); + var svs = ciyfn.split(datakey, '.'); datas = new Array(); for (var i = 0; i < svs.length; i++) { var ind = svs[i].indexOf(':'); diff --git a/web/jscss/ciycmp.js b/web/jscss/ciycmp.js index ee941ba..90444e1 100644 --- a/web/jscss/ciycmp.js +++ b/web/jscss/ciycmp.js @@ -905,6 +905,7 @@ ciycmpfunc.ciyselect = function (opn) { opn.hasmore = opn.hasmore || opn.dom.hasattr('hasmore'); opn.minsearch = toint(opn.minsearch || opn.dom.attr('minsearch') || 0); opn.all = opn.all || opn.dom.attr('all') || ''; + opn.range = opn.range || opn.dom.attr('range'); opn.minwidth = opn.minwidth || opn.dom.attr('minwidth') || ''; opn.placeholder = opn.placeholder || opn.dom.attr('placeholder') || '请选择'; if (typeof (opn.fn_li) != 'function') @@ -1108,6 +1109,97 @@ ciycmpfunc.ciyselect = function (opn) { panelrect(); } } +ciycmpfunc.ciyinputbet = function (opn) { + var thos = this; + this.onchange = opn.onchange; + opn.initevent = opn.initevent || opn.dom.hasattr('initevent'); + opn.hasmore = opn.hasmore || opn.dom.hasattr('hasmore'); + opn.inpstyle = opn.inpstyle || opn.dom.attr('inpstyle') || ''; + opn.bets = ciyfn.split(opn.bet || opn.dom.attr('bet'), '.'); + opn.units = ciyfn.split(opn.unit || opn.dom.attr('unit'), '.'); + if (opn.bets.length < opn.units.length) + opn.units.splice(opn.bets.length); + if (opn.bets.length > opn.units.length) + opn.bets.splice(opn.units.length); + if (opn.bets.length == 0) { + opn.bets = [1]; + opn.units = ['']; + } + opn.betidx = 0; + for (var i = 0; i < opn.bets.length; i++) { + opn.bets[i] = toint(opn.bets[i]); + if (opn.bets[i] < 1) + opn.bets[i] = 1; + if (opn.units[i].substring(0, 1) == '*') { + opn.betidx = i; + opn.units[i] = opn.units[i].substring(1); + } + } + opn.width = opn.width || opn.dom.attr('width') || '5em'; + opn.align = opn.align || opn.dom.attr('align') || 'right'; + var html = ''; + html += ''; + html += ''; + if (opn.hasmore) + html += ''; + if (opn.units.length > 1) + html += ''; + if (opn.units.length == 1) + html += '' + opn.units[0] + ''; + opn.dom.html(html).css({ display: 'inline-flex', alignItems: 'center' }); + if (opn.units.length > 1) { + var ranges = []; + for (var i = 0; i < opn.units.length; i++) + ranges.push({ id: i, name: opn.units[i] }); + ciycmp({ + dom: $5('ciy-select', opn.dom), range: ranges, onchange: function (e) { + opn.betidx = toint(e.value); + thos.value = tofloat(showinpdom.val()) * opn.bets[opn.betidx]; + thos.setvalue(undefined, 'unit'); + } + }); + } + var valuedom = opn.dom.children(0); + var showinpdom = opn.dom.children(1); + var showinpunitdom = null; + if (opn.hasmore) + showinpunitdom = opn.dom.children(2); + this.setvalue = function (newvalue, from) { + if (newvalue !== undefined) { + this.value = toint(newvalue); + for (var i = opn.bets.length - 1; i >= 0; i--) { + if (this.value / opn.bets[i] >= 0.1) { + if ((opn.bets[i] >= 1000 && this.value % parseInt(opn.bets[i] / 1000) == 0) || i < opn.betidx) { + opn.betidx = i; + break; + } + } + if (this.value != 0 && this.value % opn.bets[i] == 0) { + opn.betidx = i; + break; + } + } + $5('ciy-select', opn.dom).val(opn.betidx); + if (newvalue !== '') + showinpdom.val(this.value * 1.0 / opn.bets[opn.betidx]); + else + showinpdom.val(''); + } + if (showinpunitdom) + showinpunitdom.val(opn.units[opn.betidx]); + valuedom.val(this.value); + if (from && typeof (this.onchange) == 'function') + this.onchange({ name: opn.name, dom: opn.dom, from: from, value: this.value }); + } + this.setvalue(opn.value, opn.initevent ? 'init' : ''); + showinpdom.on('keyup', function () { + thos.value = tofloat(showinpdom.val()) * opn.bets[opn.betidx]; + thos.setvalue(undefined, 'keyup'); + }); +} ciycmpfunc.ciyupload = function (opn) { // v2 var thos = this; this.onchange = opn.onchange; diff --git a/web/jscss/ciycmp2.js b/web/jscss/ciycmp2.js index 917f557..e0eeed6 100644 --- a/web/jscss/ciycmp2.js +++ b/web/jscss/ciycmp2.js @@ -120,49 +120,6 @@ ciycmpfunc.ciyselcas = function (opn) { return 1; } } -ciycmpfunc.ciyinputbet = function (opn) { - var thos = this; - this.onchange = opn.onchange; - opn.initevent = opn.initevent || opn.dom.hasattr('initevent'); - opn.hasmore = opn.hasmore || opn.dom.hasattr('hasmore'); - opn.inpstyle = opn.inpstyle || opn.dom.attr('inpstyle') || ''; - opn.bet = toint(opn.bet || opn.dom.attr('bet') || 1); - if (opn.bet < 1) - opn.bet = 1; - opn.unit = opn.unit || opn.dom.attr('unit') || ''; - opn.width = opn.width || opn.dom.attr('width') || '5em'; - opn.align = opn.align || opn.dom.attr('align') || 'right'; - var html = ''; - html += ''; - html += ''; - if (opn.hasmore) - html += ''; - if (opn.unit) - html += ' ' + opn.unit + ''; - opn.dom.html(html).css({ display: 'inline-flex', alignItems: 'center' }); - var valuedom = opn.dom.children(0); - var showinpdom = opn.dom.children(1); - this.setvalue = function (newvalue, from) { - if (newvalue !== undefined) { - this.value = tofloat(newvalue); - if (newvalue !== '') - showinpdom.val(this.value / opn.bet); - else - showinpdom.val(newvalue); - } - valuedom.val(this.value); - if (from && typeof (this.onchange) == 'function') - this.onchange({ name: opn.name, dom: opn.dom, from: from, value: this.value }); - } - this.setvalue(opn.value, opn.initevent ? 'init' : ''); - showinpdom.on('keyup', function () { - thos.value = tofloat(showinpdom.val()) * opn.bet; - thos.setvalue(undefined, 'keyup'); - }); -} ciycmpfunc.ciyselmulti = function (opn) { var thos = this; this.onchange = opn.onchange; diff --git a/web/jscss/ciytable.js b/web/jscss/ciytable.js index 69bed22..3731393 100644 --- a/web/jscss/ciytable.js +++ b/web/jscss/ciytable.js @@ -1248,7 +1248,35 @@ ciyfn.tdshow = function (dataori, ext, linedata, once, json, isview) { var cns = (ciyfn.tofix(num, toint(pstr)) + '').split('.'); var ret = cns[0].replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,'); if (cns.length > 1) - ret += '.' + cns[1] + ' '; + ret += '.' + cns[1] + ' '; + ret += ciyfn.lang(unit); + return ret; + } + function numbet(num, fixlen, bet, unit) { + var unitarr = unit.split('.'); + var betarr = bet.split('.'); + num = toint(num); + var betidx = 0; + for (var i = betarr.length - 1; i >= 0; i--) { + if (num / betarr[i] >= 0.1) { + if (betarr[i] >= 1000 && num % parseInt(betarr[i] / 1000) == 0) { + betidx = i; + break; + } + } + if (num != 0 && num % betarr[i] == 0) { + betidx = i; + break; + } + } + num = num / betarr[betidx]; + var cns = (ciyfn.tofix(num, toint(fixlen)) + '').split('.'); + var ret = cns[0].replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,'); + if (cns.length > 1) + ret += '.' + cns[1] + ' '; + var unit = unitarr[betidx]; + if (unit.substring(0, 1) == '*') + unit = unit.substring(1); ret += ciyfn.lang(unit); return ret; } @@ -1342,13 +1370,13 @@ ciyfn.tdshow = function (dataori, ext, linedata, once, json, isview) { var us = dataori.split('|');// 瓶 瓶|24|盒 瓶|24|盒|20|箱 datashow = ''; if (us.length == 5) { - datashow += '1' + us[4] + us[3] + us[2] + ''; + datashow += '1' + us[4] + '=' + us[3] + us[2] + ''; yuenum = nums / (parseInt(us[3]) * parseInt(us[1])); if (yuenum > 0.9) yuestr = "≈" + Math.round(yuenum) + us[4]; } if (us.length > 2) { - datashow += '1' + us[2] + us[1] + us[0] + ''; + datashow += '1' + us[2] + '=' + us[1] + us[0] + ''; if (yuestr == '') { yuenum = nums / parseInt(us[1]); if (yuenum > 0.9) @@ -1481,32 +1509,47 @@ ciyfn.tdshow = function (dataori, ext, linedata, once, json, isview) { } return '-'; } - if (preext == 'ENID') { - var pstr = ext.substring(5); - var id = parseInt(dataori); - var key = toint(pstr, 253); - var strid = id < 10 ? '0' + id : id.toString(); - if (id === 0) - return 0; - var len = 2; - if (id > 250600) - id %= 250600; - var n = id % 8566; - if (n < 100) - n += 100; - var xx = Math.abs(id * n + key); - if (xx % 13 > 8) - xx += key; - if (xx % 13 > 4) - xx += key + key + key; - if (len < 1) - len = 2; - var ret = Math.abs(xx % Math.pow(10, len)); - var fx = String(ret).padStart(len, '0'); - var ulen = strid.length; - return strid[0] + fx[0] + strid.substring(1, ulen - 1) + fx[1] + strid.charAt(ulen - 1); - } preext = ext.substring(0, 3); + if (preext == 'LNY') { + if (dataori == 0) + return '--'; + var pstrs = ext.substring(4).split(','); + pstrs[0] = pstrs[0] || '元.万元.亿元'; + pstrs[1] = pstrs[1] || '2'; + return numbet(dataori, pstrs[1], '100.1000000.10000000000', pstrs[0]); + } + if (preext == 'SNY') { + if (dataori == 0) + return '--'; + var pstrs = ext.substring(4).split(','); + pstrs[0] = pstrs[0] || '.K.M.B.T.Q'; + pstrs[1] = pstrs[1] || '2'; + return numbet(dataori, pstrs[1], '100.100000.100000000.100000000000.100000000000000', pstrs[0]); + } + if (preext == 'WGT') { + if (dataori == 0) + return '--'; + var pstrs = ext.substring(4).split(','); + pstrs[0] = pstrs[0] || '克.千克.吨'; + pstrs[1] = pstrs[1] || '2'; + return numbet(dataori, pstrs[1], '1.1000.1000000', pstrs[0]); + } + if (preext == 'LGH') { + if (dataori == 0) + return '--'; + var pstrs = ext.substring(4).split(','); + pstrs[0] = pstrs[0] || '厘米.米.公里'; + pstrs[1] = pstrs[1] || '2'; + return numbet(dataori, pstrs[1], '10.1000.1000000', pstrs[0]); + } + if (preext == 'BET') { + if (dataori == 0) + return '--'; + var pstrs = ext.substring(4).split(','); + pstrs[1] = pstrs[1] || '100'; + pstrs[2] = pstrs[2] || '2'; + return numbet(dataori, pstrs[2], pstrs[1], pstrs[0]); + } if (preext == 'CYC') { if (dataori == 0) return '--';