edit修改相關內容

This commit is contained in:
admin 2023-11-20 20:18:51 +08:00
parent 6ef8cf3fc7
commit a3589dab7d
20 changed files with 3040 additions and 1739 deletions

View File

@ -30,6 +30,8 @@ class SiteController extends Controller
public function actionIndex()
{
$code = $this->request->get('code');
$url = "https://app.3dxh.h5.dev.1nww.com/#/White?code={$code}";
return $this->redirect($url);
echo($code);
exit();
return $this->render('index');

59
models/Dev.php Normal file
View File

@ -0,0 +1,59 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "cx_dev".
*
* @property int $id
* @property int $store_id 门店ID
* @property string $name 设备名称
* @property string $dev_number 设备编号
* @property int $status 0-正常 1-租赁
* @property int $created_at 添加时间
* @property int $updated_at 更新时间
* @property int|null $is_delete 是否删除0=1=
* @property int|null $deleted_at 删除时间
*/
class Dev extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'cx_dev';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['store_id', 'name', 'dev_number', 'created_at'], 'required'],
[['store_id', 'status', 'created_at', 'updated_at', 'is_delete', 'deleted_at'], 'integer'],
[['name', 'dev_number'], 'string', 'max' => 50],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'store_id' => 'Store ID',
'name' => 'Name',
'dev_number' => 'Dev Number',
'status' => 'Status',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'is_delete' => 'Is Delete',
'deleted_at' => 'Deleted At',
];
}
}

View File

@ -25,6 +25,8 @@ use app\modules\api\models\CommentForm;
use app\modules\api\models\LoginForm;
use app\modules\api\models\UserBasicInfoForm;
use app\modules\api\models\UserModifyForm;
use app\modules\api\models\ReportEditForm;
class UserController extends Controller
{
@ -56,10 +58,12 @@ class UserController extends Controller
$post = \Yii::$app->request->post(); // attributes 转成键值对形式 key=> value
$user_outh = UserOauth::findOne(['openid' => $post['code']]);
if ($user_outh == null) {
return ['code' => 1, 'msg' => '授权失败,请重新进行微信公众号授权',];
$data = ['code' => 1, 'msg' => '授权失败,请重新进行微信公众号授权',];
return $this->responseHandler($data);
}
if ($user_outh->user_id == 0) {
return ['code' => 1, 'msg' => '暂未填写信息',];
$data = ['code' => 1, 'msg' => '暂未填写信息',];
return $this->responseHandler($data);
}
// 查用户信息
@ -98,4 +102,25 @@ class UserController extends Controller
$data = $form->modify_user();
return $this->responseHandler($data);
}
/**
* showdoc
* @catalog 会员注册
* @method post
* @url /api/user/user-create
* @return {"code":0,"msg":"ok","data":{}}
* @remark
*/
public function actionUserCreate()
{
$post = \Yii::$app->request->post(); // attributes 转成键值对形式 key=> value
$form = new ReportEditForm();
// $form->cx_mch_id = $this->cx_mch_id; //商户ID 没看到传参赋值 默认给0
$form->attributes = $post;
$form->user_id = \Yii::$app->user->identity->id; //获取用户登陆ID
$data = $form->edit();
return $this->responseHandler($data);
}
}

View File

@ -84,7 +84,7 @@ class LoginByWxoaForm extends ApiModel
return ['code' => 1, 'msg' => '登陆失败'];
}
}
$data = ['code' => 1, 'msg' => '登陆成功', 'data' => $openid];
$data = ['code' => 0, 'msg' => '登陆成功', 'data' => $openid];
return $data;
}

View File

