index.vue 8.6 KB

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