submit.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. v-if="taskDefinitionKey == 'productionSupervisorApprove1'"
  14. >
  15. <el-select
  16. v-model="form.technicianId"
  17. clearable
  18. style="width: 100%"
  19. :filterable="true"
  20. >
  21. <el-option
  22. v-for="item in userOptions"
  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. >通过
  52. </el-button>
  53. <!-- <el-button
  54. icon="el-icon-edit-outline"
  55. type="success"
  56. size="mini"
  57. v-if="taskDefinitionKey === 'productionSupervisorApprove1'"
  58. @click="head"
  59. >指派技术员
  60. </el-button> -->
  61. <el-button
  62. icon="el-icon-circle-close"
  63. type="danger"
  64. size="mini"
  65. @click="handleAudit(0)"
  66. v-if="
  67. !['starter'].includes(
  68. taskDefinitionKey
  69. )
  70. "
  71. >驳回
  72. </el-button>
  73. <el-dropdown @command="(command) => handleCommand(command)" style="margin-left: 30px;">
  74. <span class="el-dropdown-link">更多<i class="el-icon-arrow-down el-icon--right"></i></span>
  75. <el-dropdown-menu slot="dropdown">
  76. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  77. </el-dropdown-menu>
  78. </el-dropdown>
  79. <!-- <el-button
  80. icon="el-icon-circle-close"
  81. type="danger"
  82. size="mini"
  83. @click="handleBackList"
  84. >退回
  85. </el-button> -->
  86. <!-- <el-button
  87. icon="el-icon-circle-close"
  88. type="danger"
  89. size="mini"
  90. @click="handleAudit(0)"
  91. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  92. >不通过
  93. </el-button>
  94. <el-button
  95. icon="el-icon-edit-outline"
  96. type="primary"
  97. size="mini"
  98. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  99. @click="handleUpdateAssignee"
  100. >转办
  101. </el-button> -->
  102. </div>
  103. <head-list ref="headRef" @changeParent="changePersonel"></head-list>
  104. </el-col>
  105. </template>
  106. <script>
  107. import {
  108. updateTech,
  109. UpdateInformation,
  110. cancel
  111. } from '@/api/bpm/components/saleManage/quotation';
  112. import {approveTaskWithVariables, rejectTask} from '@/api/bpm/task';
  113. import { listAllUserBind } from '@/api/system/organization';
  114. import headList from '@/components/headList';
  115. // 流程实例的详情页,可用于审批
  116. export default {
  117. name: '',
  118. components: {
  119. headList
  120. },
  121. props: {
  122. businessId: {
  123. default: ''
  124. },
  125. taskId: {
  126. default: ''
  127. },
  128. id: {
  129. default: ''
  130. },
  131. taskDefinitionKey: {
  132. default: ''
  133. }
  134. },
  135. data() {
  136. return {
  137. form: {
  138. technicianId: '',
  139. reason: ''
  140. },
  141. userOptions: []
  142. };
  143. },
  144. created() {
  145. this.userOptions = [];
  146. listAllUserBind().then((data) => {
  147. this.userOptions.push(...data);
  148. });
  149. },
  150. methods: {
  151. /** 处理转办审批人 */
  152. handleUpdateAssignee() {
  153. this.$emit('handleUpdateAssignee');
  154. },
  155. /** 退回 */
  156. handleBackList() {
  157. this.$emit('handleBackList');
  158. },
  159. head() {
  160. this.$refs.headRef.open();
  161. },
  162. changePersonel(data) {
  163. this.form.technicianId = data.id;
  164. this.handleAudit(1, 'zp');
  165. },
  166. async handleAudit(status, type) {
  167. //生产主管审批选择技术员
  168. // if (this.taskDefinitionKey === 'productionSupervisorApprove1') {
  169. // if (!this.form.technicianId && type == 'zp') {
  170. // this.$message.warning(`请选择技术人员!`);
  171. // return;
  172. // }
  173. // }
  174. //技术员修改
  175. // if (this.taskDefinitionKey === 'technicianApprove' && status === 1) {
  176. // let data = await this.getTableValue();
  177. // if (!arr) {
  178. // return;
  179. // }
  180. // let arr = data.map((item) => {
  181. // return {
  182. // id: item.id,
  183. // technicalAnswerId: item.technicalAnswerId,
  184. // technicalAnswerName: item.technicalAnswerName,
  185. // technicalDrawings: item.technicalDrawings,
  186. // technicalParams: item.technicalParams
  187. // };
  188. // });
  189. // try {
  190. // await updateTech(arr);
  191. // } catch (error) {}
  192. // }
  193. //销售员补充
  194. if ((this.taskDefinitionKey === 'salesmanApprove'||this.taskDefinitionKey === 'starter')&&status === 1) {
  195. let arr = await this.getTableValue();
  196. if (!arr) {
  197. return;
  198. }
  199. let data = await UpdateInformation(arr);
  200. if (data.code != '0') {
  201. return;
  202. }
  203. }
  204. this._approveTaskWithVariables(status, this.form.technicianId, type);
  205. },
  206. async _approveTaskWithVariables(status, technicianId, type) {
  207. let variables = {
  208. pass: !!status
  209. };
  210. if (technicianId && type == 'zp') {
  211. variables['technicianId'] = technicianId;
  212. }
  213. let API = !!status ? approveTaskWithVariables : rejectTask;
  214. API({
  215. id: this.taskId,
  216. reason: this.form.reason,
  217. variables
  218. }).then((res) => {
  219. if (res.data.code != '-1') {
  220. this.$emit('handleAudit', {
  221. status,
  222. title: status === 0 ? '驳回' : ''
  223. });
  224. }
  225. });
  226. },
  227. getTableValue() {
  228. return new Promise((resolve, reject) => {
  229. this.$emit('getTableValue', async (data) => {
  230. resolve(await data);
  231. });
  232. });
  233. },
  234. //更多
  235. handleCommand(command) {
  236. if (command === 'cancel') {
  237. this.$confirm("是否确认作废?", {
  238. type: 'warning',
  239. cancelButtonText: '取消',
  240. confirmButtonText: '确定'
  241. }).then(() => {
  242. cancel({
  243. id: this.taskId,
  244. reason: this.form.reason,
  245. businessId: this.businessId,
  246. }).then(() => {
  247. this.$emit('handleClose');
  248. }).catch(() => {
  249. this.$message.error("流程作废失败");
  250. });
  251. }).catch(() => {});
  252. }
  253. },
  254. }
  255. };
  256. </script>
  257. <style lang="scss"></style>