Bladeren bron

css(detail): 签字板按钮添加颜色
feat(detail): 附件、备注必填判断
feat(detail): 切换后台再切回来重新获取session

wangpx 1 jaar geleden
bovenliggende
commit
b9f7eccf3f
1 gewijzigde bestanden met toevoegingen van 49 en 27 verwijderingen
  1. 49 27
      pages/process/detail/index.vue

+ 49 - 27
pages/process/detail/index.vue

@@ -44,7 +44,6 @@
 										</view>
 									</view>
 								</view>
-								<!-- TODO 修改后端 我的 在办 办结 接口签名图片地址返回参数为sealImgPath -->
 								<view v-else-if="typeof elem.sealImgPath === 'string' && elem.sealImgPath.startsWith('/shares')" class="signature_img">
 									<img style="width: 100%;" mode="widthFix"
 										:src="config.baseUrlPre + elem.sealImgPath" />
@@ -63,7 +62,7 @@
 		<view class="repeating_table">
 			<!-- 重复表 -->
 			<uni-card v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty" spacing="0" padding="0">
-				<button @click="handlerepeatingForm" type="primary">查看明细</button>
+				<button @click="handleRepeatingForm" type="primary">查看明细</button>
 			</uni-card>
 			<uni-card v-else v-for="(table, tableIndex) in repeatingForm.elements" spacing="0" :key="tableIndex">
 				<uni-forms label-position="left" :label-width="125" :border="true">
@@ -99,12 +98,6 @@
 									{{ elem.defaultValue }}
 								</uni-td>
 							</uni-tr>
-							<!-- (列数 - 1) * 总行数 + 当前行数 -->
-							<!-- <uni-tr v-for="(item, index) in (repeatingForm.elements.length / repeatingForm.elementItem.length)" :key="index">
-								<uni-td align="center" v-for="col in repeatingForm.elementItem.length" :key="col">
-									{{ repeatingForm.elements[(col - 1) * (repeatingForm.elements.length / repeatingForm.elementItem.length) + index]!.defaultValue }}
-								</uni-td>
-							</uni-tr> -->
 						</uni-table>
 					</view>
 				</uni-card>
@@ -213,13 +206,13 @@
 			<view class="signature_button_container">
 				<uni-row :gutter="10">
 					<uni-col :span="6">
-						<button @click="onclickSignatureButton('undo')">撤销</button>
+						<button type="warn" @click="onclickSignatureButton('undo')">撤销</button>
 					</uni-col>
 					<uni-col :span="6">
-						<button @click="onclickSignatureButton('clear')">清空</button>
+						<button type="warn" @click="onclickSignatureButton('clear')">清空</button>
 					</uni-col>
 					<uni-col :span="6">
-						<button @click="onclickSignatureButton('save')">保存</button>
+						<button type="primary" @click="onclickSignatureButton('save')">保存</button>
 					</uni-col>
 					<uni-col :span="6">
 						<button @click="onclickSignatureButton('landscape')">全屏</button>
@@ -232,7 +225,7 @@
 
 <script setup lang="ts">
 import { computed, onMounted, reactive, ref } from 'vue'
-import { onLoad } from '@dcloudio/uni-app'
+import { onLoad, onShow } from '@dcloudio/uni-app'
 import { LSignatureToTempFilePathOptions, LSignatureToFileSuccess } from '@/uni_modules/lime-signature'
 import attachmentList from '@/components/ygoa/attachmentList.vue'
 import config from '@/config.js'
@@ -240,6 +233,8 @@ import $tab from '@/plugins/tab.js'
 import $modal from '@/plugins/modal.js'
 import { getProcessFlowInfo, getProcessFormInfo, getProcessFormInfoInFlow, getProcessFlow, submitProcessFlow, cancelProcessFlow, uploadSignatureImg, uploadSignatureBoardImg, uploadFile } from '@/api/process.js'
 import { useUserStore } from '@/store/user.js'
