liche update for admin licheb edit biz auto city

This commit is contained in:
xxb
2021-09-14 16:57:40 +08:00
parent a0029a9441
commit 01b96d2527
5 changed files with 247 additions and 32 deletions
+34 -18
View File
@@ -74,21 +74,35 @@ class Member extends HD_Controller{
{
$id = $this->input->get('id');
$row = $this->userM->get(['id'=>$id]);
$bizs = $this->biz_model->select(['status>='=>0],'id desc','','','id,biz_name');
$this->data['bizs'] = $bizs;
$this->data['row'] = $row;
if($id){
$info = array(
'id' => $row['id'],
'uname' => $row['uname'],
'mobile' => $row['mobile'],
'group_id' => $row['group_id'],
'biz_id' => $row['biz_id'],
);
$action = '/app/licheb/member/edit';
$_title = '编辑用户';
} else {
$info = array('biz_id' => '', 'group_id' => '');
$action = '/app/licheb/member/add';
$_title = '添加用户';
}
$this->data['info'] = $info;
$this->data['groups'] = $this->groups;
$this->data['_title'] = $row ? '编辑用户' : '添加用户';
$this->data['action'] = $action;
$this->data['_title'] = $_title;
return $this->show_view('app/licheb/member/get');
}
//添加单条数据
public function add(){
$uname = $this->input->post('uname');
$mobile = $this->input->post('mobile');
$group_id = $this->input->post('group_id');
$biz_id = $this->input->post('biz_id');
$info = $this->input->post('info');
$uname = $info['uname'];
$mobile = $info['mobile'];
$group_id = $info['group_id'];
$biz_id = $info['biz_id'];
if (!mobile_valid($mobile)) {
return $this->show_json(SYS_CODE_FAIL, '输入正确手机号');
@@ -112,18 +126,19 @@ class Member extends HD_Controller{
$biz_id && $add['biz_id'] = $biz_id;
$id = $this->userM->add($add);
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
return $this->show_json(SYS_CODE_SUCCESS, '操作成功', '/app/licheb/member');
}
//编辑单条数据
public function edit()
{
$id = $this->input->post('id');
$uname = $this->input->post('uname');
$nickname = $this->input->post('nickname');
$mobile = $this->input->post('mobile');
$group_id = $this->input->post('group_id');
$biz_id = $this->input->post('biz_id');
$info = $this->input->post('info');
$id = $info['id'];
$uname = $info['uname'];
$nickname = $info['nickname'];
$mobile = $info['mobile'];
$group_id = $info['group_id'];
$biz_id = $info['biz_id'];
if (!mobile_valid($mobile)) {
return $this->show_json(SYS_CODE_FAIL, '输入正确手机号');
@@ -138,8 +153,9 @@ class Member extends HD_Controller{
'mobile' => $mobile,
);
$group_id && $upd['group_id'] = $group_id;
$biz_id && $upd['biz_id'] = $biz_id;
$upd['group_id'] = $group_id ? $group_id : 0;
$upd['biz_id'] = $biz_id ? $biz_id : 0;
$nickname && $upd['nickname'] = $nickname;
$uname && $upd['uname'] = $uname;
+19
View File
@@ -854,6 +854,25 @@ class Store extends HD_Controller{
return $this->show_json(SYS_CODE_SUCCESS);
}
/**
* 获取店铺信息
* @return bool
*/
function json_get(){
$id = $this->input->post('id');
$row = $this->biz_model->get(array('id' => $id));
$info = array(
'id' => $row['id'],
'title' => $row['biz_name'],
'city_id' => $row['city_id'],
'county_id' => $row['county_id'],
);
$this->data = $info;
return $this->show_json(SYS_CODE_SUCCESS);
}
/**
* 获取用户信息(不存在新增,可以修改名称)
* @param $mobile
+193 -13
View File
@@ -1,41 +1,221 @@
<form id="vue-app" class="am-form am-form-horizontal" action="/app/licheb/member/<?=$row['id'] ? 'edit' : 'add'?>" data-auto="true" method="post" style="width: 90%;padding-top: 10px">
<form id="vue-edit" class="am-form am-form-horizontal" action="<?=$action?>" data-auto="true" method="post" style="width: 90%;padding-top: 10px">
<input type="hidden" name="id" value="<?=$row['id']?>"/>
<div class="am-form-group">
<label class="am-para-label">姓名:</label>
<div class="am-para-input w300">
<input type="text" placeholder="输入姓名" name="uname" value="<?=$row['uname']?>" maxlength="30"/>
<input type="text" placeholder="输入姓名" name="uname" v-model="info.uname" maxlength="30"/>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">手机号:</label>
<div class="am-para-input w300">
<input type="text" placeholder="输入手机号" name="mobile" value="<?=$row['mobile']?>" maxlength="30"/>
<input type="text" placeholder="输入手机号" name="mobile" v-model="info.mobile" maxlength="30"/>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">角色:</label>
<div class="am-para-input w100">
<select name="group_id">
<?foreach($groups as $key=>$val){?>
<option value="<?=$key?>" <?=$key==$row['group_id']?'selected':''?>><?=$val?></option>
<?}?>
<select name="group_id" v-model="info.group_id">
<option value="">选择角色</option>
<option :value="i" v-for="(v,i) in groups">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">门店:</label>
<div class="am-para-input w300">
<select name="biz_id">
<?foreach($bizs as $key=>$val){?>
<option value="<?=$val['id']?>" <?=$val['id']==$row['biz_id']?'selected':''?>><?=$val['biz_name']?></option>
<?}?>
<div class="am-para-inline w120">
<select title="城市" v-model="biz.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in biz.cityAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select title="行政区" v-model="biz.county_id">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in biz.countyAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w200">
<select name="biz_id" v-model="biz.biz_id">
<option value="">门店</option>
<template v-for="(v,i) in biz.bizAry">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<div class="am-para-input"><button class="am-btn am-btn-success" type="submit">提交</button></div>
<div class="am-para-input"><button class="am-btn am-btn-success" type="button" @click='saveEdit'>提交</button></div>
</div>
</form>
<script type="text/javascript">
var vue_app;
var loading = false;
$(function(){
vue_app = new Vue({
el: '#vue-edit',
data: {
info:{},
groups:[],
biz: {cityAry: [], countyAry: [], bizAry: [], city_id: '', county_id: '', biz_id: ''}
},
computed: {},
created: function () {
},
updated: function () {
},
mounted:function() {
var vm = this;
vm.info = <?=json_encode($info, JSON_UNESCAPED_UNICODE)?>;
vm.groups = <?=json_encode($groups, JSON_UNESCAPED_UNICODE)?>;
vm.init_biz();
},
methods: {
init_biz:function() {
var vm = this;
vm.biz.biz_id = vm.info.biz_id;
//初始化获取城市列表
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: '350',
key: 'city',
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.biz.cityAry = response.data;
}
}
});
//获取店铺信息
if(vm.biz.biz_id > 0){
$.ajax({
type: 'post',
url: '/biz/store/store/json_get',
dataType: 'json',
data: {
id: vm.biz.biz_id
},
success:function(response){
if (response.code == 1) {
if(response.data.id>0){
vm.biz.city_id = response.data.city_id;
vm.biz.county_id = response.data.county_id;
}
}
}
});
}
},
saveEdit: function () {
if (loading) {
return;
}
var vm = this;
loading = true;
$.ajax({
url: '<?=$action?>',
type: 'post',
dataType: 'json',
data: {
info: vm.info
},
beforeSend: function () {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
},
success: function (data) {
loading = false;
if (data.code) {
layer.msg(data.msg, {
icon: 1,
time: 2000
}, function () {
window.location.reload();
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
loading = false;
layer.closeAll('loading');
}
});
}
},
watch:{
'biz.city_id':function(nv, ov){
var that = this;
if(nv == ''){
that.biz.countyAry = [];
that.biz.county_id = '';
} else {
if(nv.substring(0,4) != that.biz.county_id.substring(0, 4)){
that.biz.county_id = '';
}
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
key:'county',
type:1
},
success:function(response){
if (response.code == 1) {
that.biz.countyAry = response.data;
}
}
});
}
},
'biz.county_id':function(nv, ov){
var that = this;
if(nv == ''){
that.biz.bizAry = [];
that.biz.biz_id = '';
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.biz.city_id,
county_id: that.biz.county_id,
status:1
},
success:function(response){
if (response.code == 1) {
that.biz.bizAry = response.data.list;
if(that.biz.biz_id>0){
var biz_id = '';
for(var i in that.biz.bizAry){
if(that.biz.biz_id == that.biz.bizAry[i].id){
biz_id = that.biz.biz_id;
break;
}
}
that.biz.biz_id = biz_id;
}
}
}
});
}
},
'biz.biz_id':function(nv, ov){
var vm = this;
vm.info.biz_id = nv;
}
}
});
});
</script>
-1
View File
@@ -156,7 +156,6 @@
that.bizAry = [];
that.params.biz_id = '';
}
console.log(that.bizAry);
}
},
watch:{
+1
View File
@@ -826,6 +826,7 @@ $(function () {
window.location.href = this.options[this.selectedIndex].getAttribute('data-url');
});
/*! 选择框联动 */
$body.on('change','[data-toggle="next-select"]',function () {
var refurl = $(this).data('refurl');
var next = $(this).data('next');