You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

781 lines
27 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
Promise.prototype.finally = function(callback) {
const promise = this.constructor;
return this.then(
(value) => promise.resolve(callback()).then(() => value),
(reason) => promise.resolve(callback()).then(() => {
throw reason;
})
);
};
}
;
if (typeof uni !== "undefined" && uni && uni.requireGlobal) {
const global = uni.requireGlobal();
ArrayBuffer = global.ArrayBuffer;
Int8Array = global.Int8Array;
Uint8Array = global.Uint8Array;
Uint8ClampedArray = global.Uint8ClampedArray;
Int16Array = global.Int16Array;
Uint16Array = global.Uint16Array;
Int32Array = global.Int32Array;
Uint32Array = global.Uint32Array;
Float32Array = global.Float32Array;
Float64Array = global.Float64Array;
BigInt64Array = global.BigInt64Array;
BigUint64Array = global.BigUint64Array;
}
;
if (uni.restoreGlobal) {
uni.restoreGlobal(Vue, weex, plus, setTimeout, clearTimeout, setInterval, clearInterval);
}
(function(vue) {
"use strict";
function formatAppLog(type, filename, ...args) {
if (uni.__log__) {
uni.__log__(type, filename, ...args);
} else {
console[type].apply(console, [...args, filename]);
}
}
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _sfc_main$5 = {
data() {
return {
currentDate: "",
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: "进行中"
}
]
};
},
onLoad() {
this.updateDate();
},
methods: {
updateDate() {
const now = /* @__PURE__ */ new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, "0");
const day = String(now.getDate()).padStart(2, "0");
this.currentDate = `${year}-${month}-${day}`;
},
scanInventory() {
uni.scanCode({
success: (res) => {
formatAppLog("log", "at pages/index/index.vue:65", "url:", res.result);
let url = res.result;
let id = "";
const match = url.match(/[?&]id=([^&]+)/);
if (match) {
id = match[1];
}
formatAppLog("log", "at pages/index/index.vue:73", "id:", id);
if (!id) {
uni.showToast({ title: "二维码无效", icon: "none" });
return;
}
uni.navigateTo({
url: `/pages/inventory/inventory?code=${encodeURIComponent(id)}`
});
},
fail: () => {
uni.showToast({ title: "扫码失败", icon: "none" });
}
});
},
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/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)}`
});
}
}
};
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", { class: "index-bg" }, [
vue.createElementVNode("view", { class: "index-content" }, [
vue.createElementVNode("view", { class: "btn-group" }, [
vue.createElementVNode("button", {
class: "main-btn",
onClick: _cache[0] || (_cache[0] = (...args) => $options.scanInventory && $options.scanInventory(...args))
}, "扫码盘点"),
vue.createElementVNode("button", {
class: "main-btn outline",
onClick: _cache[1] || (_cache[1] = (...args) => $options.scanView && $options.scanView(...args))
}, "扫码查看")
]),
vue.createElementVNode("view", { class: "task-section" }, [
vue.createElementVNode("view", { class: "task-title" }, "盘点任务列表"),
vue.createElementVNode("view", { class: "task-list" }, [
(vue.openBlock(true), vue.createElementBlock(
vue.Fragment,
null,
vue.renderList($data.taskList, (item, idx) => {
return vue.openBlock(), vue.createElementBlock("view", {
class: "task-item",
key: idx,
onClick: ($event) => $options.goTaskDetail(item)
}, [
vue.createElementVNode("view", { class: "task-info" }, [
vue.createElementVNode(
"text",
{ class: "task-name" },
vue.toDisplayString(item.title),
1
/* TEXT */
),
vue.createElementVNode(
"text",
{ class: "task-time" },
vue.toDisplayString(item.time),
1
/* TEXT */
)
]),
vue.createElementVNode(
"text",
{
class: vue.normalizeClass(["task-status", item.status])
},
vue.toDisplayString(item.statusText),
3
/* TEXT, CLASS */
)
], 8, ["onClick"]);
}),
128
/* KEYED_FRAGMENT */
))
])
])
])
]);
}
const PagesIndexIndex = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$4], ["__file", "D:/Lynn/Langye/stocktaking/pages/index/index.vue"]]);
const BASE_API = "http://192.168.60.99:8004/";
const config = {
BASE_API
};
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
});
});
}
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
});
});
}
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
});
});
}
function saveInventoryCheck(data) {
const token = uni.getStorageSync("token");
return new Promise((resolve, reject) => {
formatAppLog("log", "at api.js:70", "confirm接口");
uni.request({
url: BASE_API + "api/admin/material-infos-plan-link/confirm",
method: "POST",
data: {
...data,
token
},
success: resolve,
fail: reject
});
});
}
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) => {
try {
const data = JSON.parse(res.data);
resolve(data);
} catch (e) {
reject(e);
}
},
fail: reject
});
});
}
const _sfc_main$4 = {
data() {
return {
userInfo: {}
};
},
onShow() {
getUserInfo().then((response) => {
if (response.data) {
formatAppLog("log", "at pages/profile/profile.vue:36", "返回数据", response.data);
this.userInfo = response.data;
} else {
uni.showToast({
title: response.data.errmsg || "获取信息失败",
icon: "none"
});
}
}).catch(() => {
uni.showToast({ title: "网络错误", icon: "none" });
});
},
methods: {
logout() {
uni.removeStorageSync("token");
uni.reLaunch({ url: "/pages/login/login" });
}
}
};
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", { class: "profile-container" }, [
vue.createElementVNode("view", { class: "avatar-section" }, [
vue.createElementVNode("image", {
class: "avatar",
src: $data.userInfo.avatar || "/static/profile/avatar.png",
mode: "aspectFill"
}, null, 8, ["src"])
]),
vue.createElementVNode("view", { class: "info-section" }, [
vue.createElementVNode("view", { class: "info-item" }, [
vue.createElementVNode("text", { class: "label" }, "用户名:"),
vue.createElementVNode(
"text",
{ class: "value" },
vue.toDisplayString($data.userInfo.username || "-"),
1
/* TEXT */
)
]),
vue.createElementVNode("view", { class: "info-item" }, [
vue.createElementVNode("text", { class: "label" }, "姓名:"),
vue.createElementVNode(
"text",
{ class: "value" },
vue.toDisplayString($data.userInfo.name || "-"),
1
/* TEXT */
)
]),
vue.createElementVNode("view", { class: "info-item" }, [
vue.createElementVNode("text", { class: "label" }, "部门:"),
vue.createElementVNode(
"text",
{ class: "value" },
vue.toDisplayString($data.userInfo.department && $data.userInfo.department.name || "-"),
1
/* TEXT */
)
])
]),
vue.createElementVNode("button", {
class: "logout-btn",
onClick: _cache[0] || (_cache[0] = (...args) => $options.logout && $options.logout(...args))
}, "退出登录")
]);
}
const PagesProfileProfile = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$3], ["__file", "D:/Lynn/Langye/stocktaking/pages/profile/profile.vue"]]);
const _sfc_main$3 = {
data() {
return {
username: "",
password: ""
};
},
methods: {
handleLogin() {
if (!this.username || !this.password) {
uni.showToast({
title: "请输入用户名和密码",
icon: "none"
});
return;
}
uni.showLoading({ title: "登录中...", mask: true });
login(this.username, this.password).then((response) => {
uni.hideLoading();
formatAppLog("log", "at pages/login/login.vue:41", response);
if (response.data && response.data.errcode !== void 0) {
uni.showToast({
title: response.data.errmsg || "登录失败",
icon: "none"
});
} else if (response.data) {
formatAppLog("log", "at pages/login/login.vue:48", response.data.access_token);
if (response.data.access_token) {
uni.setStorageSync("token", response.data.access_token);
}
uni.showToast({
title: "登录成功",
icon: "success",
duration: 1500
});
setTimeout(() => {
uni.switchTab({
url: "/pages/index/index"
});
}, 1500);
}
}).catch(() => {
uni.hideLoading();
uni.showToast({ title: "网络错误", icon: "none" });
});
}
}
};
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", { class: "login-bg" }, [
vue.createElementVNode("view", { class: "login-card" }, [
vue.createElementVNode("view", { class: "login-title" }, "欢迎登录"),
vue.createElementVNode("view", { class: "login-subtitle" }, "河道防汛物资管理系统"),
vue.createElementVNode("view", { class: "form-group" }, [
vue.createElementVNode("text", { class: "form-label" }, "用户名"),
vue.withDirectives(vue.createElementVNode(
"input",
{
class: "form-input",
type: "text",
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $data.username = $event),
placeholder: "请输入用户名"
},
null,
512
/* NEED_PATCH */
), [
[vue.vModelText, $data.username]
])
]),
vue.createElementVNode("view", { class: "form-group" }, [
vue.createElementVNode("text", { class: "form-label" }, "密码"),
vue.withDirectives(vue.createElementVNode(
"input",
{
class: "form-input",
type: "password",
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => $data.password = $event),
placeholder: "请输入密码"
},
null,
512
/* NEED_PATCH */
), [
[vue.vModelText, $data.password]
])
]),
vue.createElementVNode("button", {
class: "login-btn",
onClick: _cache[2] || (_cache[2] = (...args) => $options.handleLogin && $options.handleLogin(...args))
}, "登 录")
])
]);
}
const PagesLoginLogin = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$2], ["__file", "D:/Lynn/Langye/stocktaking/pages/login/login.vue"]]);
const _sfc_main$2 = {
data() {
return {
result: ""
};
},
methods: {
doScan() {
uni.scanCode({
success: (res) => {
this.result = res.result;
},
fail: () => {
uni.showToast({ title: "扫码失败", icon: "none" });
}
});
}
}
};
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", { class: "scan-bg" }, [
vue.createElementVNode("view", { class: "scan-title" }, "扫码盘点"),
vue.createElementVNode("button", {
class: "scan-btn",
onClick: _cache[0] || (_cache[0] = (...args) => $options.doScan && $options.doScan(...args))
}, "点击开始扫码"),
$data.result ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "scan-result"
}, [
vue.createElementVNode("text", { class: "result-label" }, "扫码结果:"),
vue.createElementVNode(
"text",
{ class: "result-value" },
vue.toDisplayString($data.result),
1
/* TEXT */
)
])) : vue.createCommentVNode("v-if", true)
]);
}
const PagesScanScan = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1], ["__file", "D:/Lynn/Langye/stocktaking/pages/scan/scan.vue"]]);
const _sfc_main$1 = {
data() {
return {
isViewMode: false,
stockQty: "",
countQty: "",
remark: "",
photo: "",
photos: [],
materialName: "",
materialSpec: "",
unit: "",
materialCode: "",
material_infos_plan_id: "",
materialId: ""
};
},
onLoad(options) {
this.isViewMode = options.view === "1";
this.date = this.getToday();
this.materialId = options.code;
formatAppLog("log", "at pages/inventory/inventory.vue:73", "materialId:", this.materialId);
if (this.materialId) {
getMaterialInfo(this.materialId).then((response) => {
formatAppLog("log", "at pages/inventory/inventory.vue:76", "response:", response);
if (response.data) {
this.materialName = response.data.zichanmingcheng || "-";
this.materialSpec = response.data.guigexinghao || "-";
this.unit = response.data.jiliangdanwei || "-";
this.materialCode = response.data.wuzibianma || "-";
this.material_infos_plan_id = response.data.material_infos_plan_id || "";
this.stockQty = response.data.inventorys_total || "0";
} else {
uni.showToast({ title: "未获取到物资信息", icon: "none" });
}
}).catch(() => {
uni.showToast({ title: "获取物资信息失败", icon: "none" });
});
}
},
methods: {
getToday() {
const now = /* @__PURE__ */ new Date();
const y = now.getFullYear();
const m = String(now.getMonth() + 1).padStart(2, "0");
const d = String(now.getDate()).padStart(2, "0");
return `${y}-${m}-${d}`;
},
choosePhoto() {
if (this.photos.length >= 3) {
uni.showToast({ title: "最多上传3张照片", icon: "none" });
return;
}
uni.chooseImage({
count: 3 - this.photos.length,
success: (res) => {
this.photos = [...this.photos, ...res.tempFilePaths];
}
});
},
deletePhoto(index) {
this.photos.splice(index, 1);
},
async submit() {
if (!this.countQty) {
uni.showToast({ title: "请输入盘点数量", icon: "none" });
return;
}
if (!/^(0|[1-9][0-9]*)$/.test(this.countQty)) {
uni.showToast({ title: "盘点数量必须为0或正整数", icon: "none" });
return;
}
uni.showLoading({ title: "提交中..." });
let file_ids = [];
for (let i = 0; i < this.photos.length; i++) {
try {
const res = await uploadFile(this.photos[i]);
if (res && res.id) {
file_ids.push(res.id);
}
} catch (e) {
uni.hideLoading();
uni.showToast({ title: "图片上传失败", icon: "none" });
return;
}
}
const data = {
status: "1",
material_info_id: this.materialId,
// 或实际物资id字段
check_num: this.countQty,
remark: this.remark,
file_ids
// 其他参数如 material_infos_plan_id、status、check_date 可按需补充
};
formatAppLog("log", "at pages/inventory/inventory.vue:149", "data:", data);
saveInventoryCheck(data).then((res) => {
formatAppLog("log", "at pages/inventory/inventory.vue:152", "res:", res);
uni.hideLoading();
if (res && (!res.data || res.data.errcode === void 0)) {
uni.showToast({ title: "盘点提交成功", icon: "success" });
setTimeout(() => {
uni.reLaunch({ url: "/pages/index/index" });
}, 1200);
} else {
uni.showToast({ title: res.data.errmsg || "提交失败", icon: "none" });
}
}).catch(() => {
uni.hideLoading();
uni.showToast({ title: "提交失败", icon: "none" });
});
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", { class: "inventory-bg" }, [
vue.createElementVNode("view", { class: "inventory-card" }, [
vue.createElementVNode("view", { class: "readonly-group" }, [
vue.createElementVNode("view", { class: "readonly-item" }, [
vue.createElementVNode("text", { class: "readonly-label" }, "物资名称"),
vue.createElementVNode(
"text",
{ class: "readonly-value" },
vue.toDisplayString($data.materialName),
1
/* TEXT */
)
]),
vue.createElementVNode("view", { class: "readonly-item" }, [
vue.createElementVNode("text", { class: "readonly-label" }, "物质代码"),
vue.createElementVNode(
"text",
{ class: "readonly-value" },
vue.toDisplayString($data.materialCode),
1
/* TEXT */
)
]),
vue.createElementVNode("view", { class: "readonly-item" }, [
vue.createElementVNode("text", { class: "readonly-label" }, "规格型号"),
vue.createElementVNode(
"text",
{ class: "readonly-value" },
vue.toDisplayString($data.materialSpec),
1
/* TEXT */
)
]),
vue.createElementVNode("view", { class: "readonly-item" }, [
vue.createElementVNode("text", { class: "readonly-label" }, "库存数量"),
vue.createElementVNode(
"text",
{ class: "readonly-value" },
vue.toDisplayString($data.stockQty) + vue.toDisplayString($data.unit ? " " + $data.unit : ""),
1
/* TEXT */
)
])
]),
!$data.isViewMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "form-group"
}, [
vue.createElementVNode("text", { class: "form-label" }, "盘点数量"),
vue.withDirectives(vue.createElementVNode(
"input",
{
class: "form-input",
type: "number",
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $data.countQty = $event),
placeholder: "请输入盘点数量"
},
null,
512
/* NEED_PATCH */
), [
[vue.vModelText, $data.countQty]
])
])) : vue.createCommentVNode("v-if", true),
!$data.isViewMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: "form-group"
}, [
vue.createElementVNode("text", { class: "form-label" }, "盘点备注"),
vue.withDirectives(vue.createElementVNode(
"textarea",
{
class: "form-textarea",
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => $data.remark = $event),
placeholder: "请输入备注信息"
},
null,
512
/* NEED_PATCH */
), [
[vue.vModelText, $data.remark]
])
])) : vue.createCommentVNode("v-if", true),
!$data.isViewMode ? (vue.openBlock(), vue.createElementBlock("view", {
key: 2,
class: "form-group"
}, [
vue.createElementVNode("text", { class: "form-label" }, "照片上传"),
vue.createElementVNode("view", { class: "photo-upload" }, [
(vue.openBlock(true), vue.createElementBlock(
vue.Fragment,
null,
vue.renderList($data.photos, (photo, index) => {
return vue.openBlock(), vue.createElementBlock("view", {
key: index,
class: "photo-preview"
}, [
vue.createElementVNode("image", {
src: photo,
mode: "aspectFill",
class: "photo-img"
}, null, 8, ["src"]),
vue.createElementVNode("view", {
class: "photo-del",
onClick: ($event) => $options.deletePhoto(index)
}, [
vue.createElementVNode("text", { class: "delete-icon" }, "×")
], 8, ["onClick"])
]);
}),
128
/* KEYED_FRAGMENT */
)),
$data.photos.length < 3 ? (vue.openBlock(), vue.createElementBlock("button", {
key: 0,
class: "photo-btn",
onClick: _cache[2] || (_cache[2] = (...args) => $options.choosePhoto && $options.choosePhoto(...args))
}, [
vue.createElementVNode("text", { class: "iconfont icon-camera" }),
vue.createElementVNode("text", { class: "btn-text" }, "上传照片")
])) : vue.createCommentVNode("v-if", true)
])
])) : vue.createCommentVNode("v-if", true),
!$data.isViewMode ? (vue.openBlock(), vue.createElementBlock("button", {
key: 3,
class: "submit-btn",
onClick: _cache[3] || (_cache[3] = (...args) => $options.submit && $options.submit(...args))
}, "提交盘点")) : vue.createCommentVNode("v-if", true)
])
]);
}
const PagesInventoryInventory = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__file", "D:/Lynn/Langye/stocktaking/pages/inventory/inventory.vue"]]);
__definePage("pages/index/index", PagesIndexIndex);
__definePage("pages/profile/profile", PagesProfileProfile);
__definePage("pages/login/login", PagesLoginLogin);
__definePage("pages/scan/scan", PagesScanScan);
__definePage("pages/inventory/inventory", PagesInventoryInventory);
const _sfc_main = {
onLaunch: function() {
formatAppLog("log", "at App.vue:4", "App Launch");
const token = uni.getStorageSync("token");
if (!token) {
uni.reLaunch({ url: "/pages/login/login" });
} else {
uni.reLaunch({ url: "/pages/index/index" });
}
},
onShow: function() {
formatAppLog("log", "at App.vue:13", "App Show");
},
onHide: function() {
formatAppLog("log", "at App.vue:16", "App Hide");
}
};
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "D:/Lynn/Langye/stocktaking/App.vue"]]);
function createApp() {
const app = vue.createVueApp(App);
app.config.globalProperties.$config = config;
return {
app
};
}
const { app: __app__, Vuex: __Vuex__, Pinia: __Pinia__ } = createApp();
uni.Vuex = __Vuex__;
uni.Pinia = __Pinia__;
__app__.provide("__globalStyles", __uniConfig.styles);
__app__._component.mpType = "app";
__app__._component.render = () => {
};
__app__.mount("#app");
})(Vue);