添加:典藏室 - 画列表管理

This commit is contained in:
wuhui_zzw 2023-09-28 11:04:53 +08:00
parent 1cd0371198
commit 0973536e64
21 changed files with 1077 additions and 1 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
## 典藏室管理

View File

@ -0,0 +1,14 @@
<?php
return [
app\common\events\PluginWasEnabled::class => function ($plugins) {
\Artisan::call('migrate',['--path'=>'plugins/collection-room/migrations','--force'=>true]);
},
app\common\events\PluginWasDisabled::class => function ($plugin) {
},
app\common\events\PluginWasDeleted::class => function () {
\Artisan::call('migrate:rollback',['--path'=>'plugins/collection-room/migrations']);
}
];

View File

@ -0,0 +1,8 @@
"use strict";
$.extend($.locales['en'], {
'welfare': {
test: "JavaScript i18n test: English"
}
});

View File

@ -0,0 +1,5 @@
<?php
return [
'title'=>'this is test title'
];

View File

@ -0,0 +1,6 @@
$.extend($.locales['zh-CN'], {
'welfare': {
test: "JavaScript i18n test: 简体中文"
}
});

View File

@ -0,0 +1,5 @@
<?php
return [
'title'=>'测试标题'
];

View File

@ -0,0 +1,11 @@
{
"name": "collection-room",
"terminal": "wechat|min|wap",
"version": "1.0.1",
"title": "典藏室",
"description": "典藏室",
"author": "zzw",
"url": "",
"namespace": "Yunshop\\CollectionRoom",
"config": "config.tpl"
}

View File

@ -0,0 +1,92 @@
<?php
namespace Yunshop\CollectionRoom;
class PluginApplication extends \app\common\services\PluginApplication{
protected function setMenuConfig(){
\app\backend\modules\menu\Menu::current()->setPluginMenu('collection-room', [
'name' => '典藏室',
'type' => 'marketing',
'url' => 'plugin.collection-room.admin.index.index',// url 可以填写http 也可以直接写路由
'url_params' => '',//如果是url填写的是路由则启用参数否则不启用
'permit' => 1,//如果不设置则不会做权限检测
'menu' => 1,//如果不设置则不显示菜单,子菜单也将不显示
'icon' => '',//菜单图标
'list_icon' => 'collection-room',
'parents' => [],
'top_show' => 0,
'left_first_show' => 0,
'left_second_show' => 1,
'child' => [
'plugin_collection_room_index' => [
'name' => '画列表',
'permit' => 1,
'menu' => 1,
'icon' => '',
'url' => 'plugin.collection-room.admin.index.index',
'url_params' => '',
'item' => 'plugin_collection_room_index',
'parents' => ['collection-room'],
'child' => [
// 权限补充
'plugin_collection_room_index_index' => [
'name' => '画列表',
'url' => 'plugin.collection-room.admin.index.index',
'url_params' => '',
'permit' => 1,
'menu' => 0,
'icon' => '',
'item' => 'plugin_collection_room_index_index',
'parents' => ['collection-room','plugin_collection_room_index']
],
'plugin_collection_room_index_editinfo' => [
'name' => '画编辑',
'url' => 'plugin.collection-room.admin.index.editInfo',
'url_params' => '',
'permit' => 1,
'menu' => 0,
'icon' => '',
'item' => 'plugin_collection_room_index_editinfo',
'parents' => ['collection-room','plugin_collection_room_index']
],
]
],
'plugin_collection_room_set' => [
'name' => '基本设置',
'permit' => 1,
'menu' => 1,
'icon' => '',
'url' => 'plugin.collection-room.admin.index.set',
'url_params' => '',
'parents' => ['collection-room'],
'child' => [
// 权限补充
'plugin_collection_room_index_set' => [
'name' => '基本设置',
'url' => 'plugin.collection-room.admin.index.set',
'url_params' => '',
'permit' => 1,
'menu' => 0,
'icon' => '',
'item' => 'plugin_collection_room_index_set',
'parents' => ['collection-room', 'plugin_collection_room_set'],
],
]
],
]
]);
}
public function boot(){
$events = app('events');
}
}

View File

