submit.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <el-col :span="16" :offset="6">
  3. <el-form label-width="100px" ref="formRef" :model="form">
  4. <el-form-item
  5. v-if="taskDefinitionKey === 'deptLeaderAssign'"
  6. label="采购部门"
  7. prop="userId"
  8. style="margin-bottom: 20px"
  9. >
  10. <deptSelect
  11. v-model="form.useDeptId"
  12. @changeGroup="searchDeptNodeClick"
  13. />
  14. </el-form-item>
  15. <el-form-item
  16. v-if="taskDefinitionKey === 'deptLeaderAssign'"
  17. label="采购员"
  18. prop="userId"
  19. style="margin-bottom: 20px"
  20. :rules="{
  21. required: true,
  22. message: '请选择',
  23. trigger: 'change'
  24. }"
  25. >
  26. <el-select
  27. v-model="form.userId"
  28. clearable
  29. style="width: 100%"
  30. :filterable="true"
  31. >
  32. <el-option
  33. v-for="item in userOptions"
  34. :key="item.id"
  35. :label="item.name"
  36. :value="item.id"
  37. />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item
  41. label="审批建议"
  42. style="margin-bottom: 20px"
  43. :rules="{
  44. required: true,
  45. message: '请选择',
  46. trigger: 'change'
  47. }"
  48. >
  49. <el-input
  50. type="textarea"
  51. v-model="form.reason"
  52. placeholder="请输入审批建议"
  53. />
  54. </el-form-item>
  55. </el-form>
  56. <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
  57. <el-button
  58. icon="el-icon-edit-outline"
  59. type="success"
  60. size="mini"
  61. @click="handleAudit(1)"
  62. v-if="!['storeManagerApprove'].includes(taskDefinitionKey)"
  63. >通过
  64. </el-button>
  65. <el-button
  66. icon="el-icon-circle-close"
  67. type="danger"
  68. size="mini"
  69. @click="rejectTask(0)"
  70. >驳回
  71. </el-button>
  72. <!-- <el-button
  73. icon="el-icon-circle-close"
  74. type="danger"
  75. size="mini"
  76. @click="handleBackList"
  77. >退回
  78. </el-button> -->
  79. <!-- <el-button
  80. icon="el-icon-circle-close"
  81. type="danger"
  82. size="mini"
  83. @click="handleAudit(0)"
  84. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  85. >不通过
  86. </el-button>
  87. <el-button
  88. icon="el-icon-edit-outline"
  89. type="primary"
  90. size="mini"
  91. v-if="taskDefinitionKey != 'productionSupervisorApprove1'"
  92. @click="handleUpdateAssignee"
  93. >转办
  94. </el-button> -->
  95. </div>
  96. </el-col>
  97. </template>
  98. <script>
  99. import { approveTaskWithVariables, rejectTask,cancelTask } from '@/api/bpm/task';
  100. import { listAllUserBind } from '@/api/system/organization';
  101. import {
  102. assign,
  103. cancel,
  104. UpdateInformation
  105. } from '@/api/bpm/components/purchasingManage/purchasePlanManage';
  106. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  107. import { getUserPage } from '@/api/system/organization';
  108. import storageApi from '@/api/warehouseManagement';
  109. // 流程实例的详情页,可用于审批
  110. export default {
  111. name: '',
  112. components: {
  113. deptSelect
  114. },
  115. props: {
  116. businessId: {
  117. default: ''
  118. },
  119. taskId: {
  120. default: ''
  121. },
  122. id: {
  123. default: ''
  124. },
  125. taskDefinitionKey: {
  126. default: ''
  127. }
  128. },
  129. data() {
  130. return {
  131. form: {
  132. userId: '',
  133. reason: '',
  134. useDeptId: ''
  135. },
  136. userOptions: [],
  137. isSaveLoading:false
  138. };
  139. },
  140. created() {
  141. this.userOptions = [];
  142. listAllUserBind().then((data) => {
  143. this.userOptions.push(...data);
  144. });
  145. },
  146. methods: {
  147. /** 处理转办审批人 */
  148. handleUpdateAssignee() {
  149. this.$emit('handleUpdateAssignee');
  150. },
  151. /** 退回 */
  152. handleBackList() {
  153. this.$emit('handleBackList');
  154. },
  155. searchDeptNodeClick(val) {
  156. console.log(val, 'val');
  157. getUserPage({
  158. groupId: val,
  159. size: 999
  160. }).then((data) => {
  161. this.userOptions = data.list;
  162. });
  163. },
  164. async storeManagerApprove() {
  165. let res = await this.getTableValue();
  166. let storageData = res.returnStorageData;
  167. if(!storageData){
  168. return
  169. }
  170. storageData.isSkip = 1;
  171. try {
  172. this.isSaveLoading = true;
  173. await storageApi.storage(storageData);
  174. approveTaskWithVariables({
  175. id: this.taskId,
  176. reason: this.form.reason,
  177. variables: {
  178. pass: true
  179. }
  180. }).then((res) => {
  181. if (res.code != '-1') {
  182. this.$emit('handleAudit', {
  183. status: 1,
  184. title: '入库'
  185. });
  186. }
  187. this.isSaveLoading = false;
  188. });
  189. } catch (error) {
  190. this.isSaveLoading = false;
  191. this.$message.error('保存失败');
  192. }
  193. },
  194. async handleAudit(status) {
  195. let userInfo = this.userOptions.find(
  196. (item) => item.id == this.form.userId
  197. );
  198. //主管指派采购员
  199. if (this.taskDefinitionKey === 'deptLeaderAssign') {
  200. if (!this.form.userId) {
  201. this.$message.warning(`请选择采购员!`);
  202. return;
  203. }
  204. await assign({
  205. userId: userInfo.id,
  206. userName: userInfo.name,
  207. id: this.taskId,
  208. reason: this.form.reason,
  209. businessId: this.businessId
  210. });
  211. }
  212. // //采购员核对
  213. // if (this.taskDefinitionKey === 'purchaserCheck') {
  214. // let arr = await this.getTableValue();
  215. // if (!arr) {
  216. // return;
  217. // }
  218. // await UpdateInformation(arr);
  219. // }
  220. let API = !!status ? approveTaskWithVariables : rejectTask;
  221. API({
  222. id: this.taskId,
  223. reason: this.form.reason,
  224. variables: {
  225. userId: userInfo?.id,
  226. pass: !!status
  227. }
  228. });
  229. this.$emit('handleAudit', {
  230. status,
  231. title: status === 0 ? '驳回' : ''
  232. });
  233. },
  234. rejectTask(status) {
  235. rejectTask({
  236. id: this.taskId,
  237. reason: this.form.reason,
  238. variables: {
  239. pass: !!status
  240. }
  241. });
  242. this.$emit('handleAudit', {
  243. status,
  244. title: status === 0 ? '驳回' : ''
  245. });
  246. },
  247. getTableValue() {
  248. return new Promise((resolve, reject) => {
  249. this.$emit('getTableValue', async (data) => {
  250. resolve(await data);
  251. });
  252. });
  253. },
  254. //更多
  255. handleCommand(command) {
  256. if (command === 'cancel') {
  257. this.$confirm('是否确认作废?', {
  258. type: 'warning',
  259. cancelButtonText: '取消',
  260. confirmButtonText: '确定'
  261. })
  262. .then(() => {
  263. cancelTask({
  264. id: this.id,
  265. taskId: this.taskId,
  266. reason: this.form.reason,
  267. businessId: this.businessId
  268. })
  269. .then(() => {
  270. this.$emit('handleClose');
  271. })
  272. .catch(() => {
  273. this.$message.error('流程作废失败');
  274. });
  275. })
  276. .catch(() => {});
  277. }
  278. }
  279. }
  280. };
  281. </script>
  282. <style lang="scss"></style>