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,32 +1,49 @@
<template>
<!-- 基本信息的表单 -->
<div>
<a-form :model="formData" name="basic" layout="horizontal" labelWrap>
<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-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 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-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-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-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="物料名称" />
@ -38,8 +55,13 @@
{{ 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">
<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>
@ -50,7 +72,6 @@
<vxe-button mode="text" status="error" @click="removeRow(row)">删除</vxe-button>
</template>
</vxe-column>
</vxe-table>
</div>
</template>
@ -59,20 +80,20 @@
import { VxeTableInstance } from 'vxe-table'
import api from '@/api'
import { useUserStore } from '@/stores/user'
import dayjs, { Dayjs } from 'dayjs';
import dayjs, { Dayjs } from 'dayjs'
//
const props = defineProps(
{
applyType: {
type: String,
default: ''
}
} // applyType使121: 2:
default: '',
},
}, // applyType使121: 2:
)
const getTableData = () => {
const $table = tableRef.value
return $table?.getTableData().fullData;
return $table?.getTableData().fullData
}
const getApplyForm = () => {
return {
@ -80,16 +101,16 @@ const getApplyForm = () => {
applicant: formData.value.applicant,
applyDate: formData.value.applyDate.format('YYYY-MM-DD HH:mm:ss'),
isConfirm: true,
result: ''
result: '',
}
}
defineExpose({ getTableData, getApplyForm })
interface FormData {
applicant: string; //
applyDate: Dayjs; //
applyType: string; //
slectedList: number[]; //
applicant: string //
applyDate: Dayjs //
applyType: string //
slectedList: number[] //
}
const userStore = useUserStore()
@ -97,10 +118,8 @@ const formData = ref<FormData>({
applicant: userStore.userName,
applyDate: dayjs(),
applyType: props.applyType,
slectedList: []
});
slectedList: [],
})
// vxe-table
export interface RowVO {
@ -118,7 +137,7 @@ const tableRef = ref<VxeTableInstance<RowVO>>()
// vxe-table
const tableData = ref<Array<RowVO>>([])
//
const options = ref<{ label: string, value: number }[]>([])
const options = ref<{ label: string; value: number }[]>([])
const materialList = ref<material.Material[]>([])
const getMaterialList = async () => {
await api.materialApi.material.all((data) => {
@ -130,11 +149,9 @@ const getMaterialList = async () => {
}
getMaterialList()
//
// value: number, option: { label: string, value: number }
const insertEvent = (value: any) => {
const insertEvent = (value: string) => {
// value
const m = materialList.value.find((item) => item.id === (value ? parseInt(value) : -1))
if (m) {
@ -147,18 +164,17 @@ const insertEvent = (value: any) => {
quantity: 1,
assignRule: m.assignRule ? m.assignRule : 'HIGH_VALUE',
disabled: false,
checked: false
checked: false,
}
const $table = tableRef.value
if ($table) {
$table.insertAt(row, -1)
}
}
}
// table
const removeEvent = (value: any) => {
const removeEvent = (value: string) => {
const $table = tableRef.value
// value
if ($table) {
@ -185,5 +201,4 @@ const removeRow = async (row: RowVO) => {
$table.remove(row)
}
}
</script>

View File

@ -60,6 +60,7 @@
/**
* 点击下一步
*/
type GroupedSums = Record<string, number>
const nextStep = () => {
if (applyFormRef.value && current.value === 0) {
totalValue.value = 0
@ -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
}
@ -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' ? `数量不一致` : '',
}
})
}
@ -111,12 +112,15 @@
const applyForm = applyFormRef.value.getApplyForm() //
const detailList = scanFormRef.value.getTableData() //
api.materialApi.apply.saveApply({ applyForm: applyForm, applyDetails: applyDetails, detailList: detailList }, () => {
api.materialApi.apply.saveApply(
{ applyForm: applyForm, applyDetails: applyDetails, detailList: detailList },
() => {
console.log('申请成功')
//
loading.value = false
current.value = 3
})
},
)
}
</script>