首页 > 其他分享 >当前时间加日期处理

当前时间加日期处理

时间:2023-02-09 17:34:56浏览次数:35  
标签:00 peopelListForm 处理 08 replace 日期 let 当前 timearr

 


 

 

 


<template> <div class="task-box"> <p class="title-p">人行记录</p> <div class="box"> <tableList @onGetSelection="getSelection" :columns="columns" :data="dataList" :total="total"> <!-- form表单查询内容 --> <div slot="search" style="display: flex"> <Form ref="peopelListForm" :model="peopelListForm" :label-width="100" inline :label-colon="true"> <Row> <Col span="24"> <FormItem label="姓名"> <Input style="width: 180px" type="text" v-model="peopelListForm.personName" placeholder="请输入关键词搜索" clearable /> </FormItem> <FormItem label="门禁点"> <Input style="width: 180px" type="text" v-model="peopelListForm.doorName" placeholder="请输入关键词搜索" clearable /> </FormItem> <FormItem label="门禁点区域"> <Input style="width: 180px" type="text" v-model="peopelListForm.doorRegionIndexCode" placeholder="请输入关键词搜索" clearable /> </FormItem> </Col> </Row> <FormItem label="事件时间"> <Date-picker type="datetimerange" placeholder="选择日期" style="width: 320px" @on-change="getTime" :value="timearr" :clearable="false"></Date-picker> </FormItem> </Form> <div slot="operator" class="operator"> <Button type="primary" @click="handleSubmit('peopelListForm')" style="margin-left: 30px">查询 </Button> <Button @click="handleReset('peopelListForm')" style="margin-left: 8px">重置 </Button> </div> </div> <!-- 操作列 --> <div slot-scope="{ row }" slot="createTime"> <div>{{ row.createTime | chengearmTime }}</div> </div> <div slot-scope="{ row }" slot="inAndOutType"> <div>{{ inAndOutTypeABC[row.inAndOutType] }}</div> </div> <div slot-scope="{ row }" slot="eventTime"> <div>{{ row.eventTime ? eventTime(row.eventTime) : "/" }}</div> </div> <div slot="paging"> <paging :total="total" :current="peopelListForm.pageNo" @changePage="changePage" @changePageSize="changePageSize"></paging> </div> </tableList> </div> </div> </template> <script> import { accessrecord } from "@/api/people.js"; import { formatDate } from "@/libs"; import { setColumns } from "../../libs/table-list"; // 处理表格中colmns数据的js方法 import paging from "../components/paging"; import tableList from "../components/table-list"; // 表格组件 // 弹窗 export default { components: { tableList, paging }, data() { return { total: 0, peopelListForm: { personName: "", doorName: "", doorRegionIndexCode: "", startTime: "", endTime: "", receiveStartTime: "", receiveEndTime: "", }, dataList: [], columns: [], checkedId: [], //多选的id timearr: [ // "2022-12-01 00:00:00","2022-12-01 10:00:00" ], inAndOutTypeABC: { 1: "进", 0: "出", "-1": "未知", }, }; }, watch: {}, filters: { chengearmTime(armTime) { return formatDate(Number(armTime), "yyyy-MM-dd hh:mm:ss"); }, }, mounted() { this.columns = setColumns([true, true, false], "peoplelist", 200); }, created() { let time = new Date(); let nowTime = this.timestampToTime( time.toLocaleString("en-US", { hour12: false }).split(" ") ); this.timearr = [nowTime[0] + " " + "00:00:00", nowTime[1]]; this._list(); }, methods: { timestampToTime(times) { let time = times[1]; let mdy = times[0]; mdy = mdy.split("/"); let month = parseInt(mdy[0]); let day = parseInt(mdy[1]); let year = parseInt(mdy[2]); let time1 = year + "-" + month + "-" + day + " " + time; let time2 = year + "-" + month + "-" + day; return [time2, time1]; }, eventTime(v) { let d = v.replace(/T/, " "); let dd = d.substring(0, d.indexOf("+")); return dd; }, getTime(e) { if (e) { this.timearr = e; this.peopelListForm.startTime = e[0].replace(/[\s]/g, "T") + "+08:00"; this.peopelListForm.endTime = e[1].replace(/[\s]/g, "T") + "+08:00"; this.peopelListForm.receiveStartTime = e[0].replace(/[\s]/g, "T") + "+08:00"; this.peopelListForm.receiveEndTime = e[1].replace(/[\s]/g, "T") + "+08:00"; } else { this.peopelListForm.startTime = this.timearr[0].replace(/[\s]/g, "T") + "+08:00"; this.peopelListForm.endTime = this.timearr[1].replace(/[\s]/g, "T") + "+08:00"; this.peopelListForm.receiveStartTime = this.timearr[0].replace(/[\s]/g, "T") + "+08:00"; this.peopelListForm.receiveEndTime = this.timearr[1].replace(/[\s]/g, "T") + "+08:00"; } //2004-05-03T17:30:08+08:00或20040503T173008+0对应时间为2004年5月3日下午5点30分8秒 }, //撤单 pdRow(row, type, typename) { this.$Modal.confirm({ title: "提示", content: `您确定要${typename}吗?`, onOk: () => { // // console.log("row, type, typename", row, type, typename); }, onCancel: () => { // this.$Message.info("已取消"); }, }); }, //列表 _list() { this.peopelListForm.startTime = this.timearr[0].replace(/[\s]/g, "T") + "+08:00"; this.peopelListForm.endTime = this.timearr[1].replace(/[\s]/g, "T") + "+08:00"; this.peopelListForm.receiveStartTime = this.timearr[0].replace(/[\s]/g, "T") + "+08:00"; this.peopelListForm.receiveEndTime = this.timearr[1].replace(/[\s]/g, "T") + "+08:00"; accessrecord(this.peopelListForm).then((res) => { let d = res.data; if (d.code == "00000") { this.dataList = d.data.list || []; this.total = d.data.total; } else { this.$Message.error(res.data.desc); this.dataList = [] this.total = 0 } }); }, // 分页处理 changePage(value) { this.peopelListForm.pageNo = value; this._list(); }, changePageSize(value) { this.peopelListForm.pageSize = value; this._list(); }, // 表单的提交和重置 handleSubmit() { this.$Message["success"]({ background: true, content: "查询成功", }); this._list(); }, handleReset(name) { this.$Message["success"]({ background: true, content: "重置成功", }); Object.keys(this.peopelListForm).forEach((key) => { this.peopelListForm[key] = ""; }); // this.timearr = ["2022-12-01 00:00:00", "2022-12-01 10:00:00"]; let time = new Date(); let nowTime = this.timestampToTime( time.toLocaleString("en-US", { hour12: false }).split(" ") ); this.timearr = [nowTime[0] + " " + "00:00:00", nowTime[1]]; this.peopelListForm.pageNo = 1; this.peopelListForm.pageSize = 10; this._list(); }, //多选 getSelection(value) { // 获取从子组件中传过来的值 this.checkedId = value.map((item) => { return item.id; }); }, //批量 handleEnableBatch() { if (this.checkedId.length <= 0) { this.$Message.error("请先选择"); return false; } this.$Modal.confirm({ title: "提示", content: "确定启用选中的账号?", onOk: () => { console.log("checkedId", this.checkedId); // let data = { // ids: this.ids.join(","), // }; // enableBatch(data).then((res) => { // if (res.data.success == true) { // this.$Message.success(res.data.msg); // this.ids = []; // this.getData(); // } // }); }, onCancel: () => { this.$Message.info("已取消"); }, }); }, }, destroyed() { }, }; </script> <style lang="less" scoped> .task-box { .box { position: relative; } } //树形选中 .active { color: #66b1ff; } </style>

 

