|
|
|
@ -6,13 +6,14 @@ |
|
|
|
:inline="true" |
|
|
|
v-show="showSearch" |
|
|
|
label-width="68px" |
|
|
|
@submit.native.prevent="handleQuery" |
|
|
|
> |
|
|
|
<!-- 新增:订单号搜索项 --> |
|
|
|
|
|
|
|
<el-form-item label="所属批次" prop="batchNo"> |
|
|
|
<el-form-item label="订单号" prop="orderCode"> |
|
|
|
<el-input |
|
|
|
v-model="queryParams.batchNo" |
|
|
|
placeholder="请输入所属批次" |
|
|
|
v-model="queryParams.orderCode" |
|
|
|
placeholder="请输入订单号" |
|
|
|
clearable |
|
|
|
size="small" |
|
|
|
@keyup.enter.native="handleQuery" |
|
|
|
@ -29,6 +30,22 @@ |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item label="是否启用" prop="activationStatus"> |
|
|
|
<el-select |
|
|
|
v-model="queryParams.activationStatus" |
|
|
|
placeholder="请选择启用状态" |
|
|
|
clearable |
|
|
|
size="small" |
|
|
|
@keyup.enter.native="handleQuery" |
|
|
|
> |
|
|
|
<el-option label="否" :value="0" /> |
|
|
|
<el-option label="是" :value="1" /> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item> |
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" |
|
|
|
>搜索</el-button |
|
|
|
@ -68,6 +85,7 @@ |
|
|
|
icon="el-icon-s-claim" |
|
|
|
size="mini" |
|
|
|
@click="handleClaimDevice" |
|
|
|
v-hasPermi="['device:device:claim:batch']" |
|
|
|
>认领设备</el-button> |
|
|
|
</el-col> |
|
|
|
<el-col :span="1.5"> |
|
|
|
@ -77,8 +95,30 @@ |
|
|
|
icon="el-icon-circle-check" |
|
|
|
size="mini" |
|
|
|
:disabled="multiple" |
|
|
|
v-hasPermi="['device:device:activate:batch']" |
|
|
|
@click="handleBatchActivate" |
|
|
|
>批量激活</el-button> |
|
|
|
>批量启用</el-button> |
|
|
|
</el-col> |
|
|
|
<el-col :span="1.5"> |
|
|
|
<el-button |
|
|
|
type="danger" |
|
|
|
plain |
|
|
|
icon="el-icon-circle-close" |
|
|
|
size="mini" |
|
|
|
:disabled="multiple" |
|
|
|
@click="handleBatchDisable" |
|
|
|
>批量禁用</el-button> |
|
|
|
</el-col> |
|
|
|
<el-col :span="1.5"> |
|
|
|
<el-button |
|
|
|
type="info" |
|
|
|
plain |
|
|
|
icon="el-icon-user" |
|
|
|
size="mini" |
|
|
|
:disabled="multiple" |
|
|
|
v-hasPermi="['device:device:activate:batch']" |
|
|
|
@click="handleAssignDevice" |
|
|
|
>分配设备</el-button> |
|
|
|
</el-col> |
|
|
|
<!-- <el-col :span="1.5"> |
|
|
|
<el-button |
|
|
|
@ -124,14 +164,18 @@ |
|
|
|
@selection-change="handleSelectionChange" |
|
|
|
> |
|
|
|
<el-table-column type="selection" width="55" align="center" /> |
|
|
|
<el-table-column label="ID" align="center" prop="id" /> |
|
|
|
<el-table-column label="序列号" align="center" prop="sn" /> |
|
|
|
<el-table-column label="MAC 地址" align="center" prop="mac" /> |
|
|
|
<el-table-column label="私钥" align="center" prop="privateKey" /> |
|
|
|
<el-table-column label="所属批次" align="center" prop="batchNo" /> |
|
|
|
<el-table-column label="设备的唯一哈希 ID" align="center" prop="hashid" /> |
|
|
|
<el-table-column label="型号" align="center" prop="model" /> |
|
|
|
<el-table-column label="企业" align="center" prop="merchantName" /> |
|
|
|
<el-table-column label="MAC 地址" align="center" prop="mac" min-width="140" /> |
|
|
|
<el-table-column label="订单号" align="center" prop="orderCode" /> |
|
|
|
<el-table-column label="最后地址名称" align="center" prop="lastAddress" min-width="180" /> |
|
|
|
|
|
|
|
<el-table-column label="是否启用" align="center" prop="activationStatus" width="100"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-tag :type="getActivationTagType(scope.row.activationStatus)" size="mini"> |
|
|
|
{{ getActivationStatusLabel(scope.row.activationStatus) }} |
|
|
|
</el-tag> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<!-- <el-table-column label="绑定企业id" align="center" prop="bindBusinessId" /> --> |
|
|
|
<el-table-column |
|
|
|
@ -144,8 +188,11 @@ |
|
|
|
<span>{{ parseTime(scope.row.locateUpdateTime, "{y}-{m}-{d}") }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="最后纬度" align="center" prop="lastLat" /> |
|
|
|
<el-table-column label="最后经度" align="center" prop="lastLng" /> |
|
|
|
<el-table-column label="最后经纬度" align="center" min-width="220"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span>{{ formatCoordinates(scope.row.lastLat, scope.row.lastLng) }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="电量" align="center" prop="battery" /> |
|
|
|
<el-table-column |
|
|
|
label="最后上报时间" |
|
|
|
@ -167,7 +214,7 @@ |
|
|
|
<span>{{ parseTime(scope.row.lastLocationTime, "{y}-{m}-{d}") }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width"> |
|
|
|
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-button |
|
|
|
size="mini" |
|
|
|
@ -175,6 +222,12 @@ |
|
|
|
icon="el-icon-view" |
|
|
|
@click="handleDetail(scope.row)" |
|
|
|
>详情</el-button> |
|
|
|
<el-button |
|
|
|
size="mini" |
|
|
|
type="text" |
|
|
|
icon="el-icon-location-outline" |
|
|
|
@click="handleTrajectory(scope.row)" |
|
|
|
>轨迹</el-button> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
|
|
|
@ -219,9 +272,10 @@ |
|
|
|
:model="importForm" |
|
|
|
:rules="importRules" |
|
|
|
label-width="90px" |
|
|
|
@submit.native.prevent |
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Excel文件上传:仅1个文件(修复核心) --> |
|
|
|
@ -329,10 +383,36 @@ |
|
|
|
:visible.sync="businessSelectVisible" |
|
|
|
@select="handleBusinessSelect" |
|
|
|
/> |
|
|
|
<BusinessSelect |
|
|
|
:visible.sync="searchBusinessSelectVisible" |
|
|
|
@select="handleSearchBusinessSelect" |
|
|
|
/> |
|
|
|
<DeviceClaimDialog |
|
|
|
:visible.sync="claimDeviceOpen" |
|
|
|
@success="handleClaimSuccess" |
|
|
|
/> |
|
|
|
<el-dialog |
|
|
|
title="分配设备" |
|
|
|
:visible.sync="assignDeviceOpen" |
|
|
|
width="1200px" |
|
|
|
append-to-body |
|
|
|
@close="handleAssignDialogClose" |
|
|
|
> |
|
|
|
<UserSelector |
|
|
|
ref="userSelector" |
|
|
|
selection-mode |
|
|
|
@select="handleAssignUserSelect" |
|
|
|
/> |
|
|
|
<div slot="footer" class="dialog-footer"> |
|
|
|
<span class="assign-selected-user"> |
|
|
|
{{ `已选择员工:${selectedAssignUsers.length} 人` }} |
|
|
|
</span> |
|
|
|
<el-button @click="handleAssignDialogClose">取 消</el-button> |
|
|
|
<el-button type="primary" :loading="assignLoading" @click="handleAssignSubmit"> |
|
|
|
确 定 |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
</el-dialog> |
|
|
|
<el-dialog |
|
|
|
title="设备详情" |
|
|
|
:visible.sync="detailOpen" |
|
|
|
@ -344,16 +424,23 @@ |
|
|
|
<el-descriptions-item label="ID">{{ detailForm.id || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="序列号">{{ detailForm.sn || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="MAC 地址">{{ detailForm.mac || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="私钥">{{ detailForm.privateKey || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="所属批次">{{ detailForm.batchNo || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="设备的唯一哈希 ID">{{ detailForm.hashid || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="型号">{{ detailForm.model || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="企业">{{ detailForm.merchantName || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="企业"> |
|
|
|
{{ detailForm.businessName || detailForm.merchantName || "-" }} |
|
|
|
</el-descriptions-item> |
|
|
|
<el-descriptions-item label="分配员工"> |
|
|
|
{{ formatAssignedUsers(detailForm.assignedUsers) }} |
|
|
|
</el-descriptions-item> |
|
|
|
<el-descriptions-item label="最后地址名称"> |
|
|
|
{{ detailForm.lastAddress || "-" }} |
|
|
|
</el-descriptions-item> |
|
|
|
<el-descriptions-item label="最后位置更新时间"> |
|
|
|
{{ detailForm.locateUpdateTime ? parseTime(detailForm.locateUpdateTime, "{y}-{m}-{d}") : "-" }} |
|
|
|
</el-descriptions-item> |
|
|
|
<el-descriptions-item label="最后纬度">{{ detailForm.lastLat || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="最后经度">{{ detailForm.lastLng || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="最后经纬度"> |
|
|
|
{{ formatCoordinates(detailForm.lastLat, detailForm.lastLng) }} |
|
|
|
</el-descriptions-item> |
|
|
|
<el-descriptions-item label="电量">{{ detailForm.battery || "-" }}</el-descriptions-item> |
|
|
|
<el-descriptions-item label="最后上报时间"> |
|
|
|
{{ detailForm.lastReportedTime ? parseTime(detailForm.lastReportedTime, "{y}-{m}-{d}") : "-" }} |
|
|
|
@ -367,6 +454,10 @@ |
|
|
|
<el-button type="primary" @click="detailOpen = false">关 闭</el-button> |
|
|
|
</div> |
|
|
|
</el-dialog> |
|
|
|
<DeviceTrajectoryDialog |
|
|
|
:visible.sync="trajectoryOpen" |
|
|
|
:device="trajectoryDevice" |
|
|
|
/> |
|
|
|
<!-- 添加或修改系统设备主对话框 --> |
|
|
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
|
|
|
@ -474,20 +565,58 @@ import { |
|
|
|
addDevice, |
|
|
|
updateDevice, |
|
|
|
batchActivateDevice, |
|
|
|
batchDisableDevice, |
|
|
|
exportDevice, |
|
|
|
getBatchNo, |
|
|
|
} from "@/api/device/device"; |
|
|
|
// 新增:导入相关API(需根据实际后端接口调整) |
|
|
|
import { importDeviceSync } from "@/api/device/device"; |
|
|
|
import { assignBusinessUserDevices } from "@/api/business/businessUser"; |
|
|
|
// 导入企业选择组件 |
|
|
|
import BusinessSelect from "@/components/business/BusinessSelect"; // 替换为实际组件路径 |
|
|
|
import DeviceClaimDialog from "@/components/device"; |
|
|
|
import DeviceTrajectoryDialog from "@/components/device/TrajectoryDialog"; |
|
|
|
import UserSelector from "@/components/user"; |
|
|
|
|
|
|
|
function getDefaultImportForm() { |
|
|
|
return { |
|
|
|
orderCode: "", |
|
|
|
batchNo: "", |
|
|
|
remark: "", |
|
|
|
bindBusinessId: "", |
|
|
|
businessName: "", |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
function getDefaultQueryParams() { |
|
|
|
return { |
|
|
|
pageNum: 1, |
|
|
|
pageSize: 10, |
|
|
|
sn: null, |
|
|
|
mac: null, |
|
|
|
privateKey: null, |
|
|
|
batchNo: null, |
|
|
|
hashid: null, |
|
|
|
model: null, |
|
|
|
activationStatus: undefined, |
|
|
|
bindBusinessId: null, |
|
|
|
locateUpdateTime: null, |
|
|
|
lastLat: null, |
|
|
|
lastLng: null, |
|
|
|
battery: null, |
|
|
|
lastReportedTime: null, |
|
|
|
lastLocationTime: null, |
|
|
|
orderCode: null, |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
export default { |
|
|
|
name: "Device", |
|
|
|
components: { |
|
|
|
BusinessSelect, |
|
|
|
DeviceClaimDialog, |
|
|
|
DeviceTrajectoryDialog, |
|
|
|
UserSelector, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
@ -504,6 +633,10 @@ export default { |
|
|
|
showSearch: true, |
|
|
|
// 总条数 |
|
|
|
total: 0, |
|
|
|
activationStatusOptions: [ |
|
|
|
{ label: "已启用", value: true }, |
|
|
|
{ label: "未启用", value: false }, |
|
|
|
], |
|
|
|
// 系统设备主表格数据 |
|
|
|
deviceList: [], |
|
|
|
// 弹出层标题 |
|
|
|
@ -516,6 +649,16 @@ export default { |
|
|
|
detailLoading: false, |
|
|
|
// 详情数据 |
|
|
|
detailForm: null, |
|
|
|
// 是否显示轨迹弹窗 |
|
|
|
trajectoryOpen: false, |
|
|
|
// 轨迹弹窗设备 |
|
|
|
trajectoryDevice: null, |
|
|
|
// 是否显示分配设备弹窗 |
|
|
|
assignDeviceOpen: false, |
|
|
|
// 分配提交中 |
|
|
|
assignLoading: false, |
|
|
|
// 当前选中的员工 |
|
|
|
selectedAssignUsers: [], |
|
|
|
// 是否显示认领设备弹窗 |
|
|
|
claimDeviceOpen: false, |
|
|
|
// 是否显示导入弹窗 |
|
|
|
@ -524,21 +667,12 @@ export default { |
|
|
|
importing: false, |
|
|
|
bindBusinessId: "", // 企业ID |
|
|
|
businessName: "", // 企业名称 |
|
|
|
searchBusinessName: "", |
|
|
|
// 导入表单数据 |
|
|
|
importForm: { |
|
|
|
orderCode: "", |
|
|
|
batchNo: "", // 新增:批次号 |
|
|
|
remark: "", |
|
|
|
bindBusinessId: "", // 必须初始化,否则校验不生效 |
|
|
|
businessName: "", // 必须初始化,否则校验不生效 |
|
|
|
}, |
|
|
|
importForm: getDefaultImportForm(), |
|
|
|
// 导入表单校验规则 |
|
|
|
importRules: { |
|
|
|
orderCode: [{ required: true, message: "订单号不能为空", trigger: "blur" }], |
|
|
|
file: [{ required: true, message: "请选择要上传的Excel文件", trigger: "change" }], |
|
|
|
orderCode: [{ required: true, message: "订单号不能为空", trigger: "blur" }], |
|
|
|
bindBusinessId: [{ required: true, message: "企业不能为空", trigger: "blur" }], |
|
|
|
businessName: [{ required: true, message: "请选择企业名称", trigger: "blur" }], |
|
|
|
}, |
|
|
|
// 上传文件列表 |
|
|
|
fileList: [], |
|
|
|
@ -549,23 +683,7 @@ export default { |
|
|
|
// 导入结果弹窗 |
|
|
|
resultOpen: false, |
|
|
|
// 查询参数 |
|
|
|
queryParams: { |
|
|
|
pageNum: 1, |
|
|
|
pageSize: 10, |
|
|
|
sn: null, |
|
|
|
mac: null, |
|
|
|
privateKey: null, |
|
|
|
batchNo: null, |
|
|
|
hashid: null, |
|
|
|
model: null, |
|
|
|
bindBusinessId: null, |
|
|
|
locateUpdateTime: null, |
|
|
|
lastLat: null, |
|
|
|
lastLng: null, |
|
|
|
battery: null, |
|
|
|
lastReportedTime: null, |
|
|
|
lastLocationTime: null, |
|
|
|
}, |
|
|
|
queryParams: getDefaultQueryParams(), |
|
|
|
// 表单参数 |
|
|
|
form: {}, |
|
|
|
// 表单校验 |
|
|
|
@ -588,22 +706,37 @@ export default { |
|
|
|
}, |
|
|
|
// 企业选择弹窗开关 |
|
|
|
businessSelectVisible: false, |
|
|
|
searchBusinessSelectVisible: false, |
|
|
|
}; |
|
|
|
}, |
|
|
|
created() { |
|
|
|
this.getList(); |
|
|
|
}, |
|
|
|
deactivated() { |
|
|
|
this.closeBusinessSelectDialogs(); |
|
|
|
}, |
|
|
|
beforeDestroy() { |
|
|
|
this.closeBusinessSelectDialogs(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
closeBusinessSelectDialogs() { |
|
|
|
this.businessSelectVisible = false; |
|
|
|
this.searchBusinessSelectVisible = false; |
|
|
|
}, |
|
|
|
/** 查询系统设备主列表 */ |
|
|
|
getList() { |
|
|
|
this.loading = true; |
|
|
|
listDevice(this.queryParams) |
|
|
|
.then((response) => { |
|
|
|
this.deviceList = response.data.list; |
|
|
|
this.total = response.data.total; |
|
|
|
this.loading = false; |
|
|
|
const data = response.data || {}; |
|
|
|
this.deviceList = Array.isArray(data.list) ? data.list : []; |
|
|
|
this.total = Number(data.total) || 0; |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
this.deviceList = []; |
|
|
|
this.total = 0; |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
this.loading = false; |
|
|
|
}); |
|
|
|
}, |
|
|
|
@ -643,7 +776,12 @@ export default { |
|
|
|
}, |
|
|
|
/** 重置按钮操作 */ |
|
|
|
resetQuery() { |
|
|
|
this.resetForm("queryForm"); |
|
|
|
if (this.$refs.queryForm) { |
|
|
|
this.resetForm("queryForm"); |
|
|
|
} |
|
|
|
this.queryParams = getDefaultQueryParams(); |
|
|
|
this.searchBusinessName = ""; |
|
|
|
this.searchBusinessSelectVisible = false; |
|
|
|
this.handleQuery(); |
|
|
|
}, |
|
|
|
// 多选框选中数据 |
|
|
|
@ -652,17 +790,121 @@ export default { |
|
|
|
this.single = selection.length !== 1; |
|
|
|
this.multiple = !selection.length; |
|
|
|
}, |
|
|
|
getActivationStatusLabel(value) { |
|
|
|
return value === true || value === 1 || value === "1" ? "是" : "否"; |
|
|
|
}, |
|
|
|
getActivationTagType(value) { |
|
|
|
return value === true || value === 1 || value === "1" ? "success" : "info"; |
|
|
|
}, |
|
|
|
formatCoordinateValue(value) { |
|
|
|
return value === null || value === undefined || value === "" ? "-" : value; |
|
|
|
}, |
|
|
|
formatCoordinates(lat, lng) { |
|
|
|
return `${this.formatCoordinateValue(lat)} / ${this.formatCoordinateValue(lng)}`; |
|
|
|
}, |
|
|
|
formatAssignedUsers(users) { |
|
|
|
if (!Array.isArray(users) || !users.length) { |
|
|
|
return "-"; |
|
|
|
} |
|
|
|
return users |
|
|
|
.map((user) => { |
|
|
|
if (!user) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
const name = user.nickName || ""; |
|
|
|
const account = user.account || ""; |
|
|
|
if (name && account) { |
|
|
|
return `${name}(${account})`; |
|
|
|
} |
|
|
|
return name || account || ""; |
|
|
|
}) |
|
|
|
.filter(Boolean) |
|
|
|
.join(",") || "-"; |
|
|
|
}, |
|
|
|
/** 打开认领设备弹窗 */ |
|
|
|
handleClaimDevice() { |
|
|
|
this.claimDeviceOpen = true; |
|
|
|
}, |
|
|
|
/** 批量激活设备 */ |
|
|
|
/** 打开分配设备弹窗 */ |
|
|
|
handleAssignDevice() { |
|
|
|
if (!this.ids.length) { |
|
|
|
this.$message.warning("请先勾选需要分配的设备"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.assignDeviceOpen = true; |
|
|
|
this.selectedAssignUsers = []; |
|
|
|
this.$nextTick(() => { |
|
|
|
if (this.$refs.userSelector && this.$refs.userSelector.clearSelectionState) { |
|
|
|
this.$refs.userSelector.clearSelectionState(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
/** 选择员工账户 */ |
|
|
|
handleAssignUserSelect(rows) { |
|
|
|
this.selectedAssignUsers = Array.isArray(rows) ? rows : []; |
|
|
|
}, |
|
|
|
/** 关闭分配设备弹窗 */ |
|
|
|
handleAssignDialogClose() { |
|
|
|
this.assignDeviceOpen = false; |
|
|
|
this.assignLoading = false; |
|
|
|
this.selectedAssignUsers = []; |
|
|
|
if (this.$refs.userSelector && this.$refs.userSelector.clearSelectionState) { |
|
|
|
this.$refs.userSelector.clearSelectionState(); |
|
|
|
} |
|
|
|
}, |
|
|
|
/** 提交分配设备 */ |
|
|
|
handleAssignSubmit() { |
|
|
|
if (!this.ids.length) { |
|
|
|
this.$message.warning("请先勾选需要分配的设备"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!this.selectedAssignUsers.length) { |
|
|
|
this.$message.warning("请选择员工账户"); |
|
|
|
return; |
|
|
|
} |
|
|
|
const userIds = Array.from( |
|
|
|
new Set( |
|
|
|
this.selectedAssignUsers |
|
|
|
.map((user) => user && user.id) |
|
|
|
.filter((id) => id !== undefined && id !== null) |
|
|
|
) |
|
|
|
); |
|
|
|
const deviceIds = Array.from(new Set(this.ids)); |
|
|
|
if (!userIds.length) { |
|
|
|
this.$message.warning("未获取到有效的员工账号"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.$confirm( |
|
|
|
`确认将选中的 ${deviceIds.length} 台设备分配给 ${userIds.length} 名员工吗?`, |
|
|
|
"提示", |
|
|
|
{ |
|
|
|
confirmButtonText: "确定", |
|
|
|
cancelButtonText: "取消", |
|
|
|
type: "warning", |
|
|
|
} |
|
|
|
) |
|
|
|
.then(async () => { |
|
|
|
this.assignLoading = true; |
|
|
|
await assignBusinessUserDevices({ |
|
|
|
userIds, |
|
|
|
deviceIds, |
|
|
|
}); |
|
|
|
this.$message.success("分配成功"); |
|
|
|
this.handleAssignDialogClose(); |
|
|
|
this.getList(); |
|
|
|
}) |
|
|
|
.catch(() => {}) |
|
|
|
.finally(() => { |
|
|
|
this.assignLoading = false; |
|
|
|
}); |
|
|
|
}, |
|
|
|
/** 批量启用设备 */ |
|
|
|
handleBatchActivate() { |
|
|
|
if (!this.ids.length) { |
|
|
|
this.$message.warning("请先勾选需要激活的设备"); |
|
|
|
this.$message.warning("请先勾选需要启用的设备"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.$confirm(`确认激活选中的 ${this.ids.length} 台设备吗?`, "提示", { |
|
|
|
this.$confirm(`确认启用选中的 ${this.ids.length} 台设备吗?`, "提示", { |
|
|
|
confirmButtonText: "确定", |
|
|
|
cancelButtonText: "取消", |
|
|
|
type: "warning", |
|
|
|
@ -671,7 +913,27 @@ export default { |
|
|
|
return batchActivateDevice(this.ids); |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
this.$message.success("批量激活成功"); |
|
|
|
this.$message.success("批量启用成功"); |
|
|
|
this.getList(); |
|
|
|
}) |
|
|
|
.catch(() => {}); |
|
|
|
}, |
|
|
|
/** 批量禁用设备 */ |
|
|
|
handleBatchDisable() { |
|
|
|
if (!this.ids.length) { |
|
|
|
this.$message.warning("请先勾选需要禁用的设备"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.$confirm(`确认禁用选中的 ${this.ids.length} 台设备吗?`, "提示", { |
|
|
|
confirmButtonText: "确定", |
|
|
|
cancelButtonText: "取消", |
|
|
|
type: "warning", |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
return batchDisableDevice(this.ids); |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
this.$message.success("批量禁用成功"); |
|
|
|
this.getList(); |
|
|
|
}) |
|
|
|
.catch(() => {}); |
|
|
|
@ -686,12 +948,28 @@ export default { |
|
|
|
this.detailForm = { ...row }; |
|
|
|
getDevice(row.id) |
|
|
|
.then((response) => { |
|
|
|
this.detailForm = response.data || { ...row }; |
|
|
|
this.detailForm = { |
|
|
|
...row, |
|
|
|
...(response.data || {}), |
|
|
|
}; |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
this.detailLoading = false; |
|
|
|
}); |
|
|
|
}, |
|
|
|
/** 查看设备轨迹 */ |
|
|
|
handleTrajectory(row) { |
|
|
|
if (!row || !row.id) { |
|
|
|
this.$message.warning("未获取到设备信息"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.trajectoryDevice = { |
|
|
|
id: row.id, |
|
|
|
sn: row.sn, |
|
|
|
mac: row.mac, |
|
|
|
}; |
|
|
|
this.trajectoryOpen = true; |
|
|
|
}, |
|
|
|
/** 认领成功回调 */ |
|
|
|
handleClaimSuccess() { |
|
|
|
this.claimDeviceOpen = false; |
|
|
|
@ -769,15 +1047,10 @@ export default { |
|
|
|
// ========== 新增:Excel导入相关方法 ========== |
|
|
|
/** 打开导入弹窗 */ |
|
|
|
handleImport() { |
|
|
|
this.closeBusinessSelectDialogs(); |
|
|
|
this.importOpen = true; |
|
|
|
// 重置导入表单和文件 |
|
|
|
this.importForm = { |
|
|
|
orderCode: "", |
|
|
|
remark: "", |
|
|
|
batchNo: "", |
|
|
|
bindBusinessId: "", |
|
|
|
businessName: "", |
|
|
|
}; |
|
|
|
this.importForm = getDefaultImportForm(); |
|
|
|
this.fileList = []; |
|
|
|
this.uploadFile = null; |
|
|
|
this.$nextTick(() => { |
|
|
|
@ -846,10 +1119,6 @@ export default { |
|
|
|
|
|
|
|
// 3. 构建FormData:仅携带1个文件 |
|
|
|
const formData = new FormData(); |
|
|
|
formData.append("orderCode", this.importForm.orderCode); |
|
|
|
formData.append("remark", this.importForm.remark); |
|
|
|
formData.append("bindBusinessId", this.importForm.bindBusinessId); |
|
|
|
formData.append("batchNo", this.importForm.batchNo); |
|
|
|
|
|
|
|
formData.append("file", this.uploadFile); // 仅提交这1个文件 |
|
|
|
|
|
|
|
@ -877,16 +1146,11 @@ export default { |
|
|
|
/** 取消导入 */ |
|
|
|
cancelImport() { |
|
|
|
this.importOpen = false; |
|
|
|
this.importForm = { |
|
|
|
orderCode: "", |
|
|
|
remark: "", |
|
|
|
batchNo: "", |
|
|
|
bindBusinessId: "", |
|
|
|
businessName: "", |
|
|
|
}; // 加上batchNo重置 |
|
|
|
this.importForm = getDefaultImportForm(); |
|
|
|
this.fileList = []; |
|
|
|
this.uploadFile = null; |
|
|
|
this.baseBatchNo = ""; |
|
|
|
this.businessSelectVisible = false; |
|
|
|
}, |
|
|
|
getBatchNo() { |
|
|
|
return getBatchNo(); |
|
|
|
@ -917,6 +1181,11 @@ export default { |
|
|
|
|
|
|
|
this.businessSelectVisible = false; // 关闭企业选择弹窗 |
|
|
|
}, |
|
|
|
handleSearchBusinessSelect(row) { |
|
|
|
this.queryParams.bindBusinessId = row.id; |
|
|
|
this.searchBusinessName = row.name; |
|
|
|
this.searchBusinessSelectVisible = false; |
|
|
|
}, |
|
|
|
normalizeImportResult(data) { |
|
|
|
return { |
|
|
|
status: data?.status || "", |
|
|
|
@ -975,4 +1244,10 @@ export default { |
|
|
|
line-height: 1.8; |
|
|
|
color: #606266; |
|
|
|
} |
|
|
|
|
|
|
|
.assign-selected-user { |
|
|
|
float: left; |
|
|
|
line-height: 32px; |
|
|
|
color: #606266; |
|
|
|
} |
|
|
|
</style> |
|
|
|
|