<template>
  <div class="app-container">
    <div class="remt" style="text-align: right">
      <el-button type="primary" @click="handleAddRemarks">添加备注</el-button>
    </div>
    <div v-if="list">
      <el-card v-for="item in list" :key="item.id" class="box-card" style="margin: 0 auto">
        <div class="refund-item">
          <el-form label-width="120px">
            <el-form-item :label="item.noteUser">
              <div class="order_time">
                {{ item.addTime }}
              </div>
            </el-form-item>
            <el-form-item label="备注内容：">
              {{ item.note }}
            </el-form-item>
            <el-form-item label="图片：">
              <template v-if="item.images.length > 0">
                <el-image
                  v-for="(img, index) in item.images"
                  :key="index"
                  :preview-src-list="[img]"
                  style="width: 148px; height: 148px; margin-right: 20px"
                  :src="img"
                />
              </template>
              <template v-else> 无 </template>
            </el-form-item>
          </el-form>
        </div>
      </el-card>
    </div>
    <div v-else class="order_empty">
      <span>暂无订单备注</span>
      <el-button type="primary" @click="handleAddRemarks">添加备注</el-button>
    </div>
  </div>
</template>

<script>
import { getInformationNoteList } from '@/api/user/customer/customer'
export default {
  name: 'OrderRemarks',
  filters: {},
  data() {
    return {
      listQuery: {
        informationId: 0,
        pageNum: 1,
        pageSize: 20
      },
      isLoading: false,
      list: [] // 订单备注列表
    }
  },
  computed: {},
  created() {
    this.listQuery.informationId = this.$route.query.id
    this.getInformationNoteList()
  },
  methods: {
    // 获取订单备注列表
    async getInformationNoteList() {
      try {
        this.isLoading = false
        const res = await getInformationNoteList(this.listQuery)
        const data = res.data
        this.list = data.results
        console.log('list', this.list)
        this.isLoading = true
        console.log('isLoading', this.isLoading)
      } catch (error) {
        console.log('error', error)
      }
    },
    handleAddRemarks() {
      this.$router.push({
        path: '/user/customer/customer-remarks-add',
        query: { informationId: this.listQuery.informationId }
      })
    },
    backToList() {
      this.$store.dispatch('tagsView/delView', this.$route).then(() => {
        this.$nextTick(() => {
          this.$router.replace({
            path: '/order/deliver',
            query: {
              orderId: this.orderId
            }
          })
        })
      })
    }
  }
}
</script>

<style scoped lang="scss">
.order_empty {
  width: 100%;
  height: 40vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.order_empty span {
  color: #409eff;
  margin: 1vw;
}
.order_time {
  font-weight: 700;
}
.order_text {
  margin-right: 20px;
}
.goBack {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
::v-deep .el-form-item__content {
  margin-left: 130px !important;
}
.goBack {
  margin: 3vw 0;
  ::v-deep .el-button--medium {
    width: 100px !important;
  }
}
::v-deep .el-card {
  margin: 20px auto !important;
}
.app-title {
  line-height: 36px;
  font-size: 26px;
  font-weight: bold;
  color: #409eff;
  text-align: center;
  margin: 0;
}
.box-card {
  font-size: 14px;
}
.box-row {
  padding: 10px 0;
}
.box-row .dropdown {
  margin-top: -10px;
}
.refund-item {
  padding: 10px 0;
}
.order-item {
  background: #f7f7f7;
  margin-bottom: 20px;
  padding: 10px 15px;
  border-radius: 5px;
}
.product-row {
  padding: 10px 0;
  background: #ebeef5;
  border-top: 1px dashed #dcdfe6;
}
.op-item {
  padding: 5px 0;
}
.el-span-warning {
  color: #e6a23c;
}
.el-span-success {
  color: #67c23a;
}
.el-span-danger {
  color: #f56c6c;
}
</style>
