|
@@ -1,25 +1,27 @@
|
|
|
<template>
|
|
<template>
|
|
|
<el-dialog v-model="visible" title="开始盘点" width="800px" @open="onOpen" @close="onClose">
|
|
<el-dialog v-model="visible" title="开始盘点" width="800px" @open="onOpen" @close="onClose">
|
|
|
- <div class="form-row">
|
|
|
|
|
- <el-input v-model="device_code" placeholder="设备编号" @keyup.enter="handleAdd" />
|
|
|
|
|
- <el-input v-model="check_no" placeholder="盘点编号" @keyup.enter="handleAdd" />
|
|
|
|
|
- <el-button type="primary" @click="handleAdd">添加</el-button>
|
|
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <div class="form-row">
|
|
|
|
|
+ <el-input v-model="device_code" placeholder="设备编号" @keyup.enter="handleAdd" :disabled="loading" />
|
|
|
|
|
+ <el-input v-model="check_no" placeholder="盘点编号" @keyup.enter="handleAdd" :disabled="loading" />
|
|
|
|
|
+ <el-button type="primary" @click="handleAdd" :loading="loading">添加</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <el-table :data="deviceList" v-loading="loading" style="margin-top: 20px">
|
|
|
|
|
+ <el-table-column type="index" label="序号" width="60" />
|
|
|
|
|
+ <!-- <el-table-column prop="id" label="盘点id" width="60" /> -->
|
|
|
|
|
+ <el-table-column prop="device_code" label="设备编号" />
|
|
|
|
|
+ <el-table-column prop="check_no" label="盘点编号" />
|
|
|
|
|
+ <el-table-column prop="status_display" label="状态" />
|
|
|
|
|
+ <!-- <el-table-column prop="productName" label="商品名称" /> -->
|
|
|
|
|
+ </el-table>
|
|
|
</div>
|
|
</div>
|
|
|
-
|
|
|
|
|
- <el-table :data="deviceList" style="margin-top: 20px">
|
|
|
|
|
- <el-table-column type="index" label="序号" width="60" />
|
|
|
|
|
- <!-- <el-table-column prop="id" label="盘点id" width="60" /> -->
|
|
|
|
|
- <el-table-column prop="device_code" label="设备编号" />
|
|
|
|
|
- <el-table-column prop="check_no" label="盘点编号" />
|
|
|
|
|
- <el-table-column prop="status_display" label="状态" />
|
|
|
|
|
- <!-- <el-table-column prop="productName" label="商品名称" /> -->
|
|
|
|
|
- <el-table-column label="操作" width="180">
|
|
|
|
|
- <template #default="{ row }">
|
|
|
|
|
- <el-button type="success" size="small" @click="completeScan(row)" >完成盘点</el-button>
|
|
|
|
|
- <el-button type="danger" size="small" @click="cancelScan(row)" >取消盘点</el-button>
|
|
|
|
|
- </template>
|
|
|
|
|
- </el-table-column>
|
|
|
|
|
- </el-table>
|
|
|
|
|
|
|
+ <template #footer v-if="deviceList.length > 0">
|
|
|
|
|
+ <div class="dialog-footer">
|
|
|
|
|
+ <el-button @click="onCancelAll" :disabled="!currentRecordId">取消盘点</el-button>
|
|
|
|
|
+ <el-button type="primary" @click="onCompleteAll" :disabled="!check_no">完成盘点</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -27,11 +29,14 @@
|
|
|
import { ref } from 'vue';
|
|
import { ref } from 'vue';
|
|
|
import * as api from '../api';
|
|
import * as api from '../api';
|
|
|
import { ElMessage } from 'element-plus';
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
|
+ const emit = defineEmits(['completed']);
|
|
|
|
|
|
|
|
const visible = ref(false);
|
|
const visible = ref(false);
|
|
|
const device_code = ref('');
|
|
const device_code = ref('');
|
|
|
const check_no = ref('');
|
|
const check_no = ref('');
|
|
|
const deviceList = ref<any[]>([]);
|
|
const deviceList = ref<any[]>([]);
|
|
|
|
|
+ const currentRecordId = ref<number | null>(null);
|
|
|
|
|
+ const loading = ref(false);
|
|
|
// const btflag=ref(true);
|
|
// const btflag=ref(true);
|
|
|
|
|
|
|
|
const setCheckNo = (val: string) => {
|
|
const setCheckNo = (val: string) => {
|
|
@@ -42,6 +47,7 @@
|
|
|
device_code.value = '';
|
|
device_code.value = '';
|
|
|
// check_no.value = '';
|
|
// check_no.value = '';
|
|
|
deviceList.value = [];
|
|
deviceList.value = [];
|
|
|
|
|
+ currentRecordId.value = null;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const findCheckRecord = (checkNo: string, list: any[]) => {
|
|
const findCheckRecord = (checkNo: string, list: any[]) => {
|
|
@@ -59,24 +65,46 @@
|
|
|
device_code: device_code.value,
|
|
device_code: device_code.value,
|
|
|
check_no: check_no.value,
|
|
check_no: check_no.value,
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
- const res = await api.ScanDevice(payload);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ loading.value = true;
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await api.ScanDevice(payload);
|
|
|
|
|
+ if (res?.code===2000) {
|
|
|
|
|
+ const reslist=await api.GetPermission();
|
|
|
|
|
+ if (reslist?.code===2000) {
|
|
|
|
|
+ const record = findCheckRecord(check_no.value, reslist.data);
|
|
|
|
|
+ deviceList.value.push({
|
|
|
|
|
+ ...payload,
|
|
|
|
|
+ productName: res.data?.productName || '未知商品',
|
|
|
|
|
+ id: record?.id||0,
|
|
|
|
|
+ status_display:record?.status_display||'',
|
|
|
|
|
+ });
|
|
|
|
|
+ device_code.value = '';
|
|
|
|
|
+ currentRecordId.value = record?.id ?? null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ loading.value = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const onCompleteAll = async () => {
|
|
|
|
|
+ if (!check_no.value) return;
|
|
|
|
|
+ const res=await api.CompleteScan({ check_no: check_no.value });
|
|
|
|
|
+ if (res?.code===2000) {
|
|
|
|
|
+ ElMessage.success('完成盘点!');
|
|
|
|
|
+ visible.value = false;
|
|
|
|
|
+ emit('completed');
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const onCancelAll = async () => {
|
|
|
|
|
+ if (!currentRecordId.value) return;
|
|
|
|
|
+ const res=await api.CancelScan(currentRecordId.value);
|
|
|
if (res?.code===2000) {
|
|
if (res?.code===2000) {
|
|
|
- const reslist=await api.GetPermission();
|
|
|
|
|
- if (reslist?.code===2000) {
|
|
|
|
|
- const record = findCheckRecord(check_no.value, reslist.data);
|
|
|
|
|
- // console.log("reslist::::",res.data.id)
|
|
|
|
|
- // console.log("record::::",record)
|
|
|
|
|
- deviceList.value.push({
|
|
|
|
|
- ...payload,
|
|
|
|
|
- productName: res.data?.productName || '未知商品',
|
|
|
|
|
- id: record?.id||0,
|
|
|
|
|
- status_display:record?.status_display||'',
|
|
|
|
|
- // record,
|
|
|
|
|
- });
|
|
|
|
|
- device_code.value = '';
|
|
|
|
|
- // check_no.value = '';
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ElMessage.success('取消盘点成功!');
|
|
|
|
|
+ visible.value = false;
|
|
|
|
|
+ emit('completed');
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -98,7 +126,7 @@
|
|
|
// });
|
|
// });
|
|
|
// btflag.value=false;
|
|
// btflag.value=false;
|
|
|
ElMessage.success('完成盘点!');
|
|
ElMessage.success('完成盘点!');
|
|
|
- visible.value = false
|
|
|
|
|
|
|
+ /* visible.value = false */
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|