Bang Hu
1 天以前 8a709ba6db50831048f9c3e2452ea6dc6c3de36f
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
<template>
  <div class="product-list-container">
    <div class="page-header">
      <div class="header-content">
        <h2>产品列表</h2>
        <p>测试产品价格查看组件功能</p>
      </div>
    </div>
 
    <el-card class="product-card" shadow="never">
      <template #header>
        <div class="card-header">
          <span>产品信息</span>
          <el-button type="primary" @click="handleAddProduct">添加产品</el-button>
        </div>
      </template>
 
      <el-table
        :data="productList"
        v-loading="loading"
        style="width: 100%"
        border
        stripe
      >
        <el-table-column prop="id" label="产品ID" width="120" />
        <el-table-column prop="name" label="产品名称" min-width="200" />
        <el-table-column prop="typeName" label="产品类型" width="120" />
        <el-table-column prop="importantAreaName" label="行业领域" width="150" />
        <el-table-column prop="submissionUnit" label="提报单位" width="150" />
        <el-table-column prop="shelfStatus" label="上架状态" width="100">
          <template #default="{ row }">
            <el-tag :type="getStatusType(row.shelfStatus)" size="small">
              {{ row.shelfStatus }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200" fixed="right">
          <template #default="{ row }">
            <el-button
              type="primary"
              size="small"
              @click="handlePriceManage(row)"
            >
              价格管理
            </el-button>
            <el-button
              type="success"
              size="small"
              @click="handleViewPricing(row)"
            >
              查看定价
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
 
    <!-- 产品价格查看弹窗 -->
    <!-- <ProductPriceViewer
      v-model="priceViewerVisible"
      :product-id="currentProductId"
      @order="handleOrder"
    /> -->
  </div>
</template>
 
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import ProductPriceViewer from '@/views/productManage/productPriceViewer/index.vue'
import productApi from '@/api/productApi'
 
interface ProductItem {
  id: string
  name: string
  productType: string
  industry: string
  submitUnit: string
  submitter: string
  projectUnit: string
  industryStage: string
  description: string
  shelfStatus: '待上架' | '已上架' | '已下架'
}
 
const router = useRouter()
const loading = ref(false)
const productList = ref<ProductItem[]>([])
 
// 价格查看弹窗相关
const priceViewerVisible = ref(false)
const currentProductId = ref('')
 
 
// 获取状态类型
const getStatusType = (status: string) => {
  switch (status) {
    case '已上架':
      return 'success'
    case '待上架':
      return 'warning'
    case '已下架':
      return 'danger'
    default:
      return 'info'
  }
}
 
// 加载产品列表
const loadProductList = async () => {
  loading.value = true
  try {
    // 模拟API调用
    // await new Promise(resolve => setTimeout(resolve, 500))
    let data = {"name":"","industrialChainId":"","importantAreaId":"","importantAreaIdList":[],"typeId":"","typeChildId":[],"startDate":"","endDate":"","page":{"current":1,"size":10,"total":3}}
    const res: any = await productApi.getProductList(data)
    if (res?.code === 200) {
      productList.value = res.data.records || []
    } else {
      productList.value = []
      ElMessage.error(res?.msg || '获取产品列表失败')
    }
    // productList.value = mockProductList
  } catch (error) {
    console.error('加载产品列表失败:', error)
    ElMessage.error('加载产品列表失败')
  } finally {
    loading.value = false
  }
}
 
// 添加产品
const handleAddProduct = () => {
  ElMessage.info('添加产品功能开发中...')
}
 
// 价格管理
const handlePriceManage = (row: ProductItem) => {
  // 跳转到价格管理页面
  router.push({
    path: `/product/price/${row.id}`
  })
}
 
// 查看定价
const handleViewPricing = (row: ProductItem) => {
  // currentProductId.value = row.id
  // priceViewerVisible.value = true
  router.push({
    path: '/product/priceViewer',
    query: { productId: row.id}
  })
}
 
// 处理订购
const handleOrder = (selectedItems: any[]) => {
  console.log('选中的价格项:', selectedItems)
  ElMessage.success(`已选择 ${selectedItems.length} 个价格项进行订购`)
}
 
onMounted(() => {
  loadProductList()
})
</script>
 
<style scoped lang="scss">
.product-list-container {
  padding: 20px;
 
  .page-header {
    margin-bottom: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    padding: 20px;
    color: white;
 
    .header-content {
      h2 {
        margin: 0 0 8px 0;
        font-size: 24px;
        font-weight: 600;
      }
 
      p {
        margin: 0;
        opacity: 0.9;
        font-size: 14px;
      }
    }
  }
 
  .product-card {
    .card-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
 
      span {
        font-size: 16px;
        font-weight: 600;
        color: #303133;
      }
    }
  }
 
  :deep(.el-table) {
    .el-table__header {
      th {
        background-color: #f5f7fa;
        color: #303133;
        font-weight: 600;
      }
    }
 
    .el-table__row {
      &:hover {
        background-color: #f5f7fa;
      }
    }
  }
}
</style>