up
This commit is contained in:
@@ -1,29 +1,89 @@
|
|||||||
# 2026-04-29 工作日志
|
# 2026-04-29 工作记录
|
||||||
|
|
||||||
## 仓库物品列表添加列
|
## 完成的任务
|
||||||
|
|
||||||
在仓库容器详情页的物品列表中,在"数量"列后面添加了"工单数量"和"关联客户"两列。
|
### 1. Web 前端优化
|
||||||
|
- **WorkOrderList.vue** - 工单列表页
|
||||||
|
- 增宽工单标题列:w-64 → w-80
|
||||||
|
- 增宽描述列:w-32 → w-48
|
||||||
|
- 状态气泡添加 `whitespace-nowrap` 防止换行
|
||||||
|
|
||||||
### 修改内容
|
- **WarehouseOverview.vue** - 仓库概览页
|
||||||
|
- 操作列按钮添加 `whitespace-nowrap`
|
||||||
|
- 删除创建日期列
|
||||||
|
|
||||||
**后端** (`backend/my_work/routers/apiWarehouse.go`):
|
- **WarehouseContainerDetail.vue** - 容器详情页
|
||||||
- 修改 `/list_item` API,批量查询物品的工单绑定数量和客户关联信息
|
- 操作列按钮添加 `whitespace-nowrap`
|
||||||
- 新增返回字段:`WorkOrderCount` (int) 和 `Customers` (数组)
|
- 删除创建日期列
|
||||||
|
|
||||||
**前端** (`frontend/ops_vue_js/src/views/warehouse/WarehouseContainerDetail.vue`):
|
### 2. 部署脚本
|
||||||
- 导入 `IconTool`, `IconUser` 图标和 `RouterLink` 组件
|
- 创建 `install.sh`(根目录)
|
||||||
- 表格表头添加两列:工单数量、关联客户
|
- 执行 git pull
|
||||||
- 表格数据行显示:
|
- 构建前端:cd frontend/ops_vue_js && npm run build
|
||||||
- 工单数量:橙色徽章显示,带工具图标
|
- 安装后端:cd backend/my_work && sudo bash install.sh
|
||||||
- 关联客户:蓝色标签显示客户姓名,可点击跳转,最多显示3个
|
|
||||||
- 更新 colspan 从 8 改为 10
|
|
||||||
|
|
||||||
**i18n 翻译**:
|
### 3. 移动端开发
|
||||||
- `en.json`: 添加 `work_order.work_order_count` 和 `customer.related_customers`
|
- **add-workorder.vue** - 新建工单页
|
||||||
- `zh-CN.json`: 添加对应中文翻译
|
- 添加客户搜索功能(参考 Web 前端实现)
|
||||||
- **修复**: 修正了重复添加 `customer` 对象的问题,将 `related_customers` 合并到已有的 `customer` 对象中
|
- 修改关联物品为多选模式
|
||||||
|
- 添加 `selectedItems`、`linkedItemIds` 数组
|
||||||
|
- 修改 `submitForm()` 提交 `item_ids` 数组
|
||||||
|
|
||||||
### 技术细节
|
- **edit-workorder.vue** - 编辑工单页
|
||||||
- 工单数量通过 `TabWarehouseItemWorkOrderBind` 表统计
|
- 添加关联物品多选功能
|
||||||
- 客户信息通过 `TabWarehouseItemCustomerBind` 和 `TabCustomer` 表关联查询
|
- 添加关联客户多选功能
|
||||||
- 采用批量查询优化性能,避免N+1查询问题
|
- 加载时已关联的物品和客户
|
||||||
|
- 修改 `fetchOrder()` 加载 `res.data.items` 和 `res.data.customers`
|
||||||
|
- 修改 `submitForm()` 提交 `item_ids` 和 `customer_ids`
|
||||||
|
|
||||||
|
### 4. API 文件创建
|
||||||
|
- **customer.js** (uni-app api)
|
||||||
|
- 创建客户 API 模块
|
||||||
|
- 支持 list、get、add、update、delete 操作
|
||||||
|
|
||||||
|
## 技术要点
|
||||||
|
- 使用防抖搜索(setTimeout 300ms)
|
||||||
|
- 多选标签式 UI(参考关联客户实现)
|
||||||
|
- Vue 3 Composition API (ref, reactive, onMounted)
|
||||||
|
- uni-app 开发规范
|
||||||
|
|
||||||
|
### 5. 样式修改
|
||||||
|
- **show-workorder.vue** - 工单详情页
|
||||||
|
- 修改关联客户标签颜色:绿色 → 蓝色
|
||||||
|
- 背景色: #f6ffed → #e6f7ff
|
||||||
|
- 边框色: #b7eb8f → #91d5ff
|
||||||
|
- 文字色: #52c41a → #1890ff
|
||||||
|
- 与关联物品样式保持一致
|
||||||
|
|
||||||
|
### 6. 物品页面添加关联客户
|
||||||
|
- **add-item.vue** - 新增物品页
|
||||||
|
- 添加客户搜索功能(防抖 300ms)
|
||||||
|
- 添加 `selectedCustomers` 数组存储已选客户
|
||||||
|
- 添加 `customerSearchQuery`、`customerSearchResults` 等搜索数据
|
||||||
|
- 修改 `submitForm()` 提交 `customer_ids` 数组
|
||||||
|
- 添加客户标签样式(蓝色主题)
|
||||||
|
|
||||||
|
- **item-edit.vue** - 编辑物品页
|
||||||
|
- 添加客户搜索功能(防抖 300ms)
|
||||||
|
- 修改 `fetchDetail()` 加载已关联客户 `res.data.customers`(非 `linkedCustomers`)
|
||||||
|
- 修改 `submitForm()` 提交 `customer_ids` 数组
|
||||||
|
- 添加客户标签样式(蓝色主题)
|
||||||
|
|
||||||
|
- **item-detail.vue** - 物品详情页
|
||||||
|
- 添加加载 `res.data.customers`
|
||||||
|
- 添加显示关联客户 UI
|
||||||
|
- 添加关联客户样式
|
||||||
|
|
||||||
|
### 7. 修复关联客户显示问题
|
||||||
|
- **问题1**: item-edit.vue 没回填关联客户
|
||||||
|
- 原因:使用了错误的字段名 `linkedCustomers`
|
||||||
|
- 修复:改为 `res.data.customers`
|
||||||
|
|
||||||
|
- **问题2**: item-detail.vue 没显示关联客户
|
||||||
|
- 原因:`fetchDetail()` 没有加载 `customers` 字段
|
||||||
|
- 修复:添加 `linkedCustomers.value = res.data.customers || []`
|
||||||
|
- 添加模板代码显示关联客户
|
||||||
|
|
||||||
|
- **后端修复**: apiWarehouse.go
|
||||||
|
- `CustomerInfo` 结构体添加 `PrimaryPhone` 字段
|
||||||
|
- 返回客户信息时包含 `primary_phone`
|
||||||
|
|||||||
@@ -1159,20 +1159,22 @@ func ApiWarehouse(r *gin.RouterGroup) {
|
|||||||
models.DB.Where("item_id = ?", from.ID).Find(&customerBinds)
|
models.DB.Where("item_id = ?", from.ID).Find(&customerBinds)
|
||||||
|
|
||||||
type CustomerInfo struct {
|
type CustomerInfo struct {
|
||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
FirstName string `json:"first_name"`
|
FirstName string `json:"first_name"`
|
||||||
LastName string `json:"last_name"`
|
LastName string `json:"last_name"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
PrimaryPhone string `json:"primary_phone"`
|
||||||
}
|
}
|
||||||
var customers []CustomerInfo
|
var customers []CustomerInfo
|
||||||
for _, b := range customerBinds {
|
for _, b := range customerBinds {
|
||||||
var c TabCustomer
|
var c TabCustomer
|
||||||
if models.DB.Where("id = ?", b.CustomerID).First(&c).Error == nil {
|
if models.DB.Where("id = ?", b.CustomerID).First(&c).Error == nil {
|
||||||
customers = append(customers, CustomerInfo{
|
customers = append(customers, CustomerInfo{
|
||||||
ID: c.ID,
|
ID: c.ID,
|
||||||
FirstName: c.FirstName,
|
FirstName: c.FirstName,
|
||||||
LastName: c.LastName,
|
LastName: c.LastName,
|
||||||
Title: c.Title,
|
Title: c.Title,
|
||||||
|
PrimaryPhone: c.PrimaryPhone,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule frontend/ops2_uniapp updated: da9a303cb6...67c9f16301
Reference in New Issue
Block a user