This commit is contained in:
wangyilin 2024-09-14 17:50:34 +08:00
parent e9f6f61b21
commit 70183bdde7
5 changed files with 12 additions and 232 deletions

View File

@ -71,6 +71,7 @@
"@tarojs/webpack5-runner": "3.6.25",
"@types/jest": "^29.3.1",
"@types/node": "^18.15.11",
"@types/qrcode": "^1.5.5",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",

View File

@ -19,7 +19,6 @@ export default defineAppConfig({
pages: [
'pages/policeManager/index',
'pages/policeDetails/index',
'pages/myProject/myProject',
'pages/projectDetails/projectDetails',
'pages/form/form'

View File

@ -1,225 +0,0 @@
<template>
<view>
<nut-form ref="formRef" :model-value="formParams" :rules="rules">
<nut-form-item label="街道/社区:" prop="streetCommunity">
<view @click="streetCommunitySmallCommunityVisible = true">
{{ streetCommunitySmallCommunityLabel || "请选择街道/小区" }}
</view>
</nut-form-item>
<nut-form-item label="楼栋/门户:" prop="residentialDivision">
<view @click="buildingFloorHouseVisible = true">
{{ buildingFloorHouseLabel || "请选择楼栋/门户" }}
</view>
</nut-form-item>
<nut-form-item label="姓名:" prop="name">
<nut-input
v-model="formParams.name"
placeholder="请输入姓名"
type="text"
/>
</nut-form-item>
<nut-form-item label="性别:" prop="sex">
<nut-radio-group v-model="formParams.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="dataOfBirth">
<view @click="dataOfBirthVisible = true">
{{
dayjs(formParams.dataOfBirth).format("YYYY-MM-DD") ||
"请选择出生日期"
}}
</view>
</nut-form-item>
<nut-form-item label="身份证:" prop="idCard">
<nut-input
v-model="formParams.idCard"
placeholder="请输入身份证"
type="text"
/>
</nut-form-item>
<nut-form-item label="手机号:" prop="phone">
<nut-input
v-model="formParams.phone"
placeholder="请输入手机号码"
type="text"
/>
</nut-form-item>
<nut-form-item label="户籍地:" prop="householdRegistrationAddress">
<nut-input
v-model="formParams.householdRegistrationAddress"
placeholder="请输入户籍地"
type="text"
/>
</nut-form-item>
</nut-form>
<nut-cascader
v-model:visible="streetCommunitySmallCommunityVisible"
v-model="formParams.streetCommunitySmallCommunityIds"
:options="streetCommunitySmallCommunityTreeData"
title="选择街道/社区"
text-key="label"
@change="streetCommunitySmallCommunityChange"
></nut-cascader>
<nut-cascader
v-model:visible="buildingFloorHouseVisible"
v-model="formParams.buildingFloorHouseIds"
:options="buildingFloorHouseTreeData"
title="选择楼栋/门户"
text-key="label"
@change="buildingFloorHouseChange"
></nut-cascader>
<nut-popup v-model:visible="dataOfBirthVisible" position="bottom">
<nut-date-picker
v-model="formParams.dataOfBirth"
:min-date="min"
:max-date="max"
:three-dimensional="false"
@confirm="dataOfBirthVisible = false"
></nut-date-picker>
</nut-popup>
</view>
</template>
<script setup lang="ts">
import { SEX } from "@/enums";
import dayjs from "dayjs";
import { ref, watch } from "vue";
import type { FormRules } from "@nutui/nutui-taro/dist/types/__VUE/form/types";
import api from "@/request";
import type { FormInstance } from "@nutui/nutui-taro";
import { useLoad } from "@tarojs/taro";
const emits = defineEmits(["update:modelValue"]);
const props = withDefaults(
defineProps<{
modelValue: PersonnelInformation;
}>(),
{
modelValue: () => {
return {
name: "",
sex: 0,
dataOfBirth: new Date(),
idCard: "",
phone: "",
householdRegistrationAddress: "",
streetCommunitySmallCommunityIds: [],
buildingFloorHouseIds: [],
} as PersonnelInformation;
},
}
);
const defaultParams = { ...props.modelValue };
const formRef = ref<FormInstance>();
const formParams = ref<PersonnelInformation>({
...props.modelValue,
});
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-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
message: "身份证格式错误",
},
],
phone: [
{ required: true, message: "请输入手机号码" },
{
regex: /^400(-?)[0-9]{7}$|^1\d{10}$|^0[0-9]{2,3}-[0-9]{7,8}$/,
message: "手机格式错误",
},
],
};
watch(formParams.value, (n) => {
emits("update:modelValue", n);
});
const dataOfBirthVisible = ref(false);
const min = new Date(1920, 0, 1);
const max = new Date(2025, 10, 1);
defineExpose<{
validate: () => Promise<unknown>;
resetForm: () => void;
}>({
validate: async (): Promise<unknown> => {
const result = (await formRef.value?.validate()) as any;
if (result.valid) {
return Promise.resolve("校验通过");
}
return Promise.reject("校验不通过");
},
resetForm: () => {
for (let key in defaultParams) {
formParams.value[key] = defaultParams[key];
}
streetCommunitySmallCommunityLabel.value = "";
buildingFloorHouseLabel.value = "";
buildingFloorHouseTreeData.value = [];
},
});
const streetCommunitySmallCommunityTreeData = ref<TreeNode<string>[]>([]);
const streetCommunitySmallCommunityVisible = ref<boolean>(false);
const streetCommunitySmallCommunityLabel = ref<string>("");
const streetCommunitySmallCommunityChange = (
value: string,
pathNodes: Record<string, any>[]
) => {
buildingFloorHouseLabel.value = "";
formParams.value.buildingFloorHouseIds = [];
buildingFloorHouseTreeData.value = [];
streetCommunitySmallCommunityLabel.value = pathNodes
.map((e) => e.text)
.join(",");
getBuildingFloorHouseTreeBySmallCommunityId(value[value.length - 1]);
};
const buildingFloorHouseVisible = ref<boolean>(false);
const buildingFloorHouseLabel = ref<string>("");
const buildingFloorHouseChange = (
value: string,
pathNodes: Record<string, any>[]
) => (buildingFloorHouseLabel.value = pathNodes.map((e) => e.text).join(","));
const buildingFloorHouseTreeData = ref<TreeNode<string>[]>([]);
const getBuildingFloorHouseTreeBySmallCommunityId = (
smallCommunityId: string
) => {
api
.get<TreeNode<string>[]>(
"/residentialDivision/getBuildingFloorHouseTreeBySmallCommunityId",
{ smallCommunityId }
)
.then((resp) => {
buildingFloorHouseTreeData.value = resp.data as TreeNode<string>[];
});
};
useLoad(() => {
api
.get<TreeNode<string>[]>(
"/residentialDivision/streetCommunitySmallCommunityTree"
)
.then((resp) => {
streetCommunitySmallCommunityTreeData.value =
resp.data as TreeNode<string>[];
});
});
</script>

