bug: 修改eslint检查的代码缺陷
Some checks failed
Release / lint (push) Failing after 28s
Release / Release (push) Has been skipped

This commit is contained in:
my_ong
2024-12-10 11:34:00 +08:00
parent eebfca8790
commit b88e8479ef
4 changed files with 516 additions and 486 deletions

View File

@@ -1,27 +0,0 @@
<template>
<a-row bordered>
<a-col :span="8">
<a-button type="primary" width="90%">开始扫码</a-button>
</a-col>
<a-col :span="8">
</a-col>
<a-col :span="8">
<a-input bordered size="large" ref="snInput" placeholder="输入条形码" style="width: 90%" />
</a-col>
</a-row>
<vxe-table border stripe show-overflow ref="applyDetailTableRef" max-height="500" :column-config="{ resizable: true }"
:keyboard-config="{ isEsc: true }" size="medium">
<vxe-column type="seq" title="序号" width="60"></vxe-column>
<vxe-column field="id" title="物料id" :visible="false"></vxe-column>
<vxe-column field="name" title="物料名称" />
<vxe-column field="code" title="编码" />
<vxe-column field="spec" title="规格" />
<vxe-column field="type" title="类型" />
<vxe-column field="times" title="库存数量" />
<vxe-column field="oprator" title="盘点数量" />
</vxe-table>
</template>
<script setup lang="ts">
</script>

View File

