Przeglądaj źródła

情境编辑、复制创建。

lvxinghai 4 lat temu
rodzic
commit
716488d9e6

+ 10 - 5
pages/creatingSituations/components/checkMap.vue

@@ -56,6 +56,7 @@
 				checkRent: state => state.creatingSituations.checkRent,
 				condition: state => state.creatingSituations.condition,
 				needReload: state => state.creatingSituations.needReload,
+				editConfig: state => state.creatingSituations.editConfig
 			})
 		},
 		created:function(){
@@ -63,11 +64,15 @@
 		},
 		methods: {
 			init: function() {
-				if(this.needReload) { // 点击上一步不用获取数据
-					const {points} = this.checkRent.checkedItem;
-					const {depType} = this.condition;
-					if(!points) return;
-					let checkPointIds = points.map(({id})=> id);
+				const {checkedItem} = this.checkRent;
+				const {depType} = this.condition;
+				const {checkRent, condition, checkMap} = this.editConfig;
+				// 编辑的时候不用获取数据
+				if(this.editConfig && checkRent && depType === condition.depType && checkedItem.id === checkRent.checkedItem.id) {
+					this.commit('checkMap', checkMap);
+				} else if(this.needReload) { // 点击上一步不用获取数据
+					if(!checkedItem.points) return;
+					let checkPointIds = checkedItem.points.map(({id})=> id);
 					this.dispatch('checkDeptList', { depType, checkPointIds })
 						.then((data)=> {
 							if(data) {

+ 60 - 52
pages/creatingSituations/components/checkMapAdd.vue

@@ -1,5 +1,5 @@
 <template>
-	<view class="modal">
+	<tm-modal>
 		<scroll-view scroll-y="true" class="modal-body">
 			<view class="body-content">
 				<text class="top-title">选择要新增的单位</text>
@@ -23,7 +23,7 @@
 			<tm-simple-btn-group :options="botmBtnGroup"
 				v-on:callback="btnClick" ></tm-simple-btn-group>
 		</scroll-view>
-	</view>
+	</tm-modal>
 </template>
 
 <script>
@@ -44,8 +44,18 @@
 			},
 			...mapState({
 				checkMap: state => state.creatingSituations.checkMap,
+				condition: state => state.creatingSituations.condition,
 			})
 		},
+		created:function(){
+			if(this.checkMap.deptList.length === 0) {
+				// 获取新增单位
+				const {depType} =this.condition;
+				this.dispatch('deptList', { depType }).then((data)=>{
+					if(data) this.myCommit('deptList', data);
+				});
+			}
+		},
 		methods: {
 			changeChecked: function(id) {
 				this.checkedIds = arrFilter(id, this.checkedIds);
@@ -91,58 +101,56 @@
 </script>
 
 <style lang="less">
-	.modal {
-		.modal-body {
-			margin-top: 10%;
-			border-radius: 25rpx 25rpx 0 0;
-			padding: 35rpx 40rpx 75rpx;
-			width: 100%;
-			height: 90%;
-			font-size: 22.5rpx;
-			line-height: 33.75rpx;
-			color: #292C33;
-			background-color: #fff;
-			.top-title {
-				font-size: 30rpx;
-				line-height: 45rpx;
-			}
-			.list {
-				margin-top: 25rpx;
-				.item {
-					.item-title {
-						margin-bottom: 3.75rpx;
-						font-size: 25rpx;
-						line-height: 37.5rpx;
-						font-weight: bold;
-					}
-					.chidren {
+	.modal-body {
+		margin-top: 10%;
+		border-radius: 25rpx 25rpx 0 0;
+		padding: 35rpx 40rpx 75rpx;
+		width: 100%;
+		height: 90%;
+		font-size: 22.5rpx;
+		line-height: 33.75rpx;
+		color: #292C33;
+		background-color: #fff;
+		.top-title {
+			font-size: 30rpx;
+			line-height: 45rpx;
+		}
+		.list {
+			margin-top: 25rpx;
+			.item {
+				.item-title {
+					margin-bottom: 3.75rpx;
+					font-size: 25rpx;
+					line-height: 37.5rpx;
+					font-weight: bold;
+				}
+				.chidren {
+					display: flex;
+					flex-direction: row;
+					flex-wrap: wrap;
+					margin: 0 -17.5rpx;
+					.child {
+						position: relative;
 						display: flex;
 						flex-direction: row;
-						flex-wrap: wrap;
-						margin: 0 -17.5rpx;
-						.child {
-							position: relative;
-							display: flex;
-							flex-direction: row;
-							justify-content: center;
-							align-items: center;
-							margin: 10rpx 17.5rpx;
-							border-radius: 5rpx;
-							width: 200rpx;
-							height: 50rpx;
-							font-weight: 500;
-							background-color: #EBEDF2;
-							image {
-								position: absolute;
-								right: 0;
-								bottom: 0;
-								width: 25rpx;
-								height: 25rpx;
-							}
-							&.active {
-								color: #3377FF;
-								background-color: #E6EEFF;
-							}
+						justify-content: center;
+						align-items: center;
+						margin: 10rpx 17.5rpx;
+						border-radius: 5rpx;
+						width: 200rpx;
+						height: 50rpx;
+						font-weight: 500;
+						background-color: #EBEDF2;
+						image {
+							position: absolute;
+							right: 0;
+							bottom: 0;
+							width: 25rpx;
+							height: 25rpx;
+						}
+						&.active {
+							color: #3377FF;
+							background-color: #E6EEFF;
 						}
 					}
 				}

+ 3 - 9
pages/creatingSituations/components/checkPlan.vue

@@ -78,18 +78,12 @@
 	import { mapState } from "vuex";
 	import {dateHandle} from "../../../utils/dateHandle.js";
 	const {dateDiff, getNewData, todayDate, compare} = dateHandle;
-	const list = [
-		{id: 'week', value: 1, label: '每周', model: 7},
-		{id: 'month', value: 2, label: '每月', model: 30},
-		{id: 'twoMonth', value: 3, label: '每两月', model: 60},
-		{id: 'quarter', value: 4, label: '每季度', model: 90},
-		{id: 'halfAYear', value: 5, label: '每半年', model: 180},
-		{id: 'custom', value: 6, label: '天', model: null},
-	];
+	import {checkPlanList} from "./utils.js";
+	
 	export default {
 		data() {
 			return {
-				list
+				list: checkPlanList
 			}
 		},
 		computed: {

+ 10 - 1
pages/creatingSituations/components/checkRent.vue

@@ -44,6 +44,7 @@
 	import { mapState } from "vuex";
 	import {_stopPropagation} from "../../../utils/compatible.js";
 	import {arrFilter} from "../../../utils/arrFilter.js";
+	import {arrayEquality} from "./utils.js";
 	
 	export default {
 		data() {
@@ -56,10 +57,18 @@
 				checkRent: state => state.creatingSituations.checkRent,
 				condition: state => state.creatingSituations.condition,
 				needReload: state => state.creatingSituations.needReload,
+				editConfig: state => state.creatingSituations.editConfig
 			})
 		},
 		created:function(){
-			if(this.needReload) { // 点击上一步不用获取数据
+			// 编辑的时候不用获取数据
+			if(this.editConfig && arrayEquality(this.condition.conditionIds, this.editConfig.condition.conditionIds) && this.editConfig.checkRent) {
+				this.$store.commit({
+					type: 'creatingSituations/comChangeState', 
+					key: 'checkRent', 
+					data: this.editConfig.checkRent
+				});
+			} else if(this.needReload) { // 点击上一步不用获取数据
 				this.$store.dispatch({
 					type: 'creatingSituations/commActions',
 					key: 'checkGroupList',

+ 14 - 18
pages/creatingSituations/components/condition.vue

@@ -19,17 +19,28 @@
 
 <script>
 	import { mapState } from "vuex";
+	import {conditionOptions,editCondition} from "./utils.js";
+	
 	export default {
 		computed: {
 			...mapState({
 				condition: state => state.creatingSituations.condition,
 				needReload: state => state.creatingSituations.needReload,
-				theme: state => state.creatingSituations.theme
+				theme: state => state.creatingSituations.theme,
+				editConfig: state => state.creatingSituations.editConfig
 			})
 		},
 		created: function(){
-			if(this.needReload) // 点击上一步不用获取数据
+			// 编辑的时候不用获取数据
+			if(this.editConfig && this.editConfig.theme.id === this.theme.id) {
+				this.$store.commit({
+					type: 'creatingSituations/comChangeState', 
+					key: 'condition', 
+					data: this.editConfig.condition
+				});
+			} else if(this.needReload) {
 				this.getOptions(this.condition.depType);
+			}
 		},
 		methods: {
 			checkedHandle: function(keys) {
@@ -55,7 +66,7 @@
 							if(data.length > 0) {
 								this.myCommit('defaultOpen', [data[0].id]);
 							}
-							this.myCommit('options', this.optionsHandle(data));
+							this.myCommit('options', conditionOptions(data));
 						} 
 					});
 				} else {
@@ -66,21 +77,6 @@
 					});
 				}
 			},
-			/**
-			 * 增加树形数据字段,以适配公共组件
-			 * @param {Object} data
-			 */
-			optionsHandle: function(data) {
-				let options = data.map((item)=>{
-					return {
-						...item,
-						key: item.id,
-						label: item.name,
-						children: this.optionsHandle(item.child)
-					}
-				});
-				return options;
-			},
 			/**
 			 * 更新condition数据
 			 * @param {Object} key 要更新的属性

+ 2 - 9
pages/creatingSituations/components/theme.vue

@@ -21,15 +21,8 @@
 
 <script>
 	import { mapState } from "vuex";
-	const themeList = [{
-			id: 0, 
-			title: '个案追踪', 
-			des: '评价诊疗服务的内涵质量以及对各种诊疗规范、临床路径等的执行力',
-		},{
-			id: 1, 
-			title: '系统追踪', 
-			des: '评价对各种质量与安全管理制度与流程的执行力、医院服务的连贯性及多学科综合的服务能力',
-	}]
+	import {themeList} from "./utils.js";
+	
 	export default {
 		data() {
 			return {

+ 178 - 0
pages/creatingSituations/components/utils.js

@@ -0,0 +1,178 @@
+import {dateHandle} from "../../../utils/dateHandle.js";
+const {dateDiff} = dateHandle;
+/**
+ * 主题数据 
+ */
+export const themeList = [{
+		id: 0, 
+		title: '个案追踪', 
+		des: '评价诊疗服务的内涵质量以及对各种诊疗规范、临床路径等的执行力',
+	},{
+		id: 1, 
+		title: '系统追踪', 
+		des: '评价对各种质量与安全管理制度与流程的执行力、医院服务的连贯性及多学科综合的服务能力',
+}];
+// 查核计划里的数据
+export const checkPlanList = [
+		{id: 'week', value: 1, label: '每周', model: 7},
+		{id: 'month', value: 2, label: '每月', model: 30},
+		{id: 'twoMonth', value: 3, label: '每两月', model: 60},
+		{id: 'quarter', value: 4, label: '每季度', model: 90},
+		{id: 'halfAYear', value: 5, label: '每半年', model: 180},
+		{id: 'custom', value: 6, label: '天', model: null},
+	];
+/**
+ * 底部按钮数据
+ */
+export const normalBtnGroup = [
+	{id: 'pre', label: '上一步'},
+	{id: 'next', label: '下一步'}
+];
+export const btnGroupPlan1 = [
+	{id: 'pre', label: '上一步'},
+	{id: 'checkPlanCreate', label: '生成查核计划'}
+];
+export const btnGroupPlan2 = [
+	{id: 'checkPlanCallback', label: '返回'},
+	{id: 'next', label: '下一步'}
+];
+export const btnGroupSituationPreview = [
+	{id: 'pre', label: '上一步'},
+	{id: 'situationPreviewOK', label: '完成'}
+];
+/**
+ * 增加树形数据字段,以适配公共组件
+ * @param {Object} data
+ */
+export const conditionOptions = function(data) {
+	let options = data.map((item)=>{
+		return {
+			...item,
+			key: item.id,
+			label: item.name,
+			children: conditionOptions(item.child)
+		}
+	});
+	return options;
+}
+			
+/**
+ * 创建
+ * 构造条件提交结果
+ */
+export const optionsHandle = (arr, conditionIds) => {
+	let options = [...arr].map((item)=>{
+		return {
+			...item,
+			selectFlag: conditionIds.includes(item.id),
+			child: optionsHandle(item.child, conditionIds)
+		}
+	});
+	return options;
+}
+/**
+ * 构造查核组提交数据
+ */
+export const checkGroup = function({list, checkedItem}) {
+	let _list = [...list].map((ntem)=>{
+		return {
+			...ntem,
+			selectFlag: ntem.id === checkedItem.id ? true : false
+		}
+	});
+	return _list;
+}
+/**
+ * 构造查核地图提交数据
+ */
+export const checkDep = function(list) {
+	return list.map((item, i)=>{
+		return {
+			...item,
+			sort: i+1,
+			enableFlag: item.status === 'disable' ? false : true,
+		}
+	});
+}
+
+/**
+ * 编辑
+ * 条件树遍历,获取选中项的id
+ */
+export const initConditionIds = (arr, result) => {
+	arr.map((item)=>{
+		if(item.selectFlag || item.selectFlag === 'true') {
+			result.push(item.id);
+		}
+		if(item.child && item.child.length > 0) {
+			initConditionIds(item.child, result);
+		}
+	})
+}
+
+// 构造条件回显数据
+export const editCondition = ({depType, filterCondition})=>{
+	let conditionIds = [];
+	initConditionIds(filterCondition, conditionIds);
+	return {
+		depType, // 门急诊类型 1-门诊 2-急诊
+		conditionIds, // 选中的key
+		options: conditionOptions(filterCondition), // 树形节点数据
+		defaultOpen: filterCondition.length > 0 ? [filterCondition[0].id]:[], // 默认展开的项
+	}
+}
+// 构造查核组回显数据
+export const editCheckRent = ({checkGroup}) =>{
+	let obj = checkGroup.find((item)=>item.selectFlag || item.selectFlag === 'true');
+	return { // 查核组页面数据 
+		list: checkGroup,
+		checkedItem: obj ? obj : {id: null}
+	}
+}
+// 查核地图数据
+export const editCheckMap = ({checkDep}) =>{
+	return { // 查核地图数据
+		list: checkDep.map((item)=>{
+			return {
+				...item,
+				status: 'normal'
+			}
+		}), // 列表数据
+		actionItem: {id: '', pointList: []}, // 当前操作的列表项
+		deptList: [], // 新增单位数据
+	}
+}
+// 查核计划数据
+export const editCheckPlan = ({planConfig, planList}) =>{
+	let checkedItem = checkPlanList.find((item)=>item.value === planConfig.frequency);
+	return { // 查核计划
+		checkedItem: checkedItem?checkedItem: {id: 'month', value: 2, label: '每月', model: 30}, // 选中的取模方式对象
+		dateObj: { // 保存开始日期结束日期的对象
+			start: planConfig.startDate,
+			end: planConfig.endDate,
+			dayNum: dateDiff(planConfig.startDat, planConfig.endDate) // 两个日期间隔的天数
+		}, 
+		checkList: planList.map((item)=>{
+			return item.startDate
+		}), // 核查计划数组
+	}
+}
+// 预览数据
+export const editSituationPreview = ({name, remindPlanDay,remindPlanHour,remindCheckDay}) => {
+	return {
+		sitName: name,
+		preDay: remindPlanDay,
+		preH: remindPlanHour,
+		startDay: remindCheckDay
+	}
+} 
+// 判断两个数组全等
+export const arrayEquality = (arr1,arr2) =>{
+	let flage = true;
+	arr1.map((item, i)=>{
+		if(item !== arr2[i]){
+			flage = false;
+		}
+	});
+	return flage;
+}

+ 62 - 57
pages/creatingSituations/creatingSituations.vue

@@ -22,27 +22,26 @@
 	import checkMapAdd from "./components/checkMapAdd.vue";
 	import checkPlan from "./components/checkPlan.vue";
 	import situationPreview from "./components/situationPreview.vue";
-	
-	const normalBtnGroup = [
-		{id: 'pre', label: '上一步'},
-		{id: 'next', label: '下一步'}
-	];
-	const btnGroupPlan1 = [
-		{id: 'pre', label: '上一步'},
-		{id: 'checkPlanCreate', label: '生成查核计划'}
-	];
-	const btnGroupPlan2 = [
-		{id: 'checkPlanCallback', label: '返回'},
-		{id: 'next', label: '下一步'}
-	];
-	const btnGroupSituationPreview = [
-		{id: 'pre', label: '上一步'},
-		{id: 'situationPreviewOK', label: '完成'}
-	];
+	import {
+		themeList,
+		normalBtnGroup,
+		btnGroupPlan1,
+		btnGroupPlan2,
+		btnGroupSituationPreview,
+		optionsHandle,
+		checkDep,
+		checkGroup,
+		editCondition,
+		editCheckRent,
+		editCheckMap,
+		editCheckPlan,
+		editSituationPreview
+	} from "./components/utils.js";
 	
 	export default {
 		data() {
 			return {
+				saveType: 'POST',
 				options: [
 					{id: 'theme', title: '主题', component: theme},
 					{id: 'condition', title: '条件', component: condition, hint: '追踪条件'},
@@ -80,20 +79,59 @@
 				}
 			}
 		},
+		onLoad:function({id,type}){
+			this.saveType = type ? type : 'POST';
+			if(id) {
+				this.dispatch('detialConfig',{id}).then((data)=>{
+					if(data) {
+						const {topic} = data;
+						let theme = themeList[Number(topic)],
+							condition = editCondition(data),
+							editConfig = {};
+						this.myCommit('theme', theme); // 主题
+						if(type === 'PUT') { // 编辑
+							let checkRent = editCheckRent(data),
+							checkMap = editCheckMap(data),
+							checkPlan = editCheckPlan(data),
+							situationPreview = editSituationPreview(data);
+							this.myCommit('checkPlan', checkPlan); // 查核计划
+							this.myCommit('situationPreview', situationPreview); // 预览
+							editConfig = {
+								theme, 
+								condition, 
+								checkRent, 
+								checkMap,
+								checkPlan,
+								situationPreview
+							};
+						} else { // 复制创建
+							this.myCommit('condition', condition); // 条件
+							editConfig = {
+								theme, 
+								condition, 
+							};
+						}
+						this.myCommit('editConfig', editConfig); 
+						// 回到第一步或者第三步
+						this.myCommit('stepActive', type === 'PUT' ? 0 : 2); 
+					}
+				});
+			}
+		},
 		methods: {
 			save: function() {
 				const {sitName,preDay,preH,startDay} = this.situationPreview;
 				const {dateObj,checkedItem,checkList} = this.checkPlan;
-				const {depType, options} = this.condition;
-				if(!sitName) {
+				const {depType, options, conditionIds} = this.condition;
+				if(!sitName || sitName.length < 2) {
 					uni.showModal({
 						title: '温馨提示',
-						content: `情境名称不能为空!`,
+						content: `情境名称不能为空也不能少于2个字!`,
 						showCancel: false
 					});
 					return;
 				}
-				this.dispatch('save', {
+				this.dispatch(`save${this.saveType}`, {
 					name: sitName,
 					topic: this.theme.id,
 					checkPlanStartDate: dateObj.start,
@@ -102,9 +140,9 @@
 					remindPlanHour: preH,
 					remindCheckDay: startDay,
 					depType,
-					filterCondition: this.optionsHandle(options),
-					checkGroup: this.checkGroup(),
-					checkDep: this.checkDep(),
+					filterCondition: optionsHandle(options, conditionIds),
+					checkGroup: checkGroup(this.checkRent),
+					checkDep: checkDep(this.checkMap.list),
 					planConfig: {
 						frequency: checkedItem.value,
 						day: checkedItem.model,
@@ -193,39 +231,6 @@
 					return false;
 				}
 			},
-			/**
-			 * 构造条件提交结果
-			 */
-			optionsHandle: function(arr) {
-				let options = [...arr].map((item)=>{
-					return {
-						...item,
-						selectFlag: this.condition.conditionIds.includes(item.id),
-						child: this.optionsHandle(item.child)
-					}
-				});
-				return options;
-			},
-			checkDep: function() {
-				const {list} = this.checkMap;
-				return list.map((item, i)=>{
-					return {
-						...item,
-						sort: i+1,
-						enableFlag: item.status === 'disable' ? false : true,
-					}
-				});
-			},
-			checkGroup: function() {
-				const {list, checkedItem} = this.checkRent;
-				let _list = [...list].map((ntem)=>{
-					return {
-						...ntem,
-						selectFlag: ntem.id === checkedItem.id ? true : false
-					}
-				});
-				return _list;
-			},
 			myCommit: function(key, data) {
 				this.$store.commit({type: 'creatingSituations/comChangeState',key,data});
 			},

+ 3 - 2
pages/creatingSituations/model.js

@@ -1,5 +1,5 @@
 import { commServer } from './server.js';
-	import {dateHandle} from "../../utils/dateHandle.js";
+import {dateHandle} from "../../utils/dateHandle.js";
 	
 export default {
   namespaced: true,
@@ -39,7 +39,8 @@ export default {
 			preDay: null,
 			preH: null,
 			startDay: null
-		}
+		},
+		editConfig: null // 编辑时候的原始数据
   },
   mutations: {
 		comChangeState(state, {key, data}) {

+ 12 - 1
pages/creatingSituations/server.js

@@ -29,10 +29,21 @@ const requestList = {
     url: 'situation/addDeptList',
   },
 	// 情境新增保存
-  save: {
+  savePOST: {
     method: 'POST',
     url: 'situation',
 		successMessage: '保存成功!'
+  },
+	// 情境新增保存
+  savePUT: {
+    method: 'PUT',
+    url: 'situation',
+		successMessage: '编辑成功!'
+  },
+	// 情境配置的明细(出参同创建入参)
+  detialConfig: {
+    method: 'GET',
+    url: 'situation/config',
   },
 };
 

+ 29 - 17
pages/situationDetail/situationDetail.vue

@@ -1,5 +1,8 @@
 <template>
 	<view class="detail-page">
+		<tm-top-menu>
+			<button class="copy-btn" @click="editSituation('POST')">复制创建</button>
+		</tm-top-menu>
 		<view class="content-info">
 			<view class="top-box">
 				<view class="subscript">
@@ -39,7 +42,7 @@
 			<view class="btn-left" @click="delSituation" v-show="isAdmin">
 				<text class="left-text">作废</text>
 			</view>
-			<view class="btn-right" @click="editSituation" v-show="isAdmin">
+			<view class="btn-right" @click="editSituation('PUT')" v-show="isAdmin">
 				<text class="right-text">编辑</text>
 			</view>
 			<view class="btn-center" v-show="isChecker" @click="startUnplanned">
@@ -84,7 +87,6 @@
 				checkID:'',//新建查核计划时,计划列表中的前一个计划 id
         checkItemList:[],//时间区间包含当前时间的item
         checkGroupId: 0 // 查核组id
-
 			}
 		},
 		onLoad({ situationId }){ // situationId:情景id
@@ -155,19 +157,21 @@
 				})
 
 			},
-			editSituation(){
-				let editEnable=this.compareTime(this.firstCheckTime);
-				if(editEnable){
-					uni.navigateTo({
-						url: '/pages/creatingSituations/creatingSituations'
-					});
-				}
-				else{
-					uni.showModal({
-						title:'提示',
-						content:'已进行过一次查核,不可编辑',
-					  showCancel:false
-					})
+			editSituation(type){
+				let url=`/pages/creatingSituations/creatingSituations?id=${this.situationID}&type=${type}`;
+				if(type === 'PUT') {
+					let editEnable=this.compareTime(this.firstCheckTime);
+					// if(editEnable){
+						uni.navigateTo({url});
+					// } else{
+					// 	uni.showModal({
+					// 		title:'提示',
+					// 		content:'已进行过一次查核,不可编辑',
+					// 	  showCancel:false
+					// 	})
+					// }
+				} else {
+					uni.navigateTo({url});
 				}
 			},
 			compareTime(time){
@@ -250,6 +254,14 @@
 
 <style lang="less">
 	.detail-page{
+		margin-top: 50rpx;
+		.copy-btn {
+			border: 0;
+			height: 50rpx;
+			&::after {
+				border: 0;
+			}
+		}
 		.content-info{
 			background-color: #FFFFFF;
 			.top-box{
@@ -437,8 +449,8 @@
 		.button-box{
 			width: 750rpx;
 			height: 75rpx;
-			position: absolute;
-			bottom: 0rpx;
+			position: fixed;
+			bottom: 0;
 			.btn-center{
 				background: #3377FF;
 				text-align: center;