<template>
  <div class="diaryList">
    <div class="whiteBlock title">
      <el-form :inline="true" size="medium" :model="formInline" class="demo-form-inline">
        <el-form-item label="车牌号：">
          <el-input v-model="formInline.carNumber" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit" plain>查询</el-button>
          <el-button type="primary" @click="refreshBtn" plain>刷新</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="content whiteBlock">
      <vue-scroll style="height: 100%">
        <el-table class="tables" :data="tableList">
          <el-table-column prop="serialNo" label="流水号" align="center"></el-table-column>
          <el-table-column prop="licensePlate" label="车牌号" align="center"></el-table-column>
          <el-table-column prop="forwardingUnit" label="发货单位 " align="center"></el-table-column>
          <el-table-column prop="receivingUnit" label="收货单位 " align="center"></el-table-column>
          <el-table-column prop="goodsName" label="货名" align="center"></el-table-column>
          <el-table-column prop="specifications" label="规格" align="center"></el-table-column>
          <el-table-column prop="reserve" label="备注 " align="center"></el-table-column>
          <el-table-column prop="tare" label="毛重" align="center"></el-table-column>
          <el-table-column prop="grossWeight" label="皮重" align="center"></el-table-column>
          <el-table-column prop="netWeight" label="净重" align="center"></el-table-column>
          <el-table-column prop="tareTime" width="200px" label="毛重时间" align="center"></el-table-column>
          <el-table-column prop="grossTime" width="200px" label="皮重时间" align="center"></el-table-column>
          <el-table-column label="操作" align="center">
            <template slot-scope="scope">
              <div class="tableBtns">
                <div @click="seePhonegrap(scope.row.weighPicList)" class="operationText">
                  <i class="el-icon-delete" style="color: #eb5760; font-size: 16px; margin-right: 2px"></i>
                  <span>查看过磅照片</span>
                </div>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="pagerBox"
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNo"
          :page-sizes="$store.state.PAGESIZRS"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next"
          :total="Number(total)"
        ></el-pagination>
      </vue-scroll>
      <el-dialog title="过磅照片" :modal-append-to-body="false" :visible.sync="dialogVisiblePhone" width="40%" :before-close="handleClose" @close="closeDialog">
        <div>
          <div>
            <h6>第一次称重照片</h6>
            <div v-if="srcList.length !== 0">
              <el-image class="imgStyle" :src="`${imgUrl}/image/${phoneList.emptyPic1}`" :preview-src-list="srcList"> </el-image>
              <el-image class="imgStyle" :src="`${imgUrl}/image/${phoneList.emptyPic2}`" :preview-src-list="srcList"> </el-image>
              <el-image class="imgStyle" :src="`${imgUrl}/image/${phoneList.emptyPic3}`" :preview-src-list="srcList"> </el-image>
              <el-image class="imgStyle" :src="`${imgUrl}/image/${phoneList.emptyPic4}`" :preview-src-list="srcList"> </el-image>
            </div>
            <div v-else>
              暂无数据
            </div>
          </div>
          <div>
            <h6>第二次称重照片</h6>
            <div v-if="srcList.length !== 0">
              <el-image class="imgStyle" :src="`${imgUrl}/image/${phoneList.fullPic1}`" :preview-src-list="srcList"> </el-image>
              <el-image class="imgStyle" :src="`${imgUrl}/image/${phoneList.fullPic2}`" :preview-src-list="srcList"> </el-image>
              <el-image class="imgStyle" :src="`${imgUrl}/image/${phoneList.fullPic3}`" :preview-src-list="srcList"> </el-image>
              <el-image class="imgStyle" :src="`${imgUrl}/image/${phoneList.fullPic4}`" :preview-src-list="srcList"> </el-image>
            </div>
            <div v-else>
              暂无数据
            </div>
          </div>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import {
  getWeighInfoList,
  getReceiptAndShipmentList,
  getTradeNameList,
  addWeighInfoItem,
  editWeighInfoItem,
  deleteWeighInfoItem,
  weighTypeList
} from '@/assets/js/api/quality.js'
import axios from 'axios'

export default {
  components: {
    //   diaryMod,
  },
  data() {
    return {
      projectSn: '',
      formInline: {
        carNumber: ''
      },
      downloadData: {}, //下载数据
      tableList: [],
      pageNo: 1,
      pageSize: -1,
      total: 0,
      dialogVisiblePhone: false,
      phoneList: [],
      imgUrl: axios.defaults.baseURL,
      srcList: []
    }
  },
  created() {
    this.projectSn = this.$store.state.projectSn
    this.getListData()
  },
  methods: {
    seePhonegrap(val) {
      this.dialogVisiblePhone = true
      if (val) {
        this.phoneList = val[0]
      }else{
        this.phoneList = []
      }
      console.log(this.phoneList)
      let arr = Object.values(this.phoneList)
      arr.forEach((item, index, array) => {
        if (index !== 0 && index < 9) {
          this.srcList.push(`${this.imgUrl}/image/${array[index]}`)
        }
      })
    },
    handleClose(done) {
      done()
    },
    closeDialog(){
      this.srcList.splice(0, this.srcList.length)
      console.log("关闭",this.srcList);
    },
    //获取列表数据
    getListData() {
      let data = {
        licensePlate: this.formInline.carNumber,
        projectSn: this.projectSn,
        pageNo: this.pageNo,
        pageSize: this.pageSize
      }
      getWeighInfoList(data).then(res => {
        console.log('称重', res)
        this.tableList = res.result.records
        this.total = res.result.total
      })
    },
    //查询按钮
    onSubmit() {
      this.pageNo = 1
      this.getListData()
    },
    //刷新按钮
    refreshBtn() {
      this.pageNo = 1
      this.pageSize = 10
      this.formInline = {
        carName: ''
      }
      this.getListData()
    },
    //查看条数
    handleSizeChange(val) {
      this.pageNo = val
      this.pageSize = 10
      this.getListData()
    },
    //查看页
    handleCurrentChange(val) {
      this.pageNo = val
      this.pageSize = 10
      this.getListData()
    }
  }
}
</script>
<style lang="less" scoped>
.diaryList {
  width: 100%;
  height: 100%;
}
.title {
  padding: 20px 15px 0;
  width: 100%;
}
.content {
  margin-top: 15px;
  height: calc(100% - 93px);
}
.table_wrap {
  width: 100%;
  height: 100%;
  padding: 15px 20px;
}
table {
  border-collapse: collapse;
}

table,
td,
th {
  border: 1px solid #dde5f9;
  text-align: left;
  // height: 35px;
  // line-height: 35px;
  padding: 10px 15px;
}

.setTd {
  width: 25%;
}
.site {
  text-align: right;
}
.site2 {
  text-align: center;
}
.ellipsis {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.imgStyle {
  width: 170px;
  height: 100px;
  margin-left: 10px;
}
</style>
