作者 SHW\戥岁。。

规格类型字段

... ... @@ -57,22 +57,20 @@ class Litestoregoods extends Backend
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax())
{
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['category','activity'])
->with(['category', 'activity'])
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->with(['category','activity'])
->with(['category', 'activity'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
... ... @@ -83,7 +81,7 @@ class Litestoregoods extends Backend
$row->getRelation('category')->visible(['name']);
$row->getRelation('activity')->visible(['name']);
// $row->getRelation('freight')->visible(['name']);
$row->stock_num = Litestoregoodsspec::where('goods_id',$row['goods_id'])->sum('stock_num');
$row->stock_num = Litestoregoodsspec::where('goods_id', $row['goods_id'])->sum('stock_num');
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
... ... @@ -93,7 +91,8 @@ class Litestoregoods extends Backend
return $this->view->fetch();
}
public function addSpec($spec_name, $spec_value){
public function addSpec($spec_name, $spec_value)
{
// 判断规格组是否存在
if (!$specId = $this->SpecModel->getSpecIdByName($spec_name)) {
// 新增规格组and规则值
... ... @@ -153,7 +152,7 @@ class Litestoregoods extends Backend
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
if($params['spec_type'] == '20' && !$this->request->post("spec_many/a")){
if ($params['spec_type'] == '20' && !$this->request->post("spec_many/a")) {
$this->error('请添加规格');
}
try {
... ... @@ -167,7 +166,7 @@ class Litestoregoods extends Backend
if ($result !== false) {
//成功之后 存储商品规格
$spec_many_params = $this->request->post("spec_many/a");
$this->model->addGoodsSpec($params,$spec_many_params,$this->request->post("spec/a"));
$this->model->addGoodsSpec($params, $spec_many_params, $this->request->post("spec/a"));
$this->success();
} else {
$this->error($this->model->getError());
... ... @@ -228,7 +227,7 @@ class Litestoregoods extends Backend
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
if($params['spec_type'] == '20' && !$this->request->post("spec_many/a")){
if ($params['spec_type'] == '20' && !$this->request->post("spec_many/a")) {
$this->error('请添加规格');
}
try {
... ... @@ -242,11 +241,11 @@ class Litestoregoods extends Backend
if ($result !== false) {
//成功之后 存储商品规格
$spec_many_params = $this->request->post("spec_many/a");
$row->addGoodsSpec($params,$spec_many_params,$this->request->post("spec/a"), true);
$row->addGoodsSpec($params, $spec_many_params, $this->request->post("spec/a"), true);
// 删除购物车
Db::name('cart')->where('goods_id',$row->goods_id)->delete();
Db::name('cart')->where('goods_id', $row->goods_id)->delete();
//删除我常买
Db::name('user_buylist')->where('goods_id',$row->goods_id)->delete();
Db::name('user_buylist')->where('goods_id', $row->goods_id)->delete();
$this->success();
} else {
$this->error($row->getError());
... ... @@ -261,11 +260,77 @@ class Litestoregoods extends Backend
}
// 多规格信息
$specData = 'null';
if ($row['spec_type'] === '20'){
if ($row['spec_type'] === '20') {
$specData = json_encode($this->model->getManySpecData($row['spec_rel'], $row['spec']));
}
$row['specData'] = $specData;
$this->view->assign("row", $row);
return $this->view->fetch();
}
/**
* 导出
*/
public function clubpeople(){
//1.从数据库中导出需要进行要导出的数据
$list =Db::query('SELECT stu_list.stu_name,stu_list.stu_department,stu_list.stu_phone,stu_list.stu_email,stu_list.stu_profess
,club_branch.* FROM club_branch INNER JOIN stu_list ON club_branch.stu_number = stu_list.stu_number
where club_branch.club_id=:acc order by club_branch.club_branch_name ',['acc'=>$clubid]);
//重要补助
//2.加载PHPExcle类库
vendor('PHPExcel.PHPExcel');
//3.实例化PHPExcel类
$objPHPExcel = new \PHPExcel();
//4.激活当前的sheet表
$objPHPExcel->setActiveSheetIndex(0);
//5.设置表格头(即excel表格的第一行)
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', '部门')
->setCellValue('B1', '职位')
->setCellValue('C1', '学号')
->setCellValue('D1', '学生姓名')
->setCellValue('E1', '联系方式')
->setCellValue('F1', '邮箱')
->setCellValue('G1', '院系')
->setCellValue('H1', '专业');
//设置A列水平居中
$objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()
->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//设置单元格宽度
//6.循环刚取出来的数组,将数据逐一添加到excel表格。
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(10);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(30);
for($i=0;$i<count($list);$i++){
$objPHPExcel->getActiveSheet()->setCellValue('A'.($i+2),$list[$i]['club_branch_name']);//ID
$objPHPExcel->getActiveSheet()->setCellValue('B'.($i+2),$list[$i]['club_position']);//标签码
$objPHPExcel->getActiveSheet()->setCellValue('C'.($i+2),$list[$i]['stu_number']);//防伪码
$objPHPExcel->getActiveSheet()->setCellValue('D'.($i+2),$list[$i]['stu_name']);//ID
$objPHPExcel->getActiveSheet()->setCellValue('E'.($i+2),$list[$i]['stu_phone']);//标签码
$objPHPExcel->getActiveSheet()->setCellValue('F'.($i+2),$list[$i]['stu_email']);//ID
$objPHPExcel->getActiveSheet()->setCellValue('G'.($i+2),$list[$i]['stu_department']);//标签码
$objPHPExcel->getActiveSheet()->setCellValue('H'.($i+2),$list[$i]['stu_profess']);//防伪码
}
//7.设置保存的Excel表格名称
$filename = $club_name.'人员名单'.date('ymd',time()).'.xls';
//8.设置当前激活的sheet表格名称;
$objPHPExcel->getActiveSheet()->setTitle('人员名单');
//9.设置浏览器窗口下载表格
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:inline;filename="'.$filename.'"');
//生成excel文件
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
//下载文件在浏览器窗口
$objWriter->save('php://output');
exit;
}
}
... ...
... ... @@ -95,7 +95,7 @@ class Classification extends Api
->where('is_delete', '0')
->where('category_id', $sort_id)
->where('goods_status', '10')
->field('goods_id,goods_name,image')
->field('goods_id,spec_type,goods_name,image')
->paginate(10, false, ['page' => $page])
->each(function ($item, $key) {
if ($this->auth->isLogin()) {
... ... @@ -400,7 +400,7 @@ class Classification extends Api
->where('is_delete', '0')
->where('category_id', $sort_id)
->where('goods_status', '10')
->field('goods_id,goods_name,image')
->field('goods_id,spec_type,goods_name,image')
->paginate(10, false, ['page' => $page])
->each(function (&$item) {
if ($this->auth->isLogin()) {
... ... @@ -464,7 +464,7 @@ class Classification extends Api
$list = $model
->where('is_delete', '0')
->where('goods_status', '10')
->field('goods_id,goods_name,image')
->field('goods_id,goods_name,spec_type,image')
->paginate(10, false, ['page' => $page])
->each(function (&$item) {
if ($this->auth->isLogin()) {
... ...
... ... @@ -97,33 +97,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'litestor
$('.btn-sync').click(function () {
var index = Layer.load();
$.ajax({
// type: "POST",
url: $.fn.bootstrapTable.defaults.extend.performTask,
confirm: '确认开始执行任务吗?(数据导出属高IO操作,若本任务数据量超过2万,请择服务器相对闲时执行!)',
refresh: true,
// url: "fastexport/zdyTask",
type: "POST",
msg: "确认导出吗?导出过程请勿关闭",
url: "litestore/litestoregoods/zdy_export",
datatype: "json",
success: function (data, ret) {
if (ret.code == 1) {
if (data.direct_export) {
Fast.api.msg('任务已开始,请稍等片刻...')
window.location = 'fastexport/zdyTask';
} else {
window.open("fastexport/taskControl/task_id/" + data.id, "_blank");
}
} else {
Layer.alert(ret.msg);
}
return false;
success: function (data) {
Layer.close(index);
Layer.alert(data.msg);
},
error: function (data, ret) {
Layer.alert(ret.msg);
return false;
error: function () {
Layer.close(index);
console.log('btn-course-scheduling setInterval error');
}
});
});
table.on('load-success.bs.table', function (data) {
$(".btn-editone").data("area", ["1000px", "800px"]);
});
... ...