Browse Source

feat: 修改指令编码

wanggaokun 10 months ago
parent
commit
001ec64092
2 changed files with 22 additions and 2 deletions
  1. 19 0
      src/utils/common.ts
  2. 3 2
      src/views/manage/orderConfig/index.vue

+ 19 - 0
src/utils/common.ts

@@ -153,3 +153,22 @@ export function mIsNumber(val) {
   if (String(val).trim().length === 0) return false
   return true
 }
+
+export const generateOrderNumber = (prefix: string): string => {
+  // 获取当前日期
+  const now = new Date()
+
+  // 格式化日期为 yyyyMMddHHmmss
+  const year = now.getFullYear().toString().padStart(4, '0')
+  const month = (now.getMonth() + 1).toString().padStart(2, '0') // 注意月份是从0开始的
+  const day = now.getDate().toString().padStart(2, '0')
+  const hours = now.getHours().toString().padStart(2, '0')
+  const minutes = now.getMinutes().toString().padStart(2, '0')
+  const seconds = now.getSeconds().toString().padStart(2, '0')
+
+  // 拼接成 yyyyMMddHHmmss
+  const dateString = `${year}${month}${day}${hours}${minutes}${seconds}`
+
+  // 返回格式化的单号
+  return `${prefix}-${dateString}`
+}

+ 3 - 2
src/views/manage/orderConfig/index.vue

@@ -58,7 +58,7 @@ import {
 } from '@/api/modules/manage/orderConfig'
 import { getDictsApi } from '@/api/modules/system/dictData'
 import { listSortieAllApi } from '@/api/modules/manage/sortie'
-
+import { generateOrderNumber } from '@/utils/common'
 // ProTable 实例
 const proTable = ref<ProTableInstance>()
 
@@ -138,7 +138,7 @@ const openDialog = async (type: number, title: string, row?: any) => {
     top: '20vh',
     isEdit: type !== 3,
     fieldList: fieldList,
-    model: type == 1 ? {} : res.data,
+    model: type == 1 ? undefined : res.data,
     api: type == 1 ? addOrderConfigApi : updateOrderConfigApi,
     getTableList: proTable.value?.getTableList
   }
@@ -208,6 +208,7 @@ const setFieldList = () => {
       label: '指令编码',
       field: 'orderCode',
       rules: [{ required: true, message: '指令编码不能为空', trigger: 'blur' }],
+      value: generateOrderNumber('INST'),
       placeholder: '请输入指令编码'
     },
     {