From 434d97d385f3facf468cb5db098566a5446a09fe Mon Sep 17 00:00:00 2001 From: boi Date: Thu, 26 Jun 2025 07:08:49 +0800 Subject: [PATCH] uplei --- web/admin/develop/code_common.php | 6 +++ web/admin/develop/code_create.html | 2 +- web/admin/develop/code_list.html | 21 +++++++-- web/admin/develop/code_pc_html.php | 8 +++- web/admin/develop/code_pc_php.php | 17 +++++-- web/admin/develop/note.php | 2 +- web/jscss/ciycmp2.js | 2 +- zciyphp/comm.php | 5 +- zciyphp/db.php | 4 +- zciyphp/pdo.php | 74 +++++++++++++++++------------- 10 files changed, 95 insertions(+), 46 deletions(-) diff --git a/web/admin/develop/code_common.php b/web/admin/develop/code_common.php index 53afcdc..bd3e75a 100644 --- a/web/admin/develop/code_common.php +++ b/web/admin/develop/code_common.php @@ -51,6 +51,12 @@ function calfld($post) { } return $flds; } +function flddata($data, $idx, $def) { + $strs = explode(',', $data); + if($idx < count($strs)) + return $strs[$idx]; + return $def; +} function json_createphp() { $post = new \ciy\post(); require_once 'code_pc_php.php'; diff --git a/web/admin/develop/code_create.html b/web/admin/develop/code_create.html index 04fe741..a8638ef 100644 --- a/web/admin/develop/code_create.html +++ b/web/admin/develop/code_create.html @@ -474,7 +474,7 @@ if (data.COLUMN_NAME == 'uptimes' || data.COLUMN_NAME == 'addtimes') { spset.noup = 'now'; } - if (data.COLUMN_NAME == 'inputuser') { + if (data.COLUMN_NAME == 'inputuser' || data.COLUMN_NAME == 'vuser') { spset.noup = 'me'; } if (colcomment.cate == 'MSK') diff --git a/web/admin/develop/code_list.html b/web/admin/develop/code_list.html index efb4ed9..8fd630b 100644 --- a/web/admin/develop/code_list.html +++ b/web/admin/develop/code_list.html @@ -110,16 +110,29 @@ return json; } , fn_tdcontent: function (key, datashow, field, data) { - // if (key == 'TABLE_COMMENT') {//内部编辑,立即更新 - // return '' + datashow + ''; - // } + if (key == 'TABLE_COMMENT') {//内部编辑,立即更新 + return ''; + } if (key == '_btn') { - return '生成更名'; + var html = ''; + html += '生成'; + //html += '更名'; + return html; } } }); table.callpage(1); } + function upcomment(dom, id) { + var val = $5(dom).val(); + if (val == table.data[id].TABLE_COMMENT) + return; + ciyfn.callfunc('update', { id: id, tabname: table.data[id].TABLE_NAME, name: val }, function (json) { + table.data[id].TABLE_COMMENT = val; + $5(dom).css({ border: '1px solid var(--succ5)' }); + setTimeout(function () { $5(dom).css({ border: '' }); }, 1000); + }); + } function menubtn(dom, btn) { var id = $5(dom).parent('tr').attr('data-id'); if (btn == 'create') { diff --git a/web/admin/develop/code_pc_html.php b/web/admin/develop/code_pc_html.php index 42afb1b..5fd0480 100644 --- a/web/admin/develop/code_pc_html.php +++ b/web/admin/develop/code_pc_html.php @@ -56,7 +56,7 @@ function code_pc_html($post) { $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 == 'PCT' || $cate == 'CNY' || $cate == 'KG' || $cate == 'TC' + || $cate == 'FSIZE' || $cate == 'METRE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'BET' || $cate == 'PCT' || $cate == 'CNY' || $cate == 'KG' || $cate == 'TC' ) $ciycmp2 = true; list($dicttype, $dictname) = splitdict($fld['data']); @@ -367,6 +367,10 @@ if($hasedit){ $codex .= "\n{$pspec} {$strstart} {$strend}"; } else if ($cate == 'TON') { $codex .= "\n{$pspec} "; + } else if ($cate == 'BET') { + $unit = flddata($fld['data'], 0, ''); + $bet = flddata($fld['data'], 1, 100); + $codex .= "\n{$pspec} "; } else if ($cate == 'PCT') { $codex .= "\n{$pspec} "; } else if ($cate == 'CNY') { @@ -618,7 +622,7 @@ 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 == 'PCT' || $cate == 'CNY' || $cate == 'KG' || $cate == 'TC' || $cate == 'BR' || $cate == 'BET' ) { $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 7e39fde..b9b3a64 100644 --- a/web/admin/develop/code_pc_php.php +++ b/web/admin/develop/code_pc_php.php @@ -146,7 +146,7 @@ function code_pc_php($post) { $codex .= "\n \$csql->where('{$col}&' . \$val . '=' . \$val);"; $codex .= "\n }"; } else if ( - $cate == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' + $cate == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'BET' || $cate == 'PCT' || $cate == 'CNY' || $cate == 'NUM' || $cate == 'KG' || $cate == 'TC' || $cate == 'INT' ) { $bet = 1000; @@ -158,6 +158,9 @@ function code_pc_php($post) { $bet = 1; else if ($cate == 'PCT' || $cate == 'CNY') $bet = 100; + else if ($cate == 'BET'){ + $bet = flddata($fld['data'], 1, 100); + } $codex .= "\n \$csql->wherenumrange('{$col}', objstr(\$query, '{$col}_1'), objstr(\$query, '{$col}_2'), {$bet});"; } else if ($cate == 'DATE') { $datequery = isset($fld['set']['datequery']) ? $fld['set']['datequery'] : ''; @@ -264,7 +267,7 @@ 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 == 'METRE' || $cate == 'FSIZE' || $cate == 'WCNY' || $cate == 'SEC' || $cate == 'TON' || $cate == 'BET' || $cate == 'PCT' || $cate == 'CNY' || $cate == 'NUM' || $cate == 'KG' || $cate == 'TC' || $cate == 'INT' ) { $codex .= "\n \$input[] = array('type' => 'num', 'form' => '{$col}', 'name' => '{$fld['name']}', 'prop' => ' style=\"width:4em;\"');"; @@ -808,6 +811,11 @@ function code_pc_php($post) { } else if ($cate == 'SEC') { $codex .= "\n if (\$field == '{$col}')"; $codex .= "\n \$val .= '秒';"; + } else if ($cate == 'BET') { + $unit = flddata($fld['data'], 0, ''); + $bet = flddata($fld['data'], 1, 100); + $codex .= "\n if (\$field == '{$col}')"; + $codex .= "\n \$val = number_format(\$val / {$bet}, 3) . '{$unit}';"; } else if ($cate == 'TON') { $codex .= "\n if (\$field == '{$col}')"; $codex .= "\n \$val = number_format(\$val / 1000000, 3) . '吨';"; @@ -840,7 +848,7 @@ function code_pc_php($post) { $codex .= "\n \$param['landscape'] = true; //横向打印"; $codex .= "\n \$param['fixtopage'] = true; //打印整个工作表"; - $codex .= "\n \$param['toptitle'] = 'Demo数据报表';"; + $codex .= "\n \$param['toptitle'] = '{$titname}数据报表';"; $codex .= "\n \$str = \\ciy\\excel::general_excel_xml(\$param);"; $codex .= "\n \$filename = '';"; $codex .= "\n if (empty(\$filename))"; @@ -1100,6 +1108,9 @@ function code_pc_php($post) { $bet = 1000000; } else if ($cate == 'SEC') { $unit = '秒'; + } else if ($cate == 'BET') { + $unit = flddata($fld['data'], 0, ''); + $bet = flddata($fld['data'], 1, 100); } else if ($cate == 'TON') { $unit = '吨'; $bet = 1000000; diff --git a/web/admin/develop/note.php b/web/admin/develop/note.php index fcf47df..62fe3a1 100644 --- a/web/admin/develop/note.php +++ b/web/admin/develop/note.php @@ -38,7 +38,7 @@ class note { $typeid = getint('typeid'); $post = new \ciy\post(); $id = $post->getint('id'); - $content = $post->get('content', '', 'html'); + $content = $post->get('content'); if (empty($content)) return errjson('请填写内容'); if ($id > 0) { diff --git a/web/jscss/ciycmp2.js b/web/jscss/ciycmp2.js index 1982d63..917f557 100644 --- a/web/jscss/ciycmp2.js +++ b/web/jscss/ciycmp2.js @@ -141,7 +141,7 @@ ciycmpfunc.ciyinputbet = function (opn) { if (opn.hasmore) html += ''; if (opn.unit) - html += ' ' + 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); diff --git a/zciyphp/comm.php b/zciyphp/comm.php index 34717b2..fa7459c 100644 --- a/zciyphp/comm.php +++ b/zciyphp/comm.php @@ -59,7 +59,10 @@ */ if (isset($_SERVER['HTTP_CIY_TIMEOUT'])) set_time_limit((int)$_SERVER['HTTP_CIY_TIMEOUT'] + 10); -error_reporting(E_ALL); //0禁用错误输出;E_ALL打开错误输出 +if (substr(__DIR__, 0, 1) == '/') + error_reporting(0); //0禁用错误输出;E_ALL打开错误输出 +else + error_reporting(E_ALL); //0禁用错误输出;E_ALL打开错误输出 date_default_timezone_set('Asia/Shanghai'); if (!isset($path)) diff --git a/zciyphp/db.php b/zciyphp/db.php index dd4832c..b28821b 100644 --- a/zciyphp/db.php +++ b/zciyphp/db.php @@ -59,8 +59,8 @@ class db { //单数据库版 $cfg = webini('db' . $this->dbpst); if (is_string($cfg)) die($cfg); - $this->linkdb = new pdo(); - $this->linkdb->connect($cfg); + $this->linkdb = new pdo($cfg); + $this->linkdb->connect(); return $this->linkdb; } /** diff --git a/zciyphp/pdo.php b/zciyphp/pdo.php index 7e726c3..813fb97 100644 --- a/zciyphp/pdo.php +++ b/zciyphp/pdo.php @@ -8,35 +8,37 @@ class pdo { public $error; public $lastsql; public $lastdata; - function __construct() { + private $conn; + function __construct($conn) { $this->isconnected = false; $this->error = ''; + $this->conn = $conn; } - function connect($conn) { + function connect() { if ($this->isconnected) return true; - if (!isset($this->link)) { - try { - $timeout = 10; - if (isset($conn['timeout'])) - $timeout = (int)$conn['timeout']; - $charset = 'utf8'; - if (isset($conn['charset'])) - $charset = $conn['charset']; - $persistent = false; - if (isset($conn['persistent'])) - $persistent = (bool)$conn['persistent']; - $opts = array( - \PDO::ATTR_TIMEOUT => $timeout, - \PDO::ATTR_PERSISTENT => $persistent, - \PDO::ATTR_ERRMODE => \PDO::ERRMODE_SILENT, - \PDO::MYSQL_ATTR_INIT_COMMAND => "SET CHARACTER SET {$charset}" - ); - $this->link = new \PDO('mysql:host=' . $conn['host'] . ';dbname=' . $conn['name'] . ';port=' . $conn['port'] . ';', $conn['user'], $conn['pass'], $opts); - $this->link->query('SET SESSION sql_mode = \'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\''); - } catch (\PDOException $e) { - return $this->errsql(false, 'PDO连接失败:' . $e->GetMessage()); - } + if (isset($this->link)) + $this->link = null; + try { + $timeout = 10; + if (isset($this->conn['timeout'])) + $timeout = (int)$this->conn['timeout']; + $charset = 'utf8mb4'; + if (isset($this->conn['charset'])) + $charset = $this->conn['charset']; + $persistent = false; + if (isset($this->conn['persistent'])) + $persistent = (bool)$this->conn['persistent']; + $opts = array( + \PDO::ATTR_TIMEOUT => $timeout, + \PDO::ATTR_PERSISTENT => $persistent, + \PDO::ATTR_ERRMODE => \PDO::ERRMODE_SILENT, + \PDO::MYSQL_ATTR_INIT_COMMAND => "SET CHARACTER SET {$charset}" + ); + $this->link = new \PDO('mysql:host=' . $this->conn['host'] . ';dbname=' . $this->conn['name'] . ';port=' . $this->conn['port'] . ';', $this->conn['user'], $this->conn['pass'], $opts); + $this->link->query('SET SESSION sql_mode = \'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\''); + } catch (\PDOException $e) { + return $this->errsql(false, 'PDO连接失败:' . $e->GetMessage()); } $this->isconnected = true; return true; @@ -205,13 +207,23 @@ class pdo { function _prepare($query, $data) { $this->lastsql = $query; $this->lastdata = $data; - $rs = $this->link->prepare($query); - if ($rs === false) - return $this->errsql(false, "SQL预处理出错[{$query}]:" . $this->pdoerr($this->link)); - if ($rs->execute($data) === false) { - $arr = $rs->errorInfo(); - return $this->errsql(false, 'SQL出错:' . $arr[2] . '[' . $arr[0] . '][' . $arr[1] . ']' . $query); + for ($i = 0; $i < 3; $i++) { + $rs = $this->link->prepare($query); + if ($rs === false) + return $this->errsql(false, "SQL预处理出错[{$query}]:" . $this->pdoerr($this->link)); + if ($rs->execute($data) === false) { + $arr = $rs->errorInfo(); + // 如果是连接断开错误,尝试重新连接 + if ($arr[0] == 'HY000' && $arr[1] == 2006) { + sleep(1); + $this->isconnected = false; + if($this->connect()) + continue; + } + return $this->errsql(false, 'SQL出错:' . $arr[2] . '[' . $arr[0] . '][' . $arr[1] . ']' . $query); + } + return $rs; } - return $rs; + return $this->errsql(false, 'SQL重试3次超时:' . $arr[2] . '[' . $arr[0] . '][' . $arr[1] . ']' . $query); } }