|
|
@@ -1,5 +1,93 @@
|
|
|
<style scoped lang="scss">
|
|
|
+.device-order-container {
|
|
|
+ padding: 10px 0;
|
|
|
+}
|
|
|
+
|
|
|
+.device-order-list {
|
|
|
+ max-height: 400px;
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+
|
|
|
+.device-order-item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 12px 16px;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ background: #fafafa;
|
|
|
+ border: 1px solid #ebeef5;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: grab;
|
|
|
+ transition: all 0.2s;
|
|
|
+ user-select: none;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ background: #f0f2f5;
|
|
|
+ border-color: #d9dce1;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.dragging {
|
|
|
+ opacity: 0.5;
|
|
|
+ background: #e6f7ff;
|
|
|
+ border-color: #409eff;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.drag-over {
|
|
|
+ border-color: #409eff;
|
|
|
+ background: #ecf5ff;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.drag-handle {
|
|
|
+ margin-right: 12px;
|
|
|
+ cursor: grab;
|
|
|
+ color: #c0c4cc;
|
|
|
+ font-size: 18px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ &:active {
|
|
|
+ cursor: grabbing;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.order-sequence {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 32px;
|
|
|
+ height: 32px;
|
|
|
+ background: #409eff;
|
|
|
+ color: #fff;
|
|
|
+ border-radius: 50%;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 600;
|
|
|
+ margin-right: 16px;
|
|
|
+ flex-shrink: 0;
|
|
|
+}
|
|
|
+
|
|
|
+.order-device-info {
|
|
|
+ flex: 1;
|
|
|
+ min-width: 0;
|
|
|
+
|
|
|
+ .order-device-name {
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 500;
|
|
|
+ color: #303133;
|
|
|
+ }
|
|
|
+
|
|
|
+ .order-device-id {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #909399;
|
|
|
+ margin-top: 2px;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+.device-order-footer {
|
|
|
+ margin-top: 20px;
|
|
|
+ padding-top: 16px;
|
|
|
+ border-top: 1px solid #ebeef5;
|
|
|
+ text-align: right;
|
|
|
+}
|
|
|
</style>
|
|
|
<template>
|
|
|
<div class="system-dialog-container">
|
|
|
@@ -244,6 +332,43 @@
|
|
|
</el-form>
|
|
|
|
|
|
</el-tab-pane>
|
|
|
+
|
|
|
+ <el-tab-pane label="调整设备顺序" name="deviceOrder" v-if="state.action !== 'add'">
|
|
|
+ <div class="device-order-container" v-loading="state.deviceOrderLoading">
|
|
|
+ <el-alert
|
|
|
+ title="上下拖动设备行可调整工位顺序,调整后请点击下方保存按钮"
|
|
|
+ type="info" :closable="false" show-icon style="margin-bottom: 16px;" />
|
|
|
+
|
|
|
+ <div class="device-order-list" v-if="state.deviceOrderList.length > 0">
|
|
|
+ <div
|
|
|
+ v-for="(device, index) in state.deviceOrderList"
|
|
|
+ :key="device.id"
|
|
|
+ class="device-order-item"
|
|
|
+ :class="{ 'dragging': state.dragIndex === index, 'drag-over': state.dragOverIndex === index }"
|
|
|
+ draggable="true"
|
|
|
+ @dragstart="handleDragStart($event, index)"
|
|
|
+ @dragover.prevent="handleDragOver($event, index)"
|
|
|
+ @drop="handleDrop($event, index)"
|
|
|
+ @dragend="handleDragEnd"
|
|
|
+ >
|
|
|
+ <div class="drag-handle">
|
|
|
+ <SvgIcon name="ele-Rank"/>
|
|
|
+ </div>
|
|
|
+ <div class="order-sequence">{{ index + 1 }}</div>
|
|
|
+ <div class="order-device-info">
|
|
|
+ <div class="order-device-name">{{ device.deviceName }}</div>
|
|
|
+ <div class="order-device-id">{{ device.shortId || device.productKey }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-empty v-else description="该站点暂无设备" />
|
|
|
+
|
|
|
+ <div class="device-order-footer">
|
|
|
+ <el-button type="primary" @click="saveDeviceOrder" :loading="state.deviceOrderSaving" :disabled="state.deviceOrderList.length === 0">保存顺序</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-tab-pane>
|
|
|
</el-tabs>
|
|
|
|
|
|
|
|
|
@@ -257,7 +382,7 @@
|
|
|
</el-form-item>-->
|
|
|
|
|
|
|
|
|
- <template #footer>
|
|
|
+ <template #footer v-if="state.tab !== 'deviceOrder'">
|
|
|
<span class="dialog-footer">
|
|
|
<el-button @click="onCancel" size="default">取 消</el-button>
|
|
|
<el-button :loading="state.btnLoading" type="primary" @click="onSubmit" size="default">{{ state.dialog.submitTxt }}</el-button>
|
|
|
@@ -305,7 +430,12 @@ const initState = () => ({
|
|
|
tab: 'basic',
|
|
|
platformFeeRateList: [],
|
|
|
stationFeeRate: [],
|
|
|
- action:''
|
|
|
+ action:'',
|
|
|
+ deviceOrderList: [] as any[],
|
|
|
+ deviceOrderLoading: false,
|
|
|
+ deviceOrderSaving: false,
|
|
|
+ dragIndex: -1,
|
|
|
+ dragOverIndex: -1,
|
|
|
})
|
|
|
|
|
|
// 定义变量内容
|
|
|
@@ -322,6 +452,7 @@ const open = (action: string = 'add', row: any) => {
|
|
|
loadData(row.id);
|
|
|
state.feeForm.stationId = row.stationId
|
|
|
loadStationFeeRate();
|
|
|
+ loadDeviceListForStation(row.stationId);
|
|
|
} else {
|
|
|
state.ruleForm = Object.assign(state.ruleForm, row);
|
|
|
|
|
|
@@ -401,6 +532,57 @@ const loadPlatformFeeRateList = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+const loadDeviceListForStation = (stationId?: string) => {
|
|
|
+ const sid = stationId || state.ruleForm.stationId
|
|
|
+ if (!sid) return
|
|
|
+ state.deviceOrderLoading = true
|
|
|
+ $body('/washDevice/list', { stationId: sid, pageNum: 1, pageSize: 200 }).then((res: any) => {
|
|
|
+ state.deviceOrderList = (res.list || []).map((d: any) => ({ ...d }))
|
|
|
+ }).finally(() => {
|
|
|
+ state.deviceOrderLoading = false
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const handleDragStart = (e: DragEvent, index: number) => {
|
|
|
+ state.dragIndex = index
|
|
|
+ if (e.dataTransfer) {
|
|
|
+ e.dataTransfer.effectAllowed = 'move'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleDragOver = (_e: DragEvent, index: number) => {
|
|
|
+ state.dragOverIndex = index
|
|
|
+}
|
|
|
+
|
|
|
+const handleDrop = (_e: DragEvent, index: number) => {
|
|
|
+ if (state.dragIndex === -1 || state.dragIndex === index) return
|
|
|
+ const list = [...state.deviceOrderList]
|
|
|
+ const [item] = list.splice(state.dragIndex, 1)
|
|
|
+ list.splice(index, 0, item)
|
|
|
+ state.deviceOrderList = list
|
|
|
+}
|
|
|
+
|
|
|
+const handleDragEnd = () => {
|
|
|
+ state.dragIndex = -1
|
|
|
+ state.dragOverIndex = -1
|
|
|
+}
|
|
|
+
|
|
|
+const saveDeviceOrder = () => {
|
|
|
+ state.deviceOrderSaving = true
|
|
|
+ const devices = state.deviceOrderList.map((d: any, idx: number) => ({
|
|
|
+ id: d.id,
|
|
|
+ sequence: idx + 1
|
|
|
+ }))
|
|
|
+ $body('/washDevice/batchUpdateSequence', devices).then(() => {
|
|
|
+ Msg.message('设备顺序保存成功', 'success')
|
|
|
+ loadDeviceListForStation()
|
|
|
+ }).catch(() => {
|
|
|
+ Msg.message('保存失败', 'error')
|
|
|
+ }).finally(() => {
|
|
|
+ state.deviceOrderSaving = false
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
const handlePlatformFeeRateChange = (platformFeeRateId: any) => {
|
|
|
console.log(platformFeeRateId)
|
|
|
let rate = state.platformFeeRateList.find(k => k.id == platformFeeRateId);
|
|
|
@@ -419,6 +601,8 @@ const handleTabChange = (tab:string) => {
|
|
|
state.dialog.submitTxt = u.dialog.actions[state.action].btn + "『站点信息』"
|
|
|
}else if(tab==='fee'){
|
|
|
state.dialog.submitTxt = u.dialog.actions[state.action].btn + "『站点费率』"
|
|
|
+ }else if(tab==='deviceOrder'){
|
|
|
+ loadDeviceListForStation()
|
|
|
}
|
|
|
}
|
|
|
|