<!--金相分析-->
<template>
  <div class="app-container">
    <sticky style="margin-bottom: 10px;">
      <btn ref="btn" />
    </sticky>
    <el-form ref="ysjl" :model="ysjl" class="el-form" label-position="right" label-width="130px">
      <fieldset>
        <legend>基本信息</legend>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="报告编号" prop="baogaobianhao">
              <el-input v-model="ysjl.baogaobianhao" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="管道名称" prop="shebeimingcheng">
              <el-input v-model="ysjl.shebeimingcheng" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="管道规格(外径mm×壁厚mm)" label-width="200px" prop="guandaoguige">
              <el-input v-model="param.guandaoguige" :disabled="edit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="管道编号" prop="guandaobianhao">
              <el-input v-model="param.guandaobianhao" :disabled="edit" />
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="管道材质" prop="guandaocaizhi">
              <el-input v-model="param.guandaocaizhi" :disabled="edit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="管道级别" prop="guandaojibie">
              <el-input v-model="param.guandaojibie" :disabled="edit" />
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="热处理状态" prop="rechulizhuangtai">
              <el-input v-model="param.rechulizhuangtai" :disabled="edit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="取样部位" prop="quyangbuwei">
              <el-input v-model="param.quyangbuwei" :disabled="edit" />
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="试样编号" prop="shiyangbianhao">
              <el-input v-model="param.shiyangbianhao" :disabled="edit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="仪器型号" prop="fenxiyiqixinghao">
              <el-input v-model="param.fenxiyiqixinghao" :disabled="edit" />
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="放大倍数" prop="fangdabeishu">
              <el-input v-model="param.fangdabeishu" :disabled="edit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="腐蚀方法" prop="fushifangfa">
              <el-input v-model="param.fushifangfa" :disabled="edit" />
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="抛光方法" prop="paoguangfangfa">
              <el-input v-model="param.paoguangfangfa" :disabled="edit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="18">
            <el-form-item label="执行标准" prop="zhixingbiaozhun">
              <el-input v-model="param.zhixingbiaozhun" :disabled="edit" />
            </el-form-item>
          </el-col>
        </el-row>
      </fieldset>
      <fieldset>
        <legend>金相照片或分析部位</legend>
        <span v-if="state === 'create'" style="color: red;font-size: 26px;">请在原始报告保存后上传部位图</span>
        <pictureUpload v-else ref="picture" :info="info" @changed="changed" />
      </fieldset>
      <fieldset>
        <legend>检验信息</legend>
        <el-form-item label="分析结果" prop="jiancejieguo">
          <el-input v-model="param.jiancejieguo" :disabled="edit" type="textarea" rows="4" style="width: 800px;" />
        </el-form-item>
        <el-form-item label="" prop="jianyanrenyuan" style="display: none;">
          <el-input v-model="ysjl.jianyanrenyuan" type="text" />
        </el-form-item>
      </fieldset>
    </el-form>
  </div>
</template>
<script>
import Sticky from '@/components/Sticky'
import pictureUpload from '@/components/Upload'
import btn from '@/views/common/FxButton'
export default {
  name: 'GdZbgJxfx',
  components: { Sticky, btn, pictureUpload },
  data() {
    return {
      ysjl: {},
      param: {},
      fileList: [],
      state: '',
      edit: false,
      info: {
        ysjlId: this.$route.query.id,
        jyxm: this.$route.query.jyxm,
        limit: 1,
        multiple: false
      }
    }
  },
  watch: {
    state: function(val) {
      this.$refs.picture.stateChange(val)
    }
  },
  created() {
    this.getInfo()
  },
  methods: {
    getInfo() {
      this.api({
        url: '/fx/getFxByYsjlId',
        method: 'get',
        params: {
          ysjlId: this.$route.query.id,
          jyxm: this.$route.query.jyxm
        }
      }).then(data => {
        this.ysjl = data.ysjl
        this.state = 'create'
        if (data.param !== null && data.param !== undefined) {
          // 有分项原始报告参数
          this.state = 'update'
          this.param = data.param
          this.fileList = JSON.parse(data.param.imagePath) === null ? JSON.parse('[]') : JSON.parse(data.param.imagePath)
          if (this.fileList.length > 0) {
            for (let i = 0; i < this.fileList.length; i++) {
              this.fileList[i].url = process.env.VUE_APP_IMG_URL + '8000/jxfx/' + this.fileList[i].name
            }
          }
        }
        if (this.ysjl.flowstatus === 4) {
          this.state = 'finish'
          this.edit = true
        }
        this.$refs.btn.getParentInfo(this.ysjl, this.param, null, null, this.state, this.$route.query.jyxm)
        this.$refs.picture.getChange(this.ysjl.shebeizhongleidaima, this.state, this.fileList, 1)
      })
    },
    changed(item) {
      this.param.imagePath = item
    }
  }
}
</script>
