submit.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. v-click-once
  51. @click="handleAudit(1)"
  52. >通过
  53. </el-button>
  54. <!-- <el-button
  55. icon="el-icon-edit-outline"
  56. type="success"
  57. size="mini"
  58. v-if="taskDefinitionKey === 'productionSupervisorApprove1'"
  59. @click="head"
  60. >指派技术员
  61. </el-button> -->
  62. <el-button
  63. icon="el-icon-circle-close"
  64. type="danger"
  65. size="mini"
  66. v-click-once
  67. @click="handleAudit(0)"
  68. v-if="!['starter', 'salesmanApprove'].includes(taskDefinitionKey)"
  69. >驳回
  70. </el-button>
  71. <el-dropdown
  72. @command="(command) => handleCommand(command)"
  73. style="margin-left: 30px"
  74. >
  75. <span class="el-dropdown-link"
  76. >更多<i class="el-icon-arrow-down el-icon--right"></i
  77. ></span>
  78. <el-dropdown-menu slot="dropdown">
  79. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  80. </el-dropdown-menu>
  81. </el-dropdown>
  82. <!-- <el-button
  83. icon="el-icon-circle-close"
  84. type="danger"
  85. size="mini"
  86. @click="handleBackList"
  87. >退回
  88. </el-button> -->
  89. <!-- <el-button
  90. icon="el-icon-circle-close"
  91. type="danger"
  92. size="mini"
  93. @click="handleAudit(0)"
  94. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  95. >不通过
  96. </el-button>
  97. <el-button
  98. icon="el-icon-edit-outline"
  99. type="primary"
  100. size="mini"
  101. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  102. @click="handleUpdateAssignee"
  103. >转办
  104. </el-button> -->
  105. </div>
  106. </el-col>
  107. </template>
  108. <script>
  109. import {
  110. updateProduct,
  111. UpdateInformation,
  112. cancel
  113. } from '@/api/bpm/components/saleManage/businessOpportunity';
  114. import { approveTaskWithVariables, rejectTask,cancelTask } from '@/api/bpm/task';
  115. import { listAllUserBind } from '@/api/system/organization';
  116. // 流程实例的详情页,可用于审批
  117. export default {
  118. name: '',
  119. components: {},
  120. props: {
  121. businessId: {
  122. default: ''
  123. },
  124. taskId: {
  125. default: ''
  126. },
  127. id: {
  128. default: ''
  129. },
  130. taskDefinitionKey: {
  131. default: ''
  132. }
  133. },
  134. data() {
  135. return {
  136. form: {
  137. technicianId: '',
  138. reason: '同意',
  139. technicalAnswerName: ''
  140. },
  141. userOptions: []
  142. };
  143. },
  144. created() {
  145. this.userOptions = [];
  146. listAllUserBind().then((data) => {
  147. this.userOptions.push(...data);
  148. });
  149. },
  150. methods: {
  151. head() {
  152. this.$refs.headRef.open();
  153. },
  154. /** 处理转办审批人 */
  155. handleUpdateAssignee() {
  156. this.$emit('handleUpdateAssignee');
  157. },
  158. /** 退回 */
  159. handleBackList() {
  160. this.$emit('handleBackList');
  161. },
  162. async handleAudit(status) {
  163. if (this.taskDefinitionKey === 'starter') {
  164. let arr = await this.getTableValue();
  165. if (!arr) {
  166. return;
  167. }
  168. let data = await UpdateInformation(arr);
  169. if (data.code != '0') {
  170. return;
  171. }
  172. }
  173. //生产主管审批选择技术员
  174. if (
  175. this.taskDefinitionKey === 'productionSupervisorApprove1' &&
  176. status === 1
  177. ) {
  178. let data = await this.getTableValue();
  179. if (!data) {
  180. return;
  181. }
  182. if (!this.form.technicianId) {
  183. this.$message.warning(`请选择技术人员!`);
  184. return;
  185. }
  186. let userIfon = this.userOptions.find(
  187. (item) => item.id == this.form.technicianId
  188. );
  189. data?.productList?.forEach((item) => {
  190. item['technicalAnswerId'] = this.form.technicianId;
  191. item['technicalAnswerName'] = userIfon?.name;
  192. });
  193. await UpdateInformation(data);
  194. }
  195. //生产主管2审批
  196. if (
  197. this.taskDefinitionKey === 'productionSupervisorApprove2' &&
  198. status === 1
  199. ) {
  200. let data = await this.getTableValue();
  201. if (!data) {
  202. return;
  203. }
  204. let isProduceDeliveryDeadline = true;
  205. data?.productList?.forEach((item) => {
  206. if (!item.produceDeliveryDeadline) {
  207. isProduceDeliveryDeadline = false;
  208. }
  209. });
  210. if (!isProduceDeliveryDeadline) {
  211. this.$message.warning(`请选择生产交付交期!`);
  212. return;
  213. }
  214. await UpdateInformation(data);
  215. }
  216. //技术员修改
  217. if (
  218. (this.taskDefinitionKey === 'technicianApprove' ||
  219. this.taskDefinitionKey === 'techLeaderApprove') &&
  220. status === 1
  221. ) {
  222. let data = await this.getTableValue();
  223. if (!data) {
  224. return;
  225. }
  226. // let requiredFiled = [
  227. // {
  228. // filed: 'singleWeight',
  229. // name: '单重'
  230. // }
  231. // ];
  232. // let list = [];
  233. // data?.productList?.forEach((item) => {
  234. // requiredFiled.forEach((i) => {
  235. // if (!item[i.filed] && item[i.filed] !== 0) {
  236. // list.push(i.name);
  237. // }
  238. // });
  239. // });
  240. // if (list.length) {
  241. // return this.$message.warning('请输入' + list.join(','));
  242. // }
  243. await UpdateInformation(data);
  244. }
  245. //销售主管审批
  246. if (this.taskDefinitionKey === 'salesManagerApprove' && status === 1) {
  247. let arr = await this.getTableValue();
  248. if (!arr) {
  249. return;
  250. }
  251. await UpdateInformation(arr);
  252. }
  253. //销售员补充
  254. if (this.taskDefinitionKey === 'salesmanApprove' && status === 1) {
  255. let arr = await this.getTableValue();
  256. if (!arr) {
  257. return;
  258. }
  259. let singlePrice = true;
  260. let totalCount = true;
  261. arr?.productList.forEach((item) => {
  262. if (!item.singlePrice) {
  263. singlePrice = false;
  264. }
  265. if (!item.totalCount) {
  266. totalCount = false;
  267. }
  268. });
  269. if (!singlePrice) {
  270. this.$message.warning(`请输入单价`);
  271. return;
  272. }
  273. if (!totalCount) {
  274. this.$message.warning(`请输入数量`);
  275. return;
  276. }
  277. await UpdateInformation(arr);
  278. }
  279. this._approveTaskWithVariables(status);
  280. },
  281. async _approveTaskWithVariables(status) {
  282. // return;
  283. let variables = {
  284. pass: !!status
  285. };
  286. if (this.form.technicianId) {
  287. variables['technicianId'] = this.form.technicianId;
  288. }
  289. let API = !!status ? approveTaskWithVariables : rejectTask;
  290. API({
  291. id: this.taskId,
  292. reason: this.form.reason,
  293. variables
  294. }).then((res) => {
  295. if (res.data.code != '-1') {
  296. this.$emit('handleAudit', {
  297. status,
  298. title: status === 0 ? '驳回' : ''
  299. });
  300. }
  301. });
  302. },
  303. getTableValue() {
  304. return new Promise((resolve, reject) => {
  305. this.$emit('getTableValue', async (data) => {
  306. resolve(await data);
  307. });
  308. });
  309. },
  310. //更多
  311. handleCommand(command) {
  312. if (command === 'cancel') {
  313. this.$confirm('是否确认作废?', {
  314. type: 'warning',
  315. cancelButtonText: '取消',
  316. confirmButtonText: '确定'
  317. })
  318. .then(() => {
  319. cancelTask({
  320. id: this.id,
  321. taskId: this.taskId,
  322. reason: this.form.reason,
  323. businessId: this.businessId
  324. })
  325. .then(() => {
  326. this.$emit('handleClose');
  327. })
  328. .catch(() => {
  329. this.$message.error('流程作废失败');
  330. });
  331. })
  332. .catch(() => {});
  333. }
  334. }
  335. }
  336. };
  337. </script>
  338. <style lang="scss"></style>