ソースを参照

新增申请修改

shuchang 3 ヶ月 前
コミット
e4bda74cff

+ 2 - 0
common/config/api.js

@@ -10,6 +10,8 @@ export const loginUrl = (data) => http.get('/dev-api/api/wechat/login', data);
 export const bindInfoUrl = (data) => http.get('/dev-api/api/wechat/bindPhone', data);
 // 提交
 export const applyUrl = (params, config = {}) => http.post('/dev-api/care/applications', params, config);
+// 修改
+export const applyModifyUrl = (params, config = {}) => http.put('/dev-api/care/applications', params, config);
 // 获取申请人列表
 export const getPersonListUrl = (data) => http.get('/dev-api/care/persons/list', data);
 // 获取所在医院列表

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

@@ -31,7 +31,8 @@
 	import Page2 from './componenets/page2.vue';
 	import Page3 from './componenets/page3.vue';
 	import {
-		onLoad
+		onLoad,
+		onShow
 	} from '@dcloudio/uni-app'
 	import {
 		getCareInfo
@@ -111,9 +112,12 @@
 	onLoad((params) => {
 		if (params.id) {
 			id.value = params.id;
-			initData();
+			// initData();
 		}
 	})
+	onShow(() => {
+		initData();
+	})
 </script>
 <style>
 	page {

+ 1 - 2
pages/subpack/pages/application/list.vue

@@ -23,8 +23,7 @@
 		reactive,
 		computed,
 		getCurrentInstance,
-		onMounted,
-		computed
+		onMounted
 	} from 'vue';
 	//import { onLoad } from '@dcloudio/uni-app'
 	import applyItem from '../../components/apply/apply-item.vue';

+ 96 - 23
pages/subpack/pages/apply/apply.vue

@@ -25,7 +25,7 @@
 						</view>
 						<view class="flex-row align-center justify-between mt-4">
 							<text class="font text-black2">首选护理人员性别</text>
-							<text class="font text-black2" @click="chooseGender">{{formData.sex === '0'?'女':'男'}}</text>
+							<text class="font text-black2" @click="chooseGender">{{formData.sex === '1'?'女':'男'}}</text>
 						</view>
 						<view class="flex-row align-center justify-between mt-4">
 							<text class="font text-black2">所在医院</text>
@@ -68,11 +68,16 @@
 <script>
 	import dayjs from 'dayjs'
 	import {
-		applyUrl
-	} from '@/common/config/api.js'
+		applyUrl,
+		applyModifyUrl
+	} from '@/common/config/api.js';
+	import {
+		getCareInfo
+	} from '@/common/config/application-api.js'
 	export default {
 		data() {
 			return {
+				formId: '',
 				formData: {
 					personId: '',
 					name: '请选择申请人',
@@ -85,7 +90,16 @@
 				}
 			}
 		},
-		onLoad() {
+		onLoad(options) {
+
+			if (options.id) {
+				this.formId = options.id;
+				this.getApplyInfo();
+			} else {
+				this.formId = '';
+			}
+
+			// 监听器
 			uni.$on('personChoose', (e) => {
 				console.log(e);
 				this.formData.personId = e.id;
@@ -102,6 +116,27 @@
 			uni.$off('hospitalChoose');
 		},
 		methods: {
+			getApplyInfo() {
+				getCareInfo({
+						id: this.formId
+					})
+					.then(res => {
+						console.log('申请详情', res);
+						this.formData = {
+							personId: res.personId,
+							name: res.personName,
+							demand: res.careNeeds,
+							sex: res.nurseGender,
+							hospital: res.hospital,
+							address: res.address,
+							dayCount: res.careDays,
+							remark: res.remark
+						}
+					})
+					.catch(err => {
+						console.log('申请详情Err', err);
+					})
+			},
 			goChooseHospital() {
 				uni.navigateTo({
 					url: '/pages/subpack/pages/choose-hospital/choose-hospital'
@@ -115,7 +150,7 @@
 			chooseGender() {
 				uni.showActionSheet({
 					title: '首选护理人员性别',
-					itemList: ['女', '男'],
+					itemList: ['男', '女'],
 					success: (res) => {
 						// console.log('选择了第' + (res.tapIndex) + '个选项');
 						this.formData.sex = res.tapIndex + '';
@@ -128,7 +163,10 @@
 
 			apply() {
 				uni.showLoading();
-				applyUrl({
+				let params = {};
+				if (this.formId) {
+					params = {
+						applyId: this.formId,
 						address: this.formData.address,
 						applyDate: dayjs().format('YYYY-MM-DD'),
 						careDays: this.formData.dayCount,
@@ -138,25 +176,60 @@
 						personId: this.formData.personId,
 						personName: this.formData.name,
 						remark: this.formData.remark
-					})
-					.then(res => {
-						uni.hideLoading();
-						uni.showModal({
-							title: '提示',
-							content: `提交成功`,
-							showCancel: false,
-							confirmText: '返回首页',
-							success: (e) => {
-								if (e.confirm) {
-									uni.navigateBack()
+					}
+					applyModifyUrl(params)
+						.then(res => {
+							uni.hideLoading();
+							uni.showModal({
+								title: '提示',
+								content: `提交成功`,
+								showCancel: false,
+								confirmText: '返回',
+								success: (e) => {
+									if (e.confirm) {
+										uni.navigateBack()
+									}
 								}
-							}
+							})
 						})
-					})
-					.catch(err => {
-						uni.hideLoading();
-						console.log(err);
-					})
+						.catch(err => {
+							uni.hideLoading();
+							console.log(err);
+						})
+
+				} else {
+					params = {
+						address: this.formData.address,
+						applyDate: dayjs().format('YYYY-MM-DD'),
+						careDays: this.formData.dayCount,
+						careNeeds: this.formData.demand,
+						hospital: this.formData.hospital,
+						nurseGender: this.formData.sex,
+						personId: this.formData.personId,
+						personName: this.formData.name,
+						remark: this.formData.remark
+					}
+					applyUrl(params)
+						.then(res => {
+							uni.hideLoading();
+							uni.showModal({
+								title: '提示',
+								content: `提交成功`,
+								showCancel: false,
+								confirmText: '返回',
+								success: (e) => {
+									if (e.confirm) {
+										uni.navigateBack()
+									}
+								}
+							})
+						})
+						.catch(err => {
+							uni.hideLoading();
+							console.log(err);
+						})
+				}
+
 			},
 
 			handleSubmit() {

+ 2 - 2
utils/request/index.js

@@ -10,8 +10,8 @@ import {
 //  初始化请求配置
 const initRequest = (vm) => {
 	http.setConfig((defaultConfig) => {
-		// defaultConfig.baseURL = 'http://133.46.158.100' /* 根域名 */
-		defaultConfig.baseURL = 'http://tkhtest.natapp1.cc' /* 根域名 */
+		defaultConfig.baseURL = 'http://133.46.152.185' /* 根域名 */
+		// defaultConfig.baseURL = 'http://tkhtest.natapp1.cc' /* 根域名 */
 		// defaultConfig.baseURL = 'http://127.0.0.1' /* 根域名 */
 		defaultConfig = {
 			...defaultConfig,

+ 2 - 2
utils/request/interceptors.js

@@ -12,7 +12,7 @@ const requestInterceptors = (vm) => {
 			// 初始化请求拦截器时,会执行此方法,此时data为undefined,赋予默认{}
 			config.data = config.data || {}
 			// console.log(store.state);
-			console.log('config', config)
+			// console.log('config', config)
 			// config.header.token = store.state.vuex_token
 			config.header.Authorization = 'Bearer ' + store.state.vuex_token
 			if (config?.custom?.loading) {
@@ -30,7 +30,7 @@ const responseInterceptors = (vm) => {
 	 * @param {Object} http 
 	 */
 	http.interceptors.response.use((response) => {
-		console.log('response: ', response);
+		// console.log('response: ', response);
 		if (response?.config?.custom?.isCloseLoad) {
 			uni.hideLoading();
 		}