时间控件

This commit is contained in:
sjl
2024-11-07 10:24:33 +08:00
parent dc7e9d40e7
commit 9de2c874f0
4 changed files with 29 additions and 25 deletions

View File

@@ -28,9 +28,10 @@ export namespace Device {
createId: string; //出厂编号 createId: string; //出厂编号
hardwareVersion: string; //固件版本 hardwareVersion: string; //固件版本
softwareVersion: string; //软件版本 softwareVersion: string; //软件版本
protocol:string; //通讯协议
ip: string; //IP地址 ip: string; //IP地址
port: number; //端口号 port: number; //端口号
encryption: string; //装置是否为加密版本 encryption: number; //装置是否为加密版本
series?: string| null; //装置识别码3ds加密 series?: string| null; //装置识别码3ds加密
devKey?: string| null; //装置秘钥3ds加密 devKey?: string| null; //装置秘钥3ds加密
sampleID?: string| null; //样品编号 sampleID?: string| null; //样品编号

View File

@@ -85,16 +85,16 @@ const props = defineProps({
}, },
default: { default: {
type: String, type: String,
default: '', default: '',
}, },
}) })
// 定义事件 // 定义事件
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'update-dates', startDate: Date, endDate: Date): void; (e: 'update-dates', startDate: string, endDate: string): void;
}>() }>()
const timeUnit = ref<string>(props.default) // 默认选择 const timeUnit = ref<string>(props.default) // 默认选择
const startDate = ref<Date>(new Date()) // 起始日期 const startDate = ref<Date>(new Date(0)) // 起始日期
const endDate = ref<Date>(new Date()) // 结束日期 const endDate = ref<Date>(new Date()) // 结束日期
const isNextDisabled = ref<boolean>(false) // 控制下一周期按钮的禁用状态 const isNextDisabled = ref<boolean>(false) // 控制下一周期按钮的禁用状态
const today = ref<Date>(new Date()) // 当前日期 const today = ref<Date>(new Date()) // 当前日期
@@ -109,7 +109,7 @@ const timeUnits = ref<TimeUnit[]>(
// 发出日期变化事件 // 发出日期变化事件
const emitDateChange = () => { const emitDateChange = () => {
emit('update-dates', formatDate(startDate.value), formatDate(endDate.value)) emit('update-dates', formatDate(startDate.value), formatDate(endDate.value))
//console.log('emitDateChange', startDate.value, endDate.value); console.log('emitDateChange', startDate.value, endDate.value)
} }
// 在组件挂载时更新日期范围 // 在组件挂载时更新日期范围

View File

@@ -54,7 +54,11 @@
<el-row :gutter="24" > <el-row :gutter="24" >
<el-col :span="8"> <el-col :span="8">
<el-form-item label="生产日期" prop="createDate"> <el-form-item label="生产日期" prop="createDate">
<el-input v-model='formContent.createDate' placeholder="请输入生产日期"/> <el-date-picker
v-model="formContent.createDate"
type="datetime"
placeholder="请选择生产日期"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
@@ -75,22 +79,21 @@
</el-row> </el-row>
<el-row :gutter="24" > <el-row :gutter="24" >
<el-col :span="8"> <el-col :span="8">
<el-form-item label='通讯协议' prop='devType'> <el-form-item label='通讯协议' prop='protocol'>
<el-select v-model="formContent.devType" clearable placeholder="请选择通讯协议"> <el-select v-model="formContent.protocol" clearable placeholder="请选择通讯协议">
<el-option <el-option
v-for="item in dictStore.getDictData('High_Cate')" v-for="item in dictStore.getDictData('Event_Type')"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.code" :value="item.code"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="IP地址" prop="ip"> <el-form-item label="IP地址" prop="ip">
<!-- <el-input v-model='formContent.ip'/> --> <!-- <el-input v-model='formContent.ip'/> -->
<abc v-model:value="formContent.ip"/> <abc v-model:value="formContent.ip"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
@@ -101,13 +104,9 @@
<el-col :span="8"> <el-col :span="8">
<el-form-item label='是否加密' prop='encryption'> <el-form-item label='是否加密' prop='encryption'>
<el-select v-model="formContent.encryption" clearable placeholder="请选择是否加密"> <el-select v-model="formContent.encryption" clearable placeholder="请选择是否加密">
<el-option <el-option label="是" :value="1"></el-option>
v-for="item in dictStore.getDictData('High_Cate')" <el-option label="否" :value="0"></el-option>
:key="item.id" </el-select>
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@@ -154,7 +153,8 @@
import { computed, type Ref, ref } from 'vue'; import { computed, type Ref, ref } from 'vue';
import { useDictStore } from '@/stores/modules/dict' import { useDictStore } from '@/stores/modules/dict'
import { CirclePlus, Delete } from '@element-plus/icons-vue' import { CirclePlus, Delete } from '@element-plus/icons-vue'
import { el } from 'element-plus/es/locale'; // 使用 dayjs 库格式化
import dayjs from 'dayjs';
const dictStore = useDictStore() const dictStore = useDictStore()
// 定义弹出组件元信息 // 定义弹出组件元信息
const dialogFormRef = ref() const dialogFormRef = ref()
@@ -175,9 +175,10 @@
createId: '', createId: '',
hardwareVersion: '', hardwareVersion: '',
softwareVersion: '', softwareVersion: '',
protocol: '',
ip: '', ip: '',
port: 0, port: 0,
encryption: '', encryption: 1,
reCheckNum:0, reCheckNum:0,
state: 1, state: 1,
}) })
@@ -200,9 +201,10 @@
createId: '', createId: '',
hardwareVersion: '', hardwareVersion: '',
softwareVersion: '', softwareVersion: '',
protocol: '',
ip: '', ip: '',
port: 0, port: 0,
encryption: '', encryption: 1,
reCheckNum:0, reCheckNum:0,
state: 1, state: 1,
} }
@@ -244,6 +246,7 @@
try { try {
dialogFormRef.value?.validate(async (valid: boolean) => { dialogFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
formContent.value.createDate = dayjs(formContent.value.createDate).format('YYYY-MM-DD HH:mm:ss');
if (formContent.value.id) { if (formContent.value.id) {
updatePqDev(formContent.value).then(result => { updatePqDev(formContent.value).then(result => {
if(result.code != 'A0000'){ if(result.code != 'A0000'){
@@ -276,7 +279,7 @@
titleType.value = sign titleType.value = sign
dialogVisible.value = true dialogVisible.value = true
if (data.id) { if (data.id) {
data.createDate = data.createDate.replace('T', ' ')
formContent.value = { ...data } formContent.value = { ...data }
} else { } else {
resetFormContent() resetFormContent()

View File

@@ -51,8 +51,8 @@ const devicePopup = ref()
const getTableList = (params: any) => { const getTableList = (params: any) => {
let newParams = JSON.parse(JSON.stringify(params)) let newParams = JSON.parse(JSON.stringify(params))
newParams.createTimeEnd = endDate.value newParams.searchEndTime = endDate.value
newParams.createTimeStart = startDate.value newParams.searchBeginTime = startDate.value
return getPqDevList(newParams) return getPqDevList(newParams)
} }
@@ -105,7 +105,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
<div class='flx-flex-start'> <div class='flx-flex-start'>
<TimeControl <TimeControl
include={['日', '周', '月', '自定义']} include={['日', '周', '月', '自定义']}
default={''} default={'自定义'}
onUpdate-dates={handleDateChange} onUpdate-dates={handleDateChange}
/> />
</div> </div>