提交 23693b09 编写于 作者: D devil_gong

应用

上级 2936ddf9
......@@ -83,8 +83,8 @@ class Pets extends Controller
);
$data = Service::PetsList($data_params);
$this->assign('data_list', $data['data']);
//print_r($data['data']);
$this->assign('pets_attribute_status_list', Service::$pets_attribute_status_list);
$this->assign('pets_attribute_is_text_list', Service::$pets_attribute_is_text_list);
$this->assign('pets_attribute_gender_list', Service::$pets_attribute_gender_list);
$this->assign('pets_attribute_type_list', Service::$pets_attribute_type_list);
......@@ -101,7 +101,22 @@ class Pets extends Controller
*/
public function saveinfo($params = [])
{
$this->assign('data', []);
// 获取数据
$data = [];
if(!empty($params['id']))
{
$data_params = array(
'm' => 0,
'n' => 1,
'where' => ['id' => intval($params['id'])],
);
$ret = Service::PetsList($data_params);
$data = empty($ret['data'][0]) ? [] : $ret['data'][0];
unset($params['id']);
}
$this->assign('data', $data);
$this->assign('params', $params);
$this->assign('pets_attribute_status_list', Service::$pets_attribute_status_list);
$this->assign('pets_attribute_is_text_list', Service::$pets_attribute_is_text_list);
$this->assign('pets_attribute_gender_list', Service::$pets_attribute_gender_list);
$this->assign('pets_attribute_type_list', Service::$pets_attribute_type_list);
......
......@@ -41,6 +41,14 @@ class Service
1 => ['value' => 1, 'name' => '母'],
];
// 状态(0正常, 1丢失, 2去世, 3关闭)
public static $pets_attribute_status_list = [
0 => ['value' => 0, 'name' => '正常'],
1 => ['value' => 1, 'name' => '丢失'],
2 => ['value' => 2, 'name' => '去世'],
3 => ['value' => 3, 'name' => '关闭'],
];
/**
* 宠物列表
* @author Devil
......@@ -75,6 +83,9 @@ class Service
// 是否疫苗
$v['vaccine_name'] = self::$pets_attribute_is_text_list[$v['vaccine']]['name'];
// 状态
$v['status_name'] = self::$pets_attribute_status_list[$v['status']]['name'];
// 生日/年龄
if(empty($v['birthday']))
{
......@@ -92,6 +103,9 @@ class Service
// 相册
$v['photo'] = empty($v['photo']) ? null : self::GetPestPhotoHandle($v['photo']);
// 二维码
$v['qrcode_url'] = MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode(MyUrl('index/goods/index', ['id'=>$v['id']], true, true)))]);
// 时间
$v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']);
$v['add_time_date'] = date('Y-m-d', $v['add_time']);
......@@ -114,8 +128,12 @@ class Service
private static function GetPestPhotoHandle($photo)
{
$result = [];
if(!empty($photo) && is_array($photo))
if(!empty($photo))
{
if(is_string($photo))
{
$photo = json_decode($photo, true);
}
foreach($photo as &$v)
{
$result[] = [
......@@ -161,6 +179,10 @@ class Service
{
$where[] = ['type', '=', $params['type']];
}
if(isset($params['status']) && $params['status'] > -1)
{
$where[] = ['status', '=', intval($params['status'])];
}
if(isset($params['gender']) && $params['gender'] > -1)
{
$where[] = ['gender', '=', intval($params['gender'])];
......@@ -327,8 +349,31 @@ class Service
'person_weixin' => isset($params['person_weixin']) ? $params['person_weixin'] : '',
];
// 绑定编号
$edit_msg_title = '编辑';
if(empty($params['id']) && !empty($params['pest_no']))
{
$pets = Db::name('PluginsPetscmsPets')->where(['pest_no'=>$params['pest_no']])->field('id,pest_no,user_id')->find();
if(empty($pets))
{
return DataReturn('宠物编号不存在['.$params['pest_no'].']', -10);
}
// 是否被其他用户绑定
if(!empty($pets['user_id']))
{
return DataReturn('宠物编号已被绑定['.$params['pest_no'].']', -11);
}
// 使用编辑模式
$params['id'] = $pets['id'];
$edit_msg_title = '绑定';
}
// 添加/编辑
if(empty($params['id']))
{
$data['pest_no'] = date('YmdHis').GetNumberCode(6);
$data['add_time'] = time();
if(Db::name('PluginsPetscmsPets')->insertGetId($data) > 0)
{
......@@ -339,9 +384,9 @@ class Service
$data['upd_time'] = time();
if(Db::name('PluginsPetscmsPets')->where(['id'=>intval($params['id'])])->update($data))
{
return DataReturn('编辑成功', 0);
return DataReturn($edit_msg_title.'成功', 0);
}
return DataReturn('编辑失败', -100);
return DataReturn($edit_msg_title.'失败', -100);
}
}
......
......@@ -42,7 +42,7 @@
<td>
<span>类型:</span>
<select name="type" class="chosen-select" data-placeholder="宠物类型...">
<option value="-1">宠物类型...</option>
<option value="">宠物类型...</option>
{{if !empty($pets_attribute_type_list)}}
{{foreach $pets_attribute_type_list as $v}}
<option value="{{$v.value}}" {{if isset($params['type']) and $params['type'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
......@@ -51,12 +51,12 @@
</select>
</td>
<td>
<span>性别</span>
<select name="gender" class="chosen-select" data-placeholder="宠物性别...">
<option value="-1">宠物性别...</option>
{{if !empty($pets_attribute_gender_list)}}
{{foreach $pets_attribute_gender_list as $v}}
<option value="{{$v.value}}" {{if isset($params['gender']) and $params['gender'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
<span>状态</span>
<select name="status" class="chosen-select" data-placeholder="宠物状态...">
<option value="-1">宠物状态...</option>
{{if !empty($pets_attribute_status_list)}}
{{foreach $pets_attribute_status_list as $v}}
<option value="{{$v.value}}" {{if isset($params['status']) and $params['status'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
{{/if}}
</select>
......@@ -74,6 +74,20 @@
{{/if}}
</select>
</td>
<td>
<span>性别:</span>
<select name="gender" class="chosen-select" data-placeholder="宠物性别...">
<option value="-1">宠物性别...</option>
{{if !empty($pets_attribute_gender_list)}}
{{foreach $pets_attribute_gender_list as $v}}
<option value="{{$v.value}}" {{if isset($params['gender']) and $params['gender'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
{{/if}}
</select>
</td>
</tr>
<tr>
<td></td>
<td>
<button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example" data-am-loading="{spinner:'circle-o-notch', loadingText:'搜索中...'}">搜索</button>
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'index')}}" class="am-btn am-btn-warning am-radius am-btn-sm reset-submit">清除条件</a>
......@@ -85,7 +99,7 @@
<!-- operation start -->
<div class="am-g operation-nav">
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'saveinfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus"> 新增</a>
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'saveinfo')}}" class="am-btn am-btn-primary am-radius am-btn-xs am-icon-plus"> 新增 / 绑定</a>
</div>
<!-- operation end -->
......@@ -94,15 +108,12 @@
<table class="am-table">
<thead>
<tr>
<th>标题</th>
<th>姓名</th>
<th>类型</th>
<th class="am-hide-sm-only">性别</th>
<th class="am-hide-sm-only">品种</th>
<th class="am-hide-sm-only">是否绝育</th>
<th class="am-hide-sm-only">是否疫苗</th>
<th class="am-hide-sm-only">生日/年龄</th>
<th class="am-hide-sm-only">时间</th>
<th class="am-hide-sm-only">标题/相册</th>
<th>宠物信息</th>
<th class="am-hide-sm-only">主人信息</th>
<th class="am-hide-sm-only">二维码</th>
<th>状态</th>
<th class="am-hide-sm-only">操作时间</th>
<th>操作</th>
</tr>
</thead>
......@@ -110,29 +121,68 @@
{{if !empty($data_list)}}
{{foreach $data_list as $v}}
<tr>
<td>{{$v.title}}</td>
<td>{{$v.name}}</td>
<td>{{$v.type_name}}</td>
<td class="am-hide-sm-only">{{$v.gender_name}}</td>
<td class="am-hide-sm-only">{{$v.varieties}}</td>
<td class="am-hide-sm-only">{{$v.sterilization_name}}</td>
<td class="am-hide-sm-only">{{$v.vaccine_name}}</td>
<td class="am-hide-sm-only row-first">
<p class="ellipsis">{{$v.title}}</p>
{{if !empty($v['photo'])}}
<div data-am-widget="slider" class="am-slider am-slider-a1" data-am-slider='{"directionNav":false, "slideshow":false}' >
<ul class="am-slides">
{{foreach $v.photo as $photo}}
<li>
<img src="{{$photo.images}}" />
</li>
{{/foreach}}
</ul>
</div>
{{/if}}
</td>
<td>
编号:{{if empty($v['pest_no'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.pest_no}}{{/if}}<br />
名字:{{if empty($v['name'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.name}}{{/if}}<br />
类型:{{if empty($v['type_name'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.type_name}}{{/if}}<br />
性别:{{if empty($v['gender_name'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.gender_name}}{{/if}}<br />
生日:{{if empty($v['birthday_name'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.birthday_name}}{{/if}}<br />
年龄:{{if empty($v['age'])}}<span class="items-value-empty">未填写</span>{{else /}}<span class="am-badge am-radius">{{$v.age}}</span>{{/if}}<br />
品种:{{if empty($v['varieties'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.varieties}}{{/if}}<br />
绝育:{{$v.sterilization_name}}<br />
疫苗:{{$v.vaccine_name}}<br />
</td>
<td class="am-hide-sm-only">
姓名:{{if empty($v['person_name'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.person_name}}{{/if}}<br />
电话:{{if empty($v['person_tel'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.person_tel}}{{/if}}<br />
微信:{{if empty($v['person_weixin'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.person_weixin}}{{/if}}<br />
</td>
<td class="am-hide-sm-only row-qucode">
<img src="{{$v.qrcode_url}}" alt="{{$v.title}}" />
<a href="#">
<p><i class="am-icon-cloud-download"></i> 下载二维码</p>
</a>
</td>
<td>{{$v.status_name}}</td>
<td class="am-hide-sm-only">
{{if !empty($v['birthday_name'])}}
{{$v.birthday_name}}<br />
添加:{{$v.add_time_time}}
{{if !empty($v['upd_time_time'])}}
<br />更新:{{$v.upd_time_time}}
{{/if}}
<span class="am-badge am-radius">{{$v.age}}</span>
</td>
<td class="am-hide-sm-only">{{$v.add_time_time}}</td>
<td>
edit
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'saveinfo',array_merge($params, ['id'=>$v['id']]))}}" class="am-btn am-btn-secondary am-btn-xs am-radius am-icon-edit am-btn-block"> 编辑</a>
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'saveinfo',array_merge($params, ['id'=>$v['id']]))}}" class="am-btn am-btn-success am-btn-xs am-radius am-icon-newspaper-o am-btn-block"> 详情</a>
</td>
</tr>
{{/foreach}}
{{/if}}
{{if empty($data_list)}}
<tr>
<td colspan="10">
<td colspan="7">
<div class="table-no"><i class="am-icon-warning"></i> 没有相关数据</div>
</td>
</tr>
......
此差异已折叠。
......@@ -737,7 +737,7 @@ background:url(../images/ibar_sprites.png) no-repeat;background-position:0px -23
/**
* 用户中心布局样式
* 用户中心左侧菜单
*/
.user-menu {position:fixed;z-index:10;bottom:70px;right:10px;}
.user-sidebar {width:145px;min-height:100%;float:left;}
......@@ -817,4 +817,22 @@ button { outline: none !important; }
padding: 5px 8px;
border-radius: 3px;
border: 1px solid #ffd4d4;
}
/**
* 公共
*/
legend {
padding-bottom: 0.2rem;
margin-bottom: 1rem;
border-bottom: 1px solid #e5e5e5;
}
legend .legend-title {
font-size: 14px;
}
legend a {
color: #e7747f;
}
.items-value-empty {
color: #999;
}
\ No newline at end of file
......@@ -10,7 +10,7 @@
.time i { position:absolute; margin:4px 0px 0px -15px; }
.price input { width:101px !important; }
.time, .time { width:50%; }
.so-list tr+tr>td:first-child { padding-top:10px; }
.so-list tr+tr>td { padding-top:10px; }
.so-list .chosen-container { border-radius:2px; }
.text-grey { color: #999; }
.chosen-container-single .chosen-single, .so-list select { height: 28px; line-height: 28px; width: 100%; }
......
.user-content-body legend {
padding-bottom: 0.2rem;
margin-bottom: 1rem;
border-bottom: 1px solid #e5e5e5;
}
.user-content-body .legend-title {
font-size: 16px;
}
.user-content-body a {
.user-content-body .dl-content a {
color: #e7747f;
}
.user-content-body .items-value-empty {
color: #999;
}
.user-content-body .span-edit {
margin-left: 15px;
}
\ No newline at end of file
......@@ -10,7 +10,7 @@
.time i { position:absolute; margin:4px 0px 0px -15px; }
.price input { width:101px !important; }
.time, .time { width:50%; }
.so-list tr+tr>td:first-child { padding-top:10px; }
.so-list tr+tr>td { padding-top:10px; }
.so-list .chosen-container { border-radius:2px; }
.text-grey { color: #999; }
.chosen-container-single .chosen-single, .so-list select { height: 28px; line-height: 28px; width: 100%; }
......
......@@ -10,13 +10,20 @@
.time i { position:absolute; margin:4px 0px 0px -15px; }
.price input { width:101px !important; }
.time, .time { width:50%; }
.so-list tr+tr>td:first-child { padding-top:10px; }
.so-list tr+tr>td { padding-top:10px; }
.so-list .chosen-container { border-radius:2px; }
.text-grey { color: #999; }
.chosen-container-single .chosen-single, .so-list select { height: 28px; line-height: 28px; width: 100%; }
.reset-submit { margin-left: 20px; }
.so-list select { padding: 0 0 0 8px; }
.operation-nav { margin-top: 15px; }
.operation-nav { margin: 15px 0 10px 0; }
.row-qucode img { max-width: 100px; }
.row-qucode p { margin-top: 5px; }
.row-qucode a:hover, .row-qucode a:focus { text-decoration: none; }
.row-first { width: 20%; }
.row-first p { font-weight: 500; max-width: 240px; }
.row-first .am-slider { max-height: 130px; }
.am-slider .am-slides img { width: auto; max-height: 100%; margin: 0 auto; }
@media only screen and (min-width: 641px){
.so-list .chosen-container, .so-list select { width:217px !important; display: -webkit-inline-box; }
.thin_sub:hover { color:#F60; }
......@@ -35,4 +42,30 @@
/**
* 添加/编辑页面
*/
.person-view .am-form-group:last-child {border-bottom: 0; }
\ No newline at end of file
.base-view .am-form-group:last-child, .person-view .am-form-group:last-child, .lose-view .am-form-group:last-child {border-bottom: 0; }
form.form-validation h2 { font-weight: 700; font-size: 14px; }
form.form-validation .am-divider { margin: 10px auto; }
.lose-view { margin-top: 30px; }
form.form-validation .am-alert-secondary { background-color: #f8f8f8; }
form.form-validation .am-alert-warning { background-color: #fffbf7; }
/**
* 地图、联动地址
*/
form.form-validation .map-address {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 10px;
}
form.form-validation .region-linkage .chosen-select {
display: -webkit-inline-box;
width: calc(33.3% - 3px) !important;
}
form.form-validation .region-linkage .chosen-select .chosen-single {
width: 100%;
}
form.form-validation #map {
width: 100%;
height: 350px;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册