index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div class="pageIndexClass">
  3. <div class="content">
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
  5. highlight-current-row :action-list="[
  6. {
  7. text: '手动出库',
  8. action: () => openModal(),
  9. },
  10. ]" @get-list="getList">
  11. </byTable>
  12. </div>
  13. <el-dialog title="手动出库" v-if="dialogVisible" v-model="dialogVisible" width="1000" v-loading="loadingDialog">
  14. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  15. <template #details>
  16. <div style="width: 100%">
  17. <el-button type="primary" @click="clickAdd()">添加明细</el-button>
  18. <el-table :data="formData.data.list" style="width: 100%; margin-top: 16px">
  19. <el-table-column prop="productCode" label="产品编码" width="140" />
  20. <el-table-column prop="productName" label="产品名称" min-width="160" />
  21. <el-table-column label="尺寸 (cm)" min-width="100">
  22. <template #default="{ row, $index }">
  23. <div style="width: 100%">
  24. {{row.productLength}} * {{row.productWidth}} * {{row.productHeight}}
  25. </div>
  26. </template>
  27. </el-table-column>
  28. <!-- <el-table-column prop="productUnit" label="单位" width="100" :formatter="
  29. (row) => dictValueLabel(row.productUnit, productUnit)
  30. " /> -->
  31. <el-table-column prop="stockQuantity" label="库存数量" width="100" />
  32. <el-table-column label="出库数量" width="140">
  33. <template #default="{ row, $index }">
  34. <div style="width: 100%">
  35. <el-form-item :prop="'list.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true" class="margin-b-0">
  36. <el-input-number v-model="row.quantity" placeholder="请输入出库数量" style="width: 100%" :precision="0" :controls="false" :min="1"
  37. onmousewheel="return false;" />
  38. </el-form-item>
  39. </div>
  40. </template>
  41. </el-table-column>
  42. <el-table-column align="center" label="操作" width="80" fixed="right">
  43. <template #default="{ row, $index }">
  44. <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. </div>
  49. </template>
  50. </byForm>
  51. <template #footer>
  52. <el-button @click="dialogVisible = false" size="default">取 消</el-button>
  53. <el-button type="primary" @click="submitForm()" size="default">确 定</el-button>
  54. </template>
  55. </el-dialog>
  56. <el-dialog v-model="openProduct" title="选择商品" width="80%" append-to-body destroy-on-close>
  57. <InventoryInquiry :selectStatus="true" :warehouseId="formData.data.warehouseId" @selectGood="selectGood" :key="formData.data.warehouseId">
  58. </InventoryInquiry>
  59. </el-dialog>
  60. </div>
  61. </template>
  62. <script setup>
  63. import { computed, ref } from "vue";
  64. import byTable from "@/components/byTable/index";
  65. import byForm from "@/components/byForm/index";
  66. import { ElMessage } from "element-plus";
  67. import InventoryInquiry from "@/views/purchaseSales/outAndInWarehouse/inventoryInquiry/index";
  68. const { proxy } = getCurrentInstance();
  69. const warehouseList = ref([]);
  70. const outBoundReason = ref([
  71. {
  72. label: "生产出库",
  73. value: "9",
  74. },
  75. {
  76. label: "生产超领",
  77. value: "1",
  78. },
  79. {
  80. label: "销售出库",
  81. value: "2",
  82. },
  83. {
  84. label: "借用出库",
  85. value: "3",
  86. },
  87. ]);
  88. const produceOrder = ref([]);
  89. const productUnit = ref([]);
  90. const sourceList = ref({
  91. data: [],
  92. pagination: {
  93. total: 0,
  94. pageNum: 1,
  95. pageSize: 10,
  96. keyword: "",
  97. warehouseId: "",
  98. type: "2",
  99. },
  100. });
  101. const loading = ref(false);
  102. const selectConfig = computed(() => {
  103. return [
  104. {
  105. label: "仓库名称",
  106. prop: "warehouseId",
  107. data: warehouseList.value,
  108. },
  109. ];
  110. });
  111. const config = computed(() => {
  112. return [
  113. {
  114. attrs: {
  115. label: "仓库名称",
  116. prop: "warehouseName",
  117. width: 220,
  118. },
  119. },
  120. {
  121. attrs: {
  122. label: "物品编码",
  123. prop: "productCode",
  124. width: 160,
  125. },
  126. },
  127. {
  128. attrs: {
  129. label: "物品名称",
  130. prop: "productName",
  131. "min-width": 220,
  132. },
  133. },
  134. {
  135. attrs: {
  136. label: "规格型号",
  137. prop: "productSpec",
  138. width: 160,
  139. },
  140. },
  141. {
  142. attrs: {
  143. label: "单位",
  144. prop: "productUnit",
  145. width: 120,
  146. },
  147. render(unit) {
  148. return proxy.dictValueLabel(unit, productUnit.value);
  149. },
  150. },
  151. {
  152. attrs: {
  153. label: "出库数量",
  154. prop: "quantity",
  155. width: 140,
  156. },
  157. },
  158. {
  159. attrs: {
  160. label: "操作人",
  161. prop: "opUserName",
  162. width: 140,
  163. },
  164. },
  165. {
  166. attrs: {
  167. label: "操作时间",
  168. prop: "createTime",
  169. width: 160,
  170. },
  171. },
  172. ];
  173. });
  174. const getDict = () => {
  175. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  176. if (res.rows && res.rows.length > 0) {
  177. warehouseList.value = res.rows.map((item) => {
  178. return {
  179. label: item.name,
  180. value: item.id,
  181. };
  182. });
  183. }
  184. });
  185. proxy
  186. .post("produceOrder/page", { pageNum: 1, pageSize: 9999 })
  187. .then((res) => {
  188. produceOrder.value = res.rows.map((x) => ({
  189. label: x.code,
  190. value: x.id,
  191. }));
  192. });
  193. proxy.getDictOne(["unit"]).then((res) => {
  194. productUnit.value = res["unit"].map((x) => ({
  195. label: x.dictValue,
  196. value: x.dictKey,
  197. }));
  198. });
  199. };
  200. const getList = async (req) => {
  201. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  202. loading.value = true;
  203. proxy
  204. .post("/stockJournalDetails/page", sourceList.value.pagination)
  205. .then((res) => {
  206. sourceList.value.data = res.rows;
  207. sourceList.value.pagination.total = res.total;
  208. setTimeout(() => {
  209. loading.value = false;
  210. }, 200);
  211. });
  212. };
  213. getDict();
  214. getList();
  215. const dialogVisible = ref(false);
  216. const loadingDialog = ref(false);
  217. const submit = ref(null);
  218. const openProduct = ref(false);
  219. const formOption = reactive({
  220. inline: true,
  221. labelWidth: 100,
  222. itemWidth: 100,
  223. rules: [],
  224. });
  225. const formData = reactive({
  226. data: {},
  227. });
  228. const formConfig = computed(() => {
  229. return [
  230. {
  231. type: "title1",
  232. title: "基本信息",
  233. },
  234. {
  235. type: "select",
  236. prop: "warehouseId",
  237. label: "仓库名称",
  238. required: true,
  239. data: warehouseList.value,
  240. fn: () => {
  241. changeWarehouse();
  242. },
  243. itemWidth: 50,
  244. },
  245. {
  246. type: "input",
  247. prop: "exWarehousePerson",
  248. label: "领料人",
  249. itemWidth: 50,
  250. },
  251. {
  252. type: "select",
  253. prop: "type",
  254. label: "出库原因",
  255. required: true,
  256. data: outBoundReason.value,
  257. fn: (val) => {
  258. if (["1", "2", "9"].includes(val)) {
  259. formData.data.expectRestitutionTime = "";
  260. } else {
  261. formData.data.prodOrderId = "";
  262. }
  263. },
  264. itemWidth: 50,
  265. },
  266. {
  267. type: "select",
  268. prop: "prodOrderId",
  269. label: "生产订单",
  270. data: produceOrder.value,
  271. itemWidth: 50,
  272. isShow: ["1", "2", "9"].includes(formData.data.type),
  273. },
  274. // {
  275. // type: "select",
  276. // prop: "ssdd",
  277. // label: "销售订单",
  278. // data: outBoundReason.value,
  279. // itemWidth: 50,
  280. // isShow: formData.data.aa == "3",
  281. // },
  282. {
  283. type: "date",
  284. itemType: "date",
  285. prop: "expectRestitutionTime",
  286. label: "归还日期",
  287. itemWidth: 50,
  288. isShow: formData.data.type == "3",
  289. },
  290. {
  291. type: "input",
  292. itemType: "textarea",
  293. prop: "remarks",
  294. label: "备注",
  295. itemWidth: 100,
  296. },
  297. {
  298. type: "slot",
  299. slotName: "details",
  300. label: "出库明细",
  301. },
  302. ];
  303. });
  304. const rules = ref({
  305. warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
  306. exWarehousePerson: [
  307. { required: true, message: "请输入领料人", trigger: "blur" },
  308. ],
  309. type: [{ required: true, message: "请选择出库原因", trigger: "change" }],
  310. prodOrderId: [
  311. { required: true, message: "请选择生产订单", trigger: "change" },
  312. ],
  313. expectRestitutionTime: [
  314. { required: true, message: "请选择归还日期", trigger: "change" },
  315. ],
  316. quantity: [{ required: true, message: "请输入出库数量", trigger: "blur" }],
  317. remarks: [{ required: true, message: "请输入备注", trigger: "blur" }],
  318. });
  319. const openModal = () => {
  320. formData.data = {
  321. type: "",
  322. list: [],
  323. };
  324. loadingDialog.value = false;
  325. dialogVisible.value = true;
  326. };
  327. const clickAdd = () => {
  328. if (formData.data.warehouseId) {
  329. openProduct.value = true;
  330. } else {
  331. ElMessage("请先选择仓库");
  332. }
  333. };
  334. const changeWarehouse = () => {
  335. formData.data.list = [];
  336. };
  337. const select = (item) => {
  338. if (formData.data.list && formData.data.list.length > 0) {
  339. let data = formData.data.list.filter(
  340. (row) => row.productId === item.productId
  341. );
  342. if (data && data.length > 0) {
  343. return ElMessage("请勿重复添加");
  344. }
  345. }
  346. formData.data.list.push({
  347. productCode: item.productCode,
  348. productId: item.productId,
  349. productName: item.productName,
  350. productSpec: item.productSpec,
  351. productUnit: item.productUnit,
  352. stockQuantity: item.quantity,
  353. quantity: undefined,
  354. });
  355. ElMessage({
  356. message: "添加成功!",
  357. type: "success",
  358. });
  359. };
  360. const selectGood = (row) => {
  361. formData.data.list.push({
  362. productCode: row.productCustomCode,
  363. productId: row.productId,
  364. productName: row.productName,
  365. productLength: row.productLength,
  366. productWidth: row.productWidth,
  367. productHeight: row.productHeight,
  368. stockQuantity: row.quantity,
  369. quantity: null,
  370. });
  371. proxy.msgTip("选择成功");
  372. };
  373. const submitForm = () => {
  374. submit.value.handleSubmit(() => {
  375. if (formData.data.list && formData.data.list.length > 0) {
  376. for (let i = 0; i < formData.data.list.length; i++) {
  377. if (
  378. formData.data.list[i].stockQuantity < formData.data.list[i].quantity
  379. ) {
  380. return ElMessage("出库数量不能大于库存数量");
  381. }
  382. }
  383. } else {
  384. return ElMessage("请添加出库产品");
  385. }
  386. loadingDialog.value = true;
  387. proxy.post("/stock/edit", formData.data).then(
  388. () => {
  389. ElMessage({
  390. message: "提交成功",
  391. type: "success",
  392. });
  393. dialogVisible.value = false;
  394. getList();
  395. },
  396. (err) => {
  397. console.log(err);
  398. loadingDialog.value = false;
  399. }
  400. );
  401. });
  402. };
  403. const handleDelete = (index) => {
  404. formData.data.list.splice(index, 1);
  405. };
  406. </script>
  407. <style lang="scss" scoped>
  408. .tenant {
  409. padding: 20px;
  410. }
  411. ::v-deep(.el-input-number .el-input__inner) {
  412. text-align: left;
  413. }
  414. </style>