add.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div class="form" style="padding-bottom: 60px">
  3. <van-nav-bar
  4. :title="$t('forward.name')"
  5. :left-text="$t('common.back')"
  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. @otherBtnClick="otherBtnClick"
  17. ref="formDom"
  18. >
  19. <!-- <template #file>
  20. <div>aa</div>
  21. </template> -->
  22. </testForm>
  23. </div>
  24. </template>
  25. <script setup>
  26. import { ref, reactive, getCurrentInstance, onMounted } from "vue";
  27. import { showSuccessToast, showFailToast } from "vant";
  28. import { useRoute } from "vue-router";
  29. import testForm from "@/components/testForm/index.vue";
  30. const proxy = getCurrentInstance().proxy;
  31. const route = useRoute();
  32. const formDom = ref(null);
  33. const formData = reactive({
  34. data: {
  35. list: [],
  36. },
  37. });
  38. const rules = {
  39. receivedUserId: [
  40. {
  41. required: true,
  42. message: proxy.t("forward.pleaseSelectThePersonInCharge"),
  43. },
  44. ],
  45. };
  46. const formOption = reactive({
  47. readonly: false, //用于控制整个表单是否只读
  48. disabled: false,
  49. labelAlign: "top",
  50. scroll: true,
  51. labelWidth: "62pk",
  52. submitBtnText: proxy.t("common.submit"),
  53. otherBtn: true,
  54. otherBtnText: "退回",
  55. btnConfig: {
  56. isNeed: false,
  57. prop: "list",
  58. plain: true,
  59. listTitle: "",
  60. listConfig: [],
  61. clickFn: () => {},
  62. },
  63. });
  64. const formConfig = ref([]);
  65. const getDict = () => {
  66. proxy.get("/system/user/list?pageNum=1&pageSize=9999").then((res) => {
  67. formConfig.value[6].data = res.rows.map((item) => {
  68. return {
  69. label: item.userName,
  70. value: item.userId,
  71. };
  72. });
  73. });
  74. };
  75. const onClickLeft = () => history.back();
  76. const onSubmit = () => {
  77. if (route.query.type === "10") {
  78. const data = {
  79. id: formData.data.id,
  80. receivedUserId: formData.data.receivedUserId,
  81. };
  82. proxy.post("/productionTaskDetail/circulation", data).then(
  83. (res) => {
  84. setTimeout(() => {
  85. showSuccessToast(proxy.t("common.operationSuccessful"));
  86. proxy.$router.push("/main/jxskForward");
  87. }, 500);
  88. },
  89. (err) => {
  90. return showFailToast(err.message);
  91. }
  92. );
  93. } else {
  94. proxy
  95. .post("/productionTaskDetail/productStorage", { id: formData.data.id })
  96. .then(
  97. (res) => {
  98. setTimeout(() => {
  99. showSuccessToast(proxy.t("common.operationSuccessful"));
  100. proxy.$router.push("/main/jxskForward");
  101. }, 500);
  102. },
  103. (err) => {
  104. return showFailToast(err.message);
  105. }
  106. );
  107. }
  108. };
  109. const otherBtnClick = () => {
  110. showConfirmDialog({
  111. title: "提示",
  112. message: "你确定退回当前任务吗?",
  113. })
  114. .then(() => {
  115. proxy
  116. .post("/productionTaskDetail/revokeTask", { id: formData.data.id })
  117. .then(
  118. (res) => {
  119. proxy.$router.push("/main/jxskReceive");
  120. },
  121. (err) => {
  122. return showFailToast(err.message);
  123. }
  124. );
  125. })
  126. .catch(() => {
  127. return;
  128. });
  129. };
  130. const getDetails = () => {
  131. proxy.post("/productionTask/detail", { id: route.query.id }).then(
  132. (res) => {
  133. console.log(res, "ada");
  134. },
  135. (err) => {
  136. return showFailToast(err.message);
  137. }
  138. );
  139. };
  140. const configData = [
  141. [
  142. {
  143. type: "input",
  144. itemType: "text",
  145. label: proxy.t("forward.productName"),
  146. prop: "productName",
  147. readonly: true,
  148. },
  149. {
  150. type: "input",
  151. itemType: "text",
  152. label: proxy.t("forward.productSN"),
  153. prop: "productSn",
  154. readonly: true,
  155. },
  156. {
  157. type: "input",
  158. itemType: "text",
  159. label: proxy.t("forward.currentProcess"),
  160. prop: "productionProcessesName",
  161. readonly: true,
  162. },
  163. {
  164. type: "slot",
  165. label: proxy.t("forward.processDrawing"),
  166. slotName: "file",
  167. },
  168. {
  169. type: "title",
  170. title: proxy.t("forward.name"),
  171. },
  172. {
  173. type: "input",
  174. itemType: "text",
  175. label: proxy.t("forward.targetProcess"),
  176. prop: "nextProductionProcessesName",
  177. readonly: true,
  178. },
  179. // {
  180. // type: "picker",
  181. // label: proxy.t('forward.personInCharge'),
  182. // prop: "receivedUserId",
  183. // itemType: "onePicker",
  184. // showPicker: false,
  185. // fieldNames: {
  186. // text: "label",
  187. // value: "value",
  188. // },
  189. // data: [],
  190. // },
  191. ],
  192. [
  193. {
  194. type: "input",
  195. itemType: "text",
  196. label: proxy.t("forward.productName"),
  197. prop: "productName",
  198. readonly: true,
  199. },
  200. {
  201. type: "input",
  202. itemType: "text",
  203. label: proxy.t("forward.productSN"),
  204. prop: "productSn",
  205. readonly: true,
  206. },
  207. {
  208. type: "input",
  209. itemType: "text",
  210. label: proxy.t("forward.currentProcess"),
  211. prop: "productionProcessesName",
  212. readonly: true,
  213. },
  214. {
  215. type: "slot",
  216. label: proxy.t("forward.processDrawing"),
  217. slotName: "file",
  218. },
  219. ],
  220. ];
  221. onMounted(() => {
  222. if (route.query.type === "10") {
  223. formConfig.value = configData[0];
  224. formOption.submitBtnText = proxy.t("common.submit");
  225. // getDict();
  226. } else {
  227. formConfig.value = configData[1];
  228. formOption.submitBtnText = proxy.t("forward.submitStorage");
  229. }
  230. formData.data = { ...route.query };
  231. });
  232. </script>
  233. <style lang="scss" scoped>
  234. .row {
  235. display: flex;
  236. padding: 5px 10px 0 10px;
  237. justify-content: space-between;
  238. align-items: center;
  239. .title {
  240. flex: 1;
  241. }
  242. .delete {
  243. width: 20px;
  244. cursor: pointer;
  245. text-align: center;
  246. }
  247. }
  248. </style>