formParserDialog.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <ele-modal
  3. :visible="formParserDialogFlag"
  4. title="审批"
  5. :width="width"
  6. :centered="true"
  7. :close-on-click-modal="false"
  8. append-to-body
  9. :before-close="cancel"
  10. :maxable="true"
  11. :resizable="true"
  12. >
  13. <fm-generate-form
  14. v-if="Object.keys(form?.formJson || {}).length !== 0"
  15. :data="jsonData"
  16. :value="form.valueJson"
  17. :edit="false"
  18. ref="generateForm"
  19. >
  20. <template v-slot:blank_adopzrdd="scope">
  21. <div v-for="(item, index) in scope.model.blank_adopzrdd" :key="index">
  22. <div class="blank_adopzrdd">
  23. <span>{{ index + 1 }}报销事项:</span>
  24. <el-input
  25. v-model="scope.model.blank_adopzrdd[index].remark"
  26. type="textarea"
  27. style="width: calc(100% - 80px)"
  28. ></el-input>
  29. </div>
  30. <div class="blank_adopzrdd">
  31. <span>金额:</span>
  32. <el-input
  33. v-model="scope.model.blank_adopzrdd[index].price"
  34. type="number"
  35. style="width: calc(100% - 80px)"
  36. ></el-input>
  37. </div>
  38. </div>
  39. </template>
  40. </fm-generate-form>
  41. <outboundXTBG
  42. v-if="form.taskDefinitionKey == 'CGYSP'"
  43. :biz-type="4"
  44. :source-biz-no="form?.processInstance.id"
  45. ref="outboundXTBGRef"
  46. ></outboundXTBG>
  47. <div slot="footer" class="dialog-footer">
  48. <el-form label-width="100px" ref="formRef" :model="form">
  49. <!-- prop="reason" -->
  50. <el-form-item
  51. label="审批建议"
  52. style="margin-bottom: 20px"
  53. :rules="{
  54. required: true,
  55. message: '',
  56. trigger: 'blur'
  57. }"
  58. >
  59. <el-input
  60. type="textarea"
  61. v-model="form.reason"
  62. placeholder="请输入审批建议"
  63. />
  64. </el-form-item>
  65. </el-form>
  66. <el-button
  67. icon="el-icon-edit-outline"
  68. type="success"
  69. size="mini"
  70. @click="handleAudit(1)"
  71. v-if="form.taskDefinitionKey != 'CGYSP'"
  72. >通过
  73. </el-button>
  74. <el-button
  75. icon="el-icon-edit-outline"
  76. type="success"
  77. size="mini"
  78. :loading="isSaveLoading"
  79. @click="storemanApprove(1)"
  80. v-if="form.taskDefinitionKey == 'CGYSP'"
  81. >出库
  82. </el-button>
  83. <el-button
  84. icon="el-icon-circle-close"
  85. type="danger"
  86. size="mini"
  87. @click="handleAudit(0)"
  88. >驳回
  89. </el-button>
  90. <el-dropdown
  91. @command="(command) => handleCommand(command)"
  92. style="margin-left: 30px"
  93. >
  94. <span class="el-dropdown-link">
  95. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  96. </span>
  97. <el-dropdown-menu slot="dropdown">
  98. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  99. </el-dropdown-menu>
  100. </el-dropdown>
  101. </div>
  102. </ele-modal>
  103. </template>
  104. <script>
  105. import Parser from '@/components/FormGenerator/components/parser/Parser.vue';
  106. import outboundXTBG from '@/views/bpm/outgoingManagement/outboundXTBG.vue';
  107. import {
  108. approveTaskWithVariables,
  109. cancelTask,
  110. rejectTask
  111. } from '@/api/bpm/task';
  112. import { getToken } from '@/utils/token-util';
  113. import storageApi from '@/api/warehouseManagement';
  114. export default {
  115. name: 'formParserDialog',
  116. components: { Parser, outboundXTBG },
  117. props: {
  118. businessId: {
  119. default: ''
  120. },
  121. formParserDialogFlag: {
  122. type: Boolean,
  123. default: false
  124. }
  125. },
  126. data() {
  127. return {
  128. form: {},
  129. index: '',
  130. jsonData: {},
  131. width: '30%',
  132. isSaveLoading: false
  133. };
  134. },
  135. methods: {
  136. open(row) {
  137. this.form = _.cloneDeep(row);
  138. console.log(this.form.taskDefinitionKey, 'this.form.taskDefinitionKey');
  139. if (this.form.taskDefinitionKey == 'CGYSP') {
  140. this.width = '70%';
  141. }
  142. this.jsonData = JSON.parse(this.form.formJson.makingJson);
  143. this.jsonData.config.dataSource &&
  144. this.jsonData.config.dataSource.forEach((item) => {
  145. item.headers = {
  146. Authorization: getToken()
  147. };
  148. // item.url = item.url && item.url.replace('/api', this.APIUrl);
  149. });
  150. },
  151. cancel() {
  152. this.$emit('update:formParserDialogFlag', false);
  153. },
  154. async handleAudit(status) {
  155. await this._approveTaskWithVariables(status);
  156. },
  157. async storemanApprove(status) {
  158. let storageData = await this.$refs.outboundXTBGRef.getReturnStorage();
  159. console.log(storageData);
  160. // 出库来源isSkip 0-正常 1-外部(外部跳过内部审核流程)
  161. storageData.isSkip = 1;
  162. storageData.isMes = 1;
  163. try {
  164. this.isSaveLoading = true;
  165. await storageApi.outStorage(storageData);
  166. approveTaskWithVariables({
  167. id: this.form.id,
  168. reason: this.form.reason,
  169. businessId: this.businessId,
  170. variables: {
  171. pass: true
  172. }
  173. }).then((res) => {
  174. if (res.data.code != '-1') {
  175. this.$message.success(`出库成功!`);
  176. this.$emit('reload');
  177. this.cancel();
  178. }
  179. this.isSaveLoading = false;
  180. });
  181. } catch (error) {
  182. this.isSaveLoading = false;
  183. console.error('出库失败:', error);
  184. }
  185. },
  186. async _approveTaskWithVariables(status) {
  187. let variables = {
  188. pass: !!status
  189. };
  190. let API = !!status ? approveTaskWithVariables : rejectTask;
  191. API({
  192. id: this.form.id,
  193. reason: this.form.reason,
  194. businessId: this.businessId,
  195. variables
  196. }).then((res) => {
  197. if (res.data.code != '-1') {
  198. let params = {
  199. status,
  200. title: status === 0 ? '驳回' : ''
  201. };
  202. this.$message.success(`审批${params.title}成功!`);
  203. this.$emit('reload');
  204. this.cancel();
  205. }
  206. });
  207. },
  208. //更多
  209. handleCommand(command) {
  210. if (command === 'cancel') {
  211. this.$confirm('是否确认作废?', {
  212. type: 'warning',
  213. cancelButtonText: '取消',
  214. confirmButtonText: '确定'
  215. })
  216. .then(() => {
  217. cancelTask({
  218. taskId: this.form.id,
  219. id: this.form.processInstance.id,
  220. reason: this.form.reason
  221. })
  222. .then(() => {
  223. this.$emit('reload');
  224. this.cancel();
  225. })
  226. .catch(() => {
  227. this.$message.error('流程作废失败');
  228. });
  229. })
  230. .catch(() => {});
  231. }
  232. }
  233. }
  234. };
  235. </script>
  236. <style scoped lang="scss">
  237. .blank_adopzrdd {
  238. display: flex;
  239. align-items: center;
  240. > span {
  241. display: inline-block;
  242. width: 80px;
  243. }
  244. margin-bottom: 10px;
  245. }
  246. </style>