fuliqi
2025-02-11 c4ec0fac48c9bef59fadba87404ea3d4bf9e087c
工单、报备,图片预览功能
2个文件已修改
98 ■■■■ 已修改文件
src/components/WorkOrder/WorkOrderAuditing.vue 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/report/index.vue 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/WorkOrder/WorkOrderAuditing.vue
@@ -32,11 +32,25 @@
            >
              <el-card>
                <div v-html="condition.ywCondition"></div>
                <el-link type="primary"
                         v-for="item in condition.ywProofMaterials != null ? condition.ywProofMaterials.split(',') : condition.ywProofMaterials"
                         :underline="false" :key="item.id" @click="handleDownload(item)"
                >{{ item.substring(item.lastIndexOf('/') + 1) }}
                <div v-for="item in condition.ywProofMaterials != null ? condition.ywProofMaterials.split(',') : condition.ywProofMaterials"
                     :key="item.id">
                  <el-image
                    v-if="isImageFile(item)"
                    :src="getPreview(item)"
                    :preview-src-list="[getPreview(item)]"
                    fit="cover"
                    style="width: 100px; height: 100px; margin: 5px;"
                  >
                  </el-image>
                  <el-link
                    v-else
                    type="primary"
                    :underline="false"
                    @click="handleDownload(item)"
                  >
                    {{ getFileName(item) }}
                </el-link>
                </div>
              </el-card>
            </el-timeline-item>
          </el-timeline>
@@ -82,6 +96,19 @@
    }
  },
  methods: {
    getPreview(url) {
      // 使用全局配置的图片前缀
      return this.$img + url;
    },
    isImageFile(url) {
      const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp'];
      return imageExtensions.some(ext =>
        url.toLowerCase().endsWith(ext)
      );
    },
    getFileName(url) {
      return url.substring(url.lastIndexOf('/') + 1);
    },
    /** 下载按钮操作 */
    handleDownload(data) {
      this.$download.resource(data)
@@ -116,5 +143,4 @@
</script>
<style scoped>
</style>
src/views/system/report/index.vue
@@ -60,8 +60,17 @@
            <div class="info-item">
              <div class="info-label">报备材料</div>
              <div class="info-list">
                <div style="margin-bottom: 8px" v-for="file in formatFileList(scope.row.reportMaterials)" :key="file">
                  <el-link type="primary" @click="handleDownload(file)">
                <div style="margin-bottom: 8px" v-for="file in scope.row.reportMaterials!=null ? scope.row.reportMaterials.split(',') : scope.row.reportMaterials" :key="file">
                  <el-image
                    v-if="isImageFile(file)"
                    :src="getPreview(file)"
                    :preview-src-list="[getPreview(file)]"
                    fit="cover"
                    class="material-preview"
                    style="width: 100px; height: 100px; margin: 5px;"
                  >
                  </el-image>
                  <el-link v-else type="primary" @click="handleDownload(file)">
                    {{file.match(/\/([^\/]*)$/)[1]}}
                  </el-link>
                </div>
@@ -181,11 +190,22 @@
                    <div class="content" v-html="getHtmlContent(record.reportContent)"></div>
                  </el-descriptions-item>
                  <el-descriptions-item label="报备材料">
                    <el-link
                    <div
                      v-for="item in record.reportMaterials != null ? record.reportMaterials.split(',') : record.reportMaterials"
                      :underline="false" type="primary" :key="item" @click="handleDownload(item)">
                      :key="item">
                      <el-image
                        v-if="isImageFile(item)"
                        :src="getPreview(item)"
                        :preview-src-list="[getPreview(item)]"
                        fit="cover"
                        style="width: 100px; height: 100px; margin: 5px;">
                      </el-image>
                      <el-link
                        v-else
                        :underline="false" type="primary" @click="handleDownload(item)">
                      {{ item.substring(item.lastIndexOf("/") + 1) }}
                    </el-link>
                    </div>
                  </el-descriptions-item>
                </el-descriptions>
              </el-card>
@@ -252,10 +272,24 @@
              <span v-html="auditingForm.reportContent"></span>
            </el-form-item>
            <el-form-item label="报备材料">
              <el-link
                <!-- 添加空行 -->
                <div class="material-spacer">{{''}}</div>
              <div
                v-for="item in auditingForm.reportMaterials != null ? auditingForm.reportMaterials.split(',') : auditingForm.reportMaterials"
                :underline="false" type="primary" :key="item" @click="handleDownload(item)">{{ item.substring(item.lastIndexOf("/") + 1)
                }}</el-link>
                :key="item">
                <el-image
                  v-if="isImageFile(item)"
                  :src="getPreview(item)"
                  :preview-src-list="[getPreview(item)]"
                  fit="cover"
                  style="width: 100px; height: 100px; margin: 5px;">
                </el-image>
                <el-link
                  v-else
                  :underline="false" type="primary" @click="handleDownload(item)">
                  {{ item.substring(item.lastIndexOf("/") + 1) }}
                </el-link>
              </div>
            </el-form-item>
          </el-form>
        </div>
@@ -266,7 +300,6 @@
        <el-button type="primary" @click="auditingSubmit">审 核</el-button>
      </div>
    </el-dialog>
  </div>
</template>
@@ -373,6 +406,16 @@
    this.getList();
  },
  methods: {
    getPreview(url) {
      // 使用全局配置的图片前缀
      return this.$img + url;
    },
    isImageFile(url) {
      const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp'];
      return imageExtensions.some(ext =>
        url.toLowerCase().endsWith(ext)
      );
    },
    getHtmlContent(content) {
      if (content) {
        return content
@@ -631,6 +674,9 @@
</script>
<style lang="scss" scoped>
.material-spacer {
  height: 50px; /* 可以调整空行的高度 */
}
.content {
  height: 100px;
  max-height: 300px;