bug: 修改eslint检查的代码缺陷
This commit is contained in:
parent
b88e8479ef
commit
c6d06aa24e
@ -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页面传值的使用1和2,1: 采购入库 和 归还入库 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页面传值的使用1和2,1: 采购入库 和 归还入库 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>
|
||||
|
@ -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
|
||||
// 再step1中点击下一步的时候,就去获取step1中的表单数据
|
||||
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) {
|
||||
// 再step2中点击下一步的时候,就去获取step2中的表单数据
|
||||
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>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user