From db1fdc5e18c217df67b9d9cacf31cf8fbcab63da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=99=93=E9=B9=8F?= Date: Thu, 27 Mar 2025 23:36:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AC=A1=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- .env.production | 2 +- src/api/list/index.ts | 56 +++++ src/api/login/index.ts | 4 +- src/i18n/pages/materialReceiptNotice/zh-cn.ts | 2 +- src/router/route.ts | 12 +- src/utils/index.ts | 116 ++++++++++ src/views/login/component/account.vue | 47 ++-- src/views/materialReceiptNotice/index.vue | 96 ++++---- src/views/mssPurchaseOrder/index.vue | 124 +++++----- .../mssPurchaseOrder/purchaseDetails.vue | 100 ++++---- src/views/mssPurchaseOrder/selectedData.vue | 219 +++++++++++------- vite.config.ts | 2 +- 13 files changed, 515 insertions(+), 267 deletions(-) create mode 100644 src/api/list/index.ts create mode 100644 src/utils/index.ts diff --git a/.env.development b/.env.development index 83fd5c5..1d21b3d 100644 --- a/.env.development +++ b/.env.development @@ -2,4 +2,4 @@ ENV = development # 本地环境接口地址 -VITE_API_URL = http://localhost:8888/ \ No newline at end of file +VITE_API_URL = http://8.134.66.212:90 \ No newline at end of file diff --git a/.env.production b/.env.production index 478a841..9159d3d 100644 --- a/.env.production +++ b/.env.production @@ -2,4 +2,4 @@ ENV = production # 线上环境接口地址 -VITE_API_URL = https://lyt-top.gitee.io/vue-next-admin-preview/ \ No newline at end of file +VITE_API_URL = http://8.134.66.212:90 \ No newline at end of file diff --git a/src/api/list/index.ts b/src/api/list/index.ts new file mode 100644 index 0000000..f262ec6 --- /dev/null +++ b/src/api/list/index.ts @@ -0,0 +1,56 @@ +import request from '/@/utils/request'; + +export function listApi() { + return { + //采购订单分页列表 + getPageList: (data: object) => { + return request({ + url: '/api/Admin/PurchaseOrder/GetPageList', + method: 'post', + data, + }); + }, + //获取明细列表 + getPurchaseOrderItemList: (data: object) => { + return request({ + url: '/api/Admin/PurchaseOrder/GetPurchaseOrderItemList', + method: 'post', + data, + }); + }, + //批量修改最新交期 + batchSetNewChengNuoJiaoQi: (data: object) => { + return request({ + url: '/api/Admin/PurchaseOrder/BatchSetNewChengNuoJiaoQi', + method: 'post', + data, + }); + }, + //批量修改承诺交期 + batchSetChengNuoJiaoQi: (data: object) => { + return request({ + url: '/api/Admin/PurchaseOrder/BatchSetChengNuoJiaoQi', + method: 'post', + data, + }); + }, + //生成发货通知单 + batchAddInvoiceOrder: (data: object) => { + return request({ + url: '/api/Admin/PurchaseOrder/BatchAddInvoiceOrder', + method: 'post', + data, + }); + }, + + + //发货通知单分页列表 + invoiceOrderGetPageList: (data: object) => { + return request({ + url: '/api/Admin/InvoiceOrder/GetPageList', + method: 'post', + data, + }); + }, + }; +} diff --git a/src/api/login/index.ts b/src/api/login/index.ts index 71ed946..3c3794e 100644 --- a/src/api/login/index.ts +++ b/src/api/login/index.ts @@ -9,9 +9,9 @@ import request from '/@/utils/request'; */ export function useLoginApi() { return { - signIn: (data: object) => { + login: (data: object) => { return request({ - url: '/user/signIn', + url: '/api/Admin/Login/Login', method: 'post', data, }); diff --git a/src/i18n/pages/materialReceiptNotice/zh-cn.ts b/src/i18n/pages/materialReceiptNotice/zh-cn.ts index e95e80b..c0de2ab 100644 --- a/src/i18n/pages/materialReceiptNotice/zh-cn.ts +++ b/src/i18n/pages/materialReceiptNotice/zh-cn.ts @@ -38,7 +38,7 @@ export default { BusinessType: "单据类型", OrderCreator: "制单人", DocStatus2: "单据状态", - ReceivingDate: "收料日期", + ReceivingDate: "发货日期", Comments3: "备注", MaterialCode2: "物料编码", MaterialName2: "物料名称", diff --git a/src/router/route.ts b/src/router/route.ts index 910458b..4e98d6b 100644 --- a/src/router/route.ts +++ b/src/router/route.ts @@ -119,7 +119,7 @@ export const dynamicRoutes: Array = [ isKeepAlive: true, isAffix: false, isIframe: false, - roles: ['admin'], + roles: ['admin', 'common'], icon: 'iconfont icon-xitongshezhi', }, children: [ @@ -134,7 +134,7 @@ export const dynamicRoutes: Array = [ isKeepAlive: true, isAffix: false, isIframe: false, - roles: ['admin'], + roles: ['admin', 'common'], icon: 'iconfont icon-caidan', }, }, @@ -149,7 +149,7 @@ export const dynamicRoutes: Array = [ isKeepAlive: true, isAffix: false, isIframe: false, - roles: ['admin'], + roles: ['admin', 'common'], icon: 'ele-ColdDrink', }, }, @@ -164,7 +164,7 @@ export const dynamicRoutes: Array = [ isKeepAlive: true, isAffix: false, isIframe: false, - roles: ['admin'], + roles: ['admin', 'common'], icon: 'iconfont icon-icon-', }, }, @@ -179,7 +179,7 @@ export const dynamicRoutes: Array = [ isKeepAlive: true, isAffix: false, isIframe: false, - roles: ['admin'], + roles: ['admin', 'common'], icon: 'ele-OfficeBuilding', }, }, @@ -194,7 +194,7 @@ export const dynamicRoutes: Array = [ isKeepAlive: true, isAffix: false, isIframe: false, - roles: ['admin'], + roles: ['admin', 'common'], icon: 'ele-SetUp', }, }, diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..68f3131 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,116 @@ +import dayjs from 'dayjs'; +import md5 from 'md5'; +import { customRef, ref } from "vue" + +/** + * 格式化时间 + */ +export function formatTime( + date?: string | number | Date | dayjs.Dayjs | null | undefined, + template?: string | undefined +) { + return dayjs(date).format(template); +} + +/** + * + * 格式化时间 + */ +export function timeAgo( + date?: string | number | Date | dayjs.Dayjs | null | undefined, + template?: string +) { + const d = dayjs(date).valueOf(); + const now = Date.now(); + const diff = (now - d) / 1000; + if (diff < 3600) { + return Math.ceil(diff / 60) + '分钟前'; + } else if (diff < 3600 * 24) { + return Math.ceil(diff / 3600) + '小时前'; + } else { + return formatTime(date, template); + } +} + +/** + * md5加密 + */ +export function md5Encryption( + message: string | Buffer | number[] | Uint8Array +) { + const KEY = md5('LULU Derivation'); + return md5(KEY + md5(message)); +} + +/** + * 类型检查 + */ + +export function typeCheck(param: any) { + return Object.prototype.toString.call(param); +} + +/** + * 批量修改stage + */ +export function mutateState(state: AnyObject, payload: AnyObject) { + if ( + typeCheck(state) === '[object Object]' && + typeCheck(payload) === '[object Object]' + ) { + for (const key in payload) { + state[key] = payload[key]; + } + } else { + console.error('expected plain Object'); + } +} + +/** + * 防抖 + */ +export function debounceRef (data:any, delay = 300){ + let timer: NodeJS.Timeout | null = null; + return delay == null + ? + ref(data) + : + customRef((track, trigger) => { + return { + get () { + track() + return data + }, + set (value) { + if(timer != null){ + clearTimeout(timer) + timer = null + } + timer = setTimeout(() => { + data = value; + trigger() + }, delay) + } + } + }) +} + +//计算两个时间之间的时间差 多少天时分秒 +export function timeFn(d1: string,d2: string) {//di作为一个变量传进来 + //如果时间格式是正确的,那下面这一步转化时间格式就可以不用了 + var dateBegin = new Date(d1.replace(/-/g, "/"));//将-转化为/,使用new Date + var dateEnd = new Date(d2.replace(/-/g, "/"));//获取当前时间 + var dateDiff = dateEnd.getTime() - dateBegin.getTime();//时间差的毫秒数 + var dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000));//计算出相差天数 + var leave1=dateDiff%(24*3600*1000) //计算天数后剩余的毫秒数 + var hours=Math.floor(leave1/(3600*1000))//计算出小时数 + //计算相差分钟数 + var leave2=leave1%(3600*1000) //计算小时数后剩余的毫秒数 + var minutes=Math.floor(leave2/(60*1000))//计算相差分钟数 + //计算相差秒数 + var leave3=leave2%(60*1000) //计算分钟数后剩余的毫秒数 + var seconds=Math.round(leave3/1000) + console.log(" 相差 "+dayDiff+"天 "+hours+"小时 "+minutes+" 分钟"+seconds+" 秒") + console.log(dateDiff+"时间差的毫秒数",dayDiff+"计算出相差天数",leave1+"计算天数后剩余的毫秒数" + ,hours+"计算出小时数",minutes+"计算相差分钟数",seconds+"计算相差秒数"); +} diff --git a/src/views/login/component/account.vue b/src/views/login/component/account.vue index 31db9fe..c272cf0 100644 --- a/src/views/login/component/account.vue +++ b/src/views/login/component/account.vue @@ -48,7 +48,7 @@ import { initBackEndControlRoutes } from '/@/router/backEnd'; import { Session } from '/@/utils/storage'; import { formatAxis } from '/@/utils/formatTime'; import { NextLoading } from '/@/utils/loading'; - +import { useLoginApi } from '../../../api/login/index' // 定义变量内容 const { t } = useI18n(); const storesThemeConfig = useThemeConfig(); @@ -58,8 +58,8 @@ const router = useRouter(); const state = reactive({ isShowPassword: false, ruleForm: { - userName: 'admin', - password: '123456', + userName: 'abc', + password: '123', code: '1234', }, loading: { @@ -72,23 +72,32 @@ const currentTime = computed(() => { return formatAxis(new Date()); }); // 登录 -const onSignIn = async () => { +const onSignIn = () => { state.loading.signIn = true; - // 存储 token 到浏览器缓存 - Session.set('token', Math.random().toString(36).substr(0)); - // 模拟数据,对接接口时,记得删除多余代码及对应依赖的引入。用于 `/src/stores/userInfo.ts` 中不同用户登录判断(模拟数据) - Cookies.set('userName', state.ruleForm.userName); - if (!themeConfig.value.isRequestRoutes) { - // 前端控制路由,2、请注意执行顺序 - const isNoPower = await initFrontEndControlRoutes(); - signInSuccess(isNoPower); - } else { - // 模拟后端控制路由,isRequestRoutes 为 true,则开启后端控制路由 - // 添加完动态路由,再进行 router 跳转,否则可能报错 No match found for location with path "/" - const isNoPower = await initBackEndControlRoutes(); - // 执行完 initBackEndControlRoutes,再执行 signInSuccess - signInSuccess(isNoPower); - } + useLoginApi().login({ + userName: state.ruleForm.userName, + passWord: state.ruleForm.password, + }).then( async (res:any) => { + console.log(res) + if(res.data !== null){ + // 存储 token 到浏览器缓存 + Session.set('token', res.data); + // 模拟数据,对接接口时,记得删除多余代码及对应依赖的引入。用于 `/src/stores/userInfo.ts` 中不同用户登录判断(模拟数据) + Cookies.set('userName', state.ruleForm.userName); + if (!themeConfig.value.isRequestRoutes) { + // 前端控制路由,2、请注意执行顺序 + const isNoPower = await initFrontEndControlRoutes(); + signInSuccess(isNoPower); + } else { + // 模拟后端控制路由,isRequestRoutes 为 true,则开启后端控制路由 + // 添加完动态路由,再进行 router 跳转,否则可能报错 No match found for location with path "/" + const isNoPower = await initBackEndControlRoutes(); + // 执行完 initBackEndControlRoutes,再执行 signInSuccess + signInSuccess(isNoPower); + } + } + }) + }; // 登录成功后的跳转 const signInSuccess = (isNoPower: boolean | undefined) => { diff --git a/src/views/materialReceiptNotice/index.vue b/src/views/materialReceiptNotice/index.vue index 26de11b..3d1fba2 100644 --- a/src/views/materialReceiptNotice/index.vue +++ b/src/views/materialReceiptNotice/index.vue @@ -1,10 +1,19 @@