index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. const getDemandData = () => {
  110. proxy.post("/productionOrder/page", { pageNum: 1, pageSize: 9999, status: "30" }).then((res) => {
  111. if (res.rows && res.rows.length > 0) {
  112. productionOrder.value = productionOrder.value.concat(
  113. res.rows.map((item) => {
  114. if (item.wlnCode) {
  115. return {
  116. value: item.orderId,
  117. label: item.code + " (" + item.wlnCode + ")",
  118. };
  119. } else {
  120. return {
  121. value: item.orderId,
  122. label: item.code,
  123. };
  124. }
  125. })
  126. );
  127. }
  128. });
  129. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  130. if (res.rows && res.rows.length > 0) {
  131. warehouseList.value = res.rows
  132. .filter((item) => ["1", "5"].includes(item.type))
  133. .map((item) => {
  134. return {
  135. dictKey: item.id,
  136. dictValue: item.name,
  137. };
  138. });
  139. }
  140. });
  141. };
  142. getDemandData();
  143. const submit = ref(null);
  144. const formOption = reactive({
  145. inline: true,
  146. labelWidth: "120px",
  147. itemWidth: 100,
  148. rules: [],
  149. labelPosition: "right",
  150. });
  151. const formData = reactive({
  152. data: {
  153. orderId: "",
  154. type: 3,
  155. productionExceedReceiveSkuList: [],
  156. productionExceedReceiveBomList: [],
  157. },
  158. });
  159. const formConfig = computed(() => {
  160. return [
  161. {
  162. type: "slot",
  163. label: "订单号",
  164. slotName: "orderId",
  165. prop: "orderId",
  166. itemWidth: 51,
  167. },
  168. {
  169. type: "select",
  170. label: "超领原因",
  171. prop: "type",
  172. data: typeList.value,
  173. itemWidth: 51,
  174. disabled: true,
  175. },
  176. {
  177. type: "input",
  178. label: "责任人",
  179. prop: "responsible",
  180. itemWidth: 51,
  181. },
  182. {
  183. type: "slot",
  184. slotName: "productionExceedReceiveSkuList",
  185. label: "订单商品",
  186. },
  187. {
  188. type: "slot",
  189. slotName: "productionExceedReceiveBomList",
  190. label: "BOM明细",
  191. },
  192. ];
  193. });
  194. const rules = ref({
  195. orderId: [{ required: true, message: "请选择订单号", trigger: "change" }],
  196. type: [{ required: true, message: "请选择超领原因", trigger: "change" }],
  197. responsible: [{ required: true, message: "请输入责任人", trigger: "blur" }],
  198. });
  199. const submitForm = () => {
  200. submit.value.handleSubmit(() => {
  201. if (formData.data.productionExceedReceiveSkuList && formData.data.productionExceedReceiveSkuList.length > 0) {
  202. let list = formData.data.productionExceedReceiveSkuList.filter((item) => item.quantity > 0);
  203. if (list && list.length > 0) {
  204. for (let i = 0; i < list.length; i++) {
  205. if (!list[i].exceptionSkuSpecId) {
  206. return ElMessage("请选择生产错误SKU");
  207. }
  208. if (!list[i].warehouseId) {
  209. return ElMessage("请选择仓库");
  210. }
  211. }
  212. proxy.post("/productionExceedReceive/errorExceedReceive", formData.data).then(() => {
  213. ElMessage({ message: "操作完成", type: "success" });
  214. clickCancel();
  215. });
  216. } else {
  217. return ElMessage("请输入超领数量");
  218. }
  219. } else {
  220. return ElMessage("请添加订单商品");
  221. }
  222. });
  223. };
  224. const clickCancel = () => {
  225. formData.data = {
  226. type: 3,
  227. productionExceedReceiveSkuList: [],
  228. productionExceedReceiveBomList: [],
  229. };
  230. submit.value.resetFields();
  231. };
  232. const changeOrder = () => {
  233. if (formData.data.orderId) {
  234. proxy.post("/productionExceedReceive/getOrderSkuList", { id: formData.data.orderId }).then((res) => {
  235. if (res && res.length > 0) {
  236. formData.data.productionExceedReceiveSkuList = res.map((item) => {
  237. return {
  238. name: item.name,
  239. code: item.code,
  240. orderQuantity: item.quantity,
  241. orderSkuId: item.id,
  242. skuSpecId: item.skuSpecId,
  243. exceptionSkuSpecId: "",
  244. exceptionSkuSpecCode: "",
  245. quantity: 0,
  246. warehouseId: "",
  247. };
  248. });
  249. } else {
  250. formData.data.productionExceedReceiveSkuList = [];
  251. }
  252. });
  253. } else {
  254. formData.data.productionExceedReceiveSkuList = [];
  255. }
  256. formData.data.productionExceedReceiveBomList = [];
  257. };
  258. const rowIndex = ref(null);
  259. const openSKU = ref(false);
  260. const handleOpen = (index) => {
  261. rowIndex.value = index;
  262. openSKU.value = true;
  263. };
  264. const clickRemove = (index) => {
  265. formData.data.productionExceedReceiveSkuList[index].exceptionSkuSpecId = "";
  266. formData.data.productionExceedReceiveSkuList[index].exceptionSkuSpecCode = "";
  267. queryBOM();
  268. };
  269. const selectProduct = (item) => {
  270. if (item.id) {
  271. formData.data.productionExceedReceiveSkuList[rowIndex.value].exceptionSkuSpecId = item.id;
  272. formData.data.productionExceedReceiveSkuList[rowIndex.value].exceptionSkuSpecCode = item.code;
  273. ElMessage({ message: "选择完成", type: "success" });
  274. openSKU.value = false;
  275. queryBOM();
  276. }
  277. };
  278. const queryBOM = () => {
  279. let list = formData.data.productionExceedReceiveSkuList.filter((item) => item.quantity > 0 && item.exceptionSkuSpecId);
  280. if (list && list.length > 0) {
  281. proxy
  282. .post("/productionExceedReceive/getSkuSpecMaterialList", {
  283. skuSpecList: list.map((item) => {
  284. return {
  285. skuSpecId: item.exceptionSkuSpecId,
  286. quantity: item.quantity,
  287. };
  288. }),
  289. })
  290. .then(
  291. (res) => {
  292. formData.data.productionExceedReceiveBomList = res;
  293. },
  294. (err) => {
  295. console.log(err);
  296. formData.data.productionExceedReceiveBomList = [];
  297. }
  298. );
  299. } else {
  300. formData.data.productionExceedReceiveBomList = [];
  301. }
  302. };
  303. </script>
  304. <style lang="scss" scoped>
  305. ::v-deep(.el-input-number .el-input__inner) {
  306. text-align: left;
  307. }
  308. :deep(.el-dialog) {
  309. margin-top: 10px !important;
  310. margin-bottom: 10px !important;
  311. }
  312. </style>