Browse Source

fix:验货类型

super-yimizi 1 month ago
parent
commit
8a9948d24e

+ 4 - 3
application/admin/controller/inspection/Type.php

@@ -61,11 +61,12 @@ class Type extends Backend
         }
         
         // 处理fieldlist格式的验货选项数据
-        $arrItems = $params['items'] ?? [];
-        if(empty($arrItems)){
+        $jsonItems = $params['items'] ?? [];
+        if(empty($jsonItems)){
             $this->error(__('Parameter %s can not be empty', 'items'));
         }
-        
+        // json 处理
+        $arrItems = json_decode($jsonItems, true); 
         $params = $this->preExcludeFields($params);
 
         if ($this->dataLimit && $this->dataLimitFieldAutoFill) {

+ 1 - 1
application/admin/lang/zh-cn/inspection/type.php

@@ -1,7 +1,7 @@
 <?php
 
 return [
-    'Id'         => '验货类型ID',
+    'Id'         => '序号',
     'Name'       => '验货类型',
     'Status'     => '状态',
     'Createtime' => '创建时间',

+ 1 - 1
application/admin/view/inspection/type/add.html

@@ -52,7 +52,7 @@
             
             <div class="radio">
             {foreach name="statusList" item="vo"}
-            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="30"}checked{/in} /> {$vo}</label> 
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label> 
             {/foreach}
             </div>
 

+ 14 - 1
public/assets/js/backend/inspection/type.js

@@ -27,7 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
                         {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
-                        {field: 'status', title: __('Status'), searchList: {"30":__('Status 30')}, formatter: Table.api.formatter.status},
+                        {field: 'status', title: __('Status'), searchList: Controller.api.parseConfigJson('statusList'), formatter: Table.api.formatter.status},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
@@ -125,6 +125,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             Controller.api.bindevent();
         },
         api: {
+            // 解析Config中的JSON字符串的辅助函数
+            parseConfigJson: function(configKey, defaultValue) {
+                var configValue = Config[configKey] || defaultValue || {};                
+                // 如果是字符串,尝试解析JSON
+                if (typeof configValue === 'string') {
+                    try {
+                        return JSON.parse(configValue);
+                    } catch (e) {
+                        return defaultValue || {};
+                    }
+                }                
+                return configValue;
+            },
             bindevent: function () {
               
                 Form.api.bindevent($("form[role=form]"));