track.vue 12.4 KB
Newer Older
张锡奇's avatar
张锡奇 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
<style lang="less" >
    #searchOrderTrack{
        height:100%;
        background:white;
        display:flex;
        flex-direction:column;
        .scrollContainer1{
            flex-grow: 1;
            height:1px;
            overflow: scroll;
            -webkit-overflow-scrolling: touch;
            // padding-bottom: 42px;
        }
        .scrollContainer2{
            height:100%;
        }
        .basic{
            padding:0 20px;
            .Title{
                height:40px;
                display: flex;
                align-items: center;
            }
            .items{
                position: relative;
                margin-bottom:10px;
            }
            .items:before{
                content:"";
                position: absolute;
                left:-10px;
                border:2px solid #5cadff;
                height:100%;
            }
            .content{
                display: flex;
                line-height:25px;
                >div>span:first-child{
                    color:#aaa;
                    display: inline-block;
                    width:70px;
                }
                >div:nth-child(odd){
                    flex:1;
                    text-align: left;
                }
                >div:nth-child(even){
                    width:40%;
                    text-align: right;
                }
            }
        }
        
        .line{
            flex:1;
            border:0.5px solid #bbb;
            margin-left:15px;
        }
        .Table{
            margin-top:10px;
        }
        .btns{
            position: fixed;
            bottom:0;
            width:100%;
        }
    }
</style>

<template>
    <div id="searchOrderTrack">
        <div class="basic">
            <div class="Title">
                <span>基本信息</span>
                <div class="line"></div>
            </div> 
            <div>
                <div class="content">
                    <div><span>订单号:</span>{{hdr.sOrderNo}}</div>
                    <div>{{hdr.dReceivedDate}}</div>
                </div>
                <div class="content">
                    <div><span>客户:</span>{{hdr.sCustomerName}}</div>
                </div>
                <div class="content">
                    <div><span>产品:</span><span @click="routerToMaterialDetail" style="color:#5cadff;text-decoration:underline;">{{hdr.sSampleMaterialName}}{{hdr.sSampleMaterialNo}}</span></div>
                </div>
                <div class="content">
                    <div><span>总数量:</span><span style="color:#5cadff;">{{nAllQty}}</span></div>
                    <div><span>总金额:</span><span style="color:#5cadff;">{{nAllAmount}}</span></div>
                </div>
            </div>
        </div>
        <div class="Table">
            <customerTable :columns="columns" :list="dtl" :tableStyle="tableStyle"></customerTable>  
        </div>
        <div class="scrollContainer2">
            <div class="basic" v-for="(v1,i1) in orderallmes" :key="i1"  style="font-size:12px;">
                <div class="Title">
                    <span>{{v1.sType}}</span>
                    <div class="line"></div>
                </div> 
                <div class="items" v-for="(v2,i2) in v1.child" :key="i2">
                    <div class="content">
                        <div><span>{{v1.sType.substr(0,2)}}单号:</span>{{v2.sBillNo}}</div>
                        <div>{{v2.dDate}}</div>
                    </div>
                    <div class="content">
                        <div><span>{{v1.sCheckItemName}}</span>{{v2.sCheckItem}}</div>
                    </div>
                    <div class="content">
                        <div><span>产品:</span>{{v2.sMaterialNameSample}}</div>
                    </div>
                    <div class="content" v-for="(v3,i3) in v2.child" :key="i3" style="display:block;">
                        <div style="display:flex;lin-height:25px;">
                            <div style="display:flex;max-width:40%;width:40%;min-height:40%;flex:none;">
                                <span style="min-width:70px;display:inline-flex;align-items:center;">颜色:</span>
                                <div style="display:flex;flex-wrap:wrap;">
                                    <div style="width:100%;display:flex;align-items:center;">{{v3.sColorNo}}</div>
                                    <!-- <div style="width:100%;">色号</div> -->
                                </div>
                            </div>
                            <div style="max-width:30%;width:30%;min-height:30%;flex:none;display: flex;align-items: center;justify-content: flex-start;word-break:break-word;">
                                <span style="width:50px;min-width:50px;min-width:50px;">数量:</span>
                                <span style="color:#5cadff;text-align:left;">{{v3.nQty || 0}}{{v3.sUnit}}</span>
                            </div>
                            <div style="max-width:30%;width:30%;min-height:30%;flex:none;display: flex;align-items: center;justify-content: flex-end;">
                                <span style="width:50px;min-width:50px;min-width:50px;">金额:</span>
                                <span style="color:#5cadff;width:40%;max-with:40%;min-height:40%;word-break:break-word;text-align:left;">{{v3.nAmount || 0}}</span>
                            </div>
                        </div>
                        <div style="width:100%;text-align:left;display:flex;color:#FF8247;" v-if="!v2.isAll">
                            <span style="color:#FF8247;">摘要:</span>
                            <div style="flex:1;word-wrap: break-word;">{{v3.sRemark}}</div>
                        </div>
                    </div>
                    <div class="content" v-if="v2.isAll" style="line-height:normal;">
                        <div style="display:flex;color:#FF8247;">
                            <span style="color:#FF8247;">摘要:</span>
                            <div style="flex:1;word-wrap: break-word;">{{v2.sRemark}}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- <div class="btns">
            <x-button :gradients="['#1D62F0', '#19D5FD']" @click.native="share">转发</x-button>
        </div>
        <div id="photo">
            <img class="imgDownload" :src="url" style="width:100%;">
        </div> -->
    </div>
