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> <template>
<a-button type="primary" @click="beiginScan">开始扫码</a-button> <a-button type="primary" @click="beiginScan">开始扫码</a-button>
<a-button type="primary" danger style="left: 20px;">重新扫码</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" <a-input
style="margin-top: 20px; margin-bottom: 20px;" /> ref="snInput"
<a-row style="margin-bottom: 20px;"> 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-col :span="12">
<a-statistic title="扫码合计" :value="totalValue" style="margin-right: 50px" /> <a-statistic title="扫码合计" :value="totalValue" style="margin-right: 50px" />
</a-col> </a-col>
@ -12,10 +19,18 @@
</a-col> </a-col>
</a-row> </a-row>
<!-- Esc键退出编辑功能 --> <!-- Esc键退出编辑功能 -->
<vxe-table border stripe show-overflow ref="applyDetailTableRef" max-height="500" :column-config="{ resizable: true }" <vxe-table
:keyboard-config="{ isEsc: true }" size="medium" empty-text="请先扫码物料体条码" ref="applyDetailTableRef"
:edit-config="{ trigger: 'click', mode: 'cell' }"> 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 type="seq" title="序号" width="60"></vxe-column>
<vxe-column field="id" title="物料id" :visible="false"></vxe-column> <vxe-column field="id" title="物料id" :visible="false"></vxe-column>
<vxe-column field="barcode" title="物料条码" /> <vxe-column field="barcode" title="物料条码" />
@ -29,88 +44,81 @@
<vxe-button mode="text" status="error" @click="removeStep2Row(row)">删除</vxe-button> <vxe-button mode="text" status="error" @click="removeStep2Row(row)">删除</vxe-button>
</template> </template>
</vxe-column> </vxe-column>
</vxe-table> </vxe-table>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { VxeTableInstance } from 'vxe-table' import { VxeTableInstance } from 'vxe-table'
import { useTemplateRef } from 'vue' import { useTemplateRef } from 'vue'
import { api } from '@/api' import { api } from '@/api'
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue'
// //
const props = defineProps( const props = defineProps({
{
totalValue: { totalValue: {
type: Number, type: Number,
default: 0 default: 0,
}, },
applyId: { applyId: {
type: Number, type: Number,
required: false required: false,
} default: 0,
} },
) })
// //
const getTableData = () => { const getTableData = () => {
const $table = applyDetailTableRef.value const $table = applyDetailTableRef.value
if ($table) { if ($table) {
return $table.getTableData().fullData.map(item => ({ return $table.getTableData().fullData.map((item) => ({
assignRule: item.assignRule, assignRule: item.assignRule,
materialId: item.id, materialId: item.id,
barcode: item.barcode, barcode: item.barcode,
code: item.code, code: item.code,
date: item.times date: item.times,
})) }))
} }
} }
// //
const getApplyData = () => { const getApplyData = () => {
const $table = applyDetailTableRef.value const $table = applyDetailTableRef.value
if ($table) { if ($table) {
return $table.getTableData().fullData.map(item => ({ return $table.getTableData().fullData.map((item) => ({
applyId: props.applyId, applyId: props.applyId,
materialId: item.id, materialId: item.id,
barcode: item.barcode barcode: item.barcode,
})) }))
}
}
}} defineExpose({ getTableData, getApplyData })
const remainderValue = ref(0)
defineExpose({ getTableData,getApplyData }) //
const value = ref('')
const input = useTemplateRef('snInput')
const snListCache = ref<string[]>([]) //
// map
const materialMapCache = ref<Map<string, material.Material>>(new Map<string, material.Material>()) // ,keycode
/**
const remainderValue = ref(0)
//
const value = ref('')
const input = useTemplateRef('snInput');
const snListCache = ref<string[]>([]) //
// map
const materialMapCache = ref<Map<string, material.Material>>(new Map<string, material.Material>()) // ,keycode
/**
* 请求接口获取缓存数据 * 请求接口获取缓存数据
*/ */
const getCache = () => { const getCache = () => {
api.materialApi.material.all((data) => { api.materialApi.material.all((data) => {
data.forEach(item => { data.forEach((item) => {
if (item.code) { if (item.code) {
materialMapCache.value.set(item.code, item) // 6 materialMapCache.value.set(item.code, item) // 6
} }
}) })
}) })
} }
getCache(); getCache()
interface TableRowVO { interface TableRowVO {
id: number id: number
barcode: string barcode: string
assignRule: string assignRule: string
@ -119,37 +127,36 @@ interface TableRowVO {
spec: string spec: string
type: string type: string
times: string times: string
} }
// table // table
const applyDetailTableRef = ref<VxeTableInstance<TableRowVO>>() const applyDetailTableRef = ref<VxeTableInstance<TableRowVO>>()
// table // table
const removeStep2Row = async (row: TableRowVO) => { const removeStep2Row = async (row: TableRowVO) => {
const $table = applyDetailTableRef.value const $table = applyDetailTableRef.value
if ($table) { if ($table) {
$table.remove(row) $table.remove(row)
//sn //sn
snListCache.value = snListCache.value.filter(item => item!== row.barcode) snListCache.value = snListCache.value.filter((item) => item !== row.barcode)
// -1 // -1
remainderValue.value = remainderValue.value - 1 remainderValue.value = remainderValue.value - 1
} }
}
function beiginScan() {
// input.value?.focus()
const el = input.value as HTMLInputElement | null;
if (el) {
el.focus();
} }
}
// function beiginScan() {
const autoInsertOneRow = async () => { // input.value?.focus()
const el = input.value as HTMLInputElement | null
if (el) {
el.focus()
}
}
//
const autoInsertOneRow = async () => {
const $table = applyDetailTableRef.value const $table = applyDetailTableRef.value
const sn = value.value.trim(); const sn = value.value.trim()
/** /**
* 1. 判断sn是否合法 * 1. 判断sn是否合法
@ -160,12 +167,12 @@ const autoInsertOneRow = async () => {
if (sn.length === 0) { if (sn.length === 0) {
value.value = '' value.value = ''
message.warning('【' + sn + '】条形码为空,请重新扫码', 5) message.warning('【' + sn + '】条形码为空,请重新扫码', 5)
return; return
} }
if (snListCache.value.includes(sn)) { if (snListCache.value.includes(sn)) {
value.value = '' value.value = ''
message.warning('【' + sn + '】条形码重复,请重新扫码', 5) message.warning('【' + sn + '】条形码重复,请重新扫码', 5)
return; return
} }
// //
const code = sn.slice(0, 6) const code = sn.slice(0, 6)
@ -173,10 +180,9 @@ const autoInsertOneRow = async () => {
if (!materialInfo) { if (!materialInfo) {
value.value = '' value.value = ''
message.warning('【' + sn + '】条形码不合法,请重新扫码', 5) message.warning('【' + sn + '】条形码不合法,请重新扫码', 5)
return; return
} }
if ($table) { if ($table) {
const row: TableRowVO = { const row: TableRowVO = {
id: materialInfo?.id ?? 0, id: materialInfo?.id ?? 0,
@ -186,7 +192,7 @@ const autoInsertOneRow = async () => {
code: materialInfo?.code ?? '', code: materialInfo?.code ?? '',
spec: materialInfo?.spec ?? '', spec: materialInfo?.spec ?? '',
type: materialInfo?.type ?? '', type: materialInfo?.type ?? '',
times: new Date().toLocaleString() times: new Date().toLocaleString(),
} }
$table.insert(row) $table.insert(row)
// sn // sn
@ -197,6 +203,5 @@ const autoInsertOneRow = async () => {
// //
value.value = '' value.value = ''
} }
} }
</script> </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> <template #ops>
<a-row> <a-row>
<a-col :span="18"> <a-col :span="18">
<a-input-search v-model:value="searchKey" :placeholder="`请输入`" allow-clear enter-button <a-input-search
@search="loadData()"></a-input-search> v-model:value="searchKey"
:placeholder="`请输入`"
allow-clear
enter-button
@search="loadData()"
></a-input-search>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="6">
<a-button type="primary" style="margin-left: 10px" @click="formDrawer?.show()"> <a-button type="primary" style="margin-left: 10px" @click="formDrawer?.show()">
@ -14,42 +19,54 @@
</template> </template>
申请扫码 申请扫码
</a-button> </a-button>
</a-col> </a-col>
</a-row> </a-row>
</template> </template>
<!-- 页面表格内容 --> <!-- 页面表格内容 -->
<div style="min-height: calc(100vh - 305px)"> <div style="min-height: calc(100vh - 305px)">
<!-- 表格行 --> <!-- 表格行 -->
<a-table :columns="columns" :data-source="auditPage?.records" bordered :pagination="pagination" :loading="loading" <a-table
row-key="key"> :columns="columns"
:data-source="auditPage?.records"
bordered
:pagination="pagination"
:loading="loading"
row-key="key"
>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'auditType'"> <template v-if="column.dataIndex === 'auditType'">
{{ record.auditType === 'ALL' ? '全部盘点' : '部分盘点' }} {{ record.auditType === 'ALL' ? '全部盘点' : '部分盘点' }}
</template> </template>
<template v-if="column.dataIndex === 'reviewResult'"> <template v-if="column.dataIndex === 'reviewResult'">
<template v-if="record.reviewResult === 'WAIT_SCAN'"> 待扫码</template> <template v-if="record.reviewResult === 'WAIT_SCAN'">待扫码</template>
<template v-if="record.reviewResult === 'WAIT_SUBMIT'"> 待提交</template> <template v-if="record.reviewResult === 'WAIT_SUBMIT'">待提交</template>
<template v-if="record.reviewResult === 'WAIT_REVIEW'"> 待审核 </template> <template v-if="record.reviewResult === 'WAIT_REVIEW'">待审核</template>
<template v-if="record.reviewResult === 'PASS'"> 审核通过</template> <template v-if="record.reviewResult === 'PASS'">审核通过</template>
<template v-if="record.reviewResult === 'REJECT'"> 退回</template> <template v-if="record.reviewResult === 'REJECT'">退回</template>
</template> </template>
<template v-if="column.dataIndex === 'operation'"> <template v-if="column.dataIndex === 'operation'">
<a-button type="link" @click="showModal(record.id)" v-if="record.reviewResult === 'WAIT_SCAN' <a-button
|| record.reviewResult === 'REJECT'"> v-if="record.reviewResult === 'WAIT_SCAN' || record.reviewResult === 'REJECT'"
type="link"
@click="showModal(record.id)"
>
<template #icon> <template #icon>
<icon-font type="icon-edit" /> <icon-font type="icon-edit" />
</template> </template>
开始扫码 开始扫码
</a-button> </a-button>
<a-button type="link" style="margin-left: 10px" @click="showResultModal(record.id)" <a-button
v-if="record.reviewResult === 'WAIT_SUBMIT' || record.reviewResult === 'WAIT_SCAN'"> v-if="record.reviewResult === 'WAIT_SUBMIT' || record.reviewResult === 'WAIT_SCAN'"
type="link"
style="margin-left: 10px"
@click="showResultModal(record.id)"
>
<template #icon> <template #icon>
<icon-font type="icon-plus" /> <icon-font type="icon-plus" />
</template> </template>
生成结果 生成结果
</a-button> </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> <template #icon>
<icon-font type="icon-plus" /> <icon-font type="icon-plus" />
</template> </template>
@ -57,115 +74,129 @@
</a-button> </a-button>
</template> </template>
</template> </template>
</a-table> </a-table>
</div> </div>
</page-container> </page-container>
<!-- 新增申请抽屉 --> <!-- 新增申请抽屉 -->
<form-drawer ref="formDrawer" v-model="applyForm" :form-items="items" :config="formConfig" <form-drawer
:disabled-fields=disabledFields @ok="doSave" title="扫码盘点" /> 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" <a-modal
:confirm-loading="confirmLoading"> 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> <scan-form ref="scanFormRef" :apply-id="applyIdRef" :total-value="88"></scan-form>
</a-modal> </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> <result-form ref="handleResultRef" :apply-id="applyIdRef"></result-form>
</a-modal> </a-modal>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import api from '@/api'; import api from '@/api'
import { IPage } from '@/api/api' import { IPage } from '@/api/api'
import FormDrawer from '@/components/form-render/form-drawer.vue' import FormDrawer from '@/components/form-render/form-drawer.vue'
import { config, formItems } from './form' import { config, formItems } from './form'
import { notification } from 'ant-design-vue' import { notification } from 'ant-design-vue'
import dayjs from 'dayjs'; import dayjs from 'dayjs'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import scanForm from '../component/scan-form.vue' import scanForm from '../component/scan-form.vue'
import resultForm from './result-form.vue' import resultForm from './result-form.vue'
const searchKey = ref('')
const searchKey = ref('') const userStore = useUserStore()
const userStore = useUserStore() const scanFormRef = ref() //
const scanFormRef = ref(); // const handleResultRef = ref() //
const handleResultRef = ref(); // const confirmLoading = ref(false) // loading
const confirmLoading = ref(false) // loading //
// const applyForm = ref<Partial<material.AuditApplyInfo>>({
const applyForm = ref<Partial<material.AuditApplyInfo>>({
auditType: 'ALL', auditType: 'ALL',
applicant: userStore.userName, applicant: userStore.userName,
type: 'AUDIT', type: 'AUDIT',
applyDate: dayjs() + '', applyDate: dayjs() + '',
isConfirm: false, isConfirm: false,
reviewResult: 'WAIT_SCAN' reviewResult: 'WAIT_SCAN',
})
}) //
const auditPage = ref<IPage<material.ApplyForm>>()
const loading = ref(false)
// //
const auditPage = ref<IPage<material.ApplyForm>>() const materialList = ref<Array<{ value: string | undefined; label: string | undefined }>>([])
const loading = ref(false) const personList = ref<Array<{ value: string | undefined; label: string | undefined }>>([])
const required = ref(false)
// api.materialApi.material.all((data) => {
const materialList = ref<Array<{ value: string | undefined, label: string | undefined }>>([]) materialList.value = data.map((item) => {
const personList = ref<Array<{ value: string | undefined, label: string | undefined }>>([])
const required = ref(false)
api.materialApi.material.all((data) => {
materialList.value = data.map(item => {
return { return {
value: item?.id + '', value: item?.id + '',
label: item?.name label: item?.name,
} }
}) })
}) })
api.aclApi.user.all((data) => { api.aclApi.user.all((data) => {
personList.value = data.map(item => { personList.value = data.map((item) => {
return { return {
value: item?.name, value: item?.name,
label: item?.fullName label: item?.fullName,
} }
}) })
}) })
// //
const disabledFields = computed(() => { const disabledFields = computed(() => {
if (applyForm.value?.auditType !== 'ALL') {
required.value = true
}
return applyForm.value?.auditType === 'ALL' ? ['materials'] : [] return applyForm.value?.auditType === 'ALL' ? ['materials'] : []
}) })
// //
const formDrawer = ref<typeof FormDrawer>() const formDrawer = ref<typeof FormDrawer>()
const formConfig = computed(() => { const formConfig = computed(() => {
return config return config
}) })
// //
const items = computed(() => { const items = computed(() => {
return formItems(materialList.value, required, personList.value) return formItems(materialList.value, required, personList.value)
}) })
// //
const loadData = async (page = 1, size = 10) => { const loadData = async (page = 1, size = 10) => {
loading.value = true loading.value = true
api.materialApi.apply.searchAuditPage( api.materialApi.apply.searchAuditPage(
{ {
page: page, page: page,
size: size, size: size,
reviewResults: ['WAIT_SUBMIT', 'WAIT_SCAN', 'WAIT_REVIEW', 'PASS'], reviewResults: ['WAIT_SUBMIT', 'WAIT_SCAN', 'WAIT_REVIEW', 'PASS'],
}, (data) => { },
(data) => {
auditPage.value = data auditPage.value = data
loading.value = false loading.value = false
}); },
} )
// }
loadData() //
loadData()
// //
const columns = [ const columns = [
{ {
title: '申请ID', title: '申请ID',
dataIndex: 'id', dataIndex: 'id',
@ -199,11 +230,11 @@ const columns = [
title: '操作', title: '操作',
dataIndex: 'operation', dataIndex: 'operation',
width: 400, width: 400,
} },
] ]
// //
const pagination = computed(() => { const pagination = computed(() => {
return { return {
current: auditPage.value?.current, current: auditPage.value?.current,
pageSize: auditPage.value?.size, pageSize: auditPage.value?.size,
@ -212,10 +243,10 @@ const pagination = computed(() => {
loadData(page, pageSize) loadData(page, pageSize)
}, },
} }
}) })
// //
const doSave = (_data: material.AuditApplyInfo) => { const doSave = (_data: material.AuditApplyInfo) => {
api.materialApi.apply.auditApply(_data, () => { api.materialApi.apply.auditApply(_data, () => {
formDrawer.value?.close() formDrawer.value?.close()
notification.success({ notification.success({
@ -226,63 +257,52 @@ const doSave = (_data: material.AuditApplyInfo) => {
}, },
}) })
}) })
}
} //
const open = ref<boolean>(false)
const applyIdRef = ref()
const showModal = (applyId: number) => {
open.value = true
applyIdRef.value = applyId
}
//
// //
const open = ref<boolean>(false); const handleOk = () => {
const applyIdRef = ref(); confirmLoading.value = true
const showModal = (applyId: number) => {
open.value = true;
applyIdRef.value = applyId;
};
//
//
const handleOk = () => {
confirmLoading.value = true;
if (scanFormRef.value) { if (scanFormRef.value) {
const data = scanFormRef.value.getApplyData(); const data = scanFormRef.value.getApplyData()
api.materialApi.apply.saveScanData(applyIdRef.value, data, () => { api.materialApi.apply.saveScanData(applyIdRef.value, data, () => {
open.value = false; open.value = false
confirmLoading.value = false; confirmLoading.value = false
loadData(1) loadData(1)
}) })
} }
}
}; //
const openResult = ref<boolean>(false)
const showResultModal = (applyId: number) => {
window.console.log('点击传参' + applyId)
openResult.value = true
applyIdRef.value = applyId
}
// //
const openResult = ref<boolean>(false); const submitHandle = () => {
const showResultModal = (applyId: number) => { confirmLoading.value = true
window.console.log("点击传参" + applyId); const handleData = handleResultRef.value.getTableData()
openResult.value = true;
applyIdRef.value = applyId;
};
//
const submitHandle = () => {
confirmLoading.value = true;
const handleData =handleResultRef.value.getTableData();
api.materialApi.apply.updateReviewResult(applyIdRef.value, handleData, () => { api.materialApi.apply.updateReviewResult(applyIdRef.value, handleData, () => {
openResult.value = false; openResult.value = false
loadData(1) loadData(1)
}); })
confirmLoading.value = false; confirmLoading.value = false
} }
</script> </script>
<style lang="less"> <style lang="less">
.full-modal { .full-modal {
.ant-modal { .ant-modal {
max-width: 100%; max-width: 100%;
top: 0; top: 0;
@ -299,5 +319,5 @@ const submitHandle = () => {
.ant-modal-body { .ant-modal-body {
flex: 1; flex: 1;
} }
} }
</style> </style>