|
@@ -2,108 +2,54 @@
|
|
|
<div class="tenant">
|
|
|
<!-- <Banner /> -->
|
|
|
<div class="content">
|
|
|
- <byTable
|
|
|
- :source="sourceList.data"
|
|
|
- :pagination="sourceList.pagination"
|
|
|
- :config="config"
|
|
|
- :loading="loading"
|
|
|
- highlight-current-row
|
|
|
- :selectConfig="selectConfig"
|
|
|
- :table-events="{
|
|
|
+ <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
|
|
|
+ :selectConfig="selectConfig" :table-events="{
|
|
|
//element talbe事件都能传
|
|
|
select: select,
|
|
|
- }"
|
|
|
- :action-list="[
|
|
|
+ }" :action-list="[
|
|
|
{
|
|
|
text: '发起盘点',
|
|
|
action: () => openModal('add'),
|
|
|
},
|
|
|
- ]"
|
|
|
- @get-list="getList"
|
|
|
- >
|
|
|
+ ]" @get-list="getList">
|
|
|
<template #code="{ item }">
|
|
|
- <div
|
|
|
- style="cursor: pointer; color: #409eff"
|
|
|
- @click="handleClickCode(item)"
|
|
|
- >
|
|
|
+ <div style="cursor: pointer; color: #409eff" @click="handleClickCode(item)">
|
|
|
{{ item.code }}
|
|
|
</div>
|
|
|
</template>
|
|
|
</byTable>
|
|
|
</div>
|
|
|
- <el-dialog
|
|
|
- :title="modalType == 'add' ? '发起盘点' : '盘点详情'"
|
|
|
- v-model="dialogVisible"
|
|
|
- width="800"
|
|
|
- v-loading="loading"
|
|
|
- destroy-on-close
|
|
|
- >
|
|
|
- <byForm
|
|
|
- :formConfig="formConfig"
|
|
|
- :formOption="formOption"
|
|
|
- v-model="formData.data"
|
|
|
- :rules="rules"
|
|
|
- ref="byform"
|
|
|
- >
|
|
|
+ <el-dialog :title="modalType == 'add' ? '发起盘点' : '盘点详情'" v-model="dialogVisible" width="70%" v-loading="loading" destroy-on-close>
|
|
|
+ <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
|
|
|
<template #products>
|
|
|
<div style="width: 100%">
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- @click="openProduct = true"
|
|
|
- style="margin-bottom: 10px"
|
|
|
- v-if="modalType == 'add'"
|
|
|
- :disabled="!formData.data.warehouseId"
|
|
|
- >
|
|
|
+ <el-button type="primary" @click="openProduct = true" style="margin-bottom: 10px" v-if="modalType == 'add'"
|
|
|
+ :disabled="!formData.data.warehouseId">
|
|
|
添加物品
|
|
|
</el-button>
|
|
|
- <el-table
|
|
|
- :data="formData.data.list"
|
|
|
- :row-class-name="changeClass"
|
|
|
- show-summary
|
|
|
- :summary-method="getSummaries"
|
|
|
- >
|
|
|
+ <el-button type="primary" @click="excelImport()" plain style="margin-bottom: 10px" v-if="modalType == 'add'"
|
|
|
+ :disabled="!formData.data.warehouseId">
|
|
|
+ Excel导入
|
|
|
+ </el-button>
|
|
|
+
|
|
|
+ <el-table :data="formData.data.list" :row-class-name="changeClass" show-summary :summary-method="getSummaries">
|
|
|
<el-table-column prop="productCode" label="物品编码" />
|
|
|
<el-table-column prop="productName" label="物品名称" />
|
|
|
- <el-table-column
|
|
|
- prop="productUnit"
|
|
|
- label="单位"
|
|
|
- :formatter="
|
|
|
+ <el-table-column prop="productUnit" label="单位" :formatter="
|
|
|
(row) => dictValueLabel(row.productUnit, productUnit)
|
|
|
- "
|
|
|
- />
|
|
|
+ " />
|
|
|
<el-table-column prop="quantity" label="库存数量" />
|
|
|
- <el-table-column
|
|
|
- prop="checkQuantity"
|
|
|
- label="盘点数量"
|
|
|
- min-width="150"
|
|
|
- >
|
|
|
+ <el-table-column prop="checkQuantity" label="盘点数量" min-width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
- <el-form-item
|
|
|
- :prop="'list.' + $index + '.checkQuantity'"
|
|
|
- :rules="rules.checkQuantity"
|
|
|
- :inline-message="true"
|
|
|
- >
|
|
|
- <el-input-number
|
|
|
- v-model="row.checkQuantity"
|
|
|
- :precision="4"
|
|
|
- :controls="false"
|
|
|
- :min="0"
|
|
|
- @change="() => handleChange($index)"
|
|
|
- />
|
|
|
+ <el-form-item :prop="'list.' + $index + '.checkQuantity'" :rules="rules.checkQuantity" :inline-message="true">
|
|
|
+ <el-input-number v-model="row.checkQuantity" :precision="4" :controls="false" :min="0" @change="handleChange" />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="result" label="盘点结果" />
|
|
|
- <el-table-column
|
|
|
- prop="zip"
|
|
|
- label="操作"
|
|
|
- width="100"
|
|
|
- v-if="modalType == 'add'"
|
|
|
- >
|
|
|
+ <el-table-column prop="zip" label="操作" width="100" v-if="modalType == 'add'">
|
|
|
<template #default="{ $index }">
|
|
|
- <el-button type="primary" link @click="handleRemove($index)"
|
|
|
- >删除</el-button
|
|
|
- >
|
|
|
+ <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -112,26 +58,30 @@
|
|
|
</byForm>
|
|
|
<template #footer v-if="modalType == 'add'">
|
|
|
<el-button @click="dialogVisible = false" size="large">取 消</el-button>
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- @click="submitForm('byform')"
|
|
|
- size="large"
|
|
|
- :loading="submitLoading"
|
|
|
- >
|
|
|
+ <el-button type="primary" @click="submitForm('byform')" size="large" :loading="submitLoading">
|
|
|
确 定
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
- <el-dialog
|
|
|
- v-model="openProduct"
|
|
|
- title="选择物品"
|
|
|
- width="70%"
|
|
|
- append-to-body
|
|
|
- >
|
|
|
- <SelectGoods
|
|
|
- @cancel="openProduct = false"
|
|
|
- @pushGoods="pushGoods"
|
|
|
- ></SelectGoods>
|
|
|
+ <el-dialog v-model="openProduct" title="选择物品" width="70%" append-to-body destroy-on-close>
|
|
|
+ <SelectGoods @cancel="openProduct = false" @pushGoods="pushGoods" :selectList="acquireSelectList()" :isInventory="true"
|
|
|
+ :warehouseId="formData.data.warehouseId"></SelectGoods>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog v-model="openExcel" title="Excel导入" width="30%" append-to-body>
|
|
|
+ <div v-loading="excelLoading">
|
|
|
+ <div style="margin: 15px 0">
|
|
|
+ <el-button @click="downloadTemplate" type="primary">Excel模板下载</el-button>
|
|
|
+ </div>
|
|
|
+ <el-upload :action="actionUrl + '/stockCheck/excelImport'" :data="importData" :headers="headers"
|
|
|
+ :before-upload="useImportExcelStore().updateRequestHeaders" :on-success="handleSuccess" :on-progress="handleProgress"
|
|
|
+ :show-file-list="false" :on-error="handleError" accept=".xls, .xlsx">
|
|
|
+ <el-button type="primary" plain>点击导入</el-button>
|
|
|
+ </el-upload>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="openExcel = false" size="large">取 消</el-button>
|
|
|
+ </template>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -144,7 +94,9 @@ import byForm from "@/components/byForm/index";
|
|
|
import { computed, defineComponent, ref } from "vue";
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
import SelectGoods from "@/components/product/SelectGoods";
|
|
|
-
|
|
|
+const actionUrl = import.meta.env.VITE_APP_BASE_API;
|
|
|
+import useImportExcelStore from "@/store/modules/importExcel";
|
|
|
+const headers = computed(() => useImportExcelStore().requestHeaders);
|
|
|
const loading = ref(false);
|
|
|
const submitLoading = ref(false);
|
|
|
const sourceList = ref({
|
|
@@ -410,41 +362,93 @@ const handleSelect = (row) => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+const acquireSelectList = () => {
|
|
|
+ let data = [];
|
|
|
+ if (formData.data.list && formData.data.list.length > 0) {
|
|
|
+ data = formData.data.list.map((item) => {
|
|
|
+ return {
|
|
|
+ id: item.productId,
|
|
|
+ name: item.productName,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+};
|
|
|
+
|
|
|
const pushGoods = (goods) => {
|
|
|
- const arr = goods.map((x) => ({
|
|
|
- productId: x.id,
|
|
|
- quantity: "",
|
|
|
- checkQuantity: "",
|
|
|
- productName: x.name,
|
|
|
- productCode: x.code,
|
|
|
- productUnit: x.unit,
|
|
|
- }));
|
|
|
- const ids = arr.map((x) => x.productId);
|
|
|
- if (formData.data.warehouseId) {
|
|
|
- proxy
|
|
|
- .post("/stock/pageByWarehouse", {
|
|
|
- id: formData.data.warehouseId,
|
|
|
- productIds: ids,
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- const productList = res.rows;
|
|
|
- for (let i = 0; i < productList.length; i++) {
|
|
|
- const e = productList[i];
|
|
|
- for (let j = 0; j < arr.length; j++) {
|
|
|
- const jele = arr[j];
|
|
|
- if (e.productId === jele.productId) {
|
|
|
- formData.data.list.push({ ...jele, quantity: e.quantity });
|
|
|
- }
|
|
|
- }
|
|
|
+ if (goods && goods.length > 0) {
|
|
|
+ let afterFiltering = [];
|
|
|
+ if (formData.data.list && formData.data.list.length > 0) {
|
|
|
+ afterFiltering = goods.filter((item) => {
|
|
|
+ let data = formData.data.list.filter(
|
|
|
+ (itemProduct) => itemProduct.productId === item.id
|
|
|
+ );
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ return false;
|
|
|
}
|
|
|
+ return true;
|
|
|
});
|
|
|
+ } else {
|
|
|
+ afterFiltering = goods;
|
|
|
+ }
|
|
|
+ formData.data.list = formData.data.list.concat(
|
|
|
+ afterFiltering.map((x) => {
|
|
|
+ return {
|
|
|
+ productId: x.id,
|
|
|
+ quantity: x.stockQuantity || 0,
|
|
|
+ checkQuantity: null,
|
|
|
+ productName: x.name,
|
|
|
+ productCode: x.code,
|
|
|
+ productUnit: x.unit,
|
|
|
+ };
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ ElMessage({
|
|
|
+ message: "添加成功!",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ openProduct.value = false;
|
|
|
+ } else {
|
|
|
+ ElMessage("请选择至少一件商品");
|
|
|
}
|
|
|
- return ElMessage({
|
|
|
- message: "添加成功,已为你自动过滤库存数量为0的数据 !",
|
|
|
- type: "success",
|
|
|
- });
|
|
|
};
|
|
|
|
|
|
+// const pushGoods = (goods) => {
|
|
|
+// const arr = goods.map((x) => ({
|
|
|
+// productId: x.id,
|
|
|
+// quantity: "",
|
|
|
+// checkQuantity: "",
|
|
|
+// productName: x.name,
|
|
|
+// productCode: x.code,
|
|
|
+// productUnit: x.unit,
|
|
|
+// }));
|
|
|
+// const ids = arr.map((x) => x.productId);
|
|
|
+// if (formData.data.warehouseId) {
|
|
|
+// proxy
|
|
|
+// .post("/stock/pageByWarehouse", {
|
|
|
+// id: formData.data.warehouseId,
|
|
|
+// productIds: ids,
|
|
|
+// })
|
|
|
+// .then((res) => {
|
|
|
+// const productList = res.rows;
|
|
|
+// for (let i = 0; i < productList.length; i++) {
|
|
|
+// const e = productList[i];
|
|
|
+// for (let j = 0; j < arr.length; j++) {
|
|
|
+// const jele = arr[j];
|
|
|
+// if (e.productId === jele.productId) {
|
|
|
+// formData.data.list.push({ ...jele, quantity: e.quantity });
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// return ElMessage({
|
|
|
+// message: "添加成功,已为你自动过滤库存数量为0的数据 !",
|
|
|
+// type: "success",
|
|
|
+// });
|
|
|
+// };
|
|
|
+
|
|
|
const handleRemove = (index) => {
|
|
|
formData.data.list.splice(index, 1);
|
|
|
return ElMessage({
|
|
@@ -481,23 +485,36 @@ const handleRemove = (index) => {
|
|
|
// }
|
|
|
// });
|
|
|
|
|
|
-const handleChange = (index) => {
|
|
|
- if (!formData.data.list[index].quantity) return;
|
|
|
- if (
|
|
|
- formData.data.list[index].quantity > formData.data.list[index].checkQuantity
|
|
|
- ) {
|
|
|
- formData.data.list[index].result = "盘亏";
|
|
|
- }
|
|
|
- if (
|
|
|
- formData.data.list[index].quantity ==
|
|
|
- formData.data.list[index].checkQuantity
|
|
|
- ) {
|
|
|
- formData.data.list[index].result = "正常";
|
|
|
- }
|
|
|
- if (
|
|
|
- formData.data.list[index].quantity < formData.data.list[index].checkQuantity
|
|
|
- ) {
|
|
|
- formData.data.list[index].result = "盘盈";
|
|
|
+// const handleChange = (index) => {
|
|
|
+// if (!formData.data.list[index].quantity) return;
|
|
|
+// if (
|
|
|
+// formData.data.list[index].quantity > formData.data.list[index].checkQuantity
|
|
|
+// ) {
|
|
|
+// formData.data.list[index].result = "盘亏";
|
|
|
+// }
|
|
|
+// if (
|
|
|
+// formData.data.list[index].quantity ==
|
|
|
+// formData.data.list[index].checkQuantity
|
|
|
+// ) {
|
|
|
+// formData.data.list[index].result = "正常";
|
|
|
+// }
|
|
|
+// if (
|
|
|
+// formData.data.list[index].quantity < formData.data.list[index].checkQuantity
|
|
|
+// ) {
|
|
|
+// formData.data.list[index].result = "盘盈";
|
|
|
+// }
|
|
|
+// };
|
|
|
+
|
|
|
+const handleChange = () => {
|
|
|
+ for (let i = 0; i < formData.data.list.length; i++) {
|
|
|
+ const ele = formData.data.list[i];
|
|
|
+ if (Number(ele.quantity) > Number(ele.checkQuantity)) {
|
|
|
+ formData.data.list[i].result = "盘亏";
|
|
|
+ } else if (Number(ele.quantity) == Number(ele.checkQuantity)) {
|
|
|
+ formData.data.list[i].result = "正常";
|
|
|
+ } else if (Number(ele.quantity) < Number(ele.checkQuantity)) {
|
|
|
+ formData.data.list[i].result = "盘盈";
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -555,6 +572,69 @@ const getSummaries = (param) => {
|
|
|
});
|
|
|
return sums;
|
|
|
};
|
|
|
+const importData = ref({});
|
|
|
+const excelImport = () => {
|
|
|
+ openExcel.value = true;
|
|
|
+ importData.value = {
|
|
|
+ warehouseId: formData.data.warehouseId,
|
|
|
+ };
|
|
|
+};
|
|
|
+const excelLoading = ref(false);
|
|
|
+const openExcel = ref(false);
|
|
|
+const downloadTemplate = () => {
|
|
|
+ fetch("/static/InventoryImportTemplate.xlsx")
|
|
|
+ .then((res) => res.blob())
|
|
|
+ .then((res) => {
|
|
|
+ const url = window.URL.createObjectURL(res);
|
|
|
+ let filename = "库存盘点导入模板.xlsx";
|
|
|
+ const link = document.createElement("a");
|
|
|
+ link.style.display = "none";
|
|
|
+ link.href = url;
|
|
|
+ link.setAttribute("download", filename);
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const handleProgress = () => {
|
|
|
+ excelLoading.value = true;
|
|
|
+};
|
|
|
+const handleSuccess = (res) => {
|
|
|
+ if (res.code != 200) {
|
|
|
+ excelLoading.value = false;
|
|
|
+ return ElMessage({
|
|
|
+ message: `${res.msg},请重试!`,
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ ElMessage({
|
|
|
+ message: "导入成功!",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ if (res && res.data && res.data.length > 0) {
|
|
|
+ formData.data.list = res.data.map((x) => ({
|
|
|
+ productId: x.productId,
|
|
|
+ quantity: Number(x.stockCount) || 0,
|
|
|
+ checkQuantity: Number(x.count) || 0,
|
|
|
+ productName: x.productName,
|
|
|
+ productCode: x.productCustomCode,
|
|
|
+ productUnit: x.productUnit,
|
|
|
+ }));
|
|
|
+ handleChange();
|
|
|
+ }
|
|
|
+ openExcel.value = false;
|
|
|
+ excelLoading.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const handleError = (err) => {
|
|
|
+ ElMessage({
|
|
|
+ message: `${err},请重试!`,
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ openExcel.value = false;
|
|
|
+ excelLoading.value = false;
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|