Kirin 1 year ago
parent
commit
f0a8d6626b
2 changed files with 34 additions and 0 deletions
  1. 15 0
      app/admin/controller/user/UserCert.php
  2. 19 0
      app/admin/view/user/user_cert/index.php

+ 15 - 0
app/admin/controller/user/UserCert.php

@@ -91,4 +91,19 @@ class UserCert extends AuthController
             return JsonService::fail(Cert::getErrorInfo('操作失败或没有修改什么'));
         }
     }
+
+    /**
+     * 删除
+     * @param $id
+     * @throws \Exception
+     */
+    public function delete($id)
+    {
+        if (!$id) return $this->failed('数据不存在');
+        if (!Cert::be(['id' => $id])) return $this->failed('数据不存在');
+        if (!Cert::where('id', $id)->delete())
+            return JsonService::fail(Cert::getErrorInfo('删除失败,请稍候再试!'));
+        else
+            return JsonService::successful('删除成功!');
+    }
 }

+ 19 - 0
app/admin/view/user/user_cert/index.php

@@ -32,6 +32,9 @@
                             编辑证书
                         </button>
                         {{# } }}
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" lay-event='edit'>
+                            编辑证书
+                        </button>
                     </script>
                 </div>
             </div>
@@ -73,6 +76,22 @@
                     w: 1000
                 });
                 break;
+            case 'del':
+                var url = layList.U({c: 'user.user_cert', a: 'delete', q: {id: data.id}});
+                var code = {title: "操作提示", text: "确定删除该数据?", type: 'info', confirm: '是的,删除'};
+                $eb.$swal('delete', function () {
+                    $eb.axios.get(url).then(function (res) {
+                        if (res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success', res.data.msg);
+                            obj.del();
+                            location.reload();
+                        } else
+                            return Promise.reject(res.data.msg || '删除失败')
+                    }).catch(function (err) {
+                        $eb.$swal('error', err);
+                    });
+                }, code)
+                break;
         }
         s
     })