index.vue 9.4 KB

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