delay.vue 8.55 KB
Newer Older
lanbaoming's avatar
lanbaoming 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
<template>
  <div class="app-container">
    <el-card>
      <el-form :model="handlerParams" ref="queryForms" size="small" :inline="true"  label-width="180px" class="card">

        <el-row>
          <el-form-item :label="$t('客户名称')+':'">
              <span style="margin-left: 8px;">{{handlerParams.customerName}}</span>
          </el-form-item>
        </el-row>
        <el-row >
          <el-form-item :label="$t('原计划掉入公海池时间')+':'">
            <span style="margin-left: 8px;">{{handlerParams.orgEstimateEnterOpenSeaTime}}</span>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item :label="$t('申请延期后掉入时间')+':'">
              <el-date-picker
                v-model="handlerParams.estimateEnterOpenSeaTime"
                type="date"
                :picker-options="pickerOptions"
                value-format="timestamp"
                :placeholder="$t('请输入申请延期后掉入时间')">
              </el-date-picker>
          </el-form-item>

        </el-row>
        <el-row :span="8">
          <el-form-item :label="$t('凭证')+':'" size="medium" :require="true">
            <upload v-model="handlerParams.voucher" :limit="1"></upload>
          </el-form-item>
        </el-row>
        <el-row :span="8">
          <el-form-item :label="$t('申请理由')+':'" size="medium">
            <el-input style="width: 500px;"  type="textarea" v-model="handlerParams.reason"  />
          </el-form-item>
        </el-row>
      </el-form>
    </el-card>
    <!-- 只有不需要预付才需要审核 -->
    <template>
      <div class="page-title">{{$t('审批流程')}}</div>
      <work-flow xmlkey="quotation_customer_delay_public" v-model="ccIdArr" />
    </template>
    <div slot="footer" class="dialog-footer">
      <!-- bpmStatus
      异常流程状态,1处理中2通过3不通过4已取消
      待审核可能没有bpmStatus字段
      -->
      <template v-if="handlerParams.status == 1">
        <el-button type="primary" @click="$router.push(`/bpm/process-instance/detail?id=`+handlerParams.formId)">{{$t('审核中')}}</el-button>
        <el-button plain type="primary" @click="cancelAudit">{{$t('取消审核')}}</el-button>
        <el-button plain type="primary" @click="$store.dispatch('tagsView/delCurrentView')">{{$t('返回')}}</el-button>
      </template>
      <template v-else>
        <el-button  type="primary" @click="submitForm">{{$t('提交')}}</el-button>
        <el-button plain type="primary" @click="$store.dispatch('tagsView/delCurrentView')">{{$t('取消')}}</el-button>
      </template>
    </div>
  </div>
</template>

