<template>

  <a-modal
    :title="title"
    :width="1600"
    :height="1600"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
    cancelText="关闭"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    switchFullscreen
  >
    <a-spin :spinning="confirmLoading" style="text-align: center;">
        <img :src="imgsrc"  max-width="1600" max-height="1600"/>
    </a-spin>
  </a-modal>
</template>
<script>
import {httpAction, httpActionBlob, postAction} from '@/api/manage'

export default {
  name: 'PicForm',
  components: { },
  data() {
    return {
      imgsrc:'',
      title: '新增',
      visible: false,
      dataForm: {},
      confirmLoading: false,
      disaform: false,
      disableSubmit: false,
      dataRule: {
        name: [{ required: true, message: '请输入模型名称!' }],
        key: [{ required: true, message: '请输入模型key!' }]
      },
      url:{
        getPic:"/service/act/showResource"
      }
    }
  },
  computed: {

  },
  created() {
  },
  mounted() {

  },
  methods: {

    add () {
      this.visible = true
    },
    edit (record) {
      var that = this;
      var pid = record.id;
      var httpurl = this.url.getPic;
      var method = "GET";
      var paramer11 = {};
      paramer11.pdid = pid;
      httpActionBlob(httpurl+"?pdid="+pid,null,method).then((res)=>{
        console.log(res)
        // // that.imgsrc = res;
        // // this.imgsrc = window.URL.createObjectURL(res);
        // that.imgsrc = "data:image/png;base64,"+res;
        // console.log(123)
        // console.log(that.imgsrc)
        let currentMimeType = "image/png";
        let blob = new Blob([res], {
          type: currentMimeType,
        });
        that.imgsrc = window.URL.createObjectURL(blob)


      }).finally(() => {

      })

      this.visible = true
      // this.dataForm = Object.assign({}, record)
    },
    close () {
      this.$emit('close')
      this.visible = false
    },
    // 确定
    handleOk() {
      console.log('确定', this.dataForm)
      this.$refs.dataForm.validate(valid => {
        if (valid) {
          let url = 'act/remodel/save'
          postAction(url, this.dataForm).then(res => {
            console.log('res', res)
            if (res.success) {
              this.$message.success(res.message)
            } else {
              this.$message.error(res.message)
            }
            this.visible = false
            this.$emit('getModels')
          })
        } else {
          return false
        }
      })
    },
    // 关闭
    handleCancel() {
      this.close()
    }

  }
}
</script>

<style>
</style>
