index.vue 48 KB

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