index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <template>
  2. <view class="process_detail_container">
  3. <uni-card>
  4. <view class="main_container">
  5. <uni-section titleFontSize="1.3rem" title="申请内容" type="line"></uni-section>
  6. <uni-forms label-position="left" :label-width="125" :border="true">
  7. <view v-for="(elem, index) in formElements" :key="index">
  8. <uni-forms-item
  9. v-if="!('0' == elem.canEdit && elem.elementName.slice(-2) == '审批' && '' == elem.defaultValue) && !(undefined == elem.canEdit && elem.elementName.slice(-2) == '审批' && '' == elem.defaultValue)"
  10. :label="elem.elementName">
  11. <view class="element_value_container">
  12. <view v-if="'1' == elem.canEdit" class="element_value">
  13. <!-- 富文本框 -->
  14. <uni-easyinput v-if="'1' == elem.type" placeholder="请输入内容"
  15. v-model="elem.defaultValue" type="textarea"></uni-easyinput>
  16. <!-- 文本框 -->
  17. <uni-easyinput v-else-if="'0' == elem.type" placeholder="请输入内容"
  18. v-model="elem.defaultValue" type="text"></uni-easyinput>
  19. <!-- 审批签字板 -->
  20. <view v-else-if="'13' == elem.type">
  21. <button v-if="elem.defaultValue == ''" type="primary"
  22. @click="handleSignature(index)">签名</button>
  23. <view v-else class="signature_img">
  24. <img style="width: 100%;" mode="widthFix" @click="handleSignature(index)" :src="elem.defaultValueImg" :alt="elem.elementName + '签名'" />
  25. </view>
  26. </view>
  27. </view>
  28. <view v-else-if="typeof elem.defaultValue === 'string' && elem.defaultValue.substring(0, 7) == '/shares'" class="signature_img">
  29. <img style="width: 100%;" mode="widthFix" :src="config.baseUrlPre + elem.defaultValue" />
  30. </view>
  31. <text class="element_value" v-else>{{ elem.defaultValue }}</text>
  32. </view>
  33. </uni-forms-item>
  34. </view>
  35. </uni-forms>
  36. </view>
  37. </uni-card>
  38. <view>
  39. <!-- 重复表 -->
  40. <uni-card v-if="repeatingFormNotEmpty" spacing="0" padding="0">
  41. <button @click="handlerepeatingForm" type="primary">查看明细</button>
  42. </uni-card>
  43. <uni-popup v-if="repeatingFormNotEmpty" ref="repeatingFormPopup">
  44. <uni-card margin="0px" spacing="0px" padding="0px">
  45. <view class="repeating_table_container">
  46. <uni-table :border="true" stripe>
  47. <uni-tr>
  48. <uni-th align="center" v-for="(item, index) in repeatingForm.elementItem" :key="index">
  49. {{ item.elementName.slice(3, 5) }}
  50. </uni-th>
  51. </uni-tr>
  52. <uni-tr
  53. v-for="(item, index) in (repeatingForm.elements.length / repeatingForm.elementItem.length)"
  54. :key="index">
  55. <uni-td align="center" v-for="col in repeatingForm.elementItem.length" :key="col">
  56. <!-- (列数 - 1) * 总行数 + 当前行数 -->
  57. {{ repeatingForm.elements[(col - 1) * (repeatingForm.elements.length /
  58. repeatingForm.elementItem.length) + index]!.defaultValue }}
  59. </uni-td>
  60. </uni-tr>
  61. </uni-table>
  62. </view>
  63. </uni-card>
  64. </uni-popup>
  65. </view>
  66. <!-- 附件 -->
  67. <view v-for="(item, index) in fileList" :key="index">
  68. <uni-card v-if="item.files.length != undefined && item.files.length > 0">
  69. <uni-section titleFontSize="1.3rem" title="附件" type="line"></uni-section>
  70. <attachment-list :attachments="item.files"></attachment-list>
  71. </uni-card>
  72. </view>
  73. <view>
  74. <uni-card>
  75. <view class="flow_step_container">
  76. <uni-section titleFontSize="1.3rem" title="流转过程" type="line"></uni-section>
  77. <up-steps :current="stepActive" activeColor="#18bc37" inactiveColor="#2979ff" direction="column">
  78. <view v-for="(step, index) in options">
  79. <up-steps-item :contentClass="'redcontent'" v-if="step.state == 3" :title="step.title + ' 退回'" :desc="step.desc"
  80. :key="index" error></up-steps-item>
  81. <up-steps-item :contentClass="'redcontent'" v-else-if="step.state == 0" :title="step.title + ' 撤销'" :desc="step.desc"
  82. :key="index" error></up-steps-item>
  83. <up-steps-item v-else-if="index == stepActive" :title="step.title" :desc="step.desc"
  84. :key="index">
  85. <template #icon>
  86. <view class="active_step_circle">
  87. <text class="active_step_text">{{ index + 1 }}</text>
  88. </view>
  89. </template>
  90. </up-steps-item>
  91. <up-steps-item v-else :title="step.title" :desc="step.desc" :key="index"></up-steps-item>
  92. </view>
  93. </up-steps>
  94. </view>
  95. </uni-card>
  96. </view>
  97. <view v-if="processInfo.tinsId">
  98. <view class="remark_container">
  99. <uni-card>
  100. <uni-section titleFontSize="1.3rem" title="环节备注" type="line"></uni-section>
  101. <view class="remark_content">
  102. <uni-easyinput type="textarea" autoHeight v-model="remark" placeholder="请输入"></uni-easyinput>
  103. </view>
  104. </uni-card>
  105. </view>
  106. </view>
  107. <view v-if="processInfo.tinsId" class="approve_button">
  108. <uni-card spacing="0" padding="0">
  109. <button :disabled="!button_state" :loading="!button_state" type="primary" @click="handleSubmitProcess('1')">通过</button>
  110. </uni-card>
  111. </view>
  112. </view>
  113. <view v-if="processInfo.tinsId">
  114. <view class="reject_button">
  115. <uni-card spacing="0" padding="0" :is-shadow="false" :border="false">
  116. <uni-row>
  117. <uni-col :span="11">
  118. <button :disabled="!button_state" :loading="!button_state" type="warn" @click="handleSubmitProcess('0')">退回上一级</button>
  119. </uni-col>
  120. <uni-col :span="11" :offset="2">
  121. <button :disabled="!button_state" :loading="!button_state" type="warn" @click="handleSubmitProcess('2')">退回发起人</button>
  122. </uni-col>
  123. </uni-row>
  124. </uni-card>
  125. </view>
  126. </view>
  127. <view v-else-if="isCancel">
  128. <view class="remark_container">
  129. <uni-card>
  130. <uni-section titleFontSize="1.3rem" title="撤销备注" type="line"></uni-section>
  131. <view class="remark_content">
  132. <uni-easyinput type="textarea" autoHeight v-model="remark" placeholder="请输入"></uni-easyinput>
  133. </view>
  134. </uni-card>
  135. </view>
  136. <view class="cancel_button_container">
  137. <uni-card spacing="0" padding="0">
  138. <button :disabled="!button_state" :loading="!button_state" type="warn" @click="handleCancelProcess">撤销</button>
  139. </uni-card>
  140. </view>
  141. </view>
  142. <view style="height: 5px; margin-top: 20px;"></view>
  143. <uni-popup ref="signaturePopup" @maskClick="closeSignaturePopup">
  144. <view class="signature_container" :class="isLandscape ? ' signature_container_landscape' : ''">
  145. <view class="signature_content">
  146. <l-signature ref="signatureRef" v-if="signaturePopupShow" :landscape="isLandscape" :penSize="8" :minLineWidth="4" :maxLineWidth="12" :openSmooth="true" :preferToDataURL="true"
  147. backgroundColor="#ffffff" penColor="black"></l-signature>
  148. </view>
  149. <view class="signature_button_container">
  150. <uni-row :gutter="10">
  151. <uni-col :span="6">
  152. <button @click="onclickSignatureButton('undo')">撤销</button>
  153. </uni-col>
  154. <uni-col :span="6">
  155. <button @click="onclickSignatureButton('clear')">清空</button>
  156. </uni-col>
  157. <uni-col :span="6">
  158. <button @click="onclickSignatureButton('save')">保存</button>
  159. </uni-col>
  160. <uni-col :span="6">
  161. <button @click="onclickSignatureButton('landscape')">全屏</button>
  162. </uni-col>
  163. </uni-row>
  164. </view>
  165. </view>
  166. </uni-popup>
  167. </template>
  168. <script setup lang="ts">
  169. import { onMounted, reactive, ref } from 'vue'
  170. import { onLoad } from '@dcloudio/uni-app'
  171. import { LSignatureToTempFilePathOptions, LSignatureToFileSuccess } from '@/uni_modules/lime-signature'
  172. import attachmentList from '@/components/ygoa/attachmentList.vue'
  173. import config from '@/config.js'
  174. import $tab from '@/plugins/tab.js'
  175. import $modal from '@/plugins/modal.js'
  176. import { getProcessFlowInfo, getProcessFormInfo, getProcessFormInfoInFlow, getProcessFlow, submitProcessFlow, cancelProcessFlow, uploadSignatureImg, uploadSignatureBoardImg } from '@/api/process.js'
  177. import { useUserStore } from '@/store/user.js'
  178. const userStore = useUserStore()
  179. const processInfo = reactive({
  180. insId: '',
  181. insName: '',
  182. control: 1,
  183. username: '',
  184. tinsId: undefined
  185. })
  186. onLoad(({ insId, tinsId, insName, control }) => {
  187. // 获取传入的标题参数
  188. const title = insName || '流程信息';
  189. processInfo.insId = insId
  190. processInfo.insName = insName
  191. processInfo.control = control
  192. if (tinsId) {
  193. processInfo['tinsId'] = tinsId
  194. }
  195. // 设置导航栏标题
  196. uni.setNavigationBarTitle({
  197. title: title
  198. });
  199. })
  200. onMounted(() => {
  201. initProcessInfo()
  202. initProcessFlow()
  203. })
  204. const repeatingForm = ref({
  205. elements: [],
  206. elementItem: [],
  207. })
  208. const repeatingFormNotEmpty = ref(false)
  209. function repeatingFormHasValue() {
  210. if (repeatingForm.value === undefined) return
  211. if (repeatingForm.value.elementItem.length <= 0) return
  212. repeatingForm.value.elements.forEach(({ defaultValue }) => {
  213. if (defaultValue != "") {
  214. repeatingFormNotEmpty.value = true
  215. return new Promise((resolve, reject) => {
  216. resolve(repeatingFormNotEmpty)
  217. })
  218. }
  219. })
  220. }
  221. const formElements = ref([])
  222. const formInfo = ref({
  223. formElements: [],
  224. formId: '',
  225. formInsId: ''
  226. })
  227. const fileList = ref([])
  228. const isCancel = ref(false)
  229. function initProcessInfo() {
  230. if (processInfo.tinsId) {
  231. getProcessFormInfoInFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  232. formElements.value = returnParams.formElements
  233. formInfo.value = returnParams.formInfo[0]
  234. repeatingForm.value = returnParams.repeatingForm
  235. repeatingFormHasValue()
  236. remark.value = '同意'
  237. })
  238. } else {
  239. getProcessFormInfo(userStore.user.useId, processInfo.insId).then(({ returnParams }) => {
  240. formElements.value = returnParams.formElements
  241. repeatingForm.value = returnParams.repeatingForm
  242. fileList.value = returnParams.fileList
  243. if (returnParams.isCancel == 1) {
  244. isCancel.value = true
  245. }
  246. repeatingFormHasValue()
  247. })
  248. }
  249. }
  250. const options = ref([])
  251. const stepActive = ref(-1)
  252. const flowInfo = ref({})
  253. function initProcessFlow() {
  254. getProcessFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  255. options.value = returnParams.list.map((item, index) => {
  256. const { tmodelName, name, createdate, finishdate, remark, state } = item
  257. if (state == 1) {
  258. stepActive.value = index
  259. }
  260. const title = tmodelName + (name == '' ? '' : ' ( ' + name + ' )')
  261. const desc = '创建时间: ' + createdate
  262. + (finishdate == '' ? '\n' : '\n办理时间: ' + finishdate)
  263. + (remark == '' ? '\n' : '\n环节意见: ' + remark)
  264. return {
  265. title,
  266. desc,
  267. state
  268. }
  269. })
  270. if (stepActive.value === -1) stepActive.value = returnParams.list.length
  271. // 获取未完成过程
  272. if (processInfo.tinsId) {
  273. getProcessFlowInfo(userStore.user.useId, processInfo).then(({ returnParams }) => {
  274. options.value.push({ title: returnParams.nextTmodels[0].nextTmodelName })
  275. flowInfo.value = returnParams.flow[0]
  276. fileList.value = [
  277. { files: returnParams.flow[0].files }
  278. ]
  279. })
  280. }
  281. })
  282. }
  283. const signaturePopup = ref(null)
  284. const signatureRef = ref(null)
  285. const signaturePopupShow = ref(false)
  286. const isLandscape = ref(false)
  287. const signatureItemIndex = ref(-1)
  288. function handleSignature(index) {
  289. signatureItemIndex.value = index
  290. signaturePopup.value.open()
  291. initSignature()
  292. }
  293. function initSignature() {
  294. signaturePopupShow.value = false
  295. setTimeout(() => {
  296. signaturePopupShow.value = true
  297. }, 100)
  298. }
  299. function onclickSignatureButton(event) {
  300. switch (event) {
  301. case 'undo':
  302. signatureRef.value.undo()
  303. break;
  304. case 'clear':
  305. signatureRef.value.clear()
  306. break;
  307. case 'save':
  308. signatureRef.value.canvasToTempFilePath({
  309. success: (res: LSignatureToFileSuccess) => {
  310. console.log('res: ', res);
  311. if (res.isEmpty) {
  312. $modal.msgError('签名不能为空!')
  313. return
  314. }
  315. wx.getFileSystemManager().readFile({
  316. filePath: res.tempFilePath,
  317. encoding: 'base64',
  318. success: fileData => {
  319. const _fileData = 'data:image/png;base64,' + fileData.data
  320. uploadSignatureBoardImg(userStore.user.useId, _fileData, formElements.value[signatureItemIndex.value].tableField)
  321. // uploadSignatureImg(res.tempFilePath)
  322. .then(({returnParams}) => {
  323. formElements.value[signatureItemIndex.value].defaultValue = returnParams.sealInsID
  324. formElements.value[signatureItemIndex.value].defaultValueImg = returnParams.path
  325. signatureItemIndex.value = -1
  326. signaturePopupShow.value = false
  327. signaturePopup.value.close()
  328. })
  329. }
  330. })
  331. console.log('formElements', formElements.value[signatureItemIndex.value]);
  332. // formElements.value[signatureItemIndex.value].defaultValueImg = res.tempFilePath
  333. }
  334. } as LSignatureToTempFilePathOptions)
  335. break;
  336. case 'landscape':
  337. isLandscape.value = !isLandscape.value
  338. initSignature()
  339. break;
  340. }
  341. }
  342. function closeSignaturePopup() {
  343. signatureItemIndex.value = -1
  344. signaturePopupShow.value = false
  345. }
  346. const repeatingFormPopup = ref(null)
  347. function handlerepeatingForm() {
  348. repeatingFormPopup.value.open()
  349. }
  350. const button_state = ref(true)
  351. const remark = ref('')
  352. function handleSubmitProcess(result) {
  353. let content = '确认退回'
  354. if (result == "1") {
  355. content = '确认通过'
  356. }
  357. $modal.confirm(content).then(() => {
  358. submitProcess(result)
  359. }).catch(() => { })
  360. }
  361. function submitProcess(result) {
  362. button_state.value = false
  363. formInfo.value.formElements = formElements.value.map(({ tableField, defaultValue }) => {
  364. return {
  365. name: tableField,
  366. value: defaultValue
  367. }
  368. })
  369. let flow = Object.assign({}, flowInfo.value)
  370. flow['staffId'] = userStore.user.useId
  371. flow['gxId'] = userStore.user.gxId
  372. flow['groupId'] = flowInfo.value.groupid
  373. flow['fileIds'] = ''
  374. // result: 1通过 2退回发起人 0退回上一级
  375. flow['result'] = result
  376. flow['remark'] = remark.value
  377. flow['nextTmodelId'] = 'undefined'
  378. submitProcessFlow(flow, formInfo.value, processInfo.control).then(({ returnMsg }) => {
  379. if (returnMsg.includes('提交失败')) {
  380. // 启用提交按钮
  381. button_state.value = true
  382. $modal.msgError(returnMsg)
  383. } else {
  384. $modal.msgSuccess(returnMsg)
  385. // 通知列表刷新数据
  386. uni.$emit('ReloadProcessData');
  387. setTimeout(() => {
  388. $tab.navigateBack();
  389. }, 1000)
  390. }
  391. })
  392. }
  393. function handleCancelProcess() {
  394. if (remark.value.trim() == '') {
  395. $modal.msgError('备注不能为空!')
  396. return
  397. }
  398. $modal.confirm('确认撤销').then(() => {
  399. cancelProcess()
  400. }).catch(() => { })
  401. }
  402. function cancelProcess() {
  403. cancelProcessFlow(userStore.user.useId, remark.value, processInfo).then(({ returnMsg }) => {
  404. if (returnMsg.includes('success')) {
  405. $modal.msgSuccess('撤销成功')
  406. // 通知列表刷新数据
  407. uni.$emit('ReloadProcessData');
  408. setTimeout(() => {
  409. $tab.navigateBack();
  410. }, 1000)
  411. } else {
  412. // 启用按钮
  413. button_state.value = true
  414. $modal.msgError(returnMsg)
  415. }
  416. })
  417. }
  418. </script>
  419. <style lang="scss">
  420. .uni-section {
  421. margin-left: -15px;
  422. margin-bottom: 10px;
  423. }
  424. .signature_container {
  425. background-color: #f5f5f5;
  426. height: 40vh;
  427. width: 90vw;
  428. .signature_content {
  429. height: 80%;
  430. width: 100%;
  431. }
  432. .signature_button_container {
  433. height: 20%;
  434. width: 100%;
  435. button {
  436. height: 100%;
  437. }
  438. }
  439. }
  440. .signature_container_landscape {
  441. height: 100vh;
  442. width: 100vw;
  443. .signature_content {
  444. height: 85%;
  445. width: 100%;
  446. }
  447. .signature_button_container {
  448. margin-top: 10%;
  449. height: 15%;
  450. width: 100%;
  451. button {
  452. height: 100%;
  453. width: 100%;
  454. transform: rotate(90deg);
  455. }
  456. }
  457. }
  458. .process_detail_container {
  459. position: relative;
  460. .main_container {
  461. min-height: 60vh;
  462. .uni-forms-item__label {
  463. font-size: 1rem;
  464. font-weight: 600;
  465. }
  466. .element_value_container {
  467. .signature_img {
  468. width: 180px;
  469. }
  470. .element_value {
  471. line-height: 36px;
  472. }
  473. }
  474. }
  475. .repeating_table_container {
  476. width: 98vw;
  477. .uni-table-scroll {
  478. max-height: 80vh;
  479. .uni-table {
  480. min-width: 100% !important;
  481. .uni-table-th {
  482. min-width: 50px;
  483. background-color: #2979ff;
  484. font-weight: bold;
  485. color: #fcfcfc;
  486. }
  487. }
  488. }
  489. }
  490. .flow_step_container {
  491. min-height: 200px;
  492. .u-steps {
  493. .u-steps-item {
  494. padding-bottom: 11px;
  495. .redcontent {
  496. .u-text__value--content {
  497. color: #ff4500;
  498. }
  499. }
  500. .active_step_circle {
  501. width: 20px;
  502. height: 20px;
  503. box-sizing: border-box;
  504. flex-shrink: 0;
  505. border-radius: 100px;
  506. border-width: 1px;
  507. border-color: #A78BFA;
  508. background-color: #A78BFA;
  509. border-style: solid;
  510. display: flex;
  511. flex-direction: row;
  512. align-items: center;
  513. justify-content: center;
  514. transition: background-color .3s;
  515. .active_step_text {
  516. color: #fff;
  517. font-size: 11px;
  518. display: flex;
  519. flex-direction: row;
  520. align-items: center;
  521. justify-content: center;
  522. text-align: center;
  523. line-height: 11px;
  524. }
  525. }
  526. }
  527. .u-steps-item view:last-of-type {
  528. margin-top: 0 !important;
  529. .u-text__value--content {
  530. font-size: 16px !important;
  531. }
  532. .u-text__value--main {
  533. font-size: 16px !important;
  534. }
  535. }
  536. }
  537. }
  538. .approve_button {
  539. position: sticky;
  540. z-index: 10;
  541. width: 100%;
  542. bottom: 10px;
  543. }
  544. }
  545. .reject_button {
  546. .uni-card {
  547. background-color: #f5f5f5;
  548. }
  549. }
  550. .remark_container {
  551. .remark_content {
  552. margin-bottom: 10px;
  553. }
  554. }
  555. </style>