diff --git a/App.vue b/App.vue
index 99f6e28..71f36e2 100644
--- a/App.vue
+++ b/App.vue
@@ -2,6 +2,12 @@
export default {
onLaunch: function() {
console.log('App Launch')
+ const token = uni.getStorageSync('token');
+ if (!token) {
+ uni.reLaunch({ url: '/pages/login/login' });
+ } else {
+ uni.reLaunch({ url: '/pages/index/index' });
+ }
},
onShow: function() {
console.log('App Show')
@@ -14,4 +20,4 @@
+
diff --git a/api.js b/api.js
new file mode 100644
index 0000000..872190b
--- /dev/null
+++ b/api.js
@@ -0,0 +1,105 @@
+import { BASE_API } from './config'
+
+// 登录接口
+export function login(username, password) {
+ return new Promise((resolve, reject) => {
+ uni.request({
+ url: BASE_API + 'api/admin/auth/login',
+ method: 'POST',
+ data: {
+ username,
+ password
+ },
+ success: resolve,
+ fail: reject
+ })
+ })
+}
+
+// 获取用户信息接口
+export function getUserInfo() {
+ const token = uni.getStorageSync('token')
+ return new Promise((resolve, reject) => {
+ uni.request({
+ url: BASE_API + 'api/admin/auth/me',
+ method: 'POST',
+ data: {
+ token
+ },
+ success: resolve,
+ fail: reject
+ })
+ })
+}
+
+// 退出登录接口
+export function logoutApi() {
+ const token = uni.getStorageSync('token')
+ return new Promise((resolve, reject) => {
+ uni.request({
+ url: BASE_API + 'api/admin/auth/logout',
+ method: 'POST',
+ data: { token },
+ success: resolve,
+ fail: reject
+ })
+ })
+}
+
+// 获取物资详情接口
+export function getMaterialInfo(id) {
+ const token = uni.getStorageSync('token')
+ return new Promise((resolve, reject) => {
+ uni.request({
+ url: BASE_API + 'api/admin/material-infos/show',
+ method: 'GET',
+ data: {
+ id,
+ token
+ },
+ success: resolve,
+ fail: reject
+ })
+ })
+}
+
+// 盘点保存接口
+export function saveInventoryCheck(data) {
+ const token = uni.getStorageSync('token')
+ return new Promise((resolve, reject) => {
+ console.log("confirm接口")
+ uni.request({
+ url: BASE_API + 'api/admin/material-infos-plan-link/confirm',
+ method: 'POST',
+ data: {
+ ...data,
+ token
+ },
+ success: resolve,
+ fail: reject
+ })
+ })
+}
+
+// 文件上传接口
+export function uploadFile(filePath) {
+ const token = uni.getStorageSync('token')
+ return new Promise((resolve, reject) => {
+ uni.uploadFile({
+ url: BASE_API + 'api/admin/upload-file',
+ filePath,
+ name: 'file',
+ formData: { token },
+ success: (res) => {
+ // 假设后端返回 { code: 0, data: { id: 123, url: '...' } }
+ try {
+ const data = JSON.parse(res.data)
+ resolve(data)
+ } catch (e) {
+ reject(e)
+ }
+ },
+ fail: reject
+ })
+ })
+}
\ No newline at end of file
diff --git a/config.js b/config.js
new file mode 100644
index 0000000..c31c0aa
--- /dev/null
+++ b/config.js
@@ -0,0 +1,7 @@
+// 全局配置文件
+export const BASE_API = 'http://192.168.60.99:8004/'
+
+// 导出配置
+export default {
+ BASE_API
+}
\ No newline at end of file
diff --git a/main.js b/main.js
index c1caf36..40ff5a3 100644
--- a/main.js
+++ b/main.js
@@ -1,9 +1,11 @@
import App from './App'
+import config from './config'
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
+Vue.prototype.$config = config
App.mpType = 'app'
const app = new Vue({
...App
@@ -15,6 +17,7 @@ app.$mount()
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
+ app.config.globalProperties.$config = config
return {
app
}
diff --git a/pages.json b/pages.json
index dcb96e5..2dd3d6d 100644
--- a/pages.json
+++ b/pages.json
@@ -29,12 +29,6 @@
"style": {
"navigationBarTitleText": "物资盘点"
}
- },
- {
- "path": "pages/detail/detail",
- "style": {
- "navigationBarTitleText": "物资详情"
- }
}
],
"globalStyle": {
diff --git a/pages/detail/detail.vue b/pages/detail/detail.vue
deleted file mode 100644
index 3bc9e72..0000000
--- a/pages/detail/detail.vue
+++ /dev/null
@@ -1,149 +0,0 @@
-
-
-
-
-
- 物资名称
- {{ info.name }}
-
-
- 物资编号
- {{ info.code }}
-
-
- 库存数量
- {{ info.stockQty }}
-
-
- 物资图片
-
- 无图片
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pages/index/index.vue b/pages/index/index.vue
index b61ff66..7cf614e 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -5,15 +5,15 @@
-
- 最近盘点记录
-
-
-
- {{item.title}}
- {{item.time}}
+
+ 盘点任务列表
+
+
+
+ {{item.title}}
+ {{item.time}}
- {{item.statusText}}
+ {{item.statusText}}
@@ -26,10 +26,25 @@
data() {
return {
currentDate: '',
- recentRecords: [
- { title: '仓库A盘点', time: '2024-03-20 14:30', status: 'completed', statusText: '已完成' },
- { title: '办公用品盘点', time: '2024-03-19 10:15', status: 'processing', statusText: '进行中' },
- { title: '设备资产盘点', time: '2024-03-18 16:45', status: 'completed', statusText: '已完成' }
+ taskList: [
+ {
+ title: '仓库A盘点',
+ time: '2024-06-01 10:00',
+ status: 'pending',
+ statusText: '待完成'
+ },
+ {
+ title: '仓库B盘点',
+ time: '2024-05-28 14:30',
+ status: 'completed',
+ statusText: '已完成'
+ },
+ {
+ title: '仓库C盘点',
+ time: '2024-05-25 09:15',
+ status: 'in-progress',
+ statusText: '进行中'
+ }
]
}
},
@@ -47,8 +62,21 @@
scanInventory() {
uni.scanCode({
success: (res) => {
+ console.log("url:", res.result);
+ let url = res.result;
+ let id = '';
+ // 用正则提取 id=xxx
+ const match = url.match(/[?&]id=([^&]+)/);
+ if (match) {
+ id = match[1];
+ }
+ console.log("id:", id);
+ if (!id) {
+ uni.showToast({ title: '二维码无效', icon: 'none' });
+ return;
+ }
uni.navigateTo({
- url: `/pages/inventory/inventory?code=${encodeURIComponent(res.result)}`
+ url: `/pages/inventory/inventory?code=${encodeURIComponent(id)}`
});
},
fail: () => {
@@ -59,14 +87,29 @@
scanView() {
uni.scanCode({
success: (res) => {
+ let url = res.result;
+ let id = '';
+ const match = url.match(/[?&]id=([^&]+)/);
+ if (match) {
+ id = match[1];
+ }
+ if (!id) {
+ uni.showToast({ title: '二维码无效', icon: 'none' });
+ return;
+ }
uni.navigateTo({
- url: `/pages/detail/detail?code=${encodeURIComponent(res.result)}`
+ url: `/pages/inventory/inventory?code=${encodeURIComponent(id)}&view=1`
});
},
fail: () => {
uni.showToast({ title: '扫码失败', icon: 'none' });
}
});
+ },
+ goTaskDetail(item) {
+ uni.navigateTo({
+ url: `/pages/task-detail/task-detail?title=${encodeURIComponent(item.title)}&time=${encodeURIComponent(item.time)}&status=${item.status}&statusText=${encodeURIComponent(item.statusText)}`
+ });
}
}
}
@@ -142,7 +185,7 @@
background: #f0f7ff;
}
- .recent-section {
+ .task-section {
width: 92%;
max-width: 520px;
margin: 0 auto;
@@ -152,20 +195,20 @@
padding: 28rpx 20rpx 18rpx 20rpx;
}
- .recent-title {
+ .task-title {
font-size: 28rpx;
color: #222;
font-weight: 700;
margin-bottom: 18rpx;
}
- .recent-list {
+ .task-list {
display: flex;
flex-direction: column;
gap: 14rpx;
}
- .recent-item {
+ .task-item {
display: flex;
justify-content: space-between;
align-items: center;
@@ -173,40 +216,45 @@
border-bottom: 1px solid #f0f0f0;
}
- .recent-item:last-child {
+ .task-item:last-child {
border-bottom: none;
}
- .recent-info {
+ .task-info {
display: flex;
flex-direction: column;
}
- .recent-name {
+ .task-name {
font-size: 24rpx;
color: #333;
font-weight: 600;
}
- .recent-time {
+ .task-time {
font-size: 20rpx;
color: #999;
margin-top: 2rpx;
}
- .recent-status {
+ .task-status {
font-size: 20rpx;
padding: 4rpx 14rpx;
border-radius: 16rpx;
}
- .recent-status.completed {
+ .task-status.pending {
+ background-color: #fff3e0;
+ color: #ff9800;
+ }
+
+ .task-status.completed {
background-color: #e8f5e9;
color: #4caf50;
}
- .recent-status.processing {
- background-color: #fff3e0;
- color: #ff9800;
+ .task-status.in-progress {
+ background-color: #e8f5e9;
+ color: #4caf50;
}
diff --git a/pages/inventory/inventory.vue b/pages/inventory/inventory.vue
index 70c2bc2..96ab14b 100644
--- a/pages/inventory/inventory.vue
+++ b/pages/inventory/inventory.vue
@@ -1,61 +1,92 @@
-
- 盘点人
-
-
-
- 盘点日期
-
-
-
- 库存数量
-
+
+
+ 物资名称
+ {{ materialName }}
+
+
+ 物质代码
+ {{ materialCode }}
+
+
+ 规格型号
+ {{ materialSpec }}
+
+
+ 库存数量
+ {{ stockQty }}{{ unit ? ' ' + unit : '' }}
+
-
+
盘点数量
-
+
盘点备注
-
+
-
+
照片上传
-
+
- 删除
+
+ ×
+
-
+
-
+