chuweiqiang 1 年之前
父節點
當前提交
a89ac923ec
共有 3 個文件被更改,包括 373 次插入42 次删除
  1. 78 3
      app/admin/controller/ShopOcean.php
  2. 179 0
      app/admin/view/shop_ocean/edit.html
  3. 116 39
      app/admin/view/shop_ocean/index.html

+ 78 - 3
app/admin/controller/ShopOcean.php

@@ -36,7 +36,7 @@ class ShopOcean extends Controller
         }
         $this->title='海运订单管理';
         $this->assign('status',\app\data\model\ShopPurchase::getStatus());
-        Model::mQuery()
+        $result = Model::mQuery()
             ->with(['merchant'])
             ->when($request['name'],function (Query $query)use ($request){
                 $query->hasWhere('merchant',function (Query $query)use ($request){
@@ -44,8 +44,10 @@ class ShopOcean extends Controller
                 });
             })->where($admin_id)
             ->equal('status')
-            ->dateBetween('create_time')
-            ->layTable();
+            ->dateBetween('create_time');
+//            ->layTable();
+        $this->amount = $result->db()->sum('amount');
+        $result->page();
     }
     /**
      * 详情
@@ -106,4 +108,77 @@ class ShopOcean extends Controller
             $this->success('保存成功');
         }
     }
+
+    /**
+     * 编辑
+     * @auth true
+     * @menu true
+     */
+    public function edit(Request $request,Model $purchase,\think\Validate $validate){
+//        $this->title='发布订单';
+//        $this->assign('vo',null);
+        if($request->isGet()) {
+            DataUser::$copyRealName=true;
+            $config = systemConfig('merchant_config.packing')?:[];
+            $this->assign('config',$config);
+            $row = $purchase
+                ->with(['merchant','items','offers','favourite','ppoffer'])
+                ->where('id',$request['id'])->findOrFail();
+            if (!$row['merchant']){
+                $array = ['company'=>'平台发布'];
+                $row['merchant'] = $array;
+            }
+//            var_dump($row['form']);die;
+            $row['fm'] = explode(',',$row['form']);
+
+            $this->assign('row',$row);
+            $this->fetch('edit');
+        }else{
+            $merchant=DataMerchants::getByAdmin(AdminService::getUserId());
+            if(!$merchant){
+                $this->error('您不是商家无法发布');
+            }
+            $data=$request->post();
+            $item=$data['item']??[];
+            foreach ($item as $i){
+                $make=$validate->check($i,[
+                    'name'=>['require',],
+                    'weight'=>['require','integer'],
+//                    'spec'=>['require',],
+//                    'number'=>['require','integer'],
+//                    'standard'=>['require',],
+//                    'price'=>['require','float'],
+                ]);
+                if(!$make){
+                    $this->error('请填写正确的商品信息');
+                }
+            }
+
+            app()->db->startTrans();
+            unset($data['item']);
+            $data['admin_id']=AdminService::getUserId();
+            $data['form']=implode(',',$data['fm']);
+            $data['longitude']=$merchant['longitude']??null;
+            $data['latitude']=$merchant['latitude']??null;
+//            $data['amount']=min(array_column($item,'price'));
+            $data['type'] =1;
+//            $order= \app\data\model\ShopOcean::create($data);
+            $order=Model::update($data);
+            $order->items()->saveAll($item);
+            app()->db->commit();
+            $this->success('保存成功');
+        }
+    }
+
+    /**
+     * 取消订单
+     * @auth true
+     * @menu true
+     */
+    public function cancellation(Request $request, \app\data\model\ShopOcean $purchase){
+        $purchase_=$purchase->where('id',$request['id'])->findOrFail();
+        $purchase_['status']=0;
+        $purchase_->save();
+        $this->success('取消成功');
+    }
 }

+ 179 - 0
app/admin/view/shop_ocean/edit.html

