submit.vue 9.4 KB

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