Browse Source

编辑是否是销售团队

sunhao 5 years ago
parent
commit
2554e1917d

+ 9 - 2
app/Http/Controllers/Admin/AdminController.php

@@ -47,6 +47,10 @@ class AdminController extends Controller
47 47
         $team = DB::table('teams')->get();
48 48
         $team = json_decode(json_encode($team),true);
49 49
 
50
+        foreach($team as $k=>&$v){
51
+            $v['type'] = $v['type'] == 1 ? '销售团队' : '其他';
52
+        }
53
+
50 54
         return view('admin/teamindex', ['team' => $team]);
51 55
     }
52 56
 
@@ -216,6 +220,7 @@ class AdminController extends Controller
216 220
         ]);
217 221
         $data = array();
218 222
         $data['name'] = $request->input('name');
223
+        $data['type'] = (int)$request->input('type');
219 224
         $res = DB::table('teams')->insert($data);
220 225
        
221 226
         return redirect('/admin/admin/teamindex')->with('info', '添加成功');
@@ -238,16 +243,18 @@ class AdminController extends Controller
238 243
      */
239 244
     public function teamupdate(Request $request)
240 245
     {
246
+        $id = (int)$request->input('id');
241 247
         $this->validate($request, [
242
-            'name' => 'required|unique:teams',
248
+            'name' => 'required|unique:teams,name,'.$id.',id',
243 249
             'id' => 'required'
244 250
         ], [
245 251
             'name.required' => '团队名称不能为空',
246 252
             'name.unique' => '团队名称已存在',
247 253
         ]);
248
-        $id = (int)$request->input('id');
254
+        
249 255
         $data = array();
250 256
         $data['name'] = $request->input('name');
257
+        $data['type'] = (int)$request->input('type');
251 258
         $res = DB::table('teams')->where('id', $id)->update($data);
252 259
 
253 260
         return redirect('/admin/admin/teamindex')->with('info', '修改成功');

+ 12 - 0
resources/views/admin/teamcreate.blade.php

@@ -20,6 +20,18 @@
20 20
             </div>
21 21
 
22 22
             <div class="row cl">
23
+                <label class="form-label col-xs-4 col-sm-2">
24
+                    <font color='red'>* </font>团队类型:</label>
25
+                <div class="formControls col-xs-6 col-sm-6">
26
+                    <input type="radio" name="type"  value="1" @if(old('type')==='1') checked @else checked @endif>
27
+                    <label for="status-1" style="margin-right: 27px;">销售团队</label>
28
+                    <input type="radio" name="type" value="0" @if(old('type')==='0') checked @endif>
29
+                    <label for="status-0" style="margin-right: 27px;">其他</label>
30
+        
31
+                </div>
32
+            </div>
33
+
34
+            <div class="row cl">
23 35
                 <div class="col-9 col-offset-2">
24 36
                     <button class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>&nbsp;
25 37
                     <button class="btn btn-default" type="reset" onclick="return_index();">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>&nbsp;

+ 12 - 0
resources/views/admin/teamedit.blade.php

@@ -20,6 +20,18 @@
20 20
                 </div>
21 21
             </div>
22 22
             
23
+             <div class="row cl">
24
+                <label class="form-label col-xs-4 col-sm-2">
25
+                    <font color='red'>* </font>团队类型:</label>
26
+                <div class="formControls col-xs-6 col-sm-6">
27
+                    <input type="radio" name="type"  value="1" @if($team['type']=='1') checked @endif>
28
+                    <label for="status-1" style="margin-right: 27px;">销售团队</label>
29
+                    <input type="radio" name="type" value="0" @if($team['type']=='') checked @endif>
30
+                    <label for="status-0" style="margin-right: 27px;">其他</label>
31
+        
32
+                </div>
33
+            </div>
34
+
23 35
             <div class="row cl">
24 36
                 <div class="col-9 col-offset-2">
25 37
                     <button class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">&nbsp;&nbsp;修改&nbsp;&nbsp;</button>&nbsp;

+ 2 - 0
resources/views/admin/teamindex.blade.php

@@ -15,6 +15,7 @@
15 15
                     {{--<th width="25"><input type="checkbox" name="" value=""></th>--}}
16 16
                     <th width="25%">团队Id</th>
17 17
                     <th width="25%">团队名称</th>
18
+                    <th width="25%">团队类型</th>
18 19
                     <th width="25%">创建时间</th>
19 20
                     <th width="25%">操作</th>
20 21
                 </tr>
@@ -26,6 +27,7 @@
26 27
                         {{--<td><input name="" type="checkbox" value=""></td>--}}
27 28
                         <td class="text-c">{{$a['id']}}</td>
28 29
                         <td class="text-c">{{$a['name']}}</td>
30
+                        <td class="text-c">{{$a['type']}}</td>
29 31
                         <td class="text-c">{{$a['create_time']}}</td>
30 32
                         <td class="f-14 product-brand-manage"><a style="text-decoration:none" onClick='admin_edit("编辑团队","{{$a['id']}}")' href="javascript:;" title="编辑团队"><span class="btn btn-primary radius">编辑</span></a> <!--a style="text-decoration:none" class="ml-5" onClick="admin_del(this, '{{$a['id']}}')" href="javascript:;" title="删除"><span class="btn btn-danger radius">删除</span></a--></td>
31 33
                     </tr>