标签:00,peopelListForm,处理,08,replace,日期,let,当前,timearr
From: https://www.cnblogs.com/Byme/p/17106386.html

相关文章

  • element ui el-date-picker 禁止选择指定日期
    1、日期选择器组件代码<el-col:span="20"><el-form-itemlabel="活动起始日期值"prop="startTime"><el-date-pickerv-model="startTime"type="date"place......
  • 04 处理器 | 计算机组成原理
    1.概述数据通路:指令执行过程中,数据所经过的路径(包括路径中的部件)控制器:对指令进行译码,生成指令对应的控制信号,控制数据通路的动作,能对指令的执行部件发出控制信号取......
  • WAV音频文件处理
    使用工具WinHex:Hex文件查看Goldwave:wav音频格式处理CoolEdit:音频格式处理Goldwave软件中怎么调采样率、比特率语音识别之wave文件(*.wav)格式、PCM数据格式介绍......
  • 第7章:异常处理
    第7章:异常处理1、异常概述与异常体系结构1.1异常引出:在使用计算机语言进行项目开发的过程中,即使程序员把代码写得尽善尽美,在系统的运行过程中仍然会遇到一些问题,因为很......
  • OpenSSH 9.2P1升级以及版本显示的处理过程
    说明本次维护的时间是2023-2-9最新已发布的补丁是OpenSSH9.2P1版本其他本本应该是类似处理.下载介质在OpenSSH官网打开相关界面.http://www.openssh.com/......
  • MySQL设置当前默认时间
    ​​CURRENT_TIMESTAMP​​......
  • PHP里的日期加减方法
    //第一步,假设有一个时间$a='2012-04-2510:10:00';//第二步,获得这个日期的时间戳$a_time=strtotime($a);//第三步,获得加五个月后的时间戳$b_time=strtotime('+5......
  • Java selenium处理shadow
    ShadowRoot是ShadowDOM下面的根,跟其他元素是隔离的,即使我们选择copyselector/xpath依然是定位不到的,如下图要定位此类元素需要先定位到它的根shadowRoot,然后再定位......
  • Django框架之drf:8、断点调试,权限、认证、频率组件源码分析,基于APIView编写分页,全局异
    目录Django框架之drf一、断点调式使用1、断点调试二、权限组件源码分析三、认证组件源码分析四、频率组件源码分析1、自定义频率类2、SimpleRateThrottle五、基于APIView编......
  • moment日期 常用方法
    日期拼接 00:00:00或者 23:59:59moment(this.beginTime).hours(0).minute(0).seconds(0).format('YYYY-MM-DDHH:mm:ss')moment(this.endTime).hours(23).minute(59......