taskSubmit.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="">
  3. <u--form
  4. style="margin: 0 20px"
  5. labelPosition="left"
  6. :model="form"
  7. :rules="rules"
  8. ref="uForm"
  9. labelWidth="140rpx"
  10. >
  11. <u-form-item label="审批建议" prop="reason" required>
  12. <u--textarea
  13. style="width: 100%"
  14. height="120"
  15. border="surround"
  16. placeholder="请输入审批建议"
  17. v-model="form.reason"
  18. ></u--textarea>
  19. </u-form-item>
  20. </u--form>
  21. <view class="btnList">
  22. <u-button
  23. style="width: 45%; margin-bottom: 10rpx"
  24. :loading="loading"
  25. type="success"
  26. text="申请入库"
  27. @click="storeManagerApprove"
  28. >
  29. </u-button>
  30. <u-button
  31. style="width: 45%"
  32. :loading="loading"
  33. type="error"
  34. text="驳回"
  35. @click="handleReject"
  36. ></u-button>
  37. </view>
  38. <view class="btnConcel" v-if="taskDefinitionKey !== 'deptLeaderApprove'">
  39. <u-button @click="showAction = true">更多</u-button>
  40. </view>
  41. <u-action-sheet
  42. :actions="actionList"
  43. :closeOnClickOverlay="true"
  44. :closeOnClickAction="true"
  45. title="更多操作"
  46. :show="showAction"
  47. @close="showAction = false"
  48. @select="selectActionClick"
  49. ></u-action-sheet>
  50. </view>
  51. </template>
  52. <script>
  53. import {
  54. approveTaskWithVariablesOther,
  55. cancelTask,
  56. } from "@/api/wt/index.js";
  57. import { storage, notPass } from "@/api/warehouseManagement/index.js";
  58. export default {
  59. name: "taskSubmit",
  60. props: {
  61. businessId: {
  62. default: "",
  63. },
  64. taskId: {
  65. default: "",
  66. },
  67. id: {
  68. default: "",
  69. },
  70. taskDefinitionKey: {
  71. default: "",
  72. },
  73. },
  74. data() {
  75. return {
  76. showAction: false,
  77. loading: false,
  78. taskFormData: {},
  79. actionList: [
  80. {
  81. name: "作废",
  82. fontSize: "28",
  83. color: "#ffaa7f",
  84. },
  85. ],
  86. form: {
  87. reason: "同意",
  88. },
  89. rules: {
  90. reason: {
  91. type: "string",
  92. required: true,
  93. message: "请输入审批建议",
  94. trigger: "blur",
  95. },
  96. },
  97. };
  98. },
  99. mounted() {
  100. this.$refs.uForm.setRules(this.rules);
  101. },
  102. methods: {
  103. async storeManagerApprove() {
  104. try {
  105. await this.$refs.uForm.validate();
  106. } catch (e) {
  107. return;
  108. }
  109. let res = await this.getTableValue();
  110. let storageData = res.returnStorageData;
  111. if (!storageData || storageData === false) {
  112. return;
  113. }
  114. storageData.isSkip = 1;
  115. try {
  116. this.loading = true;
  117. let storageRes = await storage(storageData);
  118. await approveTaskWithVariablesOther({
  119. id: this.taskId,
  120. reason: this.form.reason,
  121. outInId: storageRes.data[0],
  122. businessId: this.businessId,
  123. variables: {
  124. pass: true,
  125. },
  126. });
  127. this.$emit("handleAudit", {
  128. status: 1,
  129. title: "入库",
  130. });
  131. } catch (error) {
  132. uni.showToast({ title: "保存失败", icon: "none" });
  133. } finally {
  134. this.loading = false;
  135. }
  136. },
  137. async handleReject() {
  138. try {
  139. this.loading = true;
  140. await notPass({
  141. id: this.taskId,
  142. reason: this.form.reason,
  143. businessId: this.businessId,
  144. variables: {
  145. pass: false,
  146. },
  147. });
  148. this.$emit("handleAudit", {
  149. status: 0,
  150. title: "驳回",
  151. });
  152. } catch (error) {
  153. console.error("驳回操作失败", error);
  154. uni.showToast({ title: "驳回失败", icon: "none" });
  155. } finally {
  156. this.loading = false;
  157. }
  158. },
  159. async syncTaskFormData() {
  160. try {
  161. const data = await this.getTableValue();
  162. this.taskFormData = data || {};
  163. } catch (e) {
  164. console.warn("获取 taskForm 数据失败", e);
  165. this.taskFormData = {};
  166. }
  167. return this.taskFormData;
  168. },
  169. selectActionClick(item) {
  170. if (item.name == "作废") {
  171. uni.showModal({
  172. title: "提示",
  173. content: "是否确认作废?",
  174. success: async (modalRes) => {
  175. if (modalRes.confirm) {
  176. if (!this.form.reason) {
  177. return uni.showToast({
  178. title: "审批建议不能为空",
  179. icon: "none",
  180. });
  181. }
  182. this.loading = true;
  183. await this.syncTaskFormData();
  184. cancelTask({
  185. taskId: this.taskId,
  186. id: this.id,
  187. reason: this.form.reason,
  188. businessId: this.businessId,
  189. variables: {
  190. taskFormData: this.taskFormData,
  191. },
  192. })
  193. .then(() => {
  194. this.loading = false;
  195. this.$emit("handleAudit", {
  196. title: "作废",
  197. });
  198. })
  199. .catch(() => {
  200. this.loading = false;
  201. uni.showToast({ title: "流程作废失败", icon: "none" });
  202. });
  203. }
  204. },
  205. });
  206. }
  207. },
  208. getTableValue() {
  209. return new Promise((resolve, reject) => {
  210. this.$emit("getTableValue", async (data) => {
  211. resolve(await data);
  212. });
  213. });
  214. },
  215. },
  216. };
  217. </script>
  218. <style scoped>
  219. .btnList {
  220. display: flex;
  221. }
  222. .btnConcel {
  223. margin-top: 20rpx;
  224. }
  225. </style>