index.vue 54 KB

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