index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  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. <uni-easyinput v-if="'1' == elem.type" placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))" placeholder="请输入内容"
  16. v-model="elem.defaultValue" type="textarea"></uni-easyinput>
  17. <!-- 文本框 -->
  18. <uni-easyinput v-else-if="'0' == elem.type" placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))" placeholder="请输入内容"
  19. v-model="elem.defaultValue" type="text"></uni-easyinput>
  20. <!-- 下拉框 -->
  21. <picker class="picker_container" v-else-if="'2' == elem.type"
  22. @change="bindPickerChange($event, elem)" :value="elem.defaultValue"
  23. :range="formatDict(elem.typeDetail.enum)">
  24. <view class="uni-input input_text">
  25. <!-- 设置默认值为第一个选项 -->
  26. {{ elem.defaultValue ? elem.defaultValue : elem.defaultValue =
  27. elem.typeDetail.enum[0].enumVname }}
  28. </view>
  29. </picker>
  30. <!-- 年月日 时分秒 -->
  31. <uni-datetime-picker v-else-if="'9' == elem.type" v-model="elem.defaultValue"
  32. type="datetime" />
  33. <!-- 年月日 -->
  34. <uni-datetime-picker v-else-if="'3' == elem.type" v-model="elem.defaultValue"
  35. type="date" />
  36. <!-- 审批签字板 -->
  37. <view v-else-if="'13' == elem.type">
  38. <button v-if="elem.defaultValue == ''" type="primary"
  39. @click="handleSignature(index)">签名</button>
  40. <view v-else class="signature_img">
  41. <img style="width: 100%;" mode="widthFix" @click="handleSignature(index)"
  42. :src="config.baseUrlPre + elem.sealImgPath"
  43. :alt="elem.elementName + '签名'" />
  44. </view>
  45. </view>
  46. </view>
  47. <view v-else-if="typeof elem.sealImgPath === 'string' && elem.sealImgPath.startsWith('/shares')" class="signature_img">
  48. <img style="width: 100%;" mode="widthFix"
  49. :src="config.baseUrlPre + elem.sealImgPath" />
  50. </view>
  51. <view v-else-if="typeof elem.defaultValue === 'string' && elem.defaultValue.startsWith('/shares')" class="signature_img">
  52. <img style="width: 100%;" mode="widthFix"
  53. :src="config.baseUrlPre + elem.defaultValue" />
  54. </view>
  55. <text class="element_value" v-else>{{ elem.defaultValue }}</text>
  56. </view>
  57. </uni-forms-item>
  58. </view>
  59. </uni-forms>
  60. </view>
  61. </uni-card>
  62. <view class="repeating_table">
  63. <!-- 重复表 -->
  64. <uni-card v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty" spacing="0" padding="0">
  65. <button @click="handleRepeatingForm" type="primary">查看明细</button>
  66. </uni-card>
  67. <uni-card v-else v-for="(table, tableIndex) in repeatingForm.elements" spacing="0" :key="tableIndex">
  68. <uni-forms label-position="left" :label-width="125" :border="true">
  69. <uni-forms-item :name="elem.tableField" v-for="(elem, itemIndex) in table"
  70. :label="repeatingForm.elementItem[itemIndex].elementName.slice(3)" :key="itemIndex">
  71. <uni-easyinput placeholder="请输入内容" v-model="elem.defaultValue"
  72. :type="fieldTypeDict[repeatingForm.elementItem[itemIndex].fieldType.value] || 'text'" placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
  73. </uni-forms-item>
  74. </uni-forms>
  75. <!-- <view class="repeating_table_button_container">
  76. <uni-row>
  77. <uni-col :span="10" :offset="1">
  78. <button @click="addrepeatingFormItem(tableIndex)" type="primary">新增</button>
  79. </uni-col>
  80. <uni-col :span="10" :offset="2">
  81. <button @click="delrepeatingFormItem(tableIndex)"
  82. :disabled="repeatingForm.elements.length <= 1" type="warn">删除</button>
  83. </uni-col>
  84. </uni-row>
  85. </view> -->
  86. </uni-card>
  87. <uni-popup v-if="flowInfo.seModel == '0' && repeatingFormNotEmpty" ref="repeatingFormPopup">
  88. <uni-card margin="0px" spacing="0px" padding="0px">
  89. <view class="repeating_table_container">
  90. <uni-table :border="true" stripe>
  91. <uni-tr>
  92. <uni-th align="center" v-for="(item, index) in repeatingForm.elementItem" :key="index">
  93. {{ item.elementName.slice(3, 5) }}
  94. </uni-th>
  95. </uni-tr>
  96. <uni-tr v-for="(table, tableIndex) in repeatingForm.elements" :key="tableIndex">
  97. <uni-td align="center" v-for="(elem, itemIndex) in table" :key="itemIndex">
  98. {{ elem.defaultValue }}
  99. </uni-td>
  100. </uni-tr>
  101. </uni-table>
  102. </view>
  103. </uni-card>
  104. </uni-popup>
  105. </view>
  106. <!-- 附件 -->
  107. <view v-for="(item, index) in fileList" :key="index">
  108. <uni-card v-if="item.files.length != undefined && item.files.length > 0">
  109. <uni-section titleFontSize="1.3rem" title="附件" type="line"></uni-section>
  110. <attachment-list @clickDelete="deleteFile" :canEdit="flowInfo.seModel == '1'" :attachments="item.files"></attachment-list>
  111. </uni-card>
  112. </view>
  113. <!-- 上传附件 -->
  114. <view v-if="processInfo.tinsId || flowInfo.seModel == '1'" class="file_picker_container">
  115. <uni-card title="上传附件" :extra="`${subFileList.length}/50`" spacing="0">
  116. <uni-file-picker ref="filePicker" v-model="subFileList" :auto-upload="true" mode="list" :limit="50"
  117. file-mediatype="all" @select="handleFileSelect" @progress="handleFileProgress"
  118. @success="handleFileSuccess" @fail="handleFileFail" @delete="handleFileDelete" />
  119. </uni-card>
  120. </view>
  121. <!-- 流转过程 -->
  122. <view>
  123. <uni-card>
  124. <view class="flow_step_container">
  125. <uni-section titleFontSize="1.3rem" title="流转过程" type="line"></uni-section>
  126. <up-steps :current="stepActive" activeColor="#18bc37" inactiveColor="#2979ff" direction="column">
  127. <view v-for="(step, index) in options">
  128. <up-steps-item :contentClass="'redcontent'" v-if="step.state == 3"
  129. :title="step.title + ' 退回'" :desc="step.desc" :key="index" error></up-steps-item>
  130. <up-steps-item :contentClass="'redcontent'" v-else-if="step.state == 0"
  131. :title="step.title + ' 撤销'" :desc="step.desc" :key="index" error></up-steps-item>
  132. <up-steps-item v-else-if="index == stepActive" :title="step.title" :desc="step.desc"
  133. :key="index">
  134. <template #icon>
  135. <view class="active_step_circle">
  136. <text class="active_step_text">{{ index + 1 }}</text>
  137. </view>
  138. </template>
  139. </up-steps-item>
  140. <up-steps-item v-else :title="step.title" :desc="step.desc" :key="index"></up-steps-item>
  141. </view>
  142. </up-steps>
  143. </view>
  144. </uni-card>
  145. </view>
  146. <view v-if="processInfo.tinsId">
  147. <view class="remark_container">
  148. <uni-card>
  149. <uni-section titleFontSize="1.3rem" title="环节备注" type="line"></uni-section>
  150. <view class="remark_content">
  151. <uni-easyinput type="textarea" autoHeight v-model="remark" placeholder="请输入" placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
  152. </view>
  153. </uni-card>
  154. </view>
  155. </view>
  156. <view v-if="processInfo.tinsId" class="approve_button">
  157. <uni-card spacing="0" padding="0">
  158. <button :disabled="!button_state" :loading="!button_state" type="primary"
  159. @click="handleSubmitProcess('1')">
  160. {{ flowInfo.seModel == '0' ? '通过' : '提交' }}
  161. </button>
  162. </uni-card>
  163. </view>
  164. </view>
  165. <view v-if="processInfo.tinsId && flowInfo.seModel == '0'">
  166. <view class="reject_button">
  167. <uni-card spacing="0" padding="0" :is-shadow="false" :border="false">
  168. <uni-row>
  169. <uni-col :span="11">
  170. <button :disabled="!button_state" :loading="!button_state" type="warn"
  171. @click="handleSubmitProcess('0')">退回上一级</button>
  172. </uni-col>
  173. <uni-col :span="11" :offset="2">
  174. <button :disabled="!button_state" :loading="!button_state" type="warn"
  175. @click="handleSubmitProcess('2')">退回发起人</button>
  176. </uni-col>
  177. </uni-row>
  178. </uni-card>
  179. </view>
  180. </view>
  181. <view v-else-if="isCancel">
  182. <view class="remark_container">
  183. <uni-card>
  184. <uni-section titleFontSize="1.3rem" title="撤销备注" type="line"></uni-section>
  185. <view class="remark_content">
  186. <uni-easyinput type="textarea" autoHeight v-model="remark" placeholder="请输入" placeholderStyle="font-size: calc(14px + 1.2*(1rem - 16px))"></uni-easyinput>
  187. </view>
  188. </uni-card>
  189. </view>
  190. <view class="cancel_button_container">
  191. <uni-card spacing="0" padding="0">
  192. <button :disabled="!button_state" :loading="!button_state" type="warn"
  193. @click="handleCancelProcess">撤销</button>
  194. </uni-card>
  195. </view>
  196. </view>
  197. <view style="height: 5px; margin-top: 20px;"></view>
  198. <!-- 签字版弹出层 -->
  199. <uni-popup ref="signaturePopup" @maskClick="closeSignaturePopup">
  200. <view class="signature_container" :class="{ 'signature_container_landscape': isLandscape }">
  201. <view class="signature_content">
  202. <l-signature ref="signatureRef" v-if="signaturePopupShow" :landscape="isLandscape" :penSize="8"
  203. :minLineWidth="4" :maxLineWidth="12" :openSmooth="true" :preferToDataURL="true"
  204. backgroundColor="#ffffff" penColor="black"></l-signature>
  205. </view>
  206. <view class="signature_button_container">
  207. <uni-row :gutter="10">
  208. <uni-col :span="6">
  209. <button type="warn" @click="onclickSignatureButton('undo')">撤销</button>
  210. </uni-col>
  211. <uni-col :span="6">
  212. <button type="warn" @click="onclickSignatureButton('clear')">清空</button>
  213. </uni-col>
  214. <uni-col :span="6">
  215. <button type="primary" @click="onclickSignatureButton('save')">保存</button>
  216. </uni-col>
  217. <uni-col :span="6">
  218. <button @click="onclickSignatureButton('landscape')">全屏</button>
  219. </uni-col>
  220. </uni-row>
  221. </view>
  222. </view>
  223. </uni-popup>
  224. </template>
  225. <script setup lang="ts">
  226. import { computed, onMounted, reactive, ref } from 'vue'
  227. import { onLoad, onShow } from '@dcloudio/uni-app'
  228. import { LSignatureToTempFilePathOptions, LSignatureToFileSuccess } from '@/uni_modules/lime-signature'
  229. import attachmentList from '@/components/ygoa/attachmentList.vue'
  230. import config from '@/config.js'
  231. import $tab from '@/plugins/tab.js'
  232. import $modal from '@/plugins/modal.js'
  233. import { getProcessFlowInfo, getProcessFormInfo, getProcessFormInfoInFlow, getProcessFlow, submitProcessFlow, cancelProcessFlow, uploadSignatureImg, uploadSignatureBoardImg, uploadFile } from '@/api/process.js'
  234. import { useUserStore } from '@/store/user.js'
  235. import {getLoginInfo,getSession,setSession} from '@/utils/auth.js'
  236. import {reLogin,keepSession} from '@/api/login.js'
  237. const fieldTypeDict = {
  238. '0': 'text',
  239. '1': 'digit'
  240. }
  241. const userStore = useUserStore()
  242. const processInfo = reactive({
  243. insId: '',
  244. insName: '',
  245. control: 1,
  246. username: '',
  247. reqOffice: 0,
  248. reqRemark: 0,
  249. tinsId: undefined
  250. })
  251. onLoad(({ insId, tinsId, insName, control }) => {
  252. // 获取传入的标题参数
  253. const title = insName || '流程信息';
  254. processInfo.insId = insId
  255. processInfo.insName = insName
  256. processInfo.control = control
  257. if (tinsId) {
  258. processInfo['tinsId'] = tinsId
  259. }
  260. // 设置导航栏标题
  261. uni.setNavigationBarTitle({
  262. title: title
  263. });
  264. })
  265. onShow(()=>{
  266. keepSession().then(res=>{
  267. if(typeof res === 'number'){
  268. return
  269. }else{
  270. const loginInfo = getLoginInfo()
  271. //如果有登录信息,就自动登录刷session
  272. if(Object.keys(loginInfo).length !== 0){
  273. reLogin(loginInfo.username, loginInfo.password).then((res) => {
  274. if ("ok" === res.data) {
  275. setSession(res.cookies[0].split("=")[1].split(";")[0]);
  276. }
  277. }).catch(res=>{
  278. console.log(res);
  279. })
  280. }else{
  281. $tab.reLaunch({ url: '/pages/login' })
  282. }
  283. }
  284. })
  285. .catch(err=>{
  286. console.log('err',err);
  287. // $tab.navigateBack()
  288. })
  289. })
  290. onMounted(() => {
  291. initProcessForm() // 获取表单数据
  292. initProcessInfo() // 获取流程数据
  293. })
  294. const repeatingForm = ref({
  295. elements: [],
  296. elementItem: [],
  297. })
  298. const repeatingFormNotEmpty = ref(false)
  299. function repeatingFormHasValue() {
  300. if (repeatingForm.value === undefined) return
  301. if (repeatingForm.value.elementItem.length <= 0) return
  302. repeatingForm.value.elements.forEach(({ defaultValue }) => {
  303. if (defaultValue != "") {
  304. repeatingFormNotEmpty.value = true
  305. return new Promise((resolve, reject) => {
  306. resolve(repeatingFormNotEmpty)
  307. })
  308. }
  309. })
  310. }
  311. // 新增重复表表单
  312. function addrepeatingFormItem(index) {
  313. // parseCalculation(repeatingForm.value.elementItem)
  314. const table = repeatingForm.value.elementItem.map(({ tableField, bddzText }) => {
  315. const item = {
  316. name: tableField,
  317. defaultValue: ""
  318. }
  319. if (bddzText != '') {
  320. const mulItem = bddzText.split('*')
  321. // 保存关联数据索引
  322. item['bddzText'] = mulItem.map(item => {
  323. // item['operation '].operands = mulItem.map(item => {
  324. return repeatingForm.value.elementItem.findIndex(({ elementName }) => item == elementName)
  325. })
  326. }
  327. return item
  328. })
  329. repeatingForm.value.elements.splice(index + 1, 0, table)
  330. }
  331. // 删除重复表表单
  332. function delrepeatingFormItem(index) {
  333. $modal.confirm('', '确认删除该重复表数据')
  334. .then(() => {
  335. repeatingForm.value.elements.splice(index, 1)
  336. // $repeatingForms.value.splice(index, 1)
  337. }).catch(() => { })
  338. }
  339. const formElements = ref([])
  340. const formInfo = ref({
  341. formElements: [],
  342. formId: '',
  343. formInsId: ''
  344. })
  345. const fileList = ref([])
  346. const isCancel = ref(false)
  347. function initProcessForm() {
  348. if (processInfo.tinsId) {
  349. // 待办审批流程表单数据
  350. getProcessFormInfoInFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  351. formElements.value = returnParams.formElements
  352. formInfo.value = returnParams.formInfo[0]
  353. repeatingForm.value = returnParams.repeatingForm
  354. getMainFormRule()
  355. if (returnParams.isCancel == 1) {
  356. isCancel.value = true
  357. }
  358. repeatingFormHasValue()
  359. remark.value = flowInfo.value.seModel == '0' ? '同意' : '重新提交'
  360. })
  361. } else {
  362. // 我的 在办 办结流程表单数据
  363. getProcessFormInfo(userStore.user.useId, processInfo.insId).then(({ returnParams }) => {
  364. formElements.value = returnParams.formElements
  365. repeatingForm.value = returnParams.repeatingForm
  366. fileList.value = returnParams.fileList
  367. if (returnParams.isCancel == 1) {
  368. isCancel.value = true
  369. }
  370. repeatingFormHasValue()
  371. })
  372. }
  373. }
  374. const options = ref([])
  375. const stepActive = ref(-1)
  376. const flowInfo = ref({
  377. seModel: '0'
  378. })
  379. function initProcessInfo() {
  380. getProcessFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  381. options.value = returnParams.list.map((item, index) => {
  382. const { tmodelName, name, createdate, finishdate, remark, state } = item
  383. if (state == 1) {
  384. stepActive.value = index
  385. }
  386. const title = tmodelName + (name == '' ? '' : ' ( ' + name + ' )')
  387. const desc = '创建时间: ' + createdate
  388. + (finishdate == '' ? '\n' : '\n办理时间: ' + finishdate)
  389. + (remark == '' ? '\n' : '\n环节意见: ' + remark)
  390. return {
  391. title,
  392. desc,
  393. state
  394. }
  395. })
  396. if (stepActive.value === -1) stepActive.value = returnParams.list.length
  397. // 获取未完成过程
  398. if (processInfo.tinsId) {
  399. getProcessFlowInfo(userStore.user.useId, processInfo).then(({ returnParams }) => {
  400. options.value.push({ title: returnParams.nextTmodels[0].nextTmodelName })
  401. flowInfo.value = returnParams.flow[0]
  402. fileList.value = [
  403. { files: returnParams.flow[0].files }
  404. ]
  405. processInfo.reqOffice = returnParams.tmodel.reqOffice
  406. processInfo.reqRemark = returnParams.tmodel.reqRemark
  407. })
  408. }
  409. })
  410. }
  411. // 下拉框
  412. function bindPickerChange(e, item) {
  413. const index = e.detail.value;
  414. item.defaultValue = item.typeDetail.enum[index].enumVname
  415. }
  416. function formatDict(dict) {
  417. return dict.map(({ enumVname }) => enumVname)
  418. }
  419. const signaturePopup = ref(null)
  420. const signatureRef = ref(null)
  421. const signaturePopupShow = ref(false)
  422. const isLandscape = ref(false)
  423. const signatureItemIndex = ref(-1)
  424. function handleSignature(index) {
  425. signatureItemIndex.value = index
  426. signaturePopup.value.open()
  427. initSignature()
  428. }
  429. function initSignature() {
  430. signaturePopupShow.value = false
  431. setTimeout(() => {
  432. signaturePopupShow.value = true
  433. }, 100)
  434. }
  435. function onclickSignatureButton(event) {
  436. // console.log('onclickSignatureButton: ', event);
  437. switch (event) {
  438. case 'undo':
  439. signatureRef.value.undo()
  440. break;
  441. case 'clear':
  442. signatureRef.value.clear()
  443. break;
  444. case 'save':
  445. signatureRef.value.canvasToTempFilePath({
  446. success: (res: LSignatureToFileSuccess) => {
  447. if (res.isEmpty) {
  448. $modal.msgError('签名不能为空!')
  449. return
  450. }
  451. // 判断上传文件是否是base64
  452. if (res.tempFilePath.substring(0, 'data:image/png;base64,'.length) == 'data:image/png;base64,') {
  453. const _fileData = res.tempFilePath
  454. uploadSignatureBoardImg(userStore.user.useId, _fileData, formElements.value[signatureItemIndex.value].tableField)
  455. .then(({ returnParams }) => {
  456. formElements.value[signatureItemIndex.value].defaultValue = returnParams.sealInsID
  457. formElements.value[signatureItemIndex.value].sealImgPath = returnParams.path
  458. signatureItemIndex.value = -1
  459. signaturePopupShow.value = false
  460. signaturePopup.value.close()
  461. })
  462. } else {
  463. // 转 base64
  464. wx.getFileSystemManager().readFile({
  465. filePath: res.tempFilePath,
  466. encoding: 'base64',
  467. success: fileData => {
  468. const _fileData = 'data:image/png;base64,' + fileData.data
  469. uploadSignatureBoardImg(userStore.user.useId, _fileData, formElements.value[signatureItemIndex.value].tableField)
  470. .then(({ returnParams }) => {
  471. formElements.value[signatureItemIndex.value].defaultValue = returnParams.sealInsID
  472. formElements.value[signatureItemIndex.value].sealImgPath = returnParams.path
  473. signatureItemIndex.value = -1
  474. signaturePopupShow.value = false
  475. signaturePopup.value.close()
  476. })
  477. }
  478. })
  479. }
  480. }
  481. } as LSignatureToTempFilePathOptions)
  482. break;
  483. case 'landscape':
  484. isLandscape.value = !isLandscape.value
  485. initSignature()
  486. break;
  487. }
  488. }
  489. function closeSignaturePopup() {
  490. signatureItemIndex.value = -1
  491. signaturePopupShow.value = false
  492. }
  493. const repeatingFormPopup = ref(null)
  494. // 查看重复表
  495. function handleRepeatingForm() {
  496. repeatingFormPopup.value.open()
  497. }
  498. // 附件管理
  499. function deleteFile(file) {
  500. // console.log('deleteFile: ',file);
  501. fileList.value[0].files = fileList.value[0].files.filter(({fileId}) => !(fileId == file.fileId))
  502. }
  503. // 上传附件
  504. const subFileList = ref([]) // 文件列表
  505. const subFileSeqs = ref([])
  506. async function handleFileSelect(files) { // 新增文件
  507. // console.log('handleFileSelect', files.tempFiles)
  508. files.tempFiles.forEach(file => {
  509. const data = {
  510. name: file.name,
  511. filePath: file.path,
  512. }
  513. uploadFile(data)
  514. .then(res => {
  515. file.seq = res.returnParams
  516. subFileSeqs.value.push({ 'seq': res.returnParams, 'path': file.path })
  517. subFileList.value.push(file)
  518. $modal.msgSuccess('文件' + data.name + '上传成功')
  519. })
  520. .catch(err => {
  521. $modal.msgError('文件' + data.name + '上传失败,请删除重新上传')
  522. switch (err) {
  523. case -201:
  524. console.log('文件上传失败 未找到该文件');
  525. break;
  526. case -20201:
  527. console.log('文件上传失败 返回值不是JSON字符串');
  528. break;
  529. }
  530. })
  531. })
  532. // console.log('UploadFiles', files.tempFiles);
  533. }
  534. function handleFileProgress(file, progress) {
  535. // console.log('handleFileProgress', file, progress);
  536. }
  537. function handleFileSuccess(file, res) {
  538. // console.log('handleFileSuccess', file, res);
  539. }
  540. function handleFileFail(file, err) {
  541. // console.log('handleFileFail', file, err);
  542. }
  543. function handleFileDelete(file) { // 移除文件
  544. // console.log('handleDelete', file)
  545. subFileSeqs.value.splice(subFileSeqs.value.findIndex(({ path }) => path == file.tempFilePath))
  546. }
  547. const $mainForm = ref(null)
  548. const $mainFormRules = ref({})
  549. const mainFormValue = ref({})
  550. const formatTypeDict = {
  551. '0': 'string',
  552. '1': 'number'
  553. }
  554. function validateMainForm() {
  555. }
  556. // 获取主表校验规则
  557. function getMainFormRule() {
  558. $mainFormRules.value = computed(() => {
  559. const obj = {};
  560. formElements.value.forEach(elem => {
  561. if (!('0' != elem.canEdit && '8' != elem.type)) return
  562. let labelName = elem.elementName
  563. let errorMessage = ''
  564. if ('13' == elem.type) errorMessage = '请完成签名'
  565. obj[elem.elementId] = {
  566. rules: [
  567. {
  568. required: '1' == elem.noNull,
  569. errorMessage,
  570. },
  571. // {
  572. // format: formatTypeDict[elem.fieldType] || 'string',
  573. // }
  574. ],
  575. label: labelName
  576. };
  577. });
  578. return obj;
  579. }).value
  580. }
  581. const button_state = ref(true)
  582. const remark = ref('')
  583. function handleSubmitProcess(result) {
  584. let content = '确认退回'
  585. if (result == "1") {
  586. content = '确认通过'
  587. }
  588. $modal.confirm(content).then(() => {
  589. button_state.value = false
  590. if (result == "1") {
  591. mainFormValue.value = computed(() => {
  592. const obj = {};
  593. formElements.value.forEach(elem => {
  594. if (!('0' != elem.canEdit && '8' != elem.type)) return
  595. obj[elem.elementId] = elem.defaultValue;
  596. });
  597. return obj;
  598. }).value
  599. $mainForm.value.validate().then(res => {
  600. submitProcess(result)
  601. })
  602. .catch(err => {
  603. button_state.value = true
  604. $modal.msgError('表单填写错误')
  605. })
  606. } else {
  607. submitProcess(result)
  608. }
  609. }).catch(() => { })
  610. }
  611. function submitProcess(result) {
  612. formInfo.value.formElements = formElements.value
  613. // 过滤不可编辑的表单项
  614. .filter(({canEdit}) => canEdit == '1')
  615. .map(({ tableField, defaultValue }) => {
  616. return {
  617. name: tableField,
  618. value: defaultValue
  619. }
  620. })
  621. repeatingForm.value.elements.forEach((table, index) => {
  622. const newItem = table.map((item) => {
  623. item['value'] = item.defaultValue
  624. return item
  625. })
  626. formInfo.value.formElements.push(...newItem)
  627. })
  628. let flow = Object.assign({}, flowInfo.value)
  629. flow['staffId'] = userStore.user.useId
  630. flow['gxId'] = userStore.user.gxId
  631. flow['groupId'] = flowInfo.value.groupid
  632. const seqs = subFileSeqs.value.map(({ seq }) => seq)
  633. if (processInfo.reqOffice == 1 && seqs.length == 0) {
  634. button_state.value = true
  635. $modal.msgError('请上传附件')
  636. return
  637. } else {
  638. flow['fileIds'] = seqs
  639. }
  640. if (processInfo.reqRemark == 1 && remark.value == '') {
  641. button_state.value = true
  642. $modal.msgError('请填写备注')
  643. return
  644. } else {
  645. flow['remark'] = remark.value
  646. }
  647. // result: 1通过 2退回发起人 0退回上一级
  648. flow['result'] = result
  649. flow['nextTmodelId'] = 'undefined'
  650. submitProcessFlow(flow, formInfo.value, processInfo.control).then(({ returnMsg }) => {
  651. if (returnMsg.includes('提交失败')) {
  652. // 启用提交按钮
  653. button_state.value = true
  654. $modal.msgError(returnMsg)
  655. } else {
  656. $modal.msgSuccess(returnMsg)
  657. // 通知列表刷新数据
  658. uni.$emit('ReloadProcessData');
  659. setTimeout(() => {
  660. $tab.navigateBack();
  661. }, 1000)
  662. }
  663. })
  664. }
  665. // 取消流程
  666. function handleCancelProcess() {
  667. if (remark.value.trim() == '') {
  668. $modal.msgError('备注不能为空!')
  669. return
  670. }
  671. $modal.confirm('确认撤销').then(() => {
  672. cancelProcess()
  673. }).catch(() => { })
  674. }
  675. function cancelProcess() {
  676. cancelProcessFlow(userStore.user.useId, remark.value, processInfo).then(({ returnMsg }) => {
  677. if (returnMsg.includes('success')) {
  678. $modal.msgSuccess('撤销成功')
  679. // 通知列表刷新数据
  680. uni.$emit('ReloadProcessData');
  681. setTimeout(() => {
  682. $tab.navigateBack();
  683. }, 1000)
  684. } else {
  685. // 启用按钮
  686. button_state.value = true
  687. $modal.msgError(returnMsg)
  688. }
  689. })
  690. }
  691. </script>
  692. <style lang="scss" scoped>
  693. ::v-deep .uni-section {
  694. margin-left: -15px;
  695. margin-bottom: 10px;
  696. }
  697. .signature_container {
  698. background-color: #f5f5f5;
  699. height: 40vh;
  700. width: 90vw;
  701. .signature_content {
  702. height: 80%;
  703. width: 100%;
  704. }
  705. .signature_button_container {
  706. height: 20%;
  707. width: 100%;
  708. button {
  709. height: 100%;
  710. }
  711. }
  712. }
  713. .signature_container_landscape {
  714. height: 100vh;
  715. width: 100vw;
  716. .signature_content {
  717. height: 85%;
  718. width: 100%;
  719. }
  720. .signature_button_container {
  721. margin-top: 10%;
  722. height: 15%;
  723. width: 100%;
  724. button {
  725. height: 100%;
  726. width: 100%;
  727. transform: rotate(90deg);
  728. }
  729. }
  730. }
  731. .process_detail_container {
  732. position: relative;
  733. .repeating_table {
  734. ::v-deep .uni-forms {
  735. .uni-forms-item__label {
  736. font-size: calc(1rem + 0px) !important;
  737. line-height: calc(1rem + 0px) !important;
  738. font-weight: 700;
  739. }
  740. .uni-forms-item__content {
  741. font-size: calc(14px + (1rem - 16px)) !important;
  742. font-weight: 500;
  743. .uni-easyinput__content-input {
  744. height: calc(35px + .5*(1rem - 16px)) !important;
  745. font-size: calc(14px + (1rem - 16px)) !important;
  746. font-weight: 500;
  747. }
  748. }
  749. }
  750. ::v-deep .uni-forms-item--border {
  751. padding: 5px 0 !important;
  752. }
  753. .repeating_table_button_container {
  754. margin-top: 5px;
  755. button {
  756. height: 36px;
  757. line-height: 36px;
  758. color: #fff;
  759. }
  760. .add {
  761. background-color: #1ca035;
  762. }
  763. .del {
  764. background-color: #e64340;
  765. }
  766. }
  767. }
  768. .main_container {
  769. min-height: 40vh;
  770. ::v-deep .uni-forms {
  771. .uni-forms-item__label {
  772. font-size: calc(1rem + 0px) !important;
  773. line-height: calc(1rem + 0px) !important;
  774. font-weight: 700;
  775. }
  776. .uni-forms-item__content {
  777. font-size: calc(14px + (1rem - 16px)) !important;
  778. font-weight: 500;
  779. .uni-easyinput__content-textarea {
  780. font-size: calc(14px + (1rem - 16px)) !important;
  781. font-weight: 500;
  782. }
  783. .uni-easyinput__content-input {
  784. height: calc(35px + .5*(1rem - 16px)) !important;
  785. font-size: calc(14px + (1rem - 16px)) !important;
  786. font-weight: 500;
  787. color: #333;
  788. }
  789. .uni-date {
  790. .uni-icons {
  791. font-size: calc(22px + 1.2*(1rem - 16px)) !important;
  792. font-weight: 500;
  793. }
  794. .uni-date__x-input {
  795. height: auto;
  796. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  797. font-weight: 500;
  798. }
  799. }
  800. }
  801. }
  802. .element_value_container {
  803. .signature_img {
  804. width: 180px;
  805. }
  806. .element_value {
  807. line-height: 36px;
  808. }
  809. }
  810. }
  811. ::v-deep .repeating_table_container {
  812. width: 98vw;
  813. .uni-table-scroll {
  814. max-height: 80vh;
  815. .uni-table {
  816. min-width: 100% !important;
  817. .uni-table-th {
  818. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  819. min-width: calc(50px + 2.5*(1rem - 16px));
  820. background-color: #2979ff;
  821. font-weight: bold;
  822. color: #fcfcfc;
  823. }
  824. .uni-table-td {
  825. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  826. }
  827. }
  828. }
  829. }
  830. ::v-deep .file_picker_container {
  831. .uni-card {
  832. .uni-card__header-content-title {
  833. font-size: calc(15px + .5*(1rem - 16px));
  834. }
  835. .uni-card__header-extra-text {
  836. font-size: calc(15px + .5*(1rem - 16px));
  837. }
  838. }
  839. }
  840. ::v-deep .flow_step_container {
  841. min-height: 200px;
  842. .u-steps {
  843. .u-steps-item {
  844. padding-bottom: 11px;
  845. .u-text__value--tips {
  846. font-size: calc(12px + .5*(1rem - 16px)) !important;
  847. }
  848. .redcontent {
  849. .u-text__value--content {
  850. color: #ff4500;
  851. }
  852. }
  853. .active_step_circle {
  854. width: 20px;
  855. height: 20px;
  856. box-sizing: border-box;
  857. flex-shrink: 0;
  858. border-radius: 100px;
  859. border-width: 1px;
  860. border-color: #A78BFA;
  861. background-color: #A78BFA;
  862. border-style: solid;
  863. display: flex;
  864. flex-direction: row;
  865. align-items: center;
  866. justify-content: center;
  867. transition: background-color .3s;
  868. .active_step_text {
  869. color: #fff;
  870. font-size: 11px;
  871. display: flex;
  872. flex-direction: row;
  873. align-items: center;
  874. justify-content: center;
  875. text-align: center;
  876. line-height: 11px;
  877. }
  878. }
  879. }
  880. .u-steps-item view:last-of-type {
  881. margin-top: 0 !important;
  882. .u-text__value--content {
  883. font-size: calc(16px + .5*(1rem - 16px)) !important;
  884. }
  885. .u-text__value--main {
  886. font-size: calc(16px + .5*(1rem - 16px)) !important;
  887. font-weight: 500;
  888. }
  889. }
  890. }
  891. }
  892. .approve_button {
  893. position: sticky;
  894. z-index: 10;
  895. width: 100%;
  896. bottom: 10px;
  897. }
  898. }
  899. ::v-deep button {
  900. font-size: calc(18px + .5*(1rem - 16px));
  901. }
  902. .reject_button {
  903. ::v-deep .uni-card {
  904. background-color: #f5f5f5;
  905. }
  906. }
  907. .remark_container {
  908. .remark_content {
  909. margin-bottom: 10px;
  910. ::v-deep .uni-easyinput {
  911. .uni-easyinput__content-textarea {
  912. font-size: calc(14px + .5*(1rem - 16px)) !important;
  913. }
  914. }
  915. }
  916. }
  917. ::v-deep .uni-calendar__content {
  918. margin: -20px;
  919. margin-top: 20px;
  920. .uni-calendar__header {
  921. .uni-calendar__header-text {
  922. font-size: calc(14px + .5*(1rem - 16px)) !important;
  923. }
  924. .uni-calendar__backtoday {
  925. padding: 2px 8px 2px 10px !important;
  926. font-size: calc(0.75rem + 0px) !important;
  927. }
  928. }
  929. .uni-calendar__box {
  930. .uni-calendar__weeks {
  931. .uni-calendar__weeks-day {
  932. .uni-calendar__weeks-day-text {
  933. font-size: calc(14px + .5*(1rem - 16px)) !important;
  934. }
  935. }
  936. .uni-calendar__weeks-item {
  937. .uni-calendar-item__weeks-box-item {
  938. .uni-calendar-item__weeks-box-circle {
  939. width: calc(8px + .5*(1rem - 16px)) !important;
  940. height: calc(8px + .5*(1rem - 16px)) !important;
  941. top: calc(5px - .25*(1rem - 16px)) !important;
  942. right: calc(5px - .25*(1rem - 16px)) !important;
  943. }
  944. .uni-calendar-item__weeks-box-text {
  945. font-size: calc(14px + .5*(1rem - 16px)) !important;
  946. }
  947. .uni-calendar-item__weeks-lunar-text {
  948. font-size: calc(12px + .5*(1rem - 16px)) !important;
  949. }
  950. }
  951. }
  952. }
  953. }
  954. .uni-date-changed {
  955. .uni-date-changed--time-date {
  956. font-size: calc(14px + 1*(1rem - 16px)) !important;
  957. }
  958. .uni-datetime-picker-text {
  959. font-size: calc(14px + 1*(1rem - 16px)) !important;
  960. }
  961. }
  962. }
  963. </style>