forked from integrated_whb/integrated_whb_vue
年检管理
parent
33626cab78
commit
c0944ad180
|
@ -360,3 +360,60 @@ export function idCardGetDateAndGender(idCard) {
|
|||
}
|
||||
return { sex, date };
|
||||
}
|
||||
|
||||
/**
|
||||
* 截止时间为 用户选择的月数(或者是年数)累加起始时间
|
||||
* 要解决的问题 :
|
||||
* 1.如在2020年2月29号签约,签约时间为1年,那么截止时间就只能返回2021年2月28号;
|
||||
* 2.如在2020年1月31号签约,签约时间为1个月,那么截止时间就只能返回2020年2月29号;
|
||||
* @param {*} date 要累加的时间
|
||||
* @param {*} num 累加多少个月 1年就是12个月
|
||||
*/
|
||||
export function timeTransformation(date,num) {
|
||||
date = new Date(date)
|
||||
let day = date.getDate();
|
||||
let month = date.getMonth();
|
||||
let year = date.getFullYear();
|
||||
year = year + parseInt((month + num) / 12);
|
||||
month = (month + num) % 12;
|
||||
// 0-11 转变为 1-12
|
||||
month += 1;
|
||||
|
||||
const maxDayCount = new Date(year,month,0).getDate();
|
||||
if(day > maxDayCount)day = maxDayCount
|
||||
if(month < 10 )(month = '0' + month)
|
||||
if(day < 10)(day = '0' + day)
|
||||
return year + '-' + month + '-' + day
|
||||
}
|
||||
|
||||
/**
|
||||
* 提醒日期计算
|
||||
* @param {*} date 到期日期
|
||||
* @param {*} daysToSubtract 提醒天数
|
||||
*/
|
||||
export function subtractDaysFromDate(date, daysToSubtract) {
|
||||
let newDate = new Date(); // 创建当前时间对象
|
||||
if (typeof date === 'string') {
|
||||
// 将字符串类型的日期转换成 Date 对象
|
||||
newDate.setTime(new Date(date).getTime());
|
||||
} else if (Object.prototype.toString.call(date) === "[object Date]") {
|
||||
// 直接传入了 Date 对象
|
||||
newDate = date;
|
||||
} else {
|
||||
console.log("无效的输入参数")
|
||||
}
|
||||
newDate.setDate(newDate.getDate() - daysToSubtract); // 在原有基础上减去指定天数
|
||||
const formatDateToString = (dateObj) => {
|
||||
const year = dateObj.getFullYear().toString();
|
||||
let month = (dateObj.getMonth() + 1).toString();
|
||||
let day = dateObj.getDate().toString();
|
||||
if (month.length < 2) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if (day.length < 2) {
|
||||
day = "0" + day;
|
||||
}
|
||||
return [year, month, day].join("-");
|
||||
}
|
||||
return formatDateToString(newDate); // 返回新日期的字符串表示形式
|
||||
}
|
||||
|
|
|
@ -114,12 +114,13 @@
|
|||
value-format="YYYY-MM-DD"
|
||||
format="YYYY-MM-DD"
|
||||
type="date"
|
||||
@change="getDueDate"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="年检周期" prop="ANNUAL_INSPECTION_CYCLE">
|
||||
<el-select v-model="form.ANNUAL_INSPECTION_CYCLE">
|
||||
<el-select v-model="form.ANNUAL_INSPECTION_CYCLE" @change="getDueDate">
|
||||
<el-option
|
||||
v-for="item in annualInspectionCycleList"
|
||||
:key="item.DICTIONARIES_ID"
|
||||
|
@ -136,6 +137,7 @@
|
|||
value-format="YYYY-MM-DD"
|
||||
format="YYYY-MM-DD"
|
||||
type="date"
|
||||
disabled
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
@ -156,7 +158,7 @@
|
|||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="提醒天数" prop="REMINDER_DAYS">
|
||||
<el-input v-model.number="form.REMINDER_DAYS" maxlength="50" show-word-limit/>
|
||||
<el-input v-model.number="form.REMINDER_DAYS" maxlength="50" show-word-limit @change="getRemiderDate"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
|
@ -166,6 +168,7 @@
|
|||
value-format="YYYY-MM-DD"
|
||||
format="YYYY-MM-DD"
|
||||
type="date"
|
||||
disabled
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
@ -221,7 +224,7 @@
|
|||
import { ElMessage } from "element-plus";
|
||||
import { useRoute, useRouter, } from "vue-router";
|
||||
import useFormValidate from "@/assets/js/useFormValidate.js";
|
||||
import { addingPrefixToFile } from "@/assets/js/utils.js";
|
||||
import { addingPrefixToFile ,timeTransformation,subtractDaysFromDate} from "@/assets/js/utils.js";
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const INSPECTANNUALLY_ID = route.query.INSPECTANNUALLY_ID
|
||||
|
@ -278,6 +281,34 @@
|
|||
REMINDER_DAYS: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||
REMINDER_DATE: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||
}
|
||||
const getDueDate = ()=>{
|
||||
if(form.value.PROCESSING_DATE&&form.value.ANNUAL_INSPECTION_CYCLE){
|
||||
const list = annualInspectionCycleList._rawValue
|
||||
let num = 0
|
||||
for(let i=0;i<list.length;i++){
|
||||
const _item = list[i]
|
||||
if(form.value.ANNUAL_INSPECTION_CYCLE === _item.DICTIONARIES_ID){
|
||||
num = Number(_item.BIANMA)
|
||||
}
|
||||
}
|
||||
form.value.DUE_DATE = timeTransformation(form.value.PROCESSING_DATE,num)
|
||||
if(form.value.REMINDER_DAYS){
|
||||
form.value.REMINDER_DATE = subtractDaysFromDate(form.value.DUE_DATE,form.value.REMINDER_DAYS)
|
||||
}
|
||||
}else {
|
||||
form.value.DUE_DATE = ''
|
||||
form.value.REMINDER_DATE = ''
|
||||
}
|
||||
}
|
||||
const getRemiderDate = (val)=>{
|
||||
if(val){
|
||||
if(form.value.DUE_DATE){
|
||||
form.value.REMINDER_DATE = subtractDaysFromDate(form.value.DUE_DATE,val)
|
||||
}
|
||||
}else {
|
||||
form.value.REMINDER_DATE = ''
|
||||
}
|
||||
}
|
||||
const getVehicle = async (event) =>{
|
||||
const resData = await getTrailerList({TRAFFIC_TYPE:event})
|
||||
data.vehicleList = resData.list
|
||||
|
|
|
@ -114,12 +114,13 @@
|
|||
value-format="YYYY-MM-DD"
|
||||
format="YYYY-MM-DD"
|
||||
type="date"
|
||||
@change="getDueDate"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="年检周期" prop="ANNUAL_INSPECTION_CYCLE">
|
||||
<el-select v-model="form.ANNUAL_INSPECTION_CYCLE">
|
||||
<el-select v-model="form.ANNUAL_INSPECTION_CYCLE" @change="getDueDate">
|
||||
<el-option
|
||||
v-for="item in annualInspectionCycleList"
|
||||
:key="item.DICTIONARIES_ID"
|
||||
|
@ -136,6 +137,7 @@
|
|||
value-format="YYYY-MM-DD"
|
||||
format="YYYY-MM-DD"
|
||||
type="date"
|
||||
disabled
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
@ -156,7 +158,7 @@
|
|||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="提醒天数" prop="REMINDER_DAYS">
|
||||
<el-input v-model.number="form.REMINDER_DAYS" maxlength="50" show-word-limit/>
|
||||
<el-input v-model.number="form.REMINDER_DAYS" maxlength="50" show-word-limit @change="getRemiderDate"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
|
@ -166,6 +168,7 @@
|
|||
value-format="YYYY-MM-DD"
|
||||
format="YYYY-MM-DD"
|
||||
type="date"
|
||||
disabled
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
@ -221,7 +224,7 @@
|
|||
import { ElMessage } from "element-plus";
|
||||
import { useRoute, useRouter, } from "vue-router";
|
||||
import useFormValidate from "@/assets/js/useFormValidate.js";
|
||||
import { addingPrefixToFile } from "@/assets/js/utils.js";
|
||||
import { addingPrefixToFile ,timeTransformation,subtractDaysFromDate} from "@/assets/js/utils.js";
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const INSPECTANNUALLY_ID = route.query.INSPECTANNUALLY_ID
|
||||
|
@ -278,6 +281,34 @@
|
|||
REMINDER_DAYS: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||
REMINDER_DATE: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||
}
|
||||
const getDueDate = ()=>{
|
||||
if(form.value.PROCESSING_DATE&&form.value.ANNUAL_INSPECTION_CYCLE){
|
||||
const list = annualInspectionCycleList._rawValue
|
||||
let num = 0
|
||||
for(let i=0;i<list.length;i++){
|
||||
const _item = list[i]
|
||||
if(form.value.ANNUAL_INSPECTION_CYCLE === _item.DICTIONARIES_ID){
|
||||
num = Number(_item.BIANMA)
|
||||
}
|
||||
}
|
||||
form.value.DUE_DATE = timeTransformation(form.value.PROCESSING_DATE,num)
|
||||
if(form.value.REMINDER_DAYS){
|
||||
form.value.REMINDER_DATE = subtractDaysFromDate(form.value.DUE_DATE,form.value.REMINDER_DAYS)
|
||||
}
|
||||
}else {
|
||||
form.value.DUE_DATE = ''
|
||||
form.value.REMINDER_DATE = ''
|
||||
}
|
||||
}
|
||||
const getRemiderDate = (val)=>{
|
||||
if(val){
|
||||
if(form.value.DUE_DATE){
|
||||
form.value.REMINDER_DATE = subtractDaysFromDate(form.value.DUE_DATE,val)
|
||||
}
|
||||
}else {
|
||||
form.value.REMINDER_DATE = ''
|
||||
}
|
||||
}
|
||||
const getVehicle = async (event) =>{
|
||||
const resData = await getTrailerList({TRAFFIC_TYPE:event})
|
||||
data.vehicleList = resData.list
|
||||
|
|
Loading…
Reference in New Issue