
<template>
  <div class="table_box">
            <table
              border="1px"
             
              cellspacing="0"
              cellpadding="0"
              id="print_area"
            
              class="table_text"
            >
              <tr>
                <td colspan="6" align="center">长兴县芦笋产业联合</td>
              </tr>
              <tr>
                <td colspan="6" align="center">发货单</td>
              </tr>
              <tr>
                <td align="center">客户:</td>
                <!-- <td>浙江东茂供销公司</td> -->
                <td align="center">{{ informationData.customerName }}</td>
                <td align="center" width="100">联系人:</td>
                <!-- <td>张三</td> -->
                <td align="center" width="100">{{ informationData.linkman }}</td>

                <td align="center" width="100">电话:</td>
                <!-- <td>999</td> -->
                <td align="center" width="200">{{ informationData.phoneNumber }}</td>
              </tr>
              <tr>
                <td align="center">发往地:</td>
                <!-- <td>浙江省杭州市西湖区</td> -->
                <td align="center" colspan="5">{{ informationData.address }}</td>
              </tr>
              <tr>
                <td align="center">发货地址:</td>
                <!-- <td>浙江省湖州市长兴县长兴村</td> -->
                <td align="center" colspan="5">{{ informationData.deliveryAddress }}</td>
              </tr>
              <tr>
                <td align="center">序号</td>
                <td align="center">物品名称</td>
                <td align="center">规格</td>
                <td align="center">单位</td>
                <td align="center">重量</td>
                <td align="center">备注</td>
              </tr>
              <tr>
                <td align="center">1</td>
                <td align="center">芦笋</td>
                <td align="center">大笋</td>
                <td align="center">斤</td>
                <!-- <td>1200</td> -->
                <td align="center">{{ informationData.specificationBig }}</td>

                <td align="center" v-if="bigFlag">
                  <el-input
                    @blur="bigChange('big')"
                    class="inputStyle"
                    style="width: 260px"
                    v-model="bigInput"
                  ></el-input>
                </td>
                <td align="center" v-if="!bigFlag">
                  <span @click="bighaha('big')" style="width: 260px">
                    {{
                    bigInput
                    }}
                  </span>
                  <!-- <span @click="bigChange('bigClick')" style="background: red; width: 260px">{{
                    bigInput
                  }}</span>-->
                </td>
              </tr>
              <tr>
                <td align="center">2</td>
                <td align="center">芦笋</td>
                <td align="center">中笋</td>
                <td align="center">斤</td>
                <!-- <td>1200</td> -->
                <td align="center">{{ informationData.specificationMiddle }}</td>
                <td align="center" v-if="middleFlag">
                  <el-input
                    @blur="bigChange('middle')"
                    class="inputStyle"
                    style="width: 260px"
                    v-model="middleInput"
                  ></el-input>
                </td>
                <td align="center" v-if="!middleFlag">
                  <span @click="bighaha('middle')" style="width: 260px">
                    {{
                    middleInput
                    }}
                  </span>
                </td>
              </tr>
              <tr>
                <td align="center">3</td>
                <td align="center">芦笋</td>
                <td align="center">小笋</td>
                <td align="center">斤</td>

                <td align="center">{{ informationData.specificationSmall }}</td>
                <td align="center" v-if="smallFlag">
                  <el-input
                    @blur="bigChange('small')"
                    class="inputStyle"
                    style="width: 260px"
                    v-model="smallInput"
                  ></el-input>
                </td>
                <td align="center" v-if="!smallFlag">
                  <span @click="bighaha('small')" style="width: 260px">
                    {{
                    smallInput
                    }}
                  </span>
                </td>
              </tr>
              <tr>
                <td align="center">检测结果:</td>

                <td align="center" colspan="3">
                  <el-radio v-model="radio" label="1">合格</el-radio>
                </td>
                <td align="center" colspan="3">
                  <el-radio v-model="radio" label="2">不合格</el-radio>
                </td>
              </tr>
              <tr>
                <td align="center">出库方:</td>
                <td align="center">{{ informationData.outStorageName }}</td>
                <td align="center">司机姓名:</td>
                <td align="center">{{ informationData.driverName }}</td>
                <td align="center">车牌号:</td>
                <td align="center">{{ informationData.driverPhoneNumber }}</td>
              </tr>
              <tr>
                <td align="center">发货人:</td>
                <td align="center">{{ informationData.consigner }}</td>
                <td align="center">司机电话:</td>
                <td align="center" colspan="3">{{ informationData.driverPhoneNumber }}</td>
              </tr>
              <tr>
                <td align="center">发货日期:</td>
                <td align="center">{{ informationData.deliverTime }}</td>
                <td align="center">收货方签字:</td>
                <td align="center" v-if="signFlag" colspan="3">
                  <el-input @blur="bigChange('sign')" class="inputStyle" v-model="signInput"></el-input>
                </td>
                <td align="center" v-if="!signFlag" colspan="3">
                  <span @click="bighaha('sign')">{{ signInput }}</span>
                </td>
              </tr>
            </table>

