index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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
  7. v-model="formData.data.orderId"
  8. :options="productionOrder"
  9. placeholder="请选择订单号"
  10. @change="changeOrder()"
  11. style="width: 100%"
  12. filterable />
  13. </div>
  14. </template>
  15. <template #productionExceedReceiveSkuList>
  16. <div style="width: 100%">
  17. <el-table :data="formData.data.productionExceedReceiveSkuList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  18. <el-table-column label="SKU品号" prop="code" width="160" />
  19. <el-table-column label="SKU品名" prop="name" min-width="220" />
  20. <el-table-column label="丢件SKU" width="200">
  21. <template #default="{ row, $index }">
  22. <el-button
  23. v-if="!row.exceptionSkuSpecId"
  24. type="primary"
  25. size="small"
  26. @click="handleOpen($index)"
  27. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  28. 选择SKU
  29. </el-button>
  30. <div style="width: 100%; display: flex; align-items: center" v-else>
  31. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove($index)"><Remove /></el-icon>
  32. <span>{{ row.exceptionSkuSpecCode }}</span>
  33. </div>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="仓库" width="160">
  37. <template #default="{ row, $index }">
  38. <el-form-item :prop="'productionExceedReceiveSkuList.' + $index + '.warehouseId'" style="width: 100%">
  39. <el-select v-model="row.warehouseId" placeholder="请选择仓库" clearable style="width: 100%">
  40. <el-option v-for="item in warehouseList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  41. </el-select>
  42. </el-form-item>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="订单数量" prop="orderQuantity" width="120" />
  46. <el-table-column label="超领数量" width="160">
  47. <template #default="{ row, $index }">
  48. <el-form-item :prop="'productionExceedReceiveSkuList.' + $index + '.quantity'" :inline-message="true" style="width: 100%" @change="queryBOM">
  49. <el-input-number
  50. onmousewheel="return false;"
  51. v-model="row.quantity"
  52. placeholder="超领数量"
  53. style="width: 100%"
  54. :controls="false"
  55. :min="0"
  56. :precision="0"
  57. :max="row.orderQuantity" />
  58. </el-form-item>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. </div>
  63. </template>
  64. <template #productionExceedReceiveBomList>
  65. <div style="width: 100%">
  66. <el-table :data="formData.data.productionExceedReceiveBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
  67. <el-table-column label="BOM品号" prop="bomSpecCode" width="160" />
  68. <el-table-column label="BOM品名" prop="bomSpecName" min-width="220" />
  69. <el-table-column label="仓库" prop="warehouseName" width="160" />
  70. <el-table-column label="库存数量" prop="inventoryQuantity" width="120" />
  71. <el-table-column label="出库数量" prop="outQuantity" width="120" />
  72. </el-table>
  73. </div>
  74. </template>
  75. </byForm>
  76. <div style="text-align: center; margin: 10px">
  77. <el-button @click="clickCancel()" size="large">重 置</el-button>
  78. <el-button type="primary" @click="submitForm()" size="large" v-preReClick>提 交</el-button>
  79. </div>
  80. <el-dialog title="选择SKU" v-if="openSKU" v-model="openSKU" width="84%">
  81. <SelectProduct :selectStatus="true" :type="'null'" @selectProduct="selectProduct"></SelectProduct>
  82. <template #footer>
  83. <el-button @click="openSKU = false" size="large">关 闭</el-button>
  84. </template>
  85. </el-dialog>
  86. </el-card>
  87. </template>
  88. <script setup>
  89. import byForm from "/src/components/byForm/index";
  90. import { ElMessage } from "element-plus";
  91. import SelectProduct from "/src/views/group/product/management/index";
  92. const { proxy } = getCurrentInstance();
  93. const productionOrder = ref([]);
  94. const warehouseList = ref([]);
  95. const typeList = ref([
  96. {
  97. dictKey: 1,
  98. dictValue: "制作损坏",
  99. },
  100. {
  101. dictKey: 2,
  102. dictValue: "裸垫质量不良",
  103. },
  104. {
  105. dictKey: 3,
  106. dictValue: "生产错误",
  107. },
  108. {
  109. dictKey: 4,
  110. dictValue: "丢件",
  111. },
  112. ]);
  113. const getDemandData = () => {
  114. proxy.post("/productionOrder/page", { pageNum: 1, pageSize: 9999, status: "30" }).then((res) => {
  115. if (res.rows && res.rows.length > 0) {
  116. productionOrder.value = productionOrder.value.concat(
  117. res.rows.map((item) => {
  118. if (item.wlnCode) {
  119. return {
  120. value: item.orderId,
  121. label: item.code + " (" + item.wlnCode + ")",
  122. };
  123. } else {
  124. return {
  125. value: item.orderId,
  126. label: item.code,
  127. };
  128. }
  129. })
  130. );
  131. }
  132. });
  133. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  134. if (res.rows && res.rows.length > 0) {
  135. warehouseList.value = res.rows
  136. .filter((item) => ["1", "5"].includes(item.type))
  137. .map((item) => {
  138. return {
  139. dictKey: item.id,
  140. dictValue: item.name,
  141. };
  142. });
  143. }
  144. });
  145. };
  146. getDemandData();
  147. const submit = ref(null);
  148. const formOption = reactive({
  149. inline: true,
  150. labelWidth: "120px",
  151. itemWidth: 100,
  152. rules: [],
  153. labelPosition: "right",
  154. });
  155. const formData = reactive({
  156. data: {
  157. orderId: "",
  158. type: 4,
  159. productionExceedReceiveSkuList: [],
  160. productionExceedReceiveBomList: [],
  161. },
  162. });
  163. const formConfig = computed(() => {
  164. return [
  165. {
  166. type: "slot",
  167. label: "订单号",
  168. slotName: "orderId",
  169. prop: "orderId",
  170. itemWidth: 51,
  171. },
  172. {
  173. type: "select",
  174. label: "超领原因",
  175. prop: "type",
  176. data: typeList.value,
  177. itemWidth: 51,
  178. disabled: true,
  179. },
  180. {
  181. type: "input",
  182. label: "责任人",
  183. prop: "responsible",
  184. itemWidth: 51,
  185. },
  186. {
  187. type: "slot",
  188. slotName: "productionExceedReceiveSkuList",
  189. label: "订单商品",
  190. },
  191. {
  192. type: "slot",
  193. slotName: "productionExceedReceiveBomList",
  194. label: "BOM明细",
  195. },
  196. ];
  197. });
  198. const rules = ref({
  199. orderId: [{ required: true, message: "请选择订单号", trigger: "change" }],
  200. type: [{ required: true, message: "请选择超领原因", trigger: "change" }],
  201. responsible: [{ required: true, message: "请输入责任人", trigger: "blur" }],
  202. });
  203. const submitForm = () => {
  204. submit.value.handleSubmit(() => {
  205. if (formData.data.productionExceedReceiveSkuList && formData.data.productionExceedReceiveSkuList.length > 0) {
  206. let list = formData.data.productionExceedReceiveSkuList.filter((item) => item.quantity > 0);
  207. if (list && list.length > 0) {
  208. proxy.post("/productionExceedReceive/replenishExceedReceive", formData.data).then(() => {
  209. ElMessage({ message: "操作完成", type: "success" });
  210. clickCancel();
  211. });
  212. } else {
  213. return ElMessage("请输入超领数量");
  214. }
  215. } else {
  216. return ElMessage("请添加订单商品");
  217. }
  218. });
  219. };
  220. const clickCancel = () => {
  221. formData.data = {
  222. type: 4,
  223. productionExceedReceiveSkuList: [],
  224. productionExceedReceiveBomList: [],
  225. };
  226. submit.value.resetFields();
  227. };
  228. const changeOrder = () => {
  229. if (formData.data.orderId) {
  230. proxy.post("/productionExceedReceive/getOrderSkuList", { id: formData.data.orderId }).then((res) => {
  231. if (res && res.length > 0) {
  232. formData.data.productionExceedReceiveSkuList = res.map((item) => {
  233. return {
  234. name: item.name,
  235. code: item.code,
  236. orderQuantity: item.quantity,
  237. orderSkuId: item.id,
  238. skuSpecId: item.skuSpecId,
  239. exceptionSkuSpecId: "",
  240. exceptionSkuSpecCode: "",
  241. quantity: 0,
  242. warehouseId: "",
  243. };
  244. });
  245. } else {
  246. formData.data.productionExceedReceiveSkuList = [];
  247. }
  248. });
  249. } else {
  250. formData.data.productionExceedReceiveSkuList = [];
  251. }
  252. formData.data.productionExceedReceiveBomList = [];
  253. };
  254. const rowIndex = ref(null);
  255. const openSKU = ref(false);
  256. const handleOpen = (index) => {
  257. rowIndex.value = index;
  258. openSKU.value = true;
  259. };
  260. const clickRemove = (index) => {
  261. formData.data.productionExceedReceiveSkuList[index].exceptionSkuSpecId = "";
  262. formData.data.productionExceedReceiveSkuList[index].exceptionSkuSpecCode = "";
  263. queryBOM();
  264. };
  265. const selectProduct = (item) => {
  266. if (item.id) {
  267. formData.data.productionExceedReceiveSkuList[rowIndex.value].exceptionSkuSpecId = item.id;
  268. formData.data.productionExceedReceiveSkuList[rowIndex.value].exceptionSkuSpecCode = item.code;
  269. ElMessage({ message: "选择完成", type: "success" });
  270. openSKU.value = false;
  271. queryBOM();
  272. }
  273. };
  274. const queryBOM = () => {
  275. let list = formData.data.productionExceedReceiveSkuList.filter((item) => item.quantity > 0 && item.exceptionSkuSpecId);
  276. if (list && list.length > 0) {
  277. proxy
  278. .post("/productionExceedReceive/getSkuSpecMaterialList", {
  279. skuSpecList: list.map((item) => {
  280. return {
  281. skuSpecId: item.exceptionSkuSpecId,
  282. quantity: item.quantity,
  283. };
  284. }),
  285. })
  286. .then(
  287. (res) => {
  288. formData.data.productionExceedReceiveBomList = res;
  289. },
  290. (err) => {
  291. console.log(err);
  292. formData.data.productionExceedReceiveBomList = [];
  293. }
  294. );
  295. } else {
  296. formData.data.productionExceedReceiveBomList = [];
  297. }
  298. };
  299. </script>
  300. <style lang="scss" scoped>
  301. ::v-deep(.el-input-number .el-input__inner) {
  302. text-align: left;
  303. }
  304. :deep(.el-dialog) {
  305. margin-top: 10px !important;
  306. margin-bottom: 10px !important;
  307. }
  308. </style>