detail.vue 11 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
<template>
  <el-dialog 
    title="历史开单记录详情" 
    :visible.sync="visible" 
    :close-on-click-modal="false"
    class="NCC-dialog NCC-dialog_center" 
    width="1000px"
    @close="handleClose">
    <div class="detail-content" v-loading="loading">
      <!-- 基本信息卡片 -->
      <el-card class="info-card" shadow="hover">
        <div slot="header" class="card-header">
          <i class="el-icon-tickets"></i>
          <span class="card-title">基本信息</span>
        </div>
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="info-item"> 
              <label class="info-label">
                <i class="el-icon-document"></i>
                ID:
              </label>
              <span class="info-value highlight">{{ dataForm.id || '无' }}</span>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="info-item">
              <label class="info-label">
                <i class="el-icon-tickets"></i>
                开单号:
              </label>
              <span class="info-value highlight">{{ dataForm.orderNo || '无' }}</span>
            </div>
          </el-col>
          <!-- <el-col :span="24">
            <div class="info-item">
              <label class="info-label">
                <i class="el-icon-picture"></i>
                图片名称:
              </label>
              <span class="info-value">{{ dataForm.imageName || '无' }}</span>
            </div>
          </el-col> -->
        </el-row>
      </el-card>

      <!-- 会员信息卡片 -->
      <el-card class="info-card" shadow="hover">
        <div slot="header" class="card-header">
          <i class="el-icon-user"></i>
          <span class="card-title">会员信息</span>
        </div>
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="info-item">
              <label class="info-label">
                <i class="el-icon-user"></i>
                会员编号:
              </label>
              <span class="info-value">{{ dataForm.memberNo || '无' }}</span>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="info-item">
              <label class="info-label">
                <i class="el-icon-phone"></i>
                会员手机号:
              </label>
              <span class="info-value">{{ dataForm.memberPhone || '无' }}</span>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="info-item">
              <label class="info-label">
                <i class="el-icon-user-solid"></i>
                会员名称:
              </label>
              <span class="info-value">{{ dataForm.memberName || '无' }}</span>
            </div>
          </el-col>
        </el-row>
      </el-card>

      <!-- 图片信息卡片 -->
      <el-card class="info-card" shadow="hover" v-if="imageList.length > 0">
        <div slot="header" class="card-header">
          <i class="el-icon-picture"></i>
          <span class="card-title">图片信息</span>
          <span class="image-count-badge">共 {{ imageList.length }} 张</span>
        </div>
        <div class="image-gallery">
          <div 
            v-for="(imgUrl, index) in imageList" 
            :key="index"
            class="image-item"
          >
            <el-image
              :src="imgUrl"
              :preview-src-list="imageList"
              :initial-index="index"
              fit="cover"
              class="gallery-image"
            >
              <div slot="error" class="image-error">
                <i class="el-icon-picture-outline"></i>
                <span>图片加载失败</span>
              </div>
            </el-image>
          </div>
        </div>
      </el-card>

      <!-- 备注信息卡片 -->
      <el-card class="info-card" shadow="hover" v-if="dataForm.remarks">
        <div slot="header" class="card-header">
          <i class="el-icon-edit-outline"></i>
          <span class="card-title">备注信息</span>
        </div>
        <div class="info-item">
          <div class="remarks-content">{{ dataForm.remarks || '无' }}</div>
        </div>
      </el-card>

      <!-- 时间信息卡片 -->
      <el-card class="info-card" shadow="hover">
        <div slot="header" class="card-header">
          <i class="el-icon-time"></i>
          <span class="card-title">时间信息</span>
        </div>
        <el-row :gutter="20">
          <el-col :span="12">
            <div class="info-item">
              <label class="info-label">
                <i class="el-icon-time"></i>
                创建时间:
              </label>
              <span class="info-value">{{ formatDateTime(dataForm.createdAt) || '无' }}</span>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="info-item">
              <label class="info-label">
                <i class="el-icon-time"></i>
                更新时间:
              </label>
              <span class="info-value">{{ formatDateTime(dataForm.updatedAt) || '无' }}</span>
            </div>
          </el-col>
        </el-row>
      </el-card>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="handleClose">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import request from '@/utils/request'

export default {
  name: 'DetailDialog',
  data() {
    return {
      visible: false,
      loading: false,
      dataForm: {
        id: null,
        orderNo: '',
        imageName: '',
        memberNo: '',
        memberPhone: '',
        memberName: '',
        remarks: '',
        createdAt: null,
        updatedAt: null
      }
    }
  },
  computed: {
    // 图片列表(计算属性,避免重复计算)
    imageList() {
      return this.getImageList(this.dataForm.imageName)
    }
  },
  methods: {
    // 初始化
    init(id) {
      this.visible = true
      if (id) {
        this.getInfo(id)
      }
    },
    // 获取详情
    getInfo(id) {
      this.loading = true
      request({
        url: `/api/Extend/LqOrderRecords/${id}`,
        method: 'GET'
      }).then(res => {
        if (res.code === 200) {
          this.dataForm = res.data || {}
        } else {
          this.$message.error(res.msg || '获取详情失败')
        }
        this.loading = false
      }).catch(error => {
        console.error('获取历史开单记录详情失败:', error)
        this.$message.error('获取详情失败')
        this.loading = false
      })
    },
    // 关闭
    handleClose() {
      this.visible = false
      this.dataForm = {
        id: null,
        orderNo: '',
        imageName: '',
        memberNo: '',
        memberPhone: '',
        memberName: '',
        remarks: '',
        createdAt: null,
        updatedAt: null
      }
    },
    // 格式化日期时间
    formatDateTime(dateTime) {
      if (!dateTime) return '无'
      const date = new Date(dateTime)
      if (isNaN(date.getTime())) return '无'
      const year = date.getFullYear()
      const month = String(date.getMonth() + 1).padStart(2, '0')
      const day = String(date.getDate()).padStart(2, '0')
      const hours = String(date.getHours()).padStart(2, '0')
      const minutes = String(date.getMinutes()).padStart(2, '0')
      const seconds = String(date.getSeconds()).padStart(2, '0')
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
    },
    // 解析图片URL字符串(分号分隔)
    getImageList(imageStr) {
      if (!imageStr || typeof imageStr !== 'string') return []
      // 按分号分割,过滤空字符串,去除首尾空格
      const urls = imageStr.split(';')
        .map(url => url.trim())
        .filter(url => url && url.length > 0)
      return urls
    }
  }
}
</script>

<style lang="scss" scoped>
.detail-content {
  padding: 10px 0;
//   max-height: 70vh;
//   overflow-y: auto;
}

.info-card {
  margin-bottom: 20px;
  border-radius: 8px;
  transition: all 0.3s;
  
  &:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
  
  &:last-child {
    margin-bottom: 0;
  }
  
  ::v-deep .el-card__header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
    border-bottom: 1px solid #e4e7ed;
  }
  
  ::v-deep .el-card__body {
    padding: 20px;
  }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  
  i {
    margin-right: 8px;
    color: #409EFF;
    font-size: 18px;
  }
  
  .card-title {
    font-size: 16px;
    font-weight: 600;
    color: #303133;
  }
  
  .image-count-badge {
    font-size: 12px;
    color: #909399;
    background: #f0f2f5;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: normal;
  }
}

.info-item {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  padding: 8px 0;
  
  &:last-child {
    margin-bottom: 0;
  }
  
  .info-label {
    // min-width: 120px;
    color: #606266;
    font-weight: 500;
    display: flex;
    align-items: center;
    // text-align: right;
    // margin-right: 12px;
    
    i {
      margin-right: 6px;
      color: #909399;
      font-size: 14px;
    }
  }
  
  .info-value {
    flex: 1;
    color: #303133;
    word-break: break-all;
    font-size: 14px;
    &.highlight {
      color: #409EFF;
      font-weight: 600;
    }
  }
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding: 10px 0;
  
  .image-item {
    position: relative;
    width: 100%;
    padding-top: 100%; // 保持1:1比例
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e4e7ed;
    cursor: pointer;
    transition: all 0.3s;
    
    &:hover {
      border-color: #409EFF;
      box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
      transform: translateY(-2px);
    }
    
    .gallery-image {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      
      ::v-deep .el-image__inner {
        object-fit: cover;
      }
    }
    
    .image-error {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background: #f5f7fa;
      color: #909399;
      
      i {
        font-size: 32px;
        margin-bottom: 8px;
      }
      
      span {
        font-size: 12px;
      }
    }
  }
}

.remarks-content {
  padding: 12px 16px;
  background: #f5f7fa;
  border-radius: 6px;
  color: #303133;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
  border-left: 3px solid #409EFF;
}

.dialog-footer {
  text-align: right;
  padding: 20px 0 0;
  border-top: 1px solid #e4e7ed;
  margin-top: 10px;
}

.dialog-footer .el-button {
  margin-left: 10px;
}

// 滚动条样式优化
.detail-content::-webkit-scrollbar {
  width: 6px;
}

.detail-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.detail-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
  
  &:hover {
    background: #a8a8a8;
  }
}
</style>