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