From 3e22e5bd93d4ee3967d9db9149fe0a947baa4186 Mon Sep 17 00:00:00 2001 From: cuiyouliang Date: Thu, 5 Jun 2025 15:55:52 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=BF=81=E7=A7=BB=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E6=8C=82=E5=9C=A8=E7=9A=84=E6=96=B9=E6=B3=95?= =?UTF-8?q?=202=E3=80=81=E5=AE=89=E8=A3=85moment.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/main.ts | 1 + src/plugins/index.ts | 18 ++++++++- src/utils/ruoyi.ts | 64 +++++++++++++++++++++++++++++++ src/views/oms/aftersale/index.vue | 2 +- 5 files changed, 84 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4697b3a..7017e00 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "image-conversion": "2.1.1", "js-cookie": "3.0.5", "jsencrypt": "3.3.2", + "moment": "^2.24.0", "nprogress": "0.2.0", "pinia": "3.0.2", "screenfull": "6.0.2", diff --git a/src/main.ts b/src/main.ts index c8730a2..2cba8da 100644 --- a/src/main.ts +++ b/src/main.ts @@ -46,6 +46,7 @@ ElDialog.props.closeOnClickModal.default = false; const app = createApp(App); +/*app.component('MyComponent', MyComponent)*/ app.use(HighLight); app.use(ElementIcons); app.use(router); diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 6c5e0c3..9016eb2 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -9,7 +9,18 @@ import animate from '@/animate'; import { download as dl } from '@/utils/request'; import { useDict } from '@/utils/dict'; import { getConfigKey, updateConfigByKey } from '@/api/system/config'; -import { parseTime, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'; +import { + parseTime, + addDateRange, + handleTree, + selectDictLabel, + selectDictLabels, + addDateRange2, + addDateRange3, + resetForm, + getHiddenName, + getHiddenDetailAddress +} from '@/utils/ruoyi'; import { App } from 'vue'; @@ -40,4 +51,9 @@ export default function installPlugin(app: App) { app.config.globalProperties.selectDictLabel = selectDictLabel; app.config.globalProperties.selectDictLabels = selectDictLabels; app.config.globalProperties.animate = animate; + app.config.globalProperties.addDateRange3 = addDateRange3; + app.config.globalProperties.resetForm = resetForm; + app.config.globalProperties.addDateRange2 = addDateRange2; + app.config.globalProperties.getHiddenName = getHiddenName; + app.config.globalProperties.getHiddenDetailAddress = getHiddenDetailAddress; } diff --git a/src/utils/ruoyi.ts b/src/utils/ruoyi.ts index 8cb9f97..5646b9d 100644 --- a/src/utils/ruoyi.ts +++ b/src/utils/ruoyi.ts @@ -1,3 +1,4 @@ +import moment from 'moment'; // 日期格式化 export function parseTime(time: any, pattern?: string) { if (arguments.length === 0 || !time) { @@ -63,6 +64,39 @@ export const addDateRange = (params: any, dateRange: any[], propName?: string) = return search; }; +export function addDateRange2(params, dateRange, addDay = true) { + const search = params; + dateRange = Array.isArray(dateRange) ? dateRange : []; + if (addDay) { + search['beginTime'] = dateRange[0]; + search['endTime'] = moment(dateRange[1]).add(1, 'days').format('yyyy-MM-DD'); + } else { + search['beginTime'] = dateRange[0]; + search['endTime'] = dateRange[1]; + } + return search; +} + +export function addDateRange3(params, dateRange, addDay = true) { + const search = params; + dateRange = Array.isArray(dateRange) ? dateRange : []; + if (addDay) { + search['beginTime'] = dateRange[0] + ' 00:00:00'; + search['endTime'] = moment(dateRange[1]).add(1, 'days').format('yyyy-MM-DD') + ' 00:00:00'; + } else { + search['beginTime'] = dateRange[0] + ' 00:00:00'; + search['endTime'] = dateRange[1] + ' 00:00:00'; + } + return search; +} + +// 表单重置 +export function resetForm(refName) { + if (this.$refs[refName]) { + this.$refs[refName].resetFields(); + } +} + // 回显数据字典 export const selectDictLabel = (datas: any, value: number | string) => { if (value === undefined) { @@ -231,6 +265,36 @@ export const blobValidate = (data: any) => { return data.type !== 'application/json'; }; +/** + * 姓名隐藏,只展示第一位,其余替换为 * + */ +export function getHiddenName(data) { + if (!data) return ''; + const surname = data.substr(0, 1); + const star = '*'.repeat(data.length - 1); + return surname + star; +} + +/** + * 详细地址隐藏数字包含中文数字,替换为 * + */ +export function getHiddenDetailAddress(data) { + const chineseNumbers = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十']; + if (!data || data.length === 0) { + return ''; + } + const tempResult = data.replace(/\d/g, '*'); + let result = ''; + for (let i = 0; i < tempResult.length; i++) { + if (chineseNumbers.includes(tempResult[i])) { + result += '*'; + } else { + result += tempResult[i]; + } + } + return result; +} + export default { handleTree }; diff --git a/src/views/oms/aftersale/index.vue b/src/views/oms/aftersale/index.vue index 0954ddc..e27c79f 100644 --- a/src/views/oms/aftersale/index.vue +++ b/src/views/oms/aftersale/index.vue @@ -391,7 +391,7 @@ export default { this.open = true; }, confirmReceive(orderId, type) { - this.$confirm(`您确认收到售后单号为【${order.id}】的货物了吗?`, '温馨提示', { type: 'warning' }).then(() => { + this.$confirm(`您确认收到售后单号为【${orderId}】的货物了吗?`, '温馨提示', { type: 'warning' }).then(() => { this.updateOrderForm.orderId = orderId; this.updateOrderForm.optType = type; dealWithAftersale(this.updateOrderForm).then((response) => {