index.vue 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607
  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 } 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. if (processInfo.tinsId) {
  476. // 待办审批流程表单数据todo
  477. getProcessFormInfoInFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  478. console.log('returnParams', returnParams);
  479. const modifyReturnParams = (returnParams) => {
  480. return returnParams.formElements.map(element => {
  481. if (element.type === "5") {
  482. // 将 defaultValue 按逗号分割成数组
  483. element.defaultValue = element.defaultValue.split(",");
  484. }
  485. return element;
  486. });
  487. };
  488. formElements.value = modifyReturnParams(returnParams)
  489. formInfo.value = returnParams.formInfo[0]
  490. repeatingForm.value = returnParams.repeatingForm
  491. getMainFormRule()
  492. computedMainFormValue()
  493. if (returnParams.isCancel == 1) {
  494. isCancel.value = true
  495. }
  496. repeatingFormHasValue()
  497. bindTimeRangeData()
  498. remark.value = flowInfo.value.seModel == '0' ? '同意' : '重新提交'
  499. })
  500. } else {
  501. // 我的 在办 办结流程表单数据 todo
  502. getProcessFormInfo(userStore.user.useId, processInfo.insId).then(({ returnParams }) => {
  503. formElements.value = returnParams.formElements
  504. repeatingForm.value = returnParams.repeatingForm
  505. fileList.value = returnParams.fileList
  506. if (returnParams.isCancel == 1) {
  507. isCancel.value = true
  508. }
  509. repeatingFormHasValue()
  510. })
  511. }
  512. }
  513. const options = ref([])
  514. const stepActive = ref(-1)
  515. const flowInfo = ref({
  516. seModel: '0'
  517. })
  518. // 获取流程信息
  519. function initProcessInfo() {
  520. getProcessFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  521. options.value = returnParams.list.map((item, index) => {
  522. const { tmodelName, name, createdate, finishdate, remark, state } = item
  523. if (state == 1) {
  524. stepActive.value = index
  525. }
  526. const title = tmodelName + (name == '' ? '' : ' ( ' + name + ' )')
  527. const desc = '创建时间: ' + createdate
  528. + (finishdate == '' ? '\n' : '\n办理时间: ' + finishdate)
  529. + (remark == '' ? '\n' : '\n环节意见: ' + remark)
  530. return {
  531. title,
  532. desc,
  533. state
  534. }
  535. })
  536. if (stepActive.value === -1) stepActive.value = returnParams.list.length
  537. // 获取未完成过程
  538. if (processInfo.tinsId) {
  539. getProcessFlowInfo(userStore.user.useId, processInfo).then(({ returnParams }) => {
  540. options.value.push({ title: returnParams.nextTmodels[0].nextTmodelName })
  541. flowInfo.value = returnParams.flow[0]
  542. fileList.value = [
  543. { files: returnParams.flow[0].files }
  544. ]
  545. processInfo.reqOffice = returnParams.tmodel.reqOffice
  546. processInfo.reqRemark = returnParams.tmodel.reqRemark
  547. })
  548. }
  549. console.log('options', options.value);
  550. })
  551. }
  552. // 下拉框
  553. function bindPickerChange(e, item) {
  554. const index = e.detail.value;
  555. item.defaultValue = item.typeDetail.enum[index].enumVname
  556. }
  557. function formatDict(dict) {
  558. return dict.map(({ enumVname }) => enumVname)
  559. }
  560. //数据选择器
  561. function formatCheckbox(elem) {
  562. let dict = elem.typeDetail.enum
  563. // elem['checkBox'] = ''
  564. return dict.map((item, index) => ({
  565. text: item.enumVname,
  566. value: item.enumVname
  567. }));
  568. }
  569. function changeDataCheckBox(e, elem) {
  570. elem['checkBox'] = e.detail.value.join(",")
  571. // console.log(e)
  572. }
  573. //单选框切换事件
  574. function changeDataSingleCheckBox(){
  575. }
  576. const timeRangeItems = ref([
  577. ['开始时间', '结束时间', '多少小时'],
  578. ['出发时间', '预计返回时间'],
  579. ['出差时间', '返回时间', '出差天数'],
  580. ['出门时间', '预计返回时间'],
  581. ['开始时间', '结束时间', '合计小时'],
  582. ])
  583. // 关联时间变量
  584. function bindTimeRangeData() {
  585. return new Promise<void>((resolve) => {
  586. timeRangeItems.value.forEach((range) => {
  587. const [startName, endName, bindName] = range;
  588. // 找到 startName 和 endName 的索引
  589. const startIndex = formElements.value.findIndex((item) => item.elementName === startName);
  590. const endIndex = formElements.value.findIndex((item) => item.elementName === endName);
  591. const formatDate = (date) => {
  592. const pad = (num) => num.toString().padStart(2, '0');
  593. return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
  594. }
  595. // 只有找到 startName 和 endName 后,才检查 bindName
  596. if (startIndex !== -1 && endIndex !== -1) {
  597. if (formElements.value[startIndex].defaultValue == '') {
  598. formElements.value[startIndex].defaultValue = formatDate(new Date())
  599. } else {
  600. formElements.value[startIndex].defaultValue = formatDate(new Date(formElements.value[startIndex].defaultValue))
  601. }
  602. if (bindName) {
  603. const bindIndex = formElements.value.findIndex((item) => item.elementName === bindName);
  604. if (bindIndex !== -1) {
  605. // 所有匹配项都存在,保存索引
  606. formElements.value[startIndex].endElemIndex = endIndex;
  607. formElements.value[endIndex].startElemIndex = startIndex;
  608. formElements.value[bindIndex].bindTimeRange = {
  609. startIndex,
  610. endIndex
  611. };
  612. setAttendanceSegment() // 获取班次信息
  613. }
  614. } else {
  615. // 没有 bindName,仅保存 start 和 end 的索引
  616. formElements.value[startIndex].endElemIndex = endIndex;
  617. formElements.value[endIndex].startElemIndex = startIndex;
  618. }
  619. // TODO 加班开始时间默认当天下班时间 请假时间默认当天上班时间
  620. }
  621. });
  622. resolve(); // 返回一个 resolved 状态的 Promise
  623. });
  624. }
  625. // 计算时间差
  626. function calculateBusinessDifference(item, form) {
  627. return item.defaultValue = (calculateTimeDifference(item, form) / 7).toFixed(2)
  628. }
  629. function calculateTimeDifference(item, form) {
  630. // 获取 开始时间 和 结束时间
  631. const { startIndex, endIndex } = item.bindTimeRange;
  632. const startTime = new Date(form[startIndex].defaultValue);
  633. const endTime = new Date(form[endIndex].defaultValue);
  634. // 检查时间是否合法
  635. if (isNaN(startTime.getTime()) || isNaN(endTime.getTime())) {
  636. return item.defaultValue = 0
  637. }
  638. // 请假申请的时间差 表单项为合计小时
  639. const type = item.elementName == '合计小时' ? '非工作时间' : '工作时间'
  640. // 计算时间差
  641. const timeDifferenceInHours = calculateWorkingHours(startTime, endTime, type);
  642. // const timeDifferenceInMs = endTime - startTime;
  643. // let timeDifferenceInHours = (timeDifferenceInMs / (1000 * 60 * 60)).toFixed(1);
  644. // let timeDifferenceInHours = (timeDifferenceInMs / (1000 * 60 * 60))
  645. // // 计算小数部分
  646. // const decimalPart = timeDifferenceInHours - Math.floor(timeDifferenceInHours)
  647. // if (decimalPart >= 0.5) {
  648. // // 如果小数部分大于等于 0.5,向上取整到 0.5 的倍数
  649. // timeDifferenceInHours = Math.floor(timeDifferenceInHours) + 0.5;
  650. // } else {
  651. // // 如果小数部分小于 0.5,向下取整到 0.5 的倍数
  652. // timeDifferenceInHours = Math.floor(timeDifferenceInHours);
  653. // }
  654. // 保存到 defaultValue
  655. return item.defaultValue = Number(timeDifferenceInHours.toFixed(2));
  656. }
  657. let workingPeriods = [
  658. { start: "09:00", end: "12:00" }, // 上午
  659. { start: "13:30", end: "17:30" }, // 下午
  660. ]
  661. let workDays = [1, 2, 3, 4, 5, 6, 0] // 0为周日
  662. // 获取考勤时间段
  663. function setAttendanceSegment() {
  664. getAttendanceSegment(userStore.user.unitId).then(({ returnParams }) => {
  665. const workTime = returnParams[0].work_time.split(';')
  666. let workDayArr = returnParams[0].work_days.split(',')
  667. let workTimeArr = []
  668. for (const time of workTime) {
  669. if (time == '') continue
  670. const times = time.split(',')
  671. const obj = {
  672. start: times[0],
  673. end: times[1]
  674. }
  675. workTimeArr.push(obj)
  676. }
  677. if (workTimeArr.length != 0) {
  678. workingPeriods = workTimeArr
  679. }
  680. workDayArr = workDayArr.map(item => Number(item))
  681. const sundayIndex = workDayArr.findIndex(item => item == 7)
  682. // console.log('workDays: ', workDayArr);
  683. if (sundayIndex != -1) {
  684. workDayArr[sundayIndex] = 0
  685. }
  686. if (workDayArr.length != 0) {
  687. workDays = workDayArr
  688. }
  689. })
  690. }
  691. function calculateWorkingHours(startTime, endTime, type) {
  692. // 将时间字符串解析为分钟数
  693. const formatTime = (timeString) => {
  694. const [hours, minutes] = timeString.split(":").map(Number)
  695. return hours * 60 + minutes
  696. };
  697. // 计算两个时间段的重叠部分
  698. const calculateOverlap = (start1, end1, start2, end2) => {
  699. const overlapStart = Math.max(start1, start2)
  700. const overlapEnd = Math.min(end1, end2)
  701. return Math.max(0, overlapEnd - overlapStart) // 如果无重叠返回 0
  702. };
  703. // 将 Date 转化为当天的分钟数
  704. const dateToMinutes = (date) => date.getHours() * 60 + date.getMinutes()
  705. // 判断日期是否是工作日
  706. const isRestdays = (date) => !workDays.includes(date.getDay())
  707. // 确保 startTime 和 endTime 是 Date 类型
  708. if (!(startTime instanceof Date) || !(endTime instanceof Date)) {
  709. throw new Error("startTime 和 endTime 必须是 Date 类型")
  710. }
  711. // 将时间范围分解为每天的计算
  712. const startDate = new Date(startTime)
  713. const endDate = new Date(endTime)
  714. startDate.setHours(0, 0, 0, 0)
  715. endDate.setHours(0, 0, 0, 0)
  716. let totalMinutes = 0
  717. // 遍历时间范围的每一天
  718. for (
  719. let currentDate = new Date(startDate);
  720. currentDate <= endDate;
  721. currentDate.setDate(currentDate.getDate() + 1)
  722. ) {
  723. const isStartDay = currentDate.getTime() === startDate.getTime();
  724. const isEndDay = currentDate.getTime() === endDate.getTime();
  725. // 当天的起始和结束时间
  726. const dayStart = isStartDay ? dateToMinutes(startTime) : 0;
  727. const dayEnd = isEndDay ? dateToMinutes(endTime) : 1440; // 1440 = 24 * 60
  728. // TODO 改为配置选择
  729. if (type == "工作时间") {
  730. // 如果当前日期不是工作日,跳过
  731. if (isRestdays(currentDate)) continue;
  732. // 计算工作时间段内的时间
  733. workingPeriods.forEach((period) => {
  734. const periodStart = formatTime(period.start);
  735. const periodEnd = formatTime(period.end);
  736. totalMinutes += calculateOverlap(dayStart, dayEnd, periodStart, periodEnd);
  737. });
  738. } else if (type == "非工作时间") {
  739. if (isRestdays(currentDate)) {
  740. // 计算非工作日时间差
  741. const midnight = new Date(currentDate)
  742. midnight.setHours(24, 0, 0, 0)
  743. const timeDiffInMs = dayEnd - dayStart
  744. totalMinutes += timeDiffInMs
  745. continue
  746. }
  747. // 计算非工作时间段的时间
  748. let nonWorkingMinutes = 0;
  749. let current = dayStart;
  750. for (const period of workingPeriods) {
  751. const periodStart = formatTime(period.start);
  752. const periodEnd = formatTime(period.end);
  753. if (current < periodStart) {
  754. nonWorkingMinutes += calculateOverlap(current, dayEnd, current, periodStart);
  755. }
  756. current = Math.max(current, periodEnd);
  757. }
  758. if (current < dayEnd) {
  759. nonWorkingMinutes += dayEnd - current;
  760. }
  761. totalMinutes += nonWorkingMinutes;
  762. }
  763. }
  764. // 转换为小时
  765. return totalMinutes / 60;
  766. }
  767. function setTimeRange(e) {
  768. // console.log('setTimeRange', e)
  769. }
  770. // 生成人民币大写
  771. function computedNumberToChineseCurrency(item, form) {
  772. const elem = form.find(elem => !elem.elementName.endsWith('大写') && (elem.BddzText == item.BddzText || elem.elementName == item.BddzText.slice(3)))
  773. if(elem != null) {
  774. console.log("大写转换")
  775. return item.defaultValue = convertToChineseCurrency(elem.defaultValue);
  776. } else {
  777. return '';
  778. }
  779. }
  780. // 按照公式统计数据
  781. function computedBddzTextValue(item) {
  782. const mainIndex = formElements.value.findIndex(({ elementName }) => elementName == item.BddzText.slice(3))
  783. const reIndex = repeatingForm.value.elementItem.findIndex(({ elementName }) => elementName == item.BddzText)
  784. if (item.defaultValue) {
  785. if (mainIndex != -1) {
  786. return item.defaultValue = formElements.value[mainIndex].defaultValue
  787. }
  788. if (reIndex != -1) {
  789. return computedValueToRepeatingForm(item)
  790. }
  791. }
  792. }
  793. // 统计重复表数据
  794. function computedValueToRepeatingForm(item) {
  795. const index = repeatingForm.value.elementItem.findIndex(({ elementName }) => elementName.slice(3) == item.BddzText.slice(3))
  796. let result = 0
  797. for (const formItem of repeatingForm.value.elements) {
  798. result += Number(formItem[index].defaultValue) || 0
  799. }
  800. if (item.defaultValue) {
  801. return item.defaultValue = Number(result.toFixed(2))
  802. }
  803. }
  804. function digitInput(event, item) {
  805. // 获取输入框当前的值
  806. let currentValue = event;
  807. // 过滤非数字和小数点的字符
  808. currentValue = currentValue.replace(/[^0-9.]/g, '');
  809. // 处理前导零的情况:
  810. // 如果当前值没有小数点(即是整数),去掉前导零
  811. if (currentValue.indexOf('.') === -1) {
  812. currentValue = currentValue.replace(/^0+(?=\d)/, ''); // 只有当有数字跟随时才去掉前导零
  813. } else {
  814. // 如果包含小数点,处理整数部分的前导零,保留小数部分
  815. let parts = currentValue.split('.');
  816. parts[0] = parts[0].replace(/^0+(?=\d)/, ''); // 只去掉整数部分的前导零
  817. currentValue = parts.join('.'); // 重新拼接
  818. }
  819. // 防止多个小数点
  820. const parts = currentValue.split('.');
  821. let finalValue;
  822. if (parts.length > 2) {
  823. // 如果有多个小数点,保留第一个小数点及后续数字
  824. finalValue = parts[0] + '.' + parts[1];
  825. } else {
  826. finalValue = currentValue;
  827. }
  828. // 更新最终结果到 item
  829. nextTick(() => {
  830. item.defaultValue = finalValue;
  831. event = finalValue; // 更新输入框的值
  832. });
  833. return event;
  834. }
  835. // 计算重复表关联变量表达式结果值
  836. function calculateRepeatingFormExpression(item, form) {
  837. // 提取表达式中的变量名
  838. const variablePattern = /my:[\u4e00-\u9fa5]+/g;
  839. let match;
  840. let expression = item.BddzText
  841. // 替换表达式中的变量
  842. while ((match = variablePattern.exec(item.BddzText)) !== null) {
  843. const variableName = match[0]; // 完整变量名
  844. // 找到 重复表 中对应的索引
  845. const index = repeatingForm.value.elementItem.findIndex(item => item.elementName === variableName);
  846. if (index !== -1) {
  847. const value = form[index]?.defaultValue || 0;
  848. expression = expression.replace(match[0], value);
  849. } else {
  850. // 未匹配到的变量替换为 0
  851. expression = expression.replace(match[0], 0);
  852. }
  853. }
  854. if (/[^0-9\+\-\*\/\(\)\.]/.test(expression)) {
  855. console.error('错误的表达式:', expression);
  856. $modal.msg('自动计算错误,请手动输入')
  857. return item.defaultValue = 0;
  858. }
  859. return item.defaultValue = Number(calCommonExp(expression).toFixed(2)); // 返回填充后的表达式
  860. }
  861. const signaturePopup = ref(null)
  862. const signatureRef = ref(null)
  863. const signaturePopupShow = ref(false)
  864. const isLandscape = ref(false)
  865. const signatureItemIndex = ref(-1)
  866. function handleSignature(index) {
  867. signatureItemIndex.value = index
  868. signaturePopup.value.open()
  869. initSignature()
  870. }
  871. // 初始化签字板
  872. function initSignature() {
  873. signaturePopupShow.value = false
  874. setTimeout(() => {
  875. signaturePopupShow.value = true
  876. }, 100)
  877. }
  878. // 点击签字板按钮
  879. function onclickSignatureButton(event) {
  880. // console.log('onclickSignatureButton: ', event);
  881. switch (event) {
  882. case 'undo':
  883. signatureRef.value.undo()
  884. break;
  885. case 'clear':
  886. signatureRef.value.clear()
  887. break;
  888. case 'save':
  889. signatureRef.value.canvasToTempFilePath({
  890. success: (res : LSignatureToFileSuccess) => {
  891. if (res.isEmpty) {
  892. $modal.msgError('签名不能为空!')
  893. return
  894. }
  895. // 判断上传文件是否是base64
  896. if (res.tempFilePath.substring(0, 'data:image/png;base64,'.length) == 'data:image/png;base64,') {
  897. const _fileData = res.tempFilePath
  898. uploadSignatureBoardImg(userStore.user.useId, _fileData, formElements.value[signatureItemIndex.value].tableField)
  899. .then(({ returnParams }) => {
  900. formElements.value[signatureItemIndex.value].defaultValue = returnParams.sealInsID
  901. formElements.value[signatureItemIndex.value].sealImgPath = returnParams.path
  902. signatureItemIndex.value = -1
  903. signaturePopupShow.value = false
  904. signaturePopup.value.close()
  905. })
  906. } else {
  907. // 转 base64
  908. wx.getFileSystemManager().readFile({
  909. filePath: res.tempFilePath,
  910. encoding: 'base64',
  911. success: fileData => {
  912. const _fileData = 'data:image/png;base64,' + fileData.data
  913. uploadSignatureBoardImg(userStore.user.useId, _fileData, formElements.value[signatureItemIndex.value].tableField)
  914. .then(({ returnParams }) => {
  915. formElements.value[signatureItemIndex.value].defaultValue = returnParams.sealInsID
  916. formElements.value[signatureItemIndex.value].sealImgPath = returnParams.path
  917. signatureItemIndex.value = -1
  918. signaturePopupShow.value = false
  919. signaturePopup.value.close()
  920. })
  921. }
  922. })
  923. }
  924. }
  925. } as LSignatureToTempFilePathOptions)
  926. break;
  927. case 'landscape':
  928. isLandscape.value = !isLandscape.value
  929. initSignature()
  930. break;
  931. }
  932. }
  933. function onclickAutosealButton(index) {
  934. if (signatureItemIndex.value != -1) index = signatureItemIndex.value
  935. getSeal(userStore.user.useId).then(({ returnParams }) => {
  936. formElements.value[index].defaultValue = returnParams.sealFileId.universalid
  937. formElements.value[index].sealImgPath = returnParams.sealFileId.path
  938. signaturePopupShow.value = false
  939. signaturePopup.value.close()
  940. })
  941. }
  942. function closeSignaturePopup() {
  943. signatureItemIndex.value = -1
  944. signaturePopupShow.value = false
  945. }
  946. const repeatingFormPopup = ref(null)
  947. // 查看重复表
  948. function handleRepeatingForm() {
  949. repeatingFormPopup.value.open()
  950. }
  951. // 附件管理
  952. function deleteFile(file) {
  953. // console.log('deleteFile: ',file);
  954. fileList.value[0].files = fileList.value[0].files.filter(({ fileId }) => !(fileId == file.fileId))
  955. }
  956. // 上传附件
  957. const subFileList = ref([]) // 文件列表
  958. const subFileSeqs = ref([])
  959. async function handleFileSelect(files) { // 新增文件
  960. // console.log('handleFileSelect', files.tempFiles)
  961. files.tempFiles.forEach(file => {
  962. const data = {
  963. name: file.name,
  964. filePath: file.path,
  965. }
  966. uploadFile(data)
  967. .then(res => {
  968. file.seq = res.returnParams
  969. subFileSeqs.value.push({ 'seq': res.returnParams, 'path': file.path })
  970. subFileList.value.push(file)
  971. $modal.msgSuccess('文件' + data.name + '上传成功')
  972. })
  973. .catch(err => {
  974. $modal.msgError('文件' + data.name + '上传失败,请删除重新上传')
  975. switch (err) {
  976. case -201:
  977. console.log('文件上传失败 未找到该文件');
  978. break;
  979. case -20201:
  980. console.log('文件上传失败 返回值不是JSON字符串');
  981. break;
  982. }
  983. })
  984. })
  985. // console.log('UploadFiles', files.tempFiles);
  986. }
  987. // 文件上传触发事件
  988. function handleFileProgress(file, progress) {
  989. // console.log('handleFileProgress', file, progress);
  990. }
  991. function handleFileSuccess(file, res) {
  992. // console.log('handleFileSuccess', file, res);
  993. }
  994. function handleFileFail(file, err) {
  995. // console.log('handleFileFail', file, err);
  996. }
  997. function handleFileDelete(file) { // 移除文件
  998. // console.log('handleDelete', file)
  999. subFileSeqs.value.splice(subFileSeqs.value.findIndex(({ path }) => path == file.tempFilePath))
  1000. }
  1001. const $mainForm = ref(null)
  1002. const $mainFormRules = ref({})
  1003. const mainFormValue = ref({})
  1004. const repeatingFormsValue = ref([])
  1005. const formatTypeDict = {
  1006. '0': 'string',
  1007. '1': 'number'
  1008. }
  1009. function computedMainFormValue() {
  1010. // 设置主表校验数据
  1011. mainFormValue.value = computed(() => {
  1012. const obj = {};
  1013. formElements.value.forEach(elem => {
  1014. if (!('0' != elem.canEdit && '8' != elem.type)) return
  1015. obj[elem.elementId] = elem.defaultValue;
  1016. });
  1017. return obj;
  1018. }).value
  1019. }
  1020. // 获取主表校验规则
  1021. function getMainFormRule() {
  1022. $mainFormRules.value = computed(() => {
  1023. const obj = {};
  1024. formElements.value.forEach(elem => {
  1025. if (!('0' != elem.canEdit && '8' != elem.type)) return
  1026. let labelName = elem.elementName
  1027. let errorMessage = ''
  1028. if ('13' == elem.type) errorMessage = '请完成签名'
  1029. obj[elem.elementId] = {
  1030. rules: [
  1031. {
  1032. required: '1' == elem.noNull,
  1033. errorMessage,
  1034. },
  1035. // {
  1036. // format: formatTypeDict[elem.fieldType] || 'string',
  1037. // }
  1038. ],
  1039. label: labelName
  1040. };
  1041. });
  1042. return obj;
  1043. }).value
  1044. }
  1045. function validateRepeatingForm2() {
  1046. // 设置重复表校验数据
  1047. const filterElements = repeatingForm.value.elements.filter(item => item.canEdit == "1")
  1048. if (filterElements.length == 0) return true
  1049. repeatingFormsValue.value = filterElements.map((item, index) => {
  1050. return computed(() => {
  1051. const obj = {};
  1052. item.forEach(({ name, defaultValue }) => {
  1053. obj[name] = defaultValue;
  1054. });
  1055. return obj;
  1056. }).value
  1057. })
  1058. let flag = false
  1059. repeatingFormsValue.value.forEach((item, index) => {
  1060. let ItemIndex = 0
  1061. for (const elem in item) {
  1062. if (item[elem] == '') {
  1063. const name = repeatingForm.value.elementItem[ItemIndex].elementName.slice(3)
  1064. $modal.msgError(`详情表 ${name} 数据填写错误`)
  1065. flag = false
  1066. return
  1067. }
  1068. ItemIndex++
  1069. }
  1070. flag = true
  1071. })
  1072. return flag
  1073. }
  1074. const button_state = ref(true)
  1075. const remark = ref('')
  1076. function handleSubmitProcess(result) {
  1077. let content = '确认退回'
  1078. if (result == "1") {
  1079. content = '确认通过'
  1080. }
  1081. $modal.confirm(content).then(() => {
  1082. button_state.value = false
  1083. if (result == "1") {
  1084. // 处理主表校验数据
  1085. mainFormValue.value = computed(() => {
  1086. const obj = {};
  1087. formElements.value.forEach(elem => {
  1088. let value = elem.defaultValue
  1089. if (!('0' != elem.canEdit && '8' != elem.type)) return
  1090. if ('5' == elem.type && Array.isArray(elem.defaultValue)) {
  1091. value = elem.defaultValue.join(",")
  1092. }
  1093. obj[elem.elementId] = value;
  1094. });
  1095. return obj;
  1096. }).value
  1097. // console.log('$mainForm.value: ', $mainForm.value);
  1098. // 主表数据校验
  1099. $mainForm.value.validate().then(res => {
  1100. // 重复表数据校验
  1101. if (repeatingFormNotEmpty.value && !validateRepeatingForm2()) {
  1102. button_state.value = true
  1103. return
  1104. }
  1105. submitProcess(result)
  1106. })
  1107. .catch(err => {
  1108. button_state.value = true
  1109. $modal.msgError('表单填写错误')
  1110. })
  1111. } else {
  1112. submitProcess(result)
  1113. }
  1114. }).catch(() => { })
  1115. }
  1116. function submitProcess(result) {
  1117. let flow = Object.assign({}, flowInfo.value)
  1118. formInfo.value.formElements = formElements.value
  1119. // 过滤不可编辑的表单项
  1120. .filter(({ canEdit }) => canEdit == '1')
  1121. .map(({ tableField, defaultValue, type }) => {
  1122. let value = defaultValue
  1123. if ('5' == type && Array.isArray(defaultValue)) {
  1124. value = defaultValue.join(",")
  1125. }
  1126. return {
  1127. name: tableField,
  1128. value
  1129. }
  1130. })
  1131. repeatingForm.value.elements.forEach((table, index) => {
  1132. const newItem = table.map((item) => {
  1133. item['value'] = item.defaultValue
  1134. return item
  1135. })
  1136. formInfo.value.formElements.push(...newItem)
  1137. })
  1138. flow['staffId'] = userStore.user.useId
  1139. flow['gxId'] = userStore.user.gxId
  1140. flow['groupId'] = flowInfo.value.groupid
  1141. if (result == "1") {
  1142. const seqs = subFileSeqs.value.map(({ seq }) => seq)
  1143. if (flowInfo.value.seModel == '0' && processInfo.reqOffice == 1 && seqs.length == 0) {
  1144. button_state.value = true
  1145. $modal.msgError('请上传附件')
  1146. return
  1147. } else {
  1148. flow['fileIds'] = seqs
  1149. }
  1150. if (processInfo.reqRemark == 1 && remark.value == '') {
  1151. button_state.value = true
  1152. $modal.msgError('请填写备注')
  1153. return
  1154. }
  1155. } else {
  1156. flow.fileIds = []
  1157. flow.files = []
  1158. }
  1159. flow['remark'] = remark.value
  1160. // result: 1通过 2退回发起人 0退回上一级
  1161. flow['result'] = result
  1162. flow['nextTmodelId'] = 'undefined'
  1163. submitProcessFlow(flow, formInfo.value, processInfo.control).then(({ returnMsg }) => {
  1164. if (returnMsg.includes('提交失败')) {
  1165. // 启用提交按钮
  1166. button_state.value = true
  1167. $modal.msgError(returnMsg)
  1168. } else {
  1169. $modal.msgSuccess(returnMsg)
  1170. // 通知列表刷新数据
  1171. uni.$emit('ReloadProcessData');
  1172. setTimeout(() => {
  1173. $tab.navigateBack();
  1174. }, 1000)
  1175. }
  1176. })
  1177. }
  1178. // 取消流程
  1179. function handleCancelProcess() {
  1180. if (remark.value.trim() == '') {
  1181. $modal.msgError('备注不能为空!')
  1182. return
  1183. }
  1184. $modal.confirm('确认撤销').then(() => {
  1185. cancelProcess()
  1186. }).catch(() => { })
  1187. }
  1188. function cancelProcess() {
  1189. cancelProcessFlow(userStore.user.useId, remark.value, processInfo).then(({ returnMsg }) => {
  1190. if (returnMsg.includes('success')) {
  1191. $modal.msgSuccess('撤销成功')
  1192. // 通知列表刷新数据
  1193. uni.$emit('ReloadProcessData');
  1194. setTimeout(() => {
  1195. $tab.navigateBack();
  1196. }, 1000)
  1197. } else {
  1198. // 启用按钮
  1199. button_state.value = true
  1200. $modal.msgError(returnMsg)
  1201. }
  1202. })
  1203. }
  1204. </script>
  1205. <style lang="scss" scoped>
  1206. ::v-deep .uni-section {
  1207. margin-left: -15px;
  1208. margin-bottom: 10px;
  1209. }
  1210. .signature_container {
  1211. background-color: #f5f5f5;
  1212. height: 40vh;
  1213. width: 90vw;
  1214. .signature_content {
  1215. height: 80%;
  1216. width: 100%;
  1217. }
  1218. .signature_button_container {
  1219. height: 20%;
  1220. width: 100%;
  1221. button {
  1222. height: 100%;
  1223. }
  1224. }
  1225. }
  1226. .signature_container_landscape {
  1227. height: 100vh;
  1228. width: 100vw;
  1229. .signature_content {
  1230. height: 85%;
  1231. width: 100%;
  1232. }
  1233. .signature_button_container {
  1234. margin-top: 10%;
  1235. height: 15%;
  1236. width: 100%;
  1237. button {
  1238. height: 100%;
  1239. width: 100%;
  1240. transform: rotate(90deg);
  1241. }
  1242. }
  1243. }
  1244. .process_detail_container {
  1245. position: relative;
  1246. ::v-deep uni-card{
  1247. .uni-card{
  1248. padding: 0 8px !important;
  1249. }
  1250. }
  1251. .repeating_table {
  1252. ::v-deep .uni-forms {
  1253. .uni-forms-item__label {
  1254. font-size: calc(1rem + 0px) !important;
  1255. line-height: calc(1rem + 0px) !important;
  1256. font-weight: 700;
  1257. }
  1258. .uni-forms-item__content {
  1259. font-size: calc(14px + (1rem - 16px)) !important;
  1260. font-weight: 500;
  1261. .uni-easyinput__content-input {
  1262. height: calc(35px + .5*(1rem - 16px)) !important;
  1263. font-size: calc(14px + (1rem - 16px)) !important;
  1264. font-weight: 500;
  1265. }
  1266. }
  1267. }
  1268. ::v-deep .uni-forms-item--border {
  1269. padding: 5px 0 !important;
  1270. }
  1271. .repeating_table_button_container {
  1272. margin-top: 5px;
  1273. button {
  1274. height: 36px;
  1275. line-height: 36px;
  1276. color: #fff;
  1277. }
  1278. .add {
  1279. background-color: #1ca035;
  1280. }
  1281. .del {
  1282. background-color: #e64340;
  1283. }
  1284. }
  1285. }
  1286. .main_container {
  1287. min-height: 40vh;
  1288. ::v-deep .uni-forms {
  1289. .uni-forms-item__label {
  1290. font-size: calc(1rem + 0px) !important;
  1291. line-height: calc(1rem + 0px) !important;
  1292. font-weight: 700;
  1293. }
  1294. .uni-forms-item__content {
  1295. font-size: calc(14px + (1rem - 16px)) !important;
  1296. font-weight: 500;
  1297. .uni-easyinput__content-textarea {
  1298. font-size: calc(14px + (1rem - 16px)) !important;
  1299. font-weight: 500;
  1300. }
  1301. .uni-easyinput__content-input {
  1302. height: calc(35px + .5*(1rem - 16px)) !important;
  1303. font-size: calc(14px + (1rem - 16px)) !important;
  1304. font-weight: 500;
  1305. color: #333;
  1306. }
  1307. .uni-date {
  1308. .uni-icons {
  1309. font-size: calc(22px + 1.2*(1rem - 16px)) !important;
  1310. font-weight: 500;
  1311. }
  1312. .uni-date__x-input {
  1313. height: auto;
  1314. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1315. font-weight: 500;
  1316. }
  1317. }
  1318. }
  1319. }
  1320. .element_value_container {
  1321. .signature_img {
  1322. width: 180px;
  1323. }
  1324. .element_value {
  1325. line-height: 36px;
  1326. }
  1327. }
  1328. }
  1329. // ::v-deep .repeating_table_detail2{
  1330. // .uni-forms-item__content{
  1331. // margin: auto;
  1332. // }
  1333. // .uni-forms{
  1334. // border-top: 2px #eee solid;
  1335. // }
  1336. // .uni-forms-item__label {
  1337. // width: 125px !important;
  1338. // font-size: calc(1rem + 0px) !important;
  1339. // line-height: calc(1rem + 0px) !important;
  1340. // font-weight: 700;
  1341. // }
  1342. // .uni-forms-item__content {
  1343. // font-size: calc(14px + (1rem - 16px)) !important;
  1344. // font-weight: 500;
  1345. // .uni-date {
  1346. // .uni-icons {
  1347. // font-size: calc(22px + 1.2*(1rem - 16px)) !important;
  1348. // font-weight: 500;
  1349. // }
  1350. // }
  1351. // }
  1352. // }
  1353. ::v-deep .repeating_table_detail {
  1354. .uni-card {
  1355. padding: 0 !important;
  1356. }
  1357. .uni-card__content {
  1358. padding: 0 !important;
  1359. }
  1360. .uni-section {
  1361. margin: 10px 5px;
  1362. }
  1363. }
  1364. ::v-deep .repeating_table_container {
  1365. width: 92vw;
  1366. .uni-table-scroll {
  1367. max-height: 80vh;
  1368. .uni-table {
  1369. min-width: 100% !important;
  1370. .uni-table-th {
  1371. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1372. min-width: calc(50px + 2.5*(1rem - 16px));
  1373. background-color: #2979ff;
  1374. font-weight: bold;
  1375. color: #fcfcfc;
  1376. }
  1377. .uni-table-td {
  1378. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1379. }
  1380. }
  1381. }
  1382. }
  1383. ::v-deep .file_picker_container {
  1384. .uni-card {
  1385. .uni-card__header-content-title {
  1386. font-size: calc(15px + .5*(1rem - 16px));
  1387. }
  1388. .uni-card__header-extra-text {
  1389. font-size: calc(15px + .5*(1rem - 16px));
  1390. }
  1391. }
  1392. }
  1393. ::v-deep .flow_step_container {
  1394. min-height: 200px;
  1395. .u-steps {
  1396. .u-steps-item {
  1397. padding-bottom: 11px;
  1398. .u-text__value--tips {
  1399. font-size: calc(12px + .5*(1rem - 16px)) !important;
  1400. }
  1401. .redcontent {
  1402. .u-text__value--content {
  1403. color: #ff4500;
  1404. }
  1405. }
  1406. .active_step_circle {
  1407. width: 20px;
  1408. height: 20px;
  1409. box-sizing: border-box;
  1410. flex-shrink: 0;
  1411. border-radius: 100px;
  1412. border-width: 1px;
  1413. border-color: #A78BFA;
  1414. background-color: #A78BFA;
  1415. border-style: solid;
  1416. display: flex;
  1417. flex-direction: row;
  1418. align-items: center;
  1419. justify-content: center;
  1420. transition: background-color .3s;
  1421. .active_step_text {
  1422. color: #fff;
  1423. font-size: 11px;
  1424. display: flex;
  1425. flex-direction: row;
  1426. align-items: center;
  1427. justify-content: center;
  1428. text-align: center;
  1429. line-height: 11px;
  1430. }
  1431. }
  1432. }
  1433. .u-steps-item view:last-of-type {
  1434. margin-top: 0 !important;
  1435. .u-text__value--content {
  1436. font-size: calc(16px + .5*(1rem - 16px)) !important;
  1437. }
  1438. .u-text__value--main {
  1439. font-size: calc(16px + .5*(1rem - 16px)) !important;
  1440. font-weight: 500;
  1441. }
  1442. }
  1443. }
  1444. }
  1445. .approve_button {
  1446. position: sticky;
  1447. z-index: 10;
  1448. width: 100%;
  1449. bottom: 10px;
  1450. }
  1451. }
  1452. ::v-deep button {
  1453. font-size: calc(18px + .5*(1rem - 16px));
  1454. }
  1455. .reject_button {
  1456. ::v-deep .uni-card {
  1457. background-color: #f5f5f5;
  1458. }
  1459. }
  1460. .remark_container {
  1461. .remark_content {
  1462. margin-bottom: 10px;
  1463. ::v-deep .uni-easyinput {
  1464. .uni-easyinput__content-textarea {
  1465. font-size: calc(14px + .5*(1rem - 16px)) !important;
  1466. }
  1467. }
  1468. }
  1469. }
  1470. ::v-deep .uni-calendar__content {
  1471. margin: -20px;
  1472. margin-top: 20px;
  1473. .uni-calendar__header {
  1474. .uni-calendar__header-text {
  1475. font-size: calc(14px + .5*(1rem - 16px)) !important;
  1476. }
  1477. .uni-calendar__backtoday {
  1478. padding: 2px 8px 2px 10px !important;
  1479. font-size: calc(0.75rem + 0px) !important;
  1480. }
  1481. }
  1482. .uni-calendar__box {
  1483. .uni-calendar__weeks {
  1484. .uni-calendar__weeks-day {
  1485. .uni-calendar__weeks-day-text {
  1486. font-size: calc(14px + .5*(1rem - 16px)) !important;
  1487. }
  1488. }
  1489. .uni-calendar__weeks-item {
  1490. .uni-calendar-item__weeks-box-item {
  1491. .uni-calendar-item__weeks-box-circle {
  1492. width: calc(8px + .5*(1rem - 16px)) !important;
  1493. height: calc(8px + .5*(1rem - 16px)) !important;
  1494. top: calc(5px - .25*(1rem - 16px)) !important;
  1495. right: calc(5px - .25*(1rem - 16px)) !important;
  1496. }
  1497. .uni-calendar-item__weeks-box-text {
  1498. font-size: calc(14px + .5*(1rem - 16px)) !important;
  1499. }
  1500. .uni-calendar-item__weeks-lunar-text {
  1501. font-size: calc(12px + .5*(1rem - 16px)) !important;
  1502. }
  1503. }
  1504. }
  1505. }
  1506. }
  1507. .uni-date-changed {
  1508. .uni-date-changed--time-date {
  1509. font-size: calc(14px + 1*(1rem - 16px)) !important;
  1510. }
  1511. .uni-datetime-picker-text {
  1512. font-size: calc(14px + 1*(1rem - 16px)) !important;
  1513. }
  1514. }
  1515. }
  1516. </style>