diff --git a/app/admin/controller/merchant/system/merchant/MerchantType.php b/app/admin/controller/merchant/system/merchant/MerchantType.php index 29ac1ce..1a3dff9 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantType.php +++ b/app/admin/controller/merchant/system/merchant/MerchantType.php @@ -1,18 +1,21 @@ mer_type = $mer_type; + $this->merchant = $merchant; + $this->path = [ + 'index' => 'merchant/system/merchant/type/index', + 'read' => 'merchant/system/merchant/type/read', + 'add' => 'merchant/system/merchant/type/add' + ]; } - /** + /** * 空白菜单页,由前端 ajax 获取数据 */ - function Index() + public function Index() { - return View('merchant/system/merchant/type/index'); + return View($this->path['index']); } /** * 添加/编辑 表单页 */ - public function Form() + public function Form(MenuModel $menu, FormatList $format) { - if ($param['mer_id']>0) { - $product_id = isset($param['product_id']) ? $param['product_id'] : 0; - $detail = $this->model->getStoreProductById($product_id); - if (!empty($detail)) { - $detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content'); - $detail['slider_image_arr'] = explode(',',$detail['slider_image']); - // halt($detail['slider_image_arr']); - View::assign('detail', $detail); - $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) - ->select(); - View::assign('store_brand', $store_brand); - - } - else{ - throw new \think\exception\HttpException(404, '找不到页面'); - } + $param = get_params(); + $id = isset($param['id']) ? (int)$param['id'] : 0; + + if (!empty($id)) { + // 进入编辑页,显示店铺数据 + $detail = $this->merchant->Find($id); } - return view(); + if (empty($detail)) { + $detail = [ + "create_time" => '', + "description" => '', + "id" => '', + "margin" => 0, + "is_margin" => 0, + "type_info" => '', + "description" => '', + "type_name" => '', + "update_time" => '' + ]; + } + + // 查出商户所有菜单数据 + $data = $menu->Search([], 1); + View::assign('dataTree', $format->FormatCategory($data['list'])); + View::assign('detail', $detail); + + return view($this->path['add']); } /** - * 显示店铺类型列表 + * 输出店铺类型列表数据 * * @return \think\Response */ public function Lst() { - echo 1723; $param = get_params(); - $where = []; - if (isset($param['keywords']) && !empty($param['keywords'])){ - $where[]=['store_name','like','%'.$param['keywords'].'%']; - } - $list = $this->model->getStoreProductList($where,$param); + $page = empty($param['page']) ? 1 : (int)$param['page']; + $limit = empty($param['limit']) ? 10 : (int)$param['limit']; - return table_assign(0, '', $list); + $data = $this->merchant->GetList($page, $limit); + + return table_assign(0, '', $data); } /** + * TODO: 关联权限待完成 + * * 添加店铺类型. * * @return \think\Response */ public function Add() { - $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) - ->select(); - return to_assign(0,'操作成功'); + $params = get_params(); + + $batch['type_name'] = $params['type_name']; + $batch['description'] = $params['description']; + $batch['is_margin'] = $params['is_margin']; + $batch['margin'] = $params['margin']; + $batch['type_info'] = $params['type_info']; + $menu_ids = $params['auth']; + + // 更新权限 + // $this->menu->update($menu_ids); + + $rows = $this->merchant->Add($batch); + + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } /** - * 显示指定的店铺详情 + * 查看指定的店铺详情 * - * @param int $id * @return \think\Response */ - public function Detail($id) + public function Read() { $param = get_params(); - $product_id = isset($param['product_id']) ? $param['product_id'] : 0; - $detail = $this->model->getStoreProductById($product_id); - if (!empty($detail)) { - $detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content'); - $detail['slider_image_arr'] = explode(',',$detail['slider_image']); - View::assign('detail', $detail); - $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) - ->select(); - View::assign('store_brand', $store_brand); - return view(); - } - else{ - throw new \think\exception\HttpException(404, '找不到页面'); - } + $id = isset($param['id']) ? (int)$param['id'] : 0; + + $detail = $this->merchant->Find($id); + + if (!empty($detail)) { + View::assign('detail', $detail); + return view($this->path['read']); + } else { + throw new \think\exception\HttpException(404, '找不到页面'); + } } /** - * 显示编辑资源表单页. + * TODO: 关联权限待完成 + * 编辑指定菜单. * * @param int $id * @return \think\Response */ - public function edit($id) + public function Edit() { - return to_assign(0,''); + $params = get_params(); + + $batch['type_name'] = $params['type_name']; + $batch['description'] = $params['description']; + $batch['is_margin'] = $params['is_margin']; + $batch['margin'] = $params['margin']; + $batch['type_info'] = $params['type_info']; + $menu_ids = $params['auth']; + + // 更新权限 + // $this->menu->update($menu_ids); + + $rows = $this->merchant->Add($batch); + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } /** @@ -132,36 +173,39 @@ class MerchantType extends BaseController * @param int $id * @return \think\Response */ - public function del($id) + public function Del() { $param = get_params(); - $product_id = isset($param['product_id']) ? $param['product_id'] : 0; - $type = isset($param['type']) ? $param['type'] : 0; + if (empty($param['id'])) { + return 0; + } + $id = (int)$param['id']; - $this->model->delStoreProductById($product_id,1); + $rows = $this->merchant->Del($id); + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } + /** * 备注表单页 */ - public function MarkForm() - { - return View(''); - } /** * 店铺类型备注 */ public function Mark() { + $params = get_params(); return to_assign(0, ''); } /** * 店铺类型说明 */ - public function Description(){ - View::assign('detail',[]); - return View('merchant/system/merchant/descr/index',['id'=>1]); + public function Description() + { + View::assign('detail', []); + return View('merchant/system/merchant/descr/index', ['id' => 1]); } } diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index c65f134..1432f04 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -52,16 +52,19 @@ Route::group(function(){ Route::get('lst', '/lst')->name('systemMerchantTypeLst')->option([ '_alias' => '列表', ]); - Route::get('detail/:id', '/detail')->name('systemMerchantTypeDetail')->option([ + Route::get('read', '/read')->name('systemMerchantTypeDetail')->option([ '_alias' => '详情', ]); + Route::get('form', '/form')->name('systemMerchantTypeAdd')->option([ + '_alias' => '添加/编辑页', + ]); Route::post('add', '/add')->name('systemMerchantTypeAdd')->option([ '_alias' => '添加', ]); - Route::put('edit/:id', '/edit')->name('systemMerchantTypeUpdate')->option([ + Route::put('edit', '/edit')->name('systemMerchantTypeUpdate')->option([ '_alias' => '编辑', ]); - Route::delete('del/:id', '/del')->name('systemMerchantTypeDelete')->option([ + Route::delete('del', '/del')->name('systemMerchantTypeDelete')->option([ '_alias' => '删除', ]); Route::get('mark/:id', '/markForm')->name('systemMerchantTypeMarkForm')->option([ @@ -69,7 +72,7 @@ Route::group(function(){ '_auth' => false, '_form' => 'systemMerchantTypeMark', ]); - Route::post('mark/:id', '/mark')->name('systemMerchantTypeMark')->option([ + Route::post('mark', '/mark')->name('systemMerchantTypeMark')->option([ '_alias' => '备注', ]); diff --git a/app/admin/view/merchant/system/merchant/type/add.html b/app/admin/view/merchant/system/merchant/type/add.html index d5368fe..25d57e3 100644 --- a/app/admin/view/merchant/system/merchant/type/add.html +++ b/app/admin/view/merchant/system/merchant/type/add.html @@ -13,139 +13,64 @@ {block name="body"}
-

添加

+

添加店铺类型

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + + + + + + + + +
商品名称*
平台商品分类* -
- -
-
品牌选择* -
- -
-
商品封面图 -
- -
- - -
-
-
商品轮播图 -
- - -
- -
-
-
单位*
商品关键字*
售价*
成本价*
市场价*
库存*
商品简介店铺类型名称* - + +
店铺类型要求 +
商品详情店铺保证金 - + + + + + + + + + +
+
+ + +
+
+ + 单位:元
+
店铺权限* +
+
其它说明 + +
+
- +
@@ -155,95 +80,130 @@ {block name="script"} + {/block} - \ No newline at end of file + diff --git a/app/admin/view/merchant/system/merchant/type/index.html b/app/admin/view/merchant/system/merchant/type/index.html index a2bb254..c5a0624 100644 --- a/app/admin/view/merchant/system/merchant/type/index.html +++ b/app/admin/view/merchant/system/merchant/type/index.html @@ -3,23 +3,21 @@ {block name="body"}
-
-
- -
- -
{/block} @@ -34,107 +32,75 @@ elem: '#store_product', title: '商品表列表', toolbar: '#toolbarDemo', - url: '/admin/store_product/datalist', + url: '/admin/merchant/type/lst', page: true, limit: 20, cellMinWidth: 300, cols: [ [ { - fixed: 'left', - field: 'product_id', + fixed: 'ID', + field: 'id', title: '编号', align: 'center', width: 80 - },{ - field: 'image', - title: '商品图片', + }, + { + field: 'type_name', + title: '店铺类型名称', align: 'center', - width: 100, - templet: '
', + width: 200 },{ - field: 'store_name', - title: '商品名称', + field: 'margin', + title: '店铺保证金', align: 'center', width: 100 },{ - field: 'store_info', - title: '商品简介', + field: 'type_info', + title: '店铺类型要求', align: 'center', - width: 100 + width: 220 },{ - field: 'keyword', - title: '关键字', + field: 'create_time', + title: '创建时间', align: 'center', - width: 100 + width: 150 },{ - field: 'brand_id', - title: '品牌 id', + field: 'update_time', + title: '最近修改时问', align: 'center', - width: 100 - },{ - field: 'cate_id', - title: '分类', - align: 'center', - width: 100 - },{ - field: 'unit_name', - title: '单位名', - align: 'center', - width: 100 - },{ - field: 'sales', - title: '销量', - align: 'center', - width: 100 - },{ - field: 'price', - title: '最低价格', - align: 'center', - width: 100 - },{ - field: 'cost', - title: '成本价', - align: 'center', - width: 100 - },{ - field: 'ot_price', - title: '原价', - align: 'center', - width: 100 - },{ - field: 'stock', - title: '总库存', - align: 'center', - width: 100 - }, { + width: 150 + }, + { fixed: 'right', field: 'right', title: '操作', toolbar: '#barDemo', - width: 136, + width: 190, align: 'center' - } + } ] ] + }); //监听表头工具栏事件 table.on('toolbar(store_product)', function(obj){ if (obj.event === 'add') { - tool.side("/admin/store_product/add"); + tool.side("/admin/merchant/type/form"); return false; } }); //监听表格行工具事件 table.on('tool(store_product)', function(obj) { + console.log(obj.data); var data = obj.data; if (obj.event === 'read') { - tool.side('/admin/store_product/read?product_id='+obj.data.product_id); + tool.side('/admin/merchant/type/read?id='+obj.data.id); } else if (obj.event === 'edit') { - tool.side('/admin/store_product/edit?product_id='+obj.data.product_id); + tool.side('/admin/merchant/type/form?id='+obj.data.id); } else if (obj.event === 'del') { layer.confirm('确定要删除该记录吗?', { @@ -147,7 +113,7 @@ obj.del(); } } - tool.delete("/admin/store_product/del", { product_id: data.product_id }, callback); + tool.delete("/admin/merchant/type/del", { id: data.id }, callback); layer.close(index); }); } @@ -155,17 +121,17 @@ }); //监听搜索提交 - form.on('submit(searchform)', function(data) { - layui.pageTable.reload({ - where: { - keywords: data.field.keywords - }, - page: { - curr: 1 - } - }); - return false; - }); + // form.on('submit(searchform)', function(data) { + // layui.pageTable.reload({ + // where: { + // keywords: data.field.keywords + // }, + // page: { + // curr: 1 + // } + // }); + // return false; + // }); } {/block} diff --git a/app/admin/view/merchant/system/merchant/type/read.html b/app/admin/view/merchant/system/merchant/type/read.html index c3637d7..16d33e0 100644 --- a/app/admin/view/merchant/system/merchant/type/read.html +++ b/app/admin/view/merchant/system/merchant/type/read.html @@ -10,135 +10,50 @@

文章详情

- + + autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_name}" readonly> - - - - - - - - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.margin}" readonly> - + + + + + + - + + + + + diff --git a/app/common/model/merchant/system/merchant/MerchantMargin.php b/app/common/model/merchant/system/merchant/MerchantMargin.php index 62e8eaa..3860102 100644 --- a/app/common/model/merchant/system/merchant/MerchantMargin.php +++ b/app/common/model/merchant/system/merchant/MerchantMargin.php @@ -15,11 +15,11 @@ class MerchantMargin extends Model protected $connection = 'shop'; protected $table = ''; - - function __construct() + function GetList() { - - } + $list = self::select(); + + return $list; + } +} - -} \ No newline at end of file diff --git a/app/common/model/merchant/system/merchant/MerchantType.php b/app/common/model/merchant/system/merchant/MerchantType.php index f6a4b64..d62f57d 100644 --- a/app/common/model/merchant/system/merchant/MerchantType.php +++ b/app/common/model/merchant/system/merchant/MerchantType.php @@ -1,9 +1,18 @@ order('mer_type_id DESC') + ->page($page) + ->limit($limit) + ->order('mer_type_id DESC')->paginate($rows, false,[ + 'query' => [], //url额外参数 + // 'total' => '', //最大数量 + // 'fragment' => '', //url锚点 + // 'var_page' => 'page', //分页变量 + ]); + + return $data; + } + + /** + * 查询指定店铺类型数据 + * + * @param int $page 过滤字段条件 + * @param int $limit 菜单类型: 0商城平台菜单 1商户菜单 + * + * @return array|object + */ + function Find(int $id) + { + if (empty($id)) { + throw new ValidateException('未传递参数'); + return []; + } + $row = self::where('mer_type_id', $id)->field('mer_type_id as id,type_name,margin,type_info,description,is_margin,create_time,update_time')->find(); + + return $row; + } + + /** + * 新增店铺类型数据 + * + * @param int $page 过滤字段条件 + * @param int $limit 菜单类型: 0商城平台菜单 1商户菜单 + * + * @return array|object + */ + function Add(array $set_data) { + if (empty($set_data['type_name'])) { + return 0; + } + $batch['type_name'] = $set_data['type_name']; + $batch['description'] = empty($set_data['description'])?"":$set_data['description']; + $batch['is_margin'] = empty($set_data['is_margin']); + if (!empty($set_data['is_margin'])) { + $batch['margin'] = empty($set_data['margin'])?0:$set_data['margin']; + } + $batch['type_info'] = empty($set_data['type_info'])?'':$set_data['type_info']; + $batch['create_time'] = date('Y-m-d H:i:s',time()); + $batch['update_time'] = date('Y-m-d H:i:s',time()); + + $rows = self::insert($batch); + + return $rows; + } + + /** + * 更新指定店铺类型数据 + * + * @param int $page 过滤字段条件 + * @param int $limit 菜单类型: 0商城平台菜单 1商户菜单 + * + * @return array|object + */ + function Edit(int $id, array $set_data) { + if (empty($id) || empty($set_data['type_name'])) { + throw new ValidateException('未传递参数'); + return 0; + } + + $batch['type_name'] = $set_data['type_name']; + $batch['description'] = empty($set_data['description'])?"":$set_data['description']; + $batch['is_margin'] = empty($set_data['is_margin']); + if (!empty($set_data['is_margin'])) { + $batch['margin'] = empty($set_data['margin'])?0:$set_data['margin']; + } + $batch['type_info'] = empty($set_data['type_info'])?'':$set_data['type_info']; + $batch['update_time'] = date('Y-m-d H:i:s',time()); + + $rows = self::update($batch)->where('mer_type_id', $id)->limit(1); + + return $rows; + } + + /** + * 删除指定店铺类型数据 + * + * @param int $page 过滤字段条件 + * @param int $limit 菜单类型: 0商城平台菜单 1商户菜单 + * + * @return array|object + */ + function Del(int $id) { + if (empty($id)) { + throw new ValidateException('未传递参数'); + return 0; + } + $rows = self::where('mer_type_id', $id)->delete(); + + return $rows; } - function List() - {} - function Find() - {} }
商品名称*店铺类型名称
商户商品分类* -
- -
+
店铺类型要求 +
品牌选择* -
- -
-
商品封面图 -
- - - -
- - -
-
-
商品轮播图 -
- - - -
- {volist name='detail.slider_image_arr' id='vo'} - {if $vo} - - {/if} - {/volist} - -
-
-
单位*
商品关键字*
售价*店铺保证金
成本价*
市场价*
库存*
商品简介店铺权限 + + +
其它说明
商品详情创建时间 - + {$detail.create_time} +
修改时间 + {$detail.update_time}