Prechádzať zdrojové kódy

feat(work): 加载流程图标
feat(work/edit): 流程表单数据渲染

wangpx 1 rok pred
rodič
commit
6c13b7a313
5 zmenil súbory, kde vykonal 177 pridanie a 111 odobranie
  1. 8 8
      api/login.js
  2. 27 18
      api/work.js
  3. 64 14
      pages/work/edit/index.vue
  4. 76 69
      pages/work/index.vue
  5. 2 2
      utils/request.js

+ 8 - 8
api/login.js

@@ -6,12 +6,12 @@ const preUrl = '/clientServices.do?iscrypt=1'
 export function login(username, password) {
 	return request({
 		url: preUrl,
-    method: 'post',
+		method: 'post',
 		data: {
 			'serviceId': 'eu_2013V01login',
 			'params': {
-        "userName": username,
-        "password": password
+				"userName": username,
+				"password": password
 			}
 		}
 	})
@@ -20,11 +20,11 @@ export function login(username, password) {
 export function getInfo(useId) {
 	return request({
 		url: preUrl,
-    method: 'post',
+		method: 'post',
 		data: {
 			'serviceId': 'eu_2013V01loadMe',
 			'params': {
-        "staffId": useId
+				"staffId": useId
 			}
 		}
 	})
@@ -33,12 +33,12 @@ export function getInfo(useId) {
 // 登出
 export function logout() {
 	// return request({
-    // method: 'post',
+	// method: 'post',
 	// 	data: {
 	// 		'serviceId': 'eu_2013V01login',
 	// 		'params': {
- //        "userName": username,
- //        "password": password
+	//        "userName": username,
+	//        "password": password
 	// 		}
 	// 	}
 	// })

+ 27 - 18
api/work.js

@@ -3,45 +3,54 @@ import request from '@/utils/request.js'
 const preUrl = '/clientServices.do?iscrypt=1'
 
 // 获取流程 宫格 列表
-export function getFlowList(staffId, unitId) {
+export function getProcessList(staffId, unitId) {
 	return request({
 		url: preUrl,
-    method: 'post',
+		method: 'post',
 		data: {
-			'serviceId': 'bpm_20150319001GetFlowList',
-			'params': {
-        "staffId": staffId,
-        "unitid": unitId
+			serviceId: 'bpm_20150319001GetFlowList',
+			params: {
+				staffId: staffId,
+				unitid: unitId
 			}
 		}
 	})
 }
 
 // 获取流程信息
-export function getFlowInfo(staffId, unitId) {
+export function getProcessInfo({modelId, control}) {
 	return request({
 		url: preUrl,
-    method: 'post',
+		method: 'post',
 		data: {
-			'serviceId': 'bpm_20150319001GetFlowList',
-			'params': {
-        "staffId": staffId,
-        "unitid": unitId
+			serviceId: 'bpm_20150319002GetStartFlowInfo',
+			params: {
+				modelId: modelId,
+				control: control
 			}
 		}
 	})
 }
 
 // 获取流程 表单
-export function getFlowForm(staffId, unitId) {
+export function getProcessForm(user, process) {
 	return request({
 		url: preUrl,
-    method: 'post',
+		method: 'post',
 		data: {
-			'serviceId': 'bpm_20150319001GetFlowList',
-			'params': {
-        "staffId": staffId,
-        "unitid": unitId
+			serviceId: 'bpm_20180525getflowform',
+			params: {
+				staffId: user.useId, // user.useId
+				formId: process.formId,
+				tmodelId: process.tmodelId,
+				modelId: process.modelId, // 流程模板
+				control: process.control, // 流程类型
+
+				loginID: user.useId, // user.useId
+				groupName: user.deptName, // user.deptName
+				name: user.name, // user.name
+				currentPosition: user.positionName, // user.positionName
+				id: user.unitId, // user.unitId
 			}
 		}
 	})

+ 64 - 14
pages/work/edit/index.vue

@@ -5,8 +5,13 @@
 				<uni-forms-item v-for="(item, index) in formElements" :label="item.elementName" :key="index">
 					<uni-easyinput v-if="'多少小时'==item.elementName" :disabled="true" placeholder="请输入内容"
 						:value="diffHours"></uni-easyinput>
+					<!-- 输入框 -->
 					<uni-easyinput v-else-if="'0'==item.type" :disabled="'0'==item.canEdit" placeholder="请输入内容"
 						:value="item.defaultValue"></uni-easyinput>
+					<!-- 下拉框 -->
+					<!-- <uni-data-select v-else-if="'2'==item.type" :disabled="'0'==item.canEdit" placeholder="请选择内容" :value="item.defaultValue || 0" :localdata="item.typeDetail.enum"></uni-data-select> -->
+					<!-- <button @click="openPopup">打开弹窗</button> -->
+					<!-- <uni-popup ref="popup" type="bottom" border-radius="10px 10px 0 0">底部弹出 Popup 自定义圆角</uni-popup> -->
 					<!-- 开始时间选择器 -->
 					<uni-datetime-picker :end="endTime" @change="setTimeRange(item)"
 						v-else-if="timeFlag&&'9'==item.type&&'开始时间'==item.elementName" v-model="item.defaultValue"
@@ -41,28 +46,73 @@
 <script setup lang="ts">
 	import { onMounted, reactive, ref } from 'vue'
 	import { onLoad } from '@dcloudio/uni-app'
+	import { useUserStore } from '@/store/user.js'
+	import { getProcessInfo, getProcessForm } from '@/api/work.js'
+	
+	let processInfo = reactive({
+		modelName: '流程申请',
+		control: '',
+		formId: '',
+		modelId: '',
+		tmodelId: '',
+		isMoreIns: '',
+		pathJudgeType: ''
+	})
 	onLoad((options) => {
-		// 获取传入的标题参数
-		const title = options.title || '流程申请';
+		const { modelName, modelId, control } = options
+		processInfo.modelName = modelName
+		processInfo.modelId = modelId
+		processInfo.control = control
 		// 设置导航栏标题
 		uni.setNavigationBarTitle({
-			title: title
+			title: processInfo.modelName
 		});
 	})
-	let formElements = reactive([{ elementName: 'EU单号', canEdit: '0', defaultValue: 'YGTX-WXJS027', type: '0', }, { elementName: '发起人', canEdit: '0', defaultValue: '账号1', type: '0', }, { elementName: '外协类别', canEdit: '1', defaultValue: '', type: '0', }, { elementName: '外协人姓名', canEdit: '1', defaultValue: '', type: '0', }, { elementName: '开始时间', canEdit: '1', defaultValue: '', type: '9', }, { elementName: '结束时间', canEdit: '1', defaultValue: '', type: '9', }, { elementName: '多少小时', canEdit: '1', defaultValue: '', type: '0', }, { elementName: '开户行', canEdit: '0', defaultValue: '', type: '0', }, { elementName: '开户号', canEdit: '0', defaultValue: '', type: '0', }, { elementName: '综合管理部审批', canEdit: '0', defaultValue: '', type: '13', }, { elementName: '财务审批', canEdit: '0', defaultValue: '', type: '13', }, { elementName: '总经理审批', canEdit: '0', defaultValue: '', type: '13', }])
-	const startTime = ref('') // 开始时间
-	const endTime = ref('') // 结束时间
+	onMounted(() => {
+		initProcessInfo().then(() => {
+			initProcessForm()
+		})
+	})
+	const userStore = useUserStore()
+	function initProcessInfo(){
+		return new Promise<void>((resolve, reject) => {
+				getProcessInfo(processInfo)
+				.then(({returnParams}) => {
+					const { formId, tmodelId, isMoreIns, pathJudgeType} = returnParams.flow[0]
+					processInfo.formId = formId
+					processInfo.tmodelId = tmodelId
+					processInfo.isMoreIns = isMoreIns
+					processInfo.pathJudgeType = pathJudgeType
+					resolve()
+				})
+		})
+	}
+	const formElements = ref([])
+	const startEleIndex = ref(0) // 开始时间
+	const endEleIndex = ref(0) // 结束时间
+	function initProcessForm() {
+		getProcessForm(userStore.user, processInfo).then(({returnParams}) => {
+			formElements.value = returnParams.formElements
+		
+			startEleIndex.value = formElements.value.findIndex((item) => '开始时间' == item.elementName)
+			endEleIndex.value = formElements.value.findIndex((item) => '结束时间' == item.elementName)
+			console.log('startEle', startEleIndex.value);
+			console.log('endEle', endEleIndex.value);
+			if (startEleIndex.value != -1 && endEleIndex.value != -1) { // 判断是否需要计算时间差
+			console.log('if (startEleIndex && endEleIndex)');
+				timeFlag.value = true
+				disableEndTime.value = true // 计算时间差时默认禁用结束时间选择器
+				formElements.value[startEleIndex.value].defaultValue = new Date()
+			}
+		})
+	}
+	
+	const startTime = ref(0) // 开始时间
+	const endTime = ref(0) // 结束时间
 	const diffHours = ref(' ') // 时间差
 	const timeFlag = ref(false) // 是否计算时间差
 	const disableEndTime = ref(false) // 禁用 结束时间选择器
-	onMounted(() => {
-		const startEle = formElements.find((item) => '开始时间' == item.elementName)
-		const endEle = formElements.find((item) => '结束时间' == item.elementName)
-		if (startEle && endEle) { // 判断是否需要计算时间差
-			timeFlag.value = true
-			disableEndTime.value = true // 计算时间差时默认禁用结束时间选择器
-		}
-	})
+	
 	function setTimeRange(e) {
 		if (timeFlag.value && '开始时间' == e.elementName) {
 			startTime.value = e.defaultValue // 设置 开始时间

+ 76 - 69
pages/work/index.vue

@@ -1,64 +1,72 @@
 <template>
 	<view class="work-container">
 		<!-- 宫格组件 -->
-		<uni-section :title="flowList.ftypeList[0].typeName" type="line"></uni-section>
-		<view class="grid-body">
-			<uni-grid :column="4" :showBorder="false" @change="changeProcessGrid">
-				<uni-grid-item v-for="(item, index) in flowList.fList" :index="index">
-					<view class="grid-item-box">
-						<text class="ygoa-icon icon-outsourcing"></text>
-						<text class="text">{{ item.modelName }}</text>
-					</view>
-				</uni-grid-item>
-				<!-- <uni-grid-item :index="2">
-					<view class="grid-item-box">
-						<text class="ygoa-icon icon-apply-car"></text>
-						<text class="text">用车申请</text>
-					</view>
-				</uni-grid-item>
-				<uni-grid-item :index="3">
-					<view class="grid-item-box">
-						<text class="ygoa-icon icon-apply-business"></text>
-						<text class="text">出差申请</text>
-					</view>
-				</uni-grid-item>
-				<uni-grid-item :index="4">
-					<view class="grid-item-box">
-						<text class="ygoa-icon icon-apply-out"></text>
-						<text class="text">外出申请</text>
-					</view>
-				</uni-grid-item>
-				<uni-grid-item :index="5">
-					<view class="grid-item-box">
-						<text class="ygoa-icon icon-apply-expense"></text>
-						<text class="text">费用报销</text>
-					</view>
-				</uni-grid-item>
-				<uni-grid-item :index="6">
-					<view class="grid-item-box">
-						<text class="ygoa-icon icon-apply-overtime"></text>
-						<text class="text">加班申请</text>
-					</view>
-				</uni-grid-item>
-				<uni-grid-item :index="7">
-					<view class="grid-item-box">
-						<text class="ygoa-icon icon-apply-leave"></text>
-						<text class="text">请假申请</text>
-					</view>
-				</uni-grid-item>
-				<uni-grid-item :index="8">
-					<view class="grid-item-box">
-						<text class="ygoa-icon icon-apply-purchase"></text>
-						<text class="text">采购申请</text>
-					</view>
-				</uni-grid-item>
-				<uni-grid-item :index="9">
-					<view class="grid-item-box">
-						<text class="ygoa-icon icon-apply-sign-contract"></text>
-						<text class="text">合同会签</text>
-					</view>
-				</uni-grid-item> -->
-			</uni-grid>
+		<view>
+			<uni-section :title="processList.ftypeList[0].typeName" type="line"></uni-section>
+			<view class="grid-body">
+				<uni-grid :column="4" :showBorder="false" @change="changeProcessGrid">
+					<uni-grid-item v-for="(item, index) in processList.fList" :index="index">
+						<view class="grid-item-box">
+							<text class="ygoa-icon" :class="item.modelPicture == 'default.png'?'icon-outsourcing':item.modelPicture"></text>
+							<text class="text">{{ item.modelName }}</text>
+						</view>
+					</uni-grid-item>
+					<!-- <uni-grid-item :index="1">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-outsourcing"></text>
+							<text class="text">外协结算申请</text>
+						</view>
+					</uni-grid-item>
+					<uni-grid-item :index="2">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-apply-car"></text>
+							<text class="text">用车申请</text>
+						</view>
+					</uni-grid-item>
+					<uni-grid-item :index="3">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-apply-business"></text>
+							<text class="text">出差申请</text>
+						</view>
+					</uni-grid-item>
+					<uni-grid-item :index="4">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-apply-out"></text>
+							<text class="text">外出申请</text>
+						</view>
+					</uni-grid-item>
+					<uni-grid-item :index="5">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-apply-expense"></text>
+							<text class="text">费用报销</text>
+						</view>
+					</uni-grid-item>
+					<uni-grid-item :index="6">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-apply-overtime"></text>
+							<text class="text">加班申请</text>
+						</view>
+					</uni-grid-item>
+					<uni-grid-item :index="7">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-apply-leave"></text>
+							<text class="text">请假申请</text>
+						</view>
+					</uni-grid-item>
+					<uni-grid-item :index="8">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-apply-purchase"></text>
+							<text class="text">采购申请</text>
+						</view>
+					</uni-grid-item>
+					<uni-grid-item :index="9">
+						<view class="grid-item-box">
+							<text class="ygoa-icon icon-apply-sign-contract"></text>
+							<text class="text">合同会签</text>
+						</view>
+					</uni-grid-item> -->
+				</uni-grid>
+			</view>
 		</view>
 		<uni-section title="考勤管理" type="line"></uni-section>
 		<view class="grid-body">
@@ -131,37 +139,36 @@
 	import $tab from "@/plugins/tab.js"
 	import { getUserInfo } from '@/utils/auth'
 	import { useUserStore } from '@/store/user.js'
-	import { getFlowList } from '@/api/work.js'
+	import { getProcessList } from '@/api/work.js'
 	
 	const userStore = useUserStore()
 	
 	onMounted(() => {
-		initFlowList()
+		initProcessList()
 	})
 	
-	const flowList = ref({
+	const processList = ref({
 		fList: [],
 		ftypeList: [
 			{
-				typeName: '日常办公'
+				typeName: ''
 			}
 		],
 	})
 	
-	function initFlowList() {
+	function initProcessList() {
 		const staffId = userStore.user.useId
 		const unitId = userStore.user.unitId
-		getFlowList(staffId, unitId).then(res => {
-			flowList.value = res.returnParams // 设置flowList
-			console.log('getFlowList', flowList.value);
+		getProcessList(staffId, unitId).then(res => {
+			processList.value = res.returnParams // 设置processList
+			// console.log('getProcessList', processList.value);
 		})
 	}
 	function changeProcessGrid(e) { // 点击流程宫格
 		console.log('changeProcessGrid', e);
-		const flow = flowList.value.fList[e.detail.index]
-		console.log('flow', flow);
+		const { modelName, modelId, control} = processList.value.fList[e.detail.index]
 		// 跳转流程申请页面
-		// $tab.navigateTo('/pages/work/edit/index?title=' + '')
+		$tab.navigateTo('/pages/work/edit/index?modelName=' + modelName + '&modelId=' + modelId +'&control=' + control)
 	}
 	function changeAttendanceGrid(e) {
 		if (1 == e.detail.index) { // 考勤

+ 2 - 2
utils/request.js

@@ -20,7 +20,7 @@ const request = config => {
     url = url.slice(0, -1)
     config.url = url
   }
-	console.log('request.data', config.data);
+	console.log('request.config', config);
   return new Promise((resolve, reject) => {
     uni.request({
         method: config.method || 'get',
@@ -35,7 +35,7 @@ const request = config => {
 				const returnCode = data.returnCode
         const code = statusCode || 200
         const msg = errorCode[code] || data.returnMsg || errorCode['default']
-				console.log('response', response);
+				console.log('request.response', response);
 				if (returnCode == -201) {
 				  toast(msg)
 				  reject(returnCode)