@@ -1,9 +1,16 @@
<template>
<a-button type="primary" @click="beiginScan">开始扫码</a-button>
<a-button type="primary" danger style="left: 20px;">重新扫码</a-button>
<a-input bordered size="large" ref="snInput" v-model:value="value" placeholder="输入条形码" @pressEnter="autoInsertOneRow"
style="margin-top: 20px; margin-bottom: 20px;" />
<a-row style="margin-bottom: 20px;">
<a-button type="primary" danger style="left: 20px">重新扫码</a-button>
<a-input
ref="snInput"
v-model:value="value"
bordered
size="large"
placeholder="输入条形码"
style="margin-top: 20px; margin-bottom: 20px"
@press-enter="autoInsertOneRow"
/>
<a-row style="margin-bottom: 20px">
<a-col :span="12">
<a-statistic title="扫码合计" :value="totalValue" style="margin-right: 50px" />
</a-col>
@@ -12,10 +19,18 @@
</a-col>
</a-row>
<!-- Esc键退出编辑功能 -->
<vxe-table border stripe show-overflow ref="applyDetailTableRef" max-height="500" :column-config="{ resizable: true }"
:keyboard-config="{ isEsc: true }" size="medium" empty-text="请先扫码物料体条码"
:edit-config="{ trigger: 'click', mode: 'cell' }">
<vxe-table
ref="applyDetailTableRef"
border
stripe
show-overflow
max-height="500"
:column-config="{ resizable: true }"
:keyboard-config="{ isEsc: true }"
size="medium"
empty-text="请先扫码物料体条码"
:edit-config="{ trigger: 'click', mode: 'cell' }"
>
<vxe-column type="seq" title="序号" width="60"></vxe-column>
<vxe-column field="id" title="物料id" :visible="false"></vxe-column>
<vxe-column field="barcode" title="物料条码" />
@@ -29,7 +44,6 @@
<vxe-button mode="text" status="error" @click="removeStep2Row(row)">删除</vxe-button>
</template>
</vxe-column>
</vxe-table>
</template>
@@ -37,32 +51,31 @@
import { VxeTableInstance } from 'vxe-table'
import { useTemplateRef } from 'vue'
import { api } from '@/api'
import { message } from 'ant-design-vue';
import { message } from 'ant-design-vue'
// 父组件数据交互
const props = defineProps(
{
const props = defineProps({
totalValue: {
type: Number,
default: 0
default: 0,
},
applyId: {
type: Number,
required: false
}
}
)
required: false,
default: 0,
},
})
//获取扫码的集合
const getTableData = () => {
const $table = applyDetailTableRef.value
if ($table) {
return $table.getTableData().fullData.map(item => ({
return $table.getTableData().fullData.map((item) => ({
assignRule: item.assignRule,
materialId: item.id,
barcode: item.barcode,
code: item.code,
date: item.times
date: item.times,
}))
}
}
@@ -71,44 +84,39 @@ const getTableData = () => {
const getApplyData = () => {
const $table = applyDetailTableRef.value
if ($table) {
return $table.getTableData().fullData.map(item => ({
return $table.getTableData().fullData.map((item) => ({
applyId: props.applyId,
materialId: item.id,
barcode: item.barcode
barcode: item.barcode,
}))
}}
}
}
defineExpose({ getTableData, getApplyData })
const remainderValue = ref(0)
//扫码的条形码字符串
const value = ref('')
const input = useTemplateRef('snInput');
const input = useTemplateRef('snInput')
const snListCache = ref<string[]>([]) // 缓存扫码的条形码列表
// 定义一个map缓存物料信息
const materialMapCache = ref<Map<string, material.Material>>(new Map<string, material.Material>()) // 缓存物料信息,key是code
/**
* 请求接口获取缓存数据
*/
const getCache = () => {
api.materialApi.material.all((data) => {
data.forEach(item => {
data.forEach((item) => {
if (item.code) {
materialMapCache.value.set(item.code, item) // 物料编码定义为6位
}
})
})
}
getCache();
getCache()
interface TableRowVO {
id: number
@@ -130,7 +138,7 @@ const removeStep2Row = async (row: TableRowVO) => {
if ($table) {
$table.remove(row)
//删除缓存的sn
snListCache.value = snListCache.value.filter(item => item!== row.barcode)
snListCache.value = snListCache.value.filter((item) => item !== row.barcode)
// 已扫码数量-1
remainderValue.value = remainderValue.value - 1
@@ -139,17 +147,16 @@ const removeStep2Row = async (row: TableRowVO) => {
function beiginScan() {
// input.value?.focus()
const el = input.value as HTMLInputElement | null;
const el = input.value as HTMLInputElement | null
if (el) {
el.focus();
el.focus()
}
}
// 点击开始扫码按钮,自动新增一行 或者 扫码结束后也自动新增一行
const autoInsertOneRow = async () => {
const $table = applyDetailTableRef.value
const sn = value.value.trim();
const sn = value.value.trim()
/**
* 1. 判断sn是否合法
@@ -160,12 +167,12 @@ const autoInsertOneRow = async () => {
if (sn.length === 0) {
value.value = ''
message.warning('【' + sn + '】条形码为空,请重新扫码', 5)
return;
return
}
if (snListCache.value.includes(sn)) {
value.value = ''
message.warning('【' + sn + '】条形码重复,请重新扫码', 5)
return;
return
}
// 找到条形码对应的物料编码
const code = sn.slice(0, 6)
@@ -173,10 +180,9 @@ const autoInsertOneRow = async () => {
if (!materialInfo) {
value.value = ''
message.warning('【' + sn + '】条形码不合法,请重新扫码', 5)
return;
return
}
if ($table) {
const row: TableRowVO = {
id: materialInfo?.id ?? 0,
@@ -186,7 +192,7 @@ const autoInsertOneRow = async () => {
code: materialInfo?.code ?? '',
spec: materialInfo?.spec ?? '',
type: materialInfo?.type ?? '',
times: new Date().toLocaleString()
times: new Date().toLocaleString(),
}
$table.insert(row)
// 缓存sn
@@ -198,5 +204,4 @@ const autoInsertOneRow = async () => {
value.value = ''
}
}
</script>

View File

@@ -0,0 +1,32 @@
<template>
<a-row bordered>
<a-col :span="8">
<a-button type="primary" width="90%">开始扫码</a-button>
</a-col>
<a-col :span="8"></a-col>
<a-col :span="8">
<a-input ref="snInput" bordered size="large" placeholder="输入条形码" style="width: 90%" />
</a-col>
</a-row>
<vxe-table
ref="applyDetailTableRef"
border
stripe
show-overflow
max-height="500"
:column-config="{ resizable: true }"
:keyboard-config="{ isEsc: true }"
size="medium"
>
<vxe-column type="seq" title="序号" width="60"></vxe-column>
<vxe-column field="id" title="物料id" :visible="false"></vxe-column>
<vxe-column field="name" title="物料名称" />
<vxe-column field="code" title="编码" />
<vxe-column field="spec" title="规格" />
<vxe-column field="type" title="类型" />
<vxe-column field="times" title="库存数量" />
<vxe-column field="oprator" title="盘点数量" />
</vxe-table>
</template>
<script setup lang="ts"></script>

View File

@@ -4,8 +4,13 @@
<template #ops>
<a-row>
<a-col :span="18">
<a-input-search v-model:value="searchKey" :placeholder="`请输入`" allow-clear enter-button
@search="loadData()"></a-input-search>
<a-input-search
v-model:value="searchKey"
:placeholder="`请输入`"
allow-clear
enter-button
@search="loadData()"
></a-input-search>
</a-col>
<a-col :span="6">
<a-button type="primary" style="margin-left: 10px" @click="formDrawer?.show()">
@@ -14,15 +19,20 @@
</template>
申请扫码
</a-button>
</a-col>
</a-row>
</template>
<!-- 页面表格内容 -->
<div style="min-height: calc(100vh - 305px)">
<!-- 表格行 -->
<a-table :columns="columns" :data-source="auditPage?.records" bordered :pagination="pagination" :loading="loading"
row-key="key">
<a-table
:columns="columns"
:data-source="auditPage?.records"
bordered
:pagination="pagination"
:loading="loading"
row-key="key"
>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'auditType'">
{{ record.auditType === 'ALL' ? '全部盘点' : '部分盘点' }}
@@ -35,21 +45,28 @@
<template v-if="record.reviewResult === 'REJECT'">退回</template>
</template>
<template v-if="column.dataIndex === 'operation'">
<a-button type="link" @click="showModal(record.id)" v-if="record.reviewResult === 'WAIT_SCAN'
|| record.reviewResult === 'REJECT'">
<a-button
v-if="record.reviewResult === 'WAIT_SCAN' || record.reviewResult === 'REJECT'"
type="link"
@click="showModal(record.id)"
>
<template #icon>
<icon-font type="icon-edit" />
</template>
开始扫码
</a-button>
<a-button type="link" style="margin-left: 10px" @click="showResultModal(record.id)"
v-if="record.reviewResult === 'WAIT_SUBMIT' || record.reviewResult === 'WAIT_SCAN'">
<a-button
v-if="record.reviewResult === 'WAIT_SUBMIT' || record.reviewResult === 'WAIT_SCAN'"
type="link"
style="margin-left: 10px"
@click="showResultModal(record.id)"
>
<template #icon>
<icon-font type="icon-plus" />
</template>
生成结果
</a-button>
<a-button type="link" style="margin-left: 10px" v-if="record.reviewResult === 'WAIT_REVIEW'">
<a-button v-if="record.reviewResult === 'WAIT_REVIEW'" type="link" style="margin-left: 10px">
<template #icon>
<icon-font type="icon-plus" />
</template>
@@ -57,43 +74,59 @@
</a-button>
</template>
</template>
</a-table>
</div>
</page-container>
<!-- 新增申请抽屉 -->
<form-drawer ref="formDrawer" v-model="applyForm" :form-items="items" :config="formConfig"
:disabled-fields=disabledFields @ok="doSave" title="扫码盘点" />
<form-drawer
ref="formDrawer"
v-model="applyForm"
:form-items="items"
:config="formConfig"
:disabled-fields="disabledFields"
title="扫码盘点"
@ok="doSave"
/>
<!-- 盘点作业弹窗 -->
<a-modal v-model:open="open" title="盘点作业" width="100%" wrap-class-name="full-modal" @ok="handleOk"
:confirm-loading="confirmLoading">
<a-modal
v-model:open="open"
title="盘点作业"
width="100%"
wrap-class-name="full-modal"
:confirm-loading="confirmLoading"
@ok="handleOk"
>
<scan-form ref="scanFormRef" :apply-id="applyIdRef" :total-value="88"></scan-form>
</a-modal>
<!-- 盘点结果弹窗 -->
<a-modal v-model:open="openResult" title="盘点异常数据:" okText= "提交审核" @ok="submitHandle" width="80%" :confirm-loading="confirmLoading">
<a-modal
v-model:open="openResult"
title="盘点异常数据:"
ok-text="提交审核"
width="80%"
:confirm-loading="confirmLoading"
@ok="submitHandle"
>
<result-form ref="handleResultRef" :apply-id="applyIdRef"></result-form>
</a-modal>
</template>
<script setup lang="ts">
import api from '@/api';
import api from '@/api'
import { IPage } from '@/api/api'
import FormDrawer from '@/components/form-render/form-drawer.vue'
import { config, formItems } from './form'
import { notification } from 'ant-design-vue'
import dayjs from 'dayjs';
import dayjs from 'dayjs'
import { useUserStore } from '@/stores/user'
import scanForm from '../component/scan-form.vue'
import resultForm from './result-form.vue'
const searchKey = ref('')
const userStore = useUserStore()
const scanFormRef = ref(); // 盘点作业弹窗组件
const handleResultRef = ref(); // 盘点结果弹窗组件
const scanFormRef = ref() // 盘点作业弹窗组件
const handleResultRef = ref() // 盘点结果弹窗组件
const confirmLoading = ref(false) // 盘点作业弹窗提交按钮loading
// 新增申请表单对象
const applyForm = ref<Partial<material.AuditApplyInfo>>({
@@ -102,8 +135,7 @@ const applyForm = ref<Partial<material.AuditApplyInfo>>({
type: 'AUDIT',
applyDate: dayjs() + '',
isConfirm: false,
reviewResult: 'WAIT_SCAN'
reviewResult: 'WAIT_SCAN',
})
//列表数据
@@ -111,31 +143,28 @@ const auditPage = ref<IPage<material.ApplyForm>>()
const loading = ref(false)
//新增申请的下拉框选择对象
const materialList = ref<Array<{ value: string | undefined, label: string | undefined }>>([])
const personList = ref<Array<{ value: string | undefined, label: string | undefined }>>([])
const materialList = ref<Array<{ value: string | undefined; label: string | undefined }>>([])
const personList = ref<Array<{ value: string | undefined; label: string | undefined }>>([])
const required = ref(false)
api.materialApi.material.all((data) => {
materialList.value = data.map(item => {
materialList.value = data.map((item) => {
return {
value: item?.id + '',
label: item?.name
label: item?.name,
}
})
})
api.aclApi.user.all((data) => {
personList.value = data.map(item => {
personList.value = data.map((item) => {
return {
value: item?.name,
label: item?.fullName
label: item?.fullName,
}
})
})
//是否必填
const disabledFields = computed(() => {
if (applyForm.value?.auditType !== 'ALL') {
required.value = true
}
return applyForm.value?.auditType === 'ALL' ? ['materials'] : []
})
@@ -156,10 +185,12 @@ const loadData = async (page = 1, size = 10) => {
page: page,
size: size,
reviewResults: ['WAIT_SUBMIT', 'WAIT_SCAN', 'WAIT_REVIEW', 'PASS'],
}, (data) => {
},
(data) => {
auditPage.value = data
loading.value = false
});
},
)
}
//初始加载
loadData()
@@ -199,7 +230,7 @@ const columns = [
title: '操作',
dataIndex: 'operation',
width: 400,
}
},
]
//分页信息
@@ -226,59 +257,48 @@ const doSave = (_data: material.AuditApplyInfo) => {
},
})
})
}
// 盘点作业弹窗相关
const open = ref<boolean>(false);
const applyIdRef = ref();
const open = ref<boolean>(false)
const applyIdRef = ref()
const showModal = (applyId: number) => {
open.value = true;
applyIdRef.value = applyId;
};
open.value = true
applyIdRef.value = applyId
}
// 盘点作业提交数据
//关闭弹窗 提交数据
const handleOk = () => {
confirmLoading.value = true;
confirmLoading.value = true
if (scanFormRef.value) {
const data = scanFormRef.value.getApplyData();
const data = scanFormRef.value.getApplyData()
api.materialApi.apply.saveScanData(applyIdRef.value, data, () => {
open.value = false;
confirmLoading.value = false;
open.value = false
confirmLoading.value = false
loadData(1)
})
}
};
}
// 盘点结果弹窗相关
const openResult = ref<boolean>(false);
const openResult = ref<boolean>(false)
const showResultModal = (applyId: number) => {
window.console.log("点击传参" + applyId);
openResult.value = true;
applyIdRef.value = applyId;
};
window.console.log('点击传参' + applyId)
openResult.value = true
applyIdRef.value = applyId
}
// 盘点结果提交数据
const submitHandle = () => {
confirmLoading.value = true;
const handleData =handleResultRef.value.getTableData();
confirmLoading.value = true
const handleData = handleResultRef.value.getTableData()
api.materialApi.apply.updateReviewResult(applyIdRef.value, handleData, () => {
openResult.value = false;
openResult.value = false
loadData(1)
});
confirmLoading.value = false;
})
confirmLoading.value = false
}
</script>
<style lang="less">