@@ -0,0 +1,179 @@
+{extend name="../../admin/view/main"}
+{block name='content'}
+<style>
+    .layui-card-body{
+        background: white;
+    }
+    #newForm{
+        width: 80%;
+    }
+    .image{
+        width: 100px;
+        height: 100px;
+    }
+    .video{
+        width: 200px;
+        height: 200px;
+    }
+    .child-form{
+        width: 500px;
+        background: #f4f4f4;
+        padding: 10px;
+        display: inline-block;
+    }
+</style>
+<div id="newForm">
+    <el-form :model="form" label-width="140px" ref="form" size="medium">
+        <el-form-item label="联系人" prop="real_name" :rules="{message:'此项必须',required:true}">
+            <el-input v-model="form.real_name"></el-input>
+        </el-form-item>
+        <el-form-item label="联系电话" prop="mobile" :rules="{message:'此项必须',required:true}">
+            <el-input v-model="form.mobile"></el-input>
+        </el-form-item>
+        <el-form-item label="包装形式">
+            {foreach $config as $a}
+            <label>{$a}<input type="checkbox"  v-model="form.fm" value="{$a}"></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            {/foreach}
+        </el-form-item>
+        <!--        <el-form-item label="生产技术标准" prop="standard_tech" :rules="{message:'此项必须',required:true}">
+                    <el-input v-model="form.standard_tech"></el-input>
+                </el-form-item>
+                <el-form-item label="生产验收标准" prop="standard_check" :rules="{message:'此项必须',required:true}">
+                    <el-input v-model="form.standard_check"></el-input>
+                </el-form-item>-->
+
+        <el-form-item label="商品信息:" prop="item" :rules="[{message:'此项必须',required:true},{type:'array',min:1,message:'需要商品信息'}]">
+            <div><el-button @click="addItem">添加</el-button></div>
+            <div v-for="(item,idx) in form.item" class="child-form">
+                <i class="el-icon-delete" @click="deleteItem(idx)"></i>
+                <el-form-item label="商品名称">
+                    <el-input v-model="item.name"></el-input>
+                </el-form-item>
+                <!--                <el-form-item label="规格">-->
+                <!--                    <el-input v-model="item.spec"></el-input>-->
+                <!--                </el-form-item>-->
+                <el-form-item label="数量/吨位">
+                    <el-input type="number" v-model="item.weight"></el-input>
+                </el-form-item>
+
+
+                <!--                <el-form-item label="质量标准">
+                                    <el-input v-model="item.standard"></el-input>
+                                </el-form-item>
+                                <el-form-item label="采购价">
+                                    <el-input v-model="item.price"></el-input>
+                                </el-form-item>-->
+            </div>
+        </el-form-item>
+
+        <el-form-item label="图片视频" prop="files">
+            <el-button @click="addFile('image')">增加图片/视频</el-button>
+            <div>
+                <div v-for="(item,idx) in form.images" :key="idx" style="display: inline-block;">
+                    <el-image v-if="item.type==='image'" :src="item.src" class="video"></el-image>
+                    <video controls v-else :src="item.src" class="video"></video>
+                    <a @click="form.images.splice(idx,1)">删除</a>
+                </div>
+            </div>
+        </el-form-item>
+
+
+        <el-form-item label="装货码头" :rules="{message:'此项必须',required:true}" prop="wharf_to">
+            <el-input v-model="form.wharf_to"></el-input>
+        </el-form-item>
+        <el-form-item label="到港码头" :rules="{message:'此项必须',required:true}" prop="wharf_for">
+            <el-input v-model="form.wharf_for"></el-input>
+        </el-form-item>
+        <!--        <el-form-item label="交货时间" :rules="{message:'此项必须',required:true}" prop="post_time">
+                    <el-date-picker type="datetime" v-model="form.post_time" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
+                </el-form-item>-->
+        <el-form-item>
+            <el-button type="primary" @click="save" :loading="saving">保存</el-button>
+            <el-button @click="history.back()">取消</el-button>
+        </el-form-item>
+    </el-form>
+    <div style="display: none;">
+        <button data-type="zip" data-file id="fileUpload"></button>
+    </div>
+</div>
+<script>
+    let editorContent;
+    let vo={:json_encode($row?:null,256)};
+    require(['ckeditor'], function () {
+
+    });
+    vo.item=vo.items
+    new Vue({
+        el:'#newForm',
+        data:()=>({
+            form:vo||{
+                real_name:null,
+                mobile:null,
+                standard_tech:null,
+                standard_check:null,
+                item:[],
+                images:[],
+                fm:[]
+            },
+            saving:false,
+        }),
+        methods:{
+            addItem(){
+                this.form.item.push({
+                    name:null,
+                    // spec:null,
+                    number:null,
+                    weight:0,
+                    // standard:null,
+                    // price:null,
+                })
+            },
+            deleteItem (key) {
+                this.form.item.splice(key, 1)
+            },
+            addFile(){
+                $('#fileUpload').unbind('upload.done')
+                $('#fileUpload').on('upload.done',  (e,obj) => {
+                    let type=obj.file.type.split('/')[0]
+                    if(['image','video'].indexOf(type)===-1){
+                        this.$message.error('请上传正确的格式')
+                        return
+                    }
+                    this.form.images.push({
+                        type:type,
+                        src:obj.data.url
+                    })
+                });
+                $('#fileUpload').trigger('click')
+            },
+            save(){
+                let _this=this,
+                    form=this.form
+                this.$refs.form.validate(v=>{
+                    if(!v){
+                        return
+                    }
+                    $.ajax('{:sysuri()}',{
+                        data:form,
+                        type:'post',
+                        beforeSend(){
+                            _this.saving=true
+                        },
+                        success({code,info}){
+                            if(code){
+                                _this.$message.success('保存成功')
+                                window.history.back()
+                            }else{
+                                _this.$message.error(info)
+                            }
+                        },
+                        complete(){
+                            _this.saving=false
+                        }
+                    })
+                })
+            }
+        }
+    })
+</script>
+{/block}

