<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="jilubianhao">
              <el-input v-model="ysjl.jilubianhao" 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="管道规格" prop="guandaoguige">
              <el-input v-model="param.guandaoguige" :disabled="edit">
                <template slot="append">
                  (mm)
                </template>
              </el-input>
            </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="shiyongyali">
              <el-input v-model="param.shiyongyali" :disabled="edit">
                <template slot="append">
                  MPa
                </template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="试验介质" prop="shiyanjiezhi">
              <el-input v-model="param.shiyanjiezhi" :disabled="edit" />
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="试验压力" prop="shiyanyali">
              <el-input v-model="param.shiyanyali" :disabled="edit">
                <template slot="append">
                  MPa
                </template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="介质温度" prop="jiezhiwendu">
              <el-input v-model="param.jiezhiwendu" :disabled="edit">
                <template slot="append">
                  ℃
                </template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="环境温度" prop="huanjingwendu">
              <el-input v-model="param.huanjingwendu" :disabled="edit">
                <template slot="append">
                  ℃
                </template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="ysjl.jianyanxiangmu === 'nysy'" :gutter="20">
          <el-col :span="9">
            <el-form-item label="机泵出口压力表规格" label-width="160px" prop="yalibiaoguige">
              <el-input v-model="param.yalibiaoguige" :disabled="edit">
                <template slot="append">
                  MPa
                </template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="机泵出口压力表精度" label-width="160px" prop="yalibiaojingdu">
              <el-input v-model="param.yalibiaojingdu" :disabled="edit">
                <template slot="append">
                  级
                </template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="ysjl.jianyanxiangmu === 'xlsy'" :gutter="20">
          <el-col :span="9">
            <el-form-item label="压气设备出口压力表规格" label-width="160px" prop="yalibiaoguige">
              <el-input v-model="param.yalibiaoguige" :disabled="edit">
                <template slot="append">
                  MPa
                </template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="压气设备出口压力表精度" label-width="160px" prop="yalibiaojingdu">
              <el-input v-model="param.yalibiaojingdu" :disabled="edit">
                <template slot="append">
                  级
                </template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="9">
            <el-form-item label="管线压力表规格" prop="guanxianyalibiaoguige">
              <el-input v-model="param.guanxianyalibiaoguige" :disabled="edit">
                <template slot="append">
                  MPa
                </template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <el-form-item label="管线压力表精度" prop="guanxianyalibiaojingdu">
              <el-input v-model="param.guanxianyalibiaojingdu" :disabled="edit">
                <template slot="append">
                  级
                </template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col v-if="ysjl.jianyanxiangmu === 'nysy'" :span="9">
            <el-form-item label="机泵型号" prop="jibengxinghao">
              <el-input v-model="param.jibengxinghao" :disabled="edit" />
            </el-form-item>
          </el-col>
          <el-col v-if="ysjl.jianyanxiangmu === 'xlsy'" :span="9">
            <el-form-item label="压气设备型号" prop="yaqishebeixinghao">
              <el-input v-model="param.yaqishebeixinghao" :disabled="edit" />
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <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 v-if="ysjl.jianyanxiangmu === 'nysy'" label="压力试验结论" prop="shiyanjielun">
          <el-input v-model="param.shiyanjielun" :disabled="edit" type="textarea" rows="4" style="width: 800px;" />
        </el-form-item>
        <el-form-item v-if="ysjl.jianyanxiangmu === 'xlsy'" label="泄漏性试验结论" prop="shiyanjielun">
          <el-input v-model="param.shiyanjielun" :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 btn from '@/views/common/FxButton'
import pictureUpload from '@/components/Upload'
export default {
  name: 'GdZbgNysy',
  components: { Sticky, btn, pictureUpload },
  data() {
    return {
      ysjl: {},
      param: {},
      dialogVisible: false,
      edit: false,
      fileList: [],
      state: '',
      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',
        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/nysy/' + 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>

