瀏覽代碼

积分申报++

sugangqiang 2 年之前
父節點
當前提交
fafcc7d51b

+ 5 - 2
app/common.php

@@ -461,8 +461,11 @@ function curlPost($url, $postFields) {
     return $result;
 }
 
-function getCacheById($key, $field) {
+function getCacheById($key, $field, $fieldKey = null) {
     $redis = \app\common\Redis::instance(think\facade\Config::get("cache.stores.redis.select"));
     $info = $redis->hGet($key, $field);
-    return json_decode($info, true);
+    $result = json_decode($info, true);
+    if ($fieldKey)
+        return $result[$fieldKey];
+    return $result;
 }

+ 5 - 1
app/common/api/IntegralRecordApi.php

@@ -16,7 +16,11 @@ use app\common\state\IntegralState;
 class IntegralRecordApi {
 
     public static function getOne($id) {
-        return IntegralRecord::where("id", "=", $id)->find();
+        $result = IntegralRecord::where("id", "=", $id)->find();
+        if ($result) {
+            $result["items"] = $result->detail;
+        }
+        return $result;
     }
 
     public static function getList($params) {

+ 8 - 2
app/common/controller/Api.php

@@ -647,8 +647,14 @@ class Api extends BaseController {
     }
 
     function getIntegralProjectsByType() {
-        $type = $this->request->param("type") ?: 0;
-        $where[] = ["type", "=", $type];
+        $projectType = $this->request->param("projectType") ?: 0;
+        if (session("user")["usertype"] == 2) {
+            $where[] = ["type", "=", 2];
+        } else {
+            $type = $this->request->param("type") ?: 0;
+            $where[] = ["type", "=", $type];
+        }
+        $where[] = ["projectType", "=", $projectType];
         $where[] = ["active", "=", 1];
         $list = \app\common\api\IntegralProjectApi::getAll($where);
         return json($list);

+ 0 - 1
app/enterprise/controller/Integral.php

@@ -36,7 +36,6 @@ class Integral extends EnterpriseController {
         $param = $request->param();
         $id = isset($param["id"]) ? $param["id"] : 0;
         $info = IntegralRecordApi::getOne($id);
-        $info["detail"] = $info->detail;
         $ep = EnterpriseApi::getOne($this->user["uid"]);
         if ($info) {
             $info["real_state"] = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL)["state"];

+ 3 - 3
app/enterprise/view/integral/apply.html

@@ -150,7 +150,7 @@
                                     <div class="panel-heading" onclick="$(this).next().toggle()">申报项目</div>
                                     <div class="panel-body" id="itemList">
                                         {if condition="$row['detail']"}                                        
-                                        {volist name="row.detail" id="item"}                                 
+                                        {volist name="row.items" id="item"}                                 
                                         <table style="width:100%;border-collapse: collapse;" class="table table-bordered">
                                             <tr>
                                                 <td style="width:40px;">
@@ -162,7 +162,7 @@
                                                 <td>
                                                     <div class="rowGroup">
                                                         <label class=" control-label spacing td-label"><span style="color: red">*</span>项目类别</label>
-                                                        <select class="form-control" name="projectType[]" value="{$item.projectType}" onchange="IntegralInfoDlg.onProjectTypeChange(this);">
+                                                        <select class="form-control" name="projectType[]" value="{$item.item_id|getCacheById='IntegralItem',###,'projectId'|getCacheById='IntegralProject',###,'projectType'}" onchange="IntegralInfoDlg.onProjectTypeChange(this);">
                                                             <option value="">请选择</option>
                                                             <option value="1">基础分</option>
                                                             <option value="2">贡献分</option>
@@ -173,7 +173,7 @@
                                                 <td>
                                                     <div class="rowGroup">
                                                         <label class=" control-label spacing td-label"><span style="color: red">*</span>积分项目</label>
-                                                        <select class="form-control" name="projectId[]" value="{$item.projectId}" onchange="IntegralInfoDlg.onProjectChange(this);">
+                                                        <select class="form-control" name="projectId[]" value="{$item.item_id|getCacheById='IntegralItem',###,'projectId'}" onchange="IntegralInfoDlg.onProjectChange(this);">
                                                             <option value="">请选择</option>
                                                         </select>
                                                     </div>

+ 2 - 2
public/static/modular/gate/integral/integralInfo.js

@@ -257,14 +257,14 @@ IntegralInfoDlg.deleteItem = function () {
     }
 }
 IntegralInfoDlg.onProjectTypeChange = function (obj) {
-    var type = $(obj).val();
+    var projectType = $(obj).val();
     var projectObj = $(obj).parents("table").find("select[name='projectId[]']")
     Feng.addAjaxSelect({
         "obj": projectObj,
         "displayCode": "id",
         "displayName": "name",
         "type": "GET",
-        "url": "/common/api/getIntegralProjectsByType/type/" + type
+        "url": "/common/api/getIntegralProjectsByType/projectType/" + projectType
     });
 }
 IntegralInfoDlg.onProjectChange = function (obj) {