Sfoglia il codice sorgente

feat: supplier distribution system - entities, services, controllers, and admin UI

Sisyphus 2 mesi fa
parent
commit
33938d0d18

+ 45 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplySettlementController.java

@@ -0,0 +1,45 @@
+package com.etotem.cfc.controller.admin;
+
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.entity.SupplySettlement;
+import com.etotem.cfc.entity.SupplySettlementItem;
+import com.etotem.cfc.service.SupplySettlementService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/admin/supply-settlement")
+public class SupplySettlementController {
+
+    @Resource
+    private SupplySettlementService supplySettlementService;
+
+    @PostMapping("/list-by-supplier")
+    public Result<List<SupplySettlement>> listBySupplier(@RequestParam Long supplierId) {
+        return Result.success(supplySettlementService.getSettlementsBySupplier(supplierId));
+    }
+
+    @PostMapping("/list-by-system")
+    public Result<List<SupplySettlement>> listBySystem(@RequestParam Long supplySystemId) {
+        return Result.success(supplySettlementService.getSettlementsBySystem(supplySystemId));
+    }
+
+    @PostMapping("/items")
+    public Result<List<SupplySettlementItem>> items(@RequestParam Long settlementId) {
+        return Result.success(supplySettlementService.getSettlementItems(settlementId));
+    }
+
+    @PostMapping("/confirm")
+    public Result<Void> confirm(@RequestParam Long id) {
+        boolean success = supplySettlementService.confirmSettlement(id);
+        return success ? Result.success(null) : Result.error("确认结算失败");
+    }
+
+    @PostMapping("/cancel")
+    public Result<Void> cancel(@RequestParam Long id) {
+        boolean success = supplySettlementService.cancelSettlement(id);
+        return success ? Result.success(null) : Result.error("取消结算失败");
+    }
+}

+ 84 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/SupplySystemController.java

@@ -0,0 +1,84 @@
+package com.etotem.cfc.controller.admin;
+
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.entity.Supplier;
+import com.etotem.cfc.entity.SupplyRelationship;
+import com.etotem.cfc.entity.SupplySystem;
+import com.etotem.cfc.service.SupplySystemService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/admin/supply-system")
+public class SupplySystemController {
+
+    @Resource
+    private SupplySystemService supplySystemService;
+
+    @PostMapping("/list")
+    public Result<List<SupplySystem>> list() {
+        return Result.success(supplySystemService.getAllSystems());
+    }
+
+    @PostMapping("/create")
+    public Result<SupplySystem> create(@RequestBody SupplySystem system) {
+        return Result.success(supplySystemService.createSystem(system));
+    }
+
+    @PostMapping("/update")
+    public Result<SupplySystem> update(@RequestBody SupplySystem system) {
+        boolean success = supplySystemService.updateSystem(system);
+        return success ? Result.success(system) : Result.error("更新失败");
+    }
+
+    @PostMapping("/toggle-status")
+    public Result<Void> toggleStatus(@RequestParam Long id) {
+        boolean success = supplySystemService.toggleStatus(id);
+        return success ? Result.success(null) : Result.error("操作失败");
+    }
+
+    @PostMapping("/supplier/list")
+    public Result<List<Supplier>> listSuppliers(@RequestParam Long supplySystemId) {
+        return Result.success(supplySystemService.getSuppliers(supplySystemId));
+    }
+
+    @PostMapping("/supplier/create")
+    public Result<Supplier> createSupplier(@RequestBody Supplier supplier) {
+        return Result.success(supplySystemService.createSupplier(supplier));
+    }
+
+    @PostMapping("/supplier/update")
+    public Result<Supplier> updateSupplier(@RequestBody Supplier supplier) {
+        boolean success = supplySystemService.updateSupplier(supplier);
+        return success ? Result.success(supplier) : Result.error("更新失败");
+    }
+
+    @PostMapping("/supplier/delete")
+    public Result<Void> deleteSupplier(@RequestParam Long id) {
+        boolean success = supplySystemService.deleteSupplier(id);
+        return success ? Result.success(null) : Result.error("删除失败");
+    }
+
+    @PostMapping("/relation/product")
+    public Result<List<SupplyRelationship>> getRelationsByProduct(@RequestParam Long productId) {
+        return Result.success(supplySystemService.getRelationsByProduct(productId));
+    }
+
+    @PostMapping("/relation/supplier")
+    public Result<List<SupplyRelationship>> getRelationsBySupplier(@RequestParam Long supplierId) {
+        return Result.success(supplySystemService.getRelationsBySupplier(supplierId));
+    }
+
+    @PostMapping("/relation/create")
+    public Result<SupplyRelationship> createRelation(@RequestBody SupplyRelationship relationship) {
+        return Result.success(supplySystemService.createRelationship(relationship));
+    }
+
+    @PostMapping("/relation/remove-by-product")
+    public Result<Void> removeRelationByProduct(@RequestParam Long productId) {
+        supplySystemService.removeRelationshipByProduct(productId);
+        return Result.success(null);
+    }
+}

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/SupplyRelationshipMapper.java

