<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ## 工作表表頭驗證驗證器 > 說明: 設置工作表表頭驗證驗證器。在導入表單數據時,對預設驗證規則的工作表表頭字段數據進行驗證。在設定的驗證器中可以寫字段自定義的驗證方法,也可對工作表表頭字段數據進行進一步處理(handleData操作)。默認篩選表單字段驗證器為 `\yunj\Validate` 方法:`colsValidate($callable)` * 參數 **callable** (必須),例: ```php colsValidate(function(){ return TestValidate(); }); ``` * 返回值:需為 `\yunj\Validate`或其子類的實例對象 * 驗證環境scene: * `row`:數據導入驗證每行數據時的驗證環境 在`row`環境的驗證數據中存在固定參數 `$data["sheet"]` 當前驗證數據行所在工作表。 > 示例: 導入產品數據:`序列號(sn)`、`名稱(name)`、`商戶(mid)`... * 驗證器 ```php namespace app\demo\validate\product; final class Import extends \yunj\Validate { // 自定義驗證方法,校驗序列號唯一性 protected function snUnique($value,$rule = "",$data){ $isExist = Db::name("product")->where("sn","=",$value)->select(); if($isExist ) return "該序列號已存在"; return true; } protected function handleData(array $raw_data, $scene): array { $data = $raw_data; switch ($scene) { case "row": // 固定參數:工作表 $sheet = $data["sheet"]; // 校驗商戶有效性,并獲取商戶數據添加到驗證數據里 $merchant = Db::name("merchant")->where("id","=",$data["mid"])->select(); if(!$merchant ) throw_error_json("商戶數據錯誤"); $data["merchant_data"] = $merchant; break; } return $data; } } ``` * 導入構建器: ```php $builder=YI('general_example')->cols(function($sheet){ $cols=[ 'sn'=>['title'=>'序列號','verify'=>'require|snUnique'], 'name'=>['title'=>'名稱','verify'=>'require|checkSn','desc'=>'只能輸入漢字'], 'mid'=>['title'=>'商戶','verify'=>'require|positiveInteger'] ]; return $cols; })->colsValidate(function(){ return new \app\demo\validate\product\Import(); })->row(function($sheet,$row_data){ // 獲取展商數據 $merchant = $row_data["merchant_data"]; // 業務處理... }); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看