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

View File

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