+import {getLoginInfo,getSession,setSession} from '@/utils/auth.js'
+import {reLogin} from '@/api/login.js'
 const fieldTypeDict = {
 	'0': 'text',
 	'1': 'digit'
@@ -250,6 +245,8 @@ const processInfo = reactive({
 	insName: '',
 	control: 1,
 	username: '',
+	reqOffice: 0,
+	reqRemark: 0,
 	tinsId: undefined
 })
 onLoad(({ insId, tinsId, insName, control }) => {
@@ -266,10 +263,23 @@ onLoad(({ insId, tinsId, insName, control }) => {
 		title: title
 	});
 })
+onShow(()=>{
+	let loginInfo = getLoginInfo()
+	//如果有登录信息,就自动登录刷session
+	if(Object.keys(loginInfo).length !== 0){
+		reLogin(loginInfo.username, loginInfo.password).then((res) => {
+				if ("ok" === res.data) {
+						setSession(res.cookies[0].split("=")[1].split(";")[0]);
+				}
+		}).catch(res=>{
+			console.log(res);
+		})
+	}
+})
 
 onMounted(() => {
-	initProcessInfo()
-	initProcessFlow()
+	initProcessForm() // 获取表单数据
+	initProcessInfo() // 获取流程数据
 })
 
 const repeatingForm = ref({
@@ -311,7 +321,6 @@ function addrepeatingFormItem(index) {
 }
 // 删除重复表表单
 function delrepeatingFormItem(index) {
-	console.log("delrepeatingFormItem: " + index);
 	$modal.confirm('', '确认删除该重复表数据')
 		.then(() => {
 			repeatingForm.value.elements.splice(index, 1)
@@ -326,7 +335,7 @@ const formInfo = ref({
 })
 const fileList = ref([])
 const isCancel = ref(false)
-function initProcessInfo() {
+function initProcessForm() {
 	if (processInfo.tinsId) {
 		// 待办审批流程表单数据
 		getProcessFormInfoInFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
@@ -334,7 +343,6 @@ function initProcessInfo() {
 			formInfo.value = returnParams.formInfo[0]
 			repeatingForm.value = returnParams.repeatingForm
 			getMainFormRule()
-			console.log('isCancel: ',isCancel);
 			if (returnParams.isCancel == 1) {
 				isCancel.value = true
 			}
@@ -359,7 +367,7 @@ const stepActive = ref(-1)
 const flowInfo = ref({
 	seModel: '0'
 })
-function initProcessFlow() {
+function initProcessInfo() {
 	getProcessFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
 		options.value = returnParams.list.map((item, index) => {
 			const { tmodelName, name, createdate, finishdate, remark, state } = item
@@ -385,6 +393,8 @@ function initProcessFlow() {
 				fileList.value = [
 					{ files: returnParams.flow[0].files }
 				]
+				processInfo.reqOffice = returnParams.tmodel.reqOffice
+				processInfo.reqRemark = returnParams.tmodel.reqRemark
 			})
 		}
 	})
@@ -427,7 +437,6 @@ function onclickSignatureButton(event) {
 		case 'save':
 			signatureRef.value.canvasToTempFilePath({
 				success: (res: LSignatureToFileSuccess) => {
-					console.log('res: ', res);
 					if (res.isEmpty) {
 						$modal.msgError('签名不能为空!')
 						return
@@ -477,7 +486,8 @@ function closeSignaturePopup() {
 }
 
 const repeatingFormPopup = ref(null)
-function handlerepeatingForm() {
+// 查看重复表
+function handleRepeatingForm() {
 	repeatingFormPopup.value.open()
 }
 // 附件管理
@@ -541,6 +551,7 @@ const formatTypeDict = {
 function validateMainForm() {
 
 }
+// 获取主表校验规则
 function getMainFormRule() {
 	$mainFormRules.value = computed(() => {
 		const obj = {};
@@ -555,9 +566,9 @@ function getMainFormRule() {
 						required: '1' == elem.noNull,
 						errorMessage,
 					},
-					{
-						format: formatTypeDict[elem.fieldType] || 'string',
-					}
+					// {
+					// 	format: formatTypeDict[elem.fieldType] || 'string',
+					// }
 				],
 				label: labelName
 			};
@@ -616,13 +627,24 @@ function submitProcess(result) {
 	flow['staffId'] = userStore.user.useId
 	flow['gxId'] = userStore.user.gxId
 	flow['groupId'] = flowInfo.value.groupid
-	flow['fileIds'] = subFileSeqs.value.map(({ seq }) => seq)
-	console.log('subFileSeqs.value.map(({ seq }) => seq): ',subFileSeqs.value.map(({ seq }) => seq));
+	const seqs = subFileSeqs.value.map(({ seq }) => seq)
+	if (processInfo.reqOffice == 1 && seqs.length == 0) {
+		button_state.value = true
+		$modal.msgError('请上传附件')
+		return
+	} else {
+		flow['fileIds'] = seqs
+	}
+	if (processInfo.reqRemark == 1 && remark.value == '') {
+		button_state.value = true
+		$modal.msgError('请填写备注')
+		return
+	} else {
+		flow['remark'] = remark.value
+	}
 	// result: 1通过 2退回发起人 0退回上一级
 	flow['result'] = result
-	flow['remark'] = remark.value
 	flow['nextTmodelId'] = 'undefined'
-	// TODO 启动流程 提交时 保存删除后的文件列表
 	submitProcessFlow(flow, formInfo.value, processInfo.control).then(({ returnMsg }) => {
 		if (returnMsg.includes('提交失败')) {
 			// 启用提交按钮