Просмотр исходного кода

refactor(product-manage): 优化产品列表相关功能

- 新增 postStaffs 接口
- 移除 console.log 语句
- 调整导入图标组件
- 优化 NoticeDialog组件逻辑
- 美化 NoticeDialog 组件样式
WanGxC 7 месяцев назад
Родитель
Сommit
57215e5d52

+ 8 - 0
src/views/product-manage/product-list/api.ts

@@ -63,6 +63,14 @@ export function postMonitor(body: any) {
   })
 }
 
+export function postStaffs(body: any) {
+  return request({
+    url: apiPrefix + 'alarm-manage/',
+    data: body,
+    method: 'post'
+  })
+}
+
 export function updateShopDetail(body: any) {
   return request({
     url: apiPrefix + `${ body.id }/`,

+ 0 - 1
src/views/product-manage/product-list/component/DataTable.vue

@@ -146,7 +146,6 @@ async function switchMonitor(row: any) {
 
 async function batchOpen() {
   const ids = Array.from(checkedList.value);
-  console.log("(DataTable.vue: 148)=> ids", ids);
   const res = await useResponse(api.postMonitor, { ids, status: 1 }, btnLoading);
   if (res && res.code === 2000) {
     ElMessage.success('操作成功!');

+ 2 - 2
src/views/product-manage/product-list/component/DataTableSlot.vue

@@ -6,7 +6,7 @@
  */
 
 import { useCountryInfoStore } from '/@/stores/countryInfo';
-import { Operation, Delete, Message } from '@element-plus/icons-vue';
+import { Message, Operation } from '@element-plus/icons-vue';
 import PermissionButton from '/@/components/PermissionButton/index.vue';
 import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
 import { getTagType } from '/@/utils/useTagColor';
@@ -60,7 +60,7 @@ function handleMonitor(row: any) {
     </div>
     <div v-else-if="field === 'tag'">
       <el-tag :disable-transitions="true" :type=getTagType(row.tag)>
-        {{  row.tag ??  '--'  }}
+        {{ row.tag ?? '--' }}
       </el-tag>
     </div>
     <div v-else-if="field === 'brand'">

+ 18 - 16
src/views/product-manage/product-list/component/NoticeDialog.vue

@@ -6,7 +6,6 @@
 import { ElMessage } from 'element-plus';
 import { useResponse } from '/@/utils/useResponse';
 import * as api from '../api';
-import { getStaffsOptions } from '../api';
 import { Close, Finished } from '@element-plus/icons-vue';
 
 
@@ -28,7 +27,7 @@ const currentRow: any = ref(null);
 onBeforeMount(() => {
   fetchStaffsOptions();
   fetchExistingStaff();
-})
+});
 
 function handleClose(done: any) {
   staffSelect.value = '';
@@ -70,29 +69,27 @@ async function fetchExistingStaff() {
 }
 
 async function addStaffs() {
-  staffLoading.value = true;
   const body = {
-    id: currentRow.id,
-    user_ids: staffTags.map((tag: any) => tag.id)
+    id: rowData?.id,
+    user_ids: staffTags.value.map((tag: any) => tag.id)
   };
   try {
-    // const resp = await api.postStaffs(body);
-    // if (resp.code === 2000) {
-    //   ElMessage.error('编辑成功!');
-    //   await fetchExistingStaff(currentRow);
-    // }
+    const resp = await useResponse(api.postStaffs, body, staffLoading)
+    if (resp.code === 2000) {
+      ElMessage.success('编辑成功!');
+      fetchExistingStaff();
+    }
   } catch (error) {
     ElMessage.error('编辑失败!');
   } finally {
     staffSelect.value = '';
-    staffLoading.value = false;
   }
 }
 
 function cancelDialog() {
   staffSelect.value = '';
   staffTags.value = [];
-  noticeDialog.value.visible = false
+  noticeDialog.value.visible = false;
 }
 </script>
 
@@ -130,21 +127,26 @@ function cancelDialog() {
           <span class="ml-1" style="color: #909399">仅可添加已绑定邮箱的用户</span>
         </el-col>
       </el-row>
-      <div class="flex flex-wrap gap-1.5">
+      <div class="flex flex-wrap gap-1.5 min-h-6">
         <el-tag
             v-for="tag in staffTags"
             :key="tag.id"
             closable
+            round
+            effect="plain"
             @close="removeTag(tag)">
           {{ tag.username }}
         </el-tag>
       </div>
-      
+
       <el-divider style="margin: 12px 0 20px 0"></el-divider>
-      <span slot="footer" class="dialog-footer">
+      <template #footer>
         <el-button :icon="Close" @click="cancelDialog">取 消</el-button>
         <el-button :icon="Finished" :loading="staffLoading" type="primary" @click="addStaffs">确 定</el-button>
-      </span>
+      </template>
+      <!--<span slot="footer" class="dialog-footer">-->
+      <!--  -->
+      <!--</span>-->
     </el-dialog>
   </div>
 </template>