index.vue 6.4 KB

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