add.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="form" style="padding-bottom: 60px">
  3. <van-nav-bar
  4. :title="$t('receive.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. </testForm>
  20. </div>
  21. </template>
  22. <script setup>
  23. import { ref, reactive, getCurrentInstance, onMounted } from "vue";
  24. import { showSuccessToast, showFailToast } from "vant";
  25. import { useRoute } from "vue-router";
  26. import testForm from "@/components/testForm/index.vue";
  27. const proxy = getCurrentInstance().proxy;
  28. const route = useRoute();
  29. const formDom = ref(null);
  30. const formData = reactive({
  31. data: {
  32. list: [],
  33. },
  34. });
  35. const rules = {
  36. warehouseName: [{ required: true, message: proxy.t('receive.warehouseNameCanNotBeEmpty') }],
  37. productName: [{ required: true, message: proxy.t('receive.itemNameCanNotBeEmpty') }],
  38. quantity: [{ required: true, message: proxy.t('receive.warehousingQuantityCanNotBeEmpty') }],
  39. };
  40. const formOption = reactive({
  41. readonly: false, //用于控制整个表单是否只读
  42. disabled: false,
  43. labelAlign: "top",
  44. scroll: true,
  45. labelWidth: "62pk",
  46. submitBtnText: proxy.t('receive.confirmReceipt'),
  47. otherBtn: true,
  48. otherBtnText: proxy.t('receive.return'),
  49. btnConfig: {
  50. isNeed: false,
  51. prop: "list",
  52. plain: true,
  53. listTitle: "",
  54. listConfig: [],
  55. clickFn: () => {},
  56. },
  57. });
  58. const formConfig = reactive([
  59. {
  60. type: "input",
  61. itemType: "text",
  62. label: proxy.t('receive.productName'),
  63. prop: "productName",
  64. readonly: true,
  65. },
  66. {
  67. type: "input",
  68. itemType: "text",
  69. label: proxy.t('receive.productSN'),
  70. prop: "productSn",
  71. readonly: true,
  72. },
  73. {
  74. type: "input",
  75. itemType: "text",
  76. label: proxy.t('receive.previousProcess'),
  77. prop: "productionProcessesName",
  78. readonly: true,
  79. },
  80. {
  81. type: "input",
  82. itemType: "text",
  83. label: proxy.t('receive.circulationInto'),
  84. prop: "circulationUserName",
  85. readonly: true,
  86. },
  87. ]);
  88. const onClickLeft = () => history.back();
  89. const onSubmit = () => {
  90. proxy.post("/productionTaskDetail/receive", { id: formData.data.id }).then(
  91. (res) => {
  92. setTimeout(() => {
  93. showSuccessToast(proxy.t('common.operationSuccessful'));
  94. proxy.$router.push("/main/jxskReceive");
  95. }, 500);
  96. },
  97. (err) => {
  98. return showFailToast(err.message);
  99. }
  100. );
  101. };
  102. const otherBtnClick = () => {
  103. proxy.post("/productionTaskDetail/rejection", { id: formData.data.id }).then(
  104. (res) => {
  105. setTimeout(() => {
  106. showSuccessToast(proxy.t('common.operationSuccessful'));
  107. proxy.$router.push("/main/jxskReceive");
  108. }, 500);
  109. },
  110. (err) => {
  111. return showFailToast(err.message);
  112. }
  113. );
  114. };
  115. const getDetails = () => {
  116. proxy.post("/productionTask/detail", { id: route.query.id }).then(
  117. (res) => {
  118. console.log(res, "ada");
  119. },
  120. (err) => {
  121. return showFailToast(err.message);
  122. }
  123. );
  124. };
  125. onMounted(() => {
  126. if (route.query.id) {
  127. formData.data = { ...route.query };
  128. }
  129. });
  130. </script>
  131. <style lang="scss" scoped>
  132. .row {
  133. display: flex;
  134. padding: 5px 10px 0 10px;
  135. justify-content: space-between;
  136. align-items: center;
  137. .title {
  138. flex: 1;
  139. }
  140. .delete {
  141. width: 20px;
  142. cursor: pointer;
  143. text-align: center;
  144. }
  145. }
  146. </style>