afa 5 сар өмнө
parent
commit
802e42e11f

+ 56 - 0
app/admin/controller/user/StockLog.php

@@ -0,0 +1,56 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\controller\user;
+
+use app\common\controller\Backend;
+use app\admin\traits\Actions;
+use think\annotation\route\Group;
+use think\annotation\route\Route;
+use app\common\model\StockLog as StockLogModel;
+
+#[Group("user/stock_log")]
+class StockLog extends Backend
+{
+    use Actions{
+        index as private _index;
+        add as private _add;
+        edit as private _edit;
+    }
+
+    protected function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new StockLogModel();
+    }
+
+    //查看
+    #[Route("GET,JSON","index")]
+    public function index()
+    {
+        return $this->_index();
+    }
+
+    //添加
+    #[Route("GET,POST","add")]
+    public function add()
+    {
+        //通过定义postParams来增加或覆盖post提交的表单
+        $this->postParams=[];
+        //通过定义callback回调函数来执行添加后的操作
+        $this->callback=function ($model){};
+        return $this->_add();
+    }
+
+    //修改
+    #[Route("GET,POST","edit")]
+    public function edit()
+    {
+        //通过定义postParams来增加或覆盖post提交的表单
+        $this->postParams=[];
+        //通过定义callback回调函数来执行修改后的操作
+        $this->callback=function ($model){};
+        return $this->_edit();
+    }
+
+}

+ 11 - 5
app/admin/view/shop/shop_delivery/index.html

