代码提交

This commit is contained in:
luozhun 2024-09-14 14:48:51 +08:00
parent b421a1f4c3
commit e5fa6ae335
5 changed files with 188 additions and 189 deletions

View File

@ -8,7 +8,7 @@ const requestInterceptor = (chain: Taro.Chain) => {
if (token) { if (token) {
requestParams.header = { requestParams.header = {
...requestParams.header, ...requestParams.header,
token:token.value token: token.value
} }
} }
return chain.proceed(requestParams) return chain.proceed(requestParams)
@ -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,
@ -62,7 +61,7 @@ class CustomRequest {
duration: 2000 duration: 2000
}).then() }).then()
reject(res.errMsg); reject(res.errMsg);
console.log(res.errMsg,'000') console.log(res.errMsg, '000')
} }
}) })
}) })

View File

@ -1,75 +1,79 @@
<template> <template>
<view class="form"> <view class="form">
<nut-form ref="formRef" :model-value="formData" :rules="rules"> {{ formData }}
<nut-form-item label="姓名" prop="name"> <nut-form ref="formRef" :model-value="formData" :rules="rules">
<nut-input v-model="formData.name" placeholder="请输入姓名" type="text" /> <nut-form-item label="姓名" prop="name">
</nut-form-item> <nut-input v-model="formData.name" placeholder="请输入姓名" type="text"/>
<nut-form-item label="性别" prop="sex" > </nut-form-item>
<nut-radio-group v-model="formData.sex" direction="horizontal"> <nut-form-item label="性别" prop="sex">
<nut-radio v-for="item in SEX" :key="item.value" :label="item.value" <nut-radio-group v-model="formData.sex" direction="horizontal">
>{{ item.label }} <nut-radio v-for="item in SEX" :key="item.value" :label="item.value"
</nut-radio> >{{ item.label }}
</nut-radio-group> </nut-radio>
</nut-form-item> </nut-radio-group>
<nut-form-item label="身份证" prop="idCard"> </nut-form-item>
<nut-input v-model="formData.idCard" placeholder="请填写身份证" type="text" @blur="idCardBlur"/> <nut-form-item label="身份证" prop="idCard">
</nut-form-item> <nut-input v-model="formData.idCard" placeholder="请填写身份证" type="text" @blur="idCardBlur"/>
<nut-form-item label="出生日期" prop="dateOfBirth" > </nut-form-item>
{{formData.dateOfBirth || "请填写出生年月"}} <nut-form-item label="出生日期" prop="dateOfBirth">
<!-- <nut-input @click="openDate" :disabled="true" placeholder="请填写出生年月" type="text">{{formData.dateOfBirth}}</nut-input>--> <view @click="showPicker = true">
</nut-form-item> {{
<nut-form-item label="工作岗位" prop="workPost"> dayjs(formData.dateOfBirth).isValid() ? dayjs(formData.dateOfBirth).format('YYYY-MM-DD') : '请选择出生年月'
<nut-input v-model="formData.workPost" placeholder="请输入工作岗位" type="text" /> }}
</nut-form-item> </view>
<nut-form-item label="籍贯" prop="nativePlace"> </nut-form-item>
<nut-input v-model="formData.nativePlace" placeholder="请输入籍贯" type="text" /> <nut-form-item label="工作岗位" prop="workPost">
</nut-form-item> <nut-input v-model="formData.workPost" placeholder="请输入工作岗位" type="text"/>
<nut-form-item label="地址" prop="homeAddress"> </nut-form-item>
<nut-input v-model="formData.homeAddress" placeholder="请输入地址" type="text"/> <nut-form-item label="籍贯" prop="nativePlace">
</nut-form-item> <nut-input v-model="formData.nativePlace" placeholder="请输入籍贯" type="text"/>
<nut-form-item label="保安证号" prop="securityNumber"> </nut-form-item>
<nut-input v-model="formData.securityNumber" placeholder="请输入保安证号" type="text" /> <nut-form-item label="地址" prop="homeAddress">
</nut-form-item> <nut-input v-model="formData.homeAddress" placeholder="请输入地址" type="text"/>
<nut-form-item label="备注" prop="remark"> </nut-form-item>
<nut-input v-model="formData.remark" placeholder="请填写备注" type="text" /> <nut-form-item label="保安证号" prop="securityNumber">
</nut-form-item> <nut-input v-model="formData.securityNumber" placeholder="请输入保安证号" type="text"/>
</nut-form> </nut-form-item>
<view class="formButton"> <nut-form-item label="备注" prop="remark">
<nut-button style="width: 45%" type="success" size="small" @click="submit">提交</nut-button> <nut-input v-model="formData.remark" placeholder="请填写备注" type="text"/>
<nut-button style="width: 45%" size="small" @click="reset">重置提示状态</nut-button> </nut-form-item>
</view> </nut-form>
<nut-popup v-model:visible="showPicker" position="bottom"> <view class="formButton">
<nut-date-picker <nut-button style="width: 45%" type="success" size="small" @click="submit">提交</nut-button>
v-model="pickerValue" <nut-button style="width: 45%" size="small" @click="formRef.value?.reset()">重置表单</nut-button>
:three-dimensional="false" </view>
:min-date="new Date(1900,1,1)" <nut-popup v-model:visible="showPicker" position="bottom">
:max-date="new Date(2100,1,1)" <nut-date-picker
@confirm="confirm" v-model="formData.dateOfBirth"
@cancel="showPicker = false" :three-dimensional="false"
></nut-date-picker> :min-date="new Date(1900,1,1)"
</nut-popup> :max-date="new Date(2100,1,1)"
</view> @confirm="showPicker = false"
@cancel="showPicker = false"
></nut-date-picker>
</nut-popup>
</view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {ref} 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"; 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: [
{required: true, message: "请输入身份证号"}, {required: true, message: "请输入身份证号"},
{ {
regex: /^(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))((0[1-9])|([12][0-9])|(30|31))\d{3}(\d|X)$)/, regex: /^(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))((0[1-9])|([12][0-9])|(30|31))\d{3}(\d|X)$)/,
@ -78,63 +82,47 @@ 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: '',
telephone:'', telephone: '',
sex:0, sex: 0,
nativePlace:'', nativePlace: '',
idCard:'', idCard: '',
dateOfBirth:'', dateOfBirth: null,
securityNumber:'', securityNumber: '',
remark:'', remark: '',
homeAddress: '' homeAddress: ''
} }
} else {
console.warn('error:', errors)
} }
}) })
} }