View File

@ -1,6 +1,6 @@
<template>
<view class="myProject">
<view v-if="myProjectList">
<view v-if="number !== 0">
<view class="myProjectItem" v-for="(item,index) in myProjectList" :key="index">
<view style="display: flex;justify-content: space-between">
<text>{{ item?.name }}</text>
@ -36,10 +36,12 @@ import Taro from "@tarojs/taro";
import './myproject.scss'
const myProjectList = ref<MyProjectList[]>()
const number = ref(0)
const getMyServiceProject = async () => {
const resp = await api.get<MyProjectList[]>(`/projectManageIndex/getMyServiceProject`)
myProjectList.value = resp.data
console.log(myProjectList.value.length)
number.value = resp.data.length
}
const projectClick = (items: ServiceProjectList, name: string) => {

View File

@ -110,21 +110,22 @@
</view>
</template>
<script setup lang="ts">
import Taro, {useLoad, useDidShow} from "@tarojs/taro";
import Taro, {useDidShow, useLoad} from "@tarojs/taro";
import './projectDetails.scss'
import {ref} from "vue";
import api from "@/request/index";
import * as dayjs from 'dayjs'
const serviceProjectDetails = ref()
const nameValue = ref('')
const projectData = ref<Records[]>([])
const content = ref<Records>({} as any)
//
const confirmVisible = ref(false);
const detailVisible = ref(false)
useLoad(async (options: MyProjectList) => {
nameValue.value = options.name
serviceProjectDetails.value = await JSON.parse(options.item)
@ -209,7 +210,6 @@ const dialogOk = async () => {
})
initServiceProjectSecurityUserList()
}
//
const detail = (item) => {
detailVisible.value = true
@ -220,6 +220,9 @@ const projectEdit = (item) => {
Taro.navigateTo({url: `/subPages/pages/form/form?item=${JSON.stringify(params)}`})
}
</script>
<style scoped lang="scss">