@ -45,11 +45,13 @@ class LoginForm extends ApiModel
];
}
public function login()
public function login($user=null)
{
$this->cx_mch_id = 0;
if(!$this->validate()){
return $this->getModelError();
}
if(empty($user)){
$mobile_phone = EncryptHelper::encryptMobilePhone($this->username);
$mobile_phone = $mobile_phone ? $mobile_phone : $this->username;
$user = User::find()
@ -67,10 +69,12 @@ class LoginForm extends ApiModel
if($user == null){
return [
'code' => 1,
'msg' => '用户名或者密码错误'
'msg' => '用户名或者密码错误1'
];
}
if(!$user->validatePassword($this->password)){
}
/*if(!$user->validatePassword($this->password)){
$err_msg = "密码错误";
User::lastLogin($user->id, 0, $err_msg, $this->cx_mch_id);
@ -78,7 +82,7 @@ class LoginForm extends ApiModel
'code' => 1,
'msg' => '用户名或者密码错误'
];
}
} */
if(\Yii::$app->user->login($user,\Yii::$app->params['loginAuthExpireTime'])){
$args = [];
$args['cx_mch_id'] = $this->cx_mch_id;

View File

@ -0,0 +1,79 @@
<?php
/**
* @author Any
* @description KISS
* @date 2020-12-2
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\api\models;
use function AlibabaCloud\Client\value;
use app\components\FlashStorage;
use app\components\SiteHelper;
use app\models\BallMark;
use app\models\Coach;
use app\models\Dev;
use app\models\DeviceUniqueBindUser;
use app\models\Model;
use app\models\Report;
use app\models\Store;
use app\models\User;
use app\components\auth\AToken;
use app\components\EncryptHelper;
use app\modules\api\components\ApiHelper;
use app\modules\api\components\GetDistance;
use yii\data\Pagination;
class ReportEditForm extends ApiModel
{
public $dev_id;
public $store_id;
public $user_id;
public $model_number;
public function rules()
{
return [
[['dev_id', 'store_id'], 'integer'],
[['dev_id', 'store_id'], 'required'],
];
}
/**
* 型号列表
*/
public function edit()
{
$dev = Dev::findOne(['id' => $this->dev_id]);
if ($dev == null) {
return ['code' => 1, 'msg' => '无效设备,请联系管理员'];
}
$model = new Report();
$model->user_id = $this->user_id;
$model->model_number = $dev->dev_number;
$model->store_id = $this->store_id;
$model->created_at = time();
if (!$model->save()) {
return Model::getModelErrorInfo($model);
}
return ['code' => 0, 'msg' => '成功'];
}
}

View File

@ -82,7 +82,7 @@ class UserModifyForm extends ApiModel
$form->username = $user->username;
$form->password = '123456';
$form->token_type = 3;
return $form->login();
return $form->login($user);
}
//没有信息 去绑定
@ -134,13 +134,18 @@ class UserModifyForm extends ApiModel
$form->username = $username;
$form->password = $password;
$form->token_type = 3;
$data = $form->login();
$data = $form->login($user);
return $data;
} catch (\Exception $e) {
$t->rollBack();
return [
'code' => 1,
'msg' => '失败',
'data' => [
'msg' => $e->getMessage(),
'line' => $e->getLine(),
'file' => $e->getFile(),
],
];
}
}

View File

@ -140,6 +140,7 @@ class WxmpAuthMobileForm extends ApiModel
}
$uniq = uniqid();
$time = time();
$this->url = urldecode($this->url);
$str = "jsapi_ticket={$get}&noncestr={$uniq}&timestamp={$time}&url={$this->url}";
$sign = sha1($str);
$return = [
@ -150,6 +151,7 @@ class WxmpAuthMobileForm extends ApiModel
'jsApiList' => [
'scanQRCode',
],
'url' => $this->url,
];
return $this->apiReturnSuccess('ok',$return);
}

View File

@ -205,6 +205,7 @@ class UploadController extends \app\controllers\Controller
".pdf",
".txt",
".md",
".ply",
".xml"
],
/* 上传文件格式显示 */

View File

