Pārlūkot izejas kodu

✨ feat: 商品列表: 删除产品线,卡片样式修改

WanGxC 1 gadu atpakaļ
vecāks
revīzija
c9434c3b0c

+ 7 - 0
src/views/productCenter/productList/api.ts

@@ -109,3 +109,10 @@ export function getTableDataForASIN(query) {
     params: query,
   })
 }
+export function postDeleteProductLine(body) {
+  return request({
+    url: '/api/sellers/productline/delete/',
+    method: 'POST',
+    data: body,
+  })
+}

+ 24 - 5
src/views/productCenter/productList/components/ProductSelectCard/index.vue

@@ -1,9 +1,10 @@
 <script setup lang="ts">
-import { onMounted, inject, ref, onBeforeUnmount } from 'vue'
-import { getProductCardData } from '/@/views/productCenter/productList/api'
+import { Delete, Edit } from '@element-plus/icons-vue'
 import * as echarts from 'echarts'
-import { Edit, Delete } from '@element-plus/icons-vue'
+import { ElMessage } from 'element-plus'
+import { inject, onBeforeUnmount, onMounted, ref } from 'vue'
 import emitter from '/@/utils/emitter'
+import { getProductCardData, postDeleteProductLine } from '/@/views/productCenter/productList/api'
 
 const profile = <any>inject('profile')
 
@@ -88,6 +89,24 @@ function editCard(item) {
   emitter.emit('ProductTab-editProductCard', { isVisible: true, data: item })
 }
 
+async function deleteProductLine(item) {
+  const obj = {
+    productlineId: item.productlineId,
+  }
+  try {
+    const response = await postDeleteProductLine(obj)
+    if (response.data.code == 'success') {
+      ElMessage({ message: '已删除', type: 'success' })
+      await fetchProductCardData()
+      emitter.emit('ProductSelectCard-reloading', { reloading: true })
+    } else {
+      ElMessage({ message: '删除失败', type: 'error' })
+    }
+  } catch (error) {
+    console.log('error:', error)
+  }
+}
+
 emitter.on('ProductList-updateCardData', (value: any) => {
   if (value.isUpdate) {
     cardData.value.splice(0)
@@ -126,11 +145,11 @@ onBeforeUnmount(() => {
           <div class="pct-chart" :id="`chart${index}-${item.productlineId}`"></div>
           <el-popover v-if="index !== 0" placement="bottom" :width="150" trigger="click">
             <template #reference>
-              <el-icon class="custom-icon" @click.stop=""><MoreFilled /></el-icon>
+              <el-icon class="custom-icon" @click.stop=""><Setting /></el-icon>
             </template>
             <div class="custom-popoer">
               <el-button :icon="Edit" text size="small" @click="editCard(item)">编辑</el-button>
-              <el-button :icon="Delete" text size="small" style="margin-left: 0;">删除</el-button>
+              <el-button :icon="Delete" text size="small" @click="deleteProductLine(item)" style="margin-left: 0">删除</el-button>
             </div>
           </el-popover>
           <div class="left-part-container">

+ 6 - 0
src/views/productCenter/productList/components/TopFilters/index.vue

@@ -33,6 +33,12 @@ emitter.on('ProductLineDialog-reloading', (value: any) => {
   }
 })
 
+emitter.on('ProductSelectCard-reloading', (value: any) => {
+  if (value.reloading) {
+    fetchProductLine()
+  }
+})
+
 watch(selectValue, () => {
   emitter.emit('TopFilters-selectValue', { selectValue: selectValue.value })
   // console.log('selectValue.value', selectValue.value)