|
@@ -0,0 +1,729 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="bg-in-stock" v-loading="loading">
|
|
|
|
+ <el-form ref="goodsInventoryAddFormRef" :model="goodsInventoryAddForm" :rules="goodsInventoryAddFormRule" label-width="120px" inline class="change-form">
|
|
|
|
+ <h3 style="width: 100%">盘点单</h3>
|
|
|
|
+ <el-form-item label="盘点编号" prop="sn" v-if="type === 'edit' || type === 'detail'" class="change-form-item">
|
|
|
|
+ <el-input v-model="goodsInventoryAddForm.sn" :disabled="true"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="盘点时间" prop="inventory_time" class="change-form-item">
|
|
|
|
+ <span v-if="id && type !== 'edit'">{{ goodsInventoryAddForm.inventory_time }}</span>
|
|
|
|
+ <el-date-picker
|
|
|
|
+ v-else
|
|
|
|
+ v-model="goodsInventoryAddForm.inventory_time"
|
|
|
|
+ format="YYYY-MM-DD HH:mm:ss"
|
|
|
|
+ value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
|
+ type="datetime"
|
|
|
|
+ :disabled="type === 'detail' || type === 'audit' || type === 'check'"
|
|
|
|
+ placeholder="选择日期时间"
|
|
|
|
+ >
|
|
|
|
+ </el-date-picker>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="仓库" prop="warehouse_id" class="change-form-item">
|
|
|
|
+ <span v-if="id && type !== 'edit'">{{ getWarehouse(goodsInventoryAddForm.warehouse_id) }}</span>
|
|
|
|
+ <el-select
|
|
|
|
+ v-else
|
|
|
|
+ v-model="goodsInventoryAddForm.warehouse_id"
|
|
|
|
+ @change="handleChangeWareHouse"
|
|
|
|
+ :disabled="type === 'detail' || type === 'audit' || type === 'check'"
|
|
|
|
+ >
|
|
|
|
+ <el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="盘点人" prop="inventory_person_id" class="change-form-item">
|
|
|
|
+ <span v-if="id && type !== 'edit'">{{ getadminList(goodsInventoryAddForm.inventory_person_id) }}</span>
|
|
|
|
+ <el-select
|
|
|
|
+ v-else
|
|
|
|
+ @change="forceUpdate"
|
|
|
|
+ v-model="goodsInventoryAddForm.inventory_person_id"
|
|
|
|
+ :disabled="type === 'detail' || type === 'audit' || type === 'check'"
|
|
|
|
+ >
|
|
|
|
+ <el-option v-for="item in adminList" :key="item.id" :label="item.nickname" :value="item.id" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="制单人" prop="creator_id" class="change-form-item">
|
|
|
|
+ <span v-if="id && type !== 'edit'">{{ getadminList(goodsInventoryAddForm.creator_id) }}</span>
|
|
|
|
+ <el-select
|
|
|
|
+ v-else
|
|
|
|
+ v-model="goodsInventoryAddForm.creator_id"
|
|
|
|
+ :disabled="type === 'detail' || type === 'audit' || type === 'check'"
|
|
|
|
+ @change="forceUpdate"
|
|
|
|
+ >
|
|
|
|
+ <el-option v-for="item in adminList" :key="item.id" :label="item.nickname" :value="item.id" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="盘点类型" prop="inventory_type" class="change-form-item">
|
|
|
|
+ <span v-if="id && type !== 'edit'">{{ getRoleSplit(goodsInventoryAddForm.inventory_type) }}</span>
|
|
|
|
+ <el-select
|
|
|
|
+ v-else
|
|
|
|
+ v-model="goodsInventoryAddForm.inventory_type"
|
|
|
|
+ @change="handleChangeInventoryType($event)"
|
|
|
|
+ :disabled="type === 'detail' || type === 'audit' || type === 'check'"
|
|
|
|
+ >
|
|
|
|
+ <el-option v-for="item in typeList" :key="item.id" :label="item.label" :value="item.value" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="是否通知审核人:" prop="has_notice" class="change-form-item">
|
|
|
|
+ <el-switch v-model="goodsInventoryAddForm.has_notice" inline-prompt :active-text="true" :inactive-text="false" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="审核人:" prop="notice_user_id" class="change-form-item" v-if="goodsInventoryAddForm.has_notice">
|
|
|
|
+ <el-select v-model="goodsInventoryAddForm.notice_user_id" :disabled="type === 'detail' || type === 'audit' || type === 'check'">
|
|
|
|
+ <el-option v-for="item in auditList" :key="item.id" :label="item.nickname" :value="item.id" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <div class="mx">
|
|
|
|
+ <h3>商品明细</h3>
|
|
|
|
+ <el-button class="button" size="mini" type="primary" v-if="type !== 'detail' && type !== 'check'" @click="scanCode">商品扫码</el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ class="button"
|
|
|
|
+ size="mini"
|
|
|
|
+ type="primary"
|
|
|
|
+ v-if="type !== 'detail' && type !== 'check'"
|
|
|
|
+ @click="handleSelectWarehouseEntryBatch"
|
|
|
|
+ :disabled="selectBtn"
|
|
|
|
+ >选择</el-button
|
|
|
|
+ >
|
|
|
|
+ </div>
|
|
|
|
+ <div style="width: 100%; display: block">
|
|
|
|
+ <el-form-item style="width: 100%">
|
|
|
|
+ <el-table
|
|
|
|
+ :data="goodsInventoryAddForm.product_list"
|
|
|
|
+ border
|
|
|
|
+ :cell-style="{ textAlign: 'center' }"
|
|
|
|
+ :header-cell-style="{ textAlign: 'center' }"
|
|
|
|
+ :loading="loading"
|
|
|
|
+ style="width: 100%; margin-top: 20px"
|
|
|
|
+ >
|
|
|
|
+ <el-table-column label="库位号">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-popover placement="right" trigger="click" v-if="scope.row.area_stock_list">
|
|
|
|
+ <div>
|
|
|
|
+ <p v-for="item in scope.row.area_stock_list" :key="item.id">{{ item.warehouse_area_name }}</p>
|
|
|
|
+ </div>
|
|
|
|
+ <span slot="reference" v-if="scope.row.area_stock_list.length !== 0">{{ scope.row.area_stock_list[0].warehouse_area_name }}</span>
|
|
|
|
+ </el-popover>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <!-- <el-table-column label="商品编号">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <span v-if="id"> {{ scope.row.product_vo.sn }}</span>
|
|
|
|
+ <span v-else>{{ scope.row.product_vo.sn }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column> -->
|
|
|
|
+ <el-table-column label="商品名称">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <span v-if="id">{{ scope.row.product_vo.name }}</span>
|
|
|
|
+ <span v-else>{{ scope.row.product_vo.name }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="sku">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <span v-if="!id"> {{ scope.row.product_vo.sku }}</span>
|
|
|
|
+ <span v-else> {{ scope.row.product_vo.sku }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <!-- <el-table-column label="序列号" width="160">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <div class="sn-code-container">
|
|
|
|
+ <span v-for="item in scope.row.sn_code_list" :key="item.id">
|
|
|
|
+ <p>{{ item.sn_code }}</p>
|
|
|
|
+ </span>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column prop="product_vo.spec_name" label="规格型号"> </el-table-column> -->
|
|
|
|
+ <el-table-column label="单位">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <span v-if="!id"> {{ scope.row.product_vo.unit }}</span>
|
|
|
|
+ <span v-else> {{ scope.row.product_vo.unit }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="库存数量">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ {{ scope.row.actual_stock }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="盘点数量">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <span v-if="type === 'check'">{{ scope.row.inventory_num }}</span>
|
|
|
|
+ <el-input
|
|
|
|
+ v-else
|
|
|
|
+ v-model="scope.row.inventory_num"
|
|
|
|
+ type="number"
|
|
|
|
+ :min="0"
|
|
|
|
+ :maxlength="20"
|
|
|
|
+ :disabled="type === 'detail' || type === 'audit' || type === 'check'"
|
|
|
|
+ ></el-input>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="差异">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ {{ scope.row.inventory_num - scope.row.actual_stock || 0 }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" v-if="type !== 'detail' && type !== 'audit' && type !== 'check'">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-button size="mini" type="danger" @click="goodsInventoryAddForm.product_list.splice(scope.$index, 1)">删除</el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </div>
|
|
|
|
+ </el-form>
|
|
|
|
+ <div class="footer">
|
|
|
|
+ <el-button v-if="type !== 'audit' && type !== 'detail' && type !== 'check'" type="primary" @click="submitGoodsInventoryAddForm">保存 </el-button>
|
|
|
|
+ <el-button @click="printIng" v-if="type == 'check'">打印</el-button>
|
|
|
|
+ <el-button @click="$router.back()">返回 </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ <el-dialog title="扫码入库" v-model="scanDialogVisible" width="30%" :close-on-click-modal="false">
|
|
|
|
+ <el-form ref="scanGoodsForm" :model="scanGoodsForm" label-width="120px" inline>
|
|
|
|
+ <el-form-item label="sku" prop="bar_code">
|
|
|
|
+ <el-input v-model="scanGoodsForm.bar_code" ref="input" @keyup.enter.native="toSearch()" :minlength="0" :maxlength="100"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="序列号" prop="sn_code">
|
|
|
|
+ <el-input ref="sn_input" v-model="sn_code" @keyup.enter.native="toSnCode()" :minlength="0" :maxlength="100"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ <el-dialog title="提示" v-model="dialogVisible" width="30%">
|
|
|
|
+ <el-form ref="goodsInventoryAddForm" :model="goodsInventoryAddForm" label-width="120px" inline style="width: 900px">
|
|
|
|
+ <el-form-item label="驳回原因" prop="reject_reason" required="true">
|
|
|
|
+ <el-input v-model="goodsInventoryAddForm.reject_reason" type="textarea" :minlength="0" :maxlength="100"></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ <template #footer>
|
|
|
|
+ <el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="handleRejectGoodsInventory()">确 定</el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ <el-dialog title="盘点商品" v-model="goodsVisible" width="1000px" @close="closeGoosData">
|
|
|
|
+ <div style="display: flex; align-items: center; justify-content: flex-end; padding: 10px 0">
|
|
|
|
+ <span>搜索商品:</span><el-input v-model="params.keyWord" style="width: 200px; margin-right: 5px"></el-input>
|
|
|
|
+ <el-button @click="searchGoodEvent"> 搜索 </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ <el-table :data="goodsData.records" border style="width: 100%" @selection-change="handleSelectionChange">
|
|
|
|
+ <el-table-column type="selection" width="55" />
|
|
|
|
+ <el-table-column prop="product_vo.name" label="商品名称"></el-table-column>
|
|
|
|
+ <el-table-column prop="product_vo.sku" label="sku"> </el-table-column>
|
|
|
|
+ <el-table-column prop="" label="品牌">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ {{ scope.row.product_vo.brand }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column prop="product_vo.weight" label="重量"> </el-table-column>
|
|
|
|
+ <el-table-column prop="product_vo.unit" label="单位"> </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ <el-pagination
|
|
|
|
+ @size-change="goodsPageSizeChange"
|
|
|
|
+ @current-change="goodsPageCurrentChange"
|
|
|
|
+ :current-page="goodsData.current"
|
|
|
|
+ :page-sizes="[10, 20, 50, 100]"
|
|
|
|
+ :page-size="goodsData.size"
|
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
+ :total="goodsData.total"
|
|
|
|
+ >
|
|
|
|
+ </el-pagination>
|
|
|
|
+ <template #footer>
|
|
|
|
+ <el-button @click="closeGoosData">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="submitGoosData()">确 定</el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+ <script lang="ts" setup>
|
|
|
|
+import { ref, onMounted, computed, nextTick, reactive } from 'vue';
|
|
|
|
+import { useStore, mapGetters } from 'vuex';
|
|
|
|
+/* import { Foundation, RegExp } from '~/ui-utils'; */
|
|
|
|
+import * as API_GoodsInventory from '@/api/goodsInventory';
|
|
|
|
+import * as API_GoodsExchange from '@/api/goodsExchange';
|
|
|
|
+import * as API_Setting from '@/api/setting';
|
|
|
|
+import * as API_BasicSetting from '@/api/basicSetting';
|
|
|
|
+import * as API_Auth from '@/api/auth';
|
|
|
|
+import { useRouter, useRoute } from 'vue-router';
|
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
|
+
|
|
|
|
+const router = useRouter();
|
|
|
|
+const route = useRoute();
|
|
|
|
+
|
|
|
|
+const store = useStore();
|
|
|
|
+const loading = ref(false);
|
|
|
|
+const adminList = ref<any>([]);
|
|
|
|
+const dialogVisible = ref(false);
|
|
|
|
+const warehouseList = ref<any>([]);
|
|
|
|
+const deptList = ref([]);
|
|
|
|
+const deptListAll = ref([]);
|
|
|
|
+const id = ref('');
|
|
|
|
+const type = ref('');
|
|
|
|
+const goodsInventoryAddForm = ref<any>({
|
|
|
|
+ product_list: [],
|
|
|
|
+ inventory_time: '',
|
|
|
|
+ inventory_person_id: '',
|
|
|
|
+ creator_id: '',
|
|
|
|
+ has_notice: false,
|
|
|
|
+});
|
|
|
|
+const goodsInventoryAddFormRule = ref({
|
|
|
|
+ inventory_person_id: { required: true, message: '请选择盘点人', trigger: 'change' },
|
|
|
|
+ warehouse_id: { required: true, message: '请选择报损仓库', trigger: 'change' },
|
|
|
|
+ dept_id: { required: true, message: '请选择所属部门', trigger: 'change' },
|
|
|
|
+ creator_id: { required: true, message: '请选择制单人', trigger: 'change' },
|
|
|
|
+});
|
|
|
|
+const warehouseProduct = ref(null);
|
|
|
|
+const typeList = ref([]);
|
|
|
|
+const scanDialogVisible = ref(false);
|
|
|
|
+const scanGoodsForm = ref<any>({});
|
|
|
|
+const sn_code = ref('');
|
|
|
|
+const sn_code_list = ref([]);
|
|
|
|
+const index = ref('');
|
|
|
|
+const selectBtn = ref(false);
|
|
|
|
+/* 盘点商品信息 操作部分 */
|
|
|
|
+const goodsVisible = ref(false);
|
|
|
|
+const goodsData = ref<any>([]);
|
|
|
|
+const params = reactive({
|
|
|
|
+ page_no: 1,
|
|
|
|
+ page_size: 10,
|
|
|
|
+ keyWord: '',
|
|
|
|
+});
|
|
|
|
+/* 关闭盘点商品 */
|
|
|
|
+const closeGoosData = () => {
|
|
|
|
+ goodsVisible.value = false;
|
|
|
|
+};
|
|
|
|
+/* 搜索盘点商品 */
|
|
|
|
+const searchGoodEvent = () => {
|
|
|
|
+ API_GoodsExchange.getGoodsInfo(params, goodsInventoryAddForm.value.warehouse_id).then((res) => {
|
|
|
|
+ goodsData.value = res;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+/* 选中的商品列表 */
|
|
|
|
+const goodsList = ref([]);
|
|
|
|
+const handleSelectionChange = (val) => {
|
|
|
|
+ goodsList.value = val.map((el) => {
|
|
|
|
+ /* el.product_id = el.id;
|
|
|
|
+ el.goods_id = el.id;
|
|
|
|
+ el.sn_code_list = []; */
|
|
|
|
+ return el;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+const submitGoosData = () => {
|
|
|
|
+ if (goodsList.value.length >= 1) {
|
|
|
|
+ goodsInventoryAddForm.value.product_list = goodsList.value.map((el) => {
|
|
|
|
+ /* el.sn_code_list = []; */
|
|
|
|
+ return el;
|
|
|
|
+ });
|
|
|
|
+ goodsVisible.value = false;
|
|
|
|
+ } else {
|
|
|
|
+ ElMessage.error('请选择商品信息');
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+/* 盘点商品分页 */
|
|
|
|
+const goodsPageSizeChange = (size) => {
|
|
|
|
+ params.page_size = size;
|
|
|
|
+ searchGoodEvent();
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const goodsPageCurrentChange = (page) => {
|
|
|
|
+ params.page_no = page;
|
|
|
|
+ searchGoodEvent();
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const user = computed(() => store.getters.user);
|
|
|
|
+const timeDefault = computed(() => {
|
|
|
|
+ const date = new Date();
|
|
|
|
+ return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
|
|
|
|
+});
|
|
|
|
+/* 获取审核人列表 */
|
|
|
|
+const auditList = ref<any>([]);
|
|
|
|
+const GET_AuditList = () => {
|
|
|
|
+ API_GoodsInventory.getUserByCompany().then((res) => {
|
|
|
|
+ auditList.value = res;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+onMounted(() => {
|
|
|
|
+ if (route.query.type === 'view') {
|
|
|
|
+ type.value = 'view';
|
|
|
|
+ id.value = route.query.id;
|
|
|
|
+ GET_goodsInventoryAddDetail();
|
|
|
|
+ }else{
|
|
|
|
+ type.value = 'edit';
|
|
|
|
+ id.value = route.query.id;
|
|
|
|
+ GET_goodsInventoryAddDetail();
|
|
|
|
+ }
|
|
|
|
+ /* if (route.name === 'goodsInventoryAdd') {
|
|
|
|
+ goodsInventoryAddForm.value.creator_id = user.value.uid;
|
|
|
|
+ goodsInventoryAddForm.value.inventory_person_id = user.value.uid;
|
|
|
|
+ goodsInventoryAddForm.value.dept_id = user.value.dept_id;
|
|
|
|
+ //goodsInventoryAddForm.value.inventory_time = timeDefault.value;
|
|
|
|
+ } else if (route.name === 'goodsInventoryDetail') {
|
|
|
|
+ type.value = 'detail';
|
|
|
|
+ } else if (route.query.type === 'view') {
|
|
|
|
+ type.value = 'check';
|
|
|
|
+ id.value = store.state.route.params.id;
|
|
|
|
+ GET_goodsInventoryAddDetail();
|
|
|
|
+ GET_AdministratorList();
|
|
|
|
+ GET_WarehouseList();
|
|
|
|
+ } else if (route.name === 'goodsInventoryEdit') {
|
|
|
|
+ type.value = 'edit';
|
|
|
|
+ goodsInventoryAddForm.value.creator_id = user.value.uid;
|
|
|
|
+ goodsInventoryAddForm.value.inventory_person_id = user.value.uid;
|
|
|
|
+ goodsInventoryAddForm.value.dept_id = user.value.dept_id;
|
|
|
|
+ //goodsInventoryAddForm.value.inventory_time = timeDefault.value;
|
|
|
|
+ id.value = store.state.route.params.id;
|
|
|
|
+ GET_goodsInventoryAddDetail();
|
|
|
|
+ GET_AdministratorList();
|
|
|
|
+ GET_WarehouseList();
|
|
|
|
+ } */
|
|
|
|
+ GET_AdministratorList();
|
|
|
|
+ GET_WarehouseList();
|
|
|
|
+ GET_DeptList();
|
|
|
|
+ GET_AuditList();
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const handleChangeInventoryType = (val: string) => {
|
|
|
|
+ goodsInventoryAddForm.value.product_list = [];
|
|
|
|
+ if (val === 'ALL_INVENTORY') {
|
|
|
|
+ if (!goodsInventoryAddForm.value.warehouse_id) {
|
|
|
|
+ store.dispatch('message/error', '请先选择仓库!');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ loading.value = true;
|
|
|
|
+ API_GoodsInventory.getGoodByWarehouseInventory({ page: 1, size: 10000 }, goodsInventoryAddForm.value.warehouse_id)
|
|
|
|
+ .then((res) => {
|
|
|
|
+ res.records.forEach((el) => {
|
|
|
|
+ el.sn_code_list = [];
|
|
|
|
+ });
|
|
|
|
+ goodsInventoryAddForm.value.product_list = res.records;
|
|
|
|
+ selectBtn.value = true;
|
|
|
|
+ loading.value = false;
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+ loading.value = false;
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ selectBtn.value = false;
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const input = ref();
|
|
|
|
+const toSnCode = async () => {
|
|
|
|
+ if (scanGoodsForm.value.bar_code === '') return store.dispatch('message/error', '请录入正确的sku');
|
|
|
|
+ await API_GoodsExchange.getSnCode('inventory', scanGoodsForm.value.bar_code, sn_code.value.replace(/\s+/g, '')).then(async (res) => {
|
|
|
|
+ sn_code.value = '';
|
|
|
|
+ const exists = goodsInventoryAddForm.value.product_list[index.value].sn_code_list.find((item: any) => item.sn_code === res.sn_code && item.sku === res.sku);
|
|
|
|
+ if (!exists) {
|
|
|
|
+ if (id.value) {
|
|
|
|
+ await API_GoodsExchange.skuRedis({
|
|
|
|
+ send_order_id: id.value,
|
|
|
|
+ item_id: goodsInventoryAddForm.value.product_list[index.value].id,
|
|
|
|
+ sku: res,
|
|
|
|
+ }).then(() => {
|
|
|
|
+ goodsInventoryAddForm.value.product_list[index.value].sn_code_list.push(res);
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ goodsInventoryAddForm.value.product_list[index.value].sn_code_list.push(res);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ goodsInventoryAddForm.value.product_list[index.value].inventory_num = goodsInventoryAddForm.value.product_list[index.value].sn_code_list.length;
|
|
|
|
+ scanGoodsForm.value.bar_code = '';
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ input.value.focus();
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const sn_input = ref();
|
|
|
|
+const toSearch = () => {
|
|
|
|
+ API_GoodsExchange.getProduct(goodsInventoryAddForm.value.warehouse_id, scanGoodsForm.value.bar_code.replace(/\s+/g, '')).then((res) => {
|
|
|
|
+ res.sn_code_list = [];
|
|
|
|
+ const indexs = goodsInventoryAddForm.value.product_list.findIndex(
|
|
|
|
+ (el: any) => el.goods_id === res.goods_id && el.product_id === res.product_id && el.product_vo.sku === res.product_vo.sku
|
|
|
|
+ );
|
|
|
|
+ if (indexs === -1) {
|
|
|
|
+ index.value = goodsInventoryAddForm.value.product_list.length;
|
|
|
|
+ goodsInventoryAddForm.value.product_list.push(res);
|
|
|
|
+ } else {
|
|
|
|
+ index.value = indexs;
|
|
|
|
+ }
|
|
|
|
+ if (res.product_vo.have_sn) {
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ sn_input.value.focus();
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ goodsInventoryAddForm.value.product_list[index.value].inventory_num += 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const scanCode = () => {
|
|
|
|
+ if (!goodsInventoryAddForm.value.warehouse_id) {
|
|
|
|
+ store.dispatch('message/error', '请选择仓库!');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (!goodsInventoryAddForm.value.inventory_type) {
|
|
|
|
+ store.dispatch('message/error', '请选择盘点类型!');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ scanDialogVisible.value = true;
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ input.value.focus();
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const getadminList = (value: string) => {
|
|
|
|
+ const type = adminList.value.find((type: any) => type.id === value);
|
|
|
|
+ return type ? type.real_name : '未知类型';
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const getRoleSplit = (value: string) => {
|
|
|
|
+ const type = typeList.value.find((type: any) => type.id === value);
|
|
|
|
+ return type ? type.label : '未知类型';
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const getWarehouse = (value: string) => {
|
|
|
|
+ const type = warehouseList.value.find((type: any) => type.id === value);
|
|
|
|
+ return type ? type.name : '未知类型';
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const printIng = () => {
|
|
|
|
+ // Implement print functionality
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const forceUpdate = () => {
|
|
|
|
+ store.dispatch('forceUpdate');
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const cleanGoodsList = () => {
|
|
|
|
+ goodsInventoryAddForm.value.product_list = [];
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const GET_AdministratorList = () => {
|
|
|
|
+ API_Auth.getAdministratorList({
|
|
|
|
+ page_no: 1,
|
|
|
|
+ page_size: 9999,
|
|
|
|
+ user_state: 0,
|
|
|
|
+ }).then((response) => {
|
|
|
|
+ adminList.value = response.data;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const handlePassGoodsInventory = () => {
|
|
|
|
+ store.dispatch('confirm', '确定通过吗?', '提示', { type: 'warning' }).then(() => {
|
|
|
|
+ API_GoodsInventory.auditGoodsInventory(id.value, { status: 'PASS' })
|
|
|
|
+ .then(() => {
|
|
|
|
+ store.dispatch('message/success', '已通过!');
|
|
|
|
+ const { callback } = store.state.route.params;
|
|
|
|
+ if (typeof callback === 'function') callback();
|
|
|
|
+ store.dispatch('delCurrentViews', {
|
|
|
|
+ view: store.state.route,
|
|
|
|
+ $router: store.state.router,
|
|
|
|
+ });
|
|
|
|
+ store.state.router.push({ name: 'goodsInventory' });
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {});
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const handleRejectGoodsInventory = () => {
|
|
|
|
+ if (!goodsInventoryAddForm.value.reject_reason) {
|
|
|
|
+ store.dispatch('message/error', '请填写驳回原因!');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ store
|
|
|
|
+ .dispatch('confirm', '确定拒绝吗?', '提示', { type: 'warning' })
|
|
|
|
+ .then(() => {
|
|
|
|
+ API_GoodsInventory.auditGoodsInventory(id.value, { status: 'REJECT', reject_reason: goodsInventoryAddForm.value.reject_reason }).then(() => {
|
|
|
|
+ store.dispatch('message/success', '已拒绝!');
|
|
|
|
+ const { callback } = store.state.route.params;
|
|
|
|
+ if (typeof callback === 'function') callback();
|
|
|
|
+ store.dispatch('delCurrentViews', {
|
|
|
|
+ view: store.state.route,
|
|
|
|
+ $router: store.state.router,
|
|
|
|
+ });
|
|
|
|
+ store.state.router.push({ name: 'goodsInventory' });
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {});
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const changewarehouseList = (e: any) => {
|
|
|
|
+ goodsInventoryAddForm.value.warehouse_id = '';
|
|
|
|
+ GET_WarehouseList({ dept_id: e });
|
|
|
|
+ cleanGoodsList();
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const GET_WarehouseList = (e?: any) => {
|
|
|
|
+ API_BasicSetting.getWarehouseListAll().then((response) => {
|
|
|
|
+ warehouseList.value = response;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const goodsInventoryAddFormRef = ref();
|
|
|
|
+const submitGoodsInventoryAddForm = () => {
|
|
|
|
+ goodsInventoryAddFormRef.value.validate((valid: boolean) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ const params = { ...goodsInventoryAddForm.value };
|
|
|
|
+ if (params.warehouse_id) {
|
|
|
|
+ params.warehouse_name = warehouseList.value.find((ware: any) => ware.id === params.warehouse_id).name;
|
|
|
|
+ }
|
|
|
|
+ if (params.creator_id) {
|
|
|
|
+ params.creator = adminList.value.find((admin: any) => admin.id === params.creator_id).real_name;
|
|
|
|
+ }
|
|
|
|
+ if (params.inventory_person_id) {
|
|
|
|
+ params.inventory_person = adminList.value.find((admin: any) => admin.id === params.inventory_person_id).real_name;
|
|
|
|
+ }
|
|
|
|
+ params.product_list = params.product_list.map((item: any) => ({
|
|
|
|
+ diff_num: item.usable_stock - item.inventory_num,
|
|
|
|
+ inventory_num: item.inventory_num * 1,
|
|
|
|
+ product_name: item.product_name,
|
|
|
|
+ product_sn: item.product_sn,
|
|
|
|
+ product_id: item.product_id,
|
|
|
|
+ specification: item.product_specification,
|
|
|
|
+ unit: item.product_unit,
|
|
|
|
+ remark: item.remark,
|
|
|
|
+ product_stock_id: item.id,
|
|
|
|
+ sn_code_list: item.sn_code_list,
|
|
|
|
+ }));
|
|
|
|
+ if (id.value) {
|
|
|
|
+ API_GoodsInventory.editgoodsInventoryAdd(id.value, params).then(() => {
|
|
|
|
+ ElMessage.success('修改成功!');
|
|
|
|
+ router.push({ name: 'goodsInventory' });
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ API_GoodsInventory.addgoodsInventoryAdd(params).then(() => {
|
|
|
|
+ ElMessage.success('添加成功!');
|
|
|
|
+ router.push({ name: 'goodsInventory' });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const handleSelectWarehouseEntryBatch = async () => {
|
|
|
|
+ if (!goodsInventoryAddForm.value.warehouse_id) {
|
|
|
|
+ store.dispatch('message/error', '请先选择仓库!');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ API_GoodsExchange.getGoodsInfo(params, goodsInventoryAddForm.value.warehouse_id, 'le').then((res) => {
|
|
|
|
+ goodsData.value = res;
|
|
|
|
+ goodsVisible.value = true;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const GET_DeptList = () => {
|
|
|
|
+ API_Setting.getPage({ dictType: 'inventory_type' }).then((res) => {
|
|
|
|
+ typeList.value = res.data;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const handleChangeWareHouse = (val: any) => {
|
|
|
|
+ goodsInventoryAddForm.value.product_list = [];
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const GET_goodsInventoryAddDetail = () => {
|
|
|
|
+ API_GoodsInventory.getGoodsInventoryInfo(route.query.id).then((response) => {
|
|
|
|
+ if (!response.product_list) {
|
|
|
|
+ response.product_list = [];
|
|
|
|
+ }
|
|
|
|
+ goodsInventoryAddForm.value = response;
|
|
|
|
+ GET_WarehouseList();
|
|
|
|
+ /* goodsInventoryAddForm.value.distribution_name = response.staff_name;
|
|
|
|
+ if (goodsInventoryAddForm.value.product_list) {
|
|
|
|
+ goodsInventoryAddForm.value.product_list = goodsInventoryAddForm.value.product_list.map((item: any) => {
|
|
|
|
+ item.inventory_num = item.inventory_num;
|
|
|
|
+ item.product_specification = item.specification;
|
|
|
|
+ item.product_unit = item.unit;
|
|
|
|
+ item.remain_num = item.stock_num;
|
|
|
|
+ return item;
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ goodsInventoryAddForm.value.product_list = [];
|
|
|
|
+ } */
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style scoped>
|
|
|
|
+.footer {
|
|
|
|
+ width: 100%;
|
|
|
|
+ padding: 10px;
|
|
|
|
+ bottom: 0px;
|
|
|
|
+ text-align: center;
|
|
|
|
+ z-index: 999;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.mx {
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ width: 100%;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.mx .button {
|
|
|
|
+ margin-left: 10px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.change-form {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: flex-start;
|
|
|
|
+ align-items: flex-start;
|
|
|
|
+ flex-wrap: wrap;
|
|
|
|
+ min-width: 900px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.change-form .change-form-item {
|
|
|
|
+ width: 30%;
|
|
|
|
+ margin: 0 10px 20px 0;
|
|
|
|
+ display: flex;
|
|
|
|
+ flex-direction: row;
|
|
|
|
+ flex-wrap: nowrap;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.change-form ::v-deep .el-form-item__content {
|
|
|
|
+ flex: 1;
|
|
|
|
+ width: 100%;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.change-form ::v-deep .el-date-editor,
|
|
|
|
+.change-form ::v-deep .el-cascader,
|
|
|
|
+.change-form ::v-deep .el-select {
|
|
|
|
+ width: 100%;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.bg-in-stock {
|
|
|
|
+ background-color: #fff;
|
|
|
|
+ margin: 10px;
|
|
|
|
+ padding: 25px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.goods-info {
|
|
|
|
+ display: flex;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.goods-info .goods-name-box {
|
|
|
|
+ text-align: left;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.goods-info .goods-name-box .goods-name {
|
|
|
|
+ text-overflow: ellipsis;
|
|
|
|
+ display: -webkit-box;
|
|
|
|
+ -webkit-line-clamp: 2;
|
|
|
|
+ -webkit-box-orient: vertical;
|
|
|
|
+ overflow: hidden;
|
|
|
|
+ line-height: 16px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.goods-info .goods-name-box .specs {
|
|
|
|
+ color: #999999;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.sn-code-container {
|
|
|
|
+ max-height: 100px;
|
|
|
|
+ overflow-y: auto;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+::v-deep .el-input--suffix .el-input__inner {
|
|
|
|
+ padding-right: 10px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+::v-deep .error-input .el-input__inner {
|
|
|
|
+ border: 1px solid red;
|
|
|
|
+}
|
|
|
|
+</style>
|