123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- <template>
- <div class="tenant">
- <div class="content">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- :selectConfig="selectConfig"
- highlight-current-row
- :action-list="[
- {
- text: '手动出库',
- action: () => openModal(),
- },
- ]"
- @get-list="getList"
- >
- </byTable>
- </div>
- <el-dialog
- title="手动出库"
- v-if="dialogVisible"
- v-model="dialogVisible"
- width="1000"
- v-loading="loadingDialog"
- >
- <byForm
- :formConfig="formConfig"
- :formOption="formOption"
- v-model="formData.data"
- :rules="rules"
- ref="submit"
- >
- <template #workOrderId>
- <div style="width: 100%">
- <el-button type="primary" @click="openOrder = true"
- >选择工单</el-button
- >
- <div style="margin-top: 10px" v-if="selectOrder">
- 已选择: {{ selectOrder }}
- </div>
- </div>
- </template>
- <template #details>
- <div style="width: 100%">
- <el-button type="primary" @click="clickAdd()">添加明细</el-button>
- <el-table
- :data="formData.data.list"
- style="width: 100%; margin-top: 16px"
- >
- <el-table-column
- prop="productCode"
- label="产品编码"
- width="140"
- />
- <el-table-column
- prop="productName"
- label="产品名称"
- min-width="160"
- />
- <el-table-column
- prop="productSpec"
- label="规格型号"
- width="160"
- />
- <el-table-column
- prop="productUnit"
- label="单位"
- width="100"
- :formatter="
- (row) => dictValueLabel(row.productUnit, productUnit)
- "
- />
- <el-table-column
- prop="productQuantity"
- label="库存数量"
- width="120"
- />
- <el-table-column label="出库数量" width="160">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item
- :prop="'list.' + $index + '.quantity'"
- :rules="rules.quantity"
- :inline-message="true"
- >
- <el-input-number
- v-model="row.quantity"
- placeholder="请输入出库数量"
- style="width: 100%"
- :precision="0"
- :controls="false"
- :min="1"
- onmousewheel="return false;"
- />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="操作"
- width="80"
- fixed="right"
- >
- <template #default="{ row, $index }">
- <el-button type="primary" link @click="handleDelete($index)"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="dialogVisible = false" size="large">取 消</el-button>
- <el-button type="primary" @click="submitForm()" size="large"
- >确 定</el-button
- >
- </template>
- </el-dialog>
- <el-dialog
- v-model="openProduct"
- title="选择商品"
- width="80%"
- append-to-body
- >
- <InventoryInquiry
- :selectStatus="true"
- :warehouseId="formData.data.warehouseId"
- @cancel="openProduct = false"
- @select="pushGoods"
- :key="formData.data.warehouseId"
- >
- </InventoryInquiry>
- </el-dialog>
- <el-dialog
- v-model="openOrder"
- title="工单选择"
- width="80%"
- append-to-body
- destroy-on-close
- >
- <WorkOrder :isShowSelect="true" @handleSelectRow="handleSelectRow">
- </WorkOrder>
- <template #footer>
- <el-button @click="openOrder = false" size="large">取 消</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import { computed, ref } from "vue";
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import { ElMessage } from "element-plus";
- import InventoryInquiry from "@/views/purchaseSales/outAndInWarehouse/inventoryInquiry/index";
- import WorkOrder from "@/views/JXSK/production/workOrder/index";
- import useUserStore from "@/store/modules/user";
- const { proxy } = getCurrentInstance();
- const warehouseList = ref([]);
- const productUnit = ref([]);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- keyword: "",
- warehouseId: "",
- type: "2",
- },
- });
- const loading = ref(false);
- const selectConfig = computed(() => {
- return [
- {
- label: "仓库名称",
- prop: "warehouseId",
- data: warehouseList.value,
- },
- ];
- });
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "仓库名称",
- prop: "warehouseName",
- width: 220,
- },
- },
- {
- attrs: {
- label: "关联工单号",
- prop: "workOrderCode",
- width: 120,
- },
- },
- {
- attrs: {
- label: "物品编码",
- prop: "productCode",
- width: 160,
- },
- },
- {
- attrs: {
- label: "物品名称",
- prop: "productName",
- "min-width": 220,
- },
- },
- {
- attrs: {
- label: "规格型号",
- prop: "productSpec",
- width: 160,
- },
- },
- {
- attrs: {
- label: "单位",
- prop: "productUnit",
- width: 120,
- },
- render(unit) {
- return proxy.dictValueLabel(unit, productUnit.value);
- },
- },
- {
- attrs: {
- label: "出库数量",
- prop: "quantity",
- width: 140,
- },
- },
- {
- attrs: {
- label: "操作人",
- prop: "opUserName",
- width: 140,
- },
- },
- {
- attrs: {
- label: "操作时间",
- prop: "createTime",
- width: 160,
- },
- },
- ];
- });
- const getDict = () => {
- proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
- if (res.rows && res.rows.length > 0) {
- warehouseList.value = res.rows.map((item) => {
- return {
- label: item.name,
- value: item.id,
- };
- });
- }
- });
- proxy.getDictOne(["unit"]).then((res) => {
- productUnit.value = res["unit"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- });
- };
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy
- .post("/stockJournalDetails/page", sourceList.value.pagination)
- .then((res) => {
- sourceList.value.data = res.rows;
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getDict();
- getList();
- const dialogVisible = ref(false);
- const loadingDialog = ref(false);
- const submit = ref(null);
- const openProduct = ref(false);
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const formData = reactive({
- data: {},
- });
- const formConfig = computed(() => {
- return [
- {
- label: "基本信息",
- },
- {
- type: "select",
- prop: "warehouseId",
- label: "仓库名称",
- required: true,
- data: warehouseList.value,
- fn: () => {
- changeWarehouse();
- },
- },
- {
- type: "slot",
- slotName: "workOrderId",
- label: "绑定工单",
- },
- {
- type: "slot",
- slotName: "details",
- label: "出库明细",
- },
- {
- type: "input",
- prop: "exWarehousePerson",
- label: "出库人",
- itemWidth: 50,
- },
- {
- type: "input",
- prop: "receivingPerson",
- label: "接收人",
- itemWidth: 50,
- },
- ];
- });
- const rules = ref({
- warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
- quantity: [{ required: true, message: "请输入出库数量", trigger: "blur" }],
- exWarehousePerson: [
- { required: true, message: "请输入出库人", trigger: "blur" },
- ],
- receivingPerson: [
- { required: true, message: "请输入接收人", trigger: "blur" },
- ],
- });
- const openModal = () => {
- formData.data = {
- type: "2",
- exWarehousePerson: useUserStore().user.nickName,
- list: [],
- };
- loadingDialog.value = false;
- dialogVisible.value = true;
- };
- const clickAdd = () => {
- if (formData.data.warehouseId) {
- openProduct.value = true;
- } else {
- ElMessage("请先选择仓库");
- }
- };
- const changeWarehouse = () => {
- formData.data.list = [];
- };
- const select = (item) => {
- if (formData.data.list && formData.data.list.length > 0) {
- let data = formData.data.list.filter(
- (row) => row.productId === item.productId
- );
- if (data && data.length > 0) {
- return ElMessage("请勿重复添加");
- }
- }
- formData.data.list.push({
- productCode: item.productCode,
- productId: item.productId,
- productName: item.productName,
- productSpec: item.productSpec,
- productUnit: item.productUnit,
- productQuantity: item.quantity,
- quantity: undefined,
- });
- ElMessage({
- message: "添加成功!",
- type: "success",
- });
- };
- const pushGoods = (goods) => {
- const arr = goods.map((item) => ({
- productCode: item.productCode,
- productId: item.productId,
- productName: item.productName,
- productSpec: item.productSpec,
- productUnit: item.productUnit,
- productQuantity: item.quantity,
- quantity: undefined,
- }));
- formData.data.list = formData.data.list.concat(arr);
- openProduct.value = false;
- return ElMessage({
- message: "添加成功!",
- type: "success",
- });
- };
- const submitForm = () => {
- submit.value.handleSubmit(() => {
- if (!formData.data.workOrderId) {
- return ElMessage({
- message: "请绑定工单!",
- type: "info",
- });
- }
- if (formData.data.list && formData.data.list.length > 0) {
- for (let i = 0; i < formData.data.list.length; i++) {
- if (
- formData.data.list[i].productQuantity < formData.data.list[i].quantity
- ) {
- return ElMessage("出库数量不能大于库存数量");
- }
- }
- } else {
- return ElMessage("请添加出库产品");
- }
- loadingDialog.value = true;
- proxy.post("/stock/edit", formData.data).then(
- () => {
- ElMessage({
- message: "提交成功",
- type: "success",
- });
- dialogVisible.value = false;
- getList();
- },
- (err) => {
- console.log(err);
- loadingDialog.value = false;
- }
- );
- });
- };
- const handleDelete = (index) => {
- formData.data.list.splice(index, 1);
- };
- const openOrder = ref(false);
- const selectOrder = ref("");
- const handleSelectRow = (row) => {
- formData.data.workOrderId = row.id;
- selectOrder.value = row.code;
- ElMessage({
- message: "选择成功",
- type: "success",
- });
- openOrder.value = false;
- };
- </script>
- <style lang="scss" scoped>
- .tenant {
- padding: 20px;
- }
- ::v-deep(.el-input-number .el-input__inner) {
- text-align: left;
- }
- </style>
|