Kaynağa Gözat

新增后台数据更新检查

wangjunchong 1 hafta önce
ebeveyn
işleme
90be5d3f2f

+ 15 - 0
app/admin/controller/promotion/PromotionTypes.php

@@ -222,4 +222,19 @@ class PromotionTypes extends Base
 	{
 		return res(2,"方法{$name}不存在");
 	}
+
+    /**
+     * @title    : 更新大屏数据
+     * @desc     : 描述
+     * @param    :
+     * @return   : \think\response\Json
+     * @auther   : Wjc
+     * @Date     : 2025/3/3 11:18
+     */
+    public function updateScreenData()
+    {
+        $timeStr = time();
+        cache('screen_data',$timeStr);
+        return res(1,'更新成功');
+    }
 }

+ 26 - 3
app/promotion/controller/promotion/PromotionApi.php

@@ -24,12 +24,35 @@ class PromotionApi extends Base
     public function GetHomeList()
     {
         $model = new PromotionTypes();
-        $data = $model->where('status','<>',2)->with('list')->select();
+        $data = $model->where('status','<>',2)->with(['list'=>function($query){
+            $query->where('status','<>',2);
+        }])->select();
         foreach ($data as $k=>$v){
             // list小于等于1时,model_type为detail
             $v['list']->count()>1?$data[$k]['model_type'] = 'model_list':$data[$k]['model_type']='model_detail';
-            $data[$k]['type_img'] = str_replace("\\","/",$v['type_img']);
+//            $data[$k]['type_img'] = str_replace("\\","/",$v['type_img']);
         }
-        return res(1, '获取成功', ['data'=>$data]);
+        $config['title'] = sysconfig('base.screenTitle');
+        $config['subtitle'] = sysconfig('base.screenSubTitle');
+        return res(1, '获取成功', ['data'=>$data,'config'=>$config]);
+    }
+
+    /**
+     * @title    : 检查后台是否更新数据
+     * @desc     : 描述
+     * @param    :
+     * @return   : \think\response\Json
+     * @auther   : Wjc
+     * @Date     : 2025/3/3 11:38
+     */
+    public function checkDataUpdate()
+    {
+        $timeStr = time();
+        if(cache('screen_data')){
+            $timeStr = cache('screen_data');
+        }else{
+            cache('screen_data',$timeStr);
+        }
+        return res(1,'获取成功',['timeStr'=>$timeStr]);
     }
 }

+ 0 - 2
config/database.php

@@ -57,7 +57,5 @@ return [
             // 开启字段缓存
             'fields_cache'    => false,
         ],
-
-        // 更多的数据库配置信息
     ],
 ];

+ 7 - 0
public/vue/src/api/promotion/PromotionTypes.js

@@ -55,3 +55,10 @@ export function changeStatus(data) {
     data,
   })
 }
+export function updateScreen(data) {
+  return request({
+    url: '/promotion.PromotionTypes/updateScreenData',
+    method: 'post',
+    data,
+  })
+}

+ 0 - 0
public/vue/src/views/ArrangeConfig/JdfArrangeConfig/components/periodEdit.vue


+ 17 - 0
public/vue/src/views/promotion/PromotionTypes/index.vue

@@ -71,6 +71,15 @@
         >
           添加
         </el-button>
+        <el-button
+          v-permissions="['PROMOTIONTYPES:UPDATESCREEN']"
+          icon="el-icon-plus"
+          size="mini"
+          type="primary"
+          @click="handleUpdateScreen"
+        >
+          更新大屏数据
+        </el-button>
       </div>
       <el-table
         v-loading="listLoading"
@@ -151,6 +160,7 @@
     changeStatus,
     getOptions,
     doExport,
+    updateScreen,
   } from '@/api/promotion/PromotionTypes'
   import Edit from './components/Edit.vue'
 
@@ -197,6 +207,13 @@
           this.$refs['edit'].show()
         }
       },
+      handleUpdateScreen() {
+        this.$baseConfirm('确定要更新大屏数据吗?', null, async () => {
+          const { msg } = await updateScreen()
+          this.$baseMessage(msg, 'success')
+          this.fetchData()
+        })
+      },
       handleDelete(row) {
         if (row.id) {
           this.$baseConfirm('你确定要删除当前项吗', null, async () => {