index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :selectConfig="selectConfig"
  10. highlight-current-row
  11. @get-list="getList"
  12. >
  13. </byTable>
  14. </div>
  15. <el-dialog
  16. title="出库"
  17. v-if="dialogVisible"
  18. v-model="dialogVisible"
  19. width="400"
  20. v-loading="loadingDialog"
  21. >
  22. <byForm
  23. :formConfig="formConfig"
  24. :formOption="formOption"
  25. v-model="formData.data"
  26. :rules="rules"
  27. ref="submit"
  28. >
  29. </byForm>
  30. <template #footer>
  31. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  32. <el-button type="primary" @click="submitForm()" size="large"
  33. >确 定</el-button
  34. >
  35. </template>
  36. </el-dialog>
  37. </div>
  38. </template>
  39. <script setup>
  40. import { computed, ref } from "vue";
  41. import byTable from "@/components/byTable/index";
  42. import byForm from "@/components/byForm/index";
  43. import { ElMessage } from "element-plus";
  44. const { proxy } = getCurrentInstance();
  45. const warehouseList = ref([]);
  46. const productType = ref([]);
  47. const productUnit = ref([]);
  48. const status = ref([
  49. {
  50. label: "待出库",
  51. value: 0,
  52. },
  53. {
  54. label: "部分出库",
  55. value: 1,
  56. },
  57. {
  58. label: "出库完成",
  59. value: 2,
  60. },
  61. ]);
  62. const businessType = ref([
  63. {
  64. label: "线边回仓",
  65. value: 1,
  66. },
  67. {
  68. label: "完工入库",
  69. value: 2,
  70. },
  71. {
  72. label: "采购到货",
  73. value: 3,
  74. },
  75. {
  76. label: "退货出库",
  77. value: 4,
  78. },
  79. {
  80. label: "京东订单",
  81. value: 5,
  82. },
  83. {
  84. label: "销售订单出库",
  85. value: 6,
  86. },
  87. {
  88. label: "生产任务出库",
  89. value: 7,
  90. },
  91. ]);
  92. const sourceList = ref({
  93. data: [],
  94. pagination: {
  95. total: 0,
  96. pageNum: 1,
  97. pageSize: 10,
  98. keyword: "",
  99. status: "",
  100. type: 2,
  101. },
  102. });
  103. const loading = ref(false);
  104. const selectConfig = computed(() => {
  105. return [
  106. {
  107. label: "出库状态",
  108. prop: "status",
  109. data: status.value,
  110. },
  111. ];
  112. });
  113. const config = computed(() => {
  114. return [
  115. {
  116. attrs: {
  117. label: "数据来源",
  118. prop: "businessType",
  119. width: 120,
  120. },
  121. render(type) {
  122. return proxy.dictValueLabel(type, businessType.value);
  123. },
  124. },
  125. {
  126. attrs: {
  127. label: "单号",
  128. prop: "businessCode",
  129. width: 160,
  130. },
  131. },
  132. {
  133. attrs: {
  134. label: "物品类型",
  135. prop: "productType",
  136. width: 120,
  137. },
  138. render(type) {
  139. return proxy.dictValueLabel(type, productType.value);
  140. },
  141. },
  142. {
  143. attrs: {
  144. label: "物品编码",
  145. prop: "productCode",
  146. width: 140,
  147. },
  148. },
  149. {
  150. attrs: {
  151. label: "物品名称",
  152. prop: "productName",
  153. "min-width": 200,
  154. },
  155. },
  156. {
  157. attrs: {
  158. label: "规格型号",
  159. prop: "productSpec",
  160. width: 140,
  161. },
  162. },
  163. {
  164. attrs: {
  165. label: "单位",
  166. prop: "productUnit",
  167. width: 120,
  168. },
  169. render(unit) {
  170. return proxy.dictValueLabel(unit, productUnit.value);
  171. },
  172. },
  173. {
  174. attrs: {
  175. label: "待出库数量",
  176. prop: "quantity",
  177. width: 120,
  178. },
  179. },
  180. {
  181. attrs: {
  182. label: "出库状态",
  183. prop: "status",
  184. width: 140,
  185. },
  186. render(type) {
  187. return proxy.dictValueLabel(type, status.value);
  188. },
  189. },
  190. {
  191. attrs: {
  192. label: "操作",
  193. width: "80",
  194. align: "center",
  195. },
  196. renderHTML(row) {
  197. return [
  198. row.status !== 2
  199. ? {
  200. attrs: {
  201. label: "出库",
  202. type: "primary",
  203. text: true,
  204. },
  205. el: "button",
  206. click() {
  207. clickOperation(row);
  208. },
  209. }
  210. : {},
  211. ];
  212. },
  213. },
  214. ];
  215. });
  216. const getDict = () => {
  217. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  218. if (res.rows && res.rows.length > 0) {
  219. warehouseList.value = res.rows.map((item) => {
  220. return {
  221. label: item.name,
  222. value: item.id,
  223. };
  224. });
  225. }
  226. });
  227. proxy.getDictOne(["product_type", "unit"]).then((res) => {
  228. productType.value = res["product_type"].map((x) => ({
  229. label: x.dictValue,
  230. value: x.dictKey,
  231. }));
  232. productUnit.value = res["unit"].map((x) => ({
  233. label: x.dictValue,
  234. value: x.dictKey,
  235. }));
  236. });
  237. };
  238. const getList = async (req) => {
  239. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  240. loading.value = true;
  241. proxy
  242. .post("/stockWaitDetails/page", sourceList.value.pagination)
  243. .then((res) => {
  244. sourceList.value.data = res.rows.map((x) => ({
  245. ...x,
  246. quantity: (x.quantity - x.receiptQuantity).toFixed(4),
  247. }));
  248. sourceList.value.pagination.total = res.total;
  249. setTimeout(() => {
  250. loading.value = false;
  251. }, 200);
  252. });
  253. };
  254. getDict();
  255. getList();
  256. const dialogVisible = ref(false);
  257. const loadingDialog = ref(false);
  258. const submit = ref(null);
  259. const formOption = reactive({
  260. inline: true,
  261. labelWidth: 100,
  262. itemWidth: 100,
  263. rules: [],
  264. });
  265. const formData = reactive({
  266. data: {},
  267. });
  268. const formConfig = computed(() => {
  269. return [
  270. {
  271. label: "待出库信息",
  272. },
  273. {
  274. type: "select",
  275. prop: "businessType",
  276. label: "数据来源",
  277. disabled: true,
  278. data: businessType.value,
  279. },
  280. {
  281. type: "input",
  282. prop: "businessCode",
  283. label: "单号",
  284. itemType: "text",
  285. disabled: true,
  286. },
  287. {
  288. type: "input",
  289. prop: "productName",
  290. label: "物品名称",
  291. itemType: "text",
  292. disabled: true,
  293. },
  294. {
  295. type: "input",
  296. prop: "quantity",
  297. label: "待出库数量",
  298. itemType: "text",
  299. disabled: true,
  300. },
  301. {
  302. label: "本次出库",
  303. },
  304. {
  305. type: "select",
  306. prop: "warehouseId",
  307. label: "仓库名称",
  308. required: true,
  309. data: warehouseList.value,
  310. },
  311. {
  312. type: "number",
  313. prop: "warehousingQuantity",
  314. label: "出库数量",
  315. precision: 0,
  316. min: 1,
  317. controls: false,
  318. },
  319. ];
  320. });
  321. const rules = ref({
  322. warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
  323. warehousingQuantity: [
  324. { required: true, message: "请输入出库数量", trigger: "blur" },
  325. ],
  326. });
  327. const submitForm = () => {
  328. submit.value.handleSubmit(() => {
  329. loadingDialog.value = true;
  330. if (formData.data.warehousingQuantity > Number(formData.data.quantity)) {
  331. return ElMessage({
  332. message: "出库数量不可大于待出库数量",
  333. type: "info",
  334. });
  335. }
  336. proxy
  337. .post("/stockWait/add", {
  338. id: formData.data.id,
  339. warehouseId: formData.data.warehouseId,
  340. quantity: formData.data.warehousingQuantity,
  341. })
  342. .then(
  343. () => {
  344. ElMessage({
  345. message: "提交成功",
  346. type: "success",
  347. });
  348. dialogVisible.value = false;
  349. getList();
  350. },
  351. (err) => {
  352. console.log(err);
  353. loadingDialog.value = false;
  354. }
  355. );
  356. });
  357. };
  358. const clickOperation = (row) => {
  359. formData.data = row;
  360. loadingDialog.value = false;
  361. dialogVisible.value = true;
  362. };
  363. </script>
  364. <style lang="scss" scoped>
  365. .tenant {
  366. padding: 20px;
  367. }
  368. ::v-deep(.el-input-number .el-input__inner) {
  369. text-align: left;
  370. }
  371. </style>