<template>
  <el-dialog :title="$t('异常')" :before-close="()=>{$emit('update:showExceptionOther',false)}" center
             :visible.sync="showExceptionOther" fullscreen>
    <el-form ref="form" :model="form" label-width="200">
      <el-descriptions :column="4" border class="card" :labelStyle="{ width: '110px' }"
                       :contentStyle="{ width: '110px' }"
                       style="margin-top: 10px">
        <el-descriptions-item :label="$t('快递单号') + ':'">
          {{ form.expressNo }}
        </el-descriptions-item>
        <el-descriptions-item :label="$t('发货人') + ':'">
          {{ form.customerNumber }}
        </el-descriptions-item>
        <el-descriptions-item :label="$t('签收时间') + ':'">
          {{ form.signedTime }}
        </el-descriptions-item>
        <el-descriptions-item :label="$t('在仓时间') + ':'">
          ggggg
        </el-descriptions-item>
        <el-descriptions-item :label="$t('商品信息') + ':'">
          {{ form.goodListName }}
        </el-descriptions-item>
        <el-descriptions-item :label="$t('运输方式') + ':'">
          <dict-tag :type="DICT_TYPE.ECW_CUSTOMER_TRANSPORT_TYPE" :value="form.transportId" />
        </el-descriptions-item>
        <el-descriptions-item :label="$t('始发地') + ':'">
          {{ form.startTitleZh }}
        </el-descriptions-item>
        <el-descriptions-item :label="$t('目的地') + ':'">
          {{ form.destTitleZh }}
        </el-descriptions-item>
      </el-descriptions>

      <h2>{{ $t("异常信息") }}</h2>

      <el-form-item :label="$t('异常类型')">
        <dict-tag :type="DICT_TYPE.CONS_EXCEPTION_TYPE" :value="form.exceptionType" />
      </el-form-item>
      <el-form-item :label="$t('异常描述')">
        {{ form.exceptionRemark }}
      </el-form-item>
      <el-form-item :label="$t('附件')">
        <image-upload v-model="form.exceptionUrls" :isShowEditButton="!look"></image-upload>
      </el-form-item>
      <!--      <el-row>-->
      <!--        <el-col :span="8">-->
      <!--          <el-form-item :label="$t('跟进状态')">-->
      <!--          </el-form-item>-->
      <!--        </el-col>-->
      <!--        <el-col :span="8">-->
      <!--          <el-form-item :label="$t('跟进人')">-->
      <!--          </el-form-item>-->
      <!--        </el-col>-->
      <!--        <el-col :span="8">-->
      <!--          <el-form-item :label="$t('跟进时间')">-->
      <!--          </el-form-item>-->
      <!--        </el-col>-->
      <!--      </el-row>-->
      <!--      <el-form-item :label="$t('跟进备注')">-->
      <!--      </el-form-item>-->
      <el-form-item :label="$t('处理时间')">
        {{ form.handlerTime }}
      </el-form-item>
      <el-form-item :label="$t('处理结果')">
        <dict-tag :type="DICT_TYPE.CONS_EXCEPTION_STATUS" :value="form.exceptionStatus" />
      </el-form-item>
      <el-form-item :label="$t('备注')">
        <el-input v-model="form.handlerRemark" :rows="3" type="textarea" style="width: 500px" v-if="!look"></el-input>
        <template v-else>{{form.handlerRemark}}</template>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm" v-if="!look">{{ $t("确 定") }}</el-button>
      <el-button @click="$emit('update:showExceptionOther',false)">{{ $t("取 消") }}</el-button>
    </span>
  </el-dialog>
</template>
<script>
import imageUpload from "@/components/ImageUpload/index.vue"
import {
  getConsException,
  updateConsException
} from "@/api/ecw/consException"
import ProductSelector from "@/components/ProductSelector/index.vue"
import Template from "@/views/cms/template/index.vue"

export default {
  name: "exceptionOtherHandling",
  components: { Template, ProductSelector, imageUpload },
  props: {
    id: Number,
    showExceptionOther: Boolean,
    look: Boolean
  },
  data() {
    return {
      form: {}
    }
  },
  methods: {
    submitForm() {
      this.$refs.form.validate(validate => {
        if (validate) {
          console.log(this.form.handlerResult)
          this.form.exceptionStatus = 2
          this.form.mediaBusinessType = 1
          updateConsException(this.form).then(response => {
            this.$emit("update:showExceptionOther", false)
            this.$emit("determine")
            this.$modal.msgSuccess("修改成功")
          })
        }
      })
    }
  },
  watch: {
    showExceptionOther(val) {
      if (val) {
        getConsException({id:this.id}).then(response => {
          this.form = response.data
        })
      } else {
        this.form = {}
      }
    }
  }
}
</script>

<style scoped>

</style>