@ -0,0 +1,106 @@
<?php
namespace Yunshop\CollectionRoom\admin;
use app\common\components\BaseController;
use app\common\facades\Setting;
use app\common\helpers\PaginationHelper;
use app\common\helpers\Url;
use Yunshop\CollectionRoom\models\CollectionRoomModel;
class IndexController extends BaseController{
/**
* Common: 进入列表
* Author: wu-hui
* Time: 2023/09/28 9:24
* @return array|string
* @throws \Throwable
*/
public function index(){
//参数获取
$pageSize = request()->input('page_size',10);
$search = request()->input('search');
// 获取列表信息
$field = ['id','member_id','unique_number','created_at'];
$result = CollectionRoomModel::getList($pageSize,$search,$field);
$data = [
'list' => $result['data'],
'pager' => PaginationHelper::show($result['total'],$result['current_page'],$result['per_page']),
'search' => $search
];
return view('Yunshop\CollectionRoom::index.index',$data)->render();
}
/**
* Common: 修改唯一编号
* Author: wu-hui
* Time: 2023/09/28 10:07
* @return array|\Illuminate\Http\JsonResponse|string
* @throws \Throwable
*/
public function updateNumber(){
// 参数获取
$id = request()->input('id');
$uniqueNumber = (int)request()->input('unique_number');
$isSubmit = (int)request()->input('is_submit');
// 判断:是否为提交信息
if($isSubmit == 1){
if($uniqueNumber <= 0 || $uniqueNumber > 5000) return $this->errorJson('编号必须大于0且小于5000!');
try{
// 判断:当前编号是否已经存在
$isHas = (int)CollectionRoomModel::uniacid()
->where('unique_number',$uniqueNumber)
->where('id','!=',$id)
->value('id');
if($isHas > 0) return $this->errorJson('该编号已经存在,请勿重复设置!');
// 修改内容
CollectionRoomModel::uniacid()
->where('id',$id)
->update([
'unique_number' => $uniqueNumber
]);
return $this->successJson('操作成功');
}catch(\Exception $e){
return $this->errorJson($e->getMessage());
}
}
// 获取信息
$result = CollectionRoomModel::uniacid()
->where('id',$id)
->with([
'member' => function($query){
$query->select(['uid','nickname','realname','avatar']);
}
])
->first();
return view('Yunshop\CollectionRoom::index.update_number',[
'id' => $id,
'info' => $result
])->render();
}
// 基本设置
public function set(){
// 获取设置信息 判断是否为设置
$setInfo = request()->input('collection_room');
if ($setInfo) {
// 设置信息
if (Setting::set('plugin.collection_room', $setInfo)) return $this->message('设置成功', Url::absoluteWeb('plugin.collection-room.admin.index.set'));
else $this->error('设置失败');
}else{
// 获取信息
$set = Setting::get('plugin.collection_room');
return view('Yunshop\CollectionRoom::index.set',[
'set' => $set,
])->render();
}
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/3/18
* Time: 14:27
*/
namespace Yunshop\CollectionRoom\models;
use app\common\models\BaseModel;
use app\common\models\Member;
class CollectionRoomModel extends BaseModel{
public $table = 'yz_collection_room';
public $timestamps = false;
public $casts = [
'created_at' => 'datetime:Y-m-d H:i:s'
];
protected $fillable = [
'uniacid',
'member_id',
'unique_number',
'created_at',
];
/**
* Common: 列表信息获取
* Author: wu-hui
* Time: 2023/09/28 9:18
* @param $pageSize
* @param $search
* @param string[] $field
* @return array
*/
public function getList($pageSize,$search,$field = ['*']){
// 条件生成
$where = [];
if($search['member_id'] > 0) $where[] = ['member_id','=',$search['member_id']];
// 列表获取
$model = self::uniacid()
->select($field)
->where($where)
->when(!empty($search['nickname']),function($query) use ($search){
// 合伙人 昵称|真实姓名搜索
$ids = Member::where('nickname','like',"%{$search['nickname']}%")
->orwhere('realname','like',"%{$search['nickname']}%")
->pluck('uid');
if($ids) $ids = $ids->toArray();
$query->whereIn('member_id',(array)$ids);
})
->with([
'member' => function($query){
$query->select(['uid','nickname','realname','avatar']);
}
])
->orderBy('unique_number','ASC')
->orderBy('created_at','DESC')
->orderBy('id','DESC');
$list = $model->paginate($pageSize);
return $list ? $list->toArray() : [];
}
/**
* Common: 给指定用户添加一幅画
* Author: wu-hui
* Time: 2023/09/27 18:57
* @param $memberId
*/
public static function addInfo($memberId){
// 判断:当前用户是否已经持有 未持有赠送 持有则不管
$isHas = (int)self::uniacid()->where('member_id',$memberId)->value('id');
if($isHas <= 0){
self::insert([
'uniacid' => \YunShop::app()->uniacid,
'member_id' => $memberId,
'created_at' => time()
]);
}
}
/**
* Common: 一对一关联 - 用户信息表
* Author: wu-hui
* Time: 2023/09/28 9:18
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function member(){
return $this->hasOne(Member::class, 'uid', 'member_id');
}
}

View File

View File

@ -0,0 +1,118 @@
<script src="{!!resource_absolute('static/js/xlsx.full.min.js')!!}"></script>
@extends('layouts.base')
<style>
.user{
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
overflow: hidden;
height: 80px;
}
.user .user-avatar{
height: 50px;
width: 50px;
margin-right: 5px;
border-radius: 50%;
overflow: hidden;
}
.user .user-avatar .avatar-image{
width: 100% !important;
height: 100% !important;
}
.user .user-info{
height: 50px;
text-align: left;
}
.user .user-info .user-nickname{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.user .user-info .user-status{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
@section('content')
<div class="w1200 m0a" id="storeManagerIndex">
{{--顶部搜索--}}
<div class="panel panel-info">
<div class="panel-body">
<form action="" method="post" class="form-horizontal" role="form" id="form1">
<div class="form-group">
<div class="col-sm-11 col-xs-12">
<div class="row row-fix tpl-category-container" >
<div class="col-xs-12 col-sm-8 col-lg-3">
<input class="form-control" name="search[uid]" id="" type="text" value="{{ $search['uid'] }}" placeholder="用户ID">
</div>
<div class="col-xs-12 col-sm-8 col-lg-3">
<input class="form-control" name="search[nickname]" id="" type="text" value="{{ $search['nickname'] }}" placeholder="用户昵称|真实姓名">
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12 col-sm-6 col-lg-6">
<button type="button" class="btn btn-primary" onclick="addStoreManager()"><i class="fa fa-plus"></i> 添加</button>
<button class="btn btn-success" id="search"><i class="fa fa-search"></i> 搜索</button>
</div>
</div>
</form>
</div>
</div>
{{--信息列表--}}
<div class="panel panel-default">
<div class="panel-body" style="padding-top: 0;margin-bottom: 30px;overflow: auto;padding-right: 30px;">
<table class="table" style="min-width:1500px;overflow: auto;">
<thead>
<tr>
<th style="text-align:center;width: 80px;">ID</th>
<th style="text-align:center;">用户信息</th>
<th style="text-align:center;">唯一编号</th>
<th style="text-align:center;">获得时间</th>
<th style="text-align:center;">操作</th>
</tr>
</thead>
<tbody>
@foreach ($list as $item)
<tr style="height: 50px;">
<td style="text-align:center;">{{ $item['id'] }}</td>
<td style="text-align:center;" >
<div class="user">
<div class="user-avatar">
<img class="avatar-image" src="{{$item['member']['avatar_image']}}" />
</div>
<div class="user-info">
<div class="user-nickname">{{ $item['member']['username'] ? : $item['member']['nickname'] }}</div>
<div class="user-status">ID{{ $item['member']['uid'] }}</div>
</div>
</div>
</td>
<td style="text-align:center;">{{ $item['unique_number'] }}</td>
<td style="text-align:center;">{{ $item['created_at'] }}</td>
<td style="text-align:center;">
<button onclick="updateNumber({{$item['id']}})" type="button" class="btn btn-info btn-sm">修改编号</button>
</td>
</tr>
@endforeach
</tbody>
</table>
{!! $pager !!}
</div>
</div>
</div>
<script type="text/javascript">
// 修改编号
function updateNumber(id){
let link = "{{yzWebUrl('plugin.collection-room.admin.index.update-number')}}" + `&id=${id}`;
let popup = util.ajaxshow(link,'修改唯一编号',{
width: $(window).width() * 0.8 > 1200 ? $(window).width() * 0.8 : 1200,
height: $(window).height() * 0.8 > 1200 ? $(window).height() * 0.8 : 1200,
});
}
</script>
@endsection

View File

@ -0,0 +1,520 @@
@extends('layouts.base')
@section('content')
<style>
.commission{
width: 1100px;
}
.commission .commission-box{
width: 100%;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
border-bottom: 1px solid #CCCCCC;
padding: 20px 0;
}
.commission .commission-box:first-child{
padding: 0!important;
}
.commission .commission-box:last-child{
border-bottom: none!important;
}
.commission .commission-box .level-title{
width: 220px;
text-align: center;
font-size: 15px;
border-right: 1px solid #ccc;
height: 130px;
line-height: 130px;
}
.commission .commission-box:first-child .level-title{
font-weight: bold;
height: 35px;
line-height: 35px;
border-right: none!important;
}
.commission .commission-box .commission-line-content{
width: 880px;
}
.commission .commission-box .commission-line{
width: 880px;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: flex-start;
margin-bottom: 15px;
}
.commission .commission-box .commission-line:last-child{
margin-bottom: 0!important;
}
.commission .commission-box:first-child .commission-line{
font-weight: bold;
height: 35px;
line-height: 35px;
margin-bottom: 0px!important;
}
.commission .commission-box .commission-line .line-cells{
width: 220px;
text-align: center;
}
.hide{
display: none;
}
.el-pagination{
margin-top: 20px;
text-align: right!important;
}
</style>
<div class="w1200 m0a">
<div class="rightlist" id="app">
{{--设置表单--}}
<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
<div class='panel panel-default form-horizontal form'>
{{--设置内容--}}
<el-tabs value="base_set">
<el-tab-pane label="基础设置" name="base_set">
<div class='panel-body'>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">结算方式</label>
<div class="col-sm-4 col-xs-6">
<label class="radio-inline">
<input type="radio" name="terminal_merchants[settlement_method]" value="0" @if ($set['settlement_method'] != 1) checked="checked" @endif /> 手动结算
</label>
<label class="radio-inline">
<input type="radio" name="terminal_merchants[settlement_method]" value="1" @if ($set['settlement_method'] == 1) checked="checked" @endif /> 自动结算
</label>
</div>
</div>
</div>
</el-tab-pane>
<el-tab-pane label="佣金设置" name="commission_set">
<div class='panel-body'>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">结算类型</label>
<div class="col-sm-4 col-xs-6">
<label class="radio-inline">
<input type="radio"
name="terminal_merchants[commission][is_independent_settlement]"
value="0" @if ($set['commission']['is_independent_settlement'] != 1) checked="checked" @endif
/> 一次性全部结算
</label>
<label class="radio-inline">
<input type="radio"
name="terminal_merchants[commission][is_independent_settlement]"
value="1" @if ($set['commission']['is_independent_settlement'] == 1) checked="checked" @endif
/> 分期结算
</label>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">平级奖(百分比)</label>
<div class="col-sm-9 col-xs-12">
<input type='number'
step="0.01"
min="0.01"
max="100"
name='terminal_merchants[commission][flat_ratio]'
class="form-control"
value="{{$set['commission']['flat_ratio']}}"
/>
<span class='help-block'>值必须为0.01-100;为空则无平级奖。</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">结算延迟天数</label>
<div class="col-sm-9 col-xs-12">
<input type='number'
name='terminal_merchants[commission][independent_delay_day]'
class="form-control"
value="{{$set['commission']['independent_delay_day']}}"
/>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">经销商佣金设置</label>
<div class="col-sm-9 col-xs-10">
<div class="commission">
<div class="commission-box">
<div class="level-title">经销商等级</div>
<div class="commission-line">
<div class="line-cells">商品规格</div>
<div class="line-cells">首次返佣</div>
<div class="line-cells">每期返佣</div>
<div class="line-cells">分期数量</div>
</div>
</div>
@foreach($level as $levelItem => $levelValue)
<div class="commission-box">
{{--经销商等级--}}
<div class="level-title">{{$levelValue['level_name']}}</div>
{{--规格及佣金设置--}}
<div class="commission-line-content">
@foreach($goods_label as $goodsLabelItem => $goodsLabelValue)
<div class="commission-line">
<div class="line-cells">{{$goodsLabelValue}}</div>
<div class="line-cells">
<input type="number"
step="0.01"
class="form-control"
placeholder="请输入首次返佣金额"
value="{{$set['commission'][$levelValue['id']][$goodsLabelValue]['independent_first_money']}}"
name="terminal_merchants[commission][{{$levelValue['id']}}][{{$goodsLabelValue}}][independent_first_money]"
/>
</div>
<div class="line-cells">
<input type="number"
step="0.01"
class="form-control"
placeholder="请输入每期返佣金额"
value="{{$set['commission'][$levelValue['id']][$goodsLabelValue]['independent_cycle_money']}}"
name="terminal_merchants[commission][{{$levelValue['id']}}][{{$goodsLabelValue}}][independent_cycle_money]"
/>
</div>
<div class="line-cells">
<input type="number"
class="form-control"
placeholder="请输入分期数量"
value="{{$set['commission'][$levelValue['id']][$goodsLabelValue]['independent_cycle_number']}}"
name="terminal_merchants[commission][{{$levelValue['id']}}][{{$goodsLabelValue}}][independent_cycle_number]"
/>
</div>
</div>
@endforeach
</div>
</div>
@endforeach
</div>
</div>
</div>
</div>
</el-tab-pane>
<el-tab-pane label="区域提成结算" name="area_set">
{{--计算金额--}}
<div class="form-group">
<label class="col-xs-12 col-md-2 control-label">计算金额</label>
<div class="col-sm-9 col-xs-12">
<div class="input-group">
<div class="input-group">
<div class="input-group-addon">G10</div>
<input type="number" step="0.01" name='terminal_merchants[money][g10]' class="form-control" value="{{$set['money']['g10']}}"/>
<div class="input-group-addon"></div>
<div class="input-group-addon">G15</div>
<input type="number" step="0.01" name='terminal_merchants[money][g15]' class="form-control" value="{{$set['money']['g15']}}"/>
<div class="input-group-addon"></div>
<div class="input-group-addon">G20</div>
<input type="number" step="0.01" name='terminal_merchants[money][g20]' class="form-control" value="{{$set['money']['g20']}}"/>
<div class="input-group-addon"></div>
</div>
</div>
</div>
</div>
{{--默认比例--}}
<div class="form-group">
<label class="col-xs-12 col-md-2 control-label">默认比例</label>
<div class="col-sm-9 col-xs-12">
<div class="input-group">
<div class="input-group">
<div class="input-group-addon"></div>
<input type="number" step="0.01" name='terminal_merchants[area][default_province]' class="form-control" value="{{$set['area']['default_province']}}"/>
<div class="input-group-addon">%</div>
<div class="input-group-addon"></div>
<input type="number" step="0.01" name='terminal_merchants[area][default_city]' class="form-control" value="{{$set['area']['default_city']}}"/>
<div class="input-group-addon">%</div>
<div class="input-group-addon"></div>
<input type="number" step="0.01" name='terminal_merchants[area][default_district]' class="form-control" value="{{$set['area']['default_district']}}"/>
<div class="input-group-addon">%</div>
</div>
</div>
</div>
</div>
{{--独立比例--}}
<div class="form-group">
<label class="col-xs-12 col-md-2 control-label">独立规则</label>
<div class="col-sm-9 col-xs-12">
{{--添加按钮--}}
<div class="input-group">
<el-button type="primary" icon="el-icon-plus" @click="areaSelectShow = true">添加地区</el-button>
</div>
{{--独立规则列表--}}
<el-table :data="config_list" style="width:100%">
<el-table-column prop="id" align="center" label="ID" width="50"></el-table-column>
<el-table-column prop="address_text" align="center" label="地区"></el-table-column>
<el-table-column prop="ratio" align="center" label="提成比例"></el-table-column>
<el-table-column prop="created_at" align="center" label="添加时间"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="mini" @click="editInfo(scope.row)">编辑</el-button>
<el-button size="mini" type="danger" @click="delSelfConfigInfo(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
layout="prev, pager, next"
:page-count="config_total_page"
:current-page="config_page"
@current-change="paging"
></el-pagination>
</div>
</div>
</el-tab-pane>
</el-tabs>
{{--提交按钮--}}
<div class="form-group"></div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-9 col-xs-12">
<input type="submit" name="submit" value="保存" class="btn btn-primary col-lg-1"/>
</div>
</div>
</div>
</form>
{{--地区选择器--}}
<el-dialog title="添加地区" :visible.sync="areaSelectShow" :close-on-click-modal="false" @close="closeAddDialog">
<el-form :model="areaInfo">
<el-form-item v-if="Object.keys(province_list).length > 0" label="" :label-width="areaSelectShowLabelWidth">
<el-select v-model="areaInfo.province_id" @change="getArea($event,'city')" placeholder="请选择省">
<el-option v-for="(item,index) in province_list" :key="index" :label="item.areaname" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item v-if="Object.keys(city_list).length > 0" label="" :label-width="areaSelectShowLabelWidth">
<el-select v-model="areaInfo.city_id" @change="getArea($event,'district')" placeholder="请选择市">
<el-option v-for="(item,index) in city_list" :key="index" :label="item.areaname" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item v-if="Object.keys(district_list).length > 0" label="" :label-width="areaSelectShowLabelWidth">
<el-select v-model="areaInfo.district_id" placeholder="请选择区">
<el-option v-for="(item,index) in district_list" :key="index" :label="item.areaname" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="提成比例" :label-width="areaSelectShowLabelWidth">
<el-input v-model="areaInfo.ratio" max="100" min="0"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="areaSelectShow = false"> </el-button>
<el-button type="primary" @click="confirmAdd"> </el-button>
</div>
</el-dialog>
</div>
</div>
<script>
new Vue({
el: '#app',
delimiters: ['[[', ']]'],
data(){
return {
config_list: [],
config_page: 1,
config_total_page: 1,
areaSelectShow: false,
areaSelectShowLabelWidth: '120px',
areaInfo: {
id: 0,
province_id: '',// 省id
city_id: '',// 市id
district_id: '',// 区id
ratio: 0,
},
province_list: [],// 省
city_list: [],// 市
district_list: [],// 区
}
},
mounted () {
this.getArea();
this.getAreaSetList();
},
methods: {
// 获取信息列表
getAreaSetList(){
const loading = this.selfLoading();
let _this = this;
$.ajax({
url: "{!! yzWebUrl('plugin.terminal-merchants.admin.AreaSet.getList') !!}",
data:{
page: _this.config_page,
},
success: function (result) {
if(result.result){
let data = result.data;
_this.config_list = data.data;
_this.config_total_page = data.last_page;
}
loading.close();
},
error:function (error) {
loading.close();
console.log("失败:",error);
}
})
},
// 数据分页
paging(val){
this.config_page = val;
this.getAreaSetList();
},
// 获取地址
getArea(parentid = '',type = 'province',is_init = true){
const loading = this.selfLoading();
let _this = this;
$.ajax({
url: "{!! yzWebUrl('address.get-address') !!}",
data:{
type: type,
parentid: parentid
},
cache: false,
success: function (result) {
if(type === 'province') {
_this.province_list = JSON.parse(result);
if(is_init){
_this.city_list = _this.district_list = [];
_this.areaInfo = {
province_id: '',
city_id: '',
district_id: '',
};
}
}
else if(type === 'city') {
_this.city_list = JSON.parse(result);
if(is_init){
_this.district_list = [];
_this.areaInfo.city_id = '';
_this.areaInfo.district_id = '';
}
}
else if(type === 'district') {
_this.district_list = JSON.parse(result);
if(is_init) _this.areaInfo.district_id = '';
}
loading.close();
},
error:function (error) {
loading.close();
console.log("地区获取失败:",error);
}
})
},
// 提交 添加信息|修改信息
confirmAdd(){
let _this = this;
let areaInfo = _this.areaInfo;
// 信息验证
let defaultRule = [
{name: 'province_id', checkType: 'required', errorMsg: '请选择省'},
{name: 'ratio', checkType: 'required', errorMsg: '请输入独立提成比例'},
{name: 'ratio', checkType: 'between', errorMsg: '独立提成比例必须在1 ~ 100之间',checkRule: "0,100"},
];
let result = util.validate(areaInfo,defaultRule);
if(result !== true){
_this.$alert(result);
return false;
}
// 信息提交
areaInfo.province_name = areaInfo.province_id > 0 ? _this.getAreaDesc(_this.province_list,areaInfo.province_id,'areaname') : '';
areaInfo.city_name = areaInfo.city_id > 0 ? _this.getAreaDesc(_this.city_list,areaInfo.city_id,'areaname') : '';
areaInfo.district_name = areaInfo.district_id > 0 ? _this.getAreaDesc(_this.district_list,areaInfo.district_id,'areaname') : '';
const loading = this.selfLoading();
$.ajax({
url: "{!! yzWebUrl('plugin.terminal-merchants.admin.AreaSet.editInfo') !!}",
data: areaInfo,
cache: false,
success: function (result) {
loading.close();
_this.$alert(result.msg);
// 操作成功 关闭并且刷新
if(parseInt(result.result) === 1) {
_this.getAreaSetList();
_this.areaSelectShow = false;
}
},
error:function (error) {
loading.close();
console.log("失败:",error);
}
})
},
// 循环获取对应地区的信息
getAreaDesc(list,id,key = ''){
let info = {};
Object.values(list).some(function(res){
if(parseInt(res.id) === parseInt(id)){
info = res;
return true;
}
});
return key ? info[key] : info;
},
// 关闭添加弹框后 初始化部分内容
closeAddDialog(){
// 初始化内容
let _this = this;
_this.city_list = _this.district_list = [];
_this.areaInfo = {
province_id: '',
city_id: '',
district_id: '',
};
},
// 点击删除当前独立规则
delSelfConfigInfo(id){
let _this = this;
_this.$confirm('是否确认删除当前地区独立规则?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 请求删除
const loading = this.selfLoading();
$.ajax({
url: "{!! yzWebUrl('plugin.terminal-merchants.admin.AreaSet.delInfo') !!}",
data: {
id: id
},
success: function (result) {
loading.close();
_this.$alert(result.msg).then(() => {
_this.getAreaSetList();
});
},
error:function (error) {
loading.close();
console.log("失败:",error);
}
})
}).catch(()=>{});
},
// 公共加载动画
selfLoading(){
return this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
},
// 编辑信息
editInfo(info){
let _this = this;
_this.areaInfo = Object.assign({},info);
_this.getArea(info.province_id,'city',!info.city_id > 0);
_this.getArea(info.city_id,'district',!info.district_id > 0);
_this.areaSelectShow = true;
},
},
})
</script>
@endsection

View File

@ -0,0 +1,80 @@
<style></style>
<div id="editCatePopup" class="w1200 m0a">
<div class="rightlist">
<form action="" method="post" class="form-horizontal form" id="cateForm">
<div class="form-group">
<label class="col-sm-1 control-label">持有人</label>
<div class="col-sm-10 col-xs-12">
<input class="form-control" value="{{ $info['member']['username'] ? : $info['member']['nickname'] }}" disabled/>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">当前编号</label>
<div class="col-sm-10 col-xs-12">
<input class="form-control" value="{{ $info['unique_number'] }}" disabled />
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">新编号</label>
<div class="col-sm-10 col-xs-12">
<input type="number" name="unique_number" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label"></label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="id" class="form-control" value="{{$id ?? 0}}" style="display: none;"/>
<input type="button" value="提交" class="btn btn-primary submit-btn"/>
</div>
</div>
</form>
</div>
</div>
<script>
$(function () {
// 表单验证
$("#editCatePopup").on('click','.submit-btn',function () {
// 表单信息处理
let id = $("[name='id']").val();
let unique_number = $("[name='unique_number']").val();
unique_number = parseInt(unique_number) > 0 && !isNaN(parseInt(unique_number)) ? parseInt(unique_number) : 0;
// 判断
if(unique_number <= 0 || unique_number > 5000){
let alertPopup = util.alert("编号必须大于0且小于5000",'',{
confirm:function () {
// 关闭弹框
alertPopup.modal('hide');
}
});
return false;
}
// 提交
$.ajax({
type: "post",
url: "{!! yzWebUrl('plugin.collection-room.admin.index.update-number') !!}",
data: {
id: id,
unique_number: unique_number,
is_submit: 1,
},
success: function(response) {
if(parseInt(response.result) === 1){
util.alert('操作成功','',{
confirm:function () {
history.go(0);
}
});
}else{
let alertPopup = util.alert(response.msg,'',{
confirm:function () {
// 关闭弹框
alertPopup.modal('hide');
}
});
}
}
});
});
});
</script>

View File

@ -6,11 +6,22 @@ namespace Yunshop\TeamDividend\observers;
use app\common\observers\BaseObserver;
use Illuminate\Database\Eloquent\Model;
use Yunshop\CollectionRoom\models\CollectionRoomModel;
use Yunshop\TeamDividend\events\LevelChangeEvent;
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
class DealerObserver extends BaseObserver
{
public function saving(Model $model){
\Log::debug('新增经销商',$model->uid);
if($model->uid > 0){
// 会员升级经销商 赠送一幅画
CollectionRoomModel::addInfo($model->uid);
}
}
public function updating(Model $model)
{
/**