submit.vue 5.3 KB

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