</div>
</template>
<script>
import {
    getPrint,
} from "../../apis/modules/warehouseManagementPage.js";
import { login } from "../../apis/modules/asparagus.js";
export default {
  name: "deliveryPrint",
 data() {
    return {

  informationData: {
        address: "",
        bodyMegList: "",
        consigner: "",
        customerName: "",
        deliverTime: "",
        driverName: "",
        driverPhoneNumber: "",
        licenseNumber: "",
        linkman: "",
        outStorageName: "",
        phoneNumber: "",
        memberIds: "",
        specificationBig: "",
        specificationMiddle: "",
        specificationSmall: ""
      },
    bigFlag: false,
      middleFlag: false,
      smallFlag: false,

      signFlag: false,
      signInput: "",

      bigInput: "",
      smallInput: "",
      middleInput: "",
      radio: "",

    }},

      mounted() {
    
     this.getList() 
  },
  methods: {

  
    bigChange(type) {
      if (type == "big") {
        this.bigFlag = false;
      } else if (type == "middle") {
        this.middleFlag = false;
      } else if (type == "small") {
        this.smallFlag = false;
      } else if (type == "phone") {
        this.phoneFlag = false;
      } else {
        this.signFlag = false;
      }
    },
     bighaha(type) {
      this.bigFlag = true;

      if (type == "big") {
        this.bigFlag = true;
      } else if (type == "middle") {
        this.middleFlag = true;
      } else if (type == "small") {
        this.smallFlag = true;
      } else {
        this.signFlag = true;
      }
    },


      getList() {
      login({
        username: localStorage.getItem("userId"), // "7f6b359a68bb497f937d35982203f1c3",
        password: "",
        Terminal: "PC"
      }).then(res => {
        const { status, data } = res;
        if (status === 0) {
          localStorage.setItem("token", data.token);
         this.handlePrint();
        }
      });
    },

      handlePrint() {
        window.android.getMemberTimes(memberIds,timer);
    this.examinPrint = true;

      this.bigInput = "";

      this.bigFlag = true;

      this.middleInput = "";
      this.middleFlag = true;
      this.smallInput = "";
      this.smallFlag = true;
      this.signInput = "";
      this.signFlag = true;

      const params = { time:timer, memberIds: memberIds};

      getPrint(params).then(res => {
        const data = res.data;
        const dataSort = res.data.bodyMegList;
        dataSort.forEach(item => {
          if (item.specification == "" || item.specification == "大笋") {
            this.informationData.specificationBig = item.weight;
          } else {
            this.informationData.specificationBig = 0;
          }
          if (item.specification == "" || item.specification == "中笋") {
            this.informationData.specificationMiddle = item.weight;
          } else {
            this.informationData.specificationMiddle = 0;
          }
          if (item.specification == "" || item.specification == "小笋") {
            this.informationData.specificationSmall = item.weight;
          } else {
            this.informationData.specificationSmall = 0;
          }
        });

        this.informationData.address = data.address;

        this.informationData.consigner = data.consigner;
        this.informationData.customerName = data.customerName;
        this.informationData.deliverTime = data.deliverTime;
        this.informationData.driverName = data.driverName;
        this.informationData.driverPhoneNumber = data.driverPhoneNumber;
        this.informationData.licenseNumber = data.licenseNumber;
        this.informationData.linkman = data.linkman;
        this.informationData.outStorageName = data.outStorageName;
        this.informationData.phoneNumber = data.phoneNumber;
      });
    },

  }
}

</script>
<style scoped lang="scss">
.table_box {
 width: 100%;
          height:100%;
           .table_text{
              width: 860px;
          height: 1190px;
           margin: 0 auto;       
           }
}
</style>