index.vue 46 KB

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