index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :selectConfig="selectConfig"
  12. :table-events="{
  13. //element talbe事件都能传
  14. select: select,
  15. }"
  16. :action-list="[]"
  17. @get-list="getList"
  18. >
  19. <template #slotName="{ item }">
  20. {{ item.createTime }}
  21. </template>
  22. </byTable>
  23. </div>
  24. <el-dialog
  25. title="出库"
  26. v-model="dialogVisible"
  27. width="500"
  28. v-loading="loading"
  29. >
  30. <byForm
  31. :formConfig="formConfig"
  32. :formOption="formOption"
  33. v-model="formData.data"
  34. :rules="rules"
  35. ref="byform"
  36. >
  37. </byForm>
  38. <template #footer>
  39. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  40. <el-button
  41. type="primary"
  42. @click="submitForm('byform')"
  43. size="large"
  44. :loading="submitLoading"
  45. >
  46. 确 定
  47. </el-button>
  48. </template>
  49. </el-dialog>
  50. </div>
  51. </template>
  52. <script setup>
  53. /* eslint-disable vue/no-unused-components */
  54. import { ElMessage, ElMessageBox } from "element-plus";
  55. import byTable from "@/components/byTable/index";
  56. import byForm from "@/components/byForm/index";
  57. import { computed, defineComponent, ref } from "vue";
  58. import useUserStore from "@/store/modules/user";
  59. const loading = ref(false);
  60. const submitLoading = ref(false);
  61. const sourceList = ref({
  62. data: [],
  63. pagination: {
  64. total: 3,
  65. pageNum: 1,
  66. pageSize: 10,
  67. type: 1,
  68. },
  69. });
  70. let dialogVisible = ref(false);
  71. let roomDialogVisible = ref(false);
  72. let modalType = ref("add");
  73. let rules = ref({
  74. type: [
  75. { required: true, message: "请选择仓库类型", trigger: ["blur", "change"] },
  76. ],
  77. warehouseId: [
  78. { required: true, message: "请选择仓库名称", trigger: "change" },
  79. ],
  80. quantity: [{ required: true, message: "请输入入库数量", trigger: "blur" }],
  81. });
  82. const { proxy } = getCurrentInstance();
  83. const selectConfig = reactive([
  84. {
  85. label: "数据来源",
  86. prop: "type",
  87. data: [],
  88. },
  89. {
  90. label: "出库状态",
  91. prop: "type",
  92. data: [],
  93. },
  94. ]);
  95. const inboundType = ref([
  96. {
  97. label: "未入库",
  98. value: "0",
  99. },
  100. {
  101. label: "部分入库",
  102. value: "1",
  103. },
  104. {
  105. label: "入库完成",
  106. value: "2",
  107. },
  108. ]);
  109. const config = computed(() => {
  110. return [
  111. {
  112. attrs: {
  113. label: "数据来源",
  114. prop: "businessType",
  115. },
  116. render(type) {
  117. return businessType.find((x) => x.value == type).label;
  118. },
  119. },
  120. {
  121. attrs: {
  122. label: "单号",
  123. prop: "code",
  124. },
  125. },
  126. {
  127. attrs: {
  128. label: "物品类型",
  129. prop: "logisticsCompanyName",
  130. },
  131. },
  132. {
  133. attrs: {
  134. label: "物品编码",
  135. prop: "receiptWarehouseName",
  136. },
  137. },
  138. {
  139. attrs: {
  140. label: "物品名称",
  141. prop: "operatorName",
  142. },
  143. },
  144. {
  145. attrs: {
  146. label: "型号规格",
  147. prop: "createTime",
  148. },
  149. },
  150. {
  151. attrs: {
  152. label: "单位",
  153. prop: "createTime",
  154. },
  155. },
  156. {
  157. attrs: {
  158. label: "待出库",
  159. prop: "createTime",
  160. },
  161. },
  162. {
  163. attrs: {
  164. label: "出库状态",
  165. prop: "status",
  166. },
  167. render(status) {
  168. return status == 0 ? "未入库" : status == 1 ? "部分入库" : "";
  169. },
  170. },
  171. {
  172. attrs: {
  173. label: "操作",
  174. width: "100",
  175. align: "right",
  176. },
  177. // 渲染 el-button,一般用在最后一列。
  178. renderHTML(row) {
  179. return [
  180. {
  181. attrs: {
  182. label: "出库",
  183. type: "primary",
  184. text: true,
  185. disabled: row.status > 1,
  186. },
  187. el: "button",
  188. click() {
  189. getDtl(row);
  190. },
  191. },
  192. ];
  193. },
  194. },
  195. ];
  196. });
  197. let formData = reactive({
  198. data: {},
  199. treeData: [],
  200. });
  201. const formOption = reactive({
  202. inline: true,
  203. labelWidth: 100,
  204. itemWidth: 100,
  205. rules: [],
  206. });
  207. const byform = ref(null);
  208. const treeData = ref([]);
  209. const formConfig = reactive([
  210. {
  211. type: "title",
  212. title: "待出库信息",
  213. },
  214. {
  215. type: "select",
  216. prop: "businessType",
  217. label: "数据来源",
  218. required: true,
  219. disabled: true,
  220. itemWidth: 100,
  221. data: [],
  222. },
  223. {
  224. type: "input",
  225. prop: "businessType",
  226. label: "单号",
  227. required: true,
  228. disabled: true,
  229. itemWidth: 100,
  230. data: [],
  231. },
  232. {
  233. type: "input",
  234. prop: "businessType",
  235. label: "物品名称",
  236. required: true,
  237. disabled: true,
  238. itemWidth: 100,
  239. data: [],
  240. },
  241. {
  242. type: "input",
  243. prop: "businessType",
  244. label: "待出库数量",
  245. required: true,
  246. disabled: true,
  247. itemWidth: 40,
  248. data: [],
  249. },
  250. {
  251. type: "title",
  252. title: "本次出库",
  253. },
  254. {
  255. type: "select",
  256. prop: "warehouseId",
  257. label: "仓库名称",
  258. itemWidth: 100,
  259. isLoad: {
  260. url: "/warehouse/page",
  261. req: {
  262. pageNum: 1,
  263. pageSize: 9999,
  264. },
  265. labelKey: "name",
  266. labelVal: "id",
  267. method: "post",
  268. resUrl: "rows",
  269. },
  270. },
  271. {
  272. type: "input",
  273. prop: "code",
  274. label: "出库数量",
  275. disabled: false,
  276. itemWidth: 33,
  277. },
  278. ]);
  279. const getList = async (req) => {
  280. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  281. loading.value = true;
  282. proxy
  283. .post("/stockWait/pageByWdly", sourceList.value.pagination)
  284. .then((message) => {
  285. console.log(message);
  286. sourceList.value.data = message.rows.map((x) => ({
  287. ...x,
  288. ...JSON.parse(x.victoriatouristJson),
  289. }));
  290. sourceList.value.pagination.total = message.total;
  291. setTimeout(() => {
  292. loading.value = false;
  293. }, 200);
  294. });
  295. };
  296. const openModal = () => {
  297. dialogVisible.value = true;
  298. modalType.value = "add";
  299. formData.data = {};
  300. };
  301. const submitForm = () => {
  302. byform.value.handleSubmit((valid) => {
  303. const list = formData.data.stockWaitDetailsList;
  304. const total = list.reduce((total, x) => (total += Number(x.quantity)), 0);
  305. if (!(total > 0)) {
  306. return ElMessage({
  307. message: `本次入库不能为0!`,
  308. type: "info",
  309. });
  310. }
  311. for (let i = 0; i < list.length; i++) {
  312. const e = list[i];
  313. if (Number(e.receiptQuantity) + e.quantity > Number(e.arrivalQuantity)) {
  314. return ElMessage({
  315. message: "本次入库加已入库数量不可大于发货数量!",
  316. type: "info",
  317. });
  318. }
  319. }
  320. submitLoading.value = true;
  321. proxy.post("/stockWait/addByWdly", formData.data).then(
  322. (res) => {
  323. ElMessage({
  324. message: "操作成功",
  325. type: "success",
  326. });
  327. dialogVisible.value = false;
  328. submitLoading.value = false;
  329. getList();
  330. },
  331. (err) => (submitLoading.value = false)
  332. );
  333. });
  334. };
  335. const getDtl = (row) => {
  336. modalType.value = "edit";
  337. // proxy.post("/stockWait/detailByWdly", { id: row.id }).then((res) => {
  338. // const json = JSON.parse(res.victoriatouristJson);
  339. // formData.data = {
  340. // type: "1",
  341. // businessType: res.businessType,
  342. // warehouseId: "",
  343. // code: json.code,
  344. // stockWaitDetailsList: res.stockWaitDetailsList.map((x) => ({
  345. // ...x,
  346. // arrivalQuantity: x.quantity,
  347. // quantity: 0,
  348. // })),
  349. // };
  350. // dialogVisible.value = true;
  351. // });
  352. dialogVisible.value = true;
  353. };
  354. const warehouseType = ref([]);
  355. const getDict = () => {
  356. // // 币种数据
  357. proxy
  358. .post("/dictTenantData/page", {
  359. pageNum: 1,
  360. pageSize: 999,
  361. tenantId: useUserStore().user.tenantId,
  362. dictCode: "warehouse_type",
  363. })
  364. .then((res) => {
  365. warehouseType.value = res.rows;
  366. formConfig[0].data = res.rows.map((x) => ({
  367. label: x.dictValue,
  368. value: x.dictKey,
  369. }));
  370. });
  371. };
  372. const businessType = [
  373. { label: "线边回仓", value: "1" },
  374. { label: "完工入库", value: "2" },
  375. { label: "采购到货", value: "3" },
  376. { label: "退货出库", value: "4" },
  377. ];
  378. getList();
  379. getDict();
  380. onMounted(() => {
  381. selectConfig[0].data = inboundType.value;
  382. });
  383. </script>
  384. <style lang="scss" scoped>
  385. .tenant {
  386. padding: 20px;
  387. }
  388. </style>