6
jinlin
2023-12-03 c8d8a511f45c96ed3a5123a88e48de2ffdbf632a
web/src/views/modules/project/Environ-AddOrUpdate.vue
@@ -211,10 +211,16 @@
        </div>
      </div>
    </el-form>
    <template v-slot:footer>
      <el-button v-if="dataForm.disabled" type="primary" @click="print()">打印</el-button>
    </template>
  </zt-dialog>
</template>
<script>
  import qs from "qs";
  import Cookies from "js-cookie";
  export default {
    data() {
      return {
@@ -251,11 +257,11 @@
    },
    methods: {
      init(id, row) {
        console.log(row, 'row')
        this.dataForm.id = row.id
        this.dataForm.projectId = row.projectId
        // this.dataForm.disabled
        this.dataForm.disabled
        this.getInfo()
        this.getImageUrl()
        console.log(this.dataForm.id, this.dataForm.projectId, 'params params')
      },
      // 获取信息
@@ -265,11 +271,13 @@
          projectId: this.dataForm.projectId
        }
        let res = await this.$http.get(`/project/Environ/getDto`, {params: params})
        this.dataForm = {
          ...this.dataForm,
          ...res.data
        if (res.data) {
          this.dataForm = {
            ...this.dataForm,
            ...res.data
          }
          this.getImageUrl()
        }
        console.log(this.dataForm, 'this.dataForm')
      },
      indexFormat(index) {
        return index += 1
@@ -295,27 +303,36 @@
          tableBody.scrollTop = tableBody.scrollHeight;
        })
      },
      getImageUrl() {
        let pictureId = this.getFirstImageId(this.dataForm.files, 'test_environt_diagram')
        this.dataForm.url = `${window.SITE_CONFIG['apiURL']}/sys/oss/content2?fileId=${pictureId}`
        console.log(this.dataForm.url, ' this.dataForm.url')
      },
      getFirstImageId(oss) {
        console.log(oss, ' getFirstImageId(oss)')
        let fileId = 0
        if (oss != null) {
          if (oss.groups.length > 0) {
            let group = oss.groups[0]
            if (group.fields.length > 0) {
              let field = group.fields[0]
              if (field.files.length > 0) {
                let file = field.files[0]
                fileId = file.id
              }
            }
          }
        }
        return fileId
       getImageUrl() {
         let pictureId = this.getFirstImageId(this.dataForm.files)
         this.dataForm.url = `${window.SITE_CONFIG['apiURL']}/sys/oss/content2?fileId=${pictureId}`
         console.log(this.dataForm.url, ' this.dataForm.url')
       },
       getFirstImageId(oss) {
         console.log(oss, ' getFirstImageId(oss)')
         let fileId = 0
         if (oss != null) {
           if (oss.groups.length > 0) {
             let group = oss.groups[0]
             if (group.fields.length > 0) {
               let field = group.fields[0]
               if (field.files.length > 0) {
                 let file = field.files[0]
                 fileId = file.id
               }
             }
           }
         }
         return fileId
       },
      async print() {
        console.log(this.dataForm)
        let params = qs.stringify({
          token: Cookies.get('token'),
          id: this.dataForm.id
        })
        let apiURL = `/project/Environ/exportEnviron/`
        window.location.href = `${window.SITE_CONFIG['apiURL']}${apiURL}?${params}`
      },
      // 表单提交
      async formSubmit() {