up修复数量问题

This commit is contained in:
2026-04-27 13:04:42 +08:00
parent 93359a1bd3
commit 1d1a4f3670
6 changed files with 184 additions and 15 deletions
+40
View File
@@ -0,0 +1,40 @@
/**
* 打包前自动递增版本号
* 用法: node bump-version.js
*
* - versionCode: 每次 +1(必须递增,否则 Android 无法覆盖安装)
* - versionName: 语义化版本自动递增 patch 位(1.0.0 → 1.0.1
*/
const fs = require('fs')
const path = require('path')
const manifestPath = path.join(__dirname, 'manifest.json')
if (!fs.existsSync(manifestPath)) {
console.error('未找到 manifest.json,请在 ops2_uniapp 目录下运行此脚本')
process.exit(1)
}
// manifest.json 可能包含 JS 风格注释,先去掉再解析
const raw = fs.readFileSync(manifestPath, 'utf8')
const cleaned = raw.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '')
const manifest = JSON.parse(cleaned)
// 递增 versionCode
const oldCode = parseInt(manifest.versionCode) || 0
const newCode = oldCode + 1
manifest.versionCode = newCode.toString()
// 递增 versionName 的 patch 位
const parts = (manifest.versionName || '1.0.0').split('.')
if (parts.length >= 3) {
parts[2] = (parseInt(parts[2]) + 1).toString()
} else {
parts.push('1')
}
manifest.versionName = parts.join('.')
// 写回
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n')
console.log(`版本已更新: ${manifest.versionName} (${manifest.versionCode})`)
+2 -10
View File
@@ -2,10 +2,9 @@
"name" : "Operations", "name" : "Operations",
"appid" : "__UNI__8A0DE5E", "appid" : "__UNI__8A0DE5E",
"description" : "Operations(运营)的缩写,一个前后端分离的工作流/运营管理系统。", "description" : "Operations(运营)的缩写,一个前后端分离的工作流/运营管理系统。",
"versionName" : "1.0.0", "versionName" : "1.0.1",
"versionCode" : "100", "versionCode" : "101",
"transformPx" : false, "transformPx" : false,
/* 5+App */
"app-plus" : { "app-plus" : {
"usingComponents" : true, "usingComponents" : true,
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler" : "uni-app",
@@ -16,15 +15,12 @@
"autoclose" : true, "autoclose" : true,
"delay" : 0 "delay" : 0
}, },
/* */
"modules" : { "modules" : {
"Barcode" : {}, "Barcode" : {},
"Bluetooth" : {}, "Bluetooth" : {},
"Camera" : {} "Camera" : {}
}, },
/* */
"distribute" : { "distribute" : {
/* android */
"android" : { "android" : {
"permissions" : [ "permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
@@ -44,11 +40,9 @@
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
] ]
}, },
/* ios */
"ios" : { "ios" : {
"dSYMs" : false "dSYMs" : false
}, },
/* SDK */
"sdkConfigs" : {}, "sdkConfigs" : {},
"icons" : { "icons" : {
"android" : { "android" : {
@@ -87,9 +81,7 @@
} }
} }
}, },
/* */
"quickapp" : {}, "quickapp" : {},
/* */
"mp-weixin" : { "mp-weixin" : {
"appid" : "", "appid" : "",
"setting" : { "setting" : {
+38
View File
@@ -27,6 +27,17 @@
<!-- ===== 分组关于 ===== -->
<view class="group">
<text class="group-title">关于</text>
<view class="group-body">
<view class="cell">
<text class="cell-label">版本号</text>
<text class="cell-value">{{ version }}</text>
</view>
</view>
</view>
</view> </view>
</template> </template>
@@ -37,6 +48,9 @@ import { useConfigStore } from '../../stores/config'
const useConfig=useConfigStore() const useConfig=useConfigStore()
// ---- 版本号 ----
const version = ref('')
// ---- 响应式状态 ---- // ---- 响应式状态 ----
const isTested=ref(false)//是否点了测试 const isTested=ref(false)//是否点了测试
const isTesting=ref(false)//是否正在测试 const isTesting=ref(false)//是否正在测试
@@ -101,7 +115,25 @@ function onEditApiUrl() {
onMounted(() => { onMounted(() => {
// 真机/打包环境:通过 plus.runtime 获取
// #ifndef H5
version.value = plus.runtime.version || ''
// #endif
// H5 端:从 manifest.json 读取
// #ifdef H5
fetch('/manifest.json')
.then(r => r.text())
.then(text => {
// manifest.json 可能含 JS 注释,需先去除再解析
const cleaned = text.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '')
const m = JSON.parse(cleaned)
version.value = (m.versionName || '') + ' (' + (m.versionCode || '') + ')'
})
.catch(() => {
version.value = ''
})
// #endif
}) })
</script> </script>
@@ -145,6 +177,12 @@ onMounted(()=>{
background-color: #ffffff; background-color: #ffffff;
} }
/* 左侧标签 */
.cell-label {
font-size: 30rpx;
color: #1c1c1e;
}
/* 点击高亮(uni-app 用 hover-class 实现,这里仅演示结构) */ /* 点击高亮(uni-app 用 hover-class 实现,这里仅演示结构) */
.cell:active { .cell:active {
background-color: #f2f2f7; background-color: #f2f2f7;
+49 -1
View File
@@ -17,6 +17,19 @@
<input class="form-input" v-model="form.serialNumber" placeholder="请输入物品编号(选填)" /> <input class="form-input" v-model="form.serialNumber" placeholder="请输入物品编号(选填)" />
</view> </view>
<view class="form-item">
<text class="form-label">数量</text>
<view class="quantity-row">
<view class="qty-btn" @click="form.quantity > 1 && form.quantity--">
<text class="qty-btn-text"></text>
</view>
<input class="qty-input" type="number" v-model.number="form.quantity" />
<view class="qty-btn" @click="form.quantity++">
<text class="qty-btn-text">+</text>
</view>
</view>
</view>
<view class="form-item"> <view class="form-item">
<text class="form-label">备注</text> <text class="form-label">备注</text>
<textarea class="form-textarea" v-model="form.remark" placeholder="请输入备注(选填)" /> <textarea class="form-textarea" v-model="form.remark" placeholder="请输入备注(选填)" />
@@ -68,6 +81,7 @@ const form = ref({
name: '', name: '',
serialNumber: '', serialNumber: '',
remark: '', remark: '',
quantity: 1,
photos: [] photos: []
}) })
@@ -129,6 +143,7 @@ async function submitForm() {
name: form.value.name, name: form.value.name,
serial_number: form.value.serialNumber, serial_number: form.value.serialNumber,
remark: form.value.remark, remark: form.value.remark,
quantity: form.value.quantity > 0 ? form.value.quantity : 1,
container_id: containerId.value || null, container_id: containerId.value || null,
photos: form.value.photos photos: form.value.photos
} }
@@ -154,7 +169,6 @@ async function submitForm() {
// 获取页面参数 // 获取页面参数
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
onLoad((options) => { onLoad((options) => {
console.log('add-item onLoad options:', options)
if (options && options.container_id) { if (options && options.container_id) {
containerId.value = parseInt(options.container_id) containerId.value = parseInt(options.container_id)
} }
@@ -311,4 +325,38 @@ onLoad((options) => {
border-radius: 12rpx; border-radius: 12rpx;
font-size: 32rpx; font-size: 32rpx;
} }
/* 数量选择器 */
.quantity-row {
display: flex;
align-items: center;
gap: 0;
}
.qty-btn {
width: 72rpx;
height: 72rpx;
background-color: #f0f0f0;
border-radius: 10rpx;
display: flex;
align-items: center;
justify-content: center;
}
.qty-btn-text {
font-size: 36rpx;
color: #333;
line-height: 1;
}
.qty-input {
width: 100rpx;
height: 72rpx;
text-align: center;
background-color: #f5f5f5;
font-size: 30rpx;
border-radius: 10rpx;
margin: 0 16rpx;
box-sizing: border-box;
}
</style> </style>
+50 -1
View File
@@ -22,6 +22,19 @@
<input class="form-input" v-model="form.serialNumber" placeholder="请输入物品编号(选填)" /> <input class="form-input" v-model="form.serialNumber" placeholder="请输入物品编号(选填)" />
</view> </view>
<view class="form-item">
<text class="form-label">数量</text>
<view class="quantity-row">
<view class="qty-btn" @click="form.quantity > 1 && form.quantity--">
<text class="qty-btn-text"></text>
</view>
<input class="qty-input" type="number" v-model.number="form.quantity" />
<view class="qty-btn" @click="form.quantity++">
<text class="qty-btn-text">+</text>
</view>
</view>
</view>
<view class="form-item"> <view class="form-item">
<text class="form-label">备注</text> <text class="form-label">备注</text>
<textarea class="form-textarea" v-model="form.remark" placeholder="请输入备注(选填)" /> <textarea class="form-textarea" v-model="form.remark" placeholder="请输入备注(选填)" />
@@ -75,6 +88,7 @@ const form = ref({
name: '', name: '',
serialNumber: '', serialNumber: '',
remark: '', remark: '',
quantity: 1,
photos: [] photos: []
}) })
@@ -134,6 +148,7 @@ async function fetchDetail() {
name: item.Name || '', name: item.Name || '',
serialNumber: item.SerialNumber || '', serialNumber: item.SerialNumber || '',
remark: item.Remark || '', remark: item.Remark || '',
quantity: item.Quantity ?? 1,
photos: res.data.photos ? res.data.photos.map(p => p.Sha256) : [] photos: res.data.photos ? res.data.photos.map(p => p.Sha256) : []
} }
} else { } else {
@@ -160,6 +175,7 @@ async function submitForm() {
name: form.value.name, name: form.value.name,
serial_number: form.value.serialNumber, serial_number: form.value.serialNumber,
remark: form.value.remark, remark: form.value.remark,
quantity: form.value.quantity > 0 ? form.value.quantity : 1,
photos: form.value.photos photos: form.value.photos
} }
@@ -184,7 +200,6 @@ async function submitForm() {
// 获取页面参数 // 获取页面参数
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
onLoad((options) => { onLoad((options) => {
console.log('item-edit onLoad options:', options)
if (options && options.id) { if (options && options.id) {
itemId.value = parseInt(options.id) itemId.value = parseInt(options.id)
fetchDetail() fetchDetail()
@@ -348,4 +363,38 @@ onLoad((options) => {
border-radius: 12rpx; border-radius: 12rpx;
font-size: 32rpx; font-size: 32rpx;
} }
/* 数量选择器 */
.quantity-row {
display: flex;
align-items: center;
gap: 0;
}
.qty-btn {
width: 72rpx;
height: 72rpx;
background-color: #f0f0f0;
border-radius: 10rpx;
display: flex;
align-items: center;
justify-content: center;
}
.qty-btn-text {
font-size: 36rpx;
color: #333;
line-height: 1;
}
.qty-input {
width: 100rpx;
height: 72rpx;
text-align: center;
background-color: #f5f5f5;
font-size: 30rpx;
border-radius: 10rpx;
margin: 0 16rpx;
box-sizing: border-box;
}
</style> </style>
+2
View File
@@ -82,6 +82,7 @@
<view class="item-info"> <view class="item-info">
<text class="item-name">{{ item.Name }}</text> <text class="item-name">{{ item.Name }}</text>
<text class="item-meta" v-if="item.SerialNumber">编号: {{ item.SerialNumber }}</text> <text class="item-meta" v-if="item.SerialNumber">编号: {{ item.SerialNumber }}</text>
<text class="item-meta">数量: {{ item.Quantity ?? 1 }}</text>
</view> </view>
<view class="item-arrow"></view> <view class="item-arrow"></view>
</view> </view>
@@ -110,6 +111,7 @@
<view class="item-info"> <view class="item-info">
<text class="item-name">{{ item.Name }}</text> <text class="item-name">{{ item.Name }}</text>
<text class="item-meta" v-if="item.SerialNumber">编号: {{ item.SerialNumber }}</text> <text class="item-meta" v-if="item.SerialNumber">编号: {{ item.SerialNumber }}</text>
<text class="item-meta">数量: {{ item.Quantity ?? 1 }}</text>
<text class="item-location" v-if="item.ContainerBreadcrumb"> <text class="item-location" v-if="item.ContainerBreadcrumb">
位置: {{ item.ContainerBreadcrumb }} 位置: {{ item.ContainerBreadcrumb }}
</text> </text>