diff --git a/src/App.vue b/src/App.vue
index 1d15e16..4af05a5 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,13 +1,16 @@
diff --git a/src/api/mes/mold.js b/src/api/mes/mold.js
new file mode 100644
index 0000000..3d6546c
--- /dev/null
+++ b/src/api/mes/mold.js
@@ -0,0 +1,34 @@
+import request from '@/utils/request'
+
+export function getMoldDetail(id) {
+ return request({
+ url: '/admin-api/erp/mold-brand/mold/get',
+ method: 'get',
+ params: { id }
+ })
+}
+
+export function getMoldInspectionByMoldId(moldId, params = {}) {
+ return request({
+ url: '/admin-api/mes/mold-ticket-management/getInspectionByMoldId',
+ method: 'get',
+ params: { moldId, ...params }
+ })
+}
+
+export function getMoldMaintenanceByMoldId(moldId, params = {}) {
+ return request({
+ url: '/admin-api/mes/mold-ticket-management/getMaintenanceByMoldId',
+ method: 'get',
+ params: { moldId, ...params }
+ })
+}
+
+export function getMoldRepairListByMoldId(moldId, params = {}) {
+ return request({
+ url: '/admin-api/mes/mold-repair/getRepairListByMoldId',
+ method: 'get',
+ params: { moldId, ...params }
+ })
+}
+
diff --git a/src/api/system/dict/data.js b/src/api/system/dict/data.js
index ca0c999..11d94e2 100644
--- a/src/api/system/dict/data.js
+++ b/src/api/system/dict/data.js
@@ -50,6 +50,13 @@ export function delData(dictCode) {
method: 'delete'
})
}
+
+export function getSimpleDictList() {
+ return request({
+ url: '/admin-api/system/dict-data/simple-list',
+ method: 'get'
+ })
+}
//
export const processTypes = [
{text: '制浆', value: 'zhijiang'}, {text: '成型', value: 'chengxing'},
@@ -72,4 +79,4 @@ export const feedingTypes = [
export function findTextByValue(enums,value){
const foundItem = enums.find(item => item.value === value);
return foundItem ? foundItem.text : null;
-}
\ No newline at end of file
+}
diff --git a/src/pages_function/pages/mold/detail.vue b/src/pages_function/pages/mold/detail.vue
index e144045..f12fb87 100644
--- a/src/pages_function/pages/mold/detail.vue
+++ b/src/pages_function/pages/mold/detail.vue
@@ -7,10 +7,6 @@
-
- {{ moldData.status }}
@@ -20,60 +16,183 @@
模具名称
- {{ moldData.name }}
+ {{ getDetailField('name') }}
- 模具类型
- {{ moldData.type }}
+ 模具编号
+ {{ getDetailField('code') }}
- 规格型号
- {{ moldData.spec }}
+ 模具状态
+
- 所属产线
- {{ moldData.lineName }}
+ 模具型号
+ {{ getDetailField('brandName') }}
- 存放位置
- {{ moldData.location }}
+ 模具规格
+ {{ getDetailField('moldType') }}
-
-
-
-
- 使用信息
-
- 累计产量
- {{ moldData.totalOutput }}
+ 工序
+ {{ getDetailField('orgType') }}
- 使用寿命
- {{ moldData.lifeSpan }}
+ 模穴数
+ {{ getDetailField('moldSize') }}
- 上次保养
- {{ moldData.lastMaintenance }}
+ 使用次数/次
+ {{ getDetailField('useTime') }}
- 下次保养
- {{ moldData.nextMaintenance }}
+ 使用设备
+ {{ machineLabel }}
+
+
+ 入库日期
+ {{ inTimeLabel }}
+
+
+ 是否启用
+ {{ enableLabel }}
+
+
+ 备注
+ {{ getDetailField('remark') }}
- 维护记录
-
-
-
-
- {{ record.title }}
- {{ record.time }}
+ 履历
+
+
+
+
+
+ 暂无点检数据
+
+
+ [{{ group.time }}]
+ 操作人: {{ group.operator }}
+
+
+
+ {{ item.resultLabel }}
+ {{ item.name }}
+
+
+
+ 点检方式
+ {{ detailValue(item.method) }}
+
+
+ 判定标准
+ {{ detailValue(item.criteria) }}
+
+
+ 点检时间
+ {{ detailValue(item.taskTimeLabel) }}
+
+
+ 创建时间
+ {{ detailValue(item.createTimeLabel) }}
+
+
+ 备注
+ {{ detailValue(item.remark) }}
+
+
+
+
+
+
+
+
+
+
+ 暂无保养数据
+
+
+ [{{ group.time }}]
+ 操作人: {{ group.operator }}
+
+
+
+ {{ item.resultLabel }}
+ {{ item.name }}
+
+
+
+ 保养方式
+ {{ detailValue(item.method) }}
+
+
+ 判定标准
+ {{ detailValue(item.criteria) }}
+
+
+ 保养时间
+ {{ detailValue(item.taskTimeLabel) }}
+
+
+ 创建时间
+ {{ detailValue(item.createTimeLabel) }}
+
+
+ 备注
+ {{ detailValue(item.remark) }}
+
+
+
+
+
+
-
- {{ record.typeText }}
+
+
+
+ 暂无维修数据
+
+
+ {{ group.name }}
+ 共{{ group.items.length }}条
+
+
+
+ {{ detailValue(row.subjectCode) }}
+ {{ detailValue(row.subjectName) }}
+
+
+
+ 项目内容
+ {{ detailValue(row.subjectContent) }}
+
+
+ 维修结果
+
+ {{ row.resultLabel }}
+
+
+
+ 备注
+ {{ detailValue(row.remark) }}
+
+
+ 完成日期
+ {{ detailValue(row.finishDateLabel) }}
+
+
+
+
+
+
@@ -83,42 +202,287 @@
diff --git a/src/pages_function/pages/mold/index.vue b/src/pages_function/pages/mold/index.vue
index 55b72fb..63524c6 100644
--- a/src/pages_function/pages/mold/index.vue
+++ b/src/pages_function/pages/mold/index.vue
@@ -120,7 +120,7 @@ function confirmInput() {
function navigateToDetail(code) {
uni.navigateTo({
- url: `/pages_function/pages/mold/detail?code=${encodeURIComponent(code)}`
+ url: `/pages_function/pages/mold/detail?id=${encodeURIComponent(code)}`
});
}
@@ -176,7 +176,6 @@ function navigateToDetail(code) {
.content-section {
padding: 40rpx 30rpx;
- margin-top: -40rpx;
}
.scan-section {
diff --git a/src/plugins/modal.ts b/src/plugins/modal.ts
index 4a97dd3..86ae905 100644
--- a/src/plugins/modal.ts
+++ b/src/plugins/modal.ts
@@ -1,3 +1,5 @@
+let loadingCount = 0
+
export default {
/**
* 消息提示
@@ -86,14 +88,22 @@ export default {
* @param content 遮罩层内容
*/
loading(content: string): void {
+ if (!content) {
+ content = '加载中'
+ }
+ loadingCount += 1
uni.showLoading({
- title: content
+ title: content,
+ mask: true
})
},
/**
* 关闭遮罩层
*/
closeLoading(): void {
- uni.hideLoading()
+ loadingCount = Math.max(loadingCount - 1, 0)
+ if (loadingCount === 0) {
+ uni.hideLoading()
+ }
}
}
diff --git a/src/store/modules/dict.ts b/src/store/modules/dict.ts
index 7a97fdf..d8aefcd 100644
--- a/src/store/modules/dict.ts
+++ b/src/store/modules/dict.ts
@@ -2,11 +2,12 @@ import { defineStore } from "pinia";
const useDictStore = defineStore("dict", {
state: () => ({
dict: new Array(),
+ loadedAll: false,
}),
actions: {
// 获取字典
getDict(_key: string) {
- if (_key == null && _key == "") {
+ if (_key == null || _key == "") {
return null;
}
try {
@@ -22,12 +23,16 @@ const useDictStore = defineStore("dict", {
// 设置字典
setDict(_key: string, value: any) {
if (_key !== null && _key !== "") {
+ this.removeDict(_key);
this.dict.push({
key: _key,
value: value,
});
}
},
+ setLoadedAll(loaded: boolean) {
+ this.loadedAll = loaded;
+ },
// 删除字典
removeDict(_key: string) {
var bln = false;
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index b44c1cd..b7f17bc 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -2,6 +2,7 @@ import { login, logout, getInfo } from "@/api/login";
import { getToken, setToken, removeToken } from "@/utils/auth";
import defAva from "@/static/images/profile.jpg";
import { defineStore } from "pinia";
+import { initAllDict } from "@/utils/dict";
export interface LoginForm {
username: string;
@@ -65,6 +66,7 @@ const useUserStore = defineStore("user", {
this.name = user.nickname;
this.userId = user.id;
this.avatar = avatar;
+ initAllDict().catch(() => {});
resolve(res);
})
.catch((error) => {
diff --git a/src/types/request.ts b/src/types/request.ts
index 3396bbb..01f26ab 100644
--- a/src/types/request.ts
+++ b/src/types/request.ts
@@ -11,6 +11,10 @@ interface BaseRequestConfig {
params?: any,
/** 超时事件 */
timeout?: number | undefined,
+ /** 是否显示全局loading弹框(默认显示) */
+ showLoading?: boolean,
+ /** loading文案 */
+ loadingText?: string,
}
export interface RequestConfig extends BaseRequestConfig {
/** 请求方式 */
diff --git a/src/utils/dict.ts b/src/utils/dict.ts
index bd4284f..7d2a525 100644
--- a/src/utils/dict.ts
+++ b/src/utils/dict.ts
@@ -1,7 +1,72 @@
import useDictStore from "@/store/modules/dict";
-import { getDicts } from "@/api/system/dict/data";
+import { getDicts, getSimpleDictList } from "@/api/system/dict/data";
import { Ref, ref, toRefs } from "vue";
+type DictItem = {
+ label: string;
+ value: string | number;
+ elTagType?: string;
+ elTagClass?: string;
+};
+
+function normalizeDictItem(p: any): DictItem {
+ const label = p?.dictLabel ?? p?.label ?? "";
+ const value = p?.dictValue ?? p?.value ?? "";
+ return {
+ label: String(label),
+ value: typeof value === "number" ? value : String(value),
+ elTagType: p?.colorType ?? p?.listClass ?? p?.elTagType,
+ elTagClass: p?.cssClass ?? p?.elTagClass,
+ };
+}
+
+function groupByDictType(raw: any): Record {
+ const data = raw?.data ?? raw;
+ const groups: Record = {};
+
+ if (Array.isArray(data)) {
+ data.forEach((row) => {
+ const dictType = row?.dictType ?? row?.type ?? row?.dictCode;
+ if (!dictType) return;
+ const key = String(dictType);
+ if (!groups[key]) groups[key] = [];
+ groups[key].push(normalizeDictItem(row));
+ });
+ return groups;
+ }
+
+ if (data && typeof data === "object") {
+ Object.keys(data).forEach((k) => {
+ const list = data[k];
+ if (!Array.isArray(list)) return;
+ groups[k] = list.map((row: any) => normalizeDictItem(row));
+ });
+ }
+ return groups;
+}
+
+export async function initAllDict(force: boolean = false) {
+ const dictStore = useDictStore();
+ if (!force && dictStore.loadedAll) return;
+ const resp = await getSimpleDictList();
+ const groups = groupByDictType(resp);
+ Object.keys(groups).forEach((dictType) => {
+ dictStore.setDict(dictType, groups[dictType]);
+ });
+ dictStore.setLoadedAll(true);
+}
+
+export function getDictLabel(dictType: string, value: any, defaultLabel: string = "-") {
+ const dictStore = useDictStore();
+ const dicts: DictItem[] = (dictStore.getDict(dictType) as any) || [];
+ const v = value === null || value === undefined ? "" : String(value);
+ for (let i = 0; i < dicts.length; i++) {
+ const item = dicts[i];
+ if (String(item.value) === v) return item.label;
+ }
+ return defaultLabel;
+}
+
/**
* 获取字典数据
*/
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 7cbc3a7..bf387fe 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -3,6 +3,7 @@ import { getToken, removeToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common'
import { RequestConfig, ResponseData } from '@/types/request'
+import modal from '@/plugins/modal'
let timeout = 10000
const baseUrl = config.baseUrl
@@ -22,6 +23,10 @@ const request = (config: RequestConfig): Promise> => {
config.url = url
}
return new Promise((resolve, reject) => {
+ const shouldShowLoading = config.showLoading !== false
+ if (shouldShowLoading) {
+ modal.loading(config.loadingText || '加载中')
+ }
uni.request({
method: config.method || 'GET',
timeout: config.timeout || timeout,
@@ -52,12 +57,15 @@ const request = (config: RequestConfig): Promise> => {
reject('无效的会话,或者会话已过期,请重新登录。')
removeToken()
uni.reLaunch({ url: '/pages/login' })
+ return
} else if (code === 500) {
toast(msg)
reject('500')
+ return
} else if (code !== 200) {
toast(msg)
reject(code)
+ return
}
resolve(data)
})
@@ -73,6 +81,11 @@ const request = (config: RequestConfig): Promise> => {
toast(message)
reject(error)
})
+ .finally(() => {
+ if (shouldShowLoading) {
+ modal.closeLoading()
+ }
+ })
})
}
diff --git a/src/utils/upload.ts b/src/utils/upload.ts
index 6dc104e..e0aedb8 100644
--- a/src/utils/upload.ts
+++ b/src/utils/upload.ts
@@ -3,6 +3,7 @@ import { getToken, removeToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common'
import { ResponseData, RequestUploadConfig } from '@/types/request'
+import modal from '@/plugins/modal'
let timeout = 10000
const baseUrl = config.baseUrl
@@ -21,6 +22,10 @@ const upload = (config: RequestUploadConfig): Promise> => {
config.url = url
}
return new Promise((resolve, reject) => {
+ const shouldShowLoading = config.showLoading !== false
+ if (shouldShowLoading) {
+ modal.loading(config.loadingText || '加载中')
+ }
uni.uploadFile({
timeout: config.timeout || timeout,
url: baseUrl + config.url,
@@ -43,12 +48,15 @@ const upload = (config: RequestUploadConfig): Promise> => {
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
+ return
} else if (code === 500) {
toast(msg)
reject('500')
+ return
} else if (code !== 200) {
toast(msg)
reject(code)
+ return
}
},
fail: (error: any) => {
@@ -62,6 +70,11 @@ const upload = (config: RequestUploadConfig): Promise> => {
}
toast(message)
reject(error)
+ },
+ complete: () => {
+ if (shouldShowLoading) {
+ modal.closeLoading()
+ }
}
})
})
diff --git a/tsconfig.json b/tsconfig.json
index 80c4289..a0ce95e 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,5 +1,5 @@
{
- "exclude": ["node_modules"],
+ "exclude": ["node_modules", "src/pages_function/pages/mold/index copy.vue"],
"compilerOptions": {
"noImplicitAny": true,
"importHelpers": true,