|
@@ -6,7 +6,7 @@
|
|
|
:width="1100"
|
|
|
:closeOnOverlayClick="false"
|
|
|
>
|
|
|
- <t-form ref="formRef" :model="formData" :labelWidth="120">
|
|
|
+ <t-form ref="formRef" :data="formData" :rules="rules" :labelWidth="120">
|
|
|
<t-row :gutter="[0, 20]">
|
|
|
<t-col :span="6">
|
|
|
<t-form-item label="设备出入库选择">
|
|
@@ -17,7 +17,7 @@
|
|
|
</t-form-item>
|
|
|
</t-col>
|
|
|
<t-col :span="6">
|
|
|
- <t-form-item label="设备出入库时间">
|
|
|
+ <t-form-item label="设备出入库时间" name="inOutTime">
|
|
|
<t-date-picker
|
|
|
v-model="formData.inOutTime"
|
|
|
style="width: 100%"
|
|
@@ -26,7 +26,7 @@
|
|
|
</t-form-item>
|
|
|
</t-col>
|
|
|
<t-col :span="12">
|
|
|
- <t-form-item label="设备出入库登记">
|
|
|
+ <t-form-item label="设备出入库登记" name="deviceInOutFormList">
|
|
|
<div class="w-full">
|
|
|
<t-table
|
|
|
class="dynamic-table"
|
|
@@ -37,21 +37,23 @@
|
|
|
bordered
|
|
|
size="small"
|
|
|
>
|
|
|
+ <template #operate="{ row }">
|
|
|
+ <svg-icon
|
|
|
+ class="delete-icon"
|
|
|
+ name="delete"
|
|
|
+ color="#262626"
|
|
|
+ @click="deleteRow(row)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
<template #key="{ row }">
|
|
|
- <div class="flex items-center key-cell">
|
|
|
- <Icon
|
|
|
- name="delete"
|
|
|
- class="delete-icon"
|
|
|
- @click="deleteRow(row)"
|
|
|
- ></Icon>
|
|
|
- <span class="key-index">{{ row.key }}</span>
|
|
|
- </div>
|
|
|
+ <span>{{ row.key }}</span>
|
|
|
</template>
|
|
|
<template #deviceNo="{ row }">
|
|
|
<t-select
|
|
|
v-if="formData.inOutType == 'OUT'"
|
|
|
v-model="row.deviceNo"
|
|
|
:options="deviceOutOptions"
|
|
|
+ @change="(data, { option }) => deviceChange(row, option)"
|
|
|
>
|
|
|
</t-select>
|
|
|
<t-select
|
|
@@ -79,12 +81,13 @@
|
|
|
</template>
|
|
|
<template #address="{ row }">
|
|
|
<span v-if="formData.inOutType == 'IN'">{{
|
|
|
- row.address.join('')
|
|
|
+ row.address
|
|
|
}}</span>
|
|
|
<select-area
|
|
|
v-else
|
|
|
v-model="row.address"
|
|
|
value-type="full"
|
|
|
+ @change="checkTable"
|
|
|
></select-area>
|
|
|
</template>
|
|
|
<template #basePhotoPath="{ row }">
|
|
@@ -94,13 +97,19 @@
|
|
|
></my-upload>
|
|
|
</template>
|
|
|
</t-table>
|
|
|
- <t-button theme="primary" class="m-t-15px" @click="createOneRow">
|
|
|
- <template #icon><Icon name="add"></Icon></template>
|
|
|
- 添加
|
|
|
- </t-button>
|
|
|
</div>
|
|
|
</t-form-item>
|
|
|
</t-col>
|
|
|
+ <t-col :span="12">
|
|
|
+ <t-form-item>
|
|
|
+ <t-button theme="primary" @click="createOneRow">
|
|
|
+ <template #icon
|
|
|
+ ><svg-icon name="add-circle" color="#fff"
|
|
|
+ /></template>
|
|
|
+ 添加
|
|
|
+ </t-button>
|
|
|
+ </t-form-item>
|
|
|
+ </t-col>
|
|
|
</t-row>
|
|
|
</t-form>
|
|
|
<template #foot>
|
|
@@ -114,7 +123,6 @@
|
|
|
<script setup name="AddDeviceDialog">
|
|
|
import { ref, watch } from 'vue';
|
|
|
import { cloneDeep, omit } from 'lodash';
|
|
|
-import { Icon } from 'tdesign-icons-vue-next';
|
|
|
import useOptions from '@/hooks/useOptions';
|
|
|
import { RUNNING_STATUS } from '@/config/constants';
|
|
|
import { dictToOptionList } from '@/utils/tool';
|
|
@@ -144,19 +152,69 @@ watch(
|
|
|
}
|
|
|
);
|
|
|
watch(
|
|
|
- () => formData.inOutType,
|
|
|
+ () => formData.value.inOutType,
|
|
|
() => {
|
|
|
tableData.value = [];
|
|
|
}
|
|
|
);
|
|
|
+const rules = {
|
|
|
+ inOutTime: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '设备出入库时间必选',
|
|
|
+ type: 'error',
|
|
|
+ trigger: 'change',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ deviceInOutFormList: [
|
|
|
+ {
|
|
|
+ validator: () => {
|
|
|
+ if (!tableData.value.length) {
|
|
|
+ return {
|
|
|
+ result: false,
|
|
|
+ message: '请填写至少一条记录',
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ if (formData.value.inOutType === 'OUT') {
|
|
|
+ const valid = tableData.value.every((item) => {
|
|
|
+ return item.deviceNo && item.address[2];
|
|
|
+ });
|
|
|
+ if (!valid) {
|
|
|
+ return {
|
|
|
+ result: false,
|
|
|
+ message: '设备信息未填写完整',
|
|
|
+ };
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const valid = tableData.value.every((item) => {
|
|
|
+ return item.deviceNo && item.deviceStatus && item.scanCount;
|
|
|
+ });
|
|
|
+ if (!valid) {
|
|
|
+ return {
|
|
|
+ result: false,
|
|
|
+ message: '设备信息未填写完整',
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ return {
|
|
|
+ result: true,
|
|
|
+ type: 'success',
|
|
|
+ };
|
|
|
+ },
|
|
|
+ type: 'error',
|
|
|
+ trigger: 'change',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+};
|
|
|
const columns = [
|
|
|
{
|
|
|
- title: '',
|
|
|
+ title: '序号',
|
|
|
coleKey: 'key',
|
|
|
cell: 'key',
|
|
|
- align: 'left',
|
|
|
- width: 80,
|
|
|
+ align: 'center',
|
|
|
+ width: 50,
|
|
|
},
|
|
|
{
|
|
|
title: '设备编号',
|
|
@@ -170,12 +228,12 @@ const columns = [
|
|
|
{
|
|
|
title: '运行状态',
|
|
|
colKey: 'deviceStatus',
|
|
|
- width: 120,
|
|
|
+ width: 105,
|
|
|
},
|
|
|
{
|
|
|
title: '总扫描量',
|
|
|
colKey: 'scanCount',
|
|
|
- width: 90,
|
|
|
+ width: 80,
|
|
|
},
|
|
|
{
|
|
|
title: '当前所在地',
|
|
@@ -190,16 +248,36 @@ const columns = [
|
|
|
colKey: 'basePhotoPath',
|
|
|
width: 98,
|
|
|
},
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ colKey: 'operate',
|
|
|
+ width: 50,
|
|
|
+ align: 'center',
|
|
|
+ },
|
|
|
];
|
|
|
const tableData = ref([]);
|
|
|
const resetKeys = () => {
|
|
|
tableData.value.forEach((item, index) => {
|
|
|
item.key = index + 1 + '';
|
|
|
});
|
|
|
+ checkTable();
|
|
|
+};
|
|
|
+const checkTable = async () => {
|
|
|
+ await formRef.value?.validate({ fields: ['deviceInOutFormList'] });
|
|
|
};
|
|
|
const imgChange = (obj, row) => {
|
|
|
row.basePhotoPath = obj.url;
|
|
|
};
|
|
|
+const deviceChange = (row, option) => {
|
|
|
+ row.supplierName = option.supplierName;
|
|
|
+ row.deviceStatus = option.deviceStatus;
|
|
|
+ row.scanCount = option.scanCount;
|
|
|
+ row.location = option.location;
|
|
|
+ if (formData.value.inOutType === 'IN') {
|
|
|
+ row.address = option.supplierName;
|
|
|
+ }
|
|
|
+ checkTable();
|
|
|
+};
|
|
|
const createOneRow = () => {
|
|
|
tableData.value.push({
|
|
|
deviceNo: '',
|
|
@@ -207,7 +285,7 @@ const createOneRow = () => {
|
|
|
deviceStatus: '',
|
|
|
scanCount: '',
|
|
|
location: '',
|
|
|
- address: ['', '', ''],
|
|
|
+ address: formData.value.inOutType === 'OUT' ? ['', '', ''] : '',
|
|
|
basePhotoPath: '',
|
|
|
});
|
|
|
resetKeys();
|
|
@@ -219,26 +297,11 @@ const deleteRow = (row) => {
|
|
|
tableData.value.splice(index, 1);
|
|
|
resetKeys();
|
|
|
};
|
|
|
-const validate = () => {
|
|
|
- if (!tableData.value.length) {
|
|
|
- MessagePlugin.error('请填写至少一条记录');
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (formData.inOutType === 'OUT') {
|
|
|
- return tableData.value.every((item) => {
|
|
|
- return item.deviceNo && item.address[2];
|
|
|
- });
|
|
|
- } else {
|
|
|
- MessagePlugin.error('设备信息未填写完整');
|
|
|
- return tableData.value.every((item) => {
|
|
|
- return item.deviceNo && item.deviceStatus && item.scanCount;
|
|
|
- });
|
|
|
- }
|
|
|
-};
|
|
|
-const save = () => {
|
|
|
- if (!validate()) {
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
+const save = async () => {
|
|
|
+ const valid = await formRef.value.validate();
|
|
|
+ if (valid !== true) return;
|
|
|
+
|
|
|
let deviceInOutFormList = tableData.value.map((item) => {
|
|
|
item.address = item.address.join('');
|
|
|
return { ...omit(item, 'key') };
|
|
@@ -257,17 +320,11 @@ const save = () => {
|
|
|
.dynamic-table {
|
|
|
width: 100%;
|
|
|
margin-bottom: 15px;
|
|
|
- .key-cell {
|
|
|
- .key-index {
|
|
|
- font-size: 14px;
|
|
|
- }
|
|
|
- .delete-icon {
|
|
|
- font-size: 18px;
|
|
|
- color: #777;
|
|
|
- margin-right: 10px;
|
|
|
- cursor: pointer;
|
|
|
- &:hover {
|
|
|
- color: var(--td-brand-color);
|
|
|
+ .delete-icon {
|
|
|
+ cursor: pointer;
|
|
|
+ &:hover {
|
|
|
+ :deep(use) {
|
|
|
+ fill: var(--td-brand-color);
|
|
|
}
|
|
|
}
|
|
|
}
|