View File

@ -2,14 +2,19 @@
<view class="projectDetails"> <view class="projectDetails">
<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 : '' }}{{
<text>进行中</text> '-----' + serviceProjectDetails?.name
</view> }}项目
<view> </text>
<view style="float: left;width: 50%;" class="content">经理名称:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.name }}</view> <text>进行中</text>
<view class="content">手机号:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.telephone }}</view> </view>
<view>
<view style="float: left;width: 50%;" class="content">
经理名称:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.name }}
</view> </view>
<view class="content">手机号:{{ serviceProjectDetails?.projectManagerMiniProgramUserInfo.telephone }}</view>
</view>
</view> </view>
</view> </view>
<view class="projectDetailsItem"> <view class="projectDetailsItem">
@ -44,34 +49,34 @@
</view> </view>
<!--表格--> <!--表格-->
<view class="projectDetailsTableDrop"> <view class="projectDetailsTableDrop">
<view style="padding: 0 12px">项目人员({{total}})</view> <view style="padding: 0 12px">项目人员({{ total }})</view>
<scroll-view :scroll-y="true" style="height: 80%;" @scrolltolower="lower" <scroll-view :scroll-y="true" style="height: 80%;" @scrolltolower="lower"
:scroll-into-view="toView" :scroll-top="scrollTop" :refresherEnabled="true" :scroll-into-view="toView" :scroll-top="scrollTop" :refresherEnabled="true"
@refresherrefresh="onRefresherRefresh" :refresher-triggered="isRefresher" @refresherrefresh="onRefresherRefresh" :refresher-triggered="isRefresher"
> >
<view class="projectDetailsTable" v-for="(item,index) in projectData" :key="index"> <view class="projectDetailsTable" v-for="(item,index) in projectData" :key="index">
<view> <view>
<view class="projectDetailsTableItem"> <view class="projectDetailsTableItem">
<view> <view>
<view style="display: flex;justify-content: space-between"> <view style="display: flex;justify-content: space-between">
<text>姓名:{{ item?.name?item?.name:'创建者' }}</text> <text>姓名:{{ item?.name ? item?.name : '创建者' }}</text>
<text>性别:{{ item.sex?.label?item.sex?.label:' 隐藏' }}</text> <text>性别:{{ item.sex?.label ? item.sex?.label : ' 隐藏' }}</text>
<text>职位:{{ item.workPost?item.workPost:'无' }}</text> <text>职位:{{ item.workPost ? item.workPost : '无' }}</text>
</view>
<view style="display: flex;justify-content: space-between">
<text>保安证件:{{ item.securityNumber?item.securityNumber:'125241256451' }}</text>
<text>出生年月:{{ dayjs(item.dateOfBirth).format('YYYY-MM-DD')}}</text>
</view>
<view style="display: flex;justify-content: space-between">
<text>创建时间:{{ item.createTime }}</text>
<text>身份证:{{ item.idCard }}</text>
</view>
</view> </view>
<view class="projectDetailsTableIndex" > <view style="display: flex;justify-content: space-between">
<view style="color: #3a6bbe" @click="detail(item)">详情</view> <text>保安证件:{{ item.securityNumber ? item.securityNumber : '125241256451' }}</text>
<view style="color: #ffa60d" @click="projectEdit(item)">编辑</view> <text>出生年月:{{ dayjs(item.dateOfBirth).format('YYYY-MM-DD') }}</text>
<view style="color: red" @click="deleteUssrID(item.snowFlakeId)">删除</view> </view>
</view> <view style="display: flex;justify-content: space-between">
<text>创建时间:{{ item.createTime }}</text>
<text>身份证:{{ item.idCard }}</text>
</view>
</view>
<view class="projectDetailsTableIndex">
<view style="color: #3a6bbe" @click="detail(item)">详情</view>
<view style="color: #ffa60d" @click="projectEdit(item)">编辑</view>
<view style="color: red" @click="deleteUssrID(item.snowFlakeId)">删除</view>
</view>
</view> </view>
</view> </view>
@ -83,33 +88,34 @@
<nut-button style="width: 45%" type="info">二维码录入</nut-button> <nut-button style="width: 45%" type="info">二维码录入</nut-button>
</view> </view>
<view>
<nut-dialog
content="是否确认删除该用户?"
:onOk="dialogOk"
v-model:visible="confirmVisible"
/>
</view>
<view> <view>
<nut-dialog no-cancel-btn content="详情" v-model:visible="detailVisible"> <nut-dialog
<slot> content="是否确认删除该用户?"
<view style="margin-bottom: 5px"> :onOk="dialogOk"
<view>籍贯{{content.nativePlace}}</view> v-model:visible="confirmVisible"
<view>公司{{content.securityUnitName}}</view> />
<view>家庭地址{{content.homeAddress}}</view> </view>
<view>备注{{content.remark}}</view> <view>
</view> <nut-dialog no-cancel-btn content="详情" v-model:visible="detailVisible">
</slot> <slot>
</nut-dialog> <view style="margin-bottom: 5px">
<view>籍贯{{ content.nativePlace }}</view>
<view>公司{{ content.securityUnitName }}</view>
<view>家庭地址{{ content.homeAddress }}</view>
<view>备注{{ content.remark }}</view>
</view>
</slot>
</nut-dialog>
</view> </view>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Taro, {useLoad,useDidShow} from "@tarojs/taro"; import Taro, {useLoad, useDidShow} from "@tarojs/taro";
import './projectDetails.scss' 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[]>([])
@ -127,7 +133,7 @@ useDidShow(async () => {
initServiceProjectSecurityUserList() initServiceProjectSecurityUserList()
}) })
const projectDetailsTable = async () => { const projectDetailsTable = async () => {
await Taro.showLoading({ await Taro.showLoading({
title: '加载中', title: '加载中',
}) })
const queryParams = { const queryParams = {
@ -147,16 +153,16 @@ 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: ''
} }
Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(params)}`}) Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(params)}`})
@ -190,27 +196,27 @@ const onRefresherRefresh = (e) => {
const securityUserId = ref<string>('') const securityUserId = ref<string>('')
// //
const deleteUssrID = (snowFlakeId:string)=>{ 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}, {
header:{ header: {
"content-type":'application/x-www-form-urlencoded' "content-type": 'application/x-www-form-urlencoded'
} }
}) })
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) => {
const params = {...item,sex:item.sex.value} const params = {...item, sex: item.sex.value}
Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(params)}`}) Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(params)}`})
} }

View File

@ -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
} }

View File

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