Commit dc3e69f2 authored by rlgy's avatar rlgy

反馈数据导出

parent e11cbd31
......@@ -294,7 +294,20 @@ class SourceController extends BaseController
}
}
$this->error('删除成功', '/admin/source/feedback');
} elseif ($operation == 2) {
//导出csv
$data = Feedback::find()->select(['connect', 'content', 'type', 'create_at'])->asArray()->all();
$handle = fopen('php://temp', 'rw');
fputcsv($handle, ['联系方式', '反馈内容', '反馈类型', '反馈时间']);
foreach ($data as $item) {
//todo 类型转换
if ($item['type'] == 0) {
$item['type'] = '默认';
}
fputcsv($handle, $item);
}
Yii::$app->response->sendStreamAsFile($handle, 'feedback.csv');
Yii::$app->response->send();
}
}
return $this->render('feedback');
......
......@@ -29,13 +29,21 @@
<div class="layui-inline">
<button class="layui-btn" lay-submit lay-filter="submit1">查询</button>
<button class="layui-btn">导出cvs</button>
</div>
</form>
</div>
<div class="layui-col-md3">
<div style="float: right;">
<a href="/admin/source/feedback?operation=2">
<button class="layui-btn">导出cvs</button>
</a>
</div>
</div>
</div>
<div class="layui-row">
<table class="layui-table" id="table1"></table>
<div class="layui-col-md8">
<table class="layui-table" id="table1"></table>
</div>
</div>
<script>
var form = layui.form;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment