Explorar el Código

commit: 添加上传图片表单 添加api接口

lzm hace 3 meses
padre
commit
7971a9434b

+ 14 - 1
common/config/application-api.js

@@ -35,4 +35,17 @@ export const postCareComplete = (parmas, config = {}) => http.post('/dev-api/car
 //查询全部公司 
 export const getCompanyList = (data) =>http.get('/dev-api/care/companies/listAll', data)
 //查询公司的护理人员
-export const getCompanyNursesList = (data) => http.get('/dev-api/care/nurses/listCompanyNurses', data)
+export const getCompanyNursesList = (data) => http.get('/dev-api/care/nurses/listCompanyNurses', data)
+
+//图片上传
+export const uploadImg = (params, config = {}) => http.post(`/dev-api/care/clocks/upload`,params, config);
+
+//获取图片上传的数量
+export const getImgNumber = (data) => http.get(`/dev-api/system/workConfig/type/${data.key??'need_img_num'}`, data);
+
+//添加护理打卡记录
+export const addCareClocks = (params, config = {}) => http.post(`/dev-api/care/clocks`, params, config);
+//修改护理打卡记录
+export const updateCareClocks = (params, config = {}) => http.put(`/dev-api/care/clocks`, params, config);
+//删除护理打卡记录
+export const delCareClocks = (data) => http.delete(`/dev-api/care/clocks/${data.id}`);

+ 134 - 170
pages/subpack/pages/application/componenets/page4.vue

@@ -1,55 +1,28 @@
 <template>
-	<view class="page1-warp">
-		<up-form labelPosition="top" :model="formData" ref="formRef">
-			<!-- 'wait_assign_company,wait_assign_nurse'.includes(item.status) -->
-			<up-form-item label="指派任务" labelWidth="auto" v-if="item.status && item.status.includes('wait_assign')" required>
-				<view class="flex-row justify-between align-center" style="width: 100%;">
-					<view v-if="item.status === 'wait_assign_company'">
-						<view class="">护理公司</view>
-						<view class="flow-tips-content" :class="{'theme-color': chooseInfo.name}">
-							{{chooseInfo.name??'请选择护理公司'}}
-						</view>
-					</view>
-					<view v-if="item.status === 'wait_assign_nurse'">
-						<view class="flow-tips">护理人员</view>
-						<view class="flow-tips-content" :class="{'theme-color': chooseInfo.name}">
-							{{chooseInfo.name??'请选择护理人员'}}
-						</view>
-					</view>
-					<view class="icon-box" @tap="goToChoosePage">
-						<up-icon v-if="!chooseInfo.name" size="28" class="up-icon" name="plus" />
-						<up-avatar v-else size="80rpx" :text="nameText(chooseInfo.name)" shape="square"
-							bgColor="#305BFF" />
+	<view class="page4-warp">
+		<view class="page4-form">
+			<up-form labelPosition="top" :model="formData" :rules="formRule" ref="formRef">
+				<up-form-item label="护理时间" labelWidth="auto" labelPosition="left" required prop="nursingTime">
+					<up-input v-model="formData.nursingTime" disabled disabledColor="#ffffff" border="bottom"
+						placeholder="请选择打卡时间" @tap="showTime = true;" />
+				</up-form-item>
+				<up-form-item :label="`护理打卡(0/${imgNum})`" labelWidth="auto" prop="img" required>
+					<view class="flex-row justify-between align-center" style="width: 100%;">
+						<up-upload :fileList="fileList" multiple :sizeType="['compressed']" :capture="['camera']"
+							@afterRead="afterRead" @delete="deletePic" />
 					</view>
+				</up-form-item>
+				<up-form-item label="备注" labelWidth="auto">
+					<up-textarea v-model="formData.remark" placeholder="请输入您的打卡备注" count />
+				</up-form-item>
+			</up-form>
+		</view>
 
-				</view>
-			</up-form-item>
-			<!-- <up-form-item label="护理打卡(0/6)" labelWidth="auto" required>
-				<view class="flex-row justify-between align-center" style="width: 100%;">
-					<u-upload :sizeType="['compressed']" :capture="['camera']" />
-				</view>
-			</up-form-item>
-			<up-form-item label="护理评分" labelWidth="auto" required>
-				<view class="flex-row justify-between align-center" style="width: 100%;">
-					<up-rate v-model="formData.score" activeIcon="heart-fill" inactiveIcon="heart" count="10"
-						:size="25" />
-					<view>{{formData.score*10}}</view>
-				</view>
-			</up-form-item> -->
-			<up-form-item label="审批意见" labelWidth="auto" required>
-				<up-textarea v-model="formData.remark" placeholder="请输入您的审批意见" count />
-			</up-form-item>
-		</up-form>
+		<u-datetime-picker :show="showTime" v-model="timeValue" mode="datetime" closeOnClickOverlay
+			@cancel="showTime = false" @close="showTime = false" @confirm="timeConfirm" />
 		<view class="btn-box">
 			<view class="flex-row ">
-				<up-button class="up-button" v-if="isShowBack" type="error" 
-				style="width: 250rpx;" @tap="checkTap(2)">‌退回</up-button>
-				<view v-if="isShowBack" class="btn-place"></view>
-				<up-button v-if='item.status && item.status.includes("wait_assign")' 
-				class="up-button" type="primary" @tap="assignTap"
-				>指派</up-button>
-				<up-button v-else class="up-button" type="primary"
-				 @tap="checkTap(1)">通过</up-button>
+				<up-button class="up-button" type="primary" @tap="checkTap">确定打卡</up-button>
 			</view>
 		</view>
 	</view>
@@ -59,7 +32,8 @@
 	import {
 		ref,
 		reactive,
-		computed
+		computed,
+		onMounted
 	} from 'vue';
 	import {
 		useStore
@@ -69,12 +43,12 @@
 		onUnload
 	} from "@dcloudio/uni-app"
 	import {
-		postCareAssign,
-		postCareCheck,
-		postCareComplete
+		getImgNumber,
+		addCareClocks,
+		uploadImg
 	} from '@/common/config/application-api.js'
-	
-	
+
+
 	const store = useStore();
 	const props = defineProps({
 		item: {
@@ -84,127 +58,131 @@
 			}
 		}
 	})
-	// 使用 ref 创建响应式引用  
+
+	const showTime = ref(false);
+	const timeValue = ref(new Date().getTime());
 	const formRef = ref(null);
+	const fileList = ref([]);
 	const formData = reactive({
-		remark: '', //审核意见
-		careCompany: '', //护理公司
-		careStaff: '', //护理人员
-		score: 1, //评分
+		img: [],
+		remark: '', //意见
+		nursingTime: '', //护理时间
 	})
 	const formRule = reactive({
-		remark: ''
-	})
-	const chooseInfo = ref({}); //选择的数据
-	
-	//名字取值
-	const nameText = computed(() => {
-		return (name) => {
-			name = name.replaceAll('南充','').replaceAll('服务','').replaceAll('养老', '').replaceAll('有限公司', '');
-			let index = name.length - 2;
-			index = index >= 0 ? index : 0;
-			return name.substring(index);
-		};
+		nursingTime: [{
+			required: true,
+			message: '请选择护理时间',
+			trigger: ['blur', 'change']
+		}],
+		img: [{
+			required: true,
+			message: '请上传图片',
+			trigger: ['blur', 'change']
+		}]
 	})
+	//点击打卡
+	function checkTap() {
+		formRef.value.validate().then(res => {
+			if(res) uni.$u.toast('校验通过')
+			else uni.$u.toast('校验失败');
+		})
+	}
 
-	//跳转选择的页面
-	function goToChoosePage() {
-		let params = {
-			maxCount: 1
-		}
-		if (chooseInfo.value.name) {
-			params.dufaultIds = chooseInfo.value.id + "";
-		}
-		
-		if(props.item.status === 'wait_assign_company') {
-			params.pageType = 'company';
-		}else if(props.item.status === 'wait_assign_nurse') {
-			params.pageType = 'user';
-		}
-		uni.$u.route('/pages/subpack/pages/application/choose', params)
+	function timeConfirm(e) {
+		// console.log('timeConfirm=>', e);
+		timeValue.value = e.value;
+		formData.nursingTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
+		showTime.value = false;
 	}
-	
-	//是否显示退回按钮
-	function isShowBack(){
-		let user = store.state.vuex_user;
-		return user.roles.includes('area') && props.item.status == 'wait_check';
+	//删除图片
+	function deletePic(event) {
+		fileList.value.splice(event.index, 1);
 	}
-	
-	//点击处理指派
-	function assignTap(){
-		if(!chooseInfo.value.id) {
-			uni.$u.toast('请选择指派的公司');
-			return false;
-		}
-		let checkParams = {...props.item};
-		
-		if(props.item.status === 'wait_assign_nurse') {
-			checkParams.status = 'assigned';
-			checkParams.nurseId = chooseInfo.value.id;
-		} else {
-			checkParams.status = 'wait_assign_nurse';
-			checkParams.companyId = chooseInfo.value.id;
-		}
-		checkParams.assignNurseRemark = formData.remark;
-		postCareAssign(checkParams).then(res=>{
-			uni.$u.toast('指派成功');
-			uni.$emit('renderApplyList');
-			setTimeout(()=>{
-				uni.$u.route({
-					type: 'back'
+	//新增图片
+	async function afterRead(event) {
+		// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
+		let lists = [].concat(event.file);
+		let fileListLen = fileList.value.length;
+		lists.map((item) => {
+			fileList.value.push({
+				...item,
+				status: "uploading",
+				message: "上传中",
+			});
+		});
+		for (let i = 0; i < lists.length; i++) {
+			const result = await uploadFilePromise(lists[i].url);
+			let item = fileList.value[fileListLen];
+			fileList.value.splice(
+				fileListLen,
+				1,
+				Object.assign(item, {
+					status: "success",
+					message: "",
+					url: result,
 				})
-			}, 1000)
-		})
-	}
-	//点击处理审核 1 审核  2 退回
-	function checkTap(type = 2){
-		if(!formData.remark){
-			uni.$u.toast('审核理由不能为空');
-			return false;
+			);
+			fileListLen++;
 		}
-		let checkParams = {...props.item};
-		checkParams.status = 'wait_assign_company';
-		if(type == 2) {
-			checkParams.status = 'disagree';
-		}
-		checkParams.auditReason = formData.remark;
-		postCareCheck(checkParams).then(res=>{
-			uni.$u.toast('审核成功');
-			uni.$emit('renderApplyList');
-			setTimeout(()=>{
-				uni.$u.route({
-					type: 'back'
-				})
-			}, 1000)
-		})
+	}
+/**
+ * TODO 上传图片有问题,上传的时间是选择 还是当前时间 
+ * 如果今天上传的护理记录  是否还可以继续上传 一天上传几次护理打卡记录
+ */ 
+
+	//上传图片
+	function uploadFilePromise(url) {
+		return new Promise((resolve, reject) => {
+			let a = uni.uploadFile({
+				url: "http://127.0.0.1/dev-api/care/clocks/upload", // 仅为示例,非真实的接口地址
+				filePath: url,
+				name: "file",
+				formData: {
+					applyId: 12,
+				},
+				success: (res) => {
+					console.log('uploadImg=>', res);
+					resolve(res.data.data);
+				},
+			});
+			
+			/* uploadImg({
+				filePath: url,
+				name: 'file'
+			}).then(res => {
+				console.log('uploadImg=>', res);
+				resolve(res.data.data);
+			}) */
+		});
 	}
 
-	onLoad(() => {
-		uni.$on('choose', ({
-			checkList
-		}) => {
-			if (checkList && checkList.length > 0) chooseInfo.value = checkList[0];
+	//获取打卡图片数量
+	const imgNum = ref(0);
+
+	function getNumber() {
+		getImgNumber({
+			params: {
+				key: 'need_img_num'
+			}
+		}).then(res => {
+			imgNum.value = res.number;
 		})
-	})
-	onUnload(() => {
-		uni.$off('choose')
+	}
+	
+	onMounted(()=>{
+		getNumber();
 	})
 </script>
 
 <style lang="scss" scoped>
-	.page1-warp {
-		padding: 24rpx 0;
+	.page4-warp {
+		padding: 30rpx;
 	}
 
-	.flow-tips {
-		font-size: 30rpx;
-		color: #222222;
-	}
-
-	.flow-tips-content {
-		font-size: 24rpx;
-		margin-top: 4rpx;
-		color: rgba(34, 34, 34, .3);
+	.page4-form {
+		padding: 30rpx;
+		border-radius: 10rpx;
+		background-color: #fff;
 	}
 
 	.btn-box {
@@ -213,21 +191,7 @@
 		position: fixed;
 		bottom: calc(50px + var(--status-bar-height));
 		/* bottom: 50px; */
+		left: 0;
 		width: 690rpx;
-
-		.btn-place {
-			width: 100rpx;
-		}
-	}
-
-	.theme-color {
-		color: #305BFF !important;
-	}
-
-	.icon-box {
-		overflow: hidden;
-		width: 80rpx;
-		height: 80rpx;
-
 	}
 </style>

+ 11 - 6
pages/subpack/pages/application/info.vue

@@ -7,10 +7,10 @@
 		</view> -->
 		<!-- 加载组件 -->
 		<view>
-			<Page1 class="page1" :item="appItem" v-show="judgePageIsShow('page2')" />
-			<Page2 class="page2" :item="appItem" v-show="judgePageIsShow('page1')" />
-			<Page3 class="page3" :item="appItem" v-show="judgePageIsShow('page3')" />
-			<Page4 class="page4" :item="appItem" v-show="judgePageIsShow('page4')" />
+			<Page1 class="page1" :item="appItem" v-if="judgePageIsShow('page2')" />
+			<Page2 class="page2" :item="appItem" v-if="judgePageIsShow('page1')" />
+			<Page3 class="page3" :item="appItem" v-if="judgePageIsShow('page3')" />
+			<Page4 class="page4" :item="appItem" v-if="judgePageIsShow('page4')" />
 		</view>
 		<u-tabbar :value="tabbarKey" v-if="judgeTabbarIsShow('tabbar')" @change="tabbarChange" fixed placeholder safeAre
 			aInsetBottom>
@@ -32,6 +32,7 @@
 	import Page1 from './componenets/page1.vue';
 	import Page2 from './componenets/page2.vue';
 	import Page3 from './componenets/page3.vue';
+	import Page4 from './componenets/page4.vue';
 	import {
 		onLoad,
 		onShow
@@ -54,7 +55,9 @@
 	const handleTitle = computed(() => {
 		if (tabbarKey.value === 'page2') return '特困审批';
 		else if (tabbarKey.value === 'page1') return '基本信息';
-		else return '申请进度';
+		else if(tabbarKey.value === 'page3') return '申请进度';
+		else if(tabbarKey.value === 'page4') return '护理打卡';
+		return '特困表单';
 	})
 	const roleAuthStatus = {
 		village: ['no_check'],
@@ -77,6 +80,7 @@
 			if (dealStatus == 'complete') judgeBool = false;
 			else if (roles.includes('village')) judgeBool = false;
 			else if (!roleAuthArray.includes(status)) judgeBool = false;
+			else if (roles.includes('nurse')) judgeBool = false;
 			//流程记录页面只有除了护理人员之外的人看到	
 		} else if (pageName === 'page3') {
 			if (roles.includes('nurse')) judgeBool = false;
@@ -100,6 +104,7 @@
 			if (dealStatus == 'complete') return false;
 			else if (roles.includes('village')) return false;
 			else if (!roleAuthArray.includes(status)) return false;
+			else if (roles.includes('nurse')) return false;
 		} else if (pageName === 'page3') {
 			if (roles.includes('nurse')) return false;
 		} else if (pageName === 'page4') {
@@ -113,7 +118,7 @@
 			id: id.value
 		}).then(res => {
 			appItem.value = res;
-			console.log('getCareInfo=>', res);
+			// console.log('getCareInfo=>', res);
 		})
 	}
 	onLoad((params) => {