GenerateForm.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view>
  3. <view style="padding: 10px 0px 66px 0px;min-height: 100px">
  4. <!--标题-->
  5. <view style="text-align:center">
  6. <text class="title">{{title}}</text>
  7. </view>
  8. <view class="card">
  9. <!--表单-->
  10. <test :grids="jsonData" :formData="formData"></test>
  11. <transferRecordsModule :historicTaskList="historicTaskList"></transferRecordsModule>
  12. <!--审核意见-->
  13. <view v-if="type === 'audit'">
  14. <view class="divider">
  15. <text class="divider-content"><span style="color: red">*</span> 审批意见</text>
  16. </view>
  17. <textarea :rows="5" maxlength="500" placeholder="请填写审核意见:" v-model="comments" show-word-limit></textarea>
  18. </view>
  19. <!--操作按钮-->
  20. <view class="bottom-wrap flex">
  21. <view class="flex-sub"
  22. v-for="(button, index) in buttons" :key="index" >
  23. <u-button type="primary" class=" buttonBox" :color="colors[index]" @click="submit(button, buttons)" :text="button.name"></u-button>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import Test from './Test.vue';
  32. import TransferRecordsModule from './TransferRecordsModule.vue';
  33. import ccpmService from '@/api/centerservice/ccpm/CcpmService'
  34. export default {
  35. onLoad: function (option) {
  36. this.flow = JSON.parse(decodeURIComponent(option.flow));
  37. this.businessId = this.flow.id
  38. this.processDefKey = this.flow.processDefKey
  39. this.title = this.flow.title
  40. this.type = this.flow.type
  41. this.jsonData = []
  42. this.comments = ''
  43. },
  44. data () {
  45. return {
  46. buttons: [
  47. {code: '_flow_agree', name: '同意'},
  48. {code: '_flow_reject', name: '驳回'},
  49. {code: '_flow_close', name: '关闭'},
  50. ],
  51. colors: [ '#3c9cff', '#f56c6c', '#5ac725', '#f9ae3d', '#89c152',
  52. '#c38cc1', '#448aca', '#73d1f1', '#ffb34b', '#f18080',
  53. '#88a867', '#bfbf39', '#94d554', '#f19ec2', '#afaae4',
  54. '#86cefa', '#98d1ee', '#72dcdc', '#9acdcb', '#77b1cc', '#80a7dc'
  55. ],
  56. flow: null,
  57. formData: {
  58. name: '',
  59. email: '',
  60. remarks: ''
  61. },
  62. jsonData: {},
  63. historicTaskList: [],
  64. title: '',
  65. businessId: '',
  66. loading: false,
  67. type: '',
  68. processDefKey: '',
  69. comments: '' // 审核意见
  70. }
  71. },
  72. activated () {
  73. this.init()
  74. },
  75. created () {
  76. this.init()
  77. },
  78. components: {
  79. Test,
  80. TransferRecordsModule,
  81. },
  82. methods: {
  83. // 初始化
  84. init () {
  85. console.log('this.businessId ', this.businessId)
  86. this.$nextTick(async () => {
  87. this.loading = true
  88. await ccpmService.getByIdGenerate(this.businessId, this.processDefKey).then((data)=>{
  89. if (data) {
  90. console.log('data',data)
  91. this.loading = false
  92. this.jsonData = JSON.parse(JSON.stringify(data.list))
  93. this.jsonData.files = data.files
  94. this.historicTaskList = data.histoicFlow
  95. } else {
  96. this.loading = false
  97. }
  98. })
  99. })
  100. },
  101. // 关闭
  102. close () {
  103. this.jsonData = []
  104. this.comments = ''
  105. uni.navigateTo({
  106. url: '/pages/workbench/task/TodoList'
  107. })
  108. },
  109. // 同意
  110. agree () {
  111. if (this.isEmpty(this.comments)) {
  112. uni.showToast({ title: '请填写审批意见!', icon: "error" });
  113. } else {
  114. this.loading = true
  115. ccpmService.reimAudit(this.businessId, 'yes', this.comments, this.processDefKey).then((data) => {
  116. this.loading = false
  117. if (data.success) {
  118. uni.showToast({ title: data.message, icon: "success" });
  119. this.close()
  120. } else {
  121. uni.showToast({ title: data.message, icon: "error" });
  122. }
  123. }).catch(() => {
  124. this.loading = false
  125. })
  126. }
  127. },
  128. // 驳回
  129. reject () {
  130. if (this.isEmpty(this.comments)) {
  131. uni.showToast({ title: '请填写审批意见', icon: "error" });
  132. } else {
  133. // 弹窗 二次确认
  134. uni.showModal({
  135. content: '确定驳回此报销申请吗?',
  136. success: async (res) => {
  137. if (res.confirm) {
  138. ccpmService.reimAudit(this.businessId, 'no', this.comments, this.processDefKey).then((data) => {
  139. this.loading = false
  140. if (data.success) {
  141. uni.showToast({ title: data.message, icon: "success" });
  142. this.close()
  143. } else {
  144. uni.showToast({ title: data.message, icon: "error" });
  145. }
  146. }).catch(() => {
  147. this.loading = false
  148. })
  149. }
  150. },
  151. })
  152. }
  153. },
  154. isEmpty(value) {
  155. let result = false;
  156. if (value == null || value == undefined) {
  157. result = true;
  158. }
  159. if (typeof value == 'string' && (value.replace(/\s+/g, "") == "" || value == "")) {
  160. result = true;
  161. }
  162. if (typeof value == "object" && value instanceof Array && value.length === 0) {
  163. result = true;
  164. }
  165. return result;
  166. },
  167. isNotEmpty (value) {
  168. return !this.isEmpty(value)
  169. },
  170. submit (currentBtn, buttons) {
  171. switch (currentBtn.code) {
  172. case '_flow_agree': // 同意
  173. this.agree()
  174. break
  175. case '_flow_reject': // 驳回
  176. this.reject()
  177. break
  178. case '_flow_close':// 关闭
  179. this.close()
  180. break
  181. }
  182. }
  183. }
  184. }
  185. </script>
  186. <style scoped>
  187. .title {
  188. font-size: 24px;
  189. font-weight: bold;
  190. }
  191. .card {
  192. padding: 15px;
  193. background-color: #fff;
  194. box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
  195. }
  196. .divider {
  197. display: flex;
  198. align-items: center;
  199. margin-top: 20px;
  200. }
  201. .divider-content {
  202. font-size: 16px;
  203. color: #333;
  204. }
  205. .FlowFormFooter {
  206. display: flex;
  207. justify-content: space-around;
  208. margin-top: 2em;
  209. }
  210. button {
  211. padding: 10px 20px;
  212. border: none;
  213. border-radius: 5px;
  214. }
  215. button[type=primary] {
  216. background-color: #409eff;
  217. color: #fff;
  218. }
  219. button[type=danger] {
  220. background-color: #f56c6c;
  221. color: #fff;
  222. }
  223. </style>