+ 116 - 39
app/admin/view/shop_ocean/index.html

@@ -45,50 +45,127 @@
                 <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
             </div>
         </form>
-        <table id="NewsTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
+        <div class="layui-tab-content">
+
+            <table class="layui-table margin-top-10" lay-skin="line">
+                {notempty name='list'}
+                <thead>
+                <tr>
+                    <th>ID</th>
+                    <th>订单号</th>
+                    <th>商家名称</th>
+                    <th>联系人</th>
+                    <th>联系方式</th>
+                    <th>包装形式</th>
+                    <th>装货码头</th>
+                    <th>到港码头</th>
+                    <th>发布时间</th>
+                    <th>操作面板</th>
+                </tr>
+                </thead>
+                {/notempty}
+                <tbody>
+                {foreach $list as $key=>$vo}
+                <tr>
+                    <!--                <td class='list-table-check-td think-checkbox'>-->
+                    <!--                    <label><input class="list-check-box" type='checkbox' value='{$vo.id}'></label>-->
+                    <!--                </td>-->
+                    <td class="nowrap">
+                        {$vo.id}
+                    </td>
+                    <td class="nowrap">
+                        {$vo.order_no}
+                    </td>
+                    <td class="nowrap">
+                        {$vo.merchant.name}
+                    </td>
+                    <td class="nowrap">
+                        {$vo.real_name}
+                    </td>
+                    <td class="nowrap">
+                        {$vo.mobile}
+                    </td>
+                    <td class="nowrap">
+                        {$vo.form}
+                    </td>
+                    <td class="nowrap">
+                        {$vo.wharf_to}
+                    </td>
+                    <!--                    <td class="nowrap">-->
+                    <!--                        {if $vo.amount == 0.00}-->
+                    <!--                        '未匹配'-->
+                    <!--                        {else}-->
+                    <!--                        {$vo.amount}-->
+                    <!--                        {/if}-->
+                    <!--                    </td>-->
+                    <td class="nowrap">
+                        {$vo.wharf_for}
+                    </td>
+                    <td class="nowrap">
+                        {$vo.create_time}
+                    </td>
+
+                    <td class="nowrap">
+                        <div>
+                            <a class="layui-btn layui-btn-primary layui-btn-sm" data-modal="{:url('detail')}?id={$vo.id}" data-area='["1200px","90%"]'>查看详情</a>
+                            {if $vo.status == 1}
+                            <a class="layui-btn layui-btn-primary layui-btn-sm" data-open="{:url('edit')}?id={$vo.id}" data-area='["1200px","90%"]'>编辑</a>
+
+                            <a class="layui-btn layui-btn-primary layui-btn-sm" data-confirm="确定要取消订单吗?" data-action="{:url('cancellation')}?id={$vo.id}" data-area='["1200px","90%"]'>取消订单</a>
+                            {/if}
+                        </div>
+                    </td>
+                </tr>
+                {/foreach}
+                </tbody>
+            </table>
+            {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+
+        </div>
+<!--        <table id="NewsTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>-->
     </div>
 </div>
 {/block}
 
 {block name='script'}
 <script>
-    let status={:json_encode($status,256)};
-    $(function () {
-        // 初始化表格组件
-        $('#NewsTable').layTable({
-            even: true, height: 'full',
-            sort: {field: 'id desc', type: 'desc'},
-            where: {},
-            cols: [[
-                //{checkbox: true, fixed: true},
-                {field: 'id', title: 'ID', align: "center"},
-                {field: 'order_no', title: '订单号', align: "center"},
-                {field: '', title: '商家名称', align: "center",templet(a){
-                        return a.merchant?a.merchant.name:''
-                    }},
-                {field: 'real_name', title: '联系人', align: "center"},
-                {field: 'mobile', title: '联系方式', align: "center"},
-                {field: 'form', title: '包装形式', align: "left"},
-                {field: 'wharf_to', title: '装货码头', align: "left"},
-                {field: 'wharf_for', title: '到港码头', align: "left"},
-                {field: 'create_time', title: '发布时间', align: 'center', minWidth: 170, sort: true},
-                {toolbar: '#toolbar', title: '操作面板', align: 'center', minWidth: 80, fixed: 'right'},
-            ]]
-        });
-
-        // 数据状态切换操作
-        layui.form.on('switch(StatusSwitch)', function (obj) {
-            var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
-            $.form.load("{:url('state')}", data, 'post', function (ret) {
-                if (ret.code < 1) $.msg.error(ret.info, 3, function () {
-                    $('#NewsTable').trigger('reload');
-                }); else {
-                    $('#NewsTable').trigger('reload');
-                }
-                return false;
-            }, false);
-        });
-    });
+    // let status={:json_encode($status,256)};
+    // $(function () {
+    //     // 初始化表格组件
+    //     $('#NewsTable').layTable({
+    //         even: true, height: 'full',
+    //         sort: {field: 'id desc', type: 'desc'},
+    //         where: {},
+    //         cols: [[
+    //             //{checkbox: true, fixed: true},
+    //             {field: 'id', title: 'ID', align: "center"},
+    //             {field: 'order_no', title: '订单号', align: "center"},
+    //             {field: '', title: '商家名称', align: "center",templet(a){
+    //                     return a.merchant?a.merchant.name:''
+    //                 }},
+    //             {field: 'real_name', title: '联系人', align: "center"},
+    //             {field: 'mobile', title: '联系方式', align: "center"},
+    //             {field: 'form', title: '包装形式', align: "left"},
+    //             {field: 'wharf_to', title: '装货码头', align: "left"},
+    //             {field: 'wharf_for', title: '到港码头', align: "left"},
+    //             {field: 'create_time', title: '发布时间', align: 'center', minWidth: 170, sort: true},
+    //             {toolbar: '#toolbar', title: '操作面板', align: 'center', minWidth: 80, fixed: 'right'},
+    //         ]]
+    //     });
+    //
+    //     // 数据状态切换操作
+    //     layui.form.on('switch(StatusSwitch)', function (obj) {
+    //         var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
+    //         $.form.load("{:url('state')}", data, 'post', function (ret) {
+    //             if (ret.code < 1) $.msg.error(ret.info, 3, function () {
+    //                 $('#NewsTable').trigger('reload');
+    //             }); else {
+    //                 $('#NewsTable').trigger('reload');
+    //             }
+    //             return false;
+    //         }, false);
+    //     });
+    // });
 
 </script>
 
@@ -114,4 +191,4 @@
     <a class="layui-btn layui-btn-primary layui-btn-sm" data-modal="{:url('detail')}?id={{d.id}}" data-area='["1200px","90%"]'>查看详情</a>
     <!--{/if}-->
 </script>
-{/block}
+{/block}