// 船运调度详情
<template>
  <div class="container">
    <el-row>
      <el-col :span="20">
        <h2 class="bg-left title">船运调度详情</h2>
      </el-col>
      <el-col :span="4" class="bg-right">
        <el-button
          class="bg-bottom"
          type="primary"
          size="small"
          @click="revert()"
          ><img
            width="6"
            height="10"
            style="vertical-align: bottom; margin-right: 3px"
            src="../../../public/img/lujing.png"
            alt=""
          />返回</el-button
        >
      </el-col>
    </el-row>
    <div class="center">
    <ws-form ref="deptBudgetList" :model="deptBudgetList">
      <div class="basicInformation">
        <h2> 任务编号 </h2>
        <ws-info-table>
          <!-- 任务编号 -->
          <ws-form-item label="任务编号" span="1"  prop="processNo">
            <ws-input
              v-model="deptBudgetList.processNo" 
              placeholder="请输入任务编号"
              maxlength="20"
              size="small"
            />
            <!-- {{deptBudgetList.processNo}} -->
          </ws-form-item>
        <!-- 货名 -->
          <ws-form-item label="货名" span="1" prop="goodsName">
            <ws-input
              v-model="deptBudgetList.goodsName"
              placeholder="请输入货名"
              maxlength="20"
              size="small"
              />
              <!-- {{deptBudgetList.goodsName}} -->
          </ws-form-item>
          <!--重量（吨）-->
          <ws-form-item
            label="重量（吨）"
            span="1"
            prop="weight"
            class="readonly"
          >
            <ws-input
              v-model="deptBudgetList.weight"
              placeholder="请输入重重"
              maxlength="100"
              size="small"
            />
            <!-- {{deptBudgetList.weight}} -->
          </ws-form-item>

          <!--发货地址-->
          <ws-form-item label="发货地址" span="1">
            <!-- <ws-input
              readonly="readonly"
              v-model="deptBudgetList.sendDetailedAddress"
              placeholder=""
              maxlength="120"
              size="small"
            /> -->
             {{deptBudgetList.sendPrivate}}{{deptBudgetList.sendCity}}{{deptBudgetList.sendArea}}
          </ws-form-item>
         <!--发货人-->
          <ws-form-item label="发货人" span="1" prop="sender">
            <ws-input
              v-model="deptBudgetList.sender"
              placeholder="请输入发货人姓名"
              maxlength="100"
              size="small"
          />
          <!-- {{deptBudgetList.sender}} -->
          </ws-form-item>

          <!--发货人电话-->
          <ws-form-item label="发货人电话" span="1" prop="senderPhone">
            <ws-input
              v-model="deptBudgetList.senderPhone"
              placeholder="请输入发货人电话"
              maxlength="100"
              size="small"
            />
            <!-- {{deptBudgetList.senderPhone}} -->
          </ws-form-item>
          <!--收货地址-->
        <ws-form-item label="收货地址" span="1" prop="receiveDetailedAddress">
            <!-- <el-cascader
            v-model="deptBudgetList.receiveDetailedAddress"
            clearable
            size="large"
            placeholder="请选择发货地址"
            style="width: 200%"
          /> -->
          {{deptBudgetList.receivePrivate}}{{deptBudgetList.receiveCity}}{{deptBudgetList.receiveArea}}
        </ws-form-item>
         <!--收货人-->
          <ws-form-item label="收货人" span="1" prop="receiver">
            <ws-input
              v-model="deptBudgetList.receiver"
              placeholder="请输入发货人"
              maxlength="100"
              size="small"
          />
          <!-- {{deptBudgetList.receiver}} -->
          </ws-form-item>

          <!--收货人电话-->
          <ws-form-item label="收货人电话" span="1" prop="receiverPhone">
            <ws-input
              v-model="deptBudgetList.receiverPhone"
              placeholder="请输入收货人电话"
              maxlength="100"
              size="small"
            />
            <!-- {{deptBudgetList.receiverPhone}} -->
          </ws-form-item>
         
          <!--发船日期-->
        <ws-form-item label="发船日期" span="1" prop="deliveryDateStart">
          <ws-input
           
            v-model="deptBudgetList.deliveryDateStart"
            placeholder=""
            maxlength="20"
            size="small"
          />
        </ws-form-item>
           <!--最晚发货日期-->
          <ws-form-item label="最晚到货日期" span="1" prop="deliveryDateEnd">
          <ws-input
          
            v-model="deptBudgetList.deliveryDateEnd"
            placeholder=""
            maxlength="20"
            size="small"
          />
        </ws-form-item>
          <!--合同编号-->
          <ws-form-item label="合同编号" span="1" prop="contractNo">
          <ws-input
          
            v-model="deptBudgetList.contractNo"
            placeholder="请输入合同编号"
            maxlength="20"
            size="small"
          />
        </ws-form-item>
          
        </ws-info-table>
      <div class="small-title"><h2>联络员及航次</h2></div>
      <div
          style="width: 100%"
          class="flex position"
           v-for="(item, index) in deptBudgetList.tranCarInfoList"
           :key="index.id"
        >
        <ws-info-table>
          <!-- 姓名 -->
          <ws-form-item label="姓名" span="1" prop="driver" class="siji">
            <ws-input
            v-model="item.driver"
            placeholder="请选择联络员"
            size="small"
            ></ws-input>
          </ws-form-item>
          <!-- 电话 -->
          <ws-form-item label="电话" span="1" prop="driverPhone" class="siji">
            <ws-input
            v-model="item.driverPhone"
            placeholder="联络员电话"
            size="small"
            ></ws-input>

          </ws-form-item>
          <!--发船日期-->
          <ws-form-item label="发船日期" span="1" prop="sendDateStart" class="siji">
            <ws-input
                v-model="item.sendDateStart"
                placeholder="请选择日期"
                
            ></ws-input>
          </ws-form-item>
        <ws-form-item label="预计到港日期" span="1" prop="receiveDateEnd" class="siji">
          <ws-input
              v-model="item.receiveDateEnd"
              placeholder="请选择日期"
              value-format="yyyy-MM-dd"
              size="small"
            />
           
        </ws-form-item>
          <!-- 船名 -->
          <ws-form-item label="船名" span="1" prop="shipName" class="siji">
            <ws-input 
              v-model="item.shipName"
              placeholder="请输入船名"
              maxlength="100"
              size="small"
            ></ws-input>
          </ws-form-item>
          <!-- 航次 -->
          <ws-form-item label="航次" span="1" prop="shipNo" class="siji">
            <ws-input 
              v-model="item.shipNo"
              placeholder="请选择航次"
              maxlength="100"
              size="small"
            ></ws-input>
          </ws-form-item>
        <!-- 类型 -->
        <ws-form-item label="类型" span="1" prop="shipType" class="siji">
          <ws-input
          v-model="item.shipType"
          placeholder=""
          size="small"
          ></ws-input>
          
        </ws-form-item>
        <ws-form-item label="数量" span="1" prop="boxNumber" class="siji" v-show="item.shipType=='集装箱'"> 
          <ws-input
          v-model="item.boxNumber"
          placeholder="请输入数量"
          size="small"
          ></ws-input>
        </ws-form-item>
        </ws-info-table>
        </div>
      <div
          style="width: 100%"
          class="flex position"
         v-for="(item, index) in freightspace"
         :key="index"
        >
     <ws-info-table>
        <ws-form-item :label="'仓位号-'+ (index + 1 )" span="1" prop="impurity" class="bot">
            <ws-input
          v-model="item.impurity"
          placeholder="请输入仓位号"
          size="small"
          ></ws-input>
          </ws-form-item>
          <!-- 重量（吨） -->
          <ws-form-item label="重量(吨)" span="1" prop="positionWeight" class="bot">
          <ws-input
          v-model="item.positionWeight"
          placeholder="请输入装仓重量"
          size="small"
          ></ws-input>
        </ws-form-item>
        
     </ws-info-table>
      <!-- <img
            width="22"
            height="22"
            class="del"
            @click="del(index)"
            src="../../../public/img/del.png"
            alt=""
          /> -->
      </div>
      <!-- <el-button
          class="add"
          type="primary"
          size="small"
          @click="add()"
          >添加仓位</el-button
        > -->
      <div style="text-align: right; padding: 10px">
        
        <el-button
          class="bg-bottom-up"
          type="primary"
          size="small"
          @click="returnsales()"
          >关闭</el-button
        >
      </div>
      </div>
    </ws-form>
    </div>
  </div>
  
</template>
<script>
import { regionData, CodeToText, TextToCode } from 'element-china-area-data'
import {shippingList,shippingLook } from '@/model/transport/index'
import Pagination from '@/components/Pagination'
import WsUpload from '@/components/WsUpload'
// import { dayjs, fmoney, EventBus } from 'base-core-lib'
import { dayjs, EventBus } from 'base-core-lib'
export default {
  name: 'viewSpareMoney',
  components: {
    WsUpload,
    Pagination,
  },
  watch: {
    // vesselId(val) {
    //   this.getList()
    // },
    isShow(val) {
      this.showType = val
    },
  },
  data() {
    return {
      //弹出框
      dialogViewSpareMoney: false,
      dialogApproveFormVisible: false,
      // 船舶类型
      monetaryKey: null,
      // 表格显示数据
      tableDate: [],
      // 是否显示
      showType: true,
      // 年
      year: '',
      deptBudgetTotal: 0,
      currentPage: 1,
      pageSize: 10,
      searchType: 1,
      searchKeyWord: '',
      contractType: 2,
      startDate: null,
      endDate: null,
      goodnameList: {},
      // 提交类型
      submitType: true,
      storageType: [],
      readonly: true,
      appendixIdsAdd: '',
      uploadSuccess: {},
      onChange: {},
      gradeList: [],
       tranCarInfoList: [],
       list:[],
       arr:[],
       freightspace: [{ binNumber: '', maxStorage: '', remark: '' }],
      rules: {
        netWeight: [
          {
            required: true,
            type: 'number',
            message: '请输入活动名称',
            trigger: 'blur',
          },
        ],
      },
      size: 10,
      compId: sessionStorage.getItem('ws-pf_compId'),
      deptCircularPage: {},
      packtypeList: {},
      date: {
        year: dayjs().format('YYYY'),
        month: dayjs().format('MM'),
      },
      contractList: [],
      deptBudgetList: {
        warehouseInOutDetail: {},
        tranCarInfoList:[]
      },
      historyList: [],

      pickerBeginDateBefore: {
        disabledDate: (time) => {
          return time.getTime() > Date.now()
        },
      },
      accessoryTFs: false,
    }
  },
  mounted() {
    this.deptBudgetList.baseId = this.$route.query.baseId
    this.deptBudgetList.positionId = this.$route.query.positionId
    this.deptBudgetList.warehouseName = this.$route.query.warehouseName
    this.deptBudgetList.binNumber = this.$route.query.binNumber
    this.getList()
  },
 activated(){
    this.loaddata()
    
 },
  methods: {
    loaddata() {
      shippingLook({ id: this.$route.query.id })
        .toPromise()
        .then((response) => {
          this.deptBudgetList = response
          // this.deptBudgetList.driver = this.deptBudgetList.tranCarInfoList[0].driver
          // this.deptBudgetList.driverPhone = this.deptBudgetList.tranCarInfoList[0].driverPhone
          // this.deptBudgetList.sendDateStart = this.deptBudgetList.tranCarInfoList[0].sendDateStart
          //   this.deptBudgetList.sendDateStart = this.deptBudgetList.tranCarInfoList[0].sendDateStart
          //    this.deptBudgetList.receiveDateEnd = this.deptBudgetList.tranCarInfoList[0].receiveDateEnd
          //   this.deptBudgetList.shipName = this.deptBudgetList.tranCarInfoList[0].shipName
          //    this.deptBudgetList.shipNo = this.deptBudgetList.tranCarInfoList[0].shipNo
          //     this.deptBudgetList.shipType = this.deptBudgetList.tranCarInfoList[0].shipType
          //    this.deptBudgetList. boxNumber =this.deptBudgetList.tranCarInfoList[0].boxNumber
          for(var i = 0; i<this.deptBudgetList.tranCarInfoList.length;i++){
           var num  = this.deptBudgetList.tranCarInfoList[i].positionWeight.split("," )  
           for(var j = 0;j<num.length;j++){
            var num2 = num[j].split("/")
             this.freightspace.push({
               'impurity': num2[i],
               'positionWeight':num2[num2.length-1]
             })
           }

          }  
    })
  },
    getList(){
      shippingList({
        compId: sessionStorage.getItem('ws-pf_compId'),
        currentPage:this.currentPage,
        pageSize:this.pageSize,
        contractType:this.contractType,
        tranTypeKey: this.tranTypeKey, 
      })
      .toPromise()
      .then((response)=>{
        this.warehouseList = response 
      })
    },
    //返回按钮
    revert() {
      this.freightspace=[]
      this.$router.push({ path: 'tranManagementShipping' })
    },
    del(index){
        if(this.freightspace.length > 1 ){
            this.freightspace.splice(index,1)
        }
    },
      add() {
      this.freightspace.push({
        binNumber: '',
        maxStorage: '',
        remark: '',
      })
    },
    //提交按钮
    submit() { 
      this.$confirm(`暂存后可在待完成页面查看，确定暂存`, {
        cancelButtonText: '取消',
        confirmButtonText: '确定',
        type: 'warning',
      })
        .then(() => {
          this.$refs.deptBudgetList.validate((valid) => {
            if (valid) {
              this.deptBudgetList.compId = sessionStorage.getItem(
                'ws-pf_compId'
              )
              this.deptBudgetList.inOutFlag = 2
              this.deptBudgetList.statusFlag = 1
              addstorageputList(this.deptBudgetList)
                .toPromise()
                .then((response) => {
                  this.$message.success('暂存成功')
                  this.$router.push({ path: 'warehouseManagementList' })
                })
            } else {
              EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
              return false
            }
          })
        })
        .catch(() => {
          return false
        })
    },
  returnsales(){
     this.$router.push({ path: 'tranManagementShipping' })
  },
    handleClose() {
      this.accessoryTFs = false
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      console.log(`当前页: ${val}`)
      this.getList()
    },
    // getList() {
    //   // 货名
    //   pullDown({ constId: 'CON2' })
    //     .toPromise()
    //     .then((response) => {
    //       this.goodnameList = response
    //     })
    //   // 品级
    //   pullDown({ constId: 'CON3' })
    //     .toPromise()
    //     .then((response) => {
    //       this.gradeList = response
    //     })
    //   // 类型
    //   pullDown({ constId: 'CON5' })
    //     .toPromise()
    //     .then((response) => {
    //       this.storageType = response
    //     })
    // },
    selecttaskType(e) {
      for (var i = 0; i < this.taskTypeList.length; i++) {
        if (this.taskTypeList[i].value == e) {
          this.searchType = this.taskTypeList[i].type
        }
      }
    },
    // fujian(row) {
    //   if (
    //     row.receiveAttachmentPath === null ||
    //     row.receiveAttachmentPath === ''
    //   ) {
    //     EventBus.$emit(
    //       'warning',
    //       this.$t('system.noticeCircular.NoInformation')
    //     )
    //   } else {
    //     this.accessoryTFs = true
    //   }
    //   this.appendixIdss = row.receiveAttachmentPath
    // },
    approve() {},
    listQuery() {},
  },
}
</script>
<style lang="scss" scoped>
/deep/.basicInformation {
  .ws-info-table {
    border: none;
  }
  .el-form-item {
    width: 33.3333%;
    border: none;
    .el-form-item__label {
      background: transparent;
      border: none;
    }
    .el-form-item__content {
      border: none;
    }
  }
}
.title {
  position: relative;
  padding-left: 10px;
}
.title::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 30px;
  background: #5473e8;
  position: absolute;
  left: 0;
}
.el-form {
  padding: 0 10%;
}
.el-button--primary {
  background-color: #5878e8;
  border-color: #5878e8;
}
.el-col {
  background: #f6f7fc;
}
.bg-right {
  text-align: right;
  padding: 16px 20px;
}
.center{
  width: 80%;
  margin: 0 auto;
}

//表格文字
/deep/.ws-info-table .el-form-item .el-form-item__label {
  text-align: left;
  font-size: 14px;
  font-weight: 400;
  color: #8890b1;
  line-height: 16px;
}
//蓝标
.small-title {
  position: relative;
  padding: 10px;
  font-weight: 600;
}
.small-title::before {
  position: absolute;
  content: '';
  display: block;
  background: #5473e8;
  width: 4px;
  height: 14px;
  left: 0px;
  top: 13px;
  padding: 4px 2px;
}
.position{
  width: 90%;
}
.position .siji{
  width: 16%;
}
/deep/.position .ws-info-table .el-form-item .el-form-item__label{
  width: 40%;
  text-align: center;
}
.position .zaizhong{
  width: 16%;
}
//减号
.del {
  right: -70px;
}
.bot{
  width: 30%;
}
.siji{
  width: 300px;
}
/deep/.el-form-item {
  border-right: 0px;
  border-bottom: 0px;
}
/deep/.ws-info-table {
  border-left: 0px;
  border-top: 0px;
}
.ws-info-table .el-form-item .el-form-item__content {
  border-right: 0px;
  border-bottom: 0px;
  border-left: 0px;
  border-top: 0px;
}
/deep/.ws-info-table .el-form-item {
  border-right: 0px;
  border-bottom: 0px;
  border-left: 0px;
  border-top: 0px;
}
/deep/.ws-info-table .el-form-item .el-form-item__content {
  background: #f5f7fa;
  border-radius: 4px;
  border: 1px solid #d8dce6;
  font-family: PingFangSC-Regular, PingFang SC;
  margin-bottom: 5px;
  background-color: #fff;
  font-size: 14px;
  font-weight: 400;
  color: #8890b1;
  line-height: 16px;
}
/deep/.ws-info-table .el-form-item .el-form-item__label {
  background-color: #fff;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #8890b1;
  line-height: 16px;
}

/deep/.ws-info-table .el-form-item .el-form-item__content {
  background: #f5f7fa;
  border-radius: 4px;
  border: 1px solid #d8dce6;
}
/deep/.flex .ws-info-table .el-form-item .el-form-item__content{
  border: 0px;
}
/deep/.ws-class-table-col {
  height: auto;
  padding: 0px 2px;
  /deep/.el-input__inner {
    padding: 0px 2px;
  }
}
/deep/.is-disabled {
  .el-input__prefix,
  .el-input__suffix {
    display: none;
  }
  .el-input__inner {
    background-color: #fff;
    border-color: #fff !important;
    color: #000 !important;
    font-size: 14px;
    cursor: text;
    padding: 0 !important;
  }
}
</style>
