接口修改、后台农作物修改
This commit is contained in:
parent
ca2e14a6f5
commit
09bfe58442
@ -253,7 +253,7 @@ class User extends BaseController
|
||||
public function postedit()
|
||||
{
|
||||
$params = get_params();
|
||||
halt($params);
|
||||
// halt($params);
|
||||
if ($params['type'] == 1) {
|
||||
unset($params['type']);
|
||||
$res = Db::table('fa_szxc_information_usermsg')->where('user_id', $params['user_id'])->update($params);
|
||||
@ -264,15 +264,80 @@ class User extends BaseController
|
||||
}
|
||||
}
|
||||
if ($params['type'] == 2) {
|
||||
halt($params);
|
||||
$params['crops_msg'] = json_encode($params['crops_msg']);
|
||||
unset($params['type']);
|
||||
$find = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->find();
|
||||
$find = Db::table('fa_szxc_information_planting')->where('user_id', $params['user_id'])->find();
|
||||
if ($find) {
|
||||
$res = Db::table('fa_szxc_information_insurance')->where('id', $find['id'])->update($params);
|
||||
$res = Db::table('fa_szxc_information_planting')->where('id', $find['id'])->update($params);
|
||||
$id = $find['id'];
|
||||
} else {
|
||||
$res = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->insert($params);
|
||||
$res = Db::table('fa_szxc_information_planting')->where('user_id', $params['user_id'])->insertGetId($params);
|
||||
$id = $res;
|
||||
}
|
||||
if ($res) {
|
||||
$time = time();
|
||||
// 新增写入种植表
|
||||
Db::table('fa_szxc_planting')->where('user_id',$params['user_id'])->delete();
|
||||
$mianji = 0;
|
||||
if($params['crops_msg']){
|
||||
$crops_msg_arr = json_decode($params['crops_msg'],1);
|
||||
foreach ($crops_msg_arr as $k=>$v){
|
||||
// 根据名字查询分类
|
||||
if($v['name']){
|
||||
$type = Db::table('fa_szxc_planting_type')->where('name',$v['name'])->find();
|
||||
if($type){
|
||||
$planting_data['type_id'] = $type['id'];
|
||||
}else{
|
||||
$type_data['name'] = $v['name'];
|
||||
$type_data['createtime'] = $time;
|
||||
$type_id = Db::table('fa_szxc_planting_type')->strict(false)->insertGetId($type_data);
|
||||
$planting_data['type_id'] = $type_id;
|
||||
}
|
||||
$planting_data['user_id'] = $params['user_id'];
|
||||
$planting_data['num'] = $v['num']??0;
|
||||
$planting_data['measure'] = $v['mianji']??0;
|
||||
$planting_data['createtime'] = $time;
|
||||
Db::table('fa_szxc_planting')->strict(false)->insertGetId($planting_data);
|
||||
}
|
||||
// 计算面积
|
||||
if($v['mianji']){
|
||||
$mianji += $v['mianji'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 新增写入养殖表
|
||||
Db::table('fa_szxc_breed')->where('user_id',$params['user_id'])->delete();
|
||||
// $mianji = 0;
|
||||
if(isset($params['breed_msg']) && !empty($params['breed_msg'])){
|
||||
$breed_msg_arr = json_decode($params['breed_msg'],1);
|
||||
foreach ($breed_msg_arr as $k=>$v){
|
||||
// 根据名字查询分类
|
||||
if($v['name']){
|
||||
$type = Db::table('fa_szxc_breed_type')->where('name',$v['name'])->find();
|
||||
if($type){
|
||||
$breed_data['type_id'] = $type['id'];
|
||||
}else{
|
||||
$type_data['name'] = $v['name'];
|
||||
$type_data['createtime'] = $time;
|
||||
$type_id = Db::table('fa_szxc_breed_type')->strict(false)->insertGetId($type_data);
|
||||
$breed_data['type_id'] = $type_id;
|
||||
}
|
||||
$breed_data['user_id'] = $params['user_id'];
|
||||
$breed_data['num'] = $v['num']??0;
|
||||
$breed_data['measure'] = $v['mianji']??0;
|
||||
$breed_data['createtime'] = $time;
|
||||
Db::table('fa_szxc_breed')->strict(false)->insertGetId($breed_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$waste_land_area = $params['land_area'] - $mianji;
|
||||
if($waste_land_area < 0){
|
||||
$waste_land_area = 0;
|
||||
}
|
||||
$ddd['waste_land_area'] = $waste_land_area;
|
||||
Db::table('fa_szxc_information_planting')->where('id', $id)->update($ddd);
|
||||
return to_assign(0, '操作成功');
|
||||
} else {
|
||||
return to_assign(1, '操作失败');
|
||||
|
@ -181,27 +181,27 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">土地面积</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{$planting['land_area']}" autocomplete="off" class="layui-input">
|
||||
<input type="text" name="land_area" value="{$planting['land_area']}" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-item" id="nzw">
|
||||
<label class="layui-form-label">农作物信息</label>
|
||||
{volist name="planting.crops_msg" id="vo"}
|
||||
<div class="aa" style="display: inline-block;">
|
||||
{volist name="planting.crops_msg" key="key" id="vo"}
|
||||
<div2 class="aa" {if $key==1} style="display: inline-block;" {else} style="display: inline-block;margin-left: 100px;" {/if}>
|
||||
<div class="layui-input-inline">
|
||||
农作物名称 <input type="text" name="crops_msg[0][name]" autocomplete="off" class="layui-input" value="{$vo.name}">
|
||||
农作物名称 <input type="text" name="crops_msg[{$key-1}][name]" autocomplete="off" class="layui-input" value="{$vo.name}">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
数量 <input type="text" name="crops_msg[0][num]" autocomplete="off" class="layui-input" value="{$vo.num}">
|
||||
数量 <input type="text" name="crops_msg[{$key-1}][num]" autocomplete="off" class="layui-input" value="{$vo.num}">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
面积 <input type="text" name="crops_msg[0][mianji]" autocomplete="off" class="layui-input" value="{$vo.mianji}">
|
||||
面积 <input type="text" name="crops_msg[{$key-1}][mianji]" autocomplete="off" class="layui-input" value="{$vo.mianji}">
|
||||
</div>
|
||||
</div>
|
||||
</div2>
|
||||
{/volist}
|
||||
|
||||
<button type="button" class="layui-btn layui-btn-normal" id="a1" style="display: block; margin-left: 100px;">添加</button>
|
||||
|
||||
<button type="button" class="layui-btn layui-btn-normal" id="a2" style="position: relative; left: 170px;top:-38px">删除</button>
|
||||
</div>
|
||||
<div class="pt-3">
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform2">立即提交</button>
|
||||
@ -498,27 +498,37 @@
|
||||
{block name="script"}
|
||||
<script>
|
||||
var moduleInit = ['tool'];
|
||||
var htmlid=1;
|
||||
function gouguInit () {
|
||||
var form = layui.form, tool = layui.tool;
|
||||
var htmlid= $("#nzw").children("div2").length;
|
||||
$("#a1").on("click", function(e) {
|
||||
var html=`
|
||||
<div class="aa" style="display: inline-block;
|
||||
<div2 id="aa`+htmlid+`" class="aa`+htmlid+`" style="display: inline-block;
|
||||
margin-left: 100px;">
|
||||
<div class="layui-input-inline">
|
||||
农作物名称 <input type="text" name="crops_msg[`+htmlid+`][name]" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
数量 <input type="text" name="crops_msg[`+htmlid+`][num]" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
面积 <input type="text" name="crops_msg[`+htmlid+`][mianji]" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
农作物名称 <input type="text" name="crops_msg[`+htmlid+`][name]" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
数量 <input type="text" name="crops_msg[`+htmlid+`][num]" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
面积 <input type="text" name="crops_msg[`+htmlid+`][mianji]" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div2>
|
||||
`
|
||||
$(".aa").after(html)
|
||||
|
||||
$("#nzw div2:last").after(html);
|
||||
++htmlid
|
||||
})
|
||||
});
|
||||
|
||||
$("#a2").on("click", function(e) {
|
||||
if(htmlid === 1){
|
||||
return;
|
||||
}
|
||||
$("#nzw div2:last").remove();
|
||||
--htmlid
|
||||
});
|
||||
|
||||
//监听提交
|
||||
form.on('submit(webform1)', function (data) {
|
||||
let callback = function (e) {
|
||||
|
@ -690,7 +690,7 @@ class Maintainentry extends BaseController
|
||||
}
|
||||
// 计算面积
|
||||
if($v['mianji']){
|
||||
$mianji .= $v['mianji'];
|
||||
$mianji += $v['mianji'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -720,7 +720,7 @@ class Maintainentry extends BaseController
|
||||
}
|
||||
//// 计算面积
|
||||
// if($v['mianji']){
|
||||
// $mianji .= $v['mianji'];
|
||||
// $mianji += $v['mianji'];
|
||||
// }
|
||||
}
|
||||
}
|
||||
@ -1353,7 +1353,7 @@ class Maintainentry extends BaseController
|
||||
}
|
||||
// 计算面积
|
||||
if($v['mianji']){
|
||||
$mianji .= $v['mianji'];
|
||||
$mianji += $v['mianji'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1382,7 +1382,7 @@ class Maintainentry extends BaseController
|
||||
}
|
||||
//// 计算面积
|
||||
// if($v['mianji']){
|
||||
// $mianji .= $v['mianji'];
|
||||
// $mianji += $v['mianji'];
|
||||
// }
|
||||
}
|
||||
}
|
||||
@ -1646,6 +1646,9 @@ class Maintainentry extends BaseController
|
||||
$res = Db::table('fa_szxc_information_usermsg')->where($map)
|
||||
->order('id desc')
|
||||
->field("id,user_id,name,age,gender,family_num,political_outlook,householder_id,is_hz,address_name,family_relation")
|
||||
->withAttr('avatar', function ($value, $data) {
|
||||
return Db::table('fa_user')->where('id', $data['user_id'])->value('avatar');
|
||||
})
|
||||
->select()->toArray();
|
||||
if ($res){
|
||||
// 获取户主id
|
||||
@ -1657,6 +1660,7 @@ class Maintainentry extends BaseController
|
||||
if($v['is_hz']==1){
|
||||
$is_set_hz = 1;
|
||||
$res[$k]['householder_name'] = '本人';
|
||||
$res[$k]['avatar'] = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230129/0dc8d0a0f3bcc168550ef263a9a170dc.png';
|
||||
}else{
|
||||
$msg= Db::table('fa_szxc_information_usermsg')->where('user_id',$v['householder_id'])->value('name');
|
||||
$res[$k]['householder_name'] = $msg?:'暂无户主';
|
||||
@ -1705,6 +1709,7 @@ class Maintainentry extends BaseController
|
||||
$return['name'] = $name;
|
||||
$return['family_num'] = Db::table('fa_szxc_information_usermsg')->where($map)->count();
|
||||
$return['is_set_hz'] = $is_set_hz;
|
||||
$return['avatar'] = Db::table('fa_user')->where('id', $user_id)->value('avatar');
|
||||
$return['data'] = $res;
|
||||
$this->apiSuccess('获取成功', $return, 1);
|
||||
}
|
||||
|
@ -553,6 +553,51 @@ class Statistics extends BaseController
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//农业产量
|
||||
public function get_num14($area_id=0,$street_id=0,$village_id=0){
|
||||
if ($area_id){
|
||||
$where[] = ['area_id', '=', $area_id];
|
||||
}
|
||||
if ($street_id){
|
||||
$where[] = ['street_id', '=', $street_id];
|
||||
}
|
||||
if ($village_id){
|
||||
$where[] = ['village_id', '=', $village_id];
|
||||
}
|
||||
|
||||
$return = [
|
||||
['value'=>1351,'name'=>'萝卜'],
|
||||
['value'=>245,'name'=>'白菜'],
|
||||
['value'=>874,'name'=>'芋头'],
|
||||
['value'=>511,'name'=>'地瓜'],
|
||||
['value'=>1024,'name'=>'土豆'],
|
||||
['value'=>249,'name'=>'山药'],
|
||||
];
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//农业销量
|
||||
public function get_num15($area_id=0,$street_id=0,$village_id=0){
|
||||
if ($area_id){
|
||||
$where[] = ['area_id', '=', $area_id];
|
||||
}
|
||||
if ($street_id){
|
||||
$where[] = ['street_id', '=', $street_id];
|
||||
}
|
||||
if ($village_id){
|
||||
$where[] = ['village_id', '=', $village_id];
|
||||
}
|
||||
|
||||
$return = [
|
||||
['value'=>835,'name'=>'萝卜'],
|
||||
['value'=>124,'name'=>'白菜'],
|
||||
['value'=>187,'name'=>'芋头'],
|
||||
['value'=>251,'name'=>'地瓜'],
|
||||
['value'=>902,'name'=>'土豆'],
|
||||
['value'=>214,'name'=>'山药'],
|
||||
];
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -433,4 +433,46 @@ function camelize($uncamelized_words,$separator='_')
|
||||
function uncamelize($camelCaps,$separator='_')
|
||||
{
|
||||
return strtolower(preg_replace('/([a-z])([A-Z])/', "$1" . $separator . "$2", $camelCaps));
|
||||
}
|
||||
|
||||
if (! function_exists('upload_file')) {
|
||||
/**
|
||||
* 上传文件.
|
||||
*
|
||||
* @param string $file 上传的文件
|
||||
* @param string $name 上传的位置
|
||||
* @param string $path 上传的文件夹
|
||||
* @param string $validate 规则验证
|
||||
* @param string $url 前缀
|
||||
*
|
||||
* @return string|bool
|
||||
* @author niu
|
||||
*/
|
||||
function upload_file($file = null, $name = 'local', $path = '', $validate = '', $url = '/')
|
||||
{
|
||||
//文件
|
||||
if (! $file) {
|
||||
return false;
|
||||
}
|
||||
//上传配置
|
||||
$config_name = 'filesystem.disks.'.$name;
|
||||
$filesystem = config($config_name);
|
||||
if (! $filesystem) {
|
||||
return false;
|
||||
}
|
||||
//上传文件
|
||||
if ($validate) {
|
||||
validate(['file' => $validate])->check(['file' => $file]);
|
||||
}
|
||||
$savename = \think\facade\Filesystem::disk($name)->putFile($path, $file, function ($file) {
|
||||
//重命名
|
||||
return date('Ymd').'/'.md5((string) microtime(true));
|
||||
});
|
||||
if(empty($url)){
|
||||
$url = '/';
|
||||
}
|
||||
$savename = $url.$savename;
|
||||
|
||||
return $savename;
|
||||
}
|
||||
}
|
57
config/upload.php
Normal file
57
config/upload.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* *
|
||||
* * ============================================================================
|
||||
* * Created by PhpStorm.
|
||||
* * User: Ice
|
||||
* * 邮箱: ice@sbing.vip
|
||||
* * 网址: https://sbing.vip
|
||||
* * Date: 2019/9/19 下午3:38
|
||||
* * ============================================================================.
|
||||
*/
|
||||
|
||||
//上传配置
|
||||
return [
|
||||
/**
|
||||
* 引擎
|
||||
*/
|
||||
'driver'=>'local',
|
||||
/**
|
||||
* 上传地址,默认是本地上传
|
||||
*/
|
||||
'uploadurl' => 'ajax/upload',
|
||||
/**
|
||||
* CDN地址
|
||||
*/
|
||||
'cdnurl' => '',
|
||||
/**
|
||||
* 文件保存格式
|
||||
*/
|
||||
'uploaddir' => 'uploads',
|
||||
/**
|
||||
* 最大可上传大小
|
||||
*/
|
||||
'maxsize' => '10mb',
|
||||
/**
|
||||
* 可上传的文件类型
|
||||
*/
|
||||
'mimetype' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx,wav,mp4,mp3,pdf',
|
||||
/**
|
||||
* 是否支持批量上传
|
||||
*/
|
||||
'multiple' => false,
|
||||
|
||||
/**
|
||||
* 文件保存格式
|
||||
*/
|
||||
'savekey' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}',
|
||||
|
||||
/**
|
||||
* 是否支持分片上传
|
||||
*/
|
||||
'chunking' => false,
|
||||
/**
|
||||
* 默认分片大小
|
||||
*/
|
||||
'chunksize' => 2097152,
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user