代码提交
This commit is contained in:
parent
b421a1f4c3
commit
e5fa6ae335
|
@ -30,7 +30,6 @@ class CustomRequest {
|
||||||
}).then()
|
}).then()
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(params,method)
|
|
||||||
Taro.request<JsonResult<T>, object>({
|
Taro.request<JsonResult<T>, object>({
|
||||||
url: this.BASE_API + url,
|
url: this.BASE_API + url,
|
||||||
data: params,
|
data: params,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="form">
|
<view class="form">
|
||||||
|
{{ formData }}
|
||||||
<nut-form ref="formRef" :model-value="formData" :rules="rules">
|
<nut-form ref="formRef" :model-value="formData" :rules="rules">
|
||||||
<nut-form-item label="姓名" prop="name">
|
<nut-form-item label="姓名" prop="name">
|
||||||
<nut-input v-model="formData.name" placeholder="请输入姓名" type="text"/>
|
<nut-input v-model="formData.name" placeholder="请输入姓名" type="text"/>
|
||||||
|
@ -15,8 +16,11 @@
|
||||||
<nut-input v-model="formData.idCard" placeholder="请填写身份证" type="text" @blur="idCardBlur"/>
|
<nut-input v-model="formData.idCard" placeholder="请填写身份证" type="text" @blur="idCardBlur"/>
|
||||||
</nut-form-item>
|
</nut-form-item>
|
||||||
<nut-form-item label="出生日期" prop="dateOfBirth">
|
<nut-form-item label="出生日期" prop="dateOfBirth">
|
||||||
{{formData.dateOfBirth || "请填写出生年月"}}
|
<view @click="showPicker = true">
|
||||||
<!-- <nut-input @click="openDate" :disabled="true" placeholder="请填写出生年月" type="text">{{formData.dateOfBirth}}</nut-input>-->
|
{{
|
||||||
|
dayjs(formData.dateOfBirth).isValid() ? dayjs(formData.dateOfBirth).format('YYYY-MM-DD') : '请选择出生年月'
|
||||||
|
}}
|
||||||
|
</view>
|
||||||
</nut-form-item>
|
</nut-form-item>
|
||||||
<nut-form-item label="工作岗位" prop="workPost">
|
<nut-form-item label="工作岗位" prop="workPost">
|
||||||
<nut-input v-model="formData.workPost" placeholder="请输入工作岗位" type="text"/>
|
<nut-input v-model="formData.workPost" placeholder="请输入工作岗位" type="text"/>
|
||||||
|
@ -36,15 +40,15 @@
|
||||||
</nut-form>
|
</nut-form>
|
||||||
<view class="formButton">
|
<view class="formButton">
|
||||||
<nut-button style="width: 45%" type="success" size="small" @click="submit">提交</nut-button>
|
<nut-button style="width: 45%" type="success" size="small" @click="submit">提交</nut-button>
|
||||||
<nut-button style="width: 45%" size="small" @click="reset">重置提示状态</nut-button>
|
<nut-button style="width: 45%" size="small" @click="formRef.value?.reset()">重置表单</nut-button>
|
||||||
</view>
|
</view>
|
||||||
<nut-popup v-model:visible="showPicker" position="bottom">
|
<nut-popup v-model:visible="showPicker" position="bottom">
|
||||||
<nut-date-picker
|
<nut-date-picker
|
||||||
v-model="pickerValue"
|
v-model="formData.dateOfBirth"
|
||||||
:three-dimensional="false"
|
:three-dimensional="false"
|
||||||
:min-date="new Date(1900,1,1)"
|
:min-date="new Date(1900,1,1)"
|
||||||
:max-date="new Date(2100,1,1)"
|
:max-date="new Date(2100,1,1)"
|
||||||
@confirm="confirm"
|
@confirm="showPicker = false"
|
||||||
@cancel="showPicker = false"
|
@cancel="showPicker = false"
|
||||||
></nut-date-picker>
|
></nut-date-picker>
|
||||||
</nut-popup>
|
</nut-popup>
|
||||||
|
@ -57,16 +61,16 @@ import {FormRules} from "@nutui/nutui-taro/dist/types/__VUE/form/types";
|
||||||
import api from "@/request";
|
import api from "@/request";
|
||||||
import './form.scss'
|
import './form.scss'
|
||||||
import Taro, {useLoad} from "@tarojs/taro";
|
import Taro, {useLoad} from "@tarojs/taro";
|
||||||
import {formDate} from "../../../../types/pages/form";
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
const showPicker = ref(false)
|
const showPicker = ref(false)
|
||||||
const formData = ref<formDate>(null!)
|
|
||||||
const pickerValue = ref(new Date())
|
const formData = ref<formDate>({} as any)
|
||||||
const formRef = ref(null)
|
const formRef = ref(null)
|
||||||
|
|
||||||
const rules: FormRules = {
|
const rules: FormRules = {
|
||||||
name: [
|
name: [
|
||||||
{required: true, message: "请输入姓名"},
|
{required: true, message: "请输入姓名"},
|
||||||
|
|
||||||
],
|
],
|
||||||
sex: [{required: true, message: "请选择性别"}],
|
sex: [{required: true, message: "请选择性别"}],
|
||||||
idCard: [
|
idCard: [
|
||||||
|
@ -80,47 +84,33 @@ const rules: FormRules = {
|
||||||
|
|
||||||
useLoad((options) => {
|
useLoad((options) => {
|
||||||
formData.value = JSON.parse(options.item)
|
formData.value = JSON.parse(options.item)
|
||||||
console.log(formData.value,'888')
|
|
||||||
})
|
})
|
||||||
const openDate = ()=>{
|
|
||||||
showPicker.value = true
|
const idCardBlur = (e: any) => {
|
||||||
}
|
|
||||||
const confirm = ({selectedValue })=>{
|
|
||||||
showPicker.value = false
|
|
||||||
formData.value.dateOfBirth = selectedValue[0] + '年' + selectedValue[1] +'月' + selectedValue[2] + ' 日'
|
|
||||||
}
|
|
||||||
const reset = () => {
|
|
||||||
formRef.value?.reset()
|
|
||||||
}
|
|
||||||
const idCardBlur = (e:string)=>{
|
|
||||||
const value = e.detail.value
|
const value = e.detail.value
|
||||||
|
if (!value?.length || value.length < 18) {
|
||||||
|
formData.value.dateOfBirth = null;
|
||||||
|
return
|
||||||
|
}
|
||||||
const birthDate = value.substring(6, 14);
|
const birthDate = value.substring(6, 14);
|
||||||
const year = birthDate.substring(0, 4);
|
const year = birthDate.substring(0, 4);
|
||||||
const month = birthDate.substring(4, 6);
|
const month = birthDate.substring(4, 6);
|
||||||
const day = birthDate.substring(6, 8);
|
const day = birthDate.substring(6, 8);
|
||||||
// 格式化为 “某年某月某日”
|
|
||||||
formData.value.dateOfBirth = new Date(parseInt(year), parseInt(month) - 1, parseInt(day))
|
formData.value.dateOfBirth = new Date(parseInt(year), parseInt(month) - 1, parseInt(day))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const snowFlakeId = ref<string>('')
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
formRef.value?.validate().then(({valid, errors}) => {
|
formRef.value?.validate().then(async ({valid}) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if(formData.value.snowFlakeId === ''){
|
const resp = await api.post('/projectManageIndex/saveOrUpdateSecurityUser', formData.value)
|
||||||
snowFlakeId.value = ''
|
|
||||||
}else{
|
|
||||||
snowFlakeId.value = formData.value.snowFlakeId as any
|
|
||||||
}
|
|
||||||
const resp = api.post('/projectManageIndex/saveOrUpdateSecurityUser',formData.value)
|
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '项目人员录入成功',
|
title: resp.message,
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
mask: true,
|
mask: true,
|
||||||
}).then()
|
}).then()
|
||||||
formData.value = {
|
formData.value = {
|
||||||
snowFlakeId:'',
|
snowFlakeId: undefined,
|
||||||
serviceProjectId: formData.value.serviceProjectId,
|
serviceProjectId: formData.value.serviceProjectId,
|
||||||
name: '',
|
name: '',
|
||||||
workPost: '',
|
workPost: '',
|
||||||
|
@ -128,13 +118,11 @@ const submit = () => {
|
||||||
sex: 0,
|
sex: 0,
|
||||||
nativePlace: '',
|
nativePlace: '',
|
||||||
idCard: '',
|
idCard: '',
|
||||||
dateOfBirth:'',
|
dateOfBirth: null,
|
||||||
securityNumber: '',
|
securityNumber: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
homeAddress: ''
|
homeAddress: ''
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.warn('error:', errors)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,16 @@
|
||||||
<view class="projectDetailsItem" style="line-height: 50rpx">
|
<view class="projectDetailsItem" style="line-height: 50rpx">
|
||||||
<view>
|
<view>
|
||||||
<view style="display: flex;justify-content: space-between">
|
<view style="display: flex;justify-content: space-between">
|
||||||
<text style="font-size: 18px">{{ nameValue ? nameValue : '' }}{{ '-----' + serviceProjectDetails?.name }}项目</text>
|
<text style="font-size: 18px">{{ nameValue ? nameValue : '' }}{{
|
||||||
|
'-----' + serviceProjectDetails?.name
|
||||||
|
}}项目
|
||||||
|
</text>
|
||||||
<text>进行中</text>
|
<text>进行中</text>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<view style="float: left;width: 50%;" class="content">经理名称:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.name }}</view>
|
<view style="float: left;width: 50%;" class="content">
|
||||||
|
经理名称:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.name }}
|
||||||
|
</view>
|
||||||
<view class="content">手机号:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.telephone }}</view>
|
<view class="content">手机号:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.telephone }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -110,6 +115,7 @@ import './projectDetails.scss'
|
||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import api from "@/request/index";
|
import api from "@/request/index";
|
||||||
import * as dayjs from 'dayjs'
|
import * as dayjs from 'dayjs'
|
||||||
|
|
||||||
const serviceProjectDetails = ref()
|
const serviceProjectDetails = ref()
|
||||||
const nameValue = ref('')
|
const nameValue = ref('')
|
||||||
const projectData = ref<Records[]>([])
|
const projectData = ref<Records[]>([])
|
||||||
|
@ -148,13 +154,13 @@ const projectDetailsTable = async () => {
|
||||||
const formAdd = () => {
|
const formAdd = () => {
|
||||||
const params = {
|
const params = {
|
||||||
serviceProjectId: serviceProjectDetails.value.snowFlakeId,
|
serviceProjectId: serviceProjectDetails.value.snowFlakeId,
|
||||||
snowFlakeId:'',
|
snowFlakeId: undefined,
|
||||||
name: '',
|
name: '',
|
||||||
workPost: '',
|
workPost: '',
|
||||||
sex: 0,
|
sex: 0,
|
||||||
nativePlace: '',
|
nativePlace: '',
|
||||||
idCard: '',
|
idCard: '',
|
||||||
dateOfBirth:'',
|
dateOfBirth: null,
|
||||||
securityNumber: '',
|
securityNumber: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
homeAddress: ''
|
homeAddress: ''
|
||||||
|
|
|
@ -11,17 +11,25 @@
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"noUnusedLocals": false,
|
"noUnusedLocals": false,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": false,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"typeRoots": ["node_modules/@types"],
|
"typeRoots": [
|
||||||
|
"node_modules/@types"
|
||||||
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["src/*"]
|
"@/*": [
|
||||||
|
"src/*"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["./src", "./types", "./config"],
|
"include": [
|
||||||
|
"./src",
|
||||||
|
"./types",
|
||||||
|
"./config"
|
||||||
|
],
|
||||||
"compileOnSave": false
|
"compileOnSave": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import {Dayjs} from "dayjs";
|
interface formDate {
|
||||||
|
|
||||||
export interface formDate {
|
|
||||||
snowFlakeId?: string;
|
snowFlakeId?: string;
|
||||||
serviceProjectId: string;
|
serviceProjectId: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
@ -9,7 +7,7 @@ export interface formDate {
|
||||||
sex: number;
|
sex: number;
|
||||||
nativePlace?: string;
|
nativePlace?: string;
|
||||||
idCard: string;
|
idCard: string;
|
||||||
dateOfBirth?:Dayjs;
|
dateOfBirth?: Date;
|
||||||
securityNumber?: string;
|
securityNumber?: string;
|
||||||
remark?: string;
|
remark?: string;
|
||||||
homeAddress?: string
|
homeAddress?: string
|
||||||
|
|
Loading…
Reference in New Issue