chuweiqiang há 1 ano atrás
pai
commit
dfbb141567

+ 72 - 3
app/admin/controller/ShopCoor.php

@@ -34,7 +34,7 @@ class ShopCoor 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){
@@ -42,8 +42,10 @@ class ShopCoor extends Controller
                 });
             })->where($admin_id)
             ->equal('status')
-            ->dateBetween('create_time')
-            ->layTable();
+            ->dateBetween('create_time');
+//            ->layTable();
+        $this->amount = $result->db()->sum('amount');
+        $result->page();
     }
     /**
      * 详情
@@ -99,4 +101,71 @@ class ShopCoor 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()) {
+            $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',],
+                    'spec'=>['require',],
+                    'number'=>['require','integer'],
+//                    'enclosure'=>['require',],
+//                    'price'=>['require','float'],
+                ]);
+                if(!$make){
+                    $this->error('请填写正确的商品信息');
+                }
+            }
+            app()->db->startTrans();
+            unset($data['item']);
+            $data['admin_id']=AdminService::getUserId();
+            $data['longitude']=$merchant['longitude']??null;
+            $data['latitude']=$merchant['latitude']??null;
+//            $data['amount']=min(array_column($item,'price'));
+            $data['type'] =1;
+//            $order= \app\data\model\ShopCoordination::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\ShopCoordination $purchase){
+        $purchase_=$purchase->where('id',$request['id'])->findOrFail();
+        $purchase_['status']=0;
+        $purchase_->save();
+        $this->success('取消成功');
+    }
 }

+ 187 - 0
app/admin/view/shop_coor/edit.html

@@ -0,0 +1,187 @@
+{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="生产技术标准" 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 v-model="item.number"></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>-->
+                <el-form-item label="文件" prop="enclosure">
+                    <el-button @click="addFiles(null,item.enclosure)">增加</el-button>
+                    <div>
+                        <span v-for="(val,idx) in item.enclosure" :key="idx">
+                            <el-tag type="text" @close="item.enclosure.splice(idx,1)" closable>{{val.filename}}</el-tag>
+                        </span>
+                    </div>
+                </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.file" :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.file.splice(idx,1)">删除</a>
+                </div>
+            </div>
+        </el-form-item>
+        <el-form-item label="交货地址" :rules="{message:'此项必须',required:true}" prop="post_address">
+            <el-input v-model="form.post_address"></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:[],
+                file:[],
+            },
+            saving:false,
+        }),
+        methods:{
+            addItem(){
+                this.form.item.push({
+                    name:null,
+                    spec:null,
+                    number:null,
+                    // standard:null,
+                    // price:null,
+                    enclosure:[]
+                })
+            },
+            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
+                    }
+                    form.push({fileurl:obj.data.url,filename:obj.data.url.split('/')[obj.data.url.split('/').length-1]})
+                    this.form.file.push({
+                        type:type,
+                        src:obj.data.url
+                    })
+                });
+                $('#fileUpload').trigger('click')
+            },
+            addFiles(ext,form){
+                $('#fileUpload').unbind('upload.done')
+                $('#fileUpload').on('upload.done',  (e,obj) => {
+                    if(ext && obj.file.type.indexOf(ext)===-1){
+                        this.$message.error('请上传正确的格式')
+                        return
+                    }
+                    form.push({fileurl:obj.data.url,filename:obj.data.url.split('/')[obj.data.url.split('/').length-1]})
+                    // form.push(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}

+ 71 - 2
app/admin/view/shop_coor/index.html

@@ -44,7 +44,76 @@
                 <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>
+                </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.post_address}
+                    </td>
+                    <td class="nowrap">
+                        {$vo.post_time}
+                    </td>
+                    <!--                    <td class="nowrap">-->
+                    <!--                        {if $vo.amount == 0.00}-->
+                    <!--                        '未匹配'-->
+                    <!--                        {else}-->
+                    <!--                        {$vo.amount}-->
+                    <!--                        {/if}-->
+                    <!--                    </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}
@@ -112,4 +181,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}