index.vue 6.08 KB
Newer Older
godwithdh's avatar
1  
godwithdh committed
1 2
<style lang="less" >
    #specimen{
张锡奇's avatar
张锡奇 committed
3
        background: #f1f1f1;
godwithdh's avatar
1  
godwithdh committed
4
        height:100%;
张锡奇's avatar
张锡奇 committed
5 6 7
        .Header{
            height:250px;
            width:100%;
godwithdh's avatar
1  
godwithdh committed
8
            img{
张锡奇's avatar
张锡奇 committed
9 10
                width: 100%;
                height:100%;
godwithdh's avatar
1  
godwithdh committed
11 12
            }
        }
张锡奇's avatar
张锡奇 committed
13 14 15 16 17
        .INFO{
            background: white;
            margin-top:10px;
            padding: 10px;
            .CONTENT{
godwithdh's avatar
1  
godwithdh committed
18
                >div{
张锡奇's avatar
张锡奇 committed
19 20 21 22 23 24 25 26 27 28 29
                    display: flex;
                    border-bottom: 1px solid #F8F8F8;
                    >p{
                        margin:0;padding:0;
                        height:30px;
                        line-height: 30px;
                    }
                    >p:first-child{
                        width:80px;
                        color:#999999
                    }
godwithdh's avatar
1  
godwithdh committed
30 31 32 33
                }
            }
        }
        .detail{
张锡奇's avatar
张锡奇 committed
34 35 36 37 38 39 40 41
            margin-top:10px;
            background: #fffeeb;
            padding:20px;
            >div{
                margin-bottom:20px;
                p{
                    margin:0;text-align:center;height:30px;line-height:30px;
                    font-weight: bold;
张锡奇's avatar
张锡奇 committed
42
                }
godwithdh's avatar
1  
godwithdh committed
43
            }
张锡奇's avatar
张锡奇 committed
44 45 46 47 48 49 50 51 52 53
            >div:last-child{
                margin-bottom:0;
            }
            .detailImg{
                width:100%;
                height:200px;
                border-top-left-radius: 40px;
                border-bottom-right-radius: 40px;
            }
            
godwithdh's avatar
1  
godwithdh committed
54 55 56 57 58
        }
    }
</style>

<template>
张锡奇's avatar
张锡奇 committed
59 60 61 62 63 64 65 66 67 68 69 70
    <div id="specimen">
        <div class="Header">
            <img class="previewer-demo-img" v-for="(item, index) in hdr_src" :src="item.src" width="100" @click="show('hdr',index)" :key="index"/>
        </div>
        <div class="INFO">
            <div class="CONTENT">
                <div><p>产品编号</p><p>{{hdr.sMaterialNo}}</p></div>
                <div><p>产品名称</p><p>{{hdr.sMaterialName}}</p></div>
                <div><p>规格</p><p>{{hdr.sSdivecification}}</p></div>
                <div><p>成分</p><p>{{hdr.sComdivonent}}</p></div>
                <div><p>幅宽</p><p>{{hdr.sWidth}}</p></div>
                <div><p>克重</p><p>{{hdr.sGMWT}}</p></div>
godwithdh's avatar
1  
godwithdh committed
71 72
            </div>
        </div>
张锡奇's avatar
张锡奇 committed
73 74 75 76 77
        <div class="detail">
            <img src="../../assets/fabric.jpg" style="width:100%;margin-bottom:10px;"/>
            <div v-for="(item, index) in dtl_src" :key="index">
                <p style="">{{item.sColorName}}({{item.sColorNo}}) —</p>
                <img class="previewer-demo-img detailImg" :src="item.src" width="100" @click="show('dtl',index)" />
godwithdh's avatar
1  
godwithdh committed
78 79
            </div>
        </div>
张锡奇's avatar
张锡奇 committed
80 81 82
        <div v-transfer-dom>
            <previewer :list="hdr_src" ref="previewer1" :options="options" @on-index-change="logIndexChange"></previewer>
            <previewer :list="dtl_src" ref="previewer2" :options="options" @on-index-change="logIndexChange"></previewer>
godwithdh's avatar
1  
godwithdh committed
83 84 85 86 87
        </div>
    </div>
</template>

<script>
张锡奇's avatar
张锡奇 committed
88 89
import Util from '@/libs/util.js';
import {Previewer , TransferDom} from 'vux';
张锡奇's avatar
张锡奇 committed
90

godwithdh's avatar
1  
godwithdh committed
91 92 93 94 95 96 97 98 99
export default {
  name: 'specimen',
  data () {
    return {
        hdr_src:[],
        dtl_src:[],
        iProjectId:'',
        sMaterialNo:'',
        hdr:{},
张锡奇's avatar
张锡奇 committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
        dtl:[],
        options: {
            getThumbBoundsFn (index) {
                // find thumbnail element
                let thumbnail = document.querySelectorAll('.previewer-demo-img')[index]
                // get window scroll Y
                let pageYScroll = window.pageYOffset || document.documentElement.scrollTop
                // optionally get horizontal scroll
                // get position of element relative to viewport
                let rect = thumbnail.getBoundingClientRect()
                // w = width
                return {x: rect.left, y: rect.top + pageYScroll, w: rect.width}
                // Good guide on how to get element coordinates:
                // http://javascript.info/tutorial/coordinates
            }
        }
godwithdh's avatar
1  
godwithdh committed
116 117
    }
  },
张锡奇's avatar
张锡奇 committed
118 119 120 121 122 123
  directives: {
    TransferDom
  },
  components:{
      Previewer
  },
godwithdh's avatar
1  
godwithdh committed
124
  async mounted(){
张锡奇's avatar
张锡奇 committed
125 126 127 128 129 130
        this.iProjectId = this.$route.params.iProjectId;
        this.$route.params.sMaterialNo.split('.').map((x,y) => {
            this.sMaterialNo += String.fromCharCode(x)
        })
        await this.getSpeciminHdr();
        await this.getSpeciminDtl();
godwithdh's avatar
1  
godwithdh committed
131 132
  },
  methods:{
张锡奇's avatar
张锡奇 committed
133 134 135 136 137 138
    logIndexChange (arg) {
        console.log(arg)
    },
    show (type,index) {
        this.$refs[type == 'hdr' ? 'previewer1' : 'previewer2'].show(index)
    },
张锡奇's avatar
张锡奇 committed
139 140 141 142 143 144 145
    error(item,index,type){
        if(type == 'hdr'){
            this.$set(this.hdr,'isErr',true)
        }else{
            this.$set(this.dtl[index],'isErr',true)
        }
    },
godwithdh's avatar
1  
godwithdh committed
146 147 148 149 150 151
    async getSpeciminHdr(){
        let result = await this.request('getSpeciminHdr',{
            data:[
                {key: "url", value: "sMaterialName"},
                {key: "searchname", value: this.sMaterialNo}
            ]
张锡奇's avatar
张锡奇 committed
152 153
        },true,{iProjectId:this.iProjectId,sUserName:'huansi'});
        if(this.hdr.length <= 0) return false;
godwithdh's avatar
1  
godwithdh committed
154
        this.hdr = result[0];
张锡奇's avatar
张锡奇 committed
155
        this.hdr.isErr = false;
张锡奇's avatar
张锡奇 committed
156 157 158
        this.hdr_src.push({
            src: `https://weixin.huansi.net/apiproxy/huansi/Mall/mmmaterial/image_click/?iProjectId=${this.iProjectId}&iIden=${this.hdr.iIden}&m=${Math.random() / 9999}`,
        })
godwithdh's avatar
1  
godwithdh committed
159 160 161 162 163 164 165
    },
    async getSpeciminDtl(){
        let result = await this.request('getSpeciminDtl',{
            data:[
                {key: "url", value: "getDetail"},
                {key: "iIden", value: this.hdr.iIden}
            ]
张锡奇's avatar
张锡奇 committed
166
        },true,{iProjectId:this.iProjectId});
godwithdh's avatar
1  
godwithdh committed
167
        result.map(x=>{
张锡奇's avatar
张锡奇 committed
168 169 170 171 172 173 174
            x.tCreateTime = x.tCreateTime.replace(/-/g,'/').split('.')[0];
        })
        let data = result.sort((x,y)=>{
            return new Date(x.tCreateTime).getTime() - new Date(y.tCreateTime).getTime();
        })
        data.map(x=>{
            x.isErr = false;
张锡奇's avatar
张锡奇 committed
175 176 177 178 179
            this.dtl_src.push({
                sColorName:x.sColorName,
                sColorNo:x.sColorNo,
                src:`https://weixin.huansi.net/apiproxy/huansi/Mall/mmmaterial/image_click/?iProjectId=${this.iProjectId}&iIden=${x.iIden}&m=${Math.random() / 9999}`
            })
godwithdh's avatar
1  
godwithdh committed
180
        })
张锡奇's avatar
张锡奇 committed
181
        this.dtl = data;
张锡奇's avatar
张锡奇 committed
182
    }
godwithdh's avatar
1  
godwithdh committed
183 184 185 186 187
  }
}
</script>