123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 |
- <template>
- <el-card class="box-card">
- <el-tabs v-model="activeName" type="card" @tab-change="changeActiveName">
- <el-tab-pane label="盘点单" name="first">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- :searchConfig="searchConfig"
- highlight-current-row
- :action-list="[
- {
- text: '盘点登记',
- action: () => clickModal(),
- },
- {
- text: '导出Excel',
- action: () => clickDerive(),
- },
- ]"
- @get-list="getList"
- @clickReset="clickReset">
- </byTable>
- </el-tab-pane>
- <el-tab-pane label="盘点明细" name="second">
- <byTable
- :source="sourceListTwo.data"
- :pagination="sourceListTwo.pagination"
- :config="configTwo"
- :loading="loading"
- :searchConfig="searchConfigTwo"
- highlight-current-row
- :action-list="[
- {
- text: '盘点登记',
- action: () => clickModal(),
- },
- ]"
- @get-list="getListTwo"
- @clickReset="clickResetTwo">
- <template #quantity="{ item }">
- <div>{{ calculationNum(item) }}</div>
- </template>
- <template #money="{ item }">
- <div>{{ calculationMoney(item) }}</div>
- </template>
- </byTable>
- </el-tab-pane>
- </el-tabs>
- <el-dialog title="导出Excel文件" v-if="openDerive" v-model="openDerive" width="400">
- <el-form :model="formData.data" :rules="rules" ref="derive">
- <el-form-item label="仓库" prop="warehouseId">
- <el-select v-model="formData.data.warehouseId" placeholder="仓库" clearable style="width: 100%">
- <el-option v-for="item in warehouseList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
- </el-select>
- </el-form-item>
- </el-form>
- <template #footer>
- <el-button @click="openDerive = false" size="large">关 闭</el-button>
- <el-button type="primary" @click="clickSubmit" v-preReClick>确 认</el-button>
- </template>
- </el-dialog>
- </el-card>
- </template>
- <script setup>
- import byTable from "/src/components/byTable/index";
- const { proxy } = getCurrentInstance();
- const activeName = ref("first");
- const departmentList = ref([{ dictKey: "0", dictValue: "胜德体育" }]);
- const warehouseList = ref([]);
- const status = ref([
- { dictKey: "0", dictValue: "正常" },
- { dictKey: "1", dictValue: "异常" },
- ]);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- departmentId: "",
- warehouseId: "",
- status: "",
- beginTime: "",
- endTime: "",
- },
- });
- const sourceListTwo = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- bomSpecCode: "",
- bomSpecName: "",
- departmentId: "",
- warehouseId: "",
- status: "",
- beginTime: "",
- endTime: "",
- },
- });
- const loading = ref(false);
- const searchConfig = computed(() => {
- return [
- {
- type: "select",
- prop: "departmentId",
- data: departmentList.value,
- label: "事业部",
- },
- {
- type: "select",
- prop: "warehouseId",
- data: warehouseList.value,
- label: "仓库",
- },
- {
- type: "select",
- prop: "status",
- data: status.value,
- label: "盘点结果",
- },
- {
- type: "date",
- propList: ["beginTime", "endTime"],
- label: "盘点日期",
- },
- ];
- });
- const searchConfigTwo = computed(() => {
- return [
- {
- type: "input",
- prop: "bomSpecCode",
- label: "品号",
- },
- {
- type: "input",
- prop: "bomSpecName",
- label: "品名",
- },
- {
- type: "select",
- prop: "departmentId",
- data: departmentList.value,
- label: "事业部",
- },
- {
- type: "select",
- prop: "warehouseId",
- data: warehouseList.value,
- label: "仓库",
- },
- {
- type: "select",
- prop: "status",
- data: status.value,
- label: "盘点结果",
- },
- {
- type: "date",
- propList: ["beginTime", "endTime"],
- label: "盘点日期",
- },
- ];
- });
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "盘点时间",
- prop: "createTime",
- width: 160,
- align: "center",
- },
- },
- {
- attrs: {
- label: "归属事业部",
- prop: "departmentName",
- "min-width": 160,
- },
- },
- {
- attrs: {
- label: "仓库类型",
- prop: "warehouseType",
- width: 140,
- },
- render(val) {
- return proxy.dictKeyValue(val, proxy.useUserStore().allDict["warehouse_type"]);
- },
- },
- {
- attrs: {
- label: "仓库名称",
- prop: "warehouseName",
- "min-width": 200,
- },
- },
- {
- attrs: {
- label: "入库类型",
- prop: "status",
- width: 140,
- },
- render(val) {
- return proxy.dictKeyValue(val, status.value);
- },
- },
- {
- attrs: {
- label: "盘点人",
- prop: "checkTaker",
- width: 160,
- align: "center",
- },
- },
- ];
- });
- const configTwo = computed(() => {
- return [
- {
- attrs: {
- label: "品号",
- prop: "bomSpecCode",
- width: 160,
- },
- },
- {
- attrs: {
- label: "品名",
- prop: "bomSpecName",
- "min-width": 220,
- },
- },
- {
- attrs: {
- label: "结存单价",
- prop: "balanceUnitPrice",
- width: 140,
- algin: "right",
- },
- },
- {
- attrs: {
- label: "仓库名称",
- prop: "warehouseName",
- width: 160,
- },
- },
- {
- attrs: {
- label: "归属事业部",
- prop: "departmentName",
- width: 160,
- },
- },
- {
- attrs: {
- label: "单位",
- prop: "bomUnit",
- width: 140,
- },
- },
- {
- attrs: {
- label: "盘前数量",
- prop: "surplusStock",
- width: 140,
- },
- },
- {
- attrs: {
- label: "盘后数量",
- prop: "checkQuantity",
- width: 140,
- },
- },
- {
- attrs: {
- label: "盘盈/亏数量",
- slot: "quantity",
- width: 140,
- },
- },
- {
- attrs: {
- label: "盘盈/亏金额",
- slot: "money",
- width: 140,
- },
- },
- {
- attrs: {
- label: "备注",
- slot: "remark",
- width: 140,
- },
- },
- ];
- });
- const getList = async (req, status) => {
- if (status) {
- sourceList.value.pagination = {
- pageNum: sourceList.value.pagination.pageNum,
- pageSize: sourceList.value.pagination.pageSize,
- };
- } else {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- }
- loading.value = true;
- proxy.post("/check/page", sourceList.value.pagination).then((res) => {
- sourceList.value.data = res.rows;
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getList();
- const clickReset = () => {
- getList("", true);
- };
- const getListTwo = async (req, status) => {
- if (status) {
- sourceListTwo.value.pagination = {
- pageNum: sourceListTwo.value.pagination.pageNum,
- pageSize: sourceListTwo.value.pagination.pageSize,
- };
- } else {
- sourceListTwo.value.pagination = { ...sourceListTwo.value.pagination, ...req };
- }
- loading.value = true;
- proxy.post("/checkBom/page", sourceListTwo.value.pagination).then((res) => {
- sourceListTwo.value.data = res.rows;
- sourceListTwo.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- const clickResetTwo = () => {
- getListTwo("", true);
- };
- const changeActiveName = (val) => {
- if (val === "first") {
- getList();
- } else {
- getListTwo();
- }
- };
- const getDemandData = () => {
- proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
- if (res.rows && res.rows.length > 0) {
- departmentList.value = departmentList.value.concat(
- res.rows.map((item) => {
- return {
- dictKey: item.id,
- dictValue: item.name,
- };
- })
- );
- }
- });
- proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
- if (res.rows && res.rows.length > 0) {
- warehouseList.value = res.rows.map((item) => {
- return {
- dictKey: item.id,
- dictValue: item.name,
- };
- });
- }
- });
- };
- getDemandData();
- const clickModal = () => {
- proxy.$router.replace({
- path: "/check/add",
- query: {
- random: proxy.random(),
- },
- });
- };
- const calculationNum = (row) => {
- let num = 0;
- if (row.checkQuantity) {
- num = Number(row.checkQuantity);
- }
- if (row.surplusStock) {
- num = Number(num) - Number(row.surplusStock);
- }
- return num;
- };
- const calculationMoney = (row) => {
- let num = 0;
- if (row.checkQuantity) {
- num = Number(row.checkQuantity);
- }
- if (row.surplusStock) {
- num = Number(num) - Number(row.surplusStock);
- }
- if (row.balanceUnitPrice) {
- money = Number(Math.round(money * Number(row.balanceUnitPrice) * 100) / 100);
- return money;
- } else {
- return 0;
- }
- };
- const openDerive = ref(false);
- const formData = reactive({
- data: {
- warehouseId: "",
- },
- });
- const rules = ref({
- warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
- });
- const clickDerive = () => {
- formData.data.warehouseId = "";
- openDerive.value = true;
- };
- const clickSubmit = () => {
- proxy.$refs.derive.validate((valid) => {
- if (valid) {
- proxy.postFile("/check/inventoryExportExcel", { id: formData.data.warehouseId }).then((res) => {
- proxy.downloadFile(res, "盘点.xlsx");
- });
- }
- });
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep(.el-input-number .el-input__inner) {
- text-align: left;
- }
- </style>
|