@@ -26,12 +26,18 @@
             columns:[
                 {checkbox: true},
                 {field: 'id',title: __('ID'),width:80,sortable: true},
+                {field: 'user_id', title: __('录入人'),operate: 'LIKE'},
                 {field: 'customer_id',title: __('客户'),operate:'LIKE'},
-                {field: 'type_id',title: __('平台'),operate: '=', searchList: Yunqi.data.platformList},
-                {field: 'type_box', title: __('店铺名称'),operate: 'LIKE'},
-                {field: 'num', title: __('员工'),searchList: {1: __('日结'), 2: __('周结'), 3: __('半月结')}},
-                {field: 'status', title: __('状态'),width:120,searchList: {1: __('正常'),2: __('停用')},formatter:Yunqi.formatter.switch},
-                {field: 'create_time', title: __('创建时间'), width:160,formatter: Yunqi.formatter.datetime,operate:false,sortable: true},
+                {field: 'shop_id',title: __('店铺'),operate:'LIKE'},
+                {field: 'plat_id',title: __('平台'),operate: false, searchList: Yunqi.data.platformList},
+                {field: 'variety_id', title: __('品种'),operate: false},
+                {field: 'spec_id', title: __('规格'),operate: false},
+                {field: 'num', title: __('数量'),operate: false},
+                {field: 'weigh', title: __('重量'),operate: false},
+                {field: 'total_price', title: __('总价'),operate: false},
+                {field: 'status', title: __('状态'),width:120,searchList: {1: __('待结算'),2: __('已结算'), 3: __('驳回')},formatter:Yunqi.formatter.switch},
+                {field: 'settlement_data', title: __('结算时间'), width:160,formatter: Yunqi.formatter.datetime,operate:false,sortable: true},
+                {field: 'createtime', title: __('创建时间'), width:160,formatter: Yunqi.formatter.datetime,operate:false,sortable: true},
                 {
                     field: 'operate',
                     title: __('操作'),

+ 82 - 0
app/admin/view/user/stock_log/add.html

@@ -0,0 +1,82 @@
+<template>
+    <el-card shadow="never" style="border: 0;">
+        <yun-form
+            ref="yunform"
+            @render="onFormRender"
+            @submit="onSubmit"
+            @success="onSuccess"
+            @fail="onFail"
+            :data="row"
+            :columns="columns">
+            <template #default>
+                {:token_field()}
+            </template>
+    
+        </yun-form>
+    </el-card>
+</template>
+<script>
+import form from "@components/Form.js";
+export default{
+    components:{
+        'YunForm':form
+    },
+    data:{
+        columns:[
+            {field:"id",title:"ID",edit:"hidden"},
+            {field:"user_id",title:"user_id",edit:"number"},
+            {field:"type_id",title:"类型",edit:"text",rules:"required"},
+            {field:"type",title:"类型1是出库  2是入库",edit:"select",rules:"required",searchList:{1:"是",0:"否"}},
+            {field:"variety_id",title:"品种id",edit:"number"},
+            {field:"change",title:"变更数量",edit:"text",rules:"required"},
+            {field:"after",title:"当前库存",edit:"text",rules:"required"},
+            {field:"remark",title:"备注",edit:"text",rules:"required"},
+            {field:"createtime",title:"创建时间"},
+            {field:"updatetime",title:"变更时间"},
+        ],
+        row:Yunqi.data.row || {}
+    },
+    //页面加载完成时执行
+    onLoad:function(query){
+        console.log(query);
+    },
+    //页面初始显示或在框架内显示时执行
+    onShow:function(){
+
+    },
+    //页面在框架内隐藏时执行
+    onHide:function(){
+
+    },
+    //页面在框架内关闭时执行
+    onUnload:function(){
+
+    },
+    methods: {
+        onFormRender:function(rows){
+            //表单渲染完成后执行
+        },
+        onSubmit:function(rows){
+            //表单提交前执行,返回false可以阻止表单提交
+            /**
+             * form常用方法
+             * this.$refs.yunform.setError(field,message);//聚焦表单项并显示错误信息
+             * this.$refs.yunform.hideField(field);//隐藏表单项
+             * this.$refs.yunform.showField(field);//显示表单项
+             * this.$refs.yunform.setValue(field,value);//为表单项设置值
+             * this.$refs.yunform.getValue(field);//为获取表单项的值
+             * this.$refs.yunform.setField(field,key,value);//修改表单json的其他属性值,比如rules,title,searchList等
+             */
+            return true;
+        },
+        onSuccess:function(response){
+            //表单提交成功后执行
+        },
+        onFail:function(err){
+            //表单提交失败后执行
+        }
+    }
+}
+</script>
+<style>
+</style>

+ 1 - 0
app/admin/view/user/stock_log/edit.html

@@ -0,0 +1 @@
+{include vue="user/stock_log/add" /}

+ 99 - 0
app/admin/view/user/stock_log/index.html

@@ -0,0 +1,99 @@
+<template>
+    <el-card shadow="never">
+        <yun-table
+                :columns="columns"
+                ref="yuntable"
+                @render="onTableRender"
+                toolbar="refresh,add,edit"
+                :auth="{
+                    add:{:$auth->check('app\\admin\\controller\\user\\StockLog','add')},
+                    edit:{:$auth->check('app\\admin\\controller\\user\\StockLog','edit')},
+                    multi:{:$auth->check('app\\admin\\controller\\user\\StockLog','multi')},
+                }"
+                :extend="extend">
+        </yun-table>
+    </el-card>
+</template>
+<script>
+import table from "@components/Table.js";
+export default{
+    components:{
+        'YunTable':table
+    },
+    data:{
+        extend:{
+            index_url: 'user/stock_log/index',
+            add_url: 'user/stock_log/add',
+            edit_url: 'user/stock_log/edit',
+            multi_url: 'user/stock_log/multi',
+        },
+        columns:[
+            {checkbox: true,selectable:function (row,index){
+                return true;
+            }},
+            {field:"id",title:"ID",operate:false},
+            {field:"user_id",title:"用户"},
+            {field:"type_id",title:"类型"},
+            {field:"type",title:"类型",width: 80,formatter:function (data) {
+                    let tag=Yunqi.formatter.tag;
+                    if (data == 1) {
+                            tag.type='primary';
+                        tag.value='出库';
+                    }else{
+                        tag.type='success';
+                        tag.value='入库';
+                    }
+                    return tag;
+            }},
+            {field:"variety_id",title:"物品/品种",operate:false},
+            {field:"change",title:"变更数量"},
+            {field:"after",title:"当前库存"},
+            {field:"remark",title:"备注",operate:false},
+            {field:"createtime",title:"创建时间",operate:"daterange",formatter:Yunqi.formatter.datetime},
+            {field:"updatetime",title:"变更时间",visible:false,operate:false,formatter:Yunqi.formatter.datetime},
+            {
+                field: 'operate',
+                title: __('操作'),
+                width:130,
+                action:{
+                    edit:function(row){
+                        //可以根据业务需求返回false让按钮不显示
+                        return true
+                    },
+                }
+            }
+        ]
+    },
+    //页面加载完成时执行
+    onLoad:function(query){
+        console.log(query);
+    },
+    //页面初始显示或在框架内显示时执行
+    onShow:function(){
+
+    },
+    //页面在框架内隐藏时执行
+    onHide:function(){
+
+    },
+    //页面在框架内关闭时执行
+    onUnload:function(){
+
+    },
+    methods: {
+        onTableRender:function(list){
+            //表格渲染完成后执行
+            /**
+             * table常用方法
+             * this.$refs.yuntable.reset();//重新渲染整个组件,当columns修改时,需要重新渲染表格才能生效,可以执行该方法。
+             * this.$refs.yuntable.reload();//保持当前的page,重新获取数据
+             * this.$refs.yuntable.submit();//返回第一页,重新获取数据
+             * this.$refs.yuntable.expandAllTree();//树形表格展开所有节点
+             * this.$refs.yuntable.expandTree(topid);//树形表格展开指定节点
+             */
+        }
+    }
+}
+</script>
+<style>
+</style>

+ 75 - 0
app/api/controller/Index.php

@@ -0,0 +1,75 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\model\StockConfig;
+use app\common\model\ShopList;
+use app\common\model\StockLog;
+use think\exception\ValidateException;
+use app\api\validate\Stock as StockValidate;
+use think\facade\Db;
+
+class Index extends Base
+{
+
+
+
+      //首页数据分组统计品种
+      public function index(StockLog $stockLog)
+      {
+            $data= $stockLog->where('user_id', $this->userinfo['id'])
+                              ->field('type,count(id) as count')
+                              ->group('type')
+                              ->select();
+            $this->success('ok', $data);
+      }
+
+      //库存统计
+      public function statistics(StockConfig $stockConfig)
+      {
+            $list = $stockConfig->alias('a')->where('a.status', $stockConfig::StatusNormal)
+                  ->leftjoin('stock_detail b', 'a.id = b.key')
+                  ->field('a.id, a.type_id,a.title,b.num')
+                  
+                  ->select();
+
+            dump($list->toArray());die;// StockConfig::Status::NORMAL
+
+            $this->success('ok', $list);
+      }
+
+
+      /**
+     * @return void 全部平台
+      */
+      public function getPlatform()
+      {
+            $list  = site_config('addonsd.platform_list');
+            $this->success('提交成功', $list);
+      }
+
+      //获取店铺
+      public function getShop(ShopList $shopList){
+            
+            $platform_id = $this->request->post('platform_id/d');
+            if(empty($platform_id)){
+                  $this->error('参数有误');
+            }
+            return $this->success('ok', $shopList->where('platform', $platform_id)->column('name', 'id'));   
+      }
+
+      //获取规格
+      public function getSpec(ShopList $shopList){
+
+            $shop_id = $this->request->post('shop_id/d');
+            if( empty($shop_id)){
+                  $this->error('参数有误');
+            }
+            $spec = $shopList->where('id', $shop_id)->value('type_spec');
+            $shopList = $spec?json_decode($spec, true): [];
+            return $this->success('ok', $shopList);  
+      }
+
+
+   
+}

+ 52 - 9
app/api/controller/Inventory.php

@@ -18,7 +18,7 @@ class Inventory extends Base
     {
         $type_id = $this->request->post('type_id', 'variety_name');
         if(!in_array($type_id, [$stockConfig::VarietyName, $stockConfig::PackingBox, $stockConfig::Material])) $this->error(__('参数错误'));
-        $list = $stockConfig::where('type_id', $type_id)->field('id,title,field_name')->select();
+        $list = $stockConfig::where('type_id', $type_id)->field('id,title,field_name,unit')->select();
         $this->success('ok', $list);
     }
 
@@ -67,16 +67,59 @@ class Inventory extends Base
         $this->success('ok', $list);
     }
 
