submit.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <el-col :span="16" :offset="6">
  3. <el-form label-width="100px" ref="formRef" :model="form">
  4. <!-- <el-form-item label="完成时间:" prop="finishTime">
  5. <el-date-picker
  6. v-model="form.finishTime"
  7. type="date"
  8. value-format="yyyy-MM-dd"
  9. ></el-date-picker>
  10. </el-form-item> -->
  11. <el-form-item
  12. label="审批建议"
  13. style="margin-bottom: 20px"
  14. :rules="{
  15. required: true,
  16. message: '请选择',
  17. trigger: 'change'
  18. }"
  19. >
  20. <el-input
  21. type="textarea"
  22. v-model="form.reason"
  23. placeholder="请输入审批建议"
  24. />
  25. </el-form-item>
  26. </el-form>
  27. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  28. <el-button
  29. icon="el-icon-edit-outline"
  30. type="success"
  31. size="mini"
  32. @click="handleAudit(1)"
  33. >通过
  34. </el-button>
  35. <!-- <el-button
  36. icon="el-icon-edit-outline"
  37. type="warning"
  38. size="mini"
  39. @click="edit"
  40. >修改完成时间
  41. </el-button> -->
  42. <el-button
  43. icon="el-icon-circle-close"
  44. type="danger"
  45. size="mini"
  46. @click="handleAudit(0)"
  47. v-if="taskDefinitionKey != 'starter'"
  48. >驳回
  49. </el-button>
  50. <!-- <el-dropdown
  51. @command="(command) => handleCommand(command)"
  52. style="margin-left: 30px"
  53. >
  54. <span class="el-dropdown-link">
  55. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  56. </span>
  57. <el-dropdown-menu slot="dropdown">
  58. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  59. </el-dropdown-menu>
  60. </el-dropdown> -->
  61. </div>
  62. <ele-modal
  63. :visible.sync="visible"
  64. title="修改完成时间"
  65. width="20vw"
  66. append-to-body
  67. @close="cancel"
  68. >
  69. <el-form label-width="100px" ref="formRef1" :model="formData">
  70. <el-form-item
  71. label="完成时间:"
  72. prop="finishTime"
  73. :rules="{
  74. required: true,
  75. message: '请输入',
  76. trigger: 'change'
  77. }"
  78. >
  79. <el-date-picker
  80. v-model="formData.finishTime"
  81. type="date"
  82. value-format="yyyy-MM-dd"
  83. style="width: 100%"
  84. ></el-date-picker>
  85. </el-form-item>
  86. <el-form-item
  87. label="审批建议"
  88. style="margin-bottom: 20px"
  89. :rules="{
  90. required: true,
  91. message: '请选择',
  92. trigger: 'change'
  93. }"
  94. >
  95. <el-input
  96. type="textarea"
  97. v-model="formData.reason"
  98. placeholder="请输入审批建议"
  99. />
  100. </el-form-item>
  101. </el-form>
  102. <template v-slot:footer>
  103. <el-button @click="visible = false">取消</el-button>
  104. <el-button type="primary" @click="save"> 确定 </el-button>
  105. </template>
  106. </ele-modal>
  107. </el-col>
  108. </template>
  109. <script>
  110. import { approveTaskWithVariables, rejectTask } from '@/api/bpm/task';
  111. import dictMixins from '@/mixins/dictMixins';
  112. import { save } from '@/api/bpm/components/entrust';
  113. // import {
  114. // assign,
  115. // cancel
  116. // } from '@/api/bpm/components/purchasingManage/purchasePlanManage';
  117. // 流程实例的详情页,可用于审批
  118. export default {
  119. mixins: [dictMixins],
  120. name: '',
  121. components: {
  122. // Parser
  123. },
  124. props: {
  125. businessId: {
  126. default: ''
  127. },
  128. taskId: {
  129. default: ''
  130. },
  131. id: {
  132. default: ''
  133. },
  134. taskDefinitionKey: {
  135. default: ''
  136. }
  137. },
  138. data() {
  139. return {
  140. visible: false,
  141. form: {
  142. reason: ''
  143. },
  144. formData: {
  145. finishTime: ''
  146. }
  147. };
  148. },
  149. created() {},
  150. methods: {
  151. async edit() {
  152. this.visible = true;
  153. this.formData = await this.getTableValue();
  154. },
  155. async handleAudit(status) {
  156. //申请人申请
  157. if (this.taskDefinitionKey === 'starter') {
  158. const data = await this.getTableValue();
  159. // return
  160. if (data) {
  161. await save(data);
  162. }
  163. }
  164. await this._approveTaskWithVariables(status);
  165. },
  166. async save() {
  167. await save(this.formData);
  168. },
  169. async _approveTaskWithVariables(status) {
  170. let variables = {
  171. pass: !!status
  172. };
  173. let API = !!status ? approveTaskWithVariables : rejectTask;
  174. API({
  175. id: this.taskId,
  176. reason: this.form.reason,
  177. variables
  178. }).then((res) => {
  179. if (res.data.code != '-1') {
  180. this.$emit('handleAudit', {
  181. status,
  182. title: status === 0 ? '驳回' : ''
  183. });
  184. }
  185. });
  186. },
  187. getTableValue() {
  188. return new Promise((resolve, reject) => {
  189. this.$emit('getTableValue', async (data) => {
  190. resolve(await data);
  191. });
  192. });
  193. },
  194. cancel() {}
  195. }
  196. };
  197. </script>
  198. <style lang="scss"></style>