admin sys add finance manger and company short is must
This commit is contained in:
@@ -63,8 +63,8 @@ class Brand extends HD_Controller
|
||||
//获取公司ID列表
|
||||
$where = array('status' => 1);
|
||||
$orderby = 'id desc';
|
||||
$select = 'id, title';
|
||||
$map_company = $this->company_model->map('id', 'title', $where, $orderby, 0, 0, $select);
|
||||
$select = 'id, short';
|
||||
$map_company = $this->company_model->map('id', 'short', $where, $orderby, 0, 0, $select);
|
||||
|
||||
$this->data['info'] = $info;
|
||||
$this->data['action'] = $action;
|
||||
|
||||
@@ -100,9 +100,13 @@ class Company extends HD_Controller{
|
||||
public function add(){
|
||||
$info = $this->input->post('info');
|
||||
$title = trim($info['title']);
|
||||
$short = trim($info['short']);
|
||||
if(!$title){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入公司名称');
|
||||
}
|
||||
if(!$short){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入公司简称');
|
||||
}
|
||||
|
||||
$where = array("title like '{$title}'" => null);
|
||||
$count = $this->company_model->count($where);
|
||||
@@ -112,7 +116,7 @@ class Company extends HD_Controller{
|
||||
|
||||
$add = array(
|
||||
'title' => $title,
|
||||
'short' => $info['short'] ? $info['short'] : '',
|
||||
'short' => $short,
|
||||
'status' => intval($info['status'])
|
||||
);
|
||||
|
||||
@@ -128,9 +132,13 @@ class Company extends HD_Controller{
|
||||
public function edit(){
|
||||
$info = $this->input->post('info');
|
||||
$title = trim($info['title']);
|
||||
$short = trim($info['short']);
|
||||
if(!$title){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入公司名称');
|
||||
}
|
||||
if(!$short){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入公司简称');
|
||||
}
|
||||
|
||||
$where = array("title like '{$title}'" => null, "id<>{$info['id']}" => null);
|
||||
$count = $this->company_model->count($where);
|
||||
@@ -140,7 +148,7 @@ class Company extends HD_Controller{
|
||||
|
||||
$upd = array(
|
||||
'title' => $title,
|
||||
'short' => $info['short'] ? $info['short'] : '',
|
||||
'short' => $short ? $short : '',
|
||||
'status' => intval($info['status'])
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2021/7/30
|
||||
* Time: 10:52
|
||||
*/
|
||||
class Finance extends HD_Controller{
|
||||
protected $log_dir;
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model("sys/sys_finance_model", 'finance_model');
|
||||
|
||||
$this->log_dir = 'sys_' . get_class($this);
|
||||
}
|
||||
|
||||
public function index(){
|
||||
return $this->lists();
|
||||
}
|
||||
|
||||
public function lists(){
|
||||
$params = $this->input->get();
|
||||
|
||||
$where = array();
|
||||
if ($params['keyword']){
|
||||
$where["(title like '%{$params['keyword']}%')"] = null;
|
||||
}
|
||||
|
||||
if(strlen($params['status']) > 0){
|
||||
$where['status'] = $params['status'];
|
||||
} else {
|
||||
$params['status'] = '';
|
||||
}
|
||||
|
||||
$page = $params['page'];
|
||||
$page = !$page ? 1 : $page;
|
||||
$size = $params['size'];
|
||||
$size = !$size ? 20 : $size;
|
||||
|
||||
$statusAry = $this->finance_model->status_ary();
|
||||
|
||||
$count = $this->finance_model->count($where);
|
||||
$lists = array();
|
||||
if($count){
|
||||
$orderby = 'id desc';
|
||||
$select = 'id, title, money_min, money_max, first_pay, month_min, month_max, status';
|
||||
$rows = $this->finance_model->select($where, $orderby, $page, $size, $select);
|
||||
foreach($rows as $k => $v){
|
||||
$lists[] = array(
|
||||
'id' => $v['id'],
|
||||
'title' => $v['title'],
|
||||
'money' => "{$v['money_min']}-{$v['money_max']}",
|
||||
'first_pay' => $v['first_pay'],
|
||||
"month" => "{$v['month_min']}-{$v['month_max']}",
|
||||
'status' => $v['status'],
|
||||
'status_name' => $statusAry[$v['status']],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['params'] = $params;
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['statusAry'] = $statusAry;
|
||||
$this->data['pager'] = array('count'=>ceil($count/$size),'curr'=>$page,'totle'=>$count);
|
||||
$this->data['_title'] = '金融产品';
|
||||
$this->show_view('sys/finance/lists',true);
|
||||
}
|
||||
|
||||
public function get(){
|
||||
$id = $this->input->get('id');
|
||||
if($id){
|
||||
$row = $this->finance_model->get(array('id' => $id));
|
||||
$info = array(
|
||||
'id' => $row['id'],
|
||||
'title' => $row['title'],
|
||||
'logo' => $row['logo'],
|
||||
'logo_url' => $row['logo'] ? build_qiniu_image_url($row['logo']) : '',
|
||||
'money_min' => $row['money_min'],
|
||||
'money_max' => $row['money_max'],
|
||||
'first_pay' => $row['first_pay'],
|
||||
'month_min' => $row['month_min'],
|
||||
'month_max' => $row['month_max'],
|
||||
'status' => $row['status'],
|
||||
);
|
||||
$action = '/sys/finance/edit';
|
||||
$title = '编辑金融产品';
|
||||
} else {
|
||||
$info = array(
|
||||
'title' => '',
|
||||
'status' => 0,
|
||||
);
|
||||
$action = '/sys/finance/add';
|
||||
$title = '新增金融产品';
|
||||
}
|
||||
|
||||
$this->data['info'] = $info;
|
||||
$this->data['action'] = $action;
|
||||
$this->data['statusAry'] = $this->finance_model->status_ary();
|
||||
$this->data['_title'] = $title;
|
||||
$this->show_view('sys/finance/get');
|
||||
}
|
||||
|
||||
public function add(){
|
||||
$info = $this->input->post('info');
|
||||
$title = trim($info['title']);
|
||||
if(!$title){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入标题');
|
||||
}
|
||||
|
||||
$where = array("title like '{$title}'" => null);
|
||||
$count = $this->finance_model->count($where);
|
||||
if($count>0){
|
||||
return $this->show_json(SYS_CODE_FAIL, '产品已经存在');
|
||||
}
|
||||
|
||||
$add = array(
|
||||
'title' => $title,
|
||||
'logo' => $info['logo'] ? $info['logo'] : '',
|
||||
'money_min' => floatval($info['money_min']),
|
||||
'money_max' => floatval($info['money_max']),
|
||||
'first_pay' => floatval($info['first_pay']),
|
||||
'month_min' => intval($info['month_min']),
|
||||
'month_max' => intval($info['month_max']),
|
||||
'status' => intval($info['status']),
|
||||
);
|
||||
|
||||
$id = $this->finance_model->add($add);
|
||||
if(!$id){
|
||||
debug_log("[error]# " . $this->finance_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$info = $this->input->post('info');
|
||||
$title = trim($info['title']);
|
||||
if(!$title){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入产品名称');
|
||||
}
|
||||
|
||||
$where = array("title like '{$title}'" => null, "id<>{$info['id']}" => null);
|
||||
$count = $this->finance_model->count($where);
|
||||
if($count>0){
|
||||
return $this->show_json(SYS_CODE_FAIL, '产品已存在');
|
||||
}
|
||||
|
||||
$upd = array(
|
||||
'title' => $title,
|
||||
'logo' => $info['logo'] ? $info['logo'] : '',
|
||||
'money_min' => floatval($info['money_min']),
|
||||
'money_max' => floatval($info['money_max']),
|
||||
'first_pay' => floatval($info['first_pay']),
|
||||
'month_min' => intval($info['month_min']),
|
||||
'month_max' => intval($info['month_max']),
|
||||
'status' => intval($info['status']),
|
||||
);
|
||||
|
||||
$ret = $this->finance_model->update($upd, array('id' => $info['id']));
|
||||
if(!$ret){
|
||||
debug_log("[error]# " . $this->finance_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
||||
}
|
||||
|
||||
function edit_status(){
|
||||
$id = $this->input->post('id');
|
||||
$status = $this->input->post('status');
|
||||
|
||||
$upd = array('status' => $status);
|
||||
$where = array('id' => $id);
|
||||
|
||||
$ret = $this->finance_model->update($upd, $where);
|
||||
if(!$ret){
|
||||
debug_log("[error]# " . $this->finance_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
||||
}
|
||||
|
||||
public function del(){
|
||||
// TODO: Implement del() method.
|
||||
}
|
||||
|
||||
public function batch(){
|
||||
// TODO: Implement batch() method.
|
||||
}
|
||||
|
||||
public function export(){
|
||||
// TODO: Implement export() method.
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">类型:</label>
|
||||
<div class="am-para-input wp50">
|
||||
<div class="am-para-input wp40">
|
||||
<select name="type" v-model="info.type">
|
||||
<option value="0">选择类型</option>
|
||||
<option v-for="(v,i) in typeAry" :value="i">{{v}}</option>
|
||||
@@ -33,7 +33,7 @@
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">公司:</label>
|
||||
<div class="am-para-input wp60">
|
||||
<div class="am-para-input wp40">
|
||||
<select name="type" v-model="info.company_id">
|
||||
<option value="0">选择公司</option>
|
||||
<option v-for="(v,i) in companyAry" :value="i">{{v}}</option>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/city/city/add" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto">
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/company/edit" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto">
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label"><span class="com-must-star">*</span>公司名称:</label>
|
||||
<div class="am-para-input"><input type="text" placeholder="请输入公司名称" name="title" v-model="info.title"/></div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">公司简称:</label>
|
||||
<label class="am-para-label"><span class="com-must-star">*</span>公司简称:</label>
|
||||
<div class="am-para-input"><input type="text" placeholder="请输入公司简称" name="short" v-model="info.short"/></div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/finance/edit" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto">
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label"><span class="com-must-star">*</span>名称:</label>
|
||||
<div class="am-para-input"><input type="text" placeholder="请输入名称" name="title" v-model="info.title"/></div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 0">
|
||||
<label class="am-para-label">logo:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-form-group am-form-file">
|
||||
<button type="button" class="am-btn am-btn-default am-btn-sm"
|
||||
data-file="1" data-type="jpg,png,gif,png,jpeg"
|
||||
data-uptype="qiniu" data-field="img"><i class="am-icon-cloud-upload"></i> 选择图片(100x100)
|
||||
</button>
|
||||
<input type="hidden" id="logo" name="img" value="<?= $info['logo'] ?>" class="layui-input">
|
||||
<img data-tips-image style="height:auto;max-height:32px;max-width:32px" :src="info.logo_url"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">首付:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" name="first_pay" v-model="info.first_pay" style="width: 20%; display: inline"/>
|
||||
<span>万元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">额度:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="最低额度" name="money_min" v-model="info.money_min" style="width: 20%; display: inline"/>
|
||||
<span>-</span>
|
||||
<input type="text" placeholder="最高额度" name="money_max" v-model="info.money_max" style="width: 20%; display: inline"/>
|
||||
<span>万元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">期限:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="最低期限" name="month_min" v-model="info.month_min" style="width: 20%; display: inline"/>
|
||||
<span>-</span>
|
||||
<input type="text" placeholder="最高期限" name="month_max" v-model="info.month_max" style="width: 20%; display: inline"/>
|
||||
<span>月</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">状态:</label>
|
||||
<div class="am-para-input wp40">
|
||||
<select name="status" v-model="info.status">
|
||||
<option v-for="(v,i) in statusAry" :value="i">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="button" @click="saveEdit">提交</button></div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
var loading = 0;
|
||||
var vue_obj;
|
||||
$(function(){
|
||||
vue_obj = new Vue({
|
||||
el: '#vue-edit',
|
||||
data: {
|
||||
info:{},
|
||||
statusAry:[],
|
||||
action:''
|
||||
},
|
||||
mounted:function(){
|
||||
var vm = this;
|
||||
vm.info = <?=json_encode($info)?>;
|
||||
vm.statusAry = <?=json_encode($statusAry)?>;
|
||||
vm.action = '<?=$action?>';
|
||||
},
|
||||
methods:{
|
||||
saveEdit:function(){
|
||||
var vm = this;
|
||||
if(1 == loading){
|
||||
return 0;
|
||||
}
|
||||
loading = 1;
|
||||
|
||||
vm.info.logo = $("#logo").val();
|
||||
|
||||
$.ajax({
|
||||
url: vm.action,
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {info:vm.info},
|
||||
beforeSend: function () {
|
||||
layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
},
|
||||
success: function (data) {
|
||||
loading = 0;
|
||||
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 = 0;
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch:{}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,93 @@
|
||||
|
||||
<div class="coms-table-wrap">
|
||||
<div class="coms-table-hd clearfix no-border">
|
||||
<form action="/sys/finance/lists" class="form-search" onsubmit="return false">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label">关键词:</label>
|
||||
<div class="am-para-inline w200">
|
||||
<input type="text" name="keyword" id="input" placeholder="输入名称关键字" v-model="params.keyword"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">状态:</label>
|
||||
<div class="am-para-inline w150">
|
||||
<select name="status" v-model="params.status">
|
||||
<option value="">请选择</option>
|
||||
<option :value="i" v-for="(v,i) in statusAry">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml20">
|
||||
<button type="submit" class="am-btn am-btn-sm am-btn-success w100">搜索</button>
|
||||
<button data-modal="/sys/finance/get" data-title="新增" type="button" class="am-btn am-btn-success w100 am-btn-sm">新增</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="coms-table-bd">
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%"><span>ID</span></th>
|
||||
<th width="25%"><span>名称</span></th>
|
||||
<th width="10%"><span>首付(万元)</span></th>
|
||||
<th width="10%"><span>额度(万元)</span></th>
|
||||
<th width="10%"><span>期限(月)</span></th>
|
||||
<th width="10%"><span>状态</span></th>
|
||||
<th width=""><span>操作</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(v,i) in lists">
|
||||
<td>{{v.id}}</td>
|
||||
<td>{{v.title}}</td>
|
||||
<td>{{v.first_pay}}</td>
|
||||
<td>{{v.money}}</td>
|
||||
<td>{{v.month}}</td>
|
||||
<td>{{v.status_name}}</td>
|
||||
<td>
|
||||
<a href="javascript:void(0);" :data-modal="'sys/finance/get?id='+v.id"
|
||||
class="am-btn am-btn-primary am-btn-xs">编辑</a>
|
||||
<a data-ajax="post" data-action="/sys/finance/edit_status" class="am-btn am-btn-danger am-btn-xs"
|
||||
:data-params-id="v.id" :data-params-status="0" v-if="1==v.status">关闭</a>
|
||||
<a data-ajax="post" data-action="/sys/finance/edit_status" class="am-btn am-btn-success am-btn-xs"
|
||||
:data-params-id="v.id" :data-params-status="1" v-if="0==v.status">开启</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="hander am-form">
|
||||
</div>
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var vue_obj;
|
||||
var loading = 0;
|
||||
$(function(){
|
||||
vue_obj = new Vue({
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params:[],
|
||||
lists:[],
|
||||
statusAry:[]
|
||||
},
|
||||
mounted:function() {
|
||||
var vm = this;
|
||||
vm.params = <?=json_encode($params)?>;
|
||||
vm.lists = <?=json_encode($lists)?>;
|
||||
vm.statusAry = <?=json_encode($statusAry)?>;
|
||||
},
|
||||
methods:{},
|
||||
watch:{}
|
||||
});
|
||||
|
||||
<?php page_script($pager) ?>
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2021/7/30
|
||||
* Time: 10:50
|
||||
*/
|
||||
class Sys_finance_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_sys_finance';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* @return array
|
||||
*/
|
||||
function status_ary(){
|
||||
$statusAry = array(/*'-1' => '删除',*/ '0' => '关闭', '1' => '开启');
|
||||
|
||||
return $statusAry;
|
||||
}
|
||||
}
|
||||
+19
@@ -204,3 +204,22 @@ create table lc_sys_company (
|
||||
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4 COLLATE=UTF8MB4_0900_AI_CI COMMENT='公司管理';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:金融产品
|
||||
-- Author:xusir
|
||||
-- Table:lc_sys_finance
|
||||
-- ---------------------------
|
||||
drop table if exists lc_sys_finance;
|
||||
create table lc_sys_finance (
|
||||
id int(10) unsigned not null auto_increment comment '自增id',
|
||||
title varchar(64) not null comment '公司名称',
|
||||
logo varchar(128) not null default '' comment '菜单图标',
|
||||
money_min decimal(12,2) not null default 0.00 comment '最低额度(万元)',
|
||||
money_max decimal(12,2) not null default 0.00 comment '最高额度(万元)',
|
||||
first_pay decimal(12,2) not null default 0.00 comment '首付(万元)',
|
||||
month_min int not null default 0 comment '最低期限(月)',
|
||||
month_max int not null default 0 comment '最高期限(月)',
|
||||
status tinyint(1) not null default '1' comment '状态:-1删除,0关闭,1开启',
|
||||
primary key (id)
|
||||
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4 COLLATE=UTF8MB4_0900_AI_CI COMMENT='金融产品';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user