|
@@ -1,16 +1,49 @@
|
|
<template>
|
|
<template>
|
|
<n-space vertical>
|
|
<n-space vertical>
|
|
- <n-space justify="space-between">
|
|
|
|
- <n-input-group>
|
|
|
|
- <n-input style="width: 300px" placeholder="请输入项目名称" />
|
|
|
|
- <n-button type="primary"> 搜索 </n-button>
|
|
|
|
- </n-input-group>
|
|
|
|
- <n-space>
|
|
|
|
- <n-button type="primary">批量导入</n-button>
|
|
|
|
- <n-button type="primary" @click="handleAdd">添加</n-button>
|
|
|
|
|
|
+ <n-page-header @back="() => $router.back()">
|
|
|
|
+ <template #title> 返回上一级 </template>
|
|
|
|
+ <template #header>
|
|
|
|
+ <n-breadcrumb>
|
|
|
|
+ <n-breadcrumb-item>任务管理</n-breadcrumb-item>
|
|
|
|
+ <n-breadcrumb-item>设备管理</n-breadcrumb-item>
|
|
|
|
+ </n-breadcrumb>
|
|
|
|
+ </template>
|
|
|
|
+ <n-space justify="space-between">
|
|
|
|
+ <n-space>
|
|
|
|
+ <n-input-group>
|
|
|
|
+ <n-input
|
|
|
|
+ style="width: 300px"
|
|
|
|
+ v-model:value="queryData.T_sn"
|
|
|
|
+ @clear="handleClear"
|
|
|
|
+ clearable
|
|
|
|
+ placeholder="请输入SN"
|
|
|
|
+ />
|
|
|
|
+ <n-button type="primary" @click="getDeviceClassListDataList">
|
|
|
|
+ 搜索
|
|
|
|
+ </n-button>
|
|
|
|
+ </n-input-group>
|
|
|
|
+ <n-space align="center">
|
|
|
|
+ <span>分类名称 </span>
|
|
|
|
+ <n-input-group>
|
|
|
|
+ <n-input
|
|
|
|
+ style="width: 300px"
|
|
|
|
+ v-model:value="formValue.T_name"
|
|
|
|
+ placeholder="请输入分类名称"
|
|
|
|
+ />
|
|
|
|
+ <n-popconfirm @positive-click="editDeviceClassInfo">
|
|
|
|
+ <template #trigger>
|
|
|
|
+ <n-button type="primary">编辑分类</n-button>
|
|
|
|
+ </template>
|
|
|
|
+ 是否确认编辑?
|
|
|
|
+ </n-popconfirm>
|
|
|
|
+ </n-input-group>
|
|
|
|
+ </n-space>
|
|
|
|
+ </n-space>
|
|
|
|
+ <n-button type="primary" @click="showAddModal">批量导入</n-button>
|
|
</n-space>
|
|
</n-space>
|
|
- </n-space>
|
|
|
|
|
|
+ </n-page-header>
|
|
<n-data-table
|
|
<n-data-table
|
|
|
|
+ :key="(row) => row.Id"
|
|
:columns="columns"
|
|
:columns="columns"
|
|
:data="data"
|
|
:data="data"
|
|
:pagination="pagination"
|
|
:pagination="pagination"
|
|
@@ -18,6 +51,7 @@
|
|
/>
|
|
/>
|
|
</n-space>
|
|
</n-space>
|
|
<n-modal
|
|
<n-modal
|
|
|
|
+ :style="{ width: modal.title === '批量导入' ? '50%' : '' }"
|
|
:show-icon="false"
|
|
:show-icon="false"
|
|
v-model:show="modal.showModal"
|
|
v-model:show="modal.showModal"
|
|
preset="dialog"
|
|
preset="dialog"
|
|
@@ -33,10 +67,10 @@
|
|
label-width="auto"
|
|
label-width="auto"
|
|
:rules="rules"
|
|
:rules="rules"
|
|
>
|
|
>
|
|
- <n-form-item label="SN" path="T_sn">
|
|
|
|
- <n-input v-model:value="formValue.T_sn" />
|
|
|
|
|
|
+ <n-form-item label="SN" path="T_sn" v-if="modal.title === '批量导入'">
|
|
|
|
+ <n-transfer v-model:value="formValue.T_sn" :options="deviceOptions" />
|
|
</n-form-item>
|
|
</n-form-item>
|
|
- <n-form-item label="ID" path="T_id">
|
|
|
|
|
|
+ <n-form-item label="编号" path="T_id" v-else>
|
|
<n-input v-model:value="formValue.T_id" />
|
|
<n-input v-model:value="formValue.T_id" />
|
|
</n-form-item>
|
|
</n-form-item>
|
|
</n-form>
|
|
</n-form>
|
|
@@ -45,8 +79,16 @@
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
import { h } from "vue";
|
|
import { h } from "vue";
|
|
-import { NButton, NSpace } from "naive-ui";
|
|
|
|
-import { getDeviceClassData, addDeviceClassData } from "@/api";
|
|
|
|
|
|
+import { NButton, NSpace, NPopconfirm, NInput } from "naive-ui";
|
|
|
|
+import {
|
|
|
|
+ getDeviceClassListData,
|
|
|
|
+ addDeviceClassListData,
|
|
|
|
+ getDeviceData,
|
|
|
|
+ editDeviceClassListData,
|
|
|
|
+ deleteDeviceClassListData,
|
|
|
|
+ getDeviceClass,
|
|
|
|
+ editDeviceClass,
|
|
|
|
+} from "@/api";
|
|
|
|
|
|
const message = useMessage();
|
|
const message = useMessage();
|
|
|
|
|
|
@@ -58,23 +100,31 @@ const formRef = ref(null);
|
|
|
|
|
|
// 验证表项的规则
|
|
// 验证表项的规则
|
|
const rules = {
|
|
const rules = {
|
|
- T_sn: { required: true, message: "不能为空", trigger: "blur" },
|
|
|
|
- T_id: { required: true, message: "不能为空", trigger: "blur" },
|
|
|
|
|
|
+ T_sn: {
|
|
|
|
+ required: true,
|
|
|
|
+ message: "不能为空",
|
|
|
|
+ trigger: "change",
|
|
|
|
+ type: "array",
|
|
|
|
+ },
|
|
|
|
+ T_id: {
|
|
|
|
+ required: true,
|
|
|
|
+ message: "不能为空",
|
|
|
|
+ trigger: "blur",
|
|
|
|
+ type: "number",
|
|
|
|
+ },
|
|
};
|
|
};
|
|
|
|
|
|
// 查询参数
|
|
// 查询参数
|
|
const queryData = reactive({
|
|
const queryData = reactive({
|
|
T_sn: "",
|
|
T_sn: "",
|
|
|
|
+ T_name: "",
|
|
});
|
|
});
|
|
|
|
|
|
// 需要展示的列
|
|
// 需要展示的列
|
|
const columns = [
|
|
const columns = [
|
|
{
|
|
{
|
|
- title: "#",
|
|
|
|
- key: "key",
|
|
|
|
- render: (_, index) => {
|
|
|
|
- return `${index + 1}`;
|
|
|
|
- },
|
|
|
|
|
|
+ title: "编号",
|
|
|
|
+ key: "T_id",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
title: "设备序列号",
|
|
title: "设备序列号",
|
|
@@ -83,32 +133,57 @@ const columns = [
|
|
{
|
|
{
|
|
title: "操作",
|
|
title: "操作",
|
|
key: "actions",
|
|
key: "actions",
|
|
- render() {
|
|
|
|
|
|
+ render(row) {
|
|
return h(
|
|
return h(
|
|
NSpace,
|
|
NSpace,
|
|
{},
|
|
{},
|
|
{
|
|
{
|
|
default: () =>
|
|
default: () =>
|
|
- ["删除"].map((item) =>
|
|
|
|
- h(
|
|
|
|
- NButton,
|
|
|
|
- {
|
|
|
|
- type: "error",
|
|
|
|
- size: "small",
|
|
|
|
- onClick: () => {},
|
|
|
|
- },
|
|
|
|
- { default: () => item }
|
|
|
|
- )
|
|
|
|
- ),
|
|
|
|
|
|
+ ["编辑编号", "删除"].map((item) => {
|
|
|
|
+ if (item === "编辑编号") {
|
|
|
|
+ return h(
|
|
|
|
+ NButton,
|
|
|
|
+ {
|
|
|
|
+ type: "primary",
|
|
|
|
+ size: "small",
|
|
|
|
+ onClick: () => showEditModal(row),
|
|
|
|
+ },
|
|
|
|
+ { default: () => item }
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ return h(
|
|
|
|
+ NPopconfirm,
|
|
|
|
+ {
|
|
|
|
+ onPositiveClick: () => deleteDeviceClassList(row),
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ default: () => "是否确认删除?",
|
|
|
|
+ trigger: () =>
|
|
|
|
+ h(
|
|
|
|
+ NButton,
|
|
|
|
+ {
|
|
|
|
+ type: "error",
|
|
|
|
+ size: "small",
|
|
|
|
+ },
|
|
|
|
+ { default: () => item }
|
|
|
|
+ ),
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }),
|
|
}
|
|
}
|
|
);
|
|
);
|
|
},
|
|
},
|
|
},
|
|
},
|
|
];
|
|
];
|
|
|
|
|
|
-// 设备列表
|
|
|
|
|
|
+// 设备分类-设备列表
|
|
const data = ref([]);
|
|
const data = ref([]);
|
|
|
|
|
|
|
|
+// 设备列表
|
|
|
|
+const deviceList = ref([]);
|
|
|
|
+const deviceOptions = ref([]);
|
|
|
|
+
|
|
const pagination = ref(false);
|
|
const pagination = ref(false);
|
|
|
|
|
|
// 模态框数据源
|
|
// 模态框数据源
|
|
@@ -117,34 +192,69 @@ const modal = reactive({
|
|
showModal: false,
|
|
showModal: false,
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+// 获取表项中收集到的值的对象
|
|
|
|
+const formValue = reactive({
|
|
|
|
+ T_sn: null,
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+// 输入框点击清空按钮时触发
|
|
|
|
+const handleClear = () => {
|
|
|
|
+ queryData.T_sn = "";
|
|
|
|
+ getDeviceClassListDataList();
|
|
|
|
+};
|
|
|
|
+
|
|
const submitCallback = () => {
|
|
const submitCallback = () => {
|
|
- if (modal.title === "添加") {
|
|
|
|
- addDeviceClass();
|
|
|
|
|
|
+ if (modal.title === "批量导入") {
|
|
|
|
+ formRef.value.validate(async (errors) => {
|
|
|
|
+ if (!errors) {
|
|
|
|
+ formValue.T_sn.forEach((T_sn) => {
|
|
|
|
+ const T_id = deviceList.value.find((item) => item.T_sn === T_sn).T_id;
|
|
|
|
+ addDeviceClassList(T_sn, T_id);
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ modal.showModal = true;
|
|
|
|
+ message.error("验证失败,请填写完整信息");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ editDeviceClassList();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-const handleAdd = () => {
|
|
|
|
- modal.title = "添加";
|
|
|
|
|
|
+
|
|
|
|
+// 显示编辑
|
|
|
|
+const showEditModal = (row) => {
|
|
|
|
+ modal.title = "编辑编号";
|
|
modal.showModal = true;
|
|
modal.showModal = true;
|
|
|
|
+ Object.assign(formValue, row);
|
|
};
|
|
};
|
|
|
|
|
|
-// 获取表项中收集到的值的对象
|
|
|
|
-const formValue = reactive({
|
|
|
|
- T_sn: null,
|
|
|
|
- T_id: null,
|
|
|
|
-});
|
|
|
|
|
|
+// 显示添加
|
|
|
|
+const showAddModal = () => {
|
|
|
|
+ modal.title = "批量导入";
|
|
|
|
+ modal.showModal = true;
|
|
|
|
+ Object.keys(formValue).forEach((key) => (formValue[key] = null));
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 删除
|
|
|
|
+const deleteDeviceClassList = async (row) => {
|
|
|
|
+ const { data: res } = await deleteDeviceClassListData({
|
|
|
|
+ Id: row.Id,
|
|
|
|
+ });
|
|
|
|
+ message.success(res.Msg);
|
|
|
|
+ getDeviceClassListDataList();
|
|
|
|
+};
|
|
|
|
|
|
-// 添加
|
|
|
|
-const addDeviceClass = () => {
|
|
|
|
|
|
+// 编辑编号
|
|
|
|
+const editDeviceClassList = () => {
|
|
formRef.value.validate(async (errors) => {
|
|
formRef.value.validate(async (errors) => {
|
|
if (!errors) {
|
|
if (!errors) {
|
|
try {
|
|
try {
|
|
- const { data: res } = await addDeviceClassData({
|
|
|
|
- T_class: props.taskId,
|
|
|
|
- T_sn: formValue.T_sn,
|
|
|
|
|
|
+ const { data: res } = await editDeviceClassListData({
|
|
|
|
+ Id: formValue.Id,
|
|
T_id: formValue.T_id,
|
|
T_id: formValue.T_id,
|
|
});
|
|
});
|
|
message.success(res.Msg);
|
|
message.success(res.Msg);
|
|
- getDeviceClassList();
|
|
|
|
|
|
+ getDeviceClassListDataList();
|
|
} finally {
|
|
} finally {
|
|
formRef.value.restoreValidation();
|
|
formRef.value.restoreValidation();
|
|
Object.keys(formValue).forEach((key) => (formValue[key] = ""));
|
|
Object.keys(formValue).forEach((key) => (formValue[key] = ""));
|
|
@@ -156,9 +266,25 @@ const addDeviceClass = () => {
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
-// 设备管理(列表)
|
|
|
|
-const getDeviceClassList = async () => {
|
|
|
|
- const { data: res } = await getDeviceClassData({
|
|
|
|
|
|
+// 批量导入
|
|
|
|
+const addDeviceClassList = async (T_sn, T_id) => {
|
|
|
|
+ try {
|
|
|
|
+ const { data: res } = await addDeviceClassListData({
|
|
|
|
+ T_class: props.taskId,
|
|
|
|
+ T_sn,
|
|
|
|
+ T_id,
|
|
|
|
+ });
|
|
|
|
+ message.success(res.Msg);
|
|
|
|
+ getDeviceClassListDataList();
|
|
|
|
+ } finally {
|
|
|
|
+ formRef.value.restoreValidation();
|
|
|
|
+ Object.keys(formValue).forEach((key) => (formValue[key] = ""));
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 设备分类-设备列表(列表)
|
|
|
|
+const getDeviceClassListDataList = async () => {
|
|
|
|
+ const { data: res } = await getDeviceClassListData({
|
|
T_class: props.taskId,
|
|
T_class: props.taskId,
|
|
T_sn: queryData.T_sn,
|
|
T_sn: queryData.T_sn,
|
|
});
|
|
});
|
|
@@ -166,7 +292,42 @@ const getDeviceClassList = async () => {
|
|
data.value = res.Data.List;
|
|
data.value = res.Data.List;
|
|
};
|
|
};
|
|
|
|
|
|
-getDeviceClassList();
|
|
|
|
|
|
+// 设备管理(列表)
|
|
|
|
+const getDeviceList = async () => {
|
|
|
|
+ const { data: res } = await getDeviceData({
|
|
|
|
+ T_MSISDN: "",
|
|
|
|
+ T_sn: "",
|
|
|
|
+ page: "",
|
|
|
|
+ page_z: "",
|
|
|
|
+ });
|
|
|
|
+ deviceOptions.value = res.Data.List.map((item) => ({
|
|
|
|
+ label: item.T_sn,
|
|
|
|
+ value: item.T_sn,
|
|
|
|
+ }));
|
|
|
|
+ deviceList.value = res.Data.List;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 设备分类(修改)
|
|
|
|
+const editDeviceClassInfo = async () => {
|
|
|
|
+ const { data: res } = await editDeviceClass({
|
|
|
|
+ Id: props.taskId,
|
|
|
|
+ T_name: formValue.T_name,
|
|
|
|
+ });
|
|
|
|
+ message.success(res.Msg);
|
|
|
|
+ getDeviceClassInfo();
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 设备分类(获取)
|
|
|
|
+const getDeviceClassInfo = async () => {
|
|
|
|
+ const { data: res } = await getDeviceClass({
|
|
|
|
+ Id: props.taskId,
|
|
|
|
+ });
|
|
|
|
+ formValue.T_name = res.Data.T_name;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+getDeviceClassInfo();
|
|
|
|
+getDeviceList();
|
|
|
|
+getDeviceClassListDataList();
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped></style>
|
|
<style scoped></style>
|