index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <el-card class="box-card">
  3. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  4. <template #orderId>
  5. <div style="width: 100%">
  6. <el-select-v2 v-model="formData.data.orderId" :options="productionOrder" placeholder="请选择订单号" @change="changeOrder()" style="width: 100%" filterable />
  7. </div>
  8. </template>
  9. <template #productionExceedReceiveSkuList>
  10. <div style="width: 100%">
  11. <el-table :data="formData.data.productionExceedReceiveSkuList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  12. <el-table-column label="SKU品号" prop="code" width="160" />
  13. <el-table-column label="SKU品名" prop="name" min-width="220" />
  14. <el-table-column label="BOM品号" prop="bomCode" width="160" />
  15. <el-table-column label="订单数量" prop="orderQuantity" width="120" />
  16. <el-table-column label="超领数量" width="160">
  17. <template #default="{ row, $index }">
  18. <el-form-item :prop="'productionExceedReceiveSkuList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true" style="width: 100%">
  19. <el-input-number
  20. onmousewheel="return false;"
  21. v-model="row.quantity"
  22. placeholder="超领数量"
  23. style="width: 100%"
  24. :controls="false"
  25. :min="0"
  26. :precision="0"
  27. :max="row.orderQuantity" />
  28. </el-form-item>
  29. </template>
  30. </el-table-column>
  31. </el-table>
  32. </div>
  33. </template>
  34. </byForm>
  35. <div style="text-align: center; margin: 10px">
  36. <el-button @click="clickCancel()" size="large">重 置</el-button>
  37. <el-button type="primary" @click="submitForm()" size="large" v-preReClick>提 交</el-button>
  38. </div>
  39. </el-card>
  40. </template>
  41. <script setup>
  42. import byForm from "/src/components/byForm/index";
  43. import { ElMessage } from "element-plus";
  44. const { proxy } = getCurrentInstance();
  45. const productionOrder = ref([]);
  46. const typeList = ref([
  47. {
  48. dictKey: 1,
  49. dictValue: "制作损坏",
  50. },
  51. {
  52. dictKey: 2,
  53. dictValue: "裸垫质量不良",
  54. },
  55. ]);
  56. const getDemandData = () => {
  57. proxy.post("/productionOrder/page", { pageNum: 1, pageSize: 9999, status: "30" }).then((res) => {
  58. if (res.rows && res.rows.length > 0) {
  59. productionOrder.value = productionOrder.value.concat(
  60. res.rows.map((item) => {
  61. if (item.wlnCode) {
  62. return {
  63. value: item.orderId,
  64. label: item.code + " (" + item.wlnCode + ")",
  65. };
  66. } else {
  67. return {
  68. value: item.orderId,
  69. label: item.code,
  70. };
  71. }
  72. })
  73. );
  74. }
  75. });
  76. };
  77. getDemandData();
  78. const submit = ref(null);
  79. const formOption = reactive({
  80. inline: true,
  81. labelWidth: "120px",
  82. itemWidth: 100,
  83. rules: [],
  84. labelPosition: "right",
  85. });
  86. const formData = reactive({
  87. data: {
  88. orderId: "",
  89. type: "",
  90. productionExceedReceiveSkuList: [],
  91. },
  92. });
  93. const formConfig = computed(() => {
  94. return [
  95. {
  96. type: "slot",
  97. label: "订单号",
  98. slotName: "orderId",
  99. prop: "orderId",
  100. itemWidth: 51,
  101. },
  102. {
  103. type: "select",
  104. label: "超领原因",
  105. prop: "type",
  106. data: typeList.value,
  107. itemWidth: 51,
  108. },
  109. {
  110. type: "input",
  111. label: "责任人",
  112. prop: "responsible",
  113. itemWidth: 51,
  114. },
  115. {
  116. type: "slot",
  117. slotName: "productionExceedReceiveSkuList",
  118. label: "订单商品",
  119. },
  120. ];
  121. });
  122. const rules = ref({
  123. orderId: [{ required: true, message: "请选择订单号", trigger: "change" }],
  124. type: [{ required: true, message: "请选择超领原因", trigger: "change" }],
  125. quantity: [{ required: true, message: "请输入超领数量", trigger: "blur" }],
  126. responsible: [{ required: true, message: "请输入责任人", trigger: "blur" }],
  127. });
  128. const submitForm = () => {
  129. submit.value.handleSubmit(() => {
  130. if (formData.data.productionExceedReceiveSkuList && formData.data.productionExceedReceiveSkuList.length > 0) {
  131. proxy.post("/productionExceedReceive/exceedReceive", formData.data).then(() => {
  132. ElMessage({ message: "操作完成", type: "success" });
  133. clickCancel();
  134. });
  135. } else {
  136. return ElMessage("请添加订单商品");
  137. }
  138. });
  139. };
  140. const clickCancel = () => {
  141. formData.data = {
  142. productionExceedReceiveSkuList: [],
  143. };
  144. submit.value.resetFields();
  145. };
  146. const changeOrder = () => {
  147. if (formData.data.orderId) {
  148. proxy.post("/productionExceedReceive/getOrderSkuList", { id: formData.data.orderId }).then((res) => {
  149. if (res && res.length > 0) {
  150. formData.data.productionExceedReceiveSkuList = res.map((item) => {
  151. return {
  152. bomSpecId: item.bomSpecId,
  153. name: item.name,
  154. code: item.code,
  155. bomCode: item.bomCode,
  156. quantity: undefined,
  157. orderQuantity: item.quantity,
  158. id: item.id,
  159. };
  160. });
  161. } else {
  162. formData.data.productionExceedReceiveSkuList = [];
  163. }
  164. });
  165. } else {
  166. formData.data.productionExceedReceiveSkuList = [];
  167. }
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. ::v-deep(.el-input-number .el-input__inner) {
  172. text-align: left;
  173. }
  174. </style>