|
@@ -5,6 +5,7 @@ import { Delete, CirclePlus } from '@element-plus/icons-vue'
|
|
|
import { GlobalStore } from '@/stores/index'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import {
|
|
|
+ Storehouse_StockIn_Add,
|
|
|
Storehouse_Product_List,
|
|
|
Storehouse_ProductClass_List,
|
|
|
Storehouse_Product_Model_List,
|
|
@@ -13,16 +14,16 @@ import {
|
|
|
} from '@/api/storehouse/index'
|
|
|
import type { FormInstance, FormRules } from 'element-plus'
|
|
|
import { default as vElTableInfiniteScroll } from 'el-table-infinite-scroll'
|
|
|
+import InStorageSn from './InStorageSn.vue'
|
|
|
|
|
|
const isNew = ref(true)
|
|
|
const selectTable = ref()
|
|
|
-const snTable = ref()
|
|
|
let selectProductData: any[] = []
|
|
|
const globalStore = GlobalStore()
|
|
|
const formLabelWidth = ref('120px')
|
|
|
const ruleFormRef = ref<FormInstance>()
|
|
|
const drawerRef = ref<InstanceType<typeof Drawer> | null>(null)
|
|
|
-const drawerSnRef = ref<InstanceType<typeof Drawer> | null>(null)
|
|
|
+const drawerSnRef = ref<InstanceType<typeof InStorageSn> | null>(null)
|
|
|
const drawerProductRef = ref<InstanceType<typeof Drawer> | null>(null)
|
|
|
|
|
|
const classOptions = ref<any[]>([])
|
|
@@ -50,8 +51,19 @@ const form = reactive<FormType>({
|
|
|
T_date: '',
|
|
|
T_remark: ''
|
|
|
})
|
|
|
+
|
|
|
+const validate_T_product = (rule: any, value: any, callback: any) => {
|
|
|
+ if (value.includes(undefined) || value === '') {
|
|
|
+ callback(new Error('请填写产品数量'))
|
|
|
+ } else if (value.includes(null)) {
|
|
|
+ callback(new Error('请添加产品SN'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const rules = reactive<FormRules>({
|
|
|
- // T_product: [{ validator: validate_T_product, trigger: 'blur' }],
|
|
|
+ T_product: [{ validator: validate_T_product, trigger: 'blur' }],
|
|
|
T_depot_id: [{ required: true, message: '请选择仓库', trigger: 'blur' }],
|
|
|
T_date: [{ required: true, message: '请选择入库日期', trigger: 'blur' }]
|
|
|
})
|
|
@@ -62,7 +74,7 @@ const columns = [
|
|
|
{ label: '产品图片', prop: 'T_img', align: 'center ', name: 'T_img' },
|
|
|
{ label: '产品名称', prop: 'T_name', align: 'center ' },
|
|
|
{ label: '产品分类', prop: 'T_class_name', align: 'center ' },
|
|
|
- { label: '产品型号', prop: 'T_model', align: 'center ' },
|
|
|
+ { label: '产品型号', prop: 'T_model', align: 'center ', ellipsis: true },
|
|
|
{ label: '产品规格', prop: 'T_spec', align: 'center ' },
|
|
|
{ label: '是否关联SN', prop: 'T_relation_sn', align: 'center ', width: 120, name: 'T_relation_sn' },
|
|
|
{ label: '*数量', prop: 'count', align: 'center ', name: 'count' },
|
|
@@ -87,18 +99,67 @@ const countBlurHandle = () => {
|
|
|
return `${item.Id},${item.count}`
|
|
|
})
|
|
|
}
|
|
|
-// const snBlurHandle = ()=>{
|
|
|
-// form.T_product = tableData.value.map(item => {
|
|
|
-// if (!item.sn) return undefined
|
|
|
-// return `${item.Id},${item.count}`
|
|
|
-// })
|
|
|
-// }
|
|
|
+const getDeviceSnToProduct = () => {
|
|
|
+ const DeviceSnData: any = drawerSnRef.value?.getDeviceSn()
|
|
|
+ // if (!DeviceSnData.size) {
|
|
|
+ // const index = tableData.value.findIndex((item: any) => item.T_relation_sn === 1)
|
|
|
+ // if (index !== -1) return [null]
|
|
|
+ // else {
|
|
|
+ // return tableData.value.map(item => {
|
|
|
+ // if (!item.count) return undefined
|
|
|
+ // return `${item.Id},${item.count}`
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ if (!DeviceSnData.size) return [null]
|
|
|
+ if (!tableData.value.every((item: any) => item.count)) return [undefined]
|
|
|
+ return tableData.value.map((item: any) => {
|
|
|
+ let product: any = ''
|
|
|
+ DeviceSnData?.forEach((value: any, key: number) => {
|
|
|
+ // T_relation_sn === 1
|
|
|
+ if (item.Id === key) {
|
|
|
+ if (item.T_relation_sn === 1 && value.length > 0) {
|
|
|
+ let str = ''
|
|
|
+ value.forEach((snObj: any) => (str += snObj.sn + ','))
|
|
|
+ product = `${item.Id}-${item.count}-${str}`
|
|
|
+ } else {
|
|
|
+ product = null
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (item.count) {
|
|
|
+ product = `${item.Id}-${item.count}-`
|
|
|
+ } else {
|
|
|
+ product = undefined
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return product + '|'
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const AddInStorage = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+ form.T_product = getDeviceSnToProduct()
|
|
|
+
|
|
|
+ formEl.validate(async valid => {
|
|
|
+ if (valid) {
|
|
|
+ const res = await Storehouse_StockIn_Add({
|
|
|
+ User_tokey: globalStore.GET_User_tokey,
|
|
|
+ ...form,
|
|
|
+ T_product: form.T_product.toString()
|
|
|
+ })
|
|
|
+ console.log(res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
const deleteProduct = (row: any) => {
|
|
|
tableData.value = tableData.value.filter(item => item.Id !== row.Id)
|
|
|
|
|
|
// 设置产品的选中
|
|
|
selectTable.value?.toggleRowSelection(row, false)
|
|
|
+ // 删除设备得sn
|
|
|
+ drawerSnRef.value?.deleteDeviceSn(row.Id)
|
|
|
}
|
|
|
|
|
|
const callbackDrawer = (done: Fn) => {
|
|
@@ -107,7 +168,6 @@ const callbackDrawer = (done: Fn) => {
|
|
|
done()
|
|
|
}
|
|
|
const callbackProductDrawer = (done: Fn) => done()
|
|
|
-const callbackSnDrawer = (done: Fn) => done()
|
|
|
|
|
|
const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return
|
|
@@ -207,6 +267,7 @@ let total = 0
|
|
|
const tableProductData = ref<any[]>([])
|
|
|
const getProductList = async () => {
|
|
|
const res: any = await Storehouse_Product_List({ ...initParam, T_name: autoSelect.value })
|
|
|
+ if (!res.Data.Data) return
|
|
|
tableProductData.value.push(...res.Data.Data)
|
|
|
total = res.Data.Num
|
|
|
if (!isNew.value) {
|
|
@@ -220,15 +281,8 @@ const getProductList = async () => {
|
|
|
}
|
|
|
const ProductselectionChange = (row: any[]) => {
|
|
|
const newProduct = row.find((product: any) => tableData.value.findIndex((item: any) => item.Id === product.Id) === -1)
|
|
|
+
|
|
|
newProduct && tableData.value.push(newProduct)
|
|
|
- // if (!isNew.value) {
|
|
|
- // const newProduct = row.find(
|
|
|
- // (product: any) => tableData.value.findIndex((item: any) => item.Id === product.Id) === -1
|
|
|
- // )
|
|
|
- // newProduct && tableData.value.push({ ...newProduct })
|
|
|
- // } else {
|
|
|
- // tableData.value = row
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
// 搜索模型
|
|
@@ -244,40 +298,16 @@ const getRowKey = (row: any) => {
|
|
|
}
|
|
|
|
|
|
// 添加sn
|
|
|
-const addDeviceSn = () => {
|
|
|
- //
|
|
|
- drawerSnRef.value?.openDrawer()
|
|
|
+const addDeviceSn = (id: number) => {
|
|
|
+ drawerSnRef.value?.addDeviceSn(id)
|
|
|
}
|
|
|
-const tableSnData: any[] = reactive([{ sn: 12131423 }])
|
|
|
-const snColumns = [
|
|
|
- { type: 'index', label: '序号', width: 80, align: 'center ' },
|
|
|
- { label: 'SN', prop: 'sn', align: 'center ' },
|
|
|
- { prop: 'operation', label: '操作', width: 80, fixed: 'right' }
|
|
|
-]
|
|
|
-
|
|
|
-const ruleSnFormRef = ref()
|
|
|
-const formSn = reactive({
|
|
|
- T_sn: ''
|
|
|
-})
|
|
|
-const rulesSn = reactive<FormRules>({
|
|
|
- T_sn: [{ required: true, message: '请输入SN号', trigger: 'blur' }]
|
|
|
-})
|
|
|
-
|
|
|
-const addSn = (formEl: FormInstance | undefined) => {
|
|
|
- if (!formEl) return
|
|
|
- formEl.validate(async valid => {
|
|
|
- if (valid) {
|
|
|
- console.log('push')
|
|
|
-
|
|
|
- tableSnData.push({ sn: formSn.T_sn })
|
|
|
+const autoGetCount = (length: number, id: number) => {
|
|
|
+ tableData.value.forEach((item: any) => {
|
|
|
+ if (item.Id === id) {
|
|
|
+ item.count = length
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-const deleteSn = (row: any) => {
|
|
|
- const index = tableSnData.findIndex((item: any) => row.sn === item.sn)
|
|
|
- tableSnData.splice(index, 1)
|
|
|
-}
|
|
|
-
|
|
|
// 接受props
|
|
|
interface ItemType {
|
|
|
T_name: string
|
|
@@ -302,7 +332,7 @@ defineExpose({
|
|
|
<el-form ref="ruleFormRef" :model="form" :rules="rules">
|
|
|
<el-divider border-style="dashed" />
|
|
|
<el-form-item label="入库单号:" :label-width="formLabelWidth" prop="T_number">
|
|
|
- <el-input v-model="form.T_number" type="text" :disabled="true" placeholder="请输入入库单号" class="w-50" />
|
|
|
+ <el-input v-model="form.T_number" type="text" :disabled="true" placeholder="系统自动生成" class="w-50" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="入库仓库:" :label-width="formLabelWidth" prop="T_depot_id">
|
|
|
<el-select v-model="form.T_depot_id" class="w-50" clearable placeholder="请选择入库仓库~">
|
|
@@ -332,27 +362,30 @@ defineExpose({
|
|
|
}"
|
|
|
>
|
|
|
<template v-for="item in columns" :key="item.prop">
|
|
|
- <el-table-column v-bind="item" v-if="item.fixed !== 'right'">
|
|
|
+ <el-table-column v-bind="item" v-if="item.fixed !== 'right' && !item.ellipsis">
|
|
|
<template #header v-if="item.prop === 'count' || item.prop === 'sn'">
|
|
|
<span style="color: red">{{ item.label }}</span>
|
|
|
</template>
|
|
|
<template #default="{ row }" v-if="item.prop === item.name">
|
|
|
<el-input
|
|
|
- v-if="item.prop === 'count'"
|
|
|
+ v-if="item.prop === 'count' && row.T_relation_sn !== 1"
|
|
|
v-model.number="row.count"
|
|
|
type="text"
|
|
|
autocomplete="off"
|
|
|
@blur="countBlurHandle"
|
|
|
/>
|
|
|
- <el-button
|
|
|
- v-if="item.prop === 'sn'"
|
|
|
- link
|
|
|
- type="primary"
|
|
|
- size="small"
|
|
|
- :icon="CirclePlus"
|
|
|
- @click="addDeviceSn"
|
|
|
- >添加</el-button
|
|
|
- >
|
|
|
+ <div v-if="item.prop === 'sn'">
|
|
|
+ <el-button
|
|
|
+ v-if="row.T_relation_sn === 1"
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ :icon="CirclePlus"
|
|
|
+ @click="addDeviceSn(row.Id)"
|
|
|
+ >添加</el-button
|
|
|
+ >
|
|
|
+ <span v-else>-</span>
|
|
|
+ </div>
|
|
|
<span v-if="item.prop === 'T_relation_sn'">
|
|
|
<el-tag v-if="row.T_relation_sn === 1" effect="dark">是</el-tag>
|
|
|
<el-tag v-else type="success" effect="dark">否</el-tag>
|
|
@@ -360,6 +393,13 @@ defineExpose({
|
|
|
<el-image v-if="item.prop === 'T_img'" style="height: 50px" :src="row.T_img" fit="cover" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column v-if="item.ellipsis && item.prop === 'T_model'" v-bind="item">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-tooltip effect="dark" :content="row.T_model" placement="bottom">
|
|
|
+ {{ row.T_model }}
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column v-bind="item" v-if="item.fixed === 'right'">
|
|
|
<template #default="{ row }">
|
|
|
<el-button link type="danger" size="small" :icon="Delete" @click="deleteProduct(row)">删除</el-button>
|
|
@@ -375,7 +415,6 @@ defineExpose({
|
|
|
</el-form-item>
|
|
|
<el-form-item label="入库仓库:" :label-width="formLabelWidth" prop="T_number">
|
|
|
<el-input
|
|
|
- class="w-50"
|
|
|
v-model="form.T_remark"
|
|
|
:autosize="{ minRows: 4, maxRows: 6 }"
|
|
|
type="textarea"
|
|
@@ -385,7 +424,7 @@ defineExpose({
|
|
|
<div class="btn">
|
|
|
<el-divider>
|
|
|
<el-button>取消</el-button>
|
|
|
- <el-button v-if="isNew" color="#626aef">提交</el-button>
|
|
|
+ <el-button v-if="isNew" color="#626aef" @click="AddInStorage(ruleFormRef)">提交</el-button>
|
|
|
</el-divider>
|
|
|
</div>
|
|
|
<Drawer ref="drawerProductRef" :handleClose="callbackProductDrawer" size="70%">
|
|
@@ -477,88 +516,11 @@ defineExpose({
|
|
|
</el-table>
|
|
|
</el-card>
|
|
|
</Drawer>
|
|
|
- <Drawer ref="drawerSnRef" :handleClose="callbackSnDrawer" size="50%">
|
|
|
- <el-card class="box-card" shadow="never">
|
|
|
- <template #header>
|
|
|
- <div class="sn-header">
|
|
|
- <el-form ref="ruleSnFormRef" :model="formSn" :rules="rulesSn">
|
|
|
- <el-form-item label="SN:" :label-width="formLabelWidth" prop="T_sn">
|
|
|
- <el-input v-model="formSn.T_sn" type="text" placeholder="请输入SN" class="w-50" />
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <el-button type="primary" @click="addSn(ruleSnFormRef)">添加</el-button>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <el-table
|
|
|
- ref="snTable"
|
|
|
- :data="tableSnData"
|
|
|
- style="width: 100%; height: 99%"
|
|
|
- :header-cell-style="{
|
|
|
- background: '#dedfe0',
|
|
|
- height: '50px'
|
|
|
- }"
|
|
|
- >
|
|
|
- <template v-for="item in snColumns" :key="item">
|
|
|
- <el-table-column v-if="item.type === 'index'" v-bind="item" />
|
|
|
- <el-table-column v-if="item.prop" align="center" v-bind="item">
|
|
|
- <template #default="{ row }">
|
|
|
- <el-button
|
|
|
- v-if="item.prop === 'operation'"
|
|
|
- link
|
|
|
- type="danger"
|
|
|
- size="small"
|
|
|
- :icon="Delete"
|
|
|
- @click="deleteSn(row)"
|
|
|
- >删除</el-button
|
|
|
- >
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </template>
|
|
|
- </el-table>
|
|
|
- </el-card>
|
|
|
- </Drawer>
|
|
|
+ <InStorageSn ref="drawerSnRef" @onCount="autoGetCount" />
|
|
|
</el-form>
|
|
|
</Drawer>
|
|
|
</div>
|
|
|
</template>
|
|
|
<style scoped lang="scss">
|
|
|
-.tooltip-content {
|
|
|
- max-width: 500px;
|
|
|
- overflow-y: auto;
|
|
|
-}
|
|
|
-.inStorage-form {
|
|
|
- :deep(.el-drawer__header) {
|
|
|
- margin-bottom: 0;
|
|
|
- }
|
|
|
- .box-card {
|
|
|
- height: 100%;
|
|
|
- :deep(.el-card__body) {
|
|
|
- height: calc(100% - 70px);
|
|
|
- }
|
|
|
- .sn-header {
|
|
|
- display: flex;
|
|
|
- justify-content: end;
|
|
|
- }
|
|
|
- }
|
|
|
- .btn {
|
|
|
- margin-top: 32px;
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- .el-button {
|
|
|
- padding: 0 32px;
|
|
|
- }
|
|
|
- }
|
|
|
- .w-50 {
|
|
|
- width: 21.5rem;
|
|
|
- }
|
|
|
- .input-suffix {
|
|
|
- width: 100%;
|
|
|
- .inline-flex {
|
|
|
- white-space: nowrap;
|
|
|
- }
|
|
|
- .d-flex {
|
|
|
- display: flex;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+@import './index.scss';
|
|
|
</style>
|