index.vue 54 KB

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