From 03a05815d7ea5612206b6cfe5d6537b4d4cedc0a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 15 九月 2026 11:41:32 +0800
Subject: [PATCH] 天津潜宇塑胶app 1.添加采购需求、库存盘点、计件单价配置、产量统计、材料消耗核算、成本核算分析页面
---
src/utils/common.ts | 69 ++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/src/utils/common.ts b/src/utils/common.ts
new file mode 100644
index 0000000..737af34
--- /dev/null
+++ b/src/utils/common.ts
@@ -0,0 +1,69 @@
+import dayjs from 'dayjs'
+
+/**
+* 鏄剧ず娑堟伅鎻愮ず妗�
+* @param content 鎻愮ず鐨勬爣棰�
+*/
+export function toast(content:string) {
+ uni.showToast({
+ icon: 'none',
+ title: content
+ })
+}
+
+/**
+* 鏈懆鏃ユ湡鍖洪棿锛堝懆涓� ~ 浠婂ぉ锛�
+* dayjs 鏈厤缃� locale 鏃朵竴鍛ㄤ粠鍛ㄦ棩绠楄捣锛岃繖閲屾樉寮忔寜鍛ㄤ竴璧风畻
+*/
+export function getWeekRange() {
+ const today = dayjs()
+ const offset = (today.day() + 6) % 7
+ return {
+ startDate: today.subtract(offset, 'day').format('YYYY-MM-DD'),
+ endDate: today.format('YYYY-MM-DD')
+ }
+}
+
+/**
+* 鏄剧ず妯℃�佸脊绐�
+* @param content 鎻愮ず鐨勬爣棰�
+*/
+export function showConfirm(content:string):Promise<any> {
+ return new Promise((resolve, reject) => {
+ uni.showModal({
+ title: '鎻愮ず',
+ content: content,
+ cancelText: '鍙栨秷',
+ confirmText: '纭畾',
+ success: function(res) {
+ resolve(res)
+ }
+ })
+ })
+}
+
+/**
+* 鍙傛暟澶勭悊
+* @param params 鍙傛暟
+*/
+export function tansParams(params:any) {
+ let result = ''
+ for (const propName of Object.keys(params)) {
+ const value = params[propName]
+ var part = encodeURIComponent(propName) + "="
+ if (value !== null && value !== "" && typeof (value) !== "undefined") {
+ if (typeof value === 'object') {
+ for (const key of Object.keys(value)) {
+ if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') {
+ let params = propName + '[' + key + ']'
+ var subPart = encodeURIComponent(params) + "="
+ result += subPart + encodeURIComponent(value[key]) + "&"
+ }
+ }
+ } else {
+ result += part + encodeURIComponent(value) + "&"
+ }
+ }
+ }
+ return result
+}
\ No newline at end of file
--
Gitblit v1.9.3