index.vue 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619
  1. <template>
  2. <page-meta root-font-size="system" />
  3. <view class="process_detail_container">
  4. <uni-card>
  5. <view class="main_container">
  6. <uni-section titleFontSize="1.3rem" title="申请内容" type="line"></uni-section>
  7. <uni-forms ref="$mainForm" :rules="$mainFormRules" :modelValue="mainFormValue" label-position="left"
  8. :label-width="125" :border="true">
  9. <view v-for="(elem, index) in formElements" :key="index">
  10. <uni-forms-item
  11. v-if="!(elem.elementName.endsWith('审批') && '' == elem.defaultValue && ['0', undefined].includes(elem.canEdit)) && ('' != elem.defaultValue || 1 == elem.canEdit) && !(elem.elementName.endsWith('单号') || elem.elementName.endsWith('申请人'))"
  12. :label="elem.elementName" :name="elem.elementId">
  13. <view class="element_value_container">
  14. <view v-if="'1' == elem.canEdit && '8' != elem.type" class="element_value">
  15. <!-- 关联变量输入框 -->
  16. <!-- 计算出差天数 -->
  17. <uni-easyinput v-if="undefined != elem.bindTimeRange && elem.elementName == '出差天数'"
  18. :type="fieldTypeDict[elem.fieldType] || 'text'"
  19. :value="calculateBusinessDifference(elem, formElements)" placeholder=""
  20. :disabled="true"></uni-easyinput>
  21. <uni-easyinput v-else-if="undefined != elem.bindTimeRange"
  22. :type="fieldTypeDict[elem.fieldType] || 'text'"
  23. :value="calculateTimeDifference(elem, formElements)" placeholder=""
  24. :disabled="true"></uni-easyinput>
  25. <!-- 金额转大写 -->
  26. <uni-easyinput v-else-if="elem.elementName.endsWith('大写')" placeholder=""
  27. :value="computedNumberToChineseCurrency(elem, formElements)" :disabled="true"></uni-easyinput>
  28. <!-- 主表关联变量输入框 -->
  29. <!-- 数值输入框 -->
  30. <uni-easyinput v-else-if="'1' == elem.fieldType && elem.BddzText" type="digit"
  31. :value="computedBddzTextValue(elem)" @input="digitInput($event, elem)"
  32. placeholder="" :disabled="true"></uni-easyinput>
  33. <!-- 输入框 -->
  34. <uni-easyinput v-else-if="elem.BddzText"
  35. :type="fieldTypeDict[elem.fieldType] || 'text'"
  36. :value="computedBddzTextValue(elem)" placeholder=""
  37. :disabled="true"></uni-easyinput>
  38. <!-- 数值输入框 -->
  39. <uni-easyinput v-else-if="'0' == elem.type && '1' == elem.fieldType"
  40. :disabled="'0' == elem.canEdit" type="digit"
  41. :placeholder="'0' == elem.canEdit ? '' : '请输入内容'"
  42. @input="digitInput($event, elem)" v-model="elem.defaultValue"
  43. placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
  44. <!-- 输入框 -->
  45. <uni-easyinput v-else-if="'0' == elem.type"
  46. placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))" placeholder="请输入内容"
  47. v-model="elem.defaultValue" type="text"></uni-easyinput>
  48. <!-- 富文本框 -->
  49. <uni-easyinput v-else-if="'1' == elem.type"
  50. placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))" placeholder="请输入内容"
  51. v-model="elem.defaultValue" type="textarea"></uni-easyinput>
  52. <!-- 下拉框 -->
  53. <picker class="picker_container" v-else-if="'2' == elem.type"
  54. @change="bindPickerChange($event, elem)" :value="elem.defaultValue"
  55. :range="formatDict(elem.typeDetail.enum)">
  56. <view class="uni-input input_text">
  57. <!-- 设置默认值为第一个选项 -->
  58. {{ elem.defaultValue ? elem.defaultValue : elem.defaultValue =
  59. elem.typeDetail.enum[0].enumVname }}
  60. </view>
  61. </picker>
  62. <!-- 数据选择器 -->
  63. <uni-data-checkbox v-else-if="'4' == elem.type" v-model="elem.defaultValue"
  64. :localdata="formatCheckbox(elem)"
  65. @change="changeDataSingleCheckBox($event,elem)"></uni-data-checkbox>
  66. <uni-data-checkbox v-else-if="'5' == elem.type" multiple v-model="elem.defaultValue"
  67. :localdata="formatCheckbox(elem)"
  68. @change="changeDataCheckBox($event,elem)"></uni-data-checkbox>
  69. <!-- 开始时间选择器 -->
  70. <uni-datetime-picker :end="formElements[elem.endElemIndex].defaultValue"
  71. @change="setTimeRange(elem)"
  72. v-else-if="'9' == elem.type && undefined != elem.endElemIndex"
  73. v-model="elem.defaultValue" :clear-icon="false" type="datetime" />
  74. <!-- 结束时间选择器 -->
  75. <uni-datetime-picker :start="formElements[elem.startElemIndex].defaultValue"
  76. @change="setTimeRange(elem)"
  77. v-else-if="'9' == elem.type && undefined != elem.startElemIndex"
  78. v-model="elem.defaultValue" :clear-icon="false" type="datetime" />
  79. <!-- 年月日 时分秒 -->
  80. <uni-datetime-picker v-else-if="'9' == elem.type" v-model="elem.defaultValue"
  81. type="datetime" />
  82. <!-- 年月日 -->
  83. <uni-datetime-picker v-else-if="'3' == elem.type" v-model="elem.defaultValue"
  84. type="date" />
  85. <!-- 审批签字板 -->
  86. <view v-else-if="'13' == elem.type">
  87. <view v-if="elem.defaultValue == ''">
  88. <uni-row>
  89. <uni-col :span="24">
  90. <button type="primary" @click="handleSignature(index)">手动签名</button>
  91. </uni-col>
  92. <uni-col :span="24">
  93. <button style="margin-top: 5px;" type="primary" @click="onclickAutosealButton(index)">一键签名</button>
  94. </uni-col>
  95. </uni-row>
  96. </view>
  97. <view v-else class="signature_img">
  98. <img style="width: 100%;" mode="widthFix" @click="handleSignature(index)"
  99. :src="config.baseUrlPre + elem.sealImgPath"
  100. :alt="elem.elementName + '签名'" />
  101. </view>
  102. </view>
  103. </view>
  104. <view
  105. v-else-if="typeof elem.sealImgPath === 'string' && elem.sealImgPath.startsWith('/shares')"
  106. class="signature_img">
  107. <img style="width: 100%;" mode="widthFix"
  108. :src="config.baseUrlPre + elem.sealImgPath" />
  109. </view>
  110. <view
  111. v-else-if="typeof elem.defaultValue === 'string' && elem.defaultValue.startsWith('/shares')"
  112. class="signature_img">
  113. <img style="width: 100%;" mode="widthFix"
  114. :src="config.baseUrlPre + elem.defaultValue" />
  115. </view>
  116. <text class="element_value" v-else>{{ Array.isArray(elem.defaultValue) ? elem.defaultValue.join(',') : elem.defaultValue }}</text>
  117. </view>
  118. </uni-forms-item>
  119. </view>
  120. </uni-forms>
  121. </view>
  122. </uni-card>
  123. <view class="repeating_table">
  124. <!-- 重复表 -->
  125. <!-- <uni-card v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty" spacing="0" padding="0">
  126. <button @click="handleRepeatingForm" type="primary">查看明细</button>
  127. </uni-card> -->
  128. <uni-card v-if="!(flowInfo.seModel == '0' && repeatingFormNotEmpty)"
  129. v-for="(table, tableIndex) in repeatingForm.elements" spacing="0" :key="tableIndex">
  130. <uni-forms label-position="left" :label-width="125" :border="true">
  131. <uni-forms-item :name="elem.tableField" v-for="(elem, itemIndex) in table"
  132. :label="repeatingForm.elementItem[itemIndex].elementName.slice(3)" :key="itemIndex">
  133. <!-- 自定义关联变量 -->
  134. <uni-easyinput v-if="repeatingForm.elementItem[itemIndex].bddzText" :placeholder="''"
  135. :type="fieldTypeDict[repeatingForm.elementItem[itemIndex].fieldType.value] || 'text'"
  136. placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"
  137. :value="calculateRepeatingFormExpression(elem, table)" :disabled="true"></uni-easyinput>
  138. <!-- 数值输入框 -->
  139. <uni-easyinput v-else-if="'1' == repeatingForm.elementItem[itemIndex].fieldType.value"
  140. placeholder="请输入内容" v-model="elem.defaultValue" @input="digitInput($event, elem)"
  141. placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))" type="digit"></uni-easyinput>
  142. <!-- 输入框 -->
  143. <uni-easyinput v-else placeholder="请输入内容" v-model="elem.defaultValue" type="'text'"
  144. placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
  145. </uni-forms-item>
  146. </uni-forms>
  147. <!-- <view class="repeating_table_button_container">
  148. <uni-row>
  149. <uni-col :span="10" :offset="1">
  150. <button @click="addrepeatingFormItem(tableIndex)" type="primary">新增</button>
  151. </uni-col>
  152. <uni-col :span="10" :offset="2">
  153. <button @click="delrepeatingFormItem(tableIndex)"
  154. :disabled="repeatingForm.elements.length <= 1" type="warn">删除</button>
  155. </uni-col>
  156. </uni-row>
  157. </view> -->
  158. </uni-card>
  159. <!-- <uni-popup v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty" ref="repeatingFormPopup">
  160. <uni-card margin="0px" spacing="0px" padding="0px">
  161. <view class="repeating_table_container">
  162. <uni-table :border="true" stripe>
  163. <uni-tr>
  164. <uni-th align="center" v-for="(item, index) in repeatingForm.elementItem" :key="index">
  165. {{ item.elementName.slice(3, 5) }}
  166. </uni-th>
  167. </uni-tr>
  168. <uni-tr v-for="(table, tableIndex) in repeatingForm.elements" :key="tableIndex">
  169. <uni-td align="center" v-for="(elem, itemIndex) in table" :key="itemIndex">
  170. {{ elem.defaultValue }}
  171. </uni-td>
  172. </uni-tr>
  173. </uni-table>
  174. </view>
  175. </uni-card>
  176. </uni-popup> -->
  177. </view>
  178. <!-- 明细 -->
  179. <!-- <view class="repeating_table_detail2">
  180. <uni-card v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty">
  181. <uni-section titleFontSize="1.3rem" title="明细" type="line"></uni-section>
  182. <uni-forms ref="baseForm" :modelValue="baseFormData" v-for="(table, tableIndex) in repeatingForm.elements" :key="tableIndex">
  183. <uni-forms-item v-for="(item, index) in repeatingForm.elementItem"
  184. :label="item.elementName.slice(3, 5)" :key="index">
  185. <text>{{table[index].defaultValue}}</text>
  186. </uni-forms-item>
  187. </uni-forms>
  188. </uni-card>
  189. </view> -->
  190. <view class="repeating_table_detail">
  191. <uni-card v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty">
  192. <uni-section titleFontSize="1.3rem" title="明细" type="line"></uni-section>
  193. <view class="repeating_table_container">
  194. <uni-table :border="true" stripe>
  195. <uni-tr>
  196. <uni-th align="center" v-for="(item, index) in repeatingForm.elementItem" :key="index">
  197. {{ item.elementName.slice(3, 5) }}
  198. </uni-th>
  199. </uni-tr>
  200. <uni-tr v-for="(table, tableIndex) in repeatingForm.elements" :key="tableIndex">
  201. <uni-td align="center" v-for="(elem, itemIndex) in table" :key="itemIndex">
  202. {{ elem.defaultValue }}
  203. </uni-td>
  204. </uni-tr>
  205. </uni-table>
  206. </view>
  207. </uni-card>
  208. </view>
  209. <!-- 附件 -->
  210. <view v-for="(item, index) in fileList" :key="index">
  211. <uni-card v-if="item.files.length != undefined && item.files.length > 0">
  212. <uni-section titleFontSize="1.3rem" title="附件" type="line"></uni-section>
  213. <attachment-list @clickDelete="deleteFile" :canEdit="flowInfo.seModel == '1'"
  214. :attachments="item.files"></attachment-list>
  215. </uni-card>
  216. </view>
  217. <!-- 上传附件 -->
  218. <view v-if="processInfo.tinsId || flowInfo.seModel == '1'" class="file_picker_container">
  219. <uni-card title="上传附件" :extra="`${subFileList.length}/50`" spacing="0">
  220. <uni-file-picker ref="filePicker" v-model="subFileList" :auto-upload="true" mode="list" :limit="50"
  221. file-mediatype="all" @select="handleFileSelect" @progress="handleFileProgress"
  222. @success="handleFileSuccess" @fail="handleFileFail" @delete="handleFileDelete" />
  223. </uni-card>
  224. </view>
  225. <!-- 流转过程 -->
  226. <view>
  227. <uni-card>
  228. <view class="flow_step_container">
  229. <uni-section titleFontSize="1.3rem" title="流转过程" type="line"></uni-section>
  230. <up-steps :current="stepActive" activeColor="#18bc37" inactiveColor="#2979ff" direction="column">
  231. <view v-for="(step, index) in options" :key="index">
  232. <up-steps-item :contentClass="'redcontent'" v-if="step.state == 3"
  233. :title="step.title + ' 退回'" :desc="step.desc" :key="index" error></up-steps-item>
  234. <up-steps-item :contentClass="'redcontent'" v-else-if="step.state == 0"
  235. :title="step.title + ' 撤销'" :desc="step.desc" :key="index" error></up-steps-item>
  236. <up-steps-item v-else-if="index == stepActive" :title="step.title" :desc="step.desc"
  237. :key="index">
  238. <template #icon>
  239. <view class="active_step_circle">
  240. <text class="active_step_text">{{ index + 1 }}</text>
  241. </view>
  242. </template>
  243. </up-steps-item>
  244. <up-steps-item v-else :title="step.title" :desc="step.desc" :key="index"></up-steps-item>
  245. </view>
  246. </up-steps>
  247. </view>
  248. </uni-card>
  249. </view>
  250. <view v-if="processInfo.tinsId">
  251. <view class="remark_container">
  252. <uni-card>
  253. <uni-section titleFontSize="1.3rem" title="环节备注" type="line"></uni-section>
  254. <view class="remark_content">
  255. <uni-easyinput type="textarea" autoHeight v-model="remark" placeholder="请输入"
  256. placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
  257. </view>
  258. </uni-card>
  259. </view>
  260. </view>
  261. <view v-if="processInfo.tinsId" class="approve_button">
  262. <uni-card spacing="0" padding="0">
  263. <button :disabled="!button_state" :loading="!button_state" type="primary"
  264. @click="handleSubmitProcess('1')">
  265. {{ flowInfo.seModel == '0' ? '通过' : '提交' }}
  266. </button>
  267. </uni-card>
  268. </view>
  269. </view>
  270. <view v-if="processInfo.tinsId && flowInfo.seModel == '0'">
  271. <view class="reject_button">
  272. <uni-card spacing="0" padding="0" :is-shadow="false" :border="false">
  273. <uni-row>
  274. <uni-col :span="11">
  275. <button :disabled="!button_state" :loading="!button_state" type="warn"
  276. @click="handleSubmitProcess('0')">退回上一级</button>
  277. </uni-col>
  278. <uni-col :span="11" :offset="2">
  279. <button :disabled="!button_state" :loading="!button_state" type="warn"
  280. @click="handleSubmitProcess('2')">退回发起人</button>
  281. </uni-col>
  282. </uni-row>
  283. </uni-card>
  284. </view>
  285. </view>
  286. <view v-else-if="isCancel">
  287. <view class="remark_container">
  288. <uni-card>
  289. <uni-section titleFontSize="1.3rem" title="撤销备注" type="line"></uni-section>
  290. <view class="remark_content">
  291. <uni-easyinput type="textarea" autoHeight v-model="remark" placeholder="请输入"
  292. placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
  293. </view>
  294. </uni-card>
  295. </view>
  296. <view class="cancel_button_container" >
  297. <uni-card spacing="0" padding="0">
  298. <button :disabled="!button_state" :loading="!button_state" type="warn"
  299. @click="handleCancelProcess">撤销</button>
  300. </uni-card>
  301. </view>
  302. </view>
  303. <view style="height: 5px; margin-top: 20px;"></view>
  304. <!-- 签字版弹出层 -->
  305. <uni-popup ref="signaturePopup" @maskClick="closeSignaturePopup">
  306. <view class="signature_container" :class="{ 'signature_container_landscape': isLandscape }">
  307. <view class="signature_content">
  308. <l-signature ref="signatureRef" v-if="signaturePopupShow" :landscape="isLandscape" :penSize="8"
  309. :minLineWidth="4" :maxLineWidth="12" :openSmooth="true" :preferToDataURL="true"
  310. backgroundColor="#ffffff" penColor="black"></l-signature>
  311. </view>
  312. <view class="signature_button_container">
  313. <uni-row :gutter="10">
  314. <uni-col :span="6">
  315. <button type="warn" @click="onclickSignatureButton('undo')">撤销</button>
  316. </uni-col>
  317. <uni-col :span="6">
  318. <button type="warn" @click="onclickSignatureButton('clear')">清空</button>
  319. </uni-col>
  320. <uni-col :span="6">
  321. <button type="primary" @click="onclickSignatureButton('save')">保存</button>
  322. </uni-col>
  323. <uni-col :span="6">
  324. <button @click="onclickSignatureButton('landscape')">全屏</button>
  325. </uni-col>
  326. <!-- <uni-col :span="24">
  327. <button type="primary" @click="onclickAutosealButton()">一键签名</button>
  328. </uni-col> -->
  329. </uni-row>
  330. </view>
  331. </view>
  332. </uni-popup>
  333. </template>
  334. <script setup lang="ts">
  335. import { computed, onMounted, reactive, ref, nextTick } from 'vue'
  336. import { onLoad, onShow, onShareAppMessage } from '@dcloudio/uni-app'
  337. import { LSignatureToTempFilePathOptions, LSignatureToFileSuccess } from '@/uni_modules/lime-signature'
  338. import attachmentList from '@/components/ygoa/attachmentList.vue'
  339. import config from '@/config.js'
  340. import $tab from '@/plugins/tab.js'
  341. import $modal from '@/plugins/modal.js'
  342. import { getProcessFlowInfo, getProcessFormInfo, getProcessFormInfoInFlow, getProcessFlow, submitProcessFlow, cancelProcessFlow, uploadSignatureImg, uploadSignatureBoardImg, uploadFile, getSeal, getTacheInfo } from '@/api/process.js'
  343. import { getAttendanceSegment } from '@/api/work.js'
  344. import { useUserStore } from '@/store/user.js'
  345. import { getLoginInfo, getSession, setSession } from '@/utils/auth.js'
  346. import { reLogin, keepSession } from '@/api/login.js'
  347. import { convertToChineseCurrency } from '@/utils/ygoa.js'
  348. import { calCommonExp } from '@/utils/rpn.js'
  349. const fieldTypeDict = {
  350. '0': 'text',
  351. '1': 'digit'
  352. }
  353. const userStore = useUserStore()
  354. const processInfo = reactive({
  355. insId: '',
  356. insName: '',
  357. control: 1,
  358. username: '',
  359. reqOffice: 0,
  360. reqRemark: 0,
  361. tinsId: undefined,
  362. // tinsObj: {}//存储流转最后一步的对象
  363. })
  364. onLoad(({ insId, tinsId, insName, control }) => {
  365. // 获取传入的标题参数
  366. const title = insName || '流程信息';
  367. processInfo.insId = insId
  368. processInfo.insName = insName
  369. processInfo.control = control
  370. if (tinsId) {
  371. processInfo['tinsId'] = tinsId
  372. }
  373. // 设置导航栏标题
  374. uni.setNavigationBarTitle({
  375. title: title
  376. });
  377. })
  378. onShow(() => {
  379. keepSession().then(res => {
  380. if (typeof res === 'number') {
  381. return
  382. } else {
  383. const loginInfo = getLoginInfo()
  384. //如果有登录信息,就自动登录刷session
  385. if (Object.keys(loginInfo).length !== 0) {
  386. reLogin(loginInfo.username, loginInfo.password).then((res) => {
  387. if ("ok" === res.data) {
  388. setSession(res.cookies[0].split("=")[1].split(";")[0]);
  389. }
  390. }).catch(res => {
  391. console.log(res);
  392. })
  393. } else {
  394. $tab.reLaunch({ url: '/pages/login' })
  395. }
  396. }
  397. })
  398. .catch(err => {
  399. console.log('err', err);
  400. // $tab.navigateBack()
  401. })
  402. })
  403. onMounted(() => {
  404. initProcessForm() // 获取表单数据
  405. initProcessInfo() // 获取流程数据
  406. })
  407. //分享转发事件
  408. onShareAppMessage((res) => {
  409. if (res.from === 'menu') {
  410. // console.log('res', res)
  411. }
  412. let url = '/pages/process/index?insId=' + processInfo.insId + '&insName=' + processInfo.insName + '&control=' + processInfo.control
  413. // console.log('url',url);
  414. return {
  415. title: processInfo.insName,
  416. path: url
  417. }
  418. })
  419. const repeatingForm = ref({
  420. elements: [],
  421. elementItem: [],
  422. })
  423. // 是否有重复表
  424. const repeatingFormNotEmpty = ref(false)
  425. function repeatingFormHasValue() {
  426. if (repeatingForm.value === undefined) return
  427. if (repeatingForm.value.elementItem.length <= 0) return
  428. repeatingForm.value.elements.forEach(({ defaultValue }) => {
  429. if (defaultValue != "") {
  430. repeatingFormNotEmpty.value = true
  431. return new Promise((resolve, reject) => {
  432. resolve(repeatingFormNotEmpty)
  433. })
  434. }
  435. })
  436. }
  437. // 新增重复表表单
  438. function addrepeatingFormItem(index) {
  439. // parseCalculation(repeatingForm.value.elementItem)
  440. const table = repeatingForm.value.elementItem.map(({ tableField, bddzText }) => {
  441. const item = {
  442. name: tableField,
  443. defaultValue: ""
  444. }
  445. if (bddzText != '') {
  446. const mulItem = bddzText.split('*')
  447. // 保存关联数据索引
  448. item['bddzText'] = mulItem.map(item => {
  449. // item['operation '].operands = mulItem.map(item => {
  450. return repeatingForm.value.elementItem.findIndex(({ elementName }) => item == elementName)
  451. })
  452. }
  453. return item
  454. })
  455. repeatingForm.value.elements.splice(index + 1, 0, table)
  456. }
  457. // 删除重复表表单
  458. function delrepeatingFormItem(index) {
  459. $modal.confirm('', '确认删除该重复表数据')
  460. .then(() => {
  461. repeatingForm.value.elements.splice(index, 1)
  462. // $repeatingForms.value.splice(index, 1)
  463. }).catch(() => { })
  464. }
  465. const formElements = ref([])
  466. const formInfo = ref({
  467. formElements: [],
  468. formId: '',
  469. formInsId: ''
  470. })
  471. const fileList = ref([])
  472. const isCancel = ref(false)
  473. // 获取流程表单
  474. function initProcessForm() {
  475. //debugger
  476. if (processInfo.tinsId) {
  477. // 待办审批流程表单数据todo
  478. getProcessFormInfoInFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  479. console.log('returnParams', returnParams);
  480. const modifyReturnParams = (returnParams) => {
  481. return returnParams.formElements.map(element => {
  482. if (element.type === "5") {
  483. // 将 defaultValue 按逗号分割成数组
  484. element.defaultValue = element.defaultValue.split(",");
  485. }
  486. return element;
  487. });
  488. };
  489. formElements.value = modifyReturnParams(returnParams)
  490. formInfo.value = returnParams.formInfo[0]
  491. repeatingForm.value = returnParams.repeatingForm
  492. getMainFormRule()
  493. computedMainFormValue()
  494. if (returnParams.isCancel == 1) {
  495. isCancel.value = true
  496. }
  497. repeatingFormHasValue()
  498. bindTimeRangeData()
  499. remark.value = flowInfo.value.seModel == '0' ? '同意' : '重新提交'
  500. })
  501. } else {
  502. // 我的 在办 办结流程表单数据 todo
  503. getProcessFormInfo(userStore.user.useId, processInfo.insId).then(({ returnParams }) => {
  504. formElements.value = returnParams.formElements
  505. repeatingForm.value = returnParams.repeatingForm
  506. fileList.value = returnParams.fileList
  507. if (returnParams.isCancel == 1) {
  508. isCancel.value = true
  509. }
  510. repeatingFormHasValue()
  511. })
  512. }
  513. }
  514. const options = ref([])
  515. const stepActive = ref(-1)
  516. const flowInfo = ref({
  517. seModel: '0'
  518. })
  519. // 获取流程信息
  520. function initProcessInfo() {
  521. //debugger
  522. getProcessFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  523. options.value = returnParams.list.map((item, index) => {
  524. const { tmodelName, name, createdate, finishdate, remark, state, task, groupName, positionName } = item
  525. if (state == 1) {
  526. stepActive.value = index
  527. }
  528. const title = tmodelName + (name == '' ? '' : ' ( ' + name + ' ' + groupName + '-' + positionName + ' )')
  529. let desc = '创建时间: ' + createdate
  530. + (finishdate == '' ? '\n' : '\n办理时间: ' + finishdate)
  531. + (remark == '' ? '\n' : '\n环节意见: ' + remark)
  532. if(task && task.length > 0) {
  533. desc += '抄送信息'
  534. task.forEach((taskitem) => {
  535. desc += '\n抄送对象:(' + taskitem.username + ') 抄送时间: ' + taskitem.createdate
  536. })
  537. }
  538. return {
  539. title,
  540. desc,
  541. state
  542. }
  543. })
  544. if (stepActive.value === -1) stepActive.value = returnParams.list.length
  545. // 获取未完成过程
  546. if (processInfo.tinsId) {
  547. getProcessFlowInfo(userStore.user.useId, processInfo).then(({ returnParams }) => {
  548. options.value.push({ title: returnParams.nextTmodels[0].nextTmodelName })
  549. flowInfo.value = returnParams.flow[0]
  550. fileList.value = [
  551. { files: returnParams.flow[0].files }
  552. ]
  553. processInfo.reqOffice = returnParams.tmodel.reqOffice
  554. processInfo.reqRemark = returnParams.tmodel.reqRemark
  555. })
  556. }
  557. console.log('options', options.value);
  558. })
  559. }
  560. // 下拉框
  561. function bindPickerChange(e, item) {
  562. const index = e.detail.value;
  563. item.defaultValue = item.typeDetail.enum[index].enumVname
  564. }
  565. function formatDict(dict) {
  566. return dict.map(({ enumVname }) => enumVname)
  567. }
  568. //数据选择器
  569. function formatCheckbox(elem) {
  570. let dict = elem.typeDetail.enum
  571. // elem['checkBox'] = ''
  572. return dict.map((item, index) => ({
  573. text: item.enumVname,
  574. value: item.enumVname
  575. }));
  576. }
  577. function changeDataCheckBox(e, elem) {
  578. elem['checkBox'] = e.detail.value.join(",")
  579. // console.log(e)
  580. }
  581. //单选框切换事件
  582. function changeDataSingleCheckBox(){
  583. }
  584. const timeRangeItems = ref([
  585. ['开始时间', '结束时间', '多少小时'],
  586. ['出发时间', '预计返回时间'],
  587. ['出差时间', '返回时间', '出差天数'],
  588. ['出门时间', '预计返回时间'],
  589. ['开始时间', '结束时间', '合计小时'],
  590. ])
  591. // 关联时间变量
  592. function bindTimeRangeData() {
  593. return new Promise<void>((resolve) => {
  594. timeRangeItems.value.forEach((range) => {
  595. const [startName, endName, bindName] = range;
  596. // 找到 startName 和 endName 的索引
  597. const startIndex = formElements.value.findIndex((item) => item.elementName === startName);
  598. const endIndex = formElements.value.findIndex((item) => item.elementName === endName);
  599. const formatDate = (date) => {
  600. const pad = (num) => num.toString().padStart(2, '0');
  601. return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
  602. }
  603. // 只有找到 startName 和 endName 后,才检查 bindName
  604. if (startIndex !== -1 && endIndex !== -1) {
  605. if (formElements.value[startIndex].defaultValue == '') {
  606. formElements.value[startIndex].defaultValue = formatDate(new Date())
  607. } else {
  608. formElements.value[startIndex].defaultValue = formatDate(new Date(formElements.value[startIndex].defaultValue))
  609. }
  610. if (bindName) {
  611. const bindIndex = formElements.value.findIndex((item) => item.elementName === bindName);
  612. if (bindIndex !== -1) {
  613. // 所有匹配项都存在,保存索引
  614. formElements.value[startIndex].endElemIndex = endIndex;
  615. formElements.value[endIndex].startElemIndex = startIndex;
  616. formElements.value[bindIndex].bindTimeRange = {
  617. startIndex,
  618. endIndex
  619. };
  620. setAttendanceSegment() // 获取班次信息
  621. }
  622. } else {
  623. // 没有 bindName,仅保存 start 和 end 的索引
  624. formElements.value[startIndex].endElemIndex = endIndex;
  625. formElements.value[endIndex].startElemIndex = startIndex;
  626. }
  627. // TODO 加班开始时间默认当天下班时间 请假时间默认当天上班时间
  628. }
  629. });
  630. resolve(); // 返回一个 resolved 状态的 Promise
  631. });
  632. }
  633. // 计算时间差
  634. function calculateBusinessDifference(item, form) {
  635. return item.defaultValue = (calculateTimeDifference(item, form) / 7).toFixed(2)
  636. }
  637. function calculateTimeDifference(item, form) {
  638. // 获取 开始时间 和 结束时间
  639. const { startIndex, endIndex } = item.bindTimeRange;
  640. const startTime = new Date(form[startIndex].defaultValue);
  641. const endTime = new Date(form[endIndex].defaultValue);
  642. // 检查时间是否合法
  643. if (isNaN(startTime.getTime()) || isNaN(endTime.getTime())) {
  644. return item.defaultValue = 0
  645. }
  646. // 请假申请的时间差 表单项为合计小时
  647. const type = item.elementName == '合计小时' ? '非工作时间' : '工作时间'
  648. // 计算时间差
  649. const timeDifferenceInHours = calculateWorkingHours(startTime, endTime, type);
  650. // const timeDifferenceInMs = endTime - startTime;
  651. // let timeDifferenceInHours = (timeDifferenceInMs / (1000 * 60 * 60)).toFixed(1);
  652. // let timeDifferenceInHours = (timeDifferenceInMs / (1000 * 60 * 60))
  653. // // 计算小数部分
  654. // const decimalPart = timeDifferenceInHours - Math.floor(timeDifferenceInHours)
  655. // if (decimalPart >= 0.5) {
  656. // // 如果小数部分大于等于 0.5,向上取整到 0.5 的倍数
  657. // timeDifferenceInHours = Math.floor(timeDifferenceInHours) + 0.5;
  658. // } else {
  659. // // 如果小数部分小于 0.5,向下取整到 0.5 的倍数
  660. // timeDifferenceInHours = Math.floor(timeDifferenceInHours);
  661. // }
  662. // 保存到 defaultValue
  663. return item.defaultValue = Number(timeDifferenceInHours.toFixed(2));
  664. }
  665. let workingPeriods = [
  666. { start: "09:00", end: "12:00" }, // 上午
  667. { start: "13:30", end: "17:30" }, // 下午
  668. ]
  669. let workDays = [1, 2, 3, 4, 5, 6, 0] // 0为周日
  670. // 获取考勤时间段
  671. function setAttendanceSegment() {
  672. getAttendanceSegment(userStore.user.unitId).then(({ returnParams }) => {
  673. const workTime = returnParams[0].work_time.split(';')
  674. let workDayArr = returnParams[0].work_days.split(',')
  675. let workTimeArr = []
  676. for (const time of workTime) {
  677. if (time == '') continue
  678. const times = time.split(',')
  679. const obj = {
  680. start: times[0],
  681. end: times[1]
  682. }
  683. workTimeArr.push(obj)
  684. }
  685. if (workTimeArr.length != 0) {
  686. workingPeriods = workTimeArr
  687. }
  688. workDayArr = workDayArr.map(item => Number(item))
  689. const sundayIndex = workDayArr.findIndex(item => item == 7)
  690. // console.log('workDays: ', workDayArr);
  691. if (sundayIndex != -1) {
  692. workDayArr[sundayIndex] = 0
  693. }
  694. if (workDayArr.length != 0) {
  695. workDays = workDayArr
  696. }
  697. })
  698. }
  699. function calculateWorkingHours(startTime, endTime, type) {
  700. // 将时间字符串解析为分钟数
  701. const formatTime = (timeString) => {
  702. const [hours, minutes] = timeString.split(":").map(Number)
  703. return hours * 60 + minutes
  704. };
  705. // 计算两个时间段的重叠部分
  706. const calculateOverlap = (start1, end1, start2, end2) => {
  707. const overlapStart = Math.max(start1, start2)
  708. const overlapEnd = Math.min(end1, end2)
  709. return Math.max(0, overlapEnd - overlapStart) // 如果无重叠返回 0
  710. };
  711. // 将 Date 转化为当天的分钟数
  712. const dateToMinutes = (date) => date.getHours() * 60 + date.getMinutes()
  713. // 判断日期是否是工作日
  714. const isRestdays = (date) => !workDays.includes(date.getDay())
  715. // 确保 startTime 和 endTime 是 Date 类型
  716. if (!(startTime instanceof Date) || !(endTime instanceof Date)) {
  717. throw new Error("startTime 和 endTime 必须是 Date 类型")
  718. }
  719. // 将时间范围分解为每天的计算
  720. const startDate = new Date(startTime)
  721. const endDate = new Date(endTime)
  722. startDate.setHours(0, 0, 0, 0)
  723. endDate.setHours(0, 0, 0, 0)
  724. let totalMinutes = 0
  725. // 遍历时间范围的每一天
  726. for (
  727. let currentDate = new Date(startDate);
  728. currentDate <= endDate;
  729. currentDate.setDate(currentDate.getDate() + 1)
  730. ) {
  731. const isStartDay = currentDate.getTime() === startDate.getTime();
  732. const isEndDay = currentDate.getTime() === endDate.getTime();
  733. // 当天的起始和结束时间
  734. const dayStart = isStartDay ? dateToMinutes(startTime) : 0;
  735. const dayEnd = isEndDay ? dateToMinutes(endTime) : 1440; // 1440 = 24 * 60
  736. // TODO 改为配置选择
  737. if (type == "工作时间") {
  738. // 如果当前日期不是工作日,跳过
  739. if (isRestdays(currentDate)) continue;
  740. // 计算工作时间段内的时间
  741. workingPeriods.forEach((period) => {
  742. const periodStart = formatTime(period.start);
  743. const periodEnd = formatTime(period.end);
  744. totalMinutes += calculateOverlap(dayStart, dayEnd, periodStart, periodEnd);
  745. });
  746. } else if (type == "非工作时间") {
  747. if (isRestdays(currentDate)) {
  748. // 计算非工作日时间差
  749. const midnight = new Date(currentDate)
  750. midnight.setHours(24, 0, 0, 0)
  751. const timeDiffInMs = dayEnd - dayStart
  752. totalMinutes += timeDiffInMs
  753. continue
  754. }
  755. // 计算非工作时间段的时间
  756. let nonWorkingMinutes = 0;
  757. let current = dayStart;
  758. for (const period of workingPeriods) {
  759. const periodStart = formatTime(period.start);
  760. const periodEnd = formatTime(period.end);
  761. if (current < periodStart) {
  762. nonWorkingMinutes += calculateOverlap(current, dayEnd, current, periodStart);
  763. }
  764. current = Math.max(current, periodEnd);
  765. }
  766. if (current < dayEnd) {
  767. nonWorkingMinutes += dayEnd - current;
  768. }
  769. totalMinutes += nonWorkingMinutes;
  770. }
  771. }
  772. // 转换为小时
  773. return totalMinutes / 60;
  774. }
  775. function setTimeRange(e) {
  776. // console.log('setTimeRange', e)
  777. }
  778. // 生成人民币大写
  779. function computedNumberToChineseCurrency(item, form) {
  780. const elem = form.find(elem => !elem.elementName.endsWith('大写') && (elem.BddzText == item.BddzText || elem.elementName == item.BddzText.slice(3)))
  781. if(elem != null) {
  782. console.log("大写转换")
  783. return item.defaultValue = convertToChineseCurrency(elem.defaultValue);
  784. } else {
  785. return '';
  786. }
  787. }
  788. // 按照公式统计数据
  789. function computedBddzTextValue(item) {
  790. const mainIndex = formElements.value.findIndex(({ elementName }) => elementName == item.BddzText.slice(3))
  791. const reIndex = repeatingForm.value.elementItem.findIndex(({ elementName }) => elementName == item.BddzText)
  792. if (item.defaultValue) {
  793. if (mainIndex != -1) {
  794. return item.defaultValue = formElements.value[mainIndex].defaultValue
  795. }
  796. if (reIndex != -1) {
  797. return computedValueToRepeatingForm(item)
  798. }
  799. }
  800. }
  801. // 统计重复表数据
  802. function computedValueToRepeatingForm(item) {
  803. const index = repeatingForm.value.elementItem.findIndex(({ elementName }) => elementName.slice(3) == item.BddzText.slice(3))
  804. let result = 0
  805. for (const formItem of repeatingForm.value.elements) {
  806. result += Number(formItem[index].defaultValue) || 0
  807. }
  808. if (item.defaultValue) {
  809. return item.defaultValue = Number(result.toFixed(2))
  810. }
  811. }
  812. function digitInput(event, item) {
  813. // 获取输入框当前的值
  814. let currentValue = event;
  815. // 过滤非数字和小数点的字符
  816. currentValue = currentValue.replace(/[^0-9.]/g, '');
  817. // 处理前导零的情况:
  818. // 如果当前值没有小数点(即是整数),去掉前导零
  819. if (currentValue.indexOf('.') === -1) {
  820. currentValue = currentValue.replace(/^0+(?=\d)/, ''); // 只有当有数字跟随时才去掉前导零
  821. } else {
  822. // 如果包含小数点,处理整数部分的前导零,保留小数部分
  823. let parts = currentValue.split('.');
  824. parts[0] = parts[0].replace(/^0+(?=\d)/, ''); // 只去掉整数部分的前导零
  825. currentValue = parts.join('.'); // 重新拼接
  826. }
  827. // 防止多个小数点
  828. const parts = currentValue.split('.');
  829. let finalValue;
  830. if (parts.length > 2) {
  831. // 如果有多个小数点,保留第一个小数点及后续数字
  832. finalValue = parts[0] + '.' + parts[1];
  833. } else {
  834. finalValue = currentValue;
  835. }
  836. // 更新最终结果到 item
  837. nextTick(() => {
  838. item.defaultValue = finalValue;
  839. event = finalValue; // 更新输入框的值
  840. });
  841. return event;
  842. }
  843. // 计算重复表关联变量表达式结果值
  844. function calculateRepeatingFormExpression(item, form) {
  845. // 提取表达式中的变量名
  846. const variablePattern = /my:[\u4e00-\u9fa5]+/g;
  847. let match;
  848. let expression = item.BddzText
  849. // 替换表达式中的变量
  850. while ((match = variablePattern.exec(item.BddzText)) !== null) {
  851. const variableName = match[0]; // 完整变量名
  852. // 找到 重复表 中对应的索引
  853. const index = repeatingForm.value.elementItem.findIndex(item => item.elementName === variableName);
  854. if (index !== -1) {
  855. const value = form[index]?.defaultValue || 0;
  856. expression = expression.replace(match[0], value);
  857. } else {
  858. // 未匹配到的变量替换为 0
  859. expression = expression.replace(match[0], 0);
  860. }
  861. }
  862. if (/[^0-9\+\-\*\/\(\)\.]/.test(expression)) {
  863. console.error('错误的表达式:', expression);
  864. $modal.msg('自动计算错误,请手动输入')
  865. return item.defaultValue = 0;
  866. }
  867. return item.defaultValue = Number(calCommonExp(expression).toFixed(2)); // 返回填充后的表达式
  868. }
  869. const signaturePopup = ref(null)
  870. const signatureRef = ref(null)
  871. const signaturePopupShow = ref(false)
  872. const isLandscape = ref(false)
  873. const signatureItemIndex = ref(-1)
  874. function handleSignature(index) {
  875. signatureItemIndex.value = index
  876. signaturePopup.value.open()
  877. initSignature()
  878. }
  879. // 初始化签字板
  880. function initSignature() {
  881. signaturePopupShow.value = false
  882. setTimeout(() => {
  883. signaturePopupShow.value = true
  884. }, 100)
  885. }
  886. // 点击签字板按钮
  887. function onclickSignatureButton(event) {
  888. // console.log('onclickSignatureButton: ', event);
  889. switch (event) {
  890. case 'undo':
  891. signatureRef.value.undo()
  892. break;
  893. case 'clear':
  894. signatureRef.value.clear()
  895. break;
  896. case 'save':
  897. signatureRef.value.canvasToTempFilePath({
  898. success: (res : LSignatureToFileSuccess) => {
  899. if (res.isEmpty) {
  900. $modal.msgError('签名不能为空!')
  901. return
  902. }
  903. // 判断上传文件是否是base64
  904. if (res.tempFilePath.substring(0, 'data:image/png;base64,'.length) == 'data:image/png;base64,') {
  905. const _fileData = res.tempFilePath
  906. uploadSignatureBoardImg(userStore.user.useId, _fileData, formElements.value[signatureItemIndex.value].tableField)
  907. .then(({ returnParams }) => {
  908. formElements.value[signatureItemIndex.value].defaultValue = returnParams.sealInsID
  909. formElements.value[signatureItemIndex.value].sealImgPath = returnParams.path
  910. signatureItemIndex.value = -1
  911. signaturePopupShow.value = false
  912. signaturePopup.value.close()
  913. })
  914. } else {
  915. // 转 base64
  916. wx.getFileSystemManager().readFile({
  917. filePath: res.tempFilePath,
  918. encoding: 'base64',
  919. success: fileData => {
  920. const _fileData = 'data:image/png;base64,' + fileData.data
  921. uploadSignatureBoardImg(userStore.user.useId, _fileData, formElements.value[signatureItemIndex.value].tableField)
  922. .then(({ returnParams }) => {
  923. formElements.value[signatureItemIndex.value].defaultValue = returnParams.sealInsID
  924. formElements.value[signatureItemIndex.value].sealImgPath = returnParams.path
  925. signatureItemIndex.value = -1
  926. signaturePopupShow.value = false
  927. signaturePopup.value.close()
  928. })
  929. }
  930. })
  931. }
  932. }
  933. } as LSignatureToTempFilePathOptions)
  934. break;
  935. case 'landscape':
  936. isLandscape.value = !isLandscape.value
  937. initSignature()
  938. break;
  939. }
  940. }
  941. function onclickAutosealButton(index) {
  942. if (signatureItemIndex.value != -1) index = signatureItemIndex.value
  943. getSeal(userStore.user.useId).then(({ returnParams }) => {
  944. formElements.value[index].defaultValue = returnParams.sealFileId.universalid
  945. formElements.value[index].sealImgPath = returnParams.sealFileId.path
  946. signaturePopupShow.value = false
  947. signaturePopup.value.close()
  948. })
  949. }
  950. function closeSignaturePopup() {
  951. signatureItemIndex.value = -1
  952. signaturePopupShow.value = false
  953. }
  954. const repeatingFormPopup = ref(null)
  955. // 查看重复表
  956. function handleRepeatingForm() {
  957. repeatingFormPopup.value.open()
  958. }
  959. // 附件管理
  960. function deleteFile(file) {
  961. // console.log('deleteFile: ',file);
  962. fileList.value[0].files = fileList.value[0].files.filter(({ fileId }) => !(fileId == file.fileId))
  963. }
  964. // 上传附件
  965. const subFileList = ref([]) // 文件列表
  966. const subFileSeqs = ref([])
  967. async function handleFileSelect(files) { // 新增文件
  968. // console.log('handleFileSelect', files.tempFiles)
  969. files.tempFiles.forEach(file => {
  970. const data = {
  971. name: file.name,
  972. filePath: file.path,
  973. }
  974. uploadFile(data)
  975. .then(res => {
  976. file.seq = res.returnParams
  977. subFileSeqs.value.push({ 'seq': res.returnParams, 'path': file.path })
  978. subFileList.value.push(file)
  979. $modal.msgSuccess('文件' + data.name + '上传成功')
  980. })
  981. .catch(err => {
  982. $modal.msgError('文件' + data.name + '上传失败,请删除重新上传')
  983. switch (err) {
  984. case -201:
  985. console.log('文件上传失败 未找到该文件');
  986. break;
  987. case -20201:
  988. console.log('文件上传失败 返回值不是JSON字符串');
  989. break;
  990. }
  991. })
  992. })
  993. // console.log('UploadFiles', files.tempFiles);
  994. }
  995. // 文件上传触发事件
  996. function handleFileProgress(file, progress) {
  997. // console.log('handleFileProgress', file, progress);
  998. }
  999. function handleFileSuccess(file, res) {
  1000. // console.log('handleFileSuccess', file, res);
  1001. }
  1002. function handleFileFail(file, err) {
  1003. // console.log('handleFileFail', file, err);
  1004. }
  1005. function handleFileDelete(file) { // 移除文件
  1006. // console.log('handleDelete', file)
  1007. subFileSeqs.value.splice(subFileSeqs.value.findIndex(({ path }) => path == file.tempFilePath))
  1008. }
  1009. const $mainForm = ref(null)
  1010. const $mainFormRules = ref({})
  1011. const mainFormValue = ref({})
  1012. const repeatingFormsValue = ref([])
  1013. const formatTypeDict = {
  1014. '0': 'string',
  1015. '1': 'number'
  1016. }
  1017. function computedMainFormValue() {
  1018. // 设置主表校验数据
  1019. mainFormValue.value = computed(() => {
  1020. const obj = {};
  1021. formElements.value.forEach(elem => {
  1022. if (!('0' != elem.canEdit && '8' != elem.type)) return
  1023. obj[elem.elementId] = elem.defaultValue;
  1024. });
  1025. return obj;
  1026. }).value
  1027. }
  1028. // 获取主表校验规则
  1029. function getMainFormRule() {
  1030. $mainFormRules.value = computed(() => {
  1031. const obj = {};
  1032. formElements.value.forEach(elem => {
  1033. if (!('0' != elem.canEdit && '8' != elem.type)) return
  1034. let labelName = elem.elementName
  1035. let errorMessage = ''
  1036. if ('13' == elem.type) errorMessage = '请完成签名'
  1037. obj[elem.elementId] = {
  1038. rules: [
  1039. {
  1040. required: '1' == elem.noNull,
  1041. errorMessage,
  1042. },
  1043. // {
  1044. // format: formatTypeDict[elem.fieldType] || 'string',
  1045. // }
  1046. ],
  1047. label: labelName
  1048. };
  1049. });
  1050. return obj;
  1051. }).value
  1052. }
  1053. function validateRepeatingForm2() {
  1054. // 设置重复表校验数据
  1055. const filterElements = repeatingForm.value.elements.filter(item => item.canEdit == "1")
  1056. if (filterElements.length == 0) return true
  1057. repeatingFormsValue.value = filterElements.map((item, index) => {
  1058. return computed(() => {
  1059. const obj = {};
  1060. item.forEach(({ name, defaultValue }) => {
  1061. obj[name] = defaultValue;
  1062. });
  1063. return obj;
  1064. }).value
  1065. })
  1066. let flag = false
  1067. repeatingFormsValue.value.forEach((item, index) => {
  1068. let ItemIndex = 0
  1069. for (const elem in item) {
  1070. if (item[elem] == '') {
  1071. const name = repeatingForm.value.elementItem[ItemIndex].elementName.slice(3)
  1072. $modal.msgError(`详情表 ${name} 数据填写错误`)
  1073. flag = false
  1074. return
  1075. }
  1076. ItemIndex++
  1077. }
  1078. flag = true
  1079. })
  1080. return flag
  1081. }
  1082. const button_state = ref(true)
  1083. const remark = ref('')
  1084. function handleSubmitProcess(result) {
  1085. let content = '确认退回'
  1086. if (result == "1") {
  1087. content = '确认通过'
  1088. }
  1089. $modal.confirm(content).then(() => {
  1090. button_state.value = false
  1091. if (result == "1") {
  1092. // 处理主表校验数据
  1093. mainFormValue.value = computed(() => {
  1094. const obj = {};
  1095. formElements.value.forEach(elem => {
  1096. let value = elem.defaultValue
  1097. if (!('0' != elem.canEdit && '8' != elem.type)) return
  1098. if ('5' == elem.type && Array.isArray(elem.defaultValue)) {
  1099. value = elem.defaultValue.join(",")
  1100. }
  1101. obj[elem.elementId] = value;
  1102. });
  1103. return obj;
  1104. }).value
  1105. // console.log('$mainForm.value: ', $mainForm.value);
  1106. // 主表数据校验
  1107. $mainForm.value.validate().then(res => {
  1108. // 重复表数据校验
  1109. if (repeatingFormNotEmpty.value && !validateRepeatingForm2()) {
  1110. button_state.value = true
  1111. return
  1112. }
  1113. submitProcess(result)
  1114. })
  1115. .catch(err => {
  1116. button_state.value = true
  1117. $modal.msgError('表单填写错误')
  1118. })
  1119. } else {
  1120. submitProcess(result)
  1121. }
  1122. }).catch(() => { })
  1123. }
  1124. function submitProcess(result) {
  1125. let flow = Object.assign({}, flowInfo.value)
  1126. formInfo.value.formElements = formElements.value
  1127. // 过滤不可编辑的表单项
  1128. .filter(({ canEdit }) => canEdit == '1')
  1129. .map(({ tableField, defaultValue, type }) => {
  1130. let value = defaultValue
  1131. if ('5' == type && Array.isArray(defaultValue)) {
  1132. value = defaultValue.join(",")
  1133. }
  1134. return {
  1135. name: tableField,
  1136. value
  1137. }
  1138. })
  1139. repeatingForm.value.elements.forEach((table, index) => {
  1140. const newItem = table.map((item) => {
  1141. item['value'] = item.defaultValue
  1142. return item
  1143. })
  1144. formInfo.value.formElements.push(...newItem)
  1145. })
  1146. flow['staffId'] = userStore.user.useId
  1147. flow['gxId'] = userStore.user.gxId
  1148. flow['groupId'] = flowInfo.value.groupid
  1149. if (result == "1") {
  1150. const seqs = subFileSeqs.value.map(({ seq }) => seq)
  1151. if (flowInfo.value.seModel == '0' && processInfo.reqOffice == 1 && seqs.length == 0) {
  1152. button_state.value = true
  1153. $modal.msgError('请上传附件')
  1154. return
  1155. } else {
  1156. flow['fileIds'] = seqs
  1157. }
  1158. if (processInfo.reqRemark == 1 && remark.value == '') {
  1159. button_state.value = true
  1160. $modal.msgError('请填写备注')
  1161. return
  1162. }
  1163. } else {
  1164. flow.fileIds = []
  1165. flow.files = []
  1166. }
  1167. flow['remark'] = remark.value
  1168. // result: 1通过 2退回发起人 0退回上一级
  1169. flow['result'] = result
  1170. flow['nextTmodelId'] = 'undefined'
  1171. submitProcessFlow(flow, formInfo.value, processInfo.control).then(({ returnMsg }) => {
  1172. if (returnMsg.includes('提交失败')) {
  1173. // 启用提交按钮
  1174. button_state.value = true
  1175. $modal.msgError(returnMsg)
  1176. } else {
  1177. $modal.msgSuccess(returnMsg)
  1178. // 通知列表刷新数据
  1179. uni.$emit('ReloadProcessData');
  1180. setTimeout(() => {
  1181. $tab.navigateBack();
  1182. }, 1000)
  1183. }
  1184. })
  1185. }
  1186. // 取消流程
  1187. function handleCancelProcess() {
  1188. if (remark.value.trim() == '') {
  1189. $modal.msgError('备注不能为空!')
  1190. return
  1191. }
  1192. $modal.confirm('确认撤销').then(() => {
  1193. cancelProcess()
  1194. }).catch(() => { })
  1195. }
  1196. function cancelProcess() {
  1197. cancelProcessFlow(userStore.user.useId, remark.value, processInfo).then(({ returnMsg }) => {
  1198. if (returnMsg.includes('success')) {
  1199. $modal.msgSuccess('撤销成功')
  1200. // 通知列表刷新数据
  1201. uni.$emit('ReloadProcessData');
  1202. setTimeout(() => {
  1203. $tab.navigateBack();
  1204. }, 1000)
  1205. } else {
  1206. // 启用按钮
  1207. button_state.value = true
  1208. $modal.msgError(returnMsg)
  1209. }
  1210. })
  1211. }
  1212. </script>
  1213. <style lang="scss" scoped>
  1214. ::v-deep .uni-section {
  1215. margin-left: -15px;
  1216. margin-bottom: 10px;
  1217. }
  1218. .signature_container {
  1219. background-color: #f5f5f5;
  1220. height: 40vh;
  1221. width: 90vw;
  1222. .signature_content {
  1223. height: 80%;
  1224. width: 100%;
  1225. }
  1226. .signature_button_container {
  1227. height: 20%;
  1228. width: 100%;
  1229. button {
  1230. height: 100%;
  1231. }
  1232. }
  1233. }
  1234. .signature_container_landscape {
  1235. height: 100vh;
  1236. width: 100vw;
  1237. .signature_content {
  1238. height: 85%;
  1239. width: 100%;
  1240. }
  1241. .signature_button_container {
  1242. margin-top: 10%;
  1243. height: 15%;
  1244. width: 100%;
  1245. button {
  1246. height: 100%;
  1247. width: 100%;
  1248. transform: rotate(90deg);
  1249. }
  1250. }
  1251. }
  1252. .process_detail_container {
  1253. position: relative;
  1254. ::v-deep uni-card{
  1255. .uni-card{
  1256. padding: 0 8px !important;
  1257. }
  1258. }
  1259. .repeating_table {
  1260. ::v-deep .uni-forms {
  1261. .uni-forms-item__label {
  1262. font-size: calc(1rem + 0px) !important;
  1263. line-height: calc(1rem + 0px) !important;
  1264. font-weight: 700;
  1265. }
  1266. .uni-forms-item__content {
  1267. font-size: calc(14px + (1rem - 16px)) !important;
  1268. font-weight: 500;
  1269. .uni-easyinput__content-input {
  1270. height: calc(35px + .5*(1rem - 16px)) !important;
  1271. font-size: calc(14px + (1rem - 16px)) !important;
  1272. font-weight: 500;
  1273. }
  1274. }
  1275. }
  1276. ::v-deep .uni-forms-item--border {
  1277. padding: 5px 0 !important;
  1278. }
  1279. .repeating_table_button_container {
  1280. margin-top: 5px;
  1281. button {
  1282. height: 36px;
  1283. line-height: 36px;
  1284. color: #fff;
  1285. }
  1286. .add {
  1287. background-color: #1ca035;
  1288. }
  1289. .del {
  1290. background-color: #e64340;
  1291. }
  1292. }
  1293. }
  1294. .main_container {
  1295. min-height: 40vh;
  1296. ::v-deep .uni-forms {
  1297. .uni-forms-item__label {
  1298. font-size: calc(1rem + 0px) !important;
  1299. line-height: calc(1rem + 0px) !important;
  1300. font-weight: 700;
  1301. }
  1302. .uni-forms-item__content {
  1303. font-size: calc(14px + (1rem - 16px)) !important;
  1304. font-weight: 500;
  1305. .uni-easyinput__content-textarea {
  1306. font-size: calc(14px + (1rem - 16px)) !important;
  1307. font-weight: 500;
  1308. }
  1309. .uni-easyinput__content-input {
  1310. height: calc(35px + .5*(1rem - 16px)) !important;
  1311. font-size: calc(14px + (1rem - 16px)) !important;
  1312. font-weight: 500;
  1313. color: #333;
  1314. }
  1315. .uni-date {
  1316. .uni-icons {
  1317. font-size: calc(22px + 1.2*(1rem - 16px)) !important;
  1318. font-weight: 500;
  1319. }
  1320. .uni-date__x-input {
  1321. height: auto;
  1322. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1323. font-weight: 500;
  1324. }
  1325. }
  1326. }
  1327. }
  1328. .element_value_container {
  1329. .signature_img {
  1330. width: 180px;
  1331. }
  1332. .element_value {
  1333. line-height: 36px;
  1334. }
  1335. }
  1336. }
  1337. // ::v-deep .repeating_table_detail2{
  1338. // .uni-forms-item__content{
  1339. // margin: auto;
  1340. // }
  1341. // .uni-forms{
  1342. // border-top: 2px #eee solid;
  1343. // }
  1344. // .uni-forms-item__label {
  1345. // width: 125px !important;
  1346. // font-size: calc(1rem + 0px) !important;
  1347. // line-height: calc(1rem + 0px) !important;
  1348. // font-weight: 700;
  1349. // }
  1350. // .uni-forms-item__content {
  1351. // font-size: calc(14px + (1rem - 16px)) !important;
  1352. // font-weight: 500;
  1353. // .uni-date {
  1354. // .uni-icons {
  1355. // font-size: calc(22px + 1.2*(1rem - 16px)) !important;
  1356. // font-weight: 500;
  1357. // }
  1358. // }
  1359. // }
  1360. // }
  1361. ::v-deep .repeating_table_detail {
  1362. .uni-card {
  1363. padding: 0 !important;
  1364. }
  1365. .uni-card__content {
  1366. padding: 0 !important;
  1367. }
  1368. .uni-section {
  1369. margin: 10px 5px;
  1370. }
  1371. }
  1372. ::v-deep .repeating_table_container {
  1373. width: 92vw;
  1374. .uni-table-scroll {
  1375. max-height: 80vh;
  1376. .uni-table {
  1377. min-width: 100% !important;
  1378. .uni-table-th {
  1379. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1380. min-width: calc(50px + 2.5*(1rem - 16px));
  1381. background-color: #2979ff;
  1382. font-weight: bold;
  1383. color: #fcfcfc;
  1384. }
  1385. .uni-table-td {
  1386. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1387. }
  1388. }
  1389. }
  1390. }
  1391. ::v-deep .file_picker_container {
  1392. .uni-card {
  1393. .uni-card__header-content-title {
  1394. font-size: calc(15px + .5*(1rem - 16px));
  1395. }
  1396. .uni-card__header-extra-text {
  1397. font-size: calc(15px + .5*(1rem - 16px));
  1398. }
  1399. }
  1400. }
  1401. ::v-deep .flow_step_container {
  1402. min-height: 200px;
  1403. .u-steps {
  1404. .u-steps-item {
  1405. padding-bottom: 11px;
  1406. .u-text__value--tips {
  1407. font-size: calc(12px + .5*(1rem - 16px)) !important;
  1408. }
  1409. .redcontent {
  1410. .u-text__value--content {
  1411. color: #ff4500;
  1412. }
  1413. }
  1414. .active_step_circle {
  1415. width: 20px;
  1416. height: 20px;
  1417. box-sizing: border-box;
  1418. flex-shrink: 0;
  1419. border-radius: 100px;
  1420. border-width: 1px;
  1421. border-color: #A78BFA;
  1422. background-color: #A78BFA;
  1423. border-style: solid;
  1424. display: flex;
  1425. flex-direction: row;
  1426. align-items: center;
  1427. justify-content: center;
  1428. transition: background-color .3s;
  1429. .active_step_text {
  1430. color: #fff;
  1431. font-size: 11px;
  1432. display: flex;
  1433. flex-direction: row;
  1434. align-items: center;
  1435. justify-content: center;
  1436. text-align: center;
  1437. line-height: 11px;
  1438. }
  1439. }
  1440. }
  1441. .u-steps-item view:last-of-type {
  1442. margin-top: 0 !important;
  1443. .u-text__value--content {
  1444. font-size: calc(16px + .5*(1rem - 16px)) !important;
  1445. }
  1446. .u-text__value--main {
  1447. font-size: calc(16px + .5*(1rem - 16px)) !important;
  1448. font-weight: 500;
  1449. }
  1450. }
  1451. }
  1452. }
  1453. .approve_button {
  1454. position: sticky;
  1455. z-index: 10;
  1456. width: 100%;
  1457. bottom: 10px;
  1458. }
  1459. }
  1460. ::v-deep button {
  1461. font-size: calc(18px + .5*(1rem - 16px));
  1462. }
  1463. .reject_button {
  1464. ::v-deep .uni-card {
  1465. background-color: #f5f5f5;
  1466. }
  1467. }
  1468. .remark_container {
  1469. .remark_content {
  1470. margin-bottom: 10px;
  1471. ::v-deep .uni-easyinput {
  1472. .uni-easyinput__content-textarea {
  1473. font-size: calc(14px + .5*(1rem - 16px)) !important;
  1474. }
  1475. }
  1476. }
  1477. }
  1478. ::v-deep .uni-calendar__content {
  1479. margin: -20px;
  1480. margin-top: 20px;
  1481. .uni-calendar__header {
  1482. .uni-calendar__header-text {
  1483. font-size: calc(14px + .5*(1rem - 16px)) !important;
  1484. }
  1485. .uni-calendar__backtoday {
  1486. padding: 2px 8px 2px 10px !important;
  1487. font-size: calc(0.75rem + 0px) !important;
  1488. }
  1489. }
  1490. .uni-calendar__box {
  1491. .uni-calendar__weeks {
  1492. .uni-calendar__weeks-day {
  1493. .uni-calendar__weeks-day-text {
  1494. font-size: calc(14px + .5*(1rem - 16px)) !important;
  1495. }
  1496. }
  1497. .uni-calendar__weeks-item {
  1498. .uni-calendar-item__weeks-box-item {
  1499. .uni-calendar-item__weeks-box-circle {
  1500. width: calc(8px + .5*(1rem - 16px)) !important;
  1501. height: calc(8px + .5*(1rem - 16px)) !important;
  1502. top: calc(5px - .25*(1rem - 16px)) !important;
  1503. right: calc(5px - .25*(1rem - 16px)) !important;
  1504. }
  1505. .uni-calendar-item__weeks-box-text {
  1506. font-size: calc(14px + .5*(1rem - 16px)) !important;
  1507. }
  1508. .uni-calendar-item__weeks-lunar-text {
  1509. font-size: calc(12px + .5*(1rem - 16px)) !important;
  1510. }
  1511. }
  1512. }
  1513. }
  1514. }
  1515. .uni-date-changed {
  1516. .uni-date-changed--time-date {
  1517. font-size: calc(14px + 1*(1rem - 16px)) !important;
  1518. }
  1519. .uni-datetime-picker-text {
  1520. font-size: calc(14px + 1*(1rem - 16px)) !important;
  1521. }
  1522. }
  1523. }
  1524. .username {
  1525. color: #2979ff;
  1526. }
  1527. </style>