</template>

<script>
import Util from '@/libs/util.js'
import customerTable from '@/components/Table'
import { mapState } from 'vuex'
import { XButton } from 'vux'

export default {
    name: 'searchOrderTrack',
    data () {
        return {
            host:'https://weixin.huansi.net/apiproxy/huansi/service/proxy/',
            // host:'http://192.168.4.40:5001',
            columns:[
                {
                    width:'20vw',
                    name:'颜色',
                    align:'center',
                    field:'sColorName',
                    fixed:true
                },
                {
                    width:'15vw',
                    name:'单价',
                    align:'center',
                    field:'nPrice',
                },
                {
                    width:'15vw',
                    name:'数量',
                    align:'center',
                    field:'nQty'
                },
                {
                    width:'15vw',
                    name:'金额',
                    align:'center',
                    field:'nAmount'
                },
                {
                    width:'35vw',
                    name:'摘要',
                    align:'center',
                    field:'sRemark'
                }
            ],
            tableStyle:{
                theadBgColor:'rgba(176,226,255,0.3)',
                complexTrBgColor:'white',
                singleTrBgColor:'#eef4fe',
                theadTdBorder:false,
                tbodyTdBorder:false,
                tbodyHeight:'auto',
                tbodyTrBorderBottom:'0.5px solid #5cadff'
            },
            dtl:[],
            nAllQty:0,
            nAllAmount:0,
            orderallmes:[],
            url:"",
            direction:''
        }
    },
    async mounted(){
        window.d = this;
    },
    async activated(){
        // window.removeEventListener("resize", this.renderResize, false)
        // window.addEventListener("resize", this.renderResize, false)
        this.clean();
        await this.getDetail();
        await this.getOrderallmes();
    },
    computed:{
        ...mapState({
            hdr:state => state.searchOrder.hdr,
            userId:state => state.app.userId
        })
    },
    methods:{
        renderResize() {
            // 判断横竖屏
            let width = document.documentElement.clientWidth
            let height = document.documentElement.clientHeight
            if(width > height) {
                this.direction = 'cross'
            }else{
                this.direction = 'vertical';
            }
            // 做页面适配
            // 注意:renderResize方法执行时虚拟dom尚未渲染挂载,如果要操作vue实例,最好在this.$nextTick()里进行。
        },
        routerToMaterialDetail(){
            this.$store.dispatch('searchOrderSaveDtl',this.hdr);
            this.$router.push({name:'searchOrderMaterialDetail'})
            // this.$store.dispatch('searchOrderSaveHdr',this.hdr);
            // this.$router.push({name:'searchOrderDetail'})
        },
        async getDetail(){
            let res = await this.apiGet(`${this.host}${this.userId}/fabricorder/dtl/`,{
                uGUID:this.hdr.uGUID
            },true);
张锡奇's avatar
张锡奇 committed
256
            
张锡奇's avatar
张锡奇 committed
257 258 259 260 261 262 263 264 265 266
            if(res.length > 0){
                this.dtl = res[0].child;
                this.nAllAmount = res[0].nAllAmount;
                this.nAllQty = res[0].nAllQty;
            }
        },
        async getOrderallmes(){
            let res = await this.apiGet(`${this.host}${this.userId}/fabricorder/orderallmes/`,{
                sOrderNo:this.hdr.sOrderNo
            },true);
张锡奇's avatar
张锡奇 committed
267
            
张锡奇's avatar
张锡奇 committed
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
            if(res.length > 0){
                this.orderallmes = res;
                for(let x of this.orderallmes){
                    x.child = x.child.filter(x=>x.sBillNo)
                }
                this.orderallmes = this.orderallmes.filter(x=>x.child.length > 0);

                this.orderallmes.map((x,i1)=>{
                    x.child.map((y,i2)=>{
                        let arr = Array.from(new Set((y.child.map(z=>z.sRemark))))
                        if(arr.length > 1){
                            y.isAll = false;
                        }else{
                            y.sRemark = arr.join('');
                            y.isAll = true;
                        }
                    })
                })
            }
        },
        clean(){
            this.orderallmes = [];
            this.dtl = [];
            this.nAllAmount = 0;
            this.nAllQty = 0;
        },
        share(){
            // wx.miniProgram.postMessage({ data: { imgBase64: imageUrl } })
       var shareContent = document.getElementById("searchOrderTrack");
            var that = this;
            html2canvas( shareContent,{
                onrendered: function(canvas){
                    var img = new Image();
                    img.src = canvas.toDataURL();
                    var url = img.src.replace('data:image/png;base64,','');
                    
                    wx.miniProgram.postMessage({ data: { imgBase64: url } })


                    // var triggerEvent = "touchstart";
                    // var blob=new Blob([''], {type:'application/octet-stream'});
                    // var url = URL.createObjectURL(blob);
                    // return false;
                    // var a = document.createElement('a');
                    // a.href = img.src;
                    // a.download = img.src.replace(/(.*\/)*([^.]+.*)/ig,"$2").split("?")[0];
                    // var e = document.createEvent('MouseEvents');
                    // e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
                    // a.dispatchEvent(e);
                    // URL.revokeObjectURL(url);
                    // document.getElementById("photo").appendChild(img);
                }
            })
        },
    },
    components:{
        customerTable,
        XButton
    },
}
</script>