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

This commit is contained in:
my_ong 2024-12-10 11:41:51 +08:00
parent b88e8479ef
commit c6d06aa24e
2 changed files with 205 additions and 186 deletions

View File

@ -1,189 +1,204 @@
<template>
<!-- 基本信息的表单 -->
<div>
<a-form :model="formData" name="basic" layout="horizontal" labelWrap>
<a-form-item label="申请人" name="applicant">
<a-input :value="formData.applicant" style="width: 40%;" />
</a-form-item>
<!-- 基本信息的表单 -->
<div>
<a-form :model="formData" name="basic" layout="horizontal" label-wrap>
<a-form-item label="申请人" name="applicant">
<a-input :value="formData.applicant" style="width: 40%" />
</a-form-item>
<a-form-item label="申请类型" name="applyType">
<a-radio-group v-model:value="formData.applyType" button-style="solid" style="width: 40%;">
<a-radio-button value='PURCHASE_RECEIPT' v-if="applyType === 'PURCHASE_RECEIPT'">采购入库</a-radio-button>
<a-radio-button value='RETURN_RECEIPT' v-if="applyType === 'PURCHASE_RECEIPT'">归还入库</a-radio-button>
<a-radio-button value='LOAN_OUT' v-if="applyType === 'LOAN_OUT'">出库外借</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item label="申请日期" name="applyDate" style="width: 40%;">
<a-date-picker v-model:value="formData.applyDate" />
</a-form-item>
<a-form-item label="选择物料" name="selected">
<a-select v-model:value="formData.slectedList" mode="multiple" bordered placeholder="请选择物料" style="width: 40%;"
show-search :options="options" @deselect="removeEvent" @select="insertEvent"></a-select>
</a-form-item>
</a-form>
</div>
<a-form-item label="申请类型" name="applyType">
<a-radio-group v-model:value="formData.applyType" button-style="solid" style="width: 40%">
<a-radio-button v-if="applyType === 'PURCHASE_RECEIPT'" value="PURCHASE_RECEIPT">采购入库</a-radio-button>
<a-radio-button v-if="applyType === 'PURCHASE_RECEIPT'" value="RETURN_RECEIPT">归还入库</a-radio-button>
<a-radio-button v-if="applyType === 'LOAN_OUT'" value="LOAN_OUT">出库外借</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item label="申请日期" name="applyDate" style="width: 40%">
<a-date-picker v-model:value="formData.applyDate" />
</a-form-item>
<a-form-item label="选择物料" name="selected">
<a-select
v-model:value="formData.slectedList"
mode="multiple"
bordered
placeholder="请选择物料"
style="width: 40%"
show-search
:options="options"
@deselect="removeEvent"
@select="insertEvent"
></a-select>
</a-form-item>
</a-form>
</div>
<!-- vxe-table -->
<div>
<vxe-table border show-overflow ref="tableRef" max-height="500" size="medium" v-model:data="tableData"
empty-text="请先选择物料" :edit-config="{ trigger: 'click', mode: 'cell', autoFocus: true }">
<vxe-column type="seq" title="序号" width="60" />
<vxe-column field="id" title="物料id" :visible="false" />
<vxe-column field="name" title="物料名称" />
<vxe-column field="code" title="编码" />
<vxe-column field="spec" title="规格" />
<vxe-column field="type" title="类型" />
<vxe-column field="assignRule" title="是否赋码">
<template #default="{ row }">
{{ row.assignRule === 'HIGH_VALUE' ? '是' : '否' }}
</template>
</vxe-column>
<vxe-column field="quantity" title="申请数量(点击修改)" :edit-render="{ name: 'input', autoSelect: true }"
keyboard-config="{edit: true, del: true}" cell-type="number">
<template #edit="{ row }">
<vxe-number-input v-model="row.quantity" type="integer"></vxe-number-input>
</template>
</vxe-column>
<!-- vxe-table -->
<div>
<vxe-table
ref="tableRef"
v-model:data="tableData"
border
show-overflow
max-height="500"
size="medium"
empty-text="请先选择物料"
:edit-config="{ trigger: 'click', mode: 'cell', autoFocus: true }"
>
<vxe-column type="seq" title="序号" width="60" />
<vxe-column field="id" title="物料id" :visible="false" />
<vxe-column field="name" title="物料名称" />
<vxe-column field="code" title="编码" />
<vxe-column field="spec" title="规格" />
<vxe-column field="type" title="类型" />
<vxe-column field="assignRule" title="是否赋码">
<template #default="{ row }">
{{ row.assignRule === 'HIGH_VALUE' ? '是' : '否' }}
</template>
</vxe-column>
<vxe-column
field="quantity"
title="申请数量(点击修改)"
:edit-render="{ name: 'input', autoSelect: true }"
keyboard-config="{edit: true, del: true}"
cell-type="number"
>
<template #edit="{ row }">
<vxe-number-input v-model="row.quantity" type="integer"></vxe-number-input>
</template>
</vxe-column>
<vxe-column field="oprator" title="操作">
<template #default="{ row }">
<vxe-button mode="text" status="error" @click="removeRow(row)">删除</vxe-button>
</template>
</vxe-column>
</vxe-table>
</div>
<vxe-column field="oprator" title="操作">
<template #default="{ row }">
<vxe-button mode="text" status="error" @click="removeRow(row)">删除</vxe-button>
</template>
</vxe-column>
</vxe-table>
</div>
</template>
<script setup lang="ts">
import { VxeTableInstance } from 'vxe-table'
import api from '@/api'
import { useUserStore } from '@/stores/user'
import dayjs, { Dayjs } from 'dayjs';
import { VxeTableInstance } from 'vxe-table'
import api from '@/api'
import { useUserStore } from '@/stores/user'
import dayjs, { Dayjs } from 'dayjs'
//
const props = defineProps(
{
applyType: {
type: String,
default: ''
}
} // applyType使121: 2:
)
const getTableData = ()=> {
const $table = tableRef.value
return $table?.getTableData().fullData;
}
const getApplyForm = () => {
return {
type: formData.value.applyType,
applicant: formData.value.applicant,
applyDate: formData.value.applyDate.format('YYYY-MM-DD HH:mm:ss'),
isConfirm: true,
result: ''
}
}
defineExpose({ getTableData, getApplyForm })
//
const props = defineProps(
{
applyType: {
type: String,
default: '',
},
}, // applyType使121: 2:
)
const getTableData = () => {
const $table = tableRef.value
return $table?.getTableData().fullData
}
const getApplyForm = () => {
return {
type: formData.value.applyType,
applicant: formData.value.applicant,
applyDate: formData.value.applyDate.format('YYYY-MM-DD HH:mm:ss'),
isConfirm: true,
result: '',
}
}
defineExpose({ getTableData, getApplyForm })
interface FormData {
applicant: string; //
applyDate: Dayjs; //
applyType: string; //
slectedList: number[]; //
}
interface FormData {
applicant: string //
applyDate: Dayjs //
applyType: string //
slectedList: number[] //
}
const userStore = useUserStore()
const formData = ref<FormData>({
applicant: userStore.userName,
applyDate: dayjs(),
applyType: props.applyType,
slectedList: []
const userStore = useUserStore()
const formData = ref<FormData>({
applicant: userStore.userName,
applyDate: dayjs(),
applyType: props.applyType,
slectedList: [],
})
});
// vxe-table
export interface RowVO {
id: number
name: string
code: string
spec: string
type: string
quantity: number
disabled: boolean
checked: boolean
assignRule: string
}
const tableRef = ref<VxeTableInstance<RowVO>>()
// vxe-table
const tableData = ref<Array<RowVO>>([])
//
const options = ref<{ label: string; value: number }[]>([])
const materialList = ref<material.Material[]>([])
const getMaterialList = async () => {
await api.materialApi.material.all((data) => {
materialList.value = data
})
options.value = materialList.value.map((item) => {
return { label: item.name ? item.name : '未知', value: item.id ? item.id : -1 }
})
}
getMaterialList()
//
// value: number, option: { label: string, value: number }
const insertEvent = (value: string) => {
// value
const m = materialList.value.find((item) => item.id === (value ? parseInt(value) : -1))
if (m) {
const row: RowVO = {
id: m.id ? m.id : -1,
name: m.name ? m.name : '未知',
code: m.code ? m.code : '未知',
spec: m.spec ? m.spec : '未知',
type: m.type ? m.type : '未知',
quantity: 1,
assignRule: m.assignRule ? m.assignRule : 'HIGH_VALUE',
disabled: false,
checked: false,
}
const $table = tableRef.value
if ($table) {
$table.insertAt(row, -1)
}
}
}
// vxe-table
export interface RowVO {
id: number
name: string
code: string
spec: string
type: string
quantity: number
disabled: boolean
checked: boolean
assignRule: string
}
const tableRef = ref<VxeTableInstance<RowVO>>()
// vxe-table
const tableData = ref<Array<RowVO>>([])
//
const options = ref<{ label: string, value: number }[]>([])
const materialList = ref<material.Material[]>([])
const getMaterialList = async () => {
await api.materialApi.material.all((data) => {
materialList.value = data
})
options.value = materialList.value.map((item) => {
return { label: item.name ? item.name : '未知', value: item.id ? item.id : -1 }
})
}
getMaterialList()
// table
const removeEvent = (value: string) => {
const $table = tableRef.value
// value
if ($table) {
$table.getTableData().fullData.forEach((item) => {
if (item.id === (value ? parseInt(value) : -1)) {
$table.remove(item)
}
})
}
}
// table
const removeRow = async (row: RowVO) => {
//tableData
const $table = tableRef.value
if ($table) {
// row.id
formData.value.slectedList.forEach((item, index) => {
if (item.toString() === row.id.toString()) {
formData.value.slectedList.splice(index, 1)
}
})
//
// value: number, option: { label: string, value: number }
const insertEvent = (value: any) => {
// value
const m = materialList.value.find((item) => item.id === (value ? parseInt(value) : -1))
if (m) {
const row: RowVO = {
id: m.id ? m.id : -1,
name: m.name ? m.name : '未知',
code: m.code ? m.code : '未知',
spec: m.spec ? m.spec : '未知',
type: m.type ? m.type : '未知',
quantity: 1,
assignRule: m.assignRule ? m.assignRule : 'HIGH_VALUE',
disabled: false,
checked: false
}
const $table = tableRef.value
if ($table) {
$table.insertAt(row, -1)
}
}
}
// table
const removeEvent = (value: any) => {
const $table = tableRef.value
// value
if ($table) {
$table.getTableData().fullData.forEach((item) => {
if (item.id === (value ? parseInt(value) : -1)) {
$table.remove(item)
}
})
}
}
// table
const removeRow = async (row: RowVO) => {
//tableData
const $table = tableRef.value
if ($table) {
// row.id
formData.value.slectedList.forEach((item, index) => {
if (item.toString() === row.id.toString()) {
formData.value.slectedList.splice(index, 1)
}
})
$table.remove(row)
}
}
$table.remove(row)
}
}
</script>

View File

@ -30,7 +30,7 @@
</template>
<script setup lang="ts">
import applyForm,{RowVO} from './apply-form.vue'
import applyForm, { RowVO } from './apply-form.vue'
import scanForm from './scan-form.vue'
import applyConfirm from './apply-confirm.vue'
import successResul from './success-resul.vue'
@ -60,12 +60,13 @@
/**
* 点击下一步
*/
type GroupedSums = Record<string, number>
const nextStep = () => {
if (applyFormRef.value && current.value === 0) {
totalValue.value = 0
totalValue.value = 0
// step1step1
selectData.value = applyFormRef.value.getTableData()
selectData.value.forEach((item:RowVO) => {
selectData.value.forEach((item: RowVO) => {
if (item.assignRule === 'HIGH_VALUE') {
totalValue.value += item.quantity
}
@ -74,7 +75,7 @@
if (scanFormRef.value && current.value === 1) {
// step2step2
const items = scanFormRef.value.getTableData()
const groupedSums = items.reduce((acc:any, item:RowVO) => {
const groupedSums = items.reduce((acc: GroupedSums, item: RowVO) => {
if (!acc[item.code]) {
acc[item.code] = 0
}
@ -82,7 +83,7 @@
return acc
}, {})
//
conformData.value = selectData.value.map((item :RowVO) => {
conformData.value = selectData.value.map((item: RowVO) => {
return {
id: item.id,
name: item.name,
@ -90,7 +91,7 @@
applyNum: item.quantity,
assignRule: item.assignRule,
scanNum: groupedSums[item.code] || 0,
remark: (item.quantity != groupedSums[item.code] && item.assignRule === 'HIGH_VALUE') ? `数量不一致` : '',
remark: item.quantity != groupedSums[item.code] && item.assignRule === 'HIGH_VALUE' ? `数量不一致` : '',
}
})
}
@ -109,14 +110,17 @@
//
const applyDetails = applyConfirmRef.value.getTableData() //
const applyForm = applyFormRef.value.getApplyForm() //
const detailList = scanFormRef.value.getTableData() //
const detailList = scanFormRef.value.getTableData() //
api.materialApi.apply.saveApply({ applyForm: applyForm, applyDetails: applyDetails, detailList: detailList }, () => {
console.log('申请成功')
//
loading.value = false
current.value = 3
})
api.materialApi.apply.saveApply(
{ applyForm: applyForm, applyDetails: applyDetails, detailList: detailList },
() => {
console.log('申请成功')
//
loading.value = false
current.value = 3
},
)
}
</script>