add.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="form" style="padding-bottom: 60px">
  3. <van-nav-bar
  4. title="任务流转"
  5. left-text="返回"
  6. left-arrow
  7. @click-left="onClickLeft"
  8. >
  9. </van-nav-bar>
  10. <testForm
  11. v-model="formData.data"
  12. :formOption="formOption"
  13. :formConfig="formConfig"
  14. :rules="rules"
  15. @onSubmit="onSubmit"
  16. ref="formDom"
  17. >
  18. <template #file>
  19. <div>aa</div>
  20. </template>
  21. </testForm>
  22. </div>
  23. </template>
  24. <script setup>
  25. import { ref, reactive, getCurrentInstance, onMounted } from "vue";
  26. import { showSuccessToast, showFailToast } from "vant";
  27. import { useRoute } from "vue-router";
  28. import testForm from "@/components/testForm/index.vue";
  29. const proxy = getCurrentInstance().proxy;
  30. const route = useRoute();
  31. const formDom = ref(null);
  32. const formData = reactive({
  33. data: {
  34. list: [],
  35. },
  36. });
  37. const rules = {
  38. receivedUserId: [{ required: true, message: "请选择负责人" }],
  39. };
  40. const formOption = reactive({
  41. readonly: false, //用于控制整个表单是否只读
  42. disabled: false,
  43. labelAlign: "top",
  44. scroll: true,
  45. labelWidth: "62pk",
  46. submitBtnText: "提交",
  47. btnConfig: {
  48. isNeed: false,
  49. prop: "list",
  50. plain: true,
  51. listTitle: "",
  52. listConfig: [],
  53. clickFn: () => {},
  54. },
  55. });
  56. const formConfig = ref([]);
  57. const getDict = () => {
  58. proxy.get("/system/user/list?pageNum=1&pageSize=9999").then((res) => {
  59. formConfig.value[6].data = res.rows.map((item) => {
  60. return {
  61. label: item.userName,
  62. value: item.userId,
  63. };
  64. });
  65. });
  66. };
  67. const onClickLeft = () => history.back();
  68. const onSubmit = () => {
  69. if (route.query.type === "10") {
  70. const data = {
  71. id: formData.data.id,
  72. receivedUserId: formData.data.receivedUserId,
  73. };
  74. proxy.post("/productionTaskDetail/circulation", data).then(
  75. (res) => {
  76. setTimeout(() => {
  77. showSuccessToast("操作成功");
  78. proxy.$router.push("/main/jxskForward");
  79. }, 500);
  80. },
  81. (err) => {
  82. return showFailToast(err.message);
  83. }
  84. );
  85. } else {
  86. proxy
  87. .post("/productionTaskDetail/productStorage", { id: formData.data.id })
  88. .then(
  89. (res) => {
  90. setTimeout(() => {
  91. showSuccessToast("操作成功");
  92. proxy.$router.push("/main/jxskForward");
  93. }, 500);
  94. },
  95. (err) => {
  96. return showFailToast(err.message);
  97. }
  98. );
  99. }
  100. };
  101. const getDetails = () => {
  102. proxy.post("/productionTask/detail", { id: route.query.id }).then(
  103. (res) => {
  104. console.log(res, "ada");
  105. },
  106. (err) => {
  107. return showFailToast(err.message);
  108. }
  109. );
  110. };
  111. const configData = [
  112. [
  113. {
  114. type: "input",
  115. itemType: "text",
  116. label: "产品名称",
  117. prop: "productName",
  118. readonly: true,
  119. },
  120. {
  121. type: "input",
  122. itemType: "text",
  123. label: "产品SN",
  124. prop: "productSn",
  125. readonly: true,
  126. },
  127. {
  128. type: "input",
  129. itemType: "text",
  130. label: "当前工序",
  131. prop: "productionProcessesName",
  132. readonly: true,
  133. },
  134. {
  135. type: "slot",
  136. label: "工序图纸",
  137. slotName: "file",
  138. },
  139. {
  140. type: "title",
  141. title: "任务流转",
  142. },
  143. {
  144. type: "input",
  145. itemType: "text",
  146. label: "目标工序",
  147. prop: "nextProductionProcessesName",
  148. readonly: true,
  149. },
  150. {
  151. type: "picker",
  152. label: "负责人",
  153. prop: "receivedUserId",
  154. itemType: "onePicker",
  155. showPicker: false,
  156. fieldNames: {
  157. text: "label",
  158. value: "value",
  159. },
  160. data: [],
  161. },
  162. ],
  163. [
  164. {
  165. type: "input",
  166. itemType: "text",
  167. label: "产品名称",
  168. prop: "productName",
  169. readonly: true,
  170. },
  171. {
  172. type: "input",
  173. itemType: "text",
  174. label: "产品SN",
  175. prop: "productSn",
  176. readonly: true,
  177. },
  178. {
  179. type: "input",
  180. itemType: "text",
  181. label: "当前工序",
  182. prop: "productionProcessesName",
  183. readonly: true,
  184. },
  185. {
  186. type: "slot",
  187. label: "工序图纸",
  188. slotName: "file",
  189. },
  190. ],
  191. ];
  192. onMounted(() => {
  193. if (route.query.type === "10") {
  194. formConfig.value = configData[0];
  195. formOption.submitBtnText = "提交";
  196. getDict();
  197. } else {
  198. formConfig.value = configData[1];
  199. formOption.submitBtnText = "提交入库";
  200. }
  201. formData.data = { ...route.query };
  202. });
  203. </script>
  204. <style lang="scss" scoped>
  205. .row {
  206. display: flex;
  207. padding: 5px 10px 0 10px;
  208. justify-content: space-between;
  209. align-items: center;
  210. .title {
  211. flex: 1;
  212. }
  213. .delete {
  214. width: 20px;
  215. cursor: pointer;
  216. text-align: center;
  217. }
  218. }
  219. </style>