This commit is contained in:
wangyilin 2024-09-14 11:09:50 +08:00
parent 25c3e2a911
commit 55c9bfa19b
3 changed files with 56 additions and 66 deletions

View File

@ -4,7 +4,7 @@
<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" />
</nut-form-item> </nut-form-item>
<nut-form-item label="年龄" prop="sex" > <nut-form-item label="性别" prop="sex" >
<nut-radio-group v-model="formData.sex" direction="horizontal"> <nut-radio-group v-model="formData.sex" direction="horizontal">
<nut-radio v-for="item in SEX" :key="item.value" :label="item.value" <nut-radio v-for="item in SEX" :key="item.value" :label="item.value"
>{{ item.label }} >{{ item.label }}
@ -15,7 +15,8 @@
<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" >
<nut-input @click="openDate" :disabled="true" v-model="formData.dateOfBirth" placeholder="请填写身份证" type="text" /> {{formData.dateOfBirth || "请填写出生年月"}}
<!-- <nut-input @click="openDate" :disabled="true" placeholder="请填写出生年月" type="text">{{formData.dateOfBirth}}</nut-input>-->
</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" />
@ -50,38 +51,22 @@
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {onMounted, ref, watch} from "vue"; import {ref} from "vue";
import {SEX} from "@/enums"; import {SEX} from "@/enums";
import {FormRules} from "@nutui/nutui-taro/dist/types/__VUE/form/types"; 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";
const showPicker = ref(false) const showPicker = ref(false)
const formData = ref<formDate>({ const formData = ref<formDate>(null!)
snowFlakeId:'',
name: '',
workPost:'',
sex:0,
nativePlace:'',
idCard:'',
dateOfBirth:'',
securityNumber:'',
remark:'',
homeAddress: ''
})
const serviceProjectId = ref('') //id
const pickerValue = ref(new Date()) const pickerValue = ref(new Date())
const formRef = ref(null) const formRef = ref(null)
const rules: FormRules = { const rules: FormRules = {
name: [ name: [
{ required: true, message: "请输入姓名" }, { required: true, message: "请输入姓名" },
{
validator: (value) => {
return !(value.length < 2 || value.length >= 20);
},
message: "名字在2~20字符之间",
},
], ],
sex: [{ required: true, message: "请选择性别" }], sex: [{ required: true, message: "请选择性别" }],
idCard:[ idCard:[
@ -95,19 +80,14 @@ const rules: FormRules = {
useLoad((options)=>{ useLoad((options)=>{
formData.value = JSON.parse(options.item) formData.value = JSON.parse(options.item)
serviceProjectId.value = JSON.parse(options.item).snowFlakeId console.log(formData.value,'888')
console.log(serviceProjectId.value)
})
watch(()=>formData.value,(res)=>{
console.log(res)
}) })
const openDate = ()=>{ const openDate = ()=>{
showPicker.value = true showPicker.value = true
} }
const confirm = ({selectedValue })=>{ const confirm = ({selectedValue })=>{
showPicker.value = false showPicker.value = false
formData.value.dateOfBirth =selectedValue[0] + '年' + selectedValue[1] +'月' + selectedValue[2] + ' 日' formData.value.dateOfBirth = selectedValue[0] + '年' + selectedValue[1] +'月' + selectedValue[2] + ' 日'
} }
const reset = () => { const reset = () => {
formRef.value?.reset() formRef.value?.reset()
@ -119,26 +99,20 @@ const idCardBlur = (e:string)=>{
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 = `${year}${month}${day}` formData.value.dateOfBirth = new Date(parseInt(year),parseInt(month) - 1,parseInt(day))
pickerValue.value = 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(({valid, errors}) => {
if (valid) { if (valid) {
const saveOrUpdateSecurityUserParams = { if(formData.value.snowFlakeId === ''){
serviceProjectId:serviceProjectId.value, snowFlakeId.value = ''
name: formData.value.name, }else{
workPost:formData.value.workPost, snowFlakeId.value = formData.value.snowFlakeId as any
sex:formData.value.sex,
nativePlace: formData.value.nativePlace,
idCard: formData.value.idCard,
dateOfBirth: pickerValue.value,
securityNumber: formData.value.securityNumber,
homeAddress: formData.value.homeAddress,
remark: formData.value.remark
} }
const resp = api.post('/projectManageIndex/saveOrUpdateSecurityUser',saveOrUpdateSecurityUserParams) const resp = api.post('/projectManageIndex/saveOrUpdateSecurityUser',formData.value)
Taro.showToast({ Taro.showToast({
title: '项目人员录入成功', title: '项目人员录入成功',
icon: 'success', icon: 'success',
@ -147,8 +121,10 @@ const submit = () => {
}).then() }).then()
formData.value = { formData.value = {
snowFlakeId:'', snowFlakeId:'',
serviceProjectId:formData.value.serviceProjectId,
name: '', name: '',
workPost:'', workPost:'',
telephone:'',
sex:0, sex:0,
nativePlace:'', nativePlace:'',
idCard:'', idCard:'',

View File

@ -3,12 +3,12 @@
<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 : '' }}{{ '-----' + detailsList?.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">经理名称:{{ detailsList?.projectManagerMiniProgramUserInfo.name }}</view> <view style="float: left;width: 50%;" class="content">经理名称:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.name }}</view>
<view class="content">手机号:{{ detailsList?.projectManagerMiniProgramUserInfo.telephone }}</view> <view class="content">手机号:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.telephone }}</view>
</view> </view>
</view> </view>
</view> </view>
@ -16,28 +16,28 @@
<view class="projectDetailsIndex"> <view class="projectDetailsIndex">
<nut-row> <nut-row>
<nut-col :span="24"> <nut-col :span="24">
<view class="content">保安证件号{{ detailsList?.idNumber }}</view> <view class="content">保安证件号{{ serviceProjectDetails?.idNumber }}</view>
</nut-col> </nut-col>
</nut-row> </nut-row>
<nut-row> <nut-row>
<nut-col :span="12"> <nut-col :span="12">
<view class="content">工作人员数量:{{ detailsList?.staffTotal }}</view> <view class="content">工作人员数量:{{ serviceProjectDetails?.staffTotal }}</view>
</nut-col> </nut-col>
<nut-col :span="12"> <nut-col :span="12">
<view class="content">保安人员数量:{{ detailsList?.securityUserTotal }}</view> <view class="content">保安人员数量:{{ serviceProjectDetails?.securityUserTotal }}</view>
</nut-col> </nut-col>
</nut-row> </nut-row>
<nut-row> <nut-row>
<nut-col :span="12"> <nut-col :span="12">
<view class="content">服务区域面积:{{ detailsList?.serviceArea }}</view> <view class="content">服务区域面积:{{ serviceProjectDetails?.serviceArea }}</view>
</nut-col> </nut-col>
<nut-col :span="12"> <nut-col :span="12">
<view class="content">楼栋数量:{{ detailsList?.buildingTotal }}</view> <view class="content">楼栋数量:{{ serviceProjectDetails?.buildingTotal }}</view>
</nut-col> </nut-col>
</nut-row> </nut-row>
<nut-row> <nut-row>
<nut-col :span="4"> <nut-col :span="4">
<view class="content">户数:{{ detailsList?.houseTotal }}</view> <view class="content">户数:{{ serviceProjectDetails?.houseTotal }}</view>
</nut-col> </nut-col>
</nut-row> </nut-row>
</view> </view>
@ -110,19 +110,18 @@ 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'
import {type} from "os"; const serviceProjectDetails = ref()
const detailsList = ref()
const nameValue = ref('') const nameValue = ref('')
const projectData = ref<Records[]>([]) const projectData = ref<Records[]>([])
const content = ref<Records>({} as any) const content = ref<Records>({} as any)
// //
const confirmVisible = ref(false); const confirmVisible = ref(false);
const detailVisible = ref(false) const detailVisible = ref(false)
useLoad(async (options: MyProjectList) => { useLoad(async (options: MyProjectList) => {
console.log(JSON.parse(options.item),'111111111111',options.name)
nameValue.value = options.name nameValue.value = options.name
detailsList.value = await JSON.parse(options.item) serviceProjectDetails.value = await JSON.parse(options.item)
}) })
useDidShow(async () => { useDidShow(async () => {
initServiceProjectSecurityUserList() initServiceProjectSecurityUserList()
@ -133,7 +132,7 @@ const projectDetailsTable = async () => {
}) })
const queryParams = { const queryParams = {
params: { params: {
serviceProjectId: detailsList.value?.snowFlakeId, serviceProjectId: serviceProjectDetails.value?.snowFlakeId,
}, },
page: { page: {
size: 4, size: 4,
@ -147,7 +146,20 @@ const projectDetailsTable = async () => {
Taro.hideLoading() Taro.hideLoading()
} }
const formAdd = () => { const formAdd = () => {
Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(detailsList.value)}`}) const params = {
serviceProjectId:serviceProjectDetails.value.snowFlakeId,
snowFlakeId:'',
name: '',
workPost:'',
sex:0,
nativePlace:'',
idCard:'',
dateOfBirth:'',
securityNumber:'',
remark:'',
homeAddress: ''
}
Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(params)}`})
} }
const total = ref<any>(null) const total = ref<any>(null)
const current = ref(1) const current = ref(1)
@ -182,7 +194,6 @@ const deleteUssrID = (snowFlakeId:string)=>{
confirmVisible.value = true confirmVisible.value = true
securityUserId.value = snowFlakeId securityUserId.value = snowFlakeId
} }
// //
const dialogOk = async ()=>{ const dialogOk = async ()=>{
await api.delete(`/projectManageIndex/deleteSecurityUserByServiceProjectId`,{securityUserId:securityUserId.value},{ await api.delete(`/projectManageIndex/deleteSecurityUserByServiceProjectId`,{securityUserId:securityUserId.value},{
@ -193,15 +204,14 @@ const dialogOk = async ()=>{
initServiceProjectSecurityUserList() initServiceProjectSecurityUserList()
} }
// //
const detail = (item)=>{ const detail = (item)=>{
detailVisible.value = true detailVisible.value = true
content.value = item content.value = item
} }
const projectEdit = (item)=>{ const projectEdit = (item)=>{
console.log(111) const params = {...item,sex:item.sex.value}
Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(item)}`}) Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(params)}`})
} }
</script> </script>

View File

@ -1,11 +1,15 @@
interface formDate { import {Dayjs} from "dayjs";
snowFlakeId?:string;
name: string; export interface formDate {
snowFlakeId?: string;
serviceProjectId: string;
name?: string;
workPost?:string; workPost?:string;
telephone?: string;
sex:number; sex:number;
nativePlace?:string; nativePlace?:string;
idCard:string; idCard:string;
dateOfBirth?:string; dateOfBirth?:Dayjs;
securityNumber?:string; securityNumber?:string;
remark?:string; remark?:string;
homeAddress?: string homeAddress?: string