功能:新增下一阶段运营能力和生产部署
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||
* Usage: keep after-sale endpoints aligned with /admin/after-sale on the backend.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
listAfterSales(params) {
|
||||
return request({
|
||||
url: '/after-sale/list',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
approveAfterSale(id, data) {
|
||||
return request({
|
||||
url: `/after-sale/${id}/approve`,
|
||||
method: 'PUT',
|
||||
data: data || {}
|
||||
})
|
||||
},
|
||||
|
||||
rejectAfterSale(id, data) {
|
||||
return request({
|
||||
url: `/after-sale/${id}/reject`,
|
||||
method: 'PUT',
|
||||
data: data || {}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||
* Usage: keep schedule endpoints aligned with /admin/artist-schedule on the backend.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
listSchedules(params) {
|
||||
return request({
|
||||
url: '/artist-schedule/list',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
saveSchedule(data) {
|
||||
return request({
|
||||
url: '/artist-schedule/save',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||
* Usage: keep campaign endpoints aligned with /admin/campaign on the backend.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
listCampaigns(params) {
|
||||
return request({
|
||||
url: '/campaign/list',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
saveCampaign(data) {
|
||||
return request({
|
||||
url: '/campaign/save',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -13,5 +13,11 @@ module.exports = {
|
||||
return request({
|
||||
url: '/dashboard/stats'
|
||||
})
|
||||
},
|
||||
|
||||
getAnalytics() {
|
||||
return request({
|
||||
url: '/dashboard/analytics'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||
* Usage: keep inventory endpoints aligned with /admin/inventory on the backend.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
listItems(params) {
|
||||
return request({
|
||||
url: '/inventory/list',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
saveItem(data) {
|
||||
return request({
|
||||
url: '/inventory/save',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
adjustStock(id, data) {
|
||||
return request({
|
||||
url: `/inventory/${id}/adjust`,
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||
* Usage: call manual payment operations only after UI permission checks; backend remains authoritative.
|
||||
*/
|
||||
const request = require('../utils/request')
|
||||
|
||||
module.exports = {
|
||||
manualConfirmOrder(orderId, remark) {
|
||||
return request({
|
||||
url: `/payment/order/${orderId}/manual-confirm`,
|
||||
method: 'POST',
|
||||
params: {
|
||||
remark
|
||||
},
|
||||
data: {}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,10 @@
|
||||
"pages/tag-form/index",
|
||||
"pages/artists/index",
|
||||
"pages/artist-form/index",
|
||||
"pages/schedules/index",
|
||||
"pages/after-sales/index",
|
||||
"pages/inventory/index",
|
||||
"pages/campaigns/index",
|
||||
"pages/shops/index",
|
||||
"pages/shop-form/index",
|
||||
"pages/permissions/index",
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
const afterSaleApi = require('../../api/after-sale')
|
||||
const navigation = require('../../utils/navigation')
|
||||
const permission = require('../../utils/permission')
|
||||
const format = require('../../utils/format')
|
||||
const { markDirty } = require('../../utils/page-state')
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待处理', value: 'PENDING' },
|
||||
{ label: '已同意', value: 'APPROVED' },
|
||||
{ label: '已驳回', value: 'REJECTED' }
|
||||
]
|
||||
|
||||
function safeList(response) {
|
||||
if (Array.isArray(response && response.list)) {
|
||||
return response.list
|
||||
}
|
||||
if (Array.isArray(response && response.records)) {
|
||||
return response.records
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
function statusText(status) {
|
||||
if (status === 'PENDING') {
|
||||
return '待处理'
|
||||
}
|
||||
if (status === 'APPROVED') {
|
||||
return '已同意'
|
||||
}
|
||||
if (status === 'REJECTED') {
|
||||
return '已驳回'
|
||||
}
|
||||
return status || '--'
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
list: [],
|
||||
total: 0,
|
||||
status: 'PENDING',
|
||||
statusOptions: STATUS_OPTIONS,
|
||||
canAudit: false
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入售后处理')) {
|
||||
return
|
||||
}
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
canAudit: permission.hasPermission(permissionCodes, 'after_sale:audit')
|
||||
})
|
||||
this.loadAfterSales()
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.loadAfterSales().finally(() => {
|
||||
wx.stopPullDownRefresh()
|
||||
})
|
||||
},
|
||||
|
||||
async loadAfterSales() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const response = await afterSaleApi.listAfterSales({
|
||||
page: 1,
|
||||
size: 20,
|
||||
status: this.data.status || undefined
|
||||
})
|
||||
this.setData({
|
||||
list: safeList(response).map(item => this.formatAfterSale(item)),
|
||||
total: Number(response && response.total) || 0
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '售后加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
formatAfterSale(item) {
|
||||
return {
|
||||
...item,
|
||||
displayCreateTime: format.formatDateTime(item.createTime),
|
||||
displayAuditTime: format.formatDateTime(item.auditTime),
|
||||
displayRefundAmount: format.formatPrice(item.refundAmount),
|
||||
statusText: statusText(item.status)
|
||||
}
|
||||
},
|
||||
|
||||
handleStatusChange(event) {
|
||||
this.setData({
|
||||
status: event.currentTarget.dataset.status || ''
|
||||
})
|
||||
this.loadAfterSales()
|
||||
},
|
||||
|
||||
promptReason(title) {
|
||||
return new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title,
|
||||
content: '可填写处理说明,留空也可以提交。',
|
||||
editable: true,
|
||||
placeholderText: '处理说明',
|
||||
confirmText: '提交',
|
||||
success: result => {
|
||||
if (!result.confirm) {
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
resolve(String(result.content || '').trim())
|
||||
},
|
||||
fail: () => resolve(null)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
async handleAudit(event) {
|
||||
if (!this.data.canAudit) {
|
||||
wx.showToast({
|
||||
title: '当前账号没有处理售后权限',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const id = event.currentTarget.dataset.id
|
||||
const action = event.currentTarget.dataset.action
|
||||
if (!id || !action) {
|
||||
return
|
||||
}
|
||||
const reason = await this.promptReason(action === 'approve' ? '同意售后' : '驳回售后')
|
||||
if (reason === null) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = {
|
||||
auditReason: reason
|
||||
}
|
||||
if (action === 'approve') {
|
||||
await afterSaleApi.approveAfterSale(id, data)
|
||||
} else {
|
||||
await afterSaleApi.rejectAfterSale(id, data)
|
||||
}
|
||||
markDirty('admin-workbench')
|
||||
wx.showToast({
|
||||
title: '售后已处理',
|
||||
icon: 'none'
|
||||
})
|
||||
this.loadAfterSales()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '售后处理失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/manage/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<navigation-bar title="售后处理" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||
|
||||
<view class="page-shell">
|
||||
<view class="page-stack">
|
||||
<view class="hero-panel">
|
||||
<text class="hero-kicker">After Sale</text>
|
||||
<text class="hero-title">售后处理</text>
|
||||
<text class="hero-desc">查看待处理退款/售后申请,在手机端完成同意或驳回的最小闭环。</text>
|
||||
</view>
|
||||
|
||||
<view class="surface-card">
|
||||
<text class="section-title">状态筛选</text>
|
||||
<view class="chip-row">
|
||||
<block wx:for="{{statusOptions}}" wx:key="value">
|
||||
<view class="chip-btn {{status === item.value ? 'active' : ''}}" data-status="{{item.value}}" bindtap="handleStatusChange">{{item.label}}</view>
|
||||
</block>
|
||||
</view>
|
||||
<text class="section-desc">共 {{total}} 条记录</text>
|
||||
</view>
|
||||
|
||||
<block wx:for="{{list}}" wx:key="id">
|
||||
<view class="list-card">
|
||||
<view class="list-head">
|
||||
<view>
|
||||
<text class="list-title">{{item.afterSaleNo || ('售后 #' + item.id)}}</text>
|
||||
<text class="list-subtitle">订单 {{item.orderId || '--'}} · {{item.displayCreateTime || '--'}}</text>
|
||||
</view>
|
||||
<text class="{{item.status === 'PENDING' ? 'badge' : 'soft-badge'}}">{{item.statusText}}</text>
|
||||
</view>
|
||||
<view class="meta-grid">
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">类型</text>
|
||||
<text class="meta-value">{{item.type || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">退款金额</text>
|
||||
<text class="meta-value">¥{{item.displayRefundAmount}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">用户 ID</text>
|
||||
<text class="meta-value">{{item.userId || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">审核时间</text>
|
||||
<text class="meta-value">{{item.displayAuditTime || '--'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{item.reason}}" class="hint-card">{{item.reason}}</view>
|
||||
<view wx:if="{{item.auditReason}}" class="hint-card">处理说明:{{item.auditReason}}</view>
|
||||
<view wx:if="{{item.status === 'PENDING'}}" class="list-actions">
|
||||
<view class="mini-btn primary" data-id="{{item.id}}" data-action="approve" bindtap="handleAudit">同意</view>
|
||||
<view class="mini-btn danger" data-id="{{item.id}}" data-action="reject" bindtap="handleAudit">驳回</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||
<text class="empty-title">暂无售后单</text>
|
||||
<text class="empty-desc">当前状态下没有需要展示的售后记录。</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,3 @@
|
||||
.page-shell {
|
||||
background: transparent;
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
const campaignApi = require('../../api/campaign')
|
||||
const navigation = require('../../utils/navigation')
|
||||
const permission = require('../../utils/permission')
|
||||
const format = require('../../utils/format')
|
||||
const { markDirty } = require('../../utils/page-state')
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '启用', value: '1' },
|
||||
{ label: '停用', value: '0' }
|
||||
]
|
||||
|
||||
function safeList(response) {
|
||||
if (Array.isArray(response && response.list)) {
|
||||
return response.list
|
||||
}
|
||||
if (Array.isArray(response && response.records)) {
|
||||
return response.records
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
list: [],
|
||||
total: 0,
|
||||
status: '',
|
||||
statusOptions: STATUS_OPTIONS,
|
||||
canManage: false,
|
||||
form: {
|
||||
title: '',
|
||||
scene: 'HOME',
|
||||
description: '',
|
||||
sortOrder: '0'
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入活动管理')) {
|
||||
return
|
||||
}
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
canManage: permission.hasPermission(permissionCodes, 'campaign:manage')
|
||||
})
|
||||
this.loadCampaigns()
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.loadCampaigns().finally(() => {
|
||||
wx.stopPullDownRefresh()
|
||||
})
|
||||
},
|
||||
|
||||
async loadCampaigns() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const response = await campaignApi.listCampaigns({
|
||||
page: 1,
|
||||
size: 20,
|
||||
status: this.data.status === '' ? undefined : Number(this.data.status)
|
||||
})
|
||||
this.setData({
|
||||
list: safeList(response).map(item => this.formatCampaign(item)),
|
||||
total: Number(response && response.total) || 0
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '活动加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
formatCampaign(item) {
|
||||
return {
|
||||
...item,
|
||||
statusText: Number(item.status) === 0 ? '停用' : '启用',
|
||||
displayStartTime: format.formatDateTime(item.startTime),
|
||||
displayEndTime: format.formatDateTime(item.endTime)
|
||||
}
|
||||
},
|
||||
|
||||
handleStatusChange(event) {
|
||||
this.setData({
|
||||
status: event.currentTarget.dataset.status
|
||||
})
|
||||
this.loadCampaigns()
|
||||
},
|
||||
|
||||
handleFormInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
if (!field) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
[`form.${field}`]: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
async handleSaveCampaign() {
|
||||
if (!this.data.canManage) {
|
||||
wx.showToast({
|
||||
title: '当前账号没有活动管理权限',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const form = this.data.form
|
||||
const title = String(form.title || '').trim()
|
||||
if (!title) {
|
||||
wx.showToast({
|
||||
title: '请填写活动标题',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
await campaignApi.saveCampaign({
|
||||
title,
|
||||
scene: String(form.scene || '').trim() || 'HOME',
|
||||
description: String(form.description || '').trim(),
|
||||
sortOrder: Number(form.sortOrder) || 0,
|
||||
status: 1
|
||||
})
|
||||
markDirty('admin-workbench')
|
||||
wx.showToast({
|
||||
title: '活动已创建',
|
||||
icon: 'none'
|
||||
})
|
||||
this.setData({
|
||||
form: {
|
||||
title: '',
|
||||
scene: 'HOME',
|
||||
description: '',
|
||||
sortOrder: '0'
|
||||
}
|
||||
})
|
||||
this.loadCampaigns()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '活动保存失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/manage/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<navigation-bar title="活动管理" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||
|
||||
<view class="page-shell">
|
||||
<view class="page-stack">
|
||||
<view class="hero-panel">
|
||||
<text class="hero-kicker">Campaign</text>
|
||||
<text class="hero-title">活动管理</text>
|
||||
<text class="hero-desc">查看营销活动和推荐位配置,支持在手机端快速创建启用活动。</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{canManage}}" class="surface-card">
|
||||
<text class="section-title">快速创建</text>
|
||||
<input class="field-input compact-field" placeholder="活动标题" placeholder-class="placeholder" value="{{form.title}}" data-field="title" bindinput="handleFormInput"></input>
|
||||
<view class="form-grid">
|
||||
<input class="field-input" placeholder="场景,如 HOME" placeholder-class="placeholder" value="{{form.scene}}" data-field="scene" bindinput="handleFormInput"></input>
|
||||
<input class="field-input" type="number" placeholder="排序" placeholder-class="placeholder" value="{{form.sortOrder}}" data-field="sortOrder" bindinput="handleFormInput"></input>
|
||||
</view>
|
||||
<textarea class="field-textarea compact-textarea" placeholder="活动说明,可留空" placeholder-class="placeholder" value="{{form.description}}" data-field="description" bindinput="handleFormInput"></textarea>
|
||||
<button class="primary-btn compact-btn" loading="{{loading}}" bindtap="handleSaveCampaign">创建活动</button>
|
||||
</view>
|
||||
|
||||
<view class="surface-card">
|
||||
<text class="section-title">活动列表</text>
|
||||
<view class="chip-row">
|
||||
<block wx:for="{{statusOptions}}" wx:key="value">
|
||||
<view class="chip-btn {{status === item.value ? 'active' : ''}}" data-status="{{item.value}}" bindtap="handleStatusChange">{{item.label}}</view>
|
||||
</block>
|
||||
</view>
|
||||
<text class="section-desc">共 {{total}} 条活动</text>
|
||||
</view>
|
||||
|
||||
<block wx:for="{{list}}" wx:key="id">
|
||||
<view class="list-card">
|
||||
<view class="list-head">
|
||||
<view>
|
||||
<text class="list-title">{{item.title}}</text>
|
||||
<text class="list-subtitle">{{item.scene || '未设置场景'}} · 排序 {{item.sortOrder || 0}}</text>
|
||||
</view>
|
||||
<text class="{{item.status === 0 ? 'soft-badge' : 'success-badge'}}">{{item.statusText}}</text>
|
||||
</view>
|
||||
<view wx:if="{{item.description}}" class="hint-card">{{item.description}}</view>
|
||||
<view class="meta-grid">
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">开始</text>
|
||||
<text class="meta-value">{{item.displayStartTime || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">结束</text>
|
||||
<text class="meta-value">{{item.displayEndTime || '--'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||
<text class="empty-title">暂无活动</text>
|
||||
<text class="empty-desc">当前筛选条件下没有营销活动。</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,20 @@
|
||||
.page-shell {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.compact-field,
|
||||
.compact-btn,
|
||||
.compact-textarea {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14rpx;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.compact-textarea {
|
||||
min-height: 140rpx;
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
const inventoryApi = require('../../api/inventory')
|
||||
const navigation = require('../../utils/navigation')
|
||||
const permission = require('../../utils/permission')
|
||||
const format = require('../../utils/format')
|
||||
const { markDirty } = require('../../utils/page-state')
|
||||
|
||||
function safeList(response) {
|
||||
if (Array.isArray(response && response.list)) {
|
||||
return response.list
|
||||
}
|
||||
if (Array.isArray(response && response.records)) {
|
||||
return response.records
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
list: [],
|
||||
total: 0,
|
||||
canManage: false,
|
||||
form: {
|
||||
itemName: '',
|
||||
category: '',
|
||||
unit: '件',
|
||||
stockQuantity: '0',
|
||||
warningThreshold: '1'
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入库存管理')) {
|
||||
return
|
||||
}
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
canManage: permission.hasPermission(permissionCodes, 'inventory:manage')
|
||||
})
|
||||
this.loadItems()
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.loadItems().finally(() => {
|
||||
wx.stopPullDownRefresh()
|
||||
})
|
||||
},
|
||||
|
||||
async loadItems() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const response = await inventoryApi.listItems({
|
||||
page: 1,
|
||||
size: 30
|
||||
})
|
||||
this.setData({
|
||||
list: safeList(response).map(item => this.formatItem(item)),
|
||||
total: Number(response && response.total) || 0
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '库存加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
formatItem(item) {
|
||||
return {
|
||||
...item,
|
||||
displayStock: format.formatPrice(item.stockQuantity),
|
||||
displayWarning: format.formatPrice(item.warningThreshold),
|
||||
statusText: Number(item.status) === 0 ? '停用' : '启用'
|
||||
}
|
||||
},
|
||||
|
||||
handleFormInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
if (!field) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
[`form.${field}`]: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
async handleSaveItem() {
|
||||
if (!this.data.canManage) {
|
||||
wx.showToast({
|
||||
title: '当前账号没有库存维护权限',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const form = this.data.form
|
||||
if (!String(form.itemName || '').trim()) {
|
||||
wx.showToast({
|
||||
title: '请填写物料名称',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
await inventoryApi.saveItem({
|
||||
itemName: String(form.itemName || '').trim(),
|
||||
category: String(form.category || '').trim(),
|
||||
unit: String(form.unit || '').trim() || '件',
|
||||
stockQuantity: Number(form.stockQuantity) || 0,
|
||||
warningThreshold: Number(form.warningThreshold) || 0,
|
||||
status: 1
|
||||
})
|
||||
markDirty('admin-workbench')
|
||||
wx.showToast({
|
||||
title: '物料已保存',
|
||||
icon: 'none'
|
||||
})
|
||||
this.setData({
|
||||
form: {
|
||||
itemName: '',
|
||||
category: '',
|
||||
unit: '件',
|
||||
stockQuantity: '0',
|
||||
warningThreshold: '1'
|
||||
}
|
||||
})
|
||||
this.loadItems()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '物料保存失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
promptAdjust(item) {
|
||||
return new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: `调整 ${item.itemName}`,
|
||||
content: '填写正数入库,负数出库。',
|
||||
editable: true,
|
||||
placeholderText: '例如 5 或 -2',
|
||||
confirmText: '调整',
|
||||
success: result => {
|
||||
if (!result.confirm) {
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
resolve(String(result.content || '').trim())
|
||||
},
|
||||
fail: () => resolve(null)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
async handleAdjust(event) {
|
||||
if (!this.data.canManage) {
|
||||
wx.showToast({
|
||||
title: '当前账号没有库存调整权限',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const item = event.currentTarget.dataset.item
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
const value = await this.promptAdjust(item)
|
||||
if (value === null) {
|
||||
return
|
||||
}
|
||||
const quantity = Number(value)
|
||||
if (!isFinite(quantity) || quantity === 0) {
|
||||
wx.showToast({
|
||||
title: '请输入非 0 数量',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
await inventoryApi.adjustStock(item.id, {
|
||||
changeType: quantity > 0 ? 'IN' : 'OUT',
|
||||
changeQuantity: quantity,
|
||||
remark: '管理端小程序调整'
|
||||
})
|
||||
markDirty('admin-workbench')
|
||||
wx.showToast({
|
||||
title: '库存已调整',
|
||||
icon: 'none'
|
||||
})
|
||||
this.loadItems()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '库存调整失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/manage/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<navigation-bar title="库存管理" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||
|
||||
<view class="page-shell">
|
||||
<view class="page-stack">
|
||||
<view class="hero-panel">
|
||||
<text class="hero-kicker">Inventory</text>
|
||||
<text class="hero-title">耗材库存</text>
|
||||
<text class="hero-desc">查看库存和预警项,支持手机端快速新增物料与正负数调整库存。</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{canManage}}" class="surface-card">
|
||||
<text class="section-title">新增物料</text>
|
||||
<view class="form-grid">
|
||||
<input class="field-input" placeholder="物料名称" placeholder-class="placeholder" value="{{form.itemName}}" data-field="itemName" bindinput="handleFormInput"></input>
|
||||
<input class="field-input" placeholder="分类" placeholder-class="placeholder" value="{{form.category}}" data-field="category" bindinput="handleFormInput"></input>
|
||||
<input class="field-input" placeholder="单位" placeholder-class="placeholder" value="{{form.unit}}" data-field="unit" bindinput="handleFormInput"></input>
|
||||
<input class="field-input" type="digit" placeholder="初始库存" placeholder-class="placeholder" value="{{form.stockQuantity}}" data-field="stockQuantity" bindinput="handleFormInput"></input>
|
||||
<input class="field-input" type="digit" placeholder="预警阈值" placeholder-class="placeholder" value="{{form.warningThreshold}}" data-field="warningThreshold" bindinput="handleFormInput"></input>
|
||||
</view>
|
||||
<button class="primary-btn compact-btn" loading="{{loading}}" bindtap="handleSaveItem">保存物料</button>
|
||||
</view>
|
||||
|
||||
<view class="surface-card">
|
||||
<text class="section-title">库存列表</text>
|
||||
<text class="section-desc">共 {{total}} 个物料,低于阈值会标记为预警。</text>
|
||||
</view>
|
||||
|
||||
<block wx:for="{{list}}" wx:key="id">
|
||||
<view class="list-card">
|
||||
<view class="list-head">
|
||||
<view>
|
||||
<text class="list-title">{{item.itemName}}</text>
|
||||
<text class="list-subtitle">{{item.category || '未分类'}} · {{item.statusText}}</text>
|
||||
</view>
|
||||
<text class="{{item.warning ? 'danger-badge' : 'success-badge'}}">{{item.warning ? '库存预警' : '正常'}}</text>
|
||||
</view>
|
||||
<view class="meta-grid">
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">当前库存</text>
|
||||
<text class="meta-value">{{item.displayStock}} {{item.unit || ''}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">预警阈值</text>
|
||||
<text class="meta-value">{{item.displayWarning}} {{item.unit || ''}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{canManage}}" class="list-actions">
|
||||
<view class="mini-btn primary" data-item="{{item}}" bindtap="handleAdjust">调整库存</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||
<text class="empty-title">暂无库存物料</text>
|
||||
<text class="empty-desc">当前店铺还没有录入耗材库存。</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,14 @@
|
||||
.page-shell {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.compact-btn {
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
* Usage: call getOrderDetail with the current route id before displaying the order detail page.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
const paymentApi = require('../../api/payment')
|
||||
const permission = require('../../utils/permission')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -14,6 +16,20 @@ const navigation = require('../../utils/navigation')
|
||||
*/
|
||||
const format = require('../../utils/format')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { markDirty } = require('../../utils/page-state')
|
||||
|
||||
function getPaymentStatusText(status) {
|
||||
if (status === 'PAID') {
|
||||
return '已支付'
|
||||
}
|
||||
if (status === 'PAYING') {
|
||||
return '支付中'
|
||||
}
|
||||
if (status === 'REFUNDED') {
|
||||
return '已退款'
|
||||
}
|
||||
return '未支付'
|
||||
}
|
||||
|
||||
Page({
|
||||
/**
|
||||
@@ -35,7 +51,8 @@ Page({
|
||||
* Purpose: order supports index.js by holding or executing the order page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
order: null
|
||||
order: null,
|
||||
canManualConfirmPay: false
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -43,11 +60,13 @@ Page({
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
onLoad(options) {
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
const cachedOrder = getTempRecord('currentOrder', null)
|
||||
const orderId = (options && options.id) || (cachedOrder && cachedOrder.id) || ''
|
||||
this.setData({
|
||||
orderId,
|
||||
order: cachedOrder ? this.formatOrder(cachedOrder) : null
|
||||
order: cachedOrder ? this.formatOrder(cachedOrder) : null,
|
||||
canManualConfirmPay: permission.hasPermission(permissionCodes, 'payment:manage')
|
||||
})
|
||||
|
||||
if (orderId) {
|
||||
@@ -82,11 +101,16 @@ Page({
|
||||
*/
|
||||
formatOrder(order) {
|
||||
const items = Array.isArray(order && order.items) ? order.items : []
|
||||
const paymentStatus = order && order.paymentStatus ? order.paymentStatus : 'UNPAID'
|
||||
return order ? {
|
||||
...order,
|
||||
displayStatusText: format.getOrderStatusText(order),
|
||||
displayPaymentStatusText: getPaymentStatusText(paymentStatus),
|
||||
displayCreateTime: format.formatDateTime(order.createTime),
|
||||
displayPayAmount: format.formatPrice(order.payAmount),
|
||||
displayPayAmount: format.formatPrice(order.payAmount || order.actualAmount),
|
||||
displayPaidAmount: format.formatPrice(order.paidAmount),
|
||||
displayPayTime: format.formatDateTime(order.payTime),
|
||||
canManualConfirmPay: paymentStatus !== 'PAID' && paymentStatus !== 'REFUNDED',
|
||||
items: items.map(item => ({
|
||||
...item,
|
||||
displayAppointmentTime: item.appointmentTime ? format.formatDateTime(item.appointmentTime) : '',
|
||||
@@ -108,6 +132,55 @@ Page({
|
||||
this.loadOrderDetail(this.data.orderId)
|
||||
},
|
||||
|
||||
async handleManualConfirmPay() {
|
||||
if (!this.data.canManualConfirmPay) {
|
||||
wx.showToast({
|
||||
title: '当前账号没有确认支付权限',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const order = this.data.order
|
||||
if (!order) {
|
||||
return
|
||||
}
|
||||
const remark = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '手动确认支付',
|
||||
content: `确认将订单 ${order.orderNo || order.id} 标记为已支付?`,
|
||||
editable: true,
|
||||
placeholderText: '备注,可留空',
|
||||
confirmText: '确认',
|
||||
success: result => {
|
||||
if (!result.confirm) {
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
resolve(String(result.content || '').trim())
|
||||
},
|
||||
fail: () => resolve(null)
|
||||
})
|
||||
})
|
||||
if (remark === null) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await paymentApi.manualConfirmOrder(order.id, remark)
|
||||
markDirty('admin-orders')
|
||||
markDirty('admin-workbench')
|
||||
wx.showToast({
|
||||
title: '支付已确认',
|
||||
icon: 'none'
|
||||
})
|
||||
this.loadOrderDetail(order.id)
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '确认支付失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onUnload supports index.js by holding or executing the on unload page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
|
||||
@@ -26,11 +26,26 @@
|
||||
<text class="meta-label">应付金额</text>
|
||||
<text class="meta-value">¥{{order.displayPayAmount || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">支付状态</text>
|
||||
<text class="meta-value">{{order.displayPaymentStatusText}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">已付金额</text>
|
||||
<text class="meta-value">¥{{order.displayPaidAmount}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">支付时间</text>
|
||||
<text class="meta-value">{{order.displayPayTime || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">备注</text>
|
||||
<text class="meta-value">{{order.remark || '暂无备注'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{canManualConfirmPay && order.canManualConfirmPay}}" class="action-row">
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="handleManualConfirmPay">手动确认支付</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{order && order.items && order.items.length}}" class="surface-card">
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
const paymentApi = require('../../api/payment')
|
||||
/**
|
||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -78,6 +79,19 @@ function formatRating(value) {
|
||||
return rating % 1 === 0 ? String(rating) : rating.toFixed(1)
|
||||
}
|
||||
|
||||
function getPaymentStatusText(status) {
|
||||
if (status === 'PAID') {
|
||||
return '已支付'
|
||||
}
|
||||
if (status === 'PAYING') {
|
||||
return '支付中'
|
||||
}
|
||||
if (status === 'REFUNDED') {
|
||||
return '已退款'
|
||||
}
|
||||
return '未支付'
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isSubmittedReview supports index.js by holding or executing the is submitted review page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -261,11 +275,15 @@ function formatOrderItem(order, item, userInfo, assistData) {
|
||||
function formatOrder(order, userInfo, assistData) {
|
||||
const items = safeList(order.items).map(item => formatOrderItem(order, item, userInfo, assistData))
|
||||
const orderReviewSummary = buildReviewSummary(order.reviewSummary)
|
||||
const paymentStatus = order.paymentStatus || 'UNPAID'
|
||||
return {
|
||||
...order,
|
||||
displayStatusText: format.getOrderStatusText(order),
|
||||
displayPaymentStatusText: getPaymentStatusText(paymentStatus),
|
||||
displayCreateTime: format.formatDateTime(order.createTime),
|
||||
displayPayAmount: format.formatPrice(order.payAmount || order.actualAmount),
|
||||
displayPaidAmount: format.formatPrice(order.paidAmount),
|
||||
canManualConfirmPay: paymentStatus !== 'PAID' && paymentStatus !== 'REFUNDED',
|
||||
items,
|
||||
reviewSummary: orderReviewSummary,
|
||||
reviewStatusText: orderReviewSummary ? orderReviewSummary.displayText : ''
|
||||
@@ -351,6 +369,7 @@ Page({
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
userInfo: null,
|
||||
canManualConfirmPay: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -368,8 +387,10 @@ Page({
|
||||
}
|
||||
|
||||
const userInfo = getApp().globalData.userInfo
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
userInfo
|
||||
userInfo,
|
||||
canManualConfirmPay: permission.hasPermission(permissionCodes, 'payment:manage')
|
||||
})
|
||||
|
||||
if (!this.data.initialized || consumeDirty('admin-orders')) {
|
||||
@@ -377,6 +398,54 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
async handleManualConfirmPay(event) {
|
||||
if (!this.data.canManualConfirmPay) {
|
||||
wx.showToast({
|
||||
title: '当前账号没有确认支付权限',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const order = event.currentTarget.dataset.order
|
||||
if (!order) {
|
||||
return
|
||||
}
|
||||
const confirmed = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '手动确认支付',
|
||||
content: `确认将订单 ${order.orderNo || order.id} 标记为已支付?`,
|
||||
editable: true,
|
||||
placeholderText: '备注,可留空',
|
||||
confirmText: '确认',
|
||||
success: result => {
|
||||
if (!result.confirm) {
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
resolve(String(result.content || '').trim())
|
||||
},
|
||||
fail: () => resolve(null)
|
||||
})
|
||||
})
|
||||
if (confirmed === null) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await paymentApi.manualConfirmOrder(order.id, confirmed)
|
||||
markDirty('admin-workbench')
|
||||
wx.showToast({
|
||||
title: '支付已确认',
|
||||
icon: 'none'
|
||||
})
|
||||
this.loadOrders()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '确认支付失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onPullDownRefresh supports index.js by holding or executing the on pull down refresh page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
<text class="meta-label">订单金额</text>
|
||||
<text class="meta-value">¥{{item.displayPayAmount}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">支付状态</text>
|
||||
<text class="meta-value">{{item.displayPaymentStatusText}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">所属门店</text>
|
||||
<text class="meta-value">{{item.shopName || '--'}}</text>
|
||||
@@ -71,6 +75,7 @@
|
||||
|
||||
<view class="list-actions">
|
||||
<view class="mini-btn" data-order="{{item}}" bindtap="handleOpenOrder">查看详情</view>
|
||||
<view wx:if="{{canManualConfirmPay && item.canManualConfirmPay}}" class="mini-btn primary" data-order="{{item}}" bindtap="handleManualConfirmPay">确认支付</view>
|
||||
<view wx:if="{{item.status !== 2}}" class="mini-btn primary" data-order="{{item}}" bindtap="handleProcessOrder">处理订单</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
const scheduleApi = require('../../api/artist-schedule')
|
||||
const navigation = require('../../utils/navigation')
|
||||
const permission = require('../../utils/permission')
|
||||
const format = require('../../utils/format')
|
||||
const { markDirty } = require('../../utils/page-state')
|
||||
|
||||
function todayText(offset) {
|
||||
const date = new Date()
|
||||
date.setDate(date.getDate() + (offset || 0))
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${month}-${day}`
|
||||
}
|
||||
|
||||
function safeList(value) {
|
||||
return Array.isArray(value) ? value : []
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
list: [],
|
||||
startDate: todayText(0),
|
||||
endDate: todayText(6),
|
||||
artistId: '',
|
||||
canEdit: false,
|
||||
form: {
|
||||
artistId: '',
|
||||
workDate: todayText(0),
|
||||
startTime: '10:00',
|
||||
endTime: '18:00',
|
||||
slotMinutes: '60',
|
||||
capacity: '1',
|
||||
remark: ''
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入排班管理')) {
|
||||
return
|
||||
}
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
canEdit: permission.hasPermission(permissionCodes, 'schedule:edit')
|
||||
})
|
||||
this.loadSchedules()
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.loadSchedules().finally(() => {
|
||||
wx.stopPullDownRefresh()
|
||||
})
|
||||
},
|
||||
|
||||
buildQuery() {
|
||||
const query = {}
|
||||
;['artistId', 'startDate', 'endDate'].forEach(key => {
|
||||
const value = String(this.data[key] || '').trim()
|
||||
if (value) {
|
||||
query[key] = value
|
||||
}
|
||||
})
|
||||
return query
|
||||
},
|
||||
|
||||
async loadSchedules() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const list = await scheduleApi.listSchedules(this.buildQuery())
|
||||
this.setData({
|
||||
list: safeList(list).map(item => this.formatSchedule(item))
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '排班加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
formatSchedule(item) {
|
||||
const startTime = String(item.startTime || '').slice(0, 5)
|
||||
const endTime = String(item.endTime || '').slice(0, 5)
|
||||
return {
|
||||
...item,
|
||||
displayDate: format.formatDate(item.workDate),
|
||||
displayTime: `${startTime || '--'} - ${endTime || '--'}`,
|
||||
statusText: Number(item.status) === 0 ? '停用' : '可预约'
|
||||
}
|
||||
},
|
||||
|
||||
handleArtistInput(event) {
|
||||
this.setData({ artistId: event.detail.value })
|
||||
},
|
||||
|
||||
handleStartDateChange(event) {
|
||||
this.setData({ startDate: event.detail.value })
|
||||
this.loadSchedules()
|
||||
},
|
||||
|
||||
handleEndDateChange(event) {
|
||||
this.setData({ endDate: event.detail.value })
|
||||
this.loadSchedules()
|
||||
},
|
||||
|
||||
handleSearch() {
|
||||
this.loadSchedules()
|
||||
},
|
||||
|
||||
handleFormInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
if (!field) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
[`form.${field}`]: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
handleFormDateChange(event) {
|
||||
this.setData({
|
||||
'form.workDate': event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
handleFormStartTimeChange(event) {
|
||||
this.setData({
|
||||
'form.startTime': event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
handleFormEndTimeChange(event) {
|
||||
this.setData({
|
||||
'form.endTime': event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
async handleSaveSchedule() {
|
||||
if (!this.data.canEdit) {
|
||||
wx.showToast({
|
||||
title: '当前账号没有编辑排班权限',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const form = this.data.form
|
||||
const artistId = String(form.artistId || '').trim()
|
||||
if (!artistId) {
|
||||
wx.showToast({
|
||||
title: '请填写美甲师 ID',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await scheduleApi.saveSchedule({
|
||||
artistId,
|
||||
workDate: form.workDate,
|
||||
startTime: form.startTime,
|
||||
endTime: form.endTime,
|
||||
slotMinutes: Number(form.slotMinutes) || 60,
|
||||
capacity: Number(form.capacity) || 1,
|
||||
status: 1,
|
||||
remark: String(form.remark || '').trim()
|
||||
})
|
||||
markDirty('admin-workbench')
|
||||
wx.showToast({
|
||||
title: '排班已保存',
|
||||
icon: 'none'
|
||||
})
|
||||
this.loadSchedules()
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '排班保存失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/manage/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<navigation-bar title="排班管理" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||
|
||||
<view class="page-shell">
|
||||
<view class="page-stack">
|
||||
<view class="hero-panel">
|
||||
<text class="hero-kicker">Schedule</text>
|
||||
<text class="hero-title">门店排班</text>
|
||||
<text class="hero-desc">按日期和美甲师查看可约班次,支持店长和管理员快速补录当天班次。</text>
|
||||
</view>
|
||||
|
||||
<view class="surface-card">
|
||||
<text class="section-title">筛选</text>
|
||||
<input class="field-input compact-field" placeholder="美甲师 ID,可留空" placeholder-class="placeholder" value="{{artistId}}" bindinput="handleArtistInput" confirm-type="search" bindconfirm="handleSearch"></input>
|
||||
<view class="filter-row">
|
||||
<picker mode="date" value="{{startDate}}" bindchange="handleStartDateChange">
|
||||
<view class="field-picker">{{startDate || '开始日期'}}</view>
|
||||
</picker>
|
||||
<picker mode="date" value="{{endDate}}" bindchange="handleEndDateChange">
|
||||
<view class="field-picker">{{endDate || '结束日期'}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<button class="secondary-btn compact-btn" loading="{{loading}}" bindtap="handleSearch">查询排班</button>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{canEdit}}" class="surface-card">
|
||||
<text class="section-title">快速补班</text>
|
||||
<view class="form-grid">
|
||||
<input class="field-input" placeholder="美甲师 ID" placeholder-class="placeholder" value="{{form.artistId}}" data-field="artistId" bindinput="handleFormInput"></input>
|
||||
<picker mode="date" value="{{form.workDate}}" bindchange="handleFormDateChange">
|
||||
<view class="field-picker">{{form.workDate}}</view>
|
||||
</picker>
|
||||
<picker mode="time" value="{{form.startTime}}" bindchange="handleFormStartTimeChange">
|
||||
<view class="field-picker">{{form.startTime}}</view>
|
||||
</picker>
|
||||
<picker mode="time" value="{{form.endTime}}" bindchange="handleFormEndTimeChange">
|
||||
<view class="field-picker">{{form.endTime}}</view>
|
||||
</picker>
|
||||
<input class="field-input" type="number" placeholder="时段分钟" placeholder-class="placeholder" value="{{form.slotMinutes}}" data-field="slotMinutes" bindinput="handleFormInput"></input>
|
||||
<input class="field-input" type="number" placeholder="容量" placeholder-class="placeholder" value="{{form.capacity}}" data-field="capacity" bindinput="handleFormInput"></input>
|
||||
</view>
|
||||
<textarea class="field-textarea compact-textarea" placeholder="备注,可留空" placeholder-class="placeholder" value="{{form.remark}}" data-field="remark" bindinput="handleFormInput"></textarea>
|
||||
<button class="primary-btn compact-btn" loading="{{loading}}" bindtap="handleSaveSchedule">保存排班</button>
|
||||
</view>
|
||||
|
||||
<block wx:for="{{list}}" wx:key="id">
|
||||
<view class="list-card">
|
||||
<view class="list-head">
|
||||
<view>
|
||||
<text class="list-title">{{item.displayDate}} · 美甲师 {{item.artistId}}</text>
|
||||
<text class="list-subtitle">{{item.displayTime}} · {{item.slotMinutes || 60}} 分钟/档 · 容量 {{item.capacity || 1}}</text>
|
||||
</view>
|
||||
<text class="{{item.status === 0 ? 'soft-badge' : 'success-badge'}}">{{item.statusText}}</text>
|
||||
</view>
|
||||
<view wx:if="{{item.remark}}" class="hint-card">{{item.remark}}</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||
<text class="empty-title">暂无排班</text>
|
||||
<text class="empty-desc">当前日期范围没有可展示班次。</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,26 @@
|
||||
.page-shell {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.compact-field,
|
||||
.compact-btn,
|
||||
.compact-textarea {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.filter-row picker,
|
||||
.form-grid picker {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.compact-textarea {
|
||||
min-height: 140rpx;
|
||||
}
|
||||
@@ -26,6 +26,10 @@ const cache = require('../../utils/cache')
|
||||
const { CACHE_TTL } = require('../../utils/config')
|
||||
const { consumeDirty } = require('../../utils/page-state')
|
||||
|
||||
function formatMoney(value) {
|
||||
return Number(value || 0).toFixed(2)
|
||||
}
|
||||
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||
@@ -62,6 +66,16 @@ Page({
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
pendingOrders: 0,
|
||||
/**
|
||||
* Purpose: analytics stores vNext operations analytics for the mobile workbench summary.
|
||||
* Usage: set from dashboard analytics when the current user has analytics:view.
|
||||
*/
|
||||
analytics: null,
|
||||
/**
|
||||
* Purpose: todoStats stores lightweight operations todo counters for the workbench.
|
||||
* Usage: show pending order and vNext operations counts without blocking the base dashboard.
|
||||
*/
|
||||
todoStats: [],
|
||||
/**
|
||||
* Purpose: shoplessAdmin supports index.js by holding or executing the shopless admin page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -142,6 +156,7 @@ Page({
|
||||
const currentShopId = this.data.currentShop && this.data.currentShop.id ? String(this.data.currentShop.id) : 'none'
|
||||
const statsCacheKey = `workbench:stats:${currentShopId}`
|
||||
const pendingCacheKey = `workbench:pending:${currentShopId}`
|
||||
const analyticsCacheKey = `workbench:analytics:${currentShopId}`
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
@@ -159,6 +174,8 @@ Page({
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
stats: null,
|
||||
analytics: null,
|
||||
todoStats: [],
|
||||
/**
|
||||
* Purpose: pendingOrders supports index.js by holding or executing the pending orders page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -208,10 +225,31 @@ Page({
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
return
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
await this.loadOperationsSummary({
|
||||
requestId,
|
||||
force,
|
||||
permissionCodes,
|
||||
analyticsCacheKey,
|
||||
pendingCacheKey
|
||||
})
|
||||
if (requestId !== this._loadRequestId) {
|
||||
return
|
||||
}
|
||||
if (this.data.initialized) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.data.analytics || this.data.todoStats.length) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
initialized: true
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (permission.hasPermission(permissionCodes, 'order:view')) {
|
||||
try {
|
||||
if (force) {
|
||||
@@ -332,6 +370,100 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
async loadOperationsSummary(options) {
|
||||
const requestId = options.requestId
|
||||
const force = options.force
|
||||
const permissionCodes = options.permissionCodes || []
|
||||
const analyticsCacheKey = options.analyticsCacheKey
|
||||
const pendingCacheKey = options.pendingCacheKey
|
||||
const tasks = []
|
||||
|
||||
if (permission.hasPermission(permissionCodes, 'analytics:view')) {
|
||||
if (force) {
|
||||
cache.removeCache(analyticsCacheKey)
|
||||
}
|
||||
tasks.push(cache.remember(analyticsCacheKey, CACHE_TTL.workbench, () => dashboardApi.getAnalytics())
|
||||
.then(analytics => ({ key: 'analytics', value: analytics }))
|
||||
.catch(() => ({ key: 'analytics', value: null })))
|
||||
}
|
||||
|
||||
if (permission.hasPermission(permissionCodes, 'order:view')) {
|
||||
if (force) {
|
||||
cache.removeCache(pendingCacheKey)
|
||||
}
|
||||
tasks.push(cache.remember(pendingCacheKey, CACHE_TTL.workbench, () => orderApi.listOrders({
|
||||
page: 1,
|
||||
size: 1,
|
||||
status: 1
|
||||
})).then(result => ({
|
||||
key: 'pendingOrders',
|
||||
value: Number(result && result.total) || 0
|
||||
})).catch(() => ({
|
||||
key: 'pendingOrders',
|
||||
value: 0
|
||||
})))
|
||||
}
|
||||
|
||||
if (!tasks.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const results = await Promise.all(tasks)
|
||||
if (requestId !== this._loadRequestId) {
|
||||
return
|
||||
}
|
||||
const nextData = {}
|
||||
results.forEach(item => {
|
||||
nextData[item.key] = item.value
|
||||
})
|
||||
const analytics = Object.prototype.hasOwnProperty.call(nextData, 'analytics') ? nextData.analytics : this.data.analytics
|
||||
const pendingOrders = Object.prototype.hasOwnProperty.call(nextData, 'pendingOrders') ? nextData.pendingOrders : this.data.pendingOrders
|
||||
nextData.todoStats = this.buildTodoStats(analytics, pendingOrders, permissionCodes)
|
||||
nextData.analytics = analytics
|
||||
nextData.pendingOrders = pendingOrders
|
||||
this.setData(nextData)
|
||||
},
|
||||
|
||||
buildTodoStats(analytics, pendingOrders, permissionCodes) {
|
||||
const todos = []
|
||||
if (permission.hasPermission(permissionCodes, 'order:view')) {
|
||||
todos.push({
|
||||
key: 'orders',
|
||||
label: '待服务订单',
|
||||
value: pendingOrders || 0,
|
||||
note: '来自订单待服务状态',
|
||||
path: '/pages/orders/index'
|
||||
})
|
||||
}
|
||||
if (permission.hasPermission(permissionCodes, 'after_sale:view')) {
|
||||
todos.push({
|
||||
key: 'afterSales',
|
||||
label: '售后待处理',
|
||||
value: '--',
|
||||
note: '进入售后处理查看明细',
|
||||
path: '/pages/after-sales/index'
|
||||
})
|
||||
}
|
||||
if (permission.hasPermission(permissionCodes, 'inventory:view')) {
|
||||
todos.push({
|
||||
key: 'inventory',
|
||||
label: '库存预警',
|
||||
value: '--',
|
||||
note: '进入库存管理查看低库存',
|
||||
path: '/pages/inventory/index'
|
||||
})
|
||||
}
|
||||
if (analytics) {
|
||||
todos.push({
|
||||
key: 'paid',
|
||||
label: '已支付订单',
|
||||
value: Number(analytics.paidOrderCount) || 0,
|
||||
note: `GMV ¥${formatMoney(analytics.totalAmount)}`
|
||||
})
|
||||
}
|
||||
return todos.slice(0, 4)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenModule supports index.js by holding or executing the handle open module page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
|
||||
@@ -34,6 +34,16 @@
|
||||
<text class="stat-value">{{permissionCount}}</text>
|
||||
<text class="stat-note">前端仅做显隐,服务端仍会兜底校验</text>
|
||||
</view>
|
||||
<view class="stat-card" wx:if="{{analytics}}">
|
||||
<text class="stat-label">经营订单</text>
|
||||
<text class="stat-value">{{analytics.orderCount || 0}}</text>
|
||||
<text class="stat-note">支付 {{analytics.paidOrderCount || 0}} · 完成 {{analytics.completedOrderCount || 0}}</text>
|
||||
</view>
|
||||
<view class="stat-card" wx:if="{{analytics}}">
|
||||
<text class="stat-label">收藏/加购</text>
|
||||
<text class="stat-value">{{analytics.favoriteCount || 0}}/{{analytics.cartCount || 0}}</text>
|
||||
<text class="stat-note">浏览 {{analytics.viewCount || 0}} · 评价 {{analytics.reviewCount || 0}}</text>
|
||||
</view>
|
||||
<view class="stat-card" wx:if="{{stats}}">
|
||||
<text class="stat-label">用户总量</text>
|
||||
<text class="stat-value">{{stats.totalUsers || 0}}</text>
|
||||
@@ -50,6 +60,20 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!shoplessAdmin && todoStats.length}}" class="surface-card">
|
||||
<text class="section-title">待办与运营</text>
|
||||
<text class="section-desc">同步 vNext 运营能力的轻量摘要,点有入口的待办可直接进入处理页。</text>
|
||||
<view class="stats-grid">
|
||||
<block wx:for="{{todoStats}}" wx:key="key">
|
||||
<view class="stat-card" data-path="{{item.path}}" bindtap="handleOpenModule">
|
||||
<text class="stat-label">{{item.label}}</text>
|
||||
<text class="stat-value">{{item.value}}</text>
|
||||
<text class="stat-note">{{item.note}}</text>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="surface-card">
|
||||
<text class="section-title">快捷入口</text>
|
||||
<text class="section-desc">只展示当前账号真实可进入的模块,避免手机端一屏堆太多无权限入口。</text>
|
||||
|
||||
@@ -51,6 +51,38 @@ const MANAGE_MODULES = [
|
||||
permissionCodes: ['nail_artist:view'],
|
||||
requiresShopContext: true
|
||||
},
|
||||
{
|
||||
key: 'schedules',
|
||||
title: '排班管理',
|
||||
description: '查看和维护美甲师班次、休息日与预约容量',
|
||||
path: '/pages/schedules/index',
|
||||
permissionCodes: ['schedule:view'],
|
||||
requiresShopContext: true
|
||||
},
|
||||
{
|
||||
key: 'afterSales',
|
||||
title: '售后处理',
|
||||
description: '查看售后申请,完成同意、驳回和处理说明',
|
||||
path: '/pages/after-sales/index',
|
||||
permissionCodes: ['after_sale:view'],
|
||||
requiresShopContext: true
|
||||
},
|
||||
{
|
||||
key: 'inventory',
|
||||
title: '库存管理',
|
||||
description: '查看耗材库存、预警并快速调整入库出库',
|
||||
path: '/pages/inventory/index',
|
||||
permissionCodes: ['inventory:view'],
|
||||
requiresShopContext: true
|
||||
},
|
||||
{
|
||||
key: 'campaigns',
|
||||
title: '活动管理',
|
||||
description: '查看营销活动、推荐位和轻量活动配置',
|
||||
path: '/pages/campaigns/index',
|
||||
permissionCodes: ['campaign:view'],
|
||||
requiresShopContext: true
|
||||
},
|
||||
{
|
||||
key: 'shops',
|
||||
title: '店铺管理',
|
||||
|
||||
Reference in New Issue
Block a user