店铺类型,说明

This commit is contained in:
liuxiaoquan 2023-03-04 17:50:17 +08:00
parent 5bdf8b9975
commit 5e4491d0b5
7 changed files with 481 additions and 474 deletions

View File

@ -1,18 +1,21 @@
<?php
/**
* 商户菜单管理
* 店铺类型管理
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
declare(strict_types=1);
namespace app\admin\controller\merchant\system\merchant;
use app\admin\BaseController;
use think\Request;
use app\common\model\merchant\system\merchant\MerchantType as MerchantTypeModel;
use app\common\model\merchant\system\auth\Menu as MenuModel;
use app\common\controller\FormatList;
use think\facade\View;
/**
@ -20,110 +23,148 @@ use think\facade\View;
*/
class MerchantType extends BaseController
{
protected $mer_type;
protected $merchant;
protected $path;
function __construct(MerchantTypeModel $mer_type)
public function __construct(MerchantTypeModel $merchant)
{
$this->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]);
}
}

View File

@ -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' => '备注',
]);

View File

@ -13,139 +13,64 @@
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">添加</h3>
<h3 class="pb-3">添加店铺类型</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">商品名称<font>*</font></td>
<td colspan="7"><input type="text" name="store_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input"></td>
</tr>
<!-- <tr>-->
<!-- <td class="layui-td-gray">平台商品分类<font>*</font></td>-->
<!-- <td colspan="3">-->
<!-- <div class="layui-col-md6">-->
<!-- <select name="cate_id" lay-verify="required" lay-search="">-->
<!-- <option value="" >请选择</option>-->
<!-- {volist name=':set_recursion(get_store_category())' id='vo'}-->
<!-- <option value="{$vo.id}" >{$vo.title}</option>-->
<!-- {/volist}-->
<!-- </select>-->
<!-- </div>-->
<!-- </td>-->
<!-- </tr>-->
<tr>
<td class="layui-td-gray">平台商品分类<font>*</font></td>
<td colspan="3">
<div class="layui-col-md6">
<select name="cate_id" lay-verify="required" lay-search="">
<option value="" >请选择</option>
{volist name=':set_recursion(get_store_category())' id='vo'}
<option value="{$vo.id}" >{$vo.title}</option>
{/volist}
</select>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">品牌选择<font>*</font></td>
<td colspan="3">
<div class="layui-col-md6">
<select name="brand_id" lay-verify="required" lay-search="">
<option value="" >请选择</option>
{volist name='store_brand' id='vo'}
<option value="{$vo.brand_id}" >{$vo.brand_name}</option>
{/volist}
</select>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">商品封面图</td>
<td>
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">
上传缩略图(尺寸:750x750)
</button>
<div class="layui-upload-list" id="upload_box_thumb"
style=" overflow: hidden;">
<img src=""
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
width="100" style="max-width: 100%; height:66px;"/>
<input type="hidden" name="image" value="">
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">商品轮播图</td>
<td>
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb2">
上传商品轮播图
</button>
<div class="layui-upload-list" id="upload_box_thumb2"
style="overflow: hidden;">
<input type="hidden" name="slider_image" value="">
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">单位<font>*</font></td>
<td colspan="7"><input type="text" name="unit_name" lay-verify="required" lay-reqText="请输入单位"
autocomplete="off" placeholder="请输入单位" class="layui-input"></td>
</tr>
<tr>
<td class="layui-td-gray">商品关键字<font>*</font></td>
<td colspan="7"><input type="text" name="keyword" lay-verify="required" lay-reqText="请输入商品关键字"
autocomplete="off" placeholder="请输入商品关键字" class="layui-input"></td>
</tr>
<tr>
<td class="layui-td-gray">售价<font>*</font></td>
<td colspan="7"><input type="text" name="price" lay-verify="required|number" lay-reqText="请输入售价"
autocomplete="off" placeholder="请输入售价" class="layui-input"></td>
</tr>
<tr>
<td class="layui-td-gray">成本价<font>*</font></td>
<td colspan="7"><input type="text" name="cost" lay-verify="required|number" lay-reqText="请输入成本价"
autocomplete="off" placeholder="请输入成本价" class="layui-input"></td>
</tr>
<tr>
<td class="layui-td-gray">市场价<font>*</font></td>
<td colspan="7"><input type="text" name="ot_price" lay-verify="required|number" lay-reqText="请输入市场价"
autocomplete="off" placeholder="请输入市场价" class="layui-input"></td>
</tr>
<tr>
<td class="layui-td-gray">库存<font>*</font></td>
<td colspan="7"><input type="text" name="stock" lay-verify="required|number" lay-reqText="请输入库存"
autocomplete="off" placeholder="请输入库存" class="layui-input"></td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">商品简介</td>
<td colspan="2" class="layui-td-gray">店铺类型名称<font>*</font></td>
<td colspan="6">
<textarea class="layui-textarea" name="store_info"></textarea>
<input type="text" name="type_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="123131{$detail.type_name}">
</td>
</tr>
<tr>
<td colspan="2" class="layui-td-gray">店铺类型要求</td>
<td colspan="6">
<textarea class="layui-textarea" name="type_info">{$detail.type_name}</textarea>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">商品详情</td>
<td colspan="2" class="layui-td-gray">店铺保证金</td>
<td colspan="6">
<textarea class="layui-textarea" id="container_content"></textarea>
<table class="layui-table layui-table-form">
<tr>
<td colspan="2">
<div class="layui-input-block">
<input type="radio" name="is_margin" value="1" title="有" checked="{$detail.is_margin}">
<input type="radio" name="is_margin" value="0" title="无" checked="{$detail.is_margin}">
</div>
</td>
<td colspan="5"></td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="margin" lay-verify="required" lay-reqText="0" autocomplete="off" placeholder="0" class="layui-input" value="{$detail.margin}">
</td>
<td colspan="5">单位:元</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" style="height: 360px;" class="layui-td-gray">店铺权限<font>*</font></td>
<td colspan="6" >
<div class="data-box" data-admin='{:json_encode($dataTree)}'></div>
<div id="test7" class="demo-tree"></div>
</td>
</tr>
<tr>
<td colspan="2" class="layui-td-gray">其它说明</td>
<td colspan="6">
<textarea class="layui-textarea" name="description">{$detail.description}</textarea>
</td>
</tr>
</table>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform" type='button'>立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
@ -155,95 +80,130 @@
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/xm-select.js"></script>
<script>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
var moduleInit = ['tool','treeGrid', 'tagpicker', 'tinymce', 'admin'];
var group_access = "{:session('gougu_admin')['group_access']}"
var multiple_images = [];
//单击图片删除图片 【注册全局函数】
function delMultipleImgs(this_img){
//获取下标
var subscript=$("#upload_box_thumb2 img").index(this_img);
//删除图片
this_img.remove();
//删除数组
multiple_images.splice(subscript, 1);
//重新排序
multiple_images.sort();
$('#upload_box_thumb2 input').attr('value', multiple_images);
//返回
return ;
}
function gouguInit() {
var form = layui.form, tool = layui.tool, tagspicker = layui.tagpicker;
var treeGrid = layui.treeGrid,table = layui.table
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
//上传商品轮播图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb2',
url: '/admin/api/upload',
multiple: true,
before: function(obj){
//预读本地文件示例不支持ie8
obj.preview(function(index, file, result){
$('#upload_box_thumb2').append(`
<img src="${result}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
width="100" style="max-width: 100%; height:66px;" alt="${file.name}" onclick="delMultipleImgs(this)" title="点击删除"/>
`)
});
},
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
//追加图片成功追加文件名至图片容器
multiple_images.push(res.data.filepath);
$('#upload_box_thumb2 input').attr('value', multiple_images);
// $('#upload_box_thumb2 img').attr('src', res.data.filepath);
}
});
var tool = layui.tool;
var form = layui.form, tool = layui.tool, tagspicker = layui.tagpicker;
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500
});
//监听提交
form.on('submit(webform)', function (data) {
data.field.content = tinyMCE.editors['container_content'].getContent();
if (data.field.content == '') {
layer.msg('请先完善商品详情');
return false;
}
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.tabRefresh(71);
tool.sideClose(1000);
}
}
tool.post('/admin/store_product/add', data.field, callback);
return false;
height: 500,
});
// 店铺权限
layui.use(['tree', 'util'], function(){
var tree = layui.tree
,layer = layui.layer
,util = layui.util
//模拟数据
,data = getData();
// [{
// title: '一级1'
// ,id: 1
// ,field: 'name1'
// ,checked: true
// ,spread: true
// ,children: [{}]
// }]
//开启复选框
tree.render({
elem: '#test7'
,data: data
,showCheckbox: true
,id:'id',//菜单id
});
//监听提交
form.on('submit(webform)', function (data) {
console.log(data.field);
// data.field.content = tinyMCE.editors['container_content'].getContent();
if (data.field == '') {
layer.msg('请先完善店铺类型');
return false;
}
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.tabRefresh(71);
tool.sideClose(1000);
}
}
//获得选中的节点
var checkData = tree.getChecked('id');
var list = new Array();
list = getChecked_list(checkData);
data.field.auth = list
tool.post('/admin/merchant/type/add', data.field, callback);
return true;
});
// 获取选中节点的id
function getChecked_list(data) {
var id = "";
$.each(data, function (index, item) {
if (id != "") {
id = id + "," + item.id;
}
else {
id = item.id;
}
var i = getChecked_list(item.children);
if (i != "") {
id = id + "," + i;
}
});
return id;
}
});
}
//获取店铺权限的数据
function getData(){
/* 初始化页面渲染时传过来的js变量 */
let dataContainerElem = document.querySelector('.data-box'),
data = dataContainerElem ? dataContainerElem.dataset : {},
dataBox = {}; //模板变量容器,`.data-box`类选择器所在的所有`data`属性值集合
Object.keys(data).forEach(function (key) {
dataBox[key] = data[key];
if (isJsonString(data[key])) dataBox[key] = JSON.parse(data[key]); //是json格式的字串才转对象
});
/**
* 判断字串是否属于json字串
*/
function isJsonString(str) {
let flag = false;
if (typeof str != 'string') return flag;
try {
JSON.parse(str);
flag = true;
} catch (e) {}
return flag;
}
//所有保存到数据节点的变量都成为`dataBox`对象的属性
return dataBox.admin;
}
</script>
{/block}
<!-- /脚本 -->
<!-- /脚本 -->

View File

@ -3,23 +3,21 @@
{block name="body"}
<div class="p-3">
<form class="layui-form gg-form-bar border-t border-x">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="请输入关键字" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
</form>
<table class="layui-hide" id="store_product" lay-filter="store_product"></table>
</div>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加商品">+ 添加商品</span>
<span class="layui-btn layui-btn-sm side-alert" lay-event="add" data-title="添加商品">+ 添加店铺类型</span>
</div>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
<div class="layui-btn-group">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a>
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</div>
</script>
{/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: '<div><img src="{{ d.image }}" style="width:30px; height:30px;"></div>',
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;
// });
}
</script>
{/block}

View File

@ -10,135 +10,50 @@
<h3 class="pb-3">文章详情</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">商品名称<font>*</font></td>
<td class="layui-td-gray">店铺类型名称</td>
<td colspan="7"><input type="text" name="store_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.store_name}" readonly></td>
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_name}" readonly></td>
</tr>
<!-- <tr>-->
<!-- <td class="layui-td-gray">平台商品分类<font>*</font></td>-->
<!-- <td colspan="3">-->
<!-- <div class="layui-col-md6">-->
<!-- <select name="cate_id" lay-verify="required" lay-search="">-->
<!-- <option value="" >请选择</option>-->
<!-- {volist name=':set_recursion(get_store_category())' id='vo'}-->
<!-- <option value="{$vo.id}" >{$vo.title}</option>-->
<!-- {/volist}-->
<!-- </select>-->
<!-- </div>-->
<!-- </td>-->
<!-- </tr>-->
<tr>
<td class="layui-td-gray">商户商品分类<font>*</font></td>
<td colspan="3">
<div class="layui-col-md6">
<select name="cate_id" lay-verify="required" lay-search="">
<option value="" >请选择</option>
{volist name=':set_recursion(get_store_category())' id='vo'}
<option value="{$vo.id}" {if $detail.cate_id==$vo.id} selected {/if}>{$vo.title}</option>
{/volist}
</select>
</div>
<td class="layui-td-gray">店铺类型要求</td>
<td colspan="7">
<input type="text" name="store_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_info}" readonly>
</td>
</tr>
<tr>
<td class="layui-td-gray">品牌选择<font>*</font></td>
<td colspan="3">
<div class="layui-col-md6">
<select name="brand_id" lay-verify="required" lay-search="">
<option value="" >请选择</option>
{volist name='store_brand' id='vo'}
<option value="{$vo.brand_id}" {if $detail.brand_id==$vo.brand_id} selected {/if}>{$vo.brand_name}</option>
{/volist}
</select>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">商品封面图</td>
<td>
<div class="layui-upload">
<!-- <button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">-->
<!-- 上传缩略图(尺寸:428x270)-->
<!-- </button>-->
<div class="layui-upload-list" id="upload_box_thumb"
style="overflow: hidden;">
<img src="{$detail.image}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
width="100" style="max-width: 100%; height:66px;"/>
<input type="hidden" name="image" value="{$detail.image}">
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">商品轮播图</td>
<td>
<div class="layui-upload">
<!-- <button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb2">-->
<!-- 上传缩略图(尺寸:428x270)-->
<!-- </button>-->
<div class="layui-upload-list" id="upload_box_thumb2"
style="overflow: hidden;">
{volist name='detail.slider_image_arr' id='vo'}
{if $vo}
<img src="{$vo}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
width="100" style="max-width: 100%; height:66px;" onclick="delMultipleImgs(this)"/>
{/if}
{/volist}
<input type="hidden" name="slider_image" value="{$detail.slider_image}">
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">单位<font>*</font></td>
<td colspan="7"><input type="text" name="unit_name" lay-verify="required" lay-reqText="请输入单位"
autocomplete="off" placeholder="请输入单位" class="layui-input" value="{$detail.unit_name}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">商品关键字<font>*</font></td>
<td colspan="7"><input type="text" name="keyword" lay-verify="required" lay-reqText="请输入商品关键字"
autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.keyword}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">售价<font>*</font></td>
<td class="layui-td-gray">店铺保证金</td>
<td colspan="7"><input type="text" name="price" lay-verify="required" lay-reqText="请输入商品关键字"
autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.price}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">成本价<font>*</font></td>
<td colspan="7"><input type="text" name="cost" lay-verify="required" lay-reqText="请输入商品关键字"
autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.cost}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">市场价<font>*</font></td>
<td colspan="7"><input type="text" name="ot_price" lay-verify="required" lay-reqText="请输入商品关键字"
autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.ot_price}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">库存<font>*</font></td>
<td colspan="7"><input type="text" name="stock" lay-verify="required" lay-reqText="请输入商品关键字"
autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.stock}" readonly></td>
autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.margin}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">商品简介</td>
<td class="layui-td-gray">店铺权限</td>
<td colspan="3">
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">其它说明</td>
<td colspan="6">
<textarea class="layui-textarea" name="store_info" readonly>{$detail.store_info}</textarea>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">商品详情</td>
<td class="layui-td-gray" style="text-align:left">创建时间</td>
<td colspan="6">
<textarea class="layui-textarea" id="container_content" readonly>{$detail.content}</textarea>
{$detail.create_time}
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">修改时间</td>
<td colspan="6">
{$detail.update_time}
</td>
</tr>

View File

@ -15,11 +15,11 @@ class MerchantMargin extends Model
protected $connection = 'shop';
protected $table = '';
function __construct()
function GetList()
{
}
$list = self::select();
return $list;
}
}
}

View File

@ -1,9 +1,18 @@
<?php
/**
* 店铺类型管理 model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
namespace app\common\model\merchant\system\merchant;
use think\exception\ValidateException;
use think\Model;
use think\facade\Db;
/**
* @mixin \think\Model
@ -11,16 +20,126 @@ use think\Model;
class MerchantType extends Model
{
protected $connection = 'shop';
protected $table = 'eb_merchant_type';
function __construct()
/**
* 查询店铺类型数据
*
* @param int $page 过滤字段条件
* @param int $limit 菜单类型: 0商城平台菜单 1商户菜单
*
* @return array|object
*/
function GetList(int $page, int $limit)
{
$rows = empty($limit) ? get_config('app . page_size') : $limit;
$data = self::field('mer_type_id as id,type_name,margin,is_margin,type_info,description,create_time,update_time')
->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()
{}
}