<script>
  import upload from '@/components/ImageUpload'
  import {getDictData, getDictDatas} from  '@/utils/dict'
  import {getCustomer,getDelayInfo,creatDelayApproval,cancelDelayApproval} from '@/api/ecw/customer'
  import WorkFlow from '@/components/WorkFlow'
  import {cancelProcessInstance} from '@/api/bpm/processInstance'
  export default {
    name: "Delay",
    components: {
      upload, WorkFlow
    },
    data() {
      return {
        // 遮罩层
        loading: false,
        handlerParams:{
        },
        customerData:{},
        showWorkFlow: false, // 是否显示工作流
        dateRangeCreateTime:[],
        pickerOptions: {
        },
        ccIdArr:[]
      };
    },
  watch:{
    ccIdArr(){
      this.$set(this.handlerParams, 'ccIds', this.ccIdArr.join(','))
    }
  },
    created() {
      if(this.$route.query.id){
        this.getData(this.$route.query.id)
      }
    },
    methods: {
       getData(id){
         getCustomer(id).then(response => {
            this.customerData = response.data
            this.getDely(id)
         });
      },
      getDely(id){
        console.log(this.customerData)
        let that = this
        getDelayInfo({customerId:id}).then(res=>{
          if(res.data){
              that.handlerParams = res.data
              if(!that.handlerParams.orgEstimateEnterOpenSeaTime){
                that.handlerParams.orgEstimateEnterOpenSeaTime = that.getNowDate(that.customerData.enterOpenSeaTime)
              }
              if(that.handlerParams.estimateEnterOpenSeaTime){
                that.handlerParams.estimateEnterOpenSeaTime = that.getTime(that.handlerParams.estimateEnterOpenSeaTime)
              }else{
                that.$set(that.handlerParams,'estimateEnterOpenSeaTime',that.customerData.estimateEnterOpenSeaTime)
              }
              if(that.handlerParams.ccIds){
                var ids = that.handlerParams.ccIds.split(',')
                ids.map(v=>{
                  that.ccIdArr.push(parseInt(v))
                })

              }
              console.log(that.ccIdArr)
            }else{
              that.handlerParams = {
                  customerId:that.customerData.id,
                  customerName:that.customerData.name,
                  orgEstimateEnterOpenSeaTime: that.getNowDate(that.customerData.enterOpenSeaTime)
              }
            }
            that.pickerOptions = {
              disabledDate: (time) => {
                var date = new Date(that.handlerParams.orgEstimateEnterOpenSeaTime);
                  return (
                    time.getTime() < date.getTime()
                  );
                },
              }
        })
      },
      submitForm(){
          // if(!this.handlerParams.orderExceptionHandlerResult){
          //   this.$modal.msgError(this.$t('请选择处理结果'));
          //   return
          // }

            // if(!this.handlerParams.fileList||this.handlerParams.fileList.length==0){
            //   this.$modal.msgError(this.$t('请上传报关资料'));
            //   return
            // }
            this.$set(this.handlerParams,'createTime',this.formatDate())
            var params = Object.assign({},this.handlerParams)
            // var ccIds = Array.isArray(this.handlerParams.ccIds) ? this.handlerParams.ccIds.join(',') : this.handlerParams.ccIds
            // params.ccIds = ccIds
            params.voucher = Array.isArray(this.handlerParams.voucher) ? this.handlerParams.voucher.join(',') : this.handlerParams.voucher

            params.estimateEnterOpenSeaTime = this.getNowDate(this.handlerParams.estimateEnterOpenSeaTime)
          creatDelayApproval(params).then(res=>{
              this.$modal.msgSuccess(this.$t('提交成功'));
              this.$store.dispatch('tagsView/delCurrentView')
          })
      },
      getTime(dateTime){
        var date = new Date(dateTime);
        return date.getTime()
      },
      getNowDate(time) {
            if(time){
              var date = new Date(time);
            }else{
              var date = new Date();
            }

             var year = date.getFullYear() // 年
             var month = date.getMonth() + 1; // 月
             var day = date.getDate(); // 日
              // 给一位数的数据前面加 “0”
             if (month >= 1 && month <= 9) {
                  month = "0" + month;
             }
              if (day >= 0 && day <= 9) {
                  day = "0" + day;
              }
        return year + "-" + month + "-" + day

       },
       formatDate() {
         var date = new Date()
         var year = date.getFullYear()
         var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
         var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
         var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
         var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
         var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
         return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
       },
      // 取消审核
      cancelAudit(){
        this.$prompt("请输入取消原因", {
          inputPattern: /[\S]+/,
          inputErrorMessage: this.$t('不能为空')
        }).then(({value}) => {
          console.log(this.handlerParams.approvalId)
          return cancelDelayApproval({approveId:this.handlerParams.approvalId,reason:value})
        })
        .then(res => {
          this.$store.dispatch('tagsView/delCurrentView')
        })
      }
    }
  };
</script>

<style scoped>
  .card-title{
      font-size: 18px;
      font-weight: bold;
       margin-top: 10px;
  }
  .header{
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .card{
    margin-top: 20px;
  }
  .dialog-footer{
    padding: 40px;
    width: 60%;
    align-items: center;
    display: flex;
    /* justify-content: space-between; */
  }
</style>