formParserDialog.vue 5.2 KB

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