增加人脸管理修改功能

This commit is contained in:
ctw committed 2025-01-03 09:15:55 +08:00
1 parent dbaf426930
commit a32cb2d4a3
9 files changed
+170 -154

No files matched your search

+2 -1
View File
@@ -2,7 +2,8 @@
# VITE_APP_DEV_SERVICE =http://123.156.230.15:8089/app-api
# VITE_APP_DEV_SERVICE =http://123.156.228.134:48080/app-api
VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/app-api
# VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/app-api
VITE_APP_DEV_SERVICE = http://192.168.101.24:48080/app-api
# ******************** end 开发环境 end ********************
+44 -40
View File
@@ -1,10 +1,11 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { ref, reactive, nextTick } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { isEmpty } from "radash";
import { hooks, router } from "@@/index";
import { applyApi } from "@@/api";
import { applyApi, faceApi } from "@@/api";
const uploadPhotoBaseUrl = import.meta.env.VITE_APP_DEV_SERVICE;
const state = reactive<any>({
detailType: "add",
@@ -12,38 +13,44 @@ const state = reactive<any>({
detail: null,
});
const applyForm = reactive<any>({
faceImg: "",
faceImg: [],
});
const uploadFileUrl = ref<any>("");
const applyFormRules = reactive<any>({
count: [
{ required: true, message: "请输入申请数量" },
{ required: true, min: 1, message: "最少申请1张" },
{ required: true, max: 20, message: "最多申请20张" },
faceImg: [
{ required: true, message: "请上传人脸图片" },
{ required: true, min: 1, message: "最少上传1张人脸图片" },
{ required: true, max: 10, message: "最多上传10张人脸图片" },
],
});
onLoad((options: any) => {
onLoad(async (options: any) => {
const { type, id } = options;
if (!isEmpty(type)) state.detailType = type;
if (!isEmpty(id)) state.detailId = id;
if (type === "view") {
getDetail();
if (type === "edit") {
applyForm.faceImg = [];
uploadFileUrl.value = "";
await getDetail();
}
});
onShow(() => {});
const getDetail = async () => {
if (isEmpty(state.detailId)) return;
const _pa = { id: state.detailId };
const { data } = await applyApi.strideDetail(_pa);
const { data } = await faceApi.get({ id: state.detailId });
if (!isEmpty(data)) {
state.detail = data;
applyForm.faceImg = [data.faceImg];
uploadFileUrl.value = data.faceImg;
}
};
applyForm.count = data.count;
if (isEmpty(data.remark)) {
applyForm.remark = "无";
} else {
applyForm.remark = data.remark;
}
const beforeComplete = (uploadFile: any) => {
if (JSON.parse(uploadFile.data).code == 0) {
uploadFileUrl.value = JSON.parse(uploadFile.data).data;
return true;
} else {
uploadFileUrl.value = "";
return false;
}
};
@@ -51,18 +58,17 @@ const applyFormRef = ref<any>(null);
const doSubmit = async () => {
applyFormRef.value.submit();
const { isPass } = applyFormRef.value.validate();
if (!isPass) return;
const range = applyForm.displayTimeRange;
if (!isPass || !uploadFileUrl.value) return;
try {
uni.showLoading({ title: "申请中...", mask: false });
const _pa = {
count: applyForm.count,
remark: applyForm.remark,
};
const { data, code }: any = await applyApi.strideApply(_pa);
uni.showLoading({ title: "提交中...", mask: false });
const { data, code }: any =
state.detailType == "edit"
? await faceApi.put({ faceImg: uploadFileUrl.value, id: state.detailId })
: await faceApi.create({ faceImg: uploadFileUrl.value });
if (code != 0) throw new Error();
uni.hideLoading();
uni.showToast({ title: "申请成功", icon: "none" });
uni.showToast({ title: "提交成功", icon: "none" });
router.back();
} catch (error) {
console.error(error);
@@ -72,21 +78,19 @@ const doSubmit = async () => {
</script>
<template>
<crud-layout title="人脸上传" bg="/static/page/blue-bg.png">
<crud-layout :title="state.detailId ? '修改人脸' : '人脸上传'" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<view class="card p-x-30rpx p-y-40rpx">
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<!-- <tm-form-item name="count" label="申请数量" :showBottom="false">
<tm-input
v-model="applyForm.count"
type="number"
:disabled="state.detailType == 'view'"
:showClear="state.detailType != 'view'"
placeholder="请输入申请数量.."
/>
</tm-form-item> -->
<tm-form-item name="faceImg" label="人脸图片" :required="false" :showBottom="false">
<tm-upload-photo v-model="applyForm.faceImg" />
<view class="h-10rpx" />
<tm-upload-photo
:rangUrl="applyForm.faceImg[0]"
:beforeComplete="beforeComplete"
v-model="applyForm.faceImg"
:maxCount="1"
:url="uploadPhotoBaseUrl + '/infra/file/upload'"
/>
</tm-form-item>
</tm-form>
</view>
@@ -95,7 +99,7 @@ const doSubmit = async () => {
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit"
>
提交
{{ state.detailId ? "修改" : "提交" }}
</view>
</crud-layout>
</template>
+20 -1
View File
@@ -19,7 +19,10 @@
<view class="flex items-center justify-between second-text-26">
<img class="w-100rpx h-100rpx rounded-50rpx" :src="v.faceImg" />
<text class="font-600">{{ v.username }}</text>
<text class="botder_btn float-right">删除</text>
<text class="botder_btn" @click="doEdit(v.id)">修改</text>
<tm-modal title="确定删除吗?" height="auto" @confirm="doDel(v.id)">
<template v-slot:trigger><text class="botder_btn">删除</text></template>
</tm-modal>
</view>
</view>
@@ -67,6 +70,22 @@ const doAdd = () => {
router.jump("/pages/humanFace/apply");
};
const doEdit = (id: string) => {
router.jump("/pages/humanFace/apply", { type: "edit", id });
};
const doDel = (id: string) => {
faceApi.del({ id }).then(
() => {
uni.showToast({ title: "删除成功", icon: "none" });
pageRef.value.reload(true);
},
() => {
uni.showToast({ title: "删除失败", icon: "none" });
}
);
};
const doCard = (v: any) => {
// if (v.status == 2) {
// router.jump("/pages/apply/stride-items", { id: v.id });
+1 -1
View File
@@ -14,7 +14,7 @@ const data = {
{ text: "外来人员就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/foreign-list" },
{ text: "跨单位就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/stride-list" },
{ text: "人脸管理", icon: "/static/icon/login.png", router: "/pages/humanFace/list" },
{ text: "测试登陆", icon: "/static/icon/login.png", router: "/pages/test/login" },
{ text: "测试登录", icon: "/static/icon/login.png", router: "/pages/test/login" },
],
};
+64 -72
View File
@@ -2,94 +2,86 @@
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { hooks, constant, router } from "@@/index"
import { userApi } from "@@/api"
import { hooks, constant, router } from "@@/index";
import { userApi } from "@@/api";
const data = {
}
const data = {};
const state = reactive<any>({
userInfo: null,
})
userInfo: null,
});
const applyForm = reactive<any>({
username: "",
password: "",
})
username: "",
password: "",
});
const applyFormRules = reactive<any>({
username: [
{ required: true, message: '请输入用户名' }
],
password: [
{ required: true, message: '请输入密码' }
],
})
username: [{ required: true, message: "请输入用户名" }],
password: [{ required: true, message: "请输入密码" }],
});
onLoad(() => {
})
onLoad(() => {});
onShow(() => {
const userInfoKey = constant.storageConstant.USERINFO
state.userInfo = uni.getStorageSync(userInfoKey)
})
const userInfoKey = constant.storageConstant.USERINFO;
state.userInfo = uni.getStorageSync(userInfoKey);
});
const applyFormRef = ref<any>(null)
const applyFormRef = ref<any>(null);
const doSubmit = async () => {
applyFormRef.value.submit()
const { isPass } = applyFormRef.value.validate()
if (!isPass) return
const tokenKey = constant.storageConstant.TOKEN
const userInfoKey = constant.storageConstant.USERINFO
uni.showLoading({ title: '登录中...', mask: true });
// try {
const _pa = { ...applyForm }
const res = await userApi.testLogin(_pa)
console.log(res)
if (res.code!=0){
uni.showToast({ title: res.msg+'。登录失败,请重新登录', icon: "error" });
return
}
uni.setStorageSync(tokenKey, res.data)
const { data: userData } = await userApi.userInfo();
uni.setStorageSync(userInfoKey, userData)
// } catch (e) {
// console.log(222)
// console.log(e);
// }
uni.hideLoading()
uni.showToast({ title: '登录成功', icon: "none" });
router.back()
}
applyFormRef.value.submit();
const { isPass } = applyFormRef.value.validate();
if (!isPass) return;
const tokenKey = constant.storageConstant.TOKEN;
const userInfoKey = constant.storageConstant.USERINFO;
uni.showLoading({ title: "登录中...", mask: true });
// try {
const _pa = { ...applyForm };
const res = await userApi.testLogin(_pa);
console.log(res);
if (res.code != 0) {
uni.showToast({ title: res.msg + "。登录失败,请重新登录", icon: "error" });
return;
}
uni.setStorageSync(tokenKey, res.data);
const { data: userData } = await userApi.userInfo();
uni.setStorageSync(userInfoKey, userData);
// } catch (e) {
// console.log(222)
// console.log(e);
// }
uni.hideLoading();
uni.showToast({ title: "登录成功", icon: "none" });
router.back();
};
</script>
<template>
<crud-layout title="登陆" bg="/static/page/blue-bg.png">
<crud-layout title="登录" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<view class="card p-x-30rpx p-y-40rpx">
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="username" label="用户名" :showBottom="false">
<tm-input v-model="applyForm.username" placeholder="请输入用户名.." />
</tm-form-item>
<view class="h-30rpx" />
<view class="card p-x-30rpx p-y-40rpx">
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="username" label="用户名" :showBottom="false">
<tm-input v-model="applyForm.username" placeholder="请输入用户名.." />
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="password" label="验证码" :showBottom="false">
<tm-input password showEye v-model="applyForm.password" placeholder="请输入用户密码.." />
</tm-form-item>
</tm-form>
</view>
<view v-if="state.detailType != 'view'"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit">
登陆
</view>
</crud-layout>
<tm-form-item name="password" label="验证码" :showBottom="false">
<tm-input password showEye v-model="applyForm.password" placeholder="请输入用户密码.." />
</tm-form-item>
</tm-form>
</view>
<view
v-if="state.detailType != 'view'"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit"
>
登录
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
:deep() {
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
}
</style>
+36 -36
View File
@@ -10,40 +10,40 @@ export default {
showLoading: false,
},
}),
// classify: (params: any) =>
// request({
// url: `/onlinefood/category/listFood`,
// method: "GET",
// params,
// custom: {
// showLoading: false,
// },
// }),
// product: (params: any) =>
// request({
// url: `/onlinefood/category/list`,
// method: "GET",
// params,
// custom: {
// showLoading: false,
// },
// }),
// getShopCar: (params: any) =>
// request({
// url: `/hardware/car/get`,
// method: "GET",
// params,
// custom: {
// showLoading: false,
// },
// }),
// updateShopCar: (data: any) =>
// request({
// url: `/hardware/car/save-or-upload`,
// method: "POST",
// data,
// custom: {
// showLoading: false,
// },
// }),
del: (params: any) =>
request({
url: `/sys/user/face-delete`,
method: "DELETE",
params,
custom: {
showLoading: false,
},
}),
create: (data: any) =>
request({
url: `/sys/user/face-create`,
method: "POST",
data,
custom: {
showLoading: false,
},
}),
get: (params: any) =>
request({
url: `/sys/user/face-get`,
method: "GET",
params,
custom: {
showLoading: false,
},
}),
put: (data: any) =>
request({
url: `/sys/user/face-update`,
method: "PUT",
data,
custom: {
showLoading: false,
},
}),
};
@@ -18,7 +18,7 @@
</view>
</template>
<script setup lang="ts">
import { ref, computed, onMounted, onBeforeUnmount, watch, PropType, getCurrentInstance, onUpdated, nextTick } from 'vue';
import { ref, computed, onMounted, onBeforeUnmount, watch, type PropType, getCurrentInstance, onUpdated, nextTick } from 'vue';
import { arrayNumberValid, arrayNumberValidByStyleMP, covetUniNumber, arrayNumberValidByStyleBorderColor, linearValid, getUnit, getUid } from "../../libs/tool";
import { getDefaultColor, getDefaultColorObj, getOutlineColorObj, getTextColorObj, getThinColorObj } from "../../libs/colors";
import { useTmConfig } from "../../libs/config";
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, computed, onMounted, onBeforeUnmount, watch, PropType, getCurrentInstance, onUpdated, nextTick } from 'vue';
import { ref, computed, onMounted, onBeforeUnmount, watch, type PropType, getCurrentInstance, onUpdated, nextTick } from 'vue';
import { arrayNumberValid, arrayNumberValidByStyleMP, covetUniNumber, arrayNumberValidByStyleBorderColor, linearValid, getUnit, getUid } from "../../libs/tool";
import { getDefaultColor, getDefaultColorObj, getOutlineColorObj, getTextColorObj, getThinColorObj } from "../../libs/colors";
import { useTmConfig } from "../../libs/config";
@@ -40,7 +40,7 @@
</template>
<script setup lang="ts">
import { PropType, computed, onMounted, ref, shallowRef, watch } from 'vue'
import { type PropType, computed, onMounted, ref, shallowRef, watch } from 'vue'
import { covetUniNumber } from '../../libs/tool';
import { TMUPLOAD_PHOTO_STATUS } from '../../interface';
import { useTmConfig } from "../../libs/config";