小程序

This commit is contained in:
wangyilin 2024-09-13 09:40:08 +08:00
parent 184a981526
commit a1042b806d
21 changed files with 399 additions and 25 deletions

View File

@ -6,7 +6,6 @@ export default defineAppConfig({
'pages/policeManager/index/index',
'pages/mine/mine',
'pages/employeeInfo/employeeInfo',
'pages/myProject/myProject',
],
window: {
backgroundTextStyle: 'light',
@ -20,6 +19,9 @@ export default defineAppConfig({
root: "subPages",
pages: [
'pages/policeManager/index',
'pages/myProject/myProject',
'pages/projectDetails/projectDetails',
'pages/form/form'
]
}
],

View File

@ -1,5 +1,6 @@
import {createApp} from 'vue'
import {createPinia} from 'pinia'
import {useCounterStore} from '@/store'
import './app.scss'
import './assets/scss/colorui.scss'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
@ -9,9 +10,13 @@ const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
const App = createApp({
onShow(options) {
const store = useCounterStore()
const token = Taro.getStorageSync('token')
if(token){
console.log(111)
Taro.switchTab({
url:'/pages/mine/mine'
})
store.setSelected(2)
}else{
console.log(2222)
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 KiB

View File

@ -7,6 +7,10 @@ export const SEX: SelectNode<number>[] = [
value: 1,
label: "女",
},
{
value: 2,
label: "隐藏",
}
];
export const IDENTITY: SelectNode<string>[] = [

View File

@ -1,6 +1,6 @@
<template>
<view class="message">
89+89+
我的我的我的我的
</view>
</template>

View File

@ -29,7 +29,6 @@ const routerPush = (path) => {
case 1:
Taro.navigateTo({
url: '/subPages/pages/policeManager/index',
})
}

View File

@ -11,7 +11,7 @@
<nut-grid :column-num="3">
<nut-grid-item
text="我的项目"
@click="Taro.navigateTo({url: '/pages/myProject/myProject'})">
@click="Taro.navigateTo({url: '/subPages/pages/myProject/myProject'})">
</nut-grid-item>
<nut-grid-item
text="警保风采"

View File

@ -15,7 +15,6 @@
placeholder="请输入您的昵称"
type="text"
/>
<!-- <nut-input class="nickNameInput" type="nickname" v-model="formData.name" placeholder="请输入您的昵称" @change="getNickname"></nut-input>-->
</nut-form-item>
<nut-form-item label="性别:" prop="sex">
<nut-radio-group v-model="formData.sex" direction="horizontal">

View File

@ -7,7 +7,7 @@ const requestInterceptor = (chain: Taro.Chain) => {
if (token) {
requestParams.header = {
...requestParams.header,
token
token:token.value
}
}
return chain.proceed(requestParams)

View File

@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '项目人员录入',
})

View File

@ -0,0 +1,8 @@
.form{
.formButton{
display: flex;
margin-top: auto;
justify-content: space-around;
margin-bottom: 30px
}
}

View File

@ -0,0 +1,165 @@
<template>
<view class="form">
<nut-form ref="formRef" :model-value="formData" :rules="rules">
<nut-form-item label="姓名" prop="name">
<nut-input v-model="formData.name" placeholder="请输入姓名" type="text" />
</nut-form-item>
<nut-form-item label="年龄" prop="sex" >
<nut-radio-group v-model="formData.sex" direction="horizontal">
<nut-radio v-for="item in SEX" :key="item.value" :label="item.value"
>{{ item.label }}
</nut-radio>
</nut-radio-group>
</nut-form-item>
<nut-form-item label="身份证" prop="idCard">
<nut-input v-model="formData.idCard" placeholder="请填写身份证" type="text" @blur="idCardBlur"/>
</nut-form-item>
<nut-form-item label="出生日期" prop="dateOfBirth" >
<nut-input @click="openDate" :disabled="true" v-model="formData.dateOfBirth" placeholder="请填写身份证" type="text" />
</nut-form-item>
<nut-form-item label="工作岗位" prop="workPost">
<nut-input v-model="formData.workPost" placeholder="请输入工作岗位" type="text" />
</nut-form-item>
<nut-form-item label="籍贯" prop="nativePlace">
<nut-input v-model="formData.nativePlace" placeholder="请输入籍贯" type="text" />
</nut-form-item>
<nut-form-item label="地址" prop="homeAddress">
<nut-input v-model="formData.homeAddress" placeholder="请输入地址" type="text"/>
</nut-form-item>
<nut-form-item label="保安证号" prop="securityNumber">
<nut-input v-model="formData.securityNumber" placeholder="请输入保安证号" type="text" />
</nut-form-item>
<nut-form-item label="备注" prop="remark">
<nut-input v-model="formData.remark" placeholder="请填写备注" type="text" />
</nut-form-item>
</nut-form>
<view class="formButton">
<nut-button style="width: 45%" type="success" size="small" @click="submit">提交</nut-button>
<nut-button style="width: 45%" size="small" @click="reset">重置提示状态</nut-button>
</view>
<nut-popup v-model:visible="showPicker" position="bottom">
<nut-date-picker
v-model="pickerValue"
:three-dimensional="false"
:min-date="new Date(1900,1,1)"
:max-date="new Date(2100,1,1)"
@confirm="confirm"
@cancel="showPicker = false"
></nut-date-picker>
</nut-popup>
</view>
</template>
<script setup lang="ts">
import {ref} from "vue";
import {SEX} from "@/enums";
import {FormRules} from "@nutui/nutui-taro/dist/types/__VUE/form/types";
import api from "@/request";
import './form.scss'
import Taro, {useLoad} from "@tarojs/taro";
const showPicker = ref(false)
const formData = ref<formDate>({
snowFlakeId:'',
serviceProjectId:'',
name: '',
workPost:'',
sex:0,
nativePlace:'',
idCard:'',
dateOfBirth:'',
securityNumber:'',
remark:'',
homeAddress: ''
})
const pickerValue = ref(new Date())
const formRef = ref(null)
const rules: FormRules = {
name: [
{ required: true, message: "请输入姓名" },
{
validator: (value) => {
return !(value.length < 2 || value.length >= 20);
},
message: "名字在2~20字符之间",
},
],
sex: [{ required: true, message: "请选择性别" }],
idCard:[
{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)$)/,
message: "身份证格式错误",
},
]
};
useLoad((options)=>{
formData.value.serviceProjectId = JSON.parse(options.item).snowFlakeId
})
const openDate = ()=>{
showPicker.value = true
}
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 birthDate = value.substring(6, 14);
const year = birthDate.substring(0, 4);
const month = birthDate.substring(4, 6);
const day = birthDate.substring(6, 8);
//
formData.value.dateOfBirth = `${year}${month}${day}`
pickerValue.value = new Date(parseInt(year),parseInt(month) - 1,parseInt(day))
}
const submit = () => {
formRef.value?.validate().then(({valid, errors}) => {
if (valid) {
const saveOrUpdateSecurityUserParams = {
serviceProjectId:formData.value.serviceProjectId,
name: formData.value.name,
workPost:formData.value.workPost,
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)
Taro.showToast({
title: '项目人员录入成功',
icon: 'success',
duration: 2000,
mask: true,
}).then()
formData.value = {
snowFlakeId:'',
serviceProjectId:formData.value.serviceProjectId,
name: '',
workPost:'',
sex:0,
nativePlace:'',
idCard:'',
dateOfBirth:'',
securityNumber:'',
remark:'',
homeAddress: ''
}
} else {
console.warn('error:', errors)
}
})
}
</script>
<style scoped lang="scss">
</style>

View File

@ -7,13 +7,9 @@
</view>
<view class="myProjectIndex">地址
<text>{{item?.provinceName}}{{item.cityName}}{{item.districtsName}}{{item.streetName}}</text>
</view>
<view style="display: flex;justify-content: space-between">
<text>项目负责人{{item?.contactPersonInfo.name}}</text>
<text>电话{{item?.contactPersonInfo.telephone}}</text>
</view>
<view class="project" >
<view v-for="(items,index) in item.serviceProjectList" :key="index">{{items.name}}</view>
<view @click="projectClick(items,item?.name)" v-for="(items,index) in item.serviceProjectList" :key="index">{{items.name}}</view>
</view>
</view>
</view>
@ -25,15 +21,16 @@ import {onMounted, ref} from "vue";
import Taro from "@tarojs/taro";
import './myproject.scss'
const myProjectList = ref<myProjectList[]>()
const myProjectList = ref<MyProjectList[]>()
const getMyServiceProject = async () => {
const token = Taro.getStorageSync('token')
const resp = await api.get<myProjectList[]>(`/projectManageIndex/getMyServiceProject`, {
token: token.value
})
const resp = await api.get<MyProjectList[]>(`/projectManageIndex/getMyServiceProject`)
myProjectList.value = resp.data
console.log(resp.data)
}
const projectClick = (items:ServiceProjectList,name:string)=>{
Taro.navigateTo({
url:`/subPages/pages/projectDetails/projectDetails?name=${name}&item=${JSON.stringify(items)}`,
})
}
onMounted(async () => {
await getMyServiceProject()

View File

@ -0,0 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '项目详情',
})

View File

@ -0,0 +1,50 @@
.projectDetails{
height: 100vh;
overflow: hidden;
background: #f1f1f1;
display: flex;
flex-direction: column;
.projectDetailsItem{
margin: 20px;
border-radius: 10px;
background: #ffffff;
padding: 15px;
font-size: 28px;
line-height: 65px;
color: #333333;
.projectDetailsIndex{
.content{
color: #9b9b9f;
}
}
}
.projectDetailsTableDrop{
height: 800px;
.projectDetailsTable{
margin: 20px;
border-radius: 10px;
background: #ffffff;
padding: 15px;
font-size: 28px;
line-height: 65px;
color: #333333;
.projectDetailsTableItem{
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
font-size: 24px;
margin-bottom: 15px
}
}
}
.projectDetailsButton{
display: flex;
margin-top: auto;
justify-content: space-around;
margin-bottom: 30px
}
}

View File

@ -0,0 +1,98 @@
<template>
<view class="projectDetails">
<view class="projectDetailsItem">
<view style="display: flex;justify-content: space-between">
<text style="font-size: 18px">{{ nameValue ? nameValue : '' }}{{ '-----' + detailsList?.name }}项目</text>
<!--<text>进行中</text>-->
</view>
<view class="projectDetailsIndex">
<nut-row>
<nut-col :span="12">
<view class="content">工作人员数量:{{ detailsList?.staffTotal }}</view>
</nut-col>
<nut-col :span="12">
<view class="content">保安人员数量:{{ detailsList?.securityUserTotal }}</view>
</nut-col>
</nut-row>
<nut-row>
<nut-col :span="12">
<view class="content">服务区域面积:{{ detailsList?.serviceArea }}</view>
</nut-col>
<nut-col :span="12">
<view class="content">楼栋数量:{{ detailsList?.buildingTotal }}</view>
</nut-col>
</nut-row>
<nut-row>
<nut-col :span="16">
<view class="content">证件号{{ detailsList?.idNumber }}</view>
</nut-col>
<nut-col :span="8">
<view class="content">户数:{{ detailsList?.houseTotal }}</view>
</nut-col>
</nut-row>
</view>
</view>
<!--表格-->
<view class="projectDetailsTableDrop">
<view class="projectDetailsTable" >
<view>项目人员</view>
<view style="border: 1px solid #ccc" v-for="(item,index) in projectData" :key="index">
<view class="projectDetailsTableItem">
<text>姓名:{{ item?.name }}</text>
<text>性别:{{ item.sex.label }}</text>
<text>职位:{{ item.workPost }}</text>
<text>保安证件:{{ item.securityNumber }}</text>
<text>地址:{{ item.homeAddress }}</text>
<text>出生年月:{{ item.dateOfBirth }}</text>
<text>创建时间:{{ item.createTime }}</text>
<text>身份证:{{ item.idCard }}</text>
</view>
</view>
</view>
</view>
<view class="projectDetailsButton">
<nut-button style="width: 45%" type="info" @click="formAdd">项目人员录入</nut-button>
<nut-button style="width: 45%" type="info">二维码录入</nut-button>
</view>
</view>
</template>
<script setup lang="ts">
import Taro, {useLoad} from "@tarojs/taro";
import './projectDetails.scss'
import {ref} from "vue";
import api from "@/request/index";
const detailsList = ref()
const nameValue = ref('')
const projectData = ref<Records[]>([])
useLoad(async (options: MyProjectList) => {
nameValue.value = options.name
detailsList.value = await JSON.parse(options.item)
await projectDetailsTable()
})
const projectDetailsTable = async () => {
const queryParams = {
params: {
serviceProjectId: detailsList.value?.snowFlakeId,
},
page: {
size: 6,
current: 1
}
}
const resp = await api.post<ProjectData>('/miniProgramUser/securityUserPager', queryParams)
projectData.value = resp?.data.records
}
const formAdd = () => {
Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(detailsList.value)}`})
}
</script>
<style scoped lang="scss">
</style>

View File

@ -0,0 +1,13 @@
interface formDate {
snowFlakeId?:string;
serviceProjectId:string;
name: string;
workPost?:string;
sex:number;
nativePlace?:string;
idCard:string;
dateOfBirth?:string;
securityNumber?:string;
remark?:string;
homeAddress?: string
}

View File

@ -1,26 +1,26 @@
interface myProjectList {
interface MyProjectList {
address?: string;
city?: string;
cityName?: string;
contactPersonInfo:contactPersonInfo;
contactPersonInfo:ContactPersonInfo;
districts?: string;
districtsName?: string;
name: string;
province?: string;
provinceName: string;
remark?: string;
serviceProjectList: serviceProjectList[];
serviceProjectList: ServiceProjectList[];
snowFlakeId?: string;
street?: string;
streetName?:string;
}
interface contactPersonInfo{
name:string,
interface ContactPersonInfo{
name:string;
telephone:string
}
interface serviceProjectList {
interface ServiceProjectList {
buildingTotal?: number;
houseTotal?: number;
idNumber?: string;

View File

@ -0,0 +1,27 @@
interface Records{
createTime?: string;
dateOfBirth?: string;
homeAddress?: string;
idCard?: string;
name?: string;
nativePlace?: string;
remark?: string;
securityNumber?: string;
securityUnitId?: string;
securityUnitName?: string;
serviceProjectId?: string;
workPost?:string;
sex?:Sex
}
interface ProjectData {
current?:string;
pages?:string;
records?: Records[];
size?: string;
total?: string;
}
interface Sex {
value:number,
label:string
}