@@ -0,0 +1,9 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.SupplyRelationship;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SupplyRelationshipMapper extends BaseMapper<SupplyRelationship> {
+}

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/SupplySettlementItemMapper.java

@@ -0,0 +1,9 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.SupplySettlementItem;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SupplySettlementItemMapper extends BaseMapper<SupplySettlementItem> {
+}

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/SupplySettlementMapper.java

@@ -0,0 +1,9 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.SupplySettlement;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SupplySettlementMapper extends BaseMapper<SupplySettlement> {
+}

+ 126 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/SupplySettlementService.java

@@ -0,0 +1,126 @@
+package com.etotem.cfc.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.etotem.cfc.entity.*;
+import com.etotem.cfc.mapper.*;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class SupplySettlementService extends ServiceImpl<SupplySettlementMapper, SupplySettlement> {
+
+    @Resource
+    private SupplySettlementItemMapper supplySettlementItemMapper;
+
+    @Resource
+    private SupplierMapper supplierMapper;
+
+    @Resource
+    private SupplySystemMapper supplySystemMapper;
+
+    @Resource
+    private ProductOrderMapper productOrderMapper;
+
+    public List<SupplySettlement> getSettlementsBySupplier(Long supplierId) {
+        LambdaQueryWrapper<SupplySettlement> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SupplySettlement::getSupplierId, supplierId)
+               .orderByDesc(SupplySettlement::getCreatedAt);
+        return this.list(wrapper);
+    }
+
+    public List<SupplySettlement> getSettlementsBySystem(Long supplySystemId) {
+        LambdaQueryWrapper<SupplySettlement> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SupplySettlement::getSupplySystemId, supplySystemId)
+               .orderByDesc(SupplySettlement::getCreatedAt);
+        return this.list(wrapper);
+    }
+
+    public List<SupplySettlementItem> getSettlementItems(Long settlementId) {
+        LambdaQueryWrapper<SupplySettlementItem> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SupplySettlementItem::getSettlementId, settlementId);
+        return supplySettlementItemMapper.selectList(wrapper);
+    }
+
+    /**
+     * Calculate and create a settlement for a completed order.
+     * Called when an order is marked as completed/confirmed.
+     */
+    @Transactional
+    public SupplySettlement createSettlementForOrder(Long orderId) {
+        ProductOrder order = productOrderMapper.selectById(orderId);
+        if (order == null || order.getSupplierId() == null) {
+            return null;
+        }
+
+        Supplier supplier = supplierMapper.selectById(order.getSupplierId());
+        if (supplier == null || supplier.getSupplySystemId() == null) {
+            return null;
+        }
+
+        SupplySystem system = supplySystemMapper.selectById(supplier.getSupplySystemId());
+        if (system == null) {
+            return null;
+        }
+
+        BigDecimal totalAmount = BigDecimal.valueOf(order.getTotalAmount()).divide(BigDecimal.valueOf(100));
+        BigDecimal platformRate = system.getPlatformProfitRate() != null
+                ? system.getPlatformProfitRate() : BigDecimal.ZERO;
+        BigDecimal platformProfit = totalAmount.multiply(platformRate);
+        BigDecimal supplierIncome = totalAmount.subtract(platformProfit);
+        BigDecimal commissionAmount = BigDecimal.valueOf(
+                order.getSupplyCommission() != null ? order.getSupplyCommission() : 0)
+                .divide(BigDecimal.valueOf(100));
+
+        SupplySettlement settlement = new SupplySettlement();
+        settlement.setSupplierId(order.getSupplierId());
+        settlement.setSupplySystemId(supplier.getSupplySystemId());
+        settlement.setOrderId(orderId);
+        settlement.setTotalAmount(totalAmount);
+        settlement.setPlatformProfit(platformProfit);
+        settlement.setSupplierIncome(supplierIncome);
+        settlement.setCommissionAmount(commissionAmount);
+        settlement.setStatus("PENDING");
+        settlement.setCreatedAt(new Date());
+        settlement.setUpdatedAt(new Date());
+        this.save(settlement);
+
+        SupplySettlementItem item = new SupplySettlementItem();
+        item.setSettlementId(settlement.getId());
+        item.setProductId(order.getProductId());
+        item.setProductName(order.getProductName());
+        item.setQuantity(order.getQuantity());
+        item.setUnitPrice(totalAmount.divide(BigDecimal.valueOf(order.getQuantity()), BigDecimal.ROUND_HALF_UP));
+        item.setSubtotal(totalAmount);
+        item.setCommissionRate(supplier.getCommissionRate());
+        item.setCommissionAmount(commissionAmount);
+        item.setCreatedAt(new Date());
+        supplySettlementItemMapper.insert(item);
+
+        return settlement;
+    }
+
+    @Transactional
+    public boolean confirmSettlement(Long id) {
+        SupplySettlement settlement = this.getById(id);
+        if (settlement == null) return false;
+        settlement.setStatus("SETTLED");
+        settlement.setSettlementDate(new Date());
+        settlement.setUpdatedAt(new Date());
+        return this.updateById(settlement);
+    }
+
+    @Transactional
+    public boolean cancelSettlement(Long id) {
+        SupplySettlement settlement = this.getById(id);
+        if (settlement == null) return false;
+        settlement.setStatus("CANCELLED");
+        settlement.setUpdatedAt(new Date());
+        return this.updateById(settlement);
+    }
+}