-    //首页数据
-    public function index(StockLog $stockLog)
+    //编辑出入库
+    public function stockedit(StockLog $stockLog)
     {
-        //分组统计品种
-        $data= $stockLog->where('user_id', $this->userinfo['id'])
-                        ->field('type,count(id) as count')
-                        ->group('type')
-                        ->select();
-        $this->success('ok', $data);
+        $data = $this->request->post();
+        $result = false;
+        Db::startTrans();
+        try {
+          
+            validate(StockValidate::class)->scene('add')->check($data);
+            
+            $resData = $stockService::setGoOutStock($this->userinfo['id'], $data);
+        
+            $result = $stockLog->saveAll($resData);
+            Db::commit();
+        }catch (ValidateException $e) {
+      
+            return $this->error($e->getError());
+        } catch (\Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        }
+        if ($result === false) {
+            $this->error(__('没有新增任何数据'));
+        }
+        $this->success();
     }
 
+
+    //删除出入库
+    public function stockdel(StockLog $stockLog)
+    {
+        $data = $this->request->post();
+        $result = false;
+        Db::startTrans();
+        try {
+          
+            validate(StockValidate::class)->scene('add')->check($data);
+            
+            $resData = $stockService::setGoOutStock($this->userinfo['id'], $data);
+        
+            $result = $stockLog->saveAll($resData);
+            Db::commit();
+        }catch (ValidateException $e) {
+      
+            return $this->error($e->getError());
+        } catch (\Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        }
+        if ($result === false) {
+            $this->error(__('没有新增任何数据'));
+        }
+        $this->success();
+    }
    
 }

