index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. label: "销售换货",
  93. value: 10,
  94. },
  95. ]);
  96. const sourceList = ref({
  97. data: [],
  98. pagination: {
  99. total: 0,
  100. pageNum: 1,
  101. pageSize: 10,
  102. keyword: "",
  103. status: "",
  104. type: 2,
  105. },
  106. });
  107. const loading = ref(false);
  108. const selectConfig = computed(() => {
  109. return [
  110. {
  111. label: "出库状态",
  112. prop: "status",
  113. data: status.value,
  114. },
  115. ];
  116. });
  117. const config = computed(() => {
  118. return [
  119. {
  120. attrs: {
  121. label: "数据来源",
  122. prop: "businessType",
  123. width: 120,
  124. },
  125. render(type) {
  126. return proxy.dictValueLabel(type, businessType.value);
  127. },
  128. },
  129. {
  130. attrs: {
  131. label: "单号",
  132. prop: "businessCode",
  133. width: 160,
  134. },
  135. },
  136. {
  137. attrs: {
  138. label: "物品类型",
  139. prop: "productType",
  140. width: 120,
  141. },
  142. render(type) {
  143. return proxy.dictValueLabel(type, productType.value);
  144. },
  145. },
  146. {
  147. attrs: {
  148. label: "物品编码",
  149. prop: "productCode",
  150. width: 140,
  151. },
  152. },
  153. {
  154. attrs: {
  155. label: "物品名称",
  156. prop: "productName",
  157. "min-width": 200,
  158. },
  159. },
  160. {
  161. attrs: {
  162. label: "规格型号",
  163. prop: "productSpec",
  164. width: 140,
  165. },
  166. },
  167. {
  168. attrs: {
  169. label: "单位",
  170. prop: "productUnit",
  171. width: 120,
  172. },
  173. render(unit) {
  174. return proxy.dictValueLabel(unit, productUnit.value);
  175. },
  176. },
  177. {
  178. attrs: {
  179. label: "待出库数量",
  180. prop: "quantity",
  181. width: 120,
  182. },
  183. },
  184. {
  185. attrs: {
  186. label: "出库状态",
  187. prop: "status",
  188. width: 140,
  189. },
  190. render(type) {
  191. return proxy.dictValueLabel(type, status.value);
  192. },
  193. },
  194. {
  195. attrs: {
  196. label: "操作",
  197. width: "80",
  198. align: "center",
  199. },
  200. renderHTML(row) {
  201. return [
  202. row.status !== 2
  203. ? {
  204. attrs: {
  205. label: "出库",
  206. type: "primary",
  207. text: true,
  208. },
  209. el: "button",
  210. click() {
  211. clickOperation(row);
  212. },
  213. }
  214. : {},
  215. ];
  216. },
  217. },
  218. ];
  219. });
  220. const getDict = () => {
  221. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  222. if (res.rows && res.rows.length > 0) {
  223. warehouseList.value = res.rows.map((item) => {
  224. return {
  225. label: item.name,
  226. value: item.id,
  227. };
  228. });
  229. }
  230. });
  231. proxy.getDictOne(["product_type", "unit"]).then((res) => {
  232. productType.value = res["product_type"].map((x) => ({
  233. label: x.dictValue,
  234. value: x.dictKey,
  235. }));
  236. productUnit.value = res["unit"].map((x) => ({
  237. label: x.dictValue,
  238. value: x.dictKey,
  239. }));
  240. });
  241. };
  242. const getList = async (req) => {
  243. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  244. loading.value = true;
  245. proxy
  246. .post("/stockWaitDetails/page", sourceList.value.pagination)
  247. .then((res) => {
  248. sourceList.value.data = res.rows.map((x) => ({
  249. ...x,
  250. quantity: (x.quantity - x.receiptQuantity).toFixed(4),
  251. }));
  252. sourceList.value.pagination.total = res.total;
  253. setTimeout(() => {
  254. loading.value = false;
  255. }, 200);
  256. });
  257. };
  258. getDict();
  259. getList();
  260. const dialogVisible = ref(false);
  261. const loadingDialog = ref(false);
  262. const submit = ref(null);
  263. const formOption = reactive({
  264. inline: true,
  265. labelWidth: 100,
  266. itemWidth: 100,
  267. rules: [],
  268. });
  269. const formData = reactive({
  270. data: {},
  271. });
  272. const formConfig = computed(() => {
  273. return [
  274. {
  275. label: "待出库信息",
  276. },
  277. {
  278. type: "select",
  279. prop: "businessType",
  280. label: "数据来源",
  281. disabled: true,
  282. data: businessType.value,
  283. },
  284. {
  285. type: "input",
  286. prop: "businessCode",
  287. label: "单号",
  288. itemType: "text",
  289. disabled: true,
  290. },
  291. {
  292. type: "input",
  293. prop: "productName",
  294. label: "物品名称",
  295. itemType: "text",
  296. disabled: true,
  297. },
  298. {
  299. type: "input",
  300. prop: "quantity",
  301. label: "待出库数量",
  302. itemType: "text",
  303. disabled: true,
  304. },
  305. {
  306. label: "本次出库",
  307. },
  308. {
  309. type: "select",
  310. prop: "warehouseId",
  311. label: "仓库名称",
  312. required: true,
  313. data: warehouseList.value,
  314. },
  315. {
  316. type: "number",
  317. prop: "warehousingQuantity",
  318. label: "出库数量",
  319. precision: 0,
  320. min: 1,
  321. controls: false,
  322. },
  323. ];
  324. });
  325. const rules = ref({
  326. warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
  327. warehousingQuantity: [
  328. { required: true, message: "请输入出库数量", trigger: "blur" },
  329. ],
  330. });
  331. const submitForm = () => {
  332. submit.value.handleSubmit(() => {
  333. loadingDialog.value = true;
  334. if (formData.data.warehousingQuantity > Number(formData.data.quantity)) {
  335. return ElMessage({
  336. message: "出库数量不可大于待出库数量",
  337. type: "info",
  338. });
  339. }
  340. proxy
  341. .post("/stockWait/add", {
  342. id: formData.data.id,
  343. warehouseId: formData.data.warehouseId,
  344. quantity: formData.data.warehousingQuantity,
  345. })
  346. .then(
  347. () => {
  348. ElMessage({
  349. message: "提交成功",
  350. type: "success",
  351. });
  352. dialogVisible.value = false;
  353. getList();
  354. },
  355. (err) => {
  356. console.log(err);
  357. loadingDialog.value = false;
  358. }
  359. );
  360. });
  361. };
  362. const clickOperation = (row) => {
  363. formData.data = row;
  364. loadingDialog.value = false;
  365. dialogVisible.value = true;
  366. };
  367. </script>
  368. <style lang="scss" scoped>
  369. .tenant {
  370. padding: 20px;
  371. }
  372. ::v-deep(.el-input-number .el-input__inner) {
  373. text-align: left;
  374. }
  375. </style>