taskSubmit.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view class="">
  3. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" :rules="rules" ref="uForm"
  4. labelWidth='140rpx'>
  5. <u-form-item v-if="['QCLeaderApprove'].includes(taskDefinitionKey)" label="质检员" prop="qualityInspectorName"
  6. required>
  7. <u--input clearable placeholder="请选择" border="surround" v-model="form.qualityInspectorName"
  8. @click.native="showTechnicianPicker"></u--input>
  9. </u-form-item>
  10. <u-form-item label="审批建议" prop="reason" required>
  11. <u--textarea style="width: 100%;" height='120' border='surround' placeholder="请输入审批建议"
  12. v-model="form.reason"></u--textarea>
  13. </u-form-item>
  14. </u--form>
  15. <view class="btnList">
  16. <u-button v-if="passBtnDisabled" style="width: 45%;margin-bottom: 10rpx;" :loading='loading' type="success" text="通过" @click="handleAudit(1)">
  17. </u-button>
  18. <u-button v-if="acceptBtnDisabled" style="width: 45%;margin-bottom: 10rpx;" :loading='loading' type="success" text="申请入库" @click="storeManagerApprove">
  19. </u-button>
  20. <u-button style="width: 45%;" :loading='loading' type="error" text="驳回" @click="handleAudit(0)"></u-button>
  21. </view>
  22. <view class="btnConcel">
  23. <u-button @click="showAction = true">更多</u-button>
  24. </view>
  25. <u-action-sheet :actions="actionList" :closeOnClickOverlay="true" :closeOnClickAction="true" title="更多操作" :show="showAction" @close="showAction = false" @select="selectActionClick"></u-action-sheet>
  26. <u-picker itemHeight='60' :show="technicianShow" visibleItemCount='10' :columns="userOptions" keyName="name"
  27. @confirm='selectTechnicianInfo' @cancel='technicianShow = false' title='选择质检员'></u-picker>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. approveTaskWithVariables,
  33. rejectTask,
  34. getWarehouseListByIdsAPI,
  35. getOutInBySourceBizNo,
  36. purchaseOrderReceiveGetByIdAPI
  37. } from '@/api/wt/index.js'
  38. import {
  39. listAllUserBind
  40. } from '@/api/common.js'
  41. import { storage } from '@/api/warehouseManagement/index.js'
  42. export default {
  43. name: 'taskSubmit',
  44. props: {
  45. businessId: {
  46. default: ''
  47. },
  48. taskId: {
  49. default: ''
  50. },
  51. id: {
  52. default: ''
  53. },
  54. taskDefinitionKey: {
  55. default: ''
  56. },
  57. fromUser: {
  58. default: ''
  59. }
  60. },
  61. computed: {
  62. acceptBtnDisabled() {
  63. return ['storeManagerApprove'].includes(this.taskDefinitionKey) && ![1, 2].includes(Number(this.outInData.flowableStatus))
  64. },
  65. passBtnDisabled() {
  66. return !['storeManagerApprove'].includes(this.taskDefinitionKey) || (['storeManagerApprove'].includes(this.taskDefinitionKey) && [2].includes(Number(this.outInData.flowableStatus)));
  67. }
  68. },
  69. data() {
  70. return {
  71. showAction: false,
  72. loading: false,
  73. technicianShow: false,
  74. userOptions: [],
  75. actionList: [{
  76. name: '作废',
  77. fontSize: '28',
  78. color: '#ffaa7f'
  79. }],
  80. outInData: {
  81. flowableStatus: ''
  82. },
  83. form: {
  84. qualityInspectorName: '',
  85. qualityInspector: '',
  86. reason: '同意',
  87. },
  88. rules: {
  89. reason: {
  90. type: 'string',
  91. required: true,
  92. message: '请输入审批建议',
  93. trigger: 'blur'
  94. },
  95. qualityInspectorName: {
  96. type: 'string',
  97. required: true,
  98. message: '请选择质检员',
  99. trigger: ['blur', 'change']
  100. },
  101. }
  102. }
  103. },
  104. mounted() {
  105. this.$refs.uForm.setRules(this.rules)
  106. this.getUserOptions()
  107. },
  108. methods: {
  109. async getUserOptions() {
  110. const data = await listAllUserBind()
  111. this.userOptions.push(data)
  112. if (this.taskDefinitionKey == 'storeManagerApprove') {
  113. let data = await purchaseOrderReceiveGetByIdAPI(this.businessId);
  114. try {
  115. this.outInData = await getInfoBySourceBizNo(
  116. data.receiveNo
  117. );
  118. console.log('outInData----------', this.outInData);
  119. } catch (error) {}
  120. }
  121. },
  122. showTechnicianPicker(val) {
  123. if (val.target.nodeName == 'I') {
  124. this.form.qualityInspector = ''
  125. this.form.qualityInspectorName = ''
  126. return
  127. }
  128. this.technicianShow = true
  129. },
  130. selectTechnicianInfo(e) {
  131. this.form.qualityInspector = e.value[0]?.id
  132. this.form.qualityInspectorName = e.value[0]?.name
  133. this.technicianShow = false
  134. },
  135. async handleAudit(status) {
  136. if (!!status) await this.$refs.uForm.validate()
  137. let storemanIds = []
  138. if (this.taskDefinitionKey === 'deptLeaderApprove') {
  139. let form = await this.getTableValue();
  140. let ids = form.productList.map((item) => item.warehouseId);
  141. let data = await getWarehouseListByIdsAPI(ids || []);
  142. storemanIds = data.map((item) => item.ownerId) || [];
  143. if (!storemanIds.length) return uni.$u.toast('未配置仓管人员,请检查')
  144. }
  145. this.loading = true
  146. await this._approveTaskWithVariables(status, Array.from(new Set(storemanIds)).toString());
  147. },
  148. async _approveTaskWithVariables(status, storemanIds) {
  149. let variables = {
  150. pass: !!status,
  151. storemanIds
  152. };
  153. if (this.form.qualityInspector) {
  154. variables['qualityInspector'] = this.form.qualityInspector;
  155. }
  156. const requestUrl = !!status ? approveTaskWithVariables : rejectTask
  157. let res = await requestUrl({
  158. id: this.taskId,
  159. reason: this.form.reason,
  160. variables
  161. })
  162. if (res.code != '-1') {
  163. this.$emit('handleAudit', {
  164. status,
  165. title: status === 0 ? '驳回' : ''
  166. });
  167. }
  168. this.loading = false
  169. },
  170. async storeManagerApprove() {
  171. let res = await this.getTableValue();
  172. let storageData = res.returnStorageData;
  173. console.log('storageData~~~', storageData);
  174. // return
  175. // 出库来源isSkip 0-正常 1-外部(外部跳过内部审核流程)
  176. storageData.isSkip = 1;
  177. storageData.fromUser = this.fromUser;
  178. try {
  179. this.loading = true;
  180. await storage(storageData);
  181. approveTaskWithVariables({
  182. id: this.taskId,
  183. reason: this.form.reason,
  184. variables: {
  185. pass: true
  186. }
  187. }).then((res) => {
  188. if (res.code != '-1') {
  189. this.$emit('handleAudit', {
  190. status: 1,
  191. title: '入库'
  192. });
  193. }
  194. this.loading = false;
  195. });
  196. } catch (error) {
  197. this.loading = false;
  198. console.error('保存失败:', error);
  199. }
  200. },
  201. selectActionClick(item) {
  202. console.log('selectActionClick', item)
  203. if (item.name == '作废') {
  204. uni.showModal({
  205. title: '提示',
  206. content: '是否确认作废?',
  207. success: (res) => {
  208. if (res.confirm) {
  209. this.loading = true
  210. cancelTask({
  211. taskId: this.taskId,
  212. id: this.id,
  213. reason: this.form.reason,
  214. businessId: this.businessId,
  215. }).then(() => {
  216. if (res.code != '-1') {
  217. this.loading = false
  218. this.$emit('handleAudit', {
  219. title: '作废'
  220. });
  221. }
  222. }).catch(() => {
  223. this.loading = false
  224. this.$message.error("流程作废失败");
  225. });
  226. } else if (res.cancel) {
  227. console.log('用户点击取消');
  228. }
  229. }
  230. });
  231. }
  232. },
  233. getTableValue() {
  234. return new Promise((resolve, reject) => {
  235. this.$emit('getTableValue', async (data) => {
  236. resolve(await data);
  237. });
  238. });
  239. }
  240. }
  241. }
  242. </script>
  243. <style scoped>
  244. .btnList {
  245. display: flex;
  246. }
  247. .btnConcel {
  248. margin-top: 20rpx;
  249. }
  250. </style>