+ 1 - 36
app/api/controller/Shops.php

@@ -3,7 +3,6 @@
 namespace app\api\controller;
 
 use app\api\validate\Shop as ShopValidate;
-use app\common\model\ShopList;
 use app\common\model\ShopDelivery;
 use think\Exception;
 use think\facade\Db;
@@ -14,40 +13,7 @@ class Shops extends Base
 {
     //protected $noNeedLogin = ['*'];
 
-    /**
-     * @return void 全部平台
-     */
-    public function getPlatform(){
-
-        $list  = site_config('addonsd.platform_list');
-        $this->success('提交成功', $list);
-    }
-
-    //获取店铺
-    public function getShop(ShopList $shopList){
-        
-        $platform_id = $this->request->post('platform_id/d');
-        if(empty($platform_id)){
-            $this->error('参数有误');
-        }
-        return $this->success('ok', $shopList->where('platform', $platform_id)->column('name', 'id'));   
-    }
-
-    
-
-    //获取规格
-    public function getSpec(ShopList $shopList){
-
-        $shop_id = $this->request->post('shop_id/d');
-        if( empty($shop_id)){
-            $this->error('参数有误');
-        }
-        $spec = $shopList->where('id', $shop_id)->value('type_spec');
-        $shopList = $spec?json_decode($spec, true): [];
-        return $this->success('ok', $shopList);  
-    }
-
-
+  
     //发货记录
     public function delivery(ShopDelivery $shopDelivery){
 
@@ -73,7 +39,6 @@ class Shops extends Base
     //添加记录
     public function create(ShopDelivery $shopDelivery, SpecService $specService)
     {
-
         $data = $this->request->post();
         $result = false;
         Db::startTrans();

+ 13 - 13
app/api/route/route.php

@@ -13,34 +13,34 @@ Route::group('user', function () {
     Route::rule('logout','user/logout','GET|POST');
 
     //平台
-    Route::rule('platform','shops/getPlatform','POST');
-
+    Route::rule('platform','index/getPlatform','POST');
     //店铺
-    Route::rule('shops','shops/getShop','POST');
-
+    Route::rule('shops','index/getShop','POST');
     //规格
-    Route::rule('specs','shops/getSpec','POST');
+    Route::rule('specs','index/getSpec','POST');
+    //首页数据
+    Route::rule('index','index/index','POST');
+    //库存统计
+    Route::rule('statistics','index/statistics','POST');
 
     //添加记录
     Route::rule('create','shops/create','POST');
-
     //发货记录
     Route::rule('delivery','shops/delivery','POST');
 
+
     //出入库数据
     Route::rule('stockList','inventory/stockList','POST');
-
     //出入库
     Route::rule('stock','inventory/stock','POST');
-
     //库存记录
     Route::rule('stocklog','inventory/stocklog','POST');
+    //编辑录入
+    Route::rule('stockedit','inventory/stockedit','POST');
+    //删除
+    Route::rule('stockdel','inventory/stockdel','POST');
 
-    //首页数据
-    Route::rule('index','inventory/index','POST');
-    //库存统计
-    Route::rule('statistics','inventory/statistics','POST');
-
+   
   })->middleware(AllowCrossDomain::class);
 
 

+ 0 - 1
app/api/service/SpecService.php

@@ -12,7 +12,6 @@ use app\common\model\StockDetail;
 class SpecService{
 
    
-
       //判断价格为空
       public static function getIsZeroSpecsPrice(array $data): bool
       {     

+ 7 - 0
app/common/model/StockConfig.php

@@ -13,4 +13,11 @@ class StockConfig extends BaseModel
       const PackingBox  = 'packing_box';
       const Material     = 'material';
 
+      //状态
+      const StatusNormal  = 1;
+      const StatusDisable = 0;
+
+
+
+
 }

+ 2 - 12
app/common/model/StockLog.php

@@ -1,30 +1,20 @@
 <?php
-
 declare(strict_types=1);
 
 namespace app\common\model;
 
+use think\Model;
 
-use app\common\model\base\BaseModel;
-
-class StockLog extends BaseModel
+class StockLog Extends Model
 {
-
-
-    
     // 自动写入时间戳字段
     protected $autoWriteTimestamp = true;
     protected $createTime = 'createtime';
     protected $updateTime = 'updatetime';
-    protected $deleteTime = false;
 
     protected $type = [
         'createtime'     =>  'timestamp:Y-m-d H:i',
         'updatetime'     =>  'timestamp:Y-m-d H:i',
-    
     ];
-   
-  
-
 
 }

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
runtime/cache/7a/b2b683b6c3e8e0985917962d853b9c.php


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно