submit.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <el-col :span="16" :offset="6">
  3. <el-form label-width="100px" ref="formRef" :model="form">
  4. <!-- <el-form-item
  5. label="采购员"
  6. prop="technicianId"
  7. style="margin-bottom: 20px"
  8. :rules="{
  9. required: true,
  10. message: '请选择',
  11. trigger: 'change'
  12. }"
  13. >
  14. <el-select
  15. v-model="form.technicianId"
  16. clearable
  17. style="width: 100%"
  18. :filterable="true"
  19. >
  20. <el-option
  21. v-for="item in userOptions"
  22. @click.native="form.userName = item.name"
  23. :key="item.id"
  24. :label="item.name"
  25. :value="item.id"
  26. />
  27. </el-select>
  28. </el-form-item> -->
  29. <el-form-item
  30. label="审批意见"
  31. style="margin-bottom: 20px"
  32. :rules="{
  33. required: true,
  34. message: '请选择',
  35. trigger: 'change'
  36. }"
  37. >
  38. <ApprovalOpinion ref="approvalOpinion" v-model="form.reason" />
  39. </el-form-item>
  40. </el-form>
  41. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  42. <el-button
  43. icon="el-icon-edit-outline"
  44. type="success"
  45. size="mini"
  46. @click="$refs.approvalOpinion.validate(1) && handleAudit(1)"
  47. v-click-once
  48. >通过
  49. </el-button>
  50. <el-button
  51. icon="el-icon-circle-close"
  52. type="danger"
  53. size="mini"
  54. v-click-once
  55. @click="$refs.approvalOpinion.validate(0) && rejectTask(0)"
  56. >驳回
  57. </el-button>
  58. <el-dropdown
  59. @command="(command) => handleCommand(command)"
  60. style="margin-left: 30px"
  61. >
  62. <span class="el-dropdown-link"
  63. >更多<i class="el-icon-arrow-down el-icon--right"></i
  64. ></span>
  65. <el-dropdown-menu slot="dropdown">
  66. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  67. </el-dropdown-menu>
  68. </el-dropdown>
  69. </div>
  70. </el-col>
  71. </template>
  72. <script>
  73. import {
  74. apspurchaseplan,
  75. cancel
  76. } from '@/api/bpm/components/apsMeterialPlan';
  77. import {
  78. approveTaskWithVariables,
  79. rejectTask,
  80. cancelTask
  81. } from '@/api/bpm/task';
  82. import { listAllUserBind } from '@/api/system/organization';
  83. // 流程实例的详情页,可用于审批
  84. export default {
  85. name: '',
  86. components: {},
  87. props: {
  88. businessId: {
  89. default: ''
  90. },
  91. taskId: {
  92. default: ''
  93. },
  94. id: {
  95. default: ''
  96. },
  97. taskDefinitionKey: {
  98. default: ''
  99. }
  100. },
  101. data() {
  102. return {
  103. form: {
  104. // technicianId: '',
  105. reason: '同意'
  106. },
  107. userOptions: []
  108. };
  109. },
  110. created() {
  111. this.userOptions = [];
  112. listAllUserBind().then((data) => {
  113. this.userOptions.push(...data);
  114. });
  115. },
  116. methods: {
  117. async handleAudit(status, type) {
  118. //生产主管审批选择技术员
  119. // if (!this.form.technicianId && status == 1) {
  120. // this.$message.warning(`请选择采购员!`);
  121. // return;
  122. // }
  123. this._approveTaskWithVariables(status);
  124. },
  125. rejectTask(status) {
  126. rejectTask({
  127. id: this.taskId,
  128. reason: this.form.reason,
  129. pass: false
  130. }).then((res) => {
  131. if (res.data.code != '-1') {
  132. this.$emit('handleAudit', {
  133. status,
  134. title: '驳回'
  135. });
  136. }
  137. });
  138. },
  139. async _approveTaskWithVariables(status) {
  140. if (status == 1) {
  141. apspurchaseplan({
  142. businessId: this.businessId,
  143. id: this.taskId,
  144. userId: this.form.technicianId,
  145. userName: this.form.userName,
  146. reason: this.form.reason,
  147. pass: true
  148. }).then((res) => {
  149. if (res.data.code != '-1') {
  150. this.$emit('handleAudit', {
  151. status,
  152. title: ''
  153. });
  154. }
  155. });
  156. } else if (status == 0) {
  157. let API = rejectTask;
  158. API({
  159. id: this.taskId,
  160. reason: this.form.reason,
  161. pass: false
  162. }).then((res) => {
  163. if (res.data.code != '-1') {
  164. this.$emit('handleAudit', {
  165. status,
  166. title: '驳回'
  167. });
  168. }
  169. });
  170. }
  171. },
  172. getTableValue() {
  173. return new Promise((resolve, reject) => {
  174. this.$emit('getTableValue', async (data) => {
  175. resolve(await data);
  176. });
  177. });
  178. },
  179. //更多
  180. handleCommand(command) {
  181. if (command === 'cancel') {
  182. this.$confirm('是否确认作废?', {
  183. type: 'warning',
  184. cancelButtonText: '取消',
  185. confirmButtonText: '确定'
  186. })
  187. .then(() => {
  188. cancelTask({
  189. taskId: this.taskId,
  190. id: this.id,
  191. reason: this.form.reason,
  192. businessId: this.businessId
  193. })
  194. .then(() => {
  195. this.$emit('handleClose');
  196. })
  197. .catch(() => {
  198. this.$message.error('流程作废失败');
  199. });
  200. })
  201. .catch(() => {});
  202. }
  203. }
  204. }
  205. };
  206. </script>
  207. <style lang="scss"></style>