+ 118 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/SupplySystemService.java

@@ -0,0 +1,118 @@
+package com.etotem.cfc.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.etotem.cfc.entity.Supplier;
+import com.etotem.cfc.entity.SupplyRelationship;
+import com.etotem.cfc.entity.SupplySystem;
+import com.etotem.cfc.mapper.SupplierMapper;
+import com.etotem.cfc.mapper.SupplyRelationshipMapper;
+import com.etotem.cfc.mapper.SupplySystemMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class SupplySystemService extends ServiceImpl<SupplySystemMapper, SupplySystem> {
+
+    @Resource
+    private SupplierMapper supplierMapper;
+
+    @Resource
+    private SupplyRelationshipMapper supplyRelationshipMapper;
+
+    public List<SupplySystem> getAllSystems() {
+        return this.list();
+    }
+
+    public List<SupplySystem> getActiveSystems() {
+        LambdaQueryWrapper<SupplySystem> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SupplySystem::getStatus, "ACTIVE");
+        return this.list(wrapper);
+    }
+
+    @Transactional
+    public SupplySystem createSystem(SupplySystem system) {
+        system.setCreatedAt(new Date());
+        system.setUpdatedAt(new Date());
+        this.save(system);
+        return system;
+    }
+
+    public boolean updateSystem(SupplySystem system) {
+        system.setUpdatedAt(new Date());
+        return this.updateById(system);
+    }
+
+    public boolean toggleStatus(Long id) {
+        SupplySystem system = this.getById(id);
+        if (system == null) return false;
+        system.setStatus("ACTIVE".equals(system.getStatus()) ? "INACTIVE" : "ACTIVE");
+        system.setUpdatedAt(new Date());
+        return this.updateById(system);
+    }
+
+    // ========== Supplier Management ==========
+
+    public List<Supplier> getSuppliers(Long supplySystemId) {
+        LambdaQueryWrapper<Supplier> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Supplier::getSupplySystemId, supplySystemId);
+        return supplierMapper.selectList(wrapper);
+    }
+
+    @Transactional
+    public Supplier createSupplier(Supplier supplier) {
+        supplier.setStatus("ACTIVE");
+        supplier.setCreatedAt(new Date());
+        supplier.setUpdatedAt(new Date());
+        supplierMapper.insert(supplier);
+        return supplier;
+    }
+
+    public boolean updateSupplier(Supplier supplier) {
+        supplier.setUpdatedAt(new Date());
+        return supplierMapper.updateById(supplier) > 0;
+    }
+
+    @Transactional
+    public boolean deleteSupplier(Long id) {
+        // Also remove associated relationships
+        LambdaQueryWrapper<SupplyRelationship> relWrapper = new LambdaQueryWrapper<>();
+        relWrapper.eq(SupplyRelationship::getSupplierId, id);
+        supplyRelationshipMapper.delete(relWrapper);
+        return supplierMapper.deleteById(id) > 0;
+    }
+
+    // ========== Product-Supplier Relationship ==========
+
+    public List<SupplyRelationship> getRelationsByProduct(Long productId) {
+        LambdaQueryWrapper<SupplyRelationship> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SupplyRelationship::getProductId, productId);
+        return supplyRelationshipMapper.selectList(wrapper);
+    }
+
+    public List<SupplyRelationship> getRelationsBySupplier(Long supplierId) {
+        LambdaQueryWrapper<SupplyRelationship> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SupplyRelationship::getSupplierId, supplierId);
+        return supplyRelationshipMapper.selectList(wrapper);
+    }
+
+    @Transactional
+    public SupplyRelationship createRelationship(SupplyRelationship relationship) {
+        relationship.setStatus("ACTIVE");
+        relationship.setCreatedAt(new Date());
+        relationship.setUpdatedAt(new Date());
+        supplyRelationshipMapper.insert(relationship);
+        return relationship;
+    }
+
+    @Transactional
+    public void removeRelationshipByProduct(Long productId) {
+        LambdaQueryWrapper<SupplyRelationship> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SupplyRelationship::getProductId, productId);
+        supplyRelationshipMapper.delete(wrapper);
+    }
+}

+ 267 - 0
cfc-web/src/views/admin/SupplySystem.vue

@@ -0,0 +1,267 @@
+<template>
+  <div class="supply-system">
+    <!-- System List -->
+    <el-card>
+      <div slot="header">
+        <span>供应商体系管理</span>
+        <el-button style="float: right" type="primary" size="small" @click="handleCreateSystem">+ 添加体系</el-button>
+      </div>
+      <el-table :data="systems" stripe>
+        <el-table-column prop="id" label="ID" width="80"></el-table-column>
+        <el-table-column prop="name" label="名称" width="150"></el-table-column>
+        <el-table-column prop="description" label="描述"></el-table-column>
+        <el-table-column prop="settlementPeriodDays" label="结算周期(天)" width="120"></el-table-column>
+        <el-table-column prop="platformProfitRate" label="平台利润率" width="120">
+          <template slot-scope="scope">
+            {{ scope.row.platformProfitRate ? (scope.row.platformProfitRate * 100).toFixed(1) + '%' : '-' }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="status" label="状态" width="100">
+          <template slot-scope="scope">
+            <el-tag :type="scope.row.status === 'ACTIVE' ? 'success' : 'danger'">
+              {{ scope.row.status === 'ACTIVE' ? '启用' : '停用' }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作" width="220">
+          <template slot-scope="scope">
+            <el-button size="mini" type="primary" @click="handleManageSupplier(scope.row)">供应商</el-button>
+            <el-button size="mini" @click="handleEditSystem(scope.row)">编辑</el-button>
+            <el-button size="mini" :type="scope.row.status === 'ACTIVE' ? 'warning' : 'success'" @click="toggleSystemStatus(scope.row)">
+              {{ scope.row.status === 'ACTIVE' ? '停用' : '启用' }}
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+    </el-card>
+
+    <!-- System Dialog -->
+    <el-dialog :visible.sync="systemDialogVisible" :title="isEditSystem ? '编辑供应商体系' : '添加供应商体系'" width="500px">
+      <el-form :model="systemForm" label-width="120px">
+        <el-form-item label="名称">
+          <el-input v-model="systemForm.name" placeholder="如: 优选供应商体系"></el-input>
+        </el-form-item>
+        <el-form-item label="结算周期(天)">
+          <el-input-number v-model="systemForm.settlementPeriodDays" :min="1" :max="90"></el-input-number>
+        </el-form-item>
+        <el-form-item label="平台利润率">
+          <el-input-number v-model="systemForm.platformProfitRate" :min="0" :max="1" :step="0.01"></el-input-number>
+        </el-form-item>
+        <el-form-item label="描述">
+          <el-input v-model="systemForm.description" type="textarea"></el-input>
+        </el-form-item>
+      </el-form>
+      <div slot="footer">
+        <el-button @click="systemDialogVisible = false">取消</el-button>
+        <el-button type="primary" @click="handleSystemSubmit">保存</el-button>
+      </div>
+    </el-dialog>
+
+    <!-- Supplier Management Dialog -->
+    <el-dialog :visible.sync="supplierDialogVisible" title="供应商管理" width="700px" @close="handleSupplierDialogClose">
+      <div>
+        <div style="margin-bottom: 15px;">
+          <strong>供应商体系:</strong>{{ currentSystem?.name }}
+          <el-button style="float: right" type="primary" size="small" @click="handleCreateSupplier">+ 添加供应商</el-button>
+        </div>
+        <el-table :data="suppliers" stripe>
+          <el-table-column prop="id" label="ID" width="60"></el-table-column>
+          <el-table-column prop="name" label="供应商名称" width="140"></el-table-column>
+          <el-table-column prop="contactName" label="联系人" width="100"></el-table-column>
+          <el-table-column prop="contactPhone" label="联系电话" width="130"></el-table-column>
+          <el-table-column prop="commissionRate" label="佣金比例" width="100">
+            <template slot-scope="scope">
+              {{ scope.row.commissionRate ? (scope.row.commissionRate * 100).toFixed(1) + '%' : '-' }}
+            </template>
+          </el-table-column>
+          <el-table-column prop="status" label="状态" width="80">
+            <template slot-scope="scope">
+              <el-tag :type="scope.row.status === 'ACTIVE' ? 'success' : 'danger'" size="mini">
+                {{ scope.row.status === 'ACTIVE' ? '启用' : '停用' }}
+              </el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column label="操作" width="120">
+            <template slot-scope="scope">
+              <el-button size="mini" @click="handleEditSupplier(scope.row)">编辑</el-button>
+              <el-button size="mini" type="danger" @click="handleDeleteSupplier(scope.row)">删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+    </el-dialog>
+
+    <!-- Supplier Form Dialog -->
+    <el-dialog :visible.sync="supplierFormVisible" :title="isEditSupplier ? '编辑供应商' : '添加供应商'" width="450px">
+      <el-form :model="supplierForm" label-width="100px">
+        <el-form-item label="供应商名称">
+          <el-input v-model="supplierForm.name" placeholder="如: XX供货商"></el-input>
+        </el-form-item>
+        <el-form-item label="联系人">
+          <el-input v-model="supplierForm.contactName"></el-input>
+        </el-form-item>
+        <el-form-item label="联系电话">
+          <el-input v-model="supplierForm.contactPhone"></el-input>
+        </el-form-item>
+        <el-form-item label="佣金比例">
+          <el-input-number v-model="supplierForm.commissionRate" :min="0" :max="1" :step="0.01"></el-input-number>
+        </el-form-item>
+      </el-form>
+      <div slot="footer">
+        <el-button @click="supplierFormVisible = false">取消</el-button>
+        <el-button type="primary" @click="handleSupplierSubmit">保存</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { getSupplySystemList, createSupplySystem, updateSupplySystem, toggleSupplySystemStatus,
+         getSupplierList, createSupplier, updateSupplier, deleteSupplier } from '@/api/admin'
+
+export default {
+  name: 'SupplySystem',
+  data() {
+    return {
+      systems: [],
+      systemDialogVisible: false,
+      isEditSystem: false,
+      systemForm: {
+        id: null,
+        name: '',
+        description: '',
+        settlementPeriodDays: 30,
+        platformProfitRate: 0,
+        status: 'ACTIVE'
+      },
+      supplierDialogVisible: false,
+      currentSystem: null,
+      suppliers: [],
+      supplierFormVisible: false,
+      isEditSupplier: false,
+      supplierForm: {
+        id: null,
+        name: '',
+        contactName: '',
+        contactPhone: '',
+        commissionRate: 0,
+        supplySystemId: null
+      }
+    }
+  },
+  created() {
+    this.loadData()
+  },
+  methods: {
+    async loadData() {
+      try {
+        const res = await getSupplySystemList()
+        if (res.data) {
+          this.systems = res.data
+        }
+      } catch (e) {
+        console.error(e)
+      }
+    },
+    handleCreateSystem() {
+      this.isEditSystem = false
+      this.systemForm = { id: null, name: '', description: '', settlementPeriodDays: 30, platformProfitRate: 0, status: 'ACTIVE' }
+      this.systemDialogVisible = true
+    },
+    handleEditSystem(row) {
+      this.isEditSystem = true
+      this.systemForm = { ...row }
+      this.systemDialogVisible = true
+    },
+    async toggleSystemStatus(row) {
+      try {
+        const res = await toggleSupplySystemStatus(row.id)
+        if (res.code === 'OK') {
+          this.$message.success('状态已更新')
+          this.loadData()
+        }
+      } catch (e) {
+        this.$message.error('更新失败')
+      }
+    },
+    async handleSystemSubmit() {
+      try {
+        if (this.isEditSystem) {
+          await updateSupplySystem(this.systemForm)
+        } else {
+          await createSupplySystem(this.systemForm)
+        }
+        this.$message.success('保存成功')
+        this.systemDialogVisible = false
+        this.loadData()
+      } catch (e) {
+        this.$message.error('保存失败')
+      }
+    },
+    async handleManageSupplier(system) {
+      this.currentSystem = system
+      this.supplierDialogVisible = true
+      try {
+        const res = await getSupplierList(system.id)
+        if (res.data) {
+          this.suppliers = res.data
+        }
+      } catch (e) {
+        console.error(e)
+      }
+    },
+    handleSupplierDialogClose() {
+      this.currentSystem = null
+      this.suppliers = []
+    },
+    handleCreateSupplier() {
+      this.isEditSupplier = false
+      this.supplierForm = { id: null, name: '', contactName: '', contactPhone: '', commissionRate: 0, supplySystemId: this.currentSystem.id }
+      this.supplierFormVisible = true
+    },
+    handleEditSupplier(row) {
+      this.isEditSupplier = true
+      this.supplierForm = { ...row }
+      this.supplierFormVisible = true
+    },
+    async handleDeleteSupplier(row) {
+      try {
+        await this.$confirm('确定删除该供应商吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' })
+        await deleteSupplier(row.id)
+        this.$message.success('删除成功')
+        const res = await getSupplierList(this.currentSystem.id)
+        if (res.data) {
+          this.suppliers = res.data
+        }
+      } catch (e) {
+        if (e !== 'cancel') {
+          this.$message.error('删除失败')
+        }
+      }
+    },
+    async handleSupplierSubmit() {
+      try {
+        if (this.isEditSupplier) {
+          await updateSupplier(this.supplierForm)
+        } else {
+          await createSupplier(this.supplierForm)
+        }
+        this.$message.success('保存成功')
+        this.supplierFormVisible = false
+        const res = await getSupplierList(this.currentSystem.id)
+        if (res.data) {
+          this.suppliers = res.data
+        }
+      } catch (e) {
+        this.$message.error('保存失败')
+      }
+    }
+  }
+}
+</script>
+
+<style scoped>
+.supply-system {
+  padding: 20px;
+}
+</style>

+ 1 - 0
session-agent-configuration.json

@@ -0,0 +1 @@
+[checkpointed session agent configuration]

+ 1 - 0
session_agent_config.json

@@ -0,0 +1 @@
+checkpointed_session_agent_config.json