本地生活商家添加导出功能

This commit is contained in:
wangxiaowei 2024-09-19 17:37:27 +08:00
parent 0f24fc61bc
commit 7e4db4e07d
5 changed files with 100 additions and 6 deletions

@ -187,4 +187,14 @@ class LocalStore extends AdminBase
return JsonServer::error('获取失败');
}
}
public function exportLocalStoreData()
{
$ids = $this->request->post('ids');
$result = LocalStoreLogic::exportLocalStoreData($ids);
if(false === $result) {
return JsonServer::error(LocalStoreLogic::getError() ?: '导出失败');
}
return JsonServer::success('', $result);
}
}

@ -29,8 +29,8 @@ class LocalStoreLogic extends Logic
public static function lists($get)
{
$lists = LocalStore::with('info')
->order('lstore_id', 'desc')
->where('is_delete', 0)
->order('lstore_id', 'desc')
->paginate([
'page' => $get['page'],
'list_rows' => $get['limit'],
@ -284,4 +284,64 @@ class LocalStoreLogic extends Logic
->update(['is_delete' => 1, 'delete_time' => date('Y-m-d H:i:s')]);
return $result;
}
public static function exportLocalStoreData($ids)
{
try{
if ($ids) {
$lists = LocalStore::with('info')
->where('is_delete', 0)
->whereIn('lstore_id', $ids)
->order('lstore_id', 'desc')
->select()->toArray();
} else {
$lists = LocalStore::with('info')
->where('is_delete', 0)
->order('lstore_id', 'desc')
->select()->toArray();
}
$state = array(
0 => '待审核',
1 => '审核通过',
2 => '审核失败'
);
foreach ($lists as $k => &$v) {
$v['store_state'] = $state[$v['store_state']];
if ($v['bankType'] == 1) {
$lists[$k]['bankTypes'] = $v['largeNumber'];
} else if ($v['bankType'] == 2) {
$lists[$k]['bankTypes'] = $v['bank_user_name'];
}
$v['bankType'] = self::$PAYMENT_TYPE[$v['bankType']];
$lists[$k]['nickname'] = $v['info']['nickname'];
}
$title = [
'nickname' => '注册昵称',
'shopName' => '商家名称',
'bankType' => '账户类型',
'bankTypes' => '大额行号/户名',
'bankName' => '银行名称',
'bankCard' => '银行卡号',
'crftNo1' => '社会信用代码',
'name' => '商户联系人',
'empowerPhone' => '联系电话',
'notes' => '用户备注',
'address' => '商家地址',
'create_time' => '创建时间'
];
$export = new ExportExcelServer();
$export->setFileName('本地生活商家列表');
$result = $export->createExcel($title, $lists);
return ['url' => $result];
} catch (\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
}

@ -47,7 +47,7 @@
</div>
<div id="largeNumberBlock" class="layui-form-item">
<label class="layui-form-label"><span style="color:red;">*</span>大额卡号:</label>
<label class="layui-form-label"><span style="color:red;">*</span>大额行号:</label>
<div class="layui-input-inline">
<input type="text" name="largeNumber" id="largeNumber" lay-verType="tips" lay-verify="crftNo1"
switch-tab="0" autocomplete="off" class="layui-input">

@ -75,15 +75,15 @@
</div>
</div>
<div id="largeNumberBlock" class="layui-form-item" {if condition="$data.bankType eq 2" } style="display: none" {/if}>
<label class="layui-form-label"><span style="color:red;">*</span>大额卡号:</label>
<div id="largeNumberBlock" class="layui-form-item" {if condition="$data.bankType eq 1" } style="display: none" {/if}>
<label class="layui-form-label"><span style="color:red;">*</span>大额行号:</label>
<div class="layui-input-inline">
<input type="text" name="largeNumber" id="largeNumber" autocomplete="off" class="layui-input"
value="{$data.largeNumber}">
</div>
</div>
<div id="bank_user_name_block" class="layui-form-item" {if condition="$data.bankType eq 1" } style="display: none" {/if}>
<div id="bank_user_name_block" class="layui-form-item" {if condition="$data.bankType eq 2" } style="display: none" {/if}>
<label class="layui-form-label"><span style="color:red;">*</span> 户名:</label>
<div class="layui-input-inline">
<input type="text" name="bank_user_name" id="bank_user_name" autocomplete="off" class="layui-input" value="{$data.bank_user_name}">

@ -28,6 +28,7 @@
<div class="layui-inline">
<a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="search">搜索</a>
<a class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="clear-search">重置</a>
<a class="layui-btn layui-btn-sm layuiadmin-btn-ad layui-btn-primary " lay-submit lay-filter="data-export">导出</a>
</div>
</div>
</div>
@ -71,7 +72,8 @@
var table = layui.table;
var form = layui.form;
like.tableLists("#like-table-lists", "{:url()}", [
{field: "lstore_id", width: 60, title: "ID"}
{type: 'checkbox'}
, {field: "lstore_id", width: 60, title: "ID"}
, {field: "shopName", width: 200, align: "center", title: "商家名称"}
, {field: "name", width: 120, align: "center", title: "商户联系人"}
, {field: "selfPhoto", width: 150, align: "center", title: "商家自拍照", templet: '#self-photo'}
@ -207,5 +209,27 @@
});
});
// 导出
form.on('submit(data-export)', function (data) {
var checkStatus = table.checkStatus('like-table-lists');
var checkData = checkStatus.data;
var ids = [];
// 取出选中的行ID
checkData.forEach(function (item) {
ids.push(parseInt(item['lstore_id']));
});
var field = data.field;
like.ajax({
url: '{:url("shop.LocalStore/exportLocalStoreData")}'
, data: {ids}
, type: 'post'
, success: function (res) {
if (res.code == 1) {
window.location.href = res.data.url;
}
}
});
});
})
</script>