123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- <template>
- <van-nav-bar :title="$t('inventoryQuery.name')" left-text="" left-arrow @click-left="onClickLeft">
- </van-nav-bar>
- <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
- <van-tabs v-model:active="active" @change="handleChangeTab">
- <van-tab :title="'按仓库'" name="first"></van-tab>
- <van-tab :title="'按产品'" name="second"></van-tab>
- <van-tab :title="'按SPU'" name="three"></van-tab>
- </van-tabs>
- <div style="overflow-y:auto" :style="{height:!deviceStore.isIosSysteme?'calc(100vh - 205px)':'calc(100vh - 225px)'}">
- <van-pull-refresh v-model="loading" @refresh="onRefresh">
- <div class="list">
- <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="onLoad" style="margin-bottom: 60px">
- <commonList :data="listData" :config="listConfig" :showMore="false">
- <template #productUnit="{row}">
- <div style="width:100%">
- {{dictValueLabel(row.productUnit,productUnit)}}
- </div>
- </template>
- <template #btn="{row}">
- <div style="width:100%;text-align:right">
- <van-button type="primary" size="small" style="margin-right:10px" @click="toDtl(row,true)">良转次</van-button>
- <van-button type="primary" size="small" @click="toDtl(row,false)">次转良</van-button>
- </div>
- </template>
- </commonList>
- <!-- @onClick="toDtl" -->
- </van-list>
- </div>
- </van-pull-refresh>
- </div>
- <van-popup v-model:show="openPopup" position="bottom" :style="{ height: '370px' }" closeable>
- <div style="padding:10px">
- <van-form @submit="onSubmit" label-align="top">
- <TitleInfo :title="submitType?'良转次':'次转良'"></TitleInfo>
- <van-field v-model="formData.data.canSum" type="text" label="可转数量" readonly />
- <van-field v-model="formData.data.quantity" type="digit" label="数量" placeholder="请输入数量" :rules="[{ required: true, message: '请填写数量' }]" />
- <div style="margin: 16px">
- <van-button round block type="primary" native-type="submit">
- 提交
- </van-button>
- </div>
- </van-form>
- </div>
- </van-popup>
- </template>
- <script setup>
- import { ref, getCurrentInstance, onMounted, reactive } from "vue";
- import commonList from "@/components/common-list.vue";
- import { useRoute } from "vue-router";
- import { getUserInfo } from "@/utils/auth";
- import { showSuccessToast, showFailToast } from "vant";
- import TitleInfo from "@/components/TitleInfo/index.vue";
- import useDeviceStore from "@/store/device";
- const deviceStore = useDeviceStore();
- const loading = ref(false);
- const router = useRoute();
- const req = ref({
- pageNum: 1,
- keyword: null,
- });
- const finished = ref(false);
- const proxy = getCurrentInstance().proxy;
- const listData = ref([]);
- const warehouseData = ref([]);
- const productUnit = ref([]);
- const active = ref("first");
- let listConfigSet = [
- [
- {
- label: "仓库名称",
- prop: "warehouseName",
- },
- {
- label: "项目组",
- prop: "deptName",
- },
- {
- label: "所属分类",
- prop: "productClassifyName",
- },
- {
- label: "物品编码",
- prop: "productCustomCode",
- },
- {
- label: "物品名称",
- prop: "productName",
- },
- {
- label: "规格",
- prop: "productSpec",
- },
- {
- type: "slot",
- slotName: "productUnit",
- label: "单位",
- prop: "productUnit",
- },
- {
- label: "可用库存",
- prop: "quantity",
- },
- {
- label: "冻结库存",
- prop: "frozenQuantity",
- },
- {
- label: "次品库存",
- prop: "defectiveQuantity",
- },
- {
- label: "最近入库时间",
- prop: "updateTime",
- },
- {
- type: "slot",
- slotName: "btn",
- label: "",
- },
- ],
- [
- {
- label: "项目组",
- prop: "deptName",
- },
- {
- label: "所属分类",
- prop: "productClassifyName",
- },
- {
- label: "物品编码",
- prop: "productCustomCode",
- },
- {
- label: "物品名称",
- prop: "productName",
- },
- {
- label: "规格",
- prop: "productSpec",
- },
- {
- type: "slot",
- slotName: "productUnit",
- label: "单位",
- prop: "productUnit",
- },
- {
- label: "可用库存",
- prop: "quantity",
- },
- {
- label: "冻结库存",
- prop: "frozenQuantity",
- },
- {
- label: "次品库存",
- prop: "defectiveQuantity",
- },
- {
- label: "最近入库时间",
- prop: "updateTime",
- },
- {
- type: "slot",
- slotName: "btn",
- label: "",
- },
- ],
- [
- {
- label: "spu编码",
- prop: "productSpuCode",
- },
- {
- label: "spu名称",
- prop: "productSpuName",
- },
- {
- label: "关联产品数",
- prop: "linkProductQuantity",
- },
- {
- label: "库存数量",
- prop: "quantity",
- },
- ],
- ];
- const listConfig = ref([]);
- listConfig.value = listConfigSet[0];
- const onRefresh = () => {
- req.value.pageNum = 1;
- finished.value = false;
- getList("refresh");
- };
- const onLoad = () => {
- getList();
- };
- const onClickLeft = () => proxy.$router.push("/main/working");
- const onClickRight = () => {
- proxy.$router.push("/main/manualInboundAdd");
- };
- const formData = reactive({
- data: {},
- });
- const openPopup = ref(false);
- const submitType = ref(false);
- const toDtl = (row, flag) => {
- submitType.value = flag;
- // proxy.$router.push({
- // path: "outInList",
- // query: {
- // productId: row.productId,
- // warehouseId: row.warehouseId,
- // },
- // });
- let canSum = flag ? row.quantity : row.defectiveQuantity;
- formData.data = {
- id: row.id,
- canSum,
- quantity: null,
- };
- openPopup.value = true;
- };
- const onSubmit = () => {
- let url = submitType.value
- ? "/stock/qualifiedToDefective"
- : "/stock/defectiveToQualified";
- if (!(Number(formData.data.quantity) > 0)) {
- return showFailToast("数量不能为0");
- }
- if (Number(formData.data.quantity) > Number(formData.data.canSum)) {
- return showFailToast("数量不可大于可转数量");
- }
- proxy.post(url, formData.data).then(
- (res) => {
- onRefresh();
- showSuccessToast("操作成功");
- openPopup.value = false;
- },
- (err) => {
- return showFailToast(err.message);
- }
- );
- };
- const getDict = () => {
- let query = {
- pageNum: 1,
- pageSize: 999,
- tenantId: getUserInfo().tenantId,
- };
- // proxy
- // .post("/supplierInfo/page", { pageNum: 1, pageSize: 9999 })
- // .then((res) => {
- // supplierData.value = res.data.rows;
- // formConfig[5].data = supplierData.value;
- // });
- proxy
- .post("/dictTenantData/page", {
- ...query,
- dictCode: "unit",
- })
- .then((res) => {
- if (res.data.rows && res.data.rows.length > 0) {
- productUnit.value = res.data.rows.map((item) => {
- return {
- label: item.dictValue,
- value: item.dictKey,
- };
- });
- }
- });
- };
- getDict();
- const getList = (type) => {
- loading.value = true;
- proxy
- .post(requestUrl.value, req.value)
- .then((res) => {
- res.data.rows = res.data.rows.map((x) => ({
- ...x,
- ...JSON.parse(x.victoriatouristJson),
- quantity: x.quantity,
- }));
- listData.value =
- type === "refresh"
- ? res.data.rows
- : listData.value.concat(res.data.rows);
- if (req.value.pageNum * 10 >= res.data.total) {
- finished.value = true;
- }
- req.value.pageNum++;
- loading.value = false;
- })
- .catch((err) => {
- loading.value = false;
- });
- };
- const requestUrl = ref("/stock/pageByWarehouse");
- const handleChangeTab = (val) => {
- if (val == "first") {
- requestUrl.value = "/stock/pageByWarehouse";
- listConfig.value = listConfigSet[0];
- } else if (val == "second") {
- requestUrl.value = "/stock/pageByProduct";
- listConfig.value = listConfigSet[1];
- } else {
- requestUrl.value = "/stock/pageByProductSpu";
- listConfig.value = listConfigSet[2];
- }
- req.value.pageNum = 1;
- listData.value = [];
- getList();
- };
- getList();
- </script>
- <style lang="scss" scoped>
- .list {
- min-height: 100%;
- }
- </style>
|