index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  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. })
  237. } else {
  238. getProcessFormInfo(userStore.user.useId, processInfo.insId).then(({ returnParams }) => {
  239. formElements.value = returnParams.formElements
  240. repeatingForm.value = returnParams.repeatingForm
  241. fileList.value = returnParams.fileList
  242. if (returnParams.isCancel == 1) {
  243. isCancel.value = true
  244. }
  245. repeatingFormHasValue()
  246. })
  247. }
  248. }
  249. const options = ref([])
  250. const stepActive = ref(-1)
  251. const flowInfo = ref({})
  252. function initProcessFlow() {
  253. getProcessFlow(userStore.user.useId, processInfo).then(({ returnParams }) => {
  254. options.value = returnParams.list.map((item, index) => {
  255. const { tmodelName, name, createdate, finishdate, remark, state } = item
  256. if (state == 1) {
  257. stepActive.value = index
  258. }
  259. const title = tmodelName + (name == '' ? '' : ' ( ' + name + ' )')
  260. const desc = '创建时间: ' + createdate
  261. + (finishdate == '' ? '\n' : '\n办理时间: ' + finishdate)
  262. + (remark == '' ? '\n' : '\n环节意见: ' + remark)
  263. return {
  264. title,
  265. desc,
  266. state
  267. }
  268. })
  269. if (stepActive.value === -1) stepActive.value = returnParams.list.length
  270. // 获取未完成过程
  271. if (processInfo.tinsId) {
  272. getProcessFlowInfo(userStore.user.useId, processInfo).then(({ returnParams }) => {
  273. options.value.push({ title: returnParams.nextTmodels[0].nextTmodelName })
  274. flowInfo.value = returnParams.flow[0]
  275. fileList.value = [
  276. { files: returnParams.flow[0].files }
  277. ]
  278. })
  279. }
  280. })
  281. }
  282. const signaturePopup = ref(null)
  283. const signatureRef = ref(null)
  284. const signaturePopupShow = ref(false)
  285. const isLandscape = ref(false)
  286. const signatureItemIndex = ref(-1)
  287. function handleSignature(index) {
  288. signatureItemIndex.value = index
  289. signaturePopup.value.open()
  290. initSignature()
  291. }
  292. function initSignature() {
  293. signaturePopupShow.value = false
  294. setTimeout(() => {
  295. signaturePopupShow.value = true
  296. }, 100)
  297. }
  298. function onclickSignatureButton(event) {
  299. switch (event) {
  300. case 'undo':
  301. signatureRef.value.undo()
  302. break;
  303. case 'clear':
  304. signatureRef.value.clear()
  305. break;
  306. case 'save':
  307. signatureRef.value.canvasToTempFilePath({
  308. success: (res: LSignatureToFileSuccess) => {
  309. console.log('res: ', res);
  310. if (res.isEmpty) {
  311. $modal.msgError('签名不能为空!')
  312. return
  313. }
  314. wx.getFileSystemManager().readFile({
  315. filePath: res.tempFilePath,
  316. encoding: 'base64',
  317. success: fileData => {
  318. const _fileData = 'data:image/png;base64,' + fileData.data
  319. uploadSignatureBoardImg(userStore.user.useId, _fileData, formElements.value[signatureItemIndex.value].tableField)
  320. // uploadSignatureImg(res.tempFilePath)
  321. .then(({returnParams}) => {
  322. formElements.value[signatureItemIndex.value].defaultValue = returnParams.sealInsID
  323. signatureItemIndex.value = -1
  324. signaturePopupShow.value = false
  325. signaturePopup.value.close()
  326. // formElements.value[signatureItemIndex.value].defaultValueImg = returnParams.path
  327. })
  328. }
  329. })
  330. console.log('formElements', formElements.value[signatureItemIndex.value]);
  331. formElements.value[signatureItemIndex.value].defaultValueImg = res.tempFilePath
  332. }
  333. } as LSignatureToTempFilePathOptions)
  334. break;
  335. case 'landscape':
  336. isLandscape.value = !isLandscape.value
  337. initSignature()
  338. break;
  339. }
  340. }
  341. function closeSignaturePopup() {
  342. signatureItemIndex.value = -1
  343. signaturePopupShow.value = false
  344. }
  345. const repeatingFormPopup = ref(null)
  346. function handlerepeatingForm() {
  347. repeatingFormPopup.value.open()
  348. }
  349. const button_state = ref(true)
  350. const remark = ref('')
  351. function handleSubmitProcess(result) {
  352. let content = '确认退回'
  353. if (result == "1") {
  354. content = '确认通过'
  355. }
  356. $modal.confirm(content).then(() => {
  357. submitProcess(result)
  358. }).catch(() => { })
  359. }
  360. function submitProcess(result) {
  361. button_state.value = false
  362. formInfo.value.formElements = formElements.value.map(({ tableField, defaultValue }) => {
  363. return {
  364. name: tableField,
  365. value: defaultValue
  366. }
  367. })
  368. let flow = Object.assign({}, flowInfo.value)
  369. flow['staffId'] = userStore.user.useId
  370. flow['gxId'] = userStore.user.gxId
  371. flow['groupId'] = flowInfo.value.groupid
  372. flow['fileIds'] = ''
  373. // result: 1通过 2退回发起人 0退回上一级
  374. flow['result'] = result
  375. flow['remark'] = remark.value
  376. flow['nextTmodelId'] = 'undefined'
  377. submitProcessFlow(flow, formInfo.value, processInfo.control).then(({ returnMsg }) => {
  378. if (returnMsg.includes('提交失败')) {
  379. // 启用提交按钮
  380. button_state.value = true
  381. $modal.msgError(returnMsg)
  382. } else {
  383. $modal.msgSuccess(returnMsg)
  384. // 通知列表刷新数据
  385. uni.$emit('ReloadProcessData');
  386. setTimeout(() => {
  387. $tab.navigateBack();
  388. }, 1000)
  389. }
  390. })
  391. }
  392. function handleCancelProcess() {
  393. if (remark.value.trim() == '') {
  394. $modal.msgError('备注不能为空!')
  395. return
  396. }
  397. $modal.confirm('确认撤销').then(() => {
  398. cancelProcess()
  399. }).catch(() => { })
  400. }
  401. function cancelProcess() {
  402. cancelProcessFlow(userStore.user.useId, remark.value, processInfo).then(({ returnMsg }) => {
  403. if (returnMsg.includes('success')) {
  404. $modal.msgSuccess('撤销成功')
  405. // 通知列表刷新数据
  406. uni.$emit('ReloadProcessData');
  407. setTimeout(() => {
  408. $tab.navigateBack();
  409. }, 1000)
  410. } else {
  411. // 启用按钮
  412. button_state.value = true
  413. $modal.msgError(returnMsg)
  414. }
  415. })
  416. }
  417. </script>
  418. <style lang="scss">
  419. .uni-section {
  420. margin-left: -15px;
  421. margin-bottom: 10px;
  422. }
  423. .signature_container {
  424. background-color: #f5f5f5;
  425. height: 40vh;
  426. width: 90vw;
  427. .signature_content {
  428. height: 80%;
  429. width: 100%;
  430. }
  431. .signature_button_container {
  432. height: 20%;
  433. width: 100%;
  434. button {
  435. height: 100%;
  436. }
  437. }
  438. }
  439. .signature_container_landscape {
  440. height: 100vh;
  441. width: 100vw;
  442. .signature_content {
  443. height: 85%;
  444. width: 100%;
  445. }
  446. .signature_button_container {
  447. margin-top: 10%;
  448. height: 15%;
  449. width: 100%;
  450. button {
  451. height: 100%;
  452. width: 100%;
  453. transform: rotate(90deg);
  454. }
  455. }
  456. }
  457. .process_detail_container {
  458. position: relative;
  459. .main_container {
  460. min-height: 60vh;
  461. .uni-forms-item__label {
  462. font-size: 1rem;
  463. font-weight: 600;
  464. }
  465. .element_value_container {
  466. .signature_img {
  467. width: 180px;
  468. }
  469. .element_value {
  470. line-height: 36px;
  471. }
  472. }
  473. }
  474. .repeating_table_container {
  475. width: 98vw;
  476. .uni-table-scroll {
  477. max-height: 80vh;
  478. .uni-table {
  479. min-width: 100% !important;
  480. .uni-table-th {
  481. min-width: 50px;
  482. background-color: #2979ff;
  483. font-weight: bold;
  484. color: #fcfcfc;
  485. }
  486. }
  487. }
  488. }
  489. .flow_step_container {
  490. min-height: 200px;
  491. .u-steps {
  492. .u-steps-item {
  493. padding-bottom: 11px;
  494. .redcontent {
  495. .u-text__value--content {
  496. color: #ff4500;
  497. }
  498. }
  499. .active_step_circle {
  500. width: 20px;
  501. height: 20px;
  502. box-sizing: border-box;
  503. flex-shrink: 0;
  504. border-radius: 100px;
  505. border-width: 1px;
  506. border-color: #A78BFA;
  507. background-color: #A78BFA;
  508. border-style: solid;
  509. display: flex;
  510. flex-direction: row;
  511. align-items: center;
  512. justify-content: center;
  513. transition: background-color .3s;
  514. .active_step_text {
  515. color: #fff;
  516. font-size: 11px;
  517. display: flex;
  518. flex-direction: row;
  519. align-items: center;
  520. justify-content: center;
  521. text-align: center;
  522. line-height: 11px;
  523. }
  524. }
  525. }
  526. .u-steps-item view:last-of-type {
  527. margin-top: 0 !important;
  528. .u-text__value--content {
  529. font-size: 16px !important;
  530. }
  531. .u-text__value--main {
  532. font-size: 16px !important;
  533. }
  534. }
  535. }
  536. }
  537. .approve_button {
  538. position: sticky;
  539. z-index: 10;
  540. width: 100%;
  541. bottom: 10px;
  542. }
  543. }
  544. .reject_button {
  545. .uni-card {
  546. background-color: #f5f5f5;
  547. }
  548. }
  549. .remark_container {
  550. .remark_content {
  551. margin-bottom: 10px;
  552. }
  553. }
  554. </style>