<template>
  <div class="up-acceptance-sheet">
    <cy-info-title>上游验收单</cy-info-title>
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      :rules="rules"
      label-position="top"
      label-width="150px"
      class="rule-form-orange"
    >
      <el-form-item
        label="验收单附件"
        prop="desc"
        style="width: 100%;"
        class="form-required"
      >
        <cy-upload
          ref="fileStorage"
          :upload-params="{}"
          :file-data="ruleForm.fileStorageList"
          :upload-from-orange-status="true"
          placeholder="请上传验收单附件"
          :disabled="true"
        />
      </el-form-item>

    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    details: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      ruleForm: {
        fileStorageList: []
      },
      rules: {

      }
    }
  },
  watch: {
    details: {
      handler: function(newV) {
        if (newV && Object.keys(newV).length) {
          const { file } = JSON.parse(JSON.stringify(newV))
          this.ruleForm.fileStorageList = file
        }
      },
      immediate: true,
      deep: true
    }
  },
  methods: {
    validate(submitType) {
      return new Promise((resolve, reject) => {
        if (submitType === 'submit') {
          this.$refs.ruleFormRef.validate(valid => {
            if (valid) {
              return resolve(this.ruleForm)
            } else {
              reject()
              return false
            }
          })
        } else {
          resolve(this.ruleForm)
        }
      })
    }
  }

}
</script>

<style lang="scss" scoped>
    .up-acceptance-sheet {
    .el-form {
      padding: 10px 20px;
    }
    }
</style>