@ -0,0 +1,104 @@
<?php
/**
* @author Any
* @description KISS
* @date 2020-11-5
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\store\controllers;
use app\components\SiteHelper;
use app\models\Dev;
use app\models\Report;
use app\models\StoreUser;
use app\models\User;
use app\modules\store\behaviors\LoginBehavior;
use app\components\EncryptHelper;
use app\modules\store\models\dev\DevActionForm;
use app\modules\store\models\dev\DevEditForm;
use app\modules\store\models\dev\DevtListForm;
use app\modules\store\models\report\ReportEditForm;
use app\modules\store\models\report\ReportListForm;
class DevController extends Controller
{
public function behaviors()
{
return array_merge(parent::behaviors(), [
'login' => [
'class' => LoginBehavior::className(),
],
]);
}
//设备列表
public function actionIndex()
{
if (\Yii::$app->request->isAjax) {
$form = new DevtListForm();
$form->store_id = \Yii::$app->store->identity->store_id;
$form->attributes = \Yii::$app->request->get();
$data = $form->search();
return $this->responseHandler($data);
}
return $this->render('index', []);
}
//添加设备
public function actionEdit($id = 0)
{
$model = Dev::findOne([
'id' => $id,
]);
if ($model == null)
$model = new Dev();
if (\Yii::$app->request->isAjax) {
$form = new DevEditForm();
$form->store_id = \Yii::$app->store->identity->store_id;
$form->model = $model;
$form->attributes = \Yii::$app->request->post();
$data = $form->edit();
return $this->responseHandler($data);
}
$return_url = \Yii::$app->request->referrer;
return $this->render("edit", [
'model' => $model,
'return_url' => $return_url,
]);
}
//设备二维码
public function actionQrcode($id = 0)
{
if (!\Yii::$app->request->isPost) {
$data = $this->invaildRequest();
return $this->responseHandler($data);
}
$form = new DevActionForm();
$form->attributes = \Yii::$app->request->post();
$data = $form->getBallQrcode();
return $this->responseHandler($data);
}
public function actionBatchQrcode()
{
$form = new DevActionForm();
$data = $form->BatchQrcode();
return $this->responseHandler($data);
}
}

View File

@ -39,6 +39,7 @@ class ReportController extends Controller
if (\Yii::$app->request->isAjax) {
$form = new ReportListForm();
$form->store_id = \Yii::$app->store->identity->store_id;
$form->user_id = \Yii::$app->store->identity->user_id;
$form->attributes = \Yii::$app->request->get();
$data = $form->search();
return $this->responseHandler($data);

View File

@ -69,6 +69,29 @@ class Menu
],
],
],
[
'name' => '设备管理',
'is_menu' => true,
'is_show' => true,
'route' => null,
'icon' => 'layui-icon-list',
'children' => [
[
'name' => '设备列表',
'is_menu' => true,
'is_show' => true,
'route' => 'store/dev/index',
],
[
'name' => '添加/编辑设备',
'is_menu' => true,
'is_show' => true,
'route' => 'store/dev/edit',
],
],
],
// [
// 'name' => '财务管理',
// 'is_menu' => true,

View File

@ -0,0 +1,178 @@
<?php
/**
* @author Any
* @description KISS
* @date 2020-11-5
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\store\models\dev;
use app\components\FlashStorage;
use app\components\SiteHelper;
use app\components\ZipFile;
use app\models\auth\RoleUser;
use app\models\BallCart;
use app\models\Coach;
use app\models\Dev;
use app\models\District;
use app\models\Model;
use app\models\Store;
use app\models\StoreUser;
use app\models\User;
use app\models\Admin;
use app\modules\store\models\AdminModel;
use app\models\common\CommonUserEditForm;
use app\modules\api\components\Mqtt;
use app\modules\api\models\StoreCityForm;
use PHPQRCode\QRcode;
class DevActionForm extends AdminModel
{
public $ids;
private $url = 'https://app.3dxh.h5.dev.1nww.com/#/White';
public function rules()
{
return [
[['ids'], 'required'],
[['ids'], 'safe'],
];
}
public function attributeLabels()
{
return [
'ids' => '选择项',
];
}
public function getBallQrcode()
{
$ball = Dev::findOne($this->ids);
if ($ball == null) {
return ['code' => 1, 'msg' => '该设备不存在'];
}
$store = Store::findOne($ball->store_id);
if ($store == null) {
return ['code' => 1, 'msg' => '该设备所在门店不存在'];
}
return $this->getQrcode($store, $ball);
}
/**
* @param $store
* @param $ball
* @return array
*/
public function getQrcode($store, $ball)
{
$path = 'qrcode/';
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$hostname = $this->url;
$filename = 'qrcode/' . $ball->dev_number . '.png';
if (!file_exists($filename)) {
$qr_data = $hostname . "?dev_id={$ball->id}&store_id={$ball->store_id}&time={$ball->created_at}&path=basicsInfo";
$errorCorrectionLevel = 'L'; //容错级别
$matrixPointSize = 5; //生成图片大小
QRcode::png($qr_data, $filename, $errorCorrectionLevel, $matrixPointSize, 2, true);
$url = \Yii::$app->request->getHostInfo() . '/' . $filename;
if (!file_exists($filename)) {
return ['code' => 1, 'msg' => '生成二维码失败'];
} else {
return ['code' => 0, 'msg' => 'ok', 'data' => $url];
}
// if (!file_exists($filename)) {
// return [
// 'code' => 1,
// 'msg' => 'Failed to generate QR code.'
// ];
// } else {
// $url = $hostname . '/' . $filename;
// $file = fopen($filename, "w");//打开文件准备写入
// fwrite($file, $url);//写入,$res为图片二进制内容
// fclose($file);//关闭
// //图片是否存在
// if (!file_exists($filename)) {
// return ['code' => 1, 'msg' => '生成二维码失败'];
// } else {
// return ['code' => 0, 'msg' => 'ok', 'data' => $url];
// }
// }
} else {
return ['code' => 0, 'msg' => 'ok', 'data' => \Yii::$app->request->getHostInfo() . '/' . $filename];
}
}
//获取小程序二维码
public function wxmpQrcode($body)
{
$plugin = new \app\models\common\PluginService();
$wxmpService = $plugin->getWxmpService(0);
$accessToken = $wxmpService->getAccessToken();
if (empty($accessToken)) {
$accessToken = $wxmpService->getAccessToken(true);
}
$body = json_encode($body);
return $wxmpService->Qrcode->getWxappQrcode($accessToken, $body);
}
public function BatchQrcode()
{
$ball = Dev::find()->select('id,store_id,name,dev_number,created_at')->where(['is_delete' => 0])->all();
if ($ball == null) {
return ['code' => 1, 'msg' => '该设备不存在'];
}
$path = 'qrcode/dev_qrcode_zip';
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$paths = [];
foreach ($ball as $value) {
$store = Store::findOne($value->store_id);
if ($store == null) {
return $value->dev_number . '编号设备所在门店不存在';
}
$r = $this->getQrcode($store, $value);
if ($r['code'] != 0) {
return $r['msg'];
}
$name = $store->name . '_' . $value->dev_number . '.png';
array_push($paths, ['name' => $name, 'path' => $r['data']]);
}
if (empty($paths)) {
return '无下载数据';
}
$zipName = '设备二维码_' . date('Y年m月d日') . '下载' . '.zip'; // 压缩包文件名
return (new ZipFile())->downloadZipImg($zipName, $path, $paths);
}
}

View File

@ -0,0 +1,89 @@
<?php
/**
* @author Any
* @description KISS
* @date 2020-11-5
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\store\models\dev;
use app\components\EncryptHelper;
use app\components\FlashStorage;
use app\models\Admin;
use app\models\auth\RoleUser;
use app\models\CardUnion;
use app\models\Dev;
use app\models\District;
use app\models\Model;
use app\models\StoreUser;
use app\models\SysAdmin;
use app\models\User;
use app\modules\store\models\AdminModel;
use app\models\common\CommonUserEditForm;
use app\modules\api\models\StoreCityForm;
use Wechat\Wechat;
class DevEditForm extends AdminModel
{
public $store_id;
public $model;
public $dev_number;
public $name;
public function rules()
{
return [
[['name', 'dev_number'], 'string'],
[['name', 'dev_number'], 'required'],
];
}
public function attributeLabels()
{
return [
'name' => '设备名称',
'dev_number' => '设备编号',
];
}
public function edit()
{
if (!$this->validate()) {
return $this->getModelError();
}
if ($this->model->isNewRecord) {
$this->model->created_at = time();
$exists = Dev::find()->where(['dev_number' => $this->dev_number, 'is_delete' => 0])->exists();
if ($exists) {
return $this->apiReturnError('设备编号已存在');
}
}
$this->model->name = $this->name;
$this->model->dev_number = $this->dev_number;
$this->model->store_id = $this->store_id;
$this->model->updated_at = time();
if (!$this->model->save()) {
return $this->getModelError($this->model);
}
return $this->apiReturnSuccess('保存成功');
}
}

View File

@ -0,0 +1,95 @@
<?php
/**
* @author Any
* @description KISS
* @date 2020-11-5
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\store\models\dev;
use app\components\EncryptHelper;
use app\components\Utils;
use app\models\Dev;
use app\models\District;
use app\models\Model;
use app\models\Report;
use app\models\Store;
use app\models\StoreUser;
use app\models\User;
use app\modules\store\models\AdminModel;
use app\models\common\CommonUserEditForm;
use yii\data\Pagination;
class DevtListForm extends AdminModel
{
public $page;
public $limit;
public $keywords;
public $status;
public $store_id;
public function rules()
{
return [
[['keywords',], 'trim'],
[['keywords',], 'string'],
[['page', 'limit'], 'integer'],
[['page'], 'default', 'value' => 1],
[['limit'], 'default', 'value' => 20],
];
}
public function search()
{
if (!$this->validate()) {
return $this->getModelError();
}
$where = ['o.store_id' => $this->store_id];
if (!empty($this->times)) {
$explode = explode(' - ', $this->times);
$where = [
'and',
['>=', 'o.created_at', strtotime($explode[0])],
['<=', 'o.created_at', strtotime($explode[1])],
];
}
$query = Dev::find()->alias('o')
->select('o.id,o.name,o.dev_number,o.created_at,o.status,s.name as store_name')
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
->where([
])->andWhere($where)
->andFilterWhere([
'OR',
['like', 'o.name', $this->keywords],
['like', 'o.dev_numbe', $this->keywords],
]);
$count = $query->count();
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.created_at' => SORT_DESC])->asArray()->all();
foreach ($list as $index => $item) {
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
$list[$index] = $item;
}
$data = [];
$data['code'] = 0;
$data['msg'] = 'ok';
$data['data'] = $list;
$data['count'] = $count;
return $data;
}
}

View File

@ -33,6 +33,8 @@ class ReportListForm extends AdminModel
public $status;
public $store_id;
public $user_id;
public function rules()
{
@ -79,13 +81,21 @@ class ReportListForm extends AdminModel
$count = $query->count();
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.created_at' => SORT_DESC])->asArray()->all();
$storeUser = StoreUser::findOne(['user_id' => $this->user_id]);
foreach ($list as $index => $item) {
$item['user_type'] = $storeUser->user_type;
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
$item['initial_path_ext'] = "";
$item['initial_name'] = '';
if (!empty($item['initial_path'])) {
$item['initial_name'] = $item['model_number'] . '初始报告';
$item['initial_name'] = $item['model_number'] . '初始模型';
$explode = explode('.', $item['initial_path']);
$item['initial_path_ext'] = end($explode);
}
@ -93,7 +103,7 @@ class ReportListForm extends AdminModel
$item['final_path_ext'] = '';
$item['final_name'] = '';
if (!empty($item['final_path'])) {
$item['final_name'] = $item['model_number'] . '最终报告';
$item['final_name'] = $item['model_number'] . '最终模型';
$explode = explode('.', $item['final_path']);
$item['final_path_ext'] = end($explode);
}

View File

@ -0,0 +1,129 @@
<?php
/**
* @author Any
* @description KISS
* @date 2020-11-5
* @version 1.0.0
*
* _____LOG_____
*
*/
use app\components\SiteHelper;
use app\widgets\PickFile;
$layui_js_file = "/statics/layuiadmin/layui/layui.all.2.5.5.js?v=1.0.0";
$this->registerJsFile($layui_js_file, ['depends' => 'app\modules\admin\assets\AppAsset']);
$this->title = '添加/编辑设备';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="layui-fluid">
<div class="layui-card">
<div class="layui-card-header"><?= $this->title ?></div>
<div class="layui-card-body">
<div class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label required">设备名称</label>
<div class="layui-input-inline">
<input type="text" name="name" placeholder="请输入设备名称" autocomplete="off" class="layui-input"
value="<?= $model->name ?>"
lay-verify="required">
</div>
<div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">设备编号</label>
<div class="layui-input-inline">
<input type="text" name="dev_number" placeholder="请输入设备编号" autocomplete="off" class="layui-input"
value="<?= $model->dev_number ?>"
lay-verify="required">
</div>
<div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<div class="">
<button class="layui-btn" lay-submit="" lay-filter="admin-theme-customise">立即提交</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
<?php $this->beginBlock('js_script_wrap') ?>
layui.config({
base: '/statics/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'user', 'upload'], function () {
var $ = layui.$
, setter = layui.setter
, admin = layui.admin
, form = layui.form
, router = layui.router()
, upload = layui.upload
, search = router.search;
form.render();
//提交
var submitLock = false;
form.on('submit(admin-theme-customise)', function (obj) {
if (submitLock) {
return false;
}
submitLock = true;
//请求登入接口
//console.log(obj)
var url = '<?= \Yii::$app->urlManager->createUrl(["/store/dev/edit", 'id' => $model->id ? $model->id : 0]) ?>';
var returnUrl = "<?= \Yii::$app->urlManager->createUrl(["/store/dev/index"]) ?>";
var data = obj.field;
data._csrf = _csrf;
$.ajax(url, {
type: "POST",
dataType: "json",
data: data,
timeout: 10000,
success: function (res) {
if (res.code == 0) {
layer.msg(res.msg, {
offset: '15px'
, icon: 1
, time: 1000
}, function () {
if (returnUrl) {
location.href = returnUrl;
} else {
location.reload();
}
});
} else {
layer.msg(res.msg, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
});
}
},
error: function (xhr, type, err) {
},
complete: function () {
submitLock = false;
}
})
});
});
<?php $this->endBlock(); ?>
</script>
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>

View File

@ -0,0 +1,488 @@
<?php
use app\models\Store;
/**
* @author Any
* @description KISS
* @date 2021年6月30日
* @version 1.0.0
*
* _____LOG_____
*
*/
$this->title = '设备列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<style type="text/css">
.layui-table-cell {
height: auto;
}
</style>
<div class="layui-fluid">
<div class="layui-card">
<div class="layui-card-header">
<?= $this->title ?>
</div>
<div class="layui-card-header layuiadmin-card-header-auto">
<div class="layui-form-item">
<div class="layui-inline">
<!--<a class=" layui-btn" href="<?= \Yii::$app->urlManager->createUrl(["store/feedback/edit"]) ?>">添加反馈</a>-->
</div>
<div class="layui-inline layui-float-right layui-form">
<!-- <div class="layui-inline layui-form-item">-->
<!-- <div class="layui-input-inline">-->
<!-- <select class="layui-select" name="status">-->
<!-- <option value="" -->
<? //=$status === null ? 'selected' : ''?><!--全部状态</option>
<!-- --><?php //foreach ($status_labels as $key => $val):?>
<!-- <option value="--><? //=$key?><!--" -->
<? //=$status == $key && $status != null ? 'selected' : ''?><!--><? //=$val?><!--</option>-->
<!-- --><?php //endforeach;?>
<!-- </select>-->
<!-- </div>-->
<!-- </div>-->
<div class="layui-inline layui-form-item">
<label class="layui-form-label">关键词</label>
<div class="layui-input-block">
<input type="text" name="keywords" placeholder="搜索设备名称,设备编号" autocomplete="off"
class="layui-input"
value="<?= \Yii::$app->request->get("keywords") ?>">
</div>
</div>
<div class="layui-inline">
<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="dtable-search">
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
</button>
</div>
</div>
</div>
</div>
<div class="layui-card-body">
<table id="dtable" lay-filter="dtable"></table>
</div>
</div>
</div>
<!--工具栏模板-->
<script type="text/html" id="toolBarTpl">
<div class="layui-btn-container">
<!-- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="batch_status_yes">批量营业</button>-->
<!-- <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_status_no">批量停业</button>-->
<!-- <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_delete">批量删除</button> -->
<button class="layui-btn layui-btn-sm" lay-event="batch_qrcode">打包二维码</button>
</div>
</script>
<!--行操作列模板-->
<script type="text/html" id="rowBarTpl">
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="qrcode">查看二维码</button>
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">编辑</button>
{{# if(d.initial_path){ }}
<a href="{{d.initial_path}}"
download="{{d.initial_name}}.{{d.initial_path_ext}}">
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="">下载初始模型</button>
</a>
{{# } }}
{{# if(d.final_path){ }}
<a href="{{d.final_path}}"
download="{{d.final_name}}.{{d.final_path_ext}}">
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载最终模型</button>
</a>
{{# } }}
{{# if(d.pdf_path){ }}
<a href="{{d.pdf_path}}"
download="{{d.pdf_name}}.{{d.pdf_path_ext}}">
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载PDF报告</button>
</a>
{{# } }}
<!-- <button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>-->
<!-- <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</button>-->
</script>
<script type="text/html" id="statusTpl">
{{# if(d.status == '0'){ }}
<span class="layui-badge layui-bg-blue">正常</span>
{{# } else{ }}
<span class="layui-badge layui-bg-red">停用</span>
{{# } }}
</script>
<script>
<?php $this->beginBlock('js_script_wrap') ?>
layui.config({
base: '/statics/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'user', 'table', 'form'], function () {
var $ = layui.$
, form = layui.form
, table = layui.table
, admin = layui.admin;
form.render();
//search
form.on('submit(dtable-search)', function (obj) {
var field = obj.field;
reload_table_data(field);
});
//重新加载表格数据
function reload_table_data(conf) {
table.reload('dtable', {
url: '<?=\Yii::$app->urlManager->createUrl(['store/report/index'])?>'
, page: true
, where: conf
});
};
//执行渲染
table.render({
//指定原始表格元素选择器推荐id选择器
elem: '#dtable'
//容器高度
//,height: 315
//容器宽度
//,width: 720
//设置表头
, cols: [[
{checkbox: true}
, {field: 'id', title: 'ID', width: 80}
, {field: 'name', title: '设备名称', width: 150}
, {field: 'dev_number', title: '设备编号', width: 180}
, {field: 'store_name', title: '门店名称'}
// , {field: 'model_number', title: '模型编号'}
// , {field: 'initial_name', title: '初始模型'}
// , {field: 'final_name', title: '最终模型'}
// , {field: 'pdf_name', title: 'PDF报告'}
, {field: 'status', title: '状态', templet: '#statusTpl', width: 80}
, {field: 'created_at_cn', title: '创建时间', width: 150}
, {title: '操作', fixed: 'right', toolbar: '#rowBarTpl', width: 240}
]
]
, url: '<?=\Yii::$app->urlManager->createUrl(['store/dev/index'])?>'
, page: true
//指向自定义工具栏模板选择器
, toolbar: '#toolBarTpl'
//头部工具栏右侧的图标按钮
, defaultToolbar: []
, limit: 20
, limits: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
, title: '<?=$this->title?>'
, data: []
, done: function (res, curr, count) {
setTimeout(function () {
$(".layui-table-main tr").each(function (index, val) {
$(".layui-table-fixed").each(function () {
$($(this).find(".layui-table-body tbody tr")[index]).height($(val).height());
});
});
$(".layui-table-header tr").each(function (index, val) {
$(".layui-table-fixed").each(function () {
$($(this).find(".layui-table-header thead tr")[index]).height($(val).height());
});
});
}, 500);
}
});
//监听工具条
table.on('tool(dtable)', function (obj) {
var row_data = obj.data;
var lay_event = obj.event;
var id = row_data.id;
var confirm_url = null;
var confirm_tip = null;
var ids = [];
ids.push(id);
if (lay_event == "delete") {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/delete'])?>";
confirm_tip = "确定删除此门店吗";
}
if (lay_event == "status_yes") {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-yes'])?>";
confirm_tip = "确定此门店变更为营业吗?";
}
if (lay_event == "status_no") {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-no'])?>";
confirm_tip = "确定此门店变更为停业吗?";
}
//if (lay_event == "find_qrcode") {
// confirm_url = "<?//=\Yii::$app->urlManager->createUrl(['store/report/edit'])?>//";
// confirm_tip = "确定上传报告吗?";
//}
if (lay_event == 'edit') {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/dev/edit'])?>" + "?id=" + id;
location.href = confirm_url;
return;
}
if (lay_event == "qrcode") {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/dev/qrcode'])?>";
confirm_tip = "确定查看此设备二维码吗?";
layer.closeAll()
layer.load(2);
return $.ajax(confirm_url, {
type: "POST",
dataType: "json",
data: {
ids: ids,
_csrf: _csrf
},
success: function (res) {
layer.closeAll('loading');
if (res.code == 0) {
var imgHtml = "<img src='" + res.data + "' width='500px' height='500px'/>";
//弹出层
layer.open({
type: 1,
shade: 0,
offset: 'auto',
area: 'auth',
shadeClose: true,
scrollbar: false,
title: "图片预览", //不显示标题
content: imgHtml, //捕获的元素注意最好该指定的元素要存放在body最外层否则可能被其它的相对元素所影响
});
} else {
layer.msg(res.msg, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
});
}
},
error: function (xhr, type, err) {
layer.closeAll('loading');
layer.msg(xhr.responseText, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
});
}
})
}
if (confirm_url != null) {
layer.confirm(confirm_tip, {
btn: ['确定', '取消']
}, function (index) {
layer.close(index)
$.ajax(confirm_url, {
type: "POST",
dataType: "json",
data: {
ids: ids,
_csrf: _csrf
},
success: function (res) {
if (res.code == 0) {
if (lay_event == 'find_qrcode') {
var imgHtml = "<img src='" + res.data + "' width='500px' height='500px'/>";
//弹出层
layer.open({
type: 1,
shade: 0,
offset: 'auto',
area: 'auth',
shadeClose: true,
scrollbar: false,
title: "图片预览", //不显示标题
content: imgHtml, //捕获的元素注意最好该指定的元素要存放在body最外层否则可能被其它的相对元素所影响
});
} else {
layer.msg(res.msg, {
offset: '15px'
, icon: 1
, time: 1000
}, function () {
location.reload();
});
}
} else {
layer.msg(res.msg, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
});
}
},
error: function (xhr, type, err) {
layer.msg(xhr.responseText, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
});
}
})
}, function () {
});
}
});
//监听工具栏
table.on('toolbar(dtable)', function (obj) {
var lay_event = obj.event;
var check_status = table.checkStatus('dtable');
var ids = [];
$(check_status.data).each(function (index) {
ids.push(check_status.data[index]['id']);
});
if (lay_event == 'batch_qrcode') {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/dev/batch-qrcode'])?>";
location.href = confirm_url;
return;
}
if (ids.length == 0) {
return layer.msg("请选择需要操作项");
}
var confirm_url = null;
var confirm_tip = null;
if (lay_event == 'batch_delete') {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/delete'])?>";
confirm_tip = "确定将选中门店删除吗";
}
if (lay_event == 'batch_status_yes') {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-yes'])?>";
confirm_tip = "确定将选中门店变更为营业吗";
}
if (lay_event == 'batch_status_no') {
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-no'])?>";
confirm_tip = "确定将选中门店变更为停业吗";
}
if (confirm_url != null) {
layer.confirm(confirm_tip, {
btn: ['确定', '取消']
}, function () {
$.ajax(confirm_url, {
type: "POST",
dataType: "json",
data: {
ids: ids,
_csrf: _csrf
},
success: function (res) {
if (res.code == 0) {
layer.msg(res.msg, {
offset: '15px'
, icon: 1
, time: 1000
}, function () {
location.reload();
});
} else {
layer.msg(res.msg, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
});
}
},
error: function (xhr, type, err) {
layer.msg(xhr.responseText, {
offset: '15px'
, icon: 2
, time: 1000
}, function () {
});
}
})
}, function () {
});
}
});
form.on('select(province)', function (res) {
app.province_id = res.value;
$(app.province).each(function (i) {
if (app.province[i].id == app.province_id) {
app.city = app.province_id != 0 ? app.province[i].list : [];
//app.city_id = app.province_id != 0 ? app.province[i].list[0]['id'] : 0;
app.area = app.province_id != 0 ? app.city[0].list : [];
//app.area_id = app.province_id != 0 ? app.city[0].list[0]['id'] : 0;
app.province_id = app.province_id == 0 ? '' : app.province_id;
app.$forceUpdate();
setTimeout(function () {
form.render('select');
}, 500);
return true;
}
});
});
form.on('select(city)', function (res) {
app.city_id = res.value;
$(app.city).each(function (i) {
if (app.city[i].id == app.city_id) {
app.area = app.city[i].list;
//app.area_id = app.city[i].list[0]['id'];
app.$forceUpdate();
setTimeout(function () {
form.render('select');
}, 500);
return true;
}
});
});
form.on('select(area)', function (res) {
app.area_id = res.value;
setTimeout(function () {
form.render('select');
}, 500);
});
});
function previewImg(obj) {
var img = new Image();
img.src = obj.src;
var imgw = img.width;
var imgh = img.height;
var img_th = imgh / imgw * 500;
var imgHtml = "<img src='" + obj.src + "' width='500px' height='" + img_th + "px'/>";
//弹出层
layer.open({
type: 1,
shade: 0.8,
offset: 'auto',
area: [500 + 'px', (img_th + 50) + 'px'],
shadeClose: true,
scrollbar: false,
title: "图片预览", //不显示标题
content: imgHtml, //捕获的元素注意最好该指定的元素要存放在body最外层否则可能被其它的相对元素所影响
cancel: function () {
//layer.msg('捕获就是从页面已经存在的元素上包裹layer的结构', { time: 5000, icon: 6 });
}
});
}
<?php $this->endBlock(); ?>
</script>
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>

View File

@ -23,7 +23,7 @@ use app\components\SiteHelper;
<img src="<?= SiteHelper::getSiteMiniLogo() ?>" alt="<?= SiteHelper::getSiteShortName() ?>"
style="width:100px;height: 100px;border-radius: 100px">
</h2>
<p>场地管理员管理系统</p>
<p>门店管理系统</p>
</div>
<div class="layadmin-user-login-box layadmin-user-login-body layui-form">
<div class="layui-form-item">

View File

@ -79,7 +79,14 @@ $this->params['breadcrumbs'][] = $this->title;
<!--行操作列模板-->
<script type="text/html" id="rowBarTpl">
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">模型上传</button>
{{# if(d.user_type == 1){ }}
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">初始模型上传</button>
{{# } }}
{{# if(d.user_type == 3){ }}
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">最终模型上传</button>
{{# } }}
{{# if(d.initial_path){ }}