this.grid is undefined

本文详细介绍了在使用Ext.js构建GridPanel时,如何正确配置CheckboxSelectionModel以避免出现this.grid is undefined错误。通过修改GridPanel的属性并确保在columns中包含CheckboxSelectionModel,可以有效解决该问题。

在做一个选择框的时候需要用到ext的CheckboxSelectionModel

以下是错误代码:

new Ext.grid.GridPanel({
    		 region:'west',
    		 split:true,//是否可以缩放
    	     title:'医疗服务单位信息',
    	     collapsible:true,//是否可以最小
    	     collapsedTitle: true,
    	     width:150,
    	     minSize:50,//最小只能拖到50
    	     maxSize:170,//最大170
    		 store:this.medicationUnitFormStore,
    	
    		 columns:[
    		         this.checkBox,
    		         {header: 'xx单位',align: 'left', width: 115, sortable: true, dataIndex: 'orgName',colspan:1}
    		         ]
    	 });


这样界面可以显示,但是只要点击checkbox就会报出this.grid is undefined这个错误,其实

这里的this.checkBox就是CheckboxSelectionModel,由于是写的组件,所以在这个地方简单的改了一下,需要注意的是当你在columns中写了checkbox之后一定需要记得在
GridPanel
的属性中也要加上这个属性 selModel:this.checkBox,这样就OK了

import { _decorator, Component, instantiate, misc, Node } from 'cc'; const { ccclass, property } = _decorator; @ccclass('zizhuandaishangwawa2') export class zizhuandaishangwawa2 extends Component { @property([Node]) children: Node[] = []; // 通过编辑器拖入子节点 @property radius: number = 50; // 分布半径 @property parentSpeed: number = 45; // 父节点旋转速度(度/秒) @property childSpeed: number = 90; // 子节点自转速度(度/秒) private initialized = false; start() { if (!this.initialized) { this.selectAndClearTiles(); this.initialized = true; } } selectAndClearTiles() { if (this.children.length < 5) { console.warn("节点数量不足 5 个!"); return; } // [优化] 直接打乱并激活前5个,销毁多余节点 for (let i = this.children.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [this.children[i], this.children[j]] = [this.children[j], this.children[i]]; } for (let i = 0; i < this.children.length; i++) { if (i < 5) { this.children[i].active = true; } else { this.children[i].destroy(); } } // 更新 children 数组 this.children = this.children.filter(child => child && child.isValid && child.active); // 初始化位置 this.resetPositions(); } resetPositions() { const count = this.children.length; for (let i = 0; i < count; i++) { const child = this.children[i]; if (child && child.isValid) { const angleDeg = i * (360 / count); const rad = misc.degreesToRadians(angleDeg); const x = this.radius * Math.cos(rad); const y = this.radius * Math.sin(rad); child.setPosition(x, y); child.active = true; } } } update(dt: number) { if (!this.node || !this.node.isValid || !this.enabled) return; // 父节点旋转 this.node.angle += this.parentSpeed * dt; // 子节点旋转 for (const child of this.children) { if (child && child.isValid) { child.angle += this.childSpeed * dt; } } } } 。这是转盘上的脚本,已经有 @property([Node]) children: Node[] = []; // 通过编辑器拖入子节点可以放置wawa。import { _decorator, Collider2D, Component, Contact2DType, Label, Node, isValid, Camera, UITransform, Vec3, view} from 'cc'; import { GameOverUI } from './GameOverUI'; import { GameData } from './GameData'; import { Tags } from './Tags'; import { A_guagouyidong } from './A_guagouyidong'; import { fuhuoUI } from './fuhuoUI'; const { ccclass, property } = _decorator; @ccclass('B_pengzhuangDefenxitong') export class B_pengzhuangDefenxitong extends Component { private processedColliders: Map<string, Tags> = new Map();// 使用单个Map替代多个Set @property(fuhuoUI) fuhuoUI: fuhuoUI = null; @property(GameOverUI) GameOverUI: GameOverUI = null; @property(Node) zizhuandaishangwawa2: Node = null; @property(Camera) mainCamera: Camera = null; @property(Label) chanceLabel: Label = null; // 游戏结束回调函数 private onGameOverCallback: (isSuccess: boolean) => void = null; onLoad() { // 碰撞检测 const collider = this.getComponent(Collider2D); if (collider) { collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this); collider.on(Contact2DType.END_CONTACT, this.onEndContact, this); } // 更新机会显示 this.updateChanceUI(); } // 设置游戏结束回调 public setGameOverCallback(callback: (isSuccess: boolean) => void) { this.onGameOverCallback = callback; } onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D) { const colliderId = otherCollider.uuid; // 如果已处理过该碰撞体,直接返回 if (this.processedColliders.has(colliderId)) return; switch (otherCollider.tag) { case Tags.HUAHUA: this.processedColliders.set(colliderId, Tags.HUAHUA); this.addScore(1); // 延迟销毁花朵 this.scheduleOnce(() => { if (isValid(otherCollider.node)) { otherCollider.node.destroy(); } }, 0.001); break; case Tags.WAWA: this.processedColliders.set(colliderId, Tags.WAWA); this.addScore(10); // 统一通过回调处理游戏结束 if (this.onGameOverCallback) { this.onGameOverCallback(true); } else { // 如果没有设置回调,使用本地方法 this.gameOver(true); } break; case Tags.DITU: this.processedColliders.set(colliderId, Tags.DITU); GameData.loseChance(); this.updateChanceUI(); // 检查是否需要显示复活界面 if (GameData.shouldShowRevive()) { this.stopAllMovements(); // 延迟显示复活界面 this.scheduleOnce(() => { if (this.fuhuoUI && isValid(this.fuhuoUI.node)) { this.fuhuoUI.show(); } }, 0.2); } break; } } onEndContact(selfCollider: Collider2D, otherCollider: Collider2D) { const colliderId = otherCollider.uuid; // 只移除地图碰撞记录 if (otherCollider.tag === Tags.DITU && this.processedColliders.has(colliderId)) { this.processedColliders.delete(colliderId); } } updateChanceUI() { if (this.chanceLabel && isValid(this.chanceLabel.node)) { this.chanceLabel.string = GameData.getChances().toString(); } } public stopAllMovements() { // 停止爪子移动 if (this.node?.isValid) { const moveComp = this.node.getComponent(A_guagouyidong); if (moveComp) { moveComp.stopMovement(); } } // 停止旋转组件 if (this.zizhuandaishangwawa2?.isValid) { const component = this.zizhuandaishangwawa2.getComponent("zizhuandaishangwawa2"); if (component) { component.enabled = false; } } } public gameOver(isSuccess: boolean) { // 调用停止移动的方法 if (this.node?.isValid) { const moveComp = this.node.getComponent(A_guagouyidong); if (moveComp) { moveComp.stopMovement(); } } // 停止旋转组件 if (this.zizhuandaishangwawa2?.isValid) { const component = this.zizhuandaishangwawa2.getComponent("zizhuandaishangwawa2"); if (component) { component.enabled = false; } } // 显示游戏结束界面 if (this.GameOverUI?.isValid) { const cameraWorldPos = this.mainCamera.node.worldPosition; this.GameOverUI.node.setWorldPosition(cameraWorldPos); this.GameOverUI.show(GameData.getScore()); } } public reset() { this.processedColliders.clear(); this.updateChanceUI(); } private addScore(count: number = 1) { GameData.addScore(count); } } 这是碰撞脚本,wawa代表抓到的娃娃,得10分。现在游玩中是其中一个场景,然后收藏页是新创建的一个场景,和进入收藏页的按钮却是在主页的这个场景里面的,现在我需要联系收藏页的场景了,就是在游玩中抓到的wawa后,得到10后,同时wawa也会出现在收藏页的场景中的指定位置里了。同时收藏页的场景中已经设有一个框,框中分了9格,需要有翻页功能,游玩中的wawa总过有45个,抓住就显示在框里面,同时每小格原本有个问号图标,代表隐藏的wawa,当抓到wawa后问号就删除,显示抓到的wawa,每页显示9个,需要设置5页。然后,小框上面也已经设有一个大框,只显示一张大图,小框里面的每一格对应有个大图,点击小格里面已经抓到和已经显示出来的小图wawa,就会出现对应的大图在大框里面,点击另外的wawa就会切换另一个对应wawa的大图。上一页和下一页按钮已经有了,还需要添加翻页脚本上去,下方也制作了页码显示‘1/5''2/5'...'5/5',请帮我对应上下页按钮添加脚本,还有以后我还会在收藏页里面会添加看广告抽奖按钮(抽wawa或金币之类)和收集9个娃娃(一个大页)会显示最后一页其中的一格wawa,这是后期添加的功能,希望现在预留空间,请帮我制作一下。用中文谢谢。请给我一个详细的方案和步骤,例如组件挂载到那个节点之类的请说明清楚
06-23
<template> <el-dialog :title="!dataForm.id ? '新增电池信息' : '修改电池信息'" :visible.sync="visible" width="90%" top="5vh" custom-class="battery-form-dialog" > <!-- 使用标签页布局 --> <el-tabs v-model="activeTab" type="card" tab-position="top"> <!-- 电池基本信息 --> <el-tab-pane label="基本信息" name="1"> <div class="form-grid"> <el-form-item label="电池ID" prop="batteryId"> <el-input v-model="dataForm.batteryId" disabled> <i slot="prefix" class="el-icon-files"></i> </el-input> </el-form-item> <el-form-item label="电压(V)" prop="batteryVoltage"> <el-input v-model="dataForm.batteryVoltage" type="number" disabled> <i slot="prefix" class="el-icon-data-line"></i> </el-input> </el-form-item> <el-form-item label="电流(A)" prop="batteryCurrent"> <el-input v-model="dataForm.batteryCurrent" type="number" disabled> <i slot="prefix" class="el-icon-sort"></i> </el-input> </el-form-item> <el-form-item label="SOC(%)" prop="batterySoc"> <el-input v-model="dataForm.batterySoc" type="number" min="0" max="100" disabled> <i slot="prefix" class="el-icon-pie-chart"></i> </el-input> </el-form-item> <el-form-item label="硬件版本" prop="batteryHardVersion"> <el-input v-model="dataForm.batteryHardVersion" disabled> <i slot="prefix" class="el-icon-cpu"></i> </el-input> </el-form-item> <el-form-item label="软件版本" prop="batterySoftVersion"> <el-input v-model="dataForm.batterySoftVersion" disabled> <i slot="prefix" class="el-icon-setting"></i> </el-input> </el-form-item> </div> </el-tab-pane> <!-- 电池状态信息 --> <el-tab-pane label="状态信息" name="2"> <div class="form-grid"> <el-form-item label="工作模式" prop="batteryWorkMode"> <el-select v-model="dataForm.batteryWorkMode" disabled> <el-option label="放电模式 (0x01)" value="1"></el-option> <el-option label="充电模式 (0x10)" value="16"></el-option> <el-option label="保护模式 (0x21)" value="33"></el-option> <el-option label="待机无输出模式 (0x30)" value="48"></el-option> <el-option label="待机预放电模式 (0x31)" value="49"></el-option> <el-option label="故障需返厂 (0xFF)" value="255"></el-option> </el-select> </el-form-item> <el-form-item label="电池类型" prop="batteryKind"> <el-select v-model="dataForm.batteryKind"> <el-option label="运营" value="0"></el-option> <el-option label="售后" value="1"></el-option> <el-option label="内测" value="2"></el-option> <el-option label="报废" value="3"></el-option> </el-select> </el-form-item> <el-form-item label="保护状态码" prop="batteryProtectCode"> <el-tooltip effect="dark" placement="top"> <div slot="content"> bit0: 放电低温 | bit1: 放电高温 | bit2: 充电高温<br> bit3: 充电低温 | bit4: 放电过流 | bit5: 放电欠压<br> bit6: 充电过流 | bit7: 充电过压 | bit8: 短路<br> bit9: 温差过大 | bit10: 压差过大 | bit11: 智能充电通信超时<br> bit12: IC保护 | bit13: 预放电失败 | bit14: BMS与Tracker通讯超时<br> bit15: Gsensor故障 | bit16~31: 保留 </div> <el-input v-model="dataForm.batteryProtectCode" disabled> <i slot="prefix" class="el-icon-warning"></i> </el-input> </el-tooltip> </el-form-item> <el-form-item label="错误状态码" prop="batteryErrorCode"> <el-tooltip effect="dark" placement="top"> <div slot="content"> 低8位故障状态码:<br> bit0: 保留 | bit1: 采样线故障 | bit2: 温度传感器损坏<br> bit3: IC损坏 | bit4: 充电MOS损坏 | bit5: 放电MOS损坏<br> bit6: 失衡 | bit7: 失效<br> 高8位工作状态:<br> bit8: G sensor损坏 | bit9: BMS与Tracker通讯故障 </div> <el-input v-model="dataForm.batteryErrorCode" disabled> <i slot="prefix" class="el-icon-warning-outline"></i> </el-input> </el-tooltip> </el-form-item> </div> </el-tab-pane> <!-- 温度电压信息 --> <el-tab-pane label="温度电压" name="3"> <div class="form-grid"> <el-form-item label="最高温度(℃)" prop="batteryTemperatureMax"> <el-input v-model="dataForm.batteryTemperatureMax" type="number" disabled> <i slot="prefix" class="el-icon-sunny"></i> </el-input> </el-form-item> <el-form-item label="最低温度(℃)" prop="batteryTemperatureMin"> <el-input v-model="dataForm.batteryTemperatureMin" type="number" disabled> <i slot="prefix" class="el-icon-cold-drink"></i> </el-input> </el-form-item> <el-form-item label="最高电压(V)" prop="batteryVoltageMax"> <el-input v-model="dataForm.batteryVoltageMax" type="number" disabled> <i slot="prefix" class="el-icon-top"></i> </el-input> </el-form-item> <el-form-item label="最低电压(V)" prop="batteryVoltageMin"> <el-input v-model="dataForm.batteryVoltageMin" type="number" disabled> <i slot="prefix" class="el-icon-bottom"></i> </el-input> </el-form-item> </div> </el-tab-pane> <!-- 设备信息 --> <el-tab-pane label="设备信息" name="4"> <div class="form-grid"> <el-form-item label="设备型号" prop="model"> <el-input v-model="dataForm.model" disabled> <i slot="prefix" class="el-icon-mobile"></i> </el-input> </el-form-item> <el-form-item label="制造商" prop="manufacture"> <el-input v-model="dataForm.manufacture" disabled> <i slot="prefix" class="el-icon-office-building"></i> </el-input> </el-form-item> <el-form-item label="IMEI" prop="imei"> <el-input v-model="dataForm.imei" disabled> <i slot="prefix" class="el-icon-phone"></i> </el-input> </el-form-item> <el-form-item label="IMSI" prop="imsi"> <el-input v-model="dataForm.imsi" disabled> <i slot="prefix" class="el-icon-sim-card"></i> </el-input> </el-form-item> <el-form-item label="ICCID" prop="iccid"> <el-input v-model="dataForm.iccid" disabled> <i slot="prefix" class="el-icon-credit-card"></i> </el-input> </el-form-item> </div> </el-tab-pane> <!-- GPS定位信息 --> <el-tab-pane label="GPS定位" name="5"> <div class="form-grid"> <el-form-item label="经度" prop="longitude"> <el-input v-model="dataForm.longitude" type="number" disabled> <i slot="prefix" class="el-icon-place"></i> </el-input> </el-form-item> <el-form-item label="经度方向" prop="longitudeDirection"> <el-select v-model="dataForm.longitudeDirection" disabled> <el-option label="东经" value="E"></el-option> <el-option label="西经" value="W"></el-option> </el-select> </el-form-item> <el-form-item label="纬度" prop="latitude"> <el-input v-model="dataForm.latitude" type="number" disabled> <i slot="prefix" class="el-icon-place"></i> </el-input> </el-form-item> <el-form-item label="纬度方向" prop="latitudeDirection"> <el-select v-model="dataForm.latitudeDirection" disabled> <el-option label="北纬" value="N"></el-option> <el-option label="南纬" value="S"></el-option> </el-select> </el-form-item> </div> </el-tab-pane> <!-- 业务信息 --> <el-tab-pane label="业务信息" name="6"> <div class="form-grid"> <el-form-item label="业务模式" prop="businessmode"> <el-select v-model="dataForm.businessmode" disabled> <el-option v-for="mode in businessModes" :key="mode.value" :label="mode.label" :value="mode.value"></el-option> </el-select> </el-form-item> <el-form-item label="处理状态" prop="handled"> <el-select v-model="dataForm.handled" disabled> <el-option label="已处理" :value="1"></el-option> <el-option label="待处理" :value="0"></el-option> </el-select> </el-form-item> <el-form-item label="执行方式" prop="todoNow"> <el-select v-model="dataForm.todoNow" disabled> <el-option label="立即执行" :value="1"></el-option> <el-option label="等待执行" :value="0"></el-option> </el-select> </el-form-item> <el-form-item label="需要回复" prop="needack"> <el-select v-model="dataForm.needack" disabled> <el-option label="是" :value="1"></el-option> <el-option label="否" :value="0"></el-option> </el-select> </el-form-item> <el-form-item label="消息类型" prop="flag"> <el-select v-model="dataForm.flag" disabled> <el-option label="设备主动请求或上报" :value="1"></el-option> <el-option label="平台主动推送或下指令" :value="2"></el-option> <el-option label="平台指令反馈的结果" :value="3"></el-option> </el-select> </el-form-item> </div> </el-tab-pane> <!-- 其他信息 --> <el-tab-pane label="其他信息" name="7"> <div class="form-grid"> <el-form-item label="原始数据" prop="payload"> <el-input v-model="dataForm.payload" type="textarea" :rows="4" disabled></el-input> </el-form-item> </div> </el-tab-pane> </el-tabs> <span slot="footer" class="dialog-footer"> <el-button @click="visible = false">取消</el-button> <el-button type="primary" @click="dataFormSubmit()">确定</el-button> </span> </el-dialog> </template> <script> export default { data() { return { visible: false, activeTab: '1', dataForm: { id: 0, batteryId: '', batteryVoltage: '', batteryCurrent: '', batterySoc: '', batteryHardVersion: '', batterySoftVersion: '', batteryWorkMode: '', batteryKind: "0", batteryProtectCode: '', batteryErrorCode: '', batteryTemperatureMax: '', batteryTemperatureMin: '', batteryVoltageMax: '', batteryVoltageMin: '', mosStatus: '', mosTemp: '', batteryCycleTimes: '', steadyStatus: '', cellVoltage: '', model: '', manufacture: '', imei: '', imsi: '', iccid: '', trackerHardwareVersion: '', trackerSoftwareVersion: '', csq: '', networkType: '', locationMode: '', longitude: '', longitudeDirection: '', latitude: '', latitudeDirection: '', gpsSpeed: '', gpsSignal: '', satelliteNum: '', accuracy: '', flag: '', clientId: '', topic: '', productKey: '', handled: '', todoNow: '', needack: '', businessmode: '', uploadTime: '', createTime: '', updateTime: '', payload: '' }, businessModes: [ { value: 1, label: "关机模式" }, { value: 2, label: "运营模式" }, { value: 3, label: "运输模式" }, { value: 4, label: "通讯充电模式" }, { value: 5, label: "盲充模式" }, { value: 6, label: "存储模式" }, { value: 7, label: "搜寻模式" }, { value: 8, label: "返厂模式" } ], /* dataRule: { batteryId: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryVoltage: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryCurrent: [ { required: true, message: '不能为空', trigger: 'blur' } ], batterySoc: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryHardVersion: [ { required: true, message: '不能为空', trigger: 'blur' } ], batterySoftVersion: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryWorkMode: [ { required: true, message: '0x01(1):放电模式 0x10(16):充电模式 0x21(33):保护模式 0x30(48):待机无输出模式 0x31(49):待机预放电模式 0xFF(255):故障需返厂不能为空', trigger: 'blur' } ], batteryProtectCode: [ { required: true, message: '保护状态 bit16~bit 31 保留 bit15:Gsensor 故障 bit14:BMS 与 Tracker通讯超时 bit13: 预放电失败 bit12: IC保护 bit11: 智能充电通信超时 bit10:压差过大 bit9:温差过大 bit8:短路 bit7:充电过压 bit6:充电过流 bit5:放电欠压 bit4:放电过流 bit3:充电低温 bit2:充电高温 bit1:放电高温 bit0:放电低温不能为空', trigger: 'blur' } ], batteryErrorCode: [ { required: true, message: '转成2进制, 总共为16位,高8位为电池包工作状态,低8位为故障状态码 bit9BMS 与 Tracker通讯故障,bit8BMS 板 G sensor损坏,(8/9无效)bit7:失效,bit6:失衡,bit5:放电 MOS 损坏,bit4:充电 MOS 损坏,bit3IC 损坏,bit2:温度传感器损坏,bit1:采样线断线,虚焊等故障 保留,置 0,bit0:保留不能为空', trigger: 'blur' } ], batteryTemperatureMax: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryTemperatureMin: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryVoltageMax: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryVoltageMin: [ { required: true, message: '不能为空', trigger: 'blur' } ], mosStatus: [ { required: true, message: '不能为空', trigger: 'blur' } ], mosTemp: [ { required: true, message: '不能为空', trigger: 'blur' } ], batteryCycleTimes: [ { required: true, message: '不能为空', trigger: 'blur' } ], steadyStatus: [ { required: true, message: '不能为空', trigger: 'blur' } ], cellVoltage: [ { required: true, message: '不能为空', trigger: 'blur' } ], model: [ { required: true, message: '不能为空', trigger: 'blur' } ], manufacture: [ { required: true, message: '不能为空', trigger: 'blur' } ], imei: [ { required: true, message: '不能为空', trigger: 'blur' } ], imsi: [ { required: true, message: '不能为空', trigger: 'blur' } ], iccid: [ { required: true, message: '不能为空', trigger: 'blur' } ], trackerHardwareVersion: [ { required: true, message: '不能为空', trigger: 'blur' } ], trackerSoftwareVersion: [ { required: true, message: '不能为空', trigger: 'blur' } ], csq: [ { required: true, message: '不能为空', trigger: 'blur' } ], networkType: [ { required: true, message: '不能为空', trigger: 'blur' } ], locationMode: [ { required: true, message: '不能为空', trigger: 'blur' } ], longitude: [ { required: true, message: '不能为空', trigger: 'blur' } ], longitudeDirection: [ { required: true, message: '不能为空', trigger: 'blur' } ], latitude: [ { required: true, message: '不能为空', trigger: 'blur' } ], latitudeDirection: [ { required: true, message: '不能为空', trigger: 'blur' } ], gpsSpeed: [ { required: true, message: '不能为空', trigger: 'blur' } ], gpsSignal: [ { required: true, message: '不能为空', trigger: 'blur' } ], satelliteNum: [ { required: true, message: '不能为空', trigger: 'blur' } ], accuracy: [ { required: true, message: '不能为空', trigger: 'blur' } ], flag: [ { required: true, message: '1:设备主动请求或上报 2:平台主动推送或下指令 3:平台指令反馈的结果不能为空', trigger: 'blur' } ], clientId: [ { required: true, message: 'MQTT发布消息所需的clientId不能为空', trigger: 'blur' } ], topic: [ { required: true, message: 'MQTT主题不能为空', trigger: 'blur' } ], productKey: [ { required: true, message: '主题名称中需要的productKey不能为空', trigger: 'blur' } ], handled: [ { required: true, message: '配置是否处理 1:已处理 0:待处理不能为空', trigger: 'blur' } ], todoNow: [ { required: true, message: '是否立即执行 0:等待执行 1:立即执行不能为空', trigger: 'blur' } ], needack: [ { required: true, message: '是否回复不能为空', trigger: 'blur' } ], businessmode: [ { required: true, message: '业务模式 1:关机模式 2:运营模式 3:运输模式 4:通讯充电模式 5:盲充模式 6:存储模式 7:搜寻模式 8:返厂模式不能为空', trigger: 'blur' } ], uploadTime: [ { required: true, message: '不能为空', trigger: 'blur' } ], createTime: [ { required: true, message: '不能为空', trigger: 'blur' } ], updateTime: [ { required: true, message: '更新时间不能为空', trigger: 'blur' } ], payload: [ { required: true, message: '原始数据不能为空', trigger: 'blur' } ] } */ } }, computed: { // 处理状态标签 handledLabel() { return this.dataForm.handled === 1 ? "已处理" : this.dataForm.handled === 0 ? "待处理" : ""; }, // 执行方式标签 todoNowLabel() { return this.dataForm.todoNow === 1 ? "立即执行" : this.dataForm.todoNow === 0 ? "等待执行" : ""; }, // 需要回复标签 needackLabel() { return this.dataForm.needack === 1 ? "是" : this.dataForm.needack === 0 ? "否" : ""; }, // 业务模式标签 businessModeLabel() { const mode = this.businessModes.find(m => m.value == this.dataForm.businessmode); return mode ? mode.label : ""; }, // 消息类型标签 flagLabel() { switch (this.dataForm.flag) { case 1: return "设备主动请求或上报"; case 2: return "平台主动推送或下指令"; case 3: return "平台指令反馈的结果"; default: return ""; } } }, methods: { init (id) { this.dataForm.id = id || 0 this.visible = true this.$nextTick(() => { this.$refs['dataForm'].resetFields() if (this.dataForm.id) { this.$http({ url: this.$http.adornUrl(`/maya/mybatteryinfo/info/${this.dataForm.id}`), method: 'get', params: this.$http.adornParams() }).then(({data}) => { if (data && data.code === 0) { this.dataForm.batteryId = data.myBatteryInfo.batteryId this.dataForm.batteryVoltage = data.myBatteryInfo.batteryVoltage this.dataForm.batteryCurrent = data.myBatteryInfo.batteryCurrent this.dataForm.batterySoc = data.myBatteryInfo.batterySoc this.dataForm.batteryHardVersion = data.myBatteryInfo.batteryHardVersion this.dataForm.batterySoftVersion = data.myBatteryInfo.batterySoftVersion this.dataForm.batteryWorkMode = data.myBatteryInfo.batteryWorkMode this.dataForm.batteryKind = String(data.myBatteryInfo.batteryKind); this.dataForm.batteryProtectCode = data.myBatteryInfo.batteryProtectCode this.dataForm.batteryErrorCode = data.myBatteryInfo.batteryErrorCode this.dataForm.batteryTemperatureMax = data.myBatteryInfo.batteryTemperatureMax this.dataForm.batteryTemperatureMin = data.myBatteryInfo.batteryTemperatureMin this.dataForm.batteryVoltageMax = data.myBatteryInfo.batteryVoltageMax this.dataForm.batteryVoltageMin = data.myBatteryInfo.batteryVoltageMin this.dataForm.mosStatus = data.myBatteryInfo.mosStatus this.dataForm.mosTemp = data.myBatteryInfo.mosTemp this.dataForm.batteryCycleTimes = data.myBatteryInfo.batteryCycleTimes this.dataForm.steadyStatus = data.myBatteryInfo.steadyStatus this.dataForm.cellVoltage = data.myBatteryInfo.cellVoltage this.dataForm.model = data.myBatteryInfo.model this.dataForm.manufacture = data.myBatteryInfo.manufacture this.dataForm.imei = data.myBatteryInfo.imei this.dataForm.imsi = data.myBatteryInfo.imsi this.dataForm.iccid = data.myBatteryInfo.iccid this.dataForm.trackerHardwareVersion = data.myBatteryInfo.trackerHardwareVersion this.dataForm.trackerSoftwareVersion = data.myBatteryInfo.trackerSoftwareVersion this.dataForm.csq = data.myBatteryInfo.csq this.dataForm.networkType = data.myBatteryInfo.networkType this.dataForm.locationMode = data.myBatteryInfo.locationMode this.dataForm.longitude = data.myBatteryInfo.longitude this.dataForm.longitudeDirection = data.myBatteryInfo.longitudeDirection this.dataForm.latitude = data.myBatteryInfo.latitude this.dataForm.latitudeDirection = data.myBatteryInfo.latitudeDirection this.dataForm.gpsSpeed = data.myBatteryInfo.gpsSpeed this.dataForm.gpsSignal = data.myBatteryInfo.gpsSignal this.dataForm.satelliteNum = data.myBatteryInfo.satelliteNum this.dataForm.accuracy = data.myBatteryInfo.accuracy this.dataForm.flag = data.myBatteryInfo.flag this.dataForm.clientId = data.myBatteryInfo.clientId this.dataForm.topic = data.myBatteryInfo.topic this.dataForm.productKey = data.myBatteryInfo.productKey this.dataForm.handled = data.myBatteryInfo.handled this.dataForm.todoNow = data.myBatteryInfo.todoNow this.dataForm.needack = data.myBatteryInfo.needack this.dataForm.businessmode = data.myBatteryInfo.businessmode this.dataForm.uploadTime = data.myBatteryInfo.uploadTime this.dataForm.createTime = data.myBatteryInfo.createTime this.dataForm.updateTime = data.myBatteryInfo.updateTime this.dataForm.payload = data.myBatteryInfo.payload } }) } }) }, // 表单提交 dataFormSubmit () { this.$refs['dataForm'].validate((valid) => { if (valid) { this.$http({ url: this.$http.adornUrl(`/maya/mybatteryinfo/${!this.dataForm.id ? 'save' : 'update'}`), method: 'post', data: this.$http.adornData({ 'id': this.dataForm.id || undefined, 'batteryId': this.dataForm.batteryId, 'batteryVoltage': this.dataForm.batteryVoltage, 'batteryCurrent': this.dataForm.batteryCurrent, 'batterySoc': this.dataForm.batterySoc, 'batteryHardVersion': this.dataForm.batteryHardVersion, 'batterySoftVersion': this.dataForm.batterySoftVersion, 'batteryWorkMode': this.dataForm.batteryWorkMode, 'batteryKind': Number(this.dataForm.batteryKind), 'batteryProtectCode': this.dataForm.batteryProtectCode, 'batteryErrorCode': this.dataForm.batteryErrorCode, 'batteryTemperatureMax': this.dataForm.batteryTemperatureMax, 'batteryTemperatureMin': this.dataForm.batteryTemperatureMin, 'batteryVoltageMax': this.dataForm.batteryVoltageMax, 'batteryVoltageMin': this.dataForm.batteryVoltageMin, 'mosStatus': this.dataForm.mosStatus, 'mosTemp': this.dataForm.mosTemp, 'batteryCycleTimes': this.dataForm.batteryCycleTimes, 'steadyStatus': this.dataForm.steadyStatus, 'cellVoltage': this.dataForm.cellVoltage, 'model': this.dataForm.model, 'manufacture': this.dataForm.manufacture, 'imei': this.dataForm.imei, 'imsi': this.dataForm.imsi, 'iccid': this.dataForm.iccid, 'trackerHardwareVersion': this.dataForm.trackerHardwareVersion, 'trackerSoftwareVersion': this.dataForm.trackerSoftwareVersion, 'csq': this.dataForm.csq, 'networkType': this.dataForm.networkType, 'locationMode': this.dataForm.locationMode, 'longitude': this.dataForm.longitude, 'longitudeDirection': this.dataForm.longitudeDirection, 'latitude': this.dataForm.latitude, 'latitudeDirection': this.dataForm.latitudeDirection, 'gpsSpeed': this.dataForm.gpsSpeed, 'gpsSignal': this.dataForm.gpsSignal, 'satelliteNum': this.dataForm.satelliteNum, 'accuracy': this.dataForm.accuracy, 'flag': this.dataForm.flag, 'clientId': this.dataForm.clientId, 'topic': this.dataForm.topic, 'productKey': this.dataForm.productKey, 'handled': this.dataForm.handled, 'todoNow': this.dataForm.todoNow, 'needack': this.dataForm.needack, 'businessmode': this.dataForm.businessmode, 'uploadTime': this.dataForm.uploadTime, 'createTime': this.dataForm.createTime, 'updateTime': this.dataForm.updateTime, 'payload': this.dataForm.payload }) }).then(({data}) => { if (data && data.code === 0) { this.$message({ message: '操作成功', type: 'success', duration: 1500, onClose: () => { this.visible = false this.$emit('refreshDataList') } }) } else { this.$message.error(data.msg) } }) } }) } } } </script> <style> .battery-form-dialog { font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; color: #1a1a1a; } /* 标签页样式优化 */ .battery-form-dialog .el-tabs__item { font-weight: 600 !important; font-size: 15px !important; padding: 0 20px !important; height: 40px; line-height: 40px; color: #555; } .battery-form-dialog .el-tabs__item.is-active { color: #1a73e8 !important; border-bottom: 3px solid #1a73e8 !important; } .battery-form-dialog .el-tabs__header { margin-bottom: 20px; } /* 网格布局 - 横向排列 */ .form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px 30px; padding: 15px; } /* 表单标签优化 */ .battery-form-dialog .el-form-item__label { display: block; font-weight: 600 !important; color: #1a1a1a !important; font-size: 14px !important; padding-bottom: 6px !important; margin-bottom: 0 !important; letter-spacing: 0.5px; } /* 输入框优化 */ .battery-form-dialog .el-input__inner, .battery-form-dialog .el-textarea__inner, .battery-form-dialog .el-select .el-input__inner { font-size: 15px !important; color: #222 !important; font-weight: 500 !important; border: 1px solid #dcdfe6 !important; background-color: #f8fafc !important; height: 40px; line-height: 40px; border-radius: 4px; } /* 文本域样式 */ .battery-form-dialog .el-textarea__inner { min-height: 100px; line-height: 1.5; padding: 10px 15px; font-family: monospace; } /* 禁用状态优化 */ .battery-form-dialog .el-input.is-disabled .el-input__inner, .battery-form-dialog .el-textarea.is-disabled .el-textarea__inner, .battery-form-dialog .el-select.is-disabled .el-input__inner { color: #444 !important; background-color: #f0f4f8 !important; border-color: #e4e7ed !important; opacity: 1; } /* 图标颜色优化 */ .battery-form-dialog .el-input__prefix { color: #1a73e8 !important; font-size: 16px; display: flex; align-items: center; padding-left: 8px; } /* 按钮优化 */ .battery-form-dialog .el-button { font-weight: 600; padding: 10px 20px; border-radius: 4px; font-size: 14px; min-width: 100px; transition: all 0.3s; } .battery-form-dialog .el-button--default { border-color: #dcdfe6; } .battery-form-dialog .el-button--primary { background-color: #1a73e8; border-color: #1a73e8; } .battery-form-dialog .el-button--primary:hover { background-color: #0d62c9; border-color: #0d62c9; } /* 标题优化 */ .battery-form-dialog .el-dialog__title { font-size: 18px !important; font-weight: 700 !important; color: #1a1a1a !important; letter-spacing: 0.5px; } /* 提示工具样式 */ .battery-form-dialog .el-tooltip__popper { max-width: 400px; font-size: 13px; line-height: 1.6; background-color: #2c3e50; color: #ecf0f1; } .battery-form-dialog .el-tooltip__popper[x-placement^="top"] .popper__arrow { border-top-color: #2c3e50; } /* 错误提示样式 */ .battery-form-dialog .el-form-item__error { color: #f56c6c; font-size: 12px; padding-top: 4px; } /* 响应式调整 */ @media (max-width: 1200px) { .form-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } } @media (max-width: 992px) { .form-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); } } @media (max-width: 768px) { .battery-form-dialog { width: 95% !important; } .form-grid { grid-template-columns: 1fr; } .battery-form-dialog .el-tabs__item { font-size: 13px !important; padding: 0 10px !important; } } </style>修复该页面,并给我完整胡代码
07-22
修正mrviewer.vue及mrdnrelate.vue功能,當進入mrviewer.vue頁面時,自動刷新,自動啟動病態關聯,自動啟動mrdnrelate.vue功能中刷新數據及手動新增關聯的功能: mrviewer.vue: <!-- mrviewer.vue --> <template> <div class="container"> <!-- 控制面板 --> <div class="control-panel"> <button @click="fetchData" class="refresh-btn">刷新數據</button> <button @click="toggleRelative" class="relative-btn"> {{ showRelative ? '病態關聯' : '病態關聯' }} </button> <!-- 本草关联器按钮 --> <button @click="toggleMNRelative" class="relative-btn"> {{ showMNRelative ? '本草關聯' : '本草關聯' }} </button> <!-- 方剂关联器按钮 --> <button @click="togglePNRelative" class="relative-btn"> {{ showPNRelative ? '方劑關聯' : '方劑關聯' }} </button> <!-- 出处关联器按钮 --> <button @click="toggleSNRelative" class="relative-btn"> {{ showSNRelative ? '典籍關聯' : '典籍關聯' }} </button> <!-- 人物关联器按钮 --> <button @click="toggleFNRelative" class="relative-btn"> {{ showFNRelative ? '人物關聯' : '人物關聯' }} </button> <!-- 新增辨證关联器按钮 --> <button @click="toggleDianNRelative" class="relative-btn"> {{ showDianNRelative ? '辨證關聯' : '辨證關聯' }} </button> <input v-model="searchQuery" placeholder="搜索..." class="search-input" /> <div class="pagination-controls"> <span>每頁顯示:</span> <select v-model.number="pageSize" class="page-size-select"> <option value="1">1筆</option> <option value="4">4筆</option> <option value="10">10筆</option> </select> <button @click="prevPage" :disabled="currentPage === 1">上一页</button> <span>第</span> <input type="number" v-model.number="inputPage" min="1" :max="totalPages" class="page-input" @input="handlePageInput"> <span>頁 / 共 {{ totalPages }} 頁</span> <button @click="nextPage" :disabled="currentPage === totalPages">下一頁</button> <span>醫案閱讀器</span> </div> </div> <!-- 主内容区域 --> <div class="content-area"> <div class="horizontal-records" v-if="filteredData.length > 0"> <div v-for="(item, index) in paginatedData" :key="item.id" class="record-card"> <div class="record-header"> <h3>醫案 #{{ (currentPage - 1) * pageSize + index + 1 }}</h3> </div> <div class="record-body"> <div v-for="(value, key) in processFieldNames(item)" :key="key" class="record-field"> <div class="field-name">{{ key }}:</div> <div class="field-value"> <!-- 病态名称 --> <div v-if="key === '相關病態' && Array.isArray(value)" class="dntag-value" v-html="formatDntagValueHTML(value)"></div> <!-- 本草名称 --> <div v-else-if="key === '相關本草' && Array.isArray(value)" class="mntag-value" v-html="formatMntagValueHTML(value)"></div> <!-- 方剂名称 --> <div v-else-if="key === '相關方劑' && Array.isArray(value)" class="pntag-value" v-html="formatPntagValueHTML(value)"></div> <!-- 出处名称 --> <div v-else-if="key === '相關典籍' && Array.isArray(value)" class="sntag-value" v-html="formatSntagValueHTML(value)"></div> <!-- 人物名称 --> <div v-else-if="key === '相關人物' && Array.isArray(value)" class="fntag-value" v-html="formatFntagValueHTML(value)"></div> <!-- 辨證名称 --> <div v-else-if="key === '相關辨證' && Array.isArray(value)" class="diantag-value" v-html="formatDiantagValueHTML(value)"></div> <div v-else-if="Array.isArray(value)" class="array-value"> <span v-for="(subItem, subIndex) in value" :key="subIndex"> <span v-html="formatValue(subItem, key)"></span><span v-if="subIndex < value.length - 1">;</span> </span> </div> <div v-else v-html="formatValue(value, key)"></div> </div> </div> </div> </div> </div> <div v-else class="no-data"> 沒有找到匹配的數據 </div> </div> <!-- 相关区域 --> <div class="relative-area"> <mrdnrelate v-if="showRelative" :currentCase="currentCase" :allTags="api2Data" @data-updated="handleDataUpdated"></mrdnrelate> <!-- 本草关联器 --> <mrmnrelate v-else-if="showMNRelative" :currentCase="currentCase" :allTags="api3Data" @data-updated="handleDataUpdated"></mrmnrelate> <!-- 方剂关联器 --> <mrpnrelate v-else-if="showPNRelative" :currentCase="currentCase" :allTags="api5Data" @data-updated="handleDataUpdated"></mrpnrelate> <!-- 出处关联器 --> <mrsnrelate v-else-if="showSNRelative" :currentCase="currentCase" :allTags="api4Data" @data-updated="handleDataUpdated"></mrsnrelate> <!-- 人物关联器 --> <mrfnrelate v-else-if="showFNRelative" :currentCase="currentCase" :allTags="api6Data" @data-updated="handleDataUpdated"></mrfnrelate> <!-- 新增辨證关联器 --> <mrdianrelate v-else-if="showDianNRelative" :currentCase="currentCase" :allTags="api7Data" @data-updated="handleDataUpdated"></mrdianrelate> <span v-else>點按下方關聯器,顯示醫案相關專有名詞</span> </div> </div> </template> <script> import mrdnrelate from './mrdnrelate.vue'; import mrmnrelate from './mrmnrelate.vue'; import mrpnrelate from './mrpnrelate.vue'; import mrsnrelate from './mrsnrelate.vue'; import mrfnrelate from './mrfnrelate.vue'; import mrdianrelate from './mrdianrelate.vue'; // 导入辨證关联器组件 export default { name: 'mrviewer', components: { mrdnrelate, mrmnrelate, mrpnrelate, mrsnrelate, mrfnrelate, mrdianrelate }, data() { return { api1Data: [], api2Data: [], api3Data: [], api4Data: [], api5Data: [], api6Data: [], api7Data: [], // 辨證标签数据 mergedData: [], currentPage: 1, pageSize: 1, searchQuery: '', sortKey: '', sortOrders: {}, inputPage: 1, fieldNames: { 'mrcase': '醫案全文', 'mrorigin': '醫案出處', 'mrdoctor': '醫案醫者', 'mrname': '醫案命名', 'mrposter': '醫案提交者', 'mrlasttime': '最後編輯時間', 'mreditnumber': '編輯次數', 'mrreadnumber': '閱讀次數', 'mrpriority': '重要性', 'dntag': '相關病態', 'mntag': '相關本草', 'pntag': '相關方劑', 'sntag': '相關典籍', 'fntag': '相關人物', 'diantag': '相關辨證' // 新增辨證字段 }, inputTimeout: null, dnNames: [], mnNames: [], pnNames: [], snNames: [], fnNames: [], dianNames: [], // 辨證名称列表 stateVersion: '1.0', showRelative: false, showMNRelative: false, showPNRelative: false, showSNRelative: false, showFNRelative: false, showDianNRelative: false, // 控制辨證关联器显示 currentCase: null }; }, computed: { filteredData() { const query = this.searchQuery.trim(); if (query && /^\d+$/.test(query)) { const idToSearch = parseInt(query, 10); return this.mergedData.filter(item => item.id === idToSearch); } if (!query) return this.mergedData; const lowerQuery = query.toLowerCase(); return this.mergedData.filter(item => { return Object.values(item).some(value => { if (value === null || value === undefined) return false; if (Array.isArray(value)) { return value.some(subValue => { if (typeof subValue === 'object' && subValue !== null) { return JSON.stringify(subValue).toLowerCase().includes(lowerQuery); } return String(subValue).toLowerCase().includes(lowerQuery); }); } if (typeof value === 'object' && value !== null) { return JSON.stringify(value).toLowerCase().includes(lowerQuery); } return String(value).toLowerCase().includes(lowerQuery); }); }); }, sortedData() { if (!this.sortKey) return this.filteredData; const order = this.sortOrders[this.sortKey] || 1; return [...this.filteredData].sort((a, b) => { const getValue = (obj) => { const val = obj[this.sortKey]; if (Array.isArray(val)) return JSON.stringify(val); return val; }; const aValue = getValue(a); const bValue = getValue(b); if (aValue === bValue) return 0; return aValue > bValue ? order : -order; }); }, paginatedData() { const start = (this.currentPage - 1) * Number(this.pageSize); const end = start + Number(this.pageSize); const data = this.sortedData.slice(start, end); if (data.length > 0) { this.currentCase = data[0]; } else { this.currentCase = null; } return data; }, totalPages() { return Math.ceil(this.filteredData.length / this.pageSize) || 1; } }, watch: { pageSize() { this.currentPage = 1; this.inputPage = 1; this.saveState(); }, currentPage(newVal) { this.inputPage = newVal; this.saveState(); }, filteredData() { if (this.currentPage > this.totalPages) { this.currentPage = Math.max(1, this.totalPages); } this.inputPage = this.currentPage; }, searchQuery() { this.saveState(); } }, methods: { handleDataUpdated() { alert('數據已更新,正在刷新醫案數據...'); this.fetchData(); }, toggleMNRelative() { if (!this.showMNRelative) { this.showRelative = false; this.showPNRelative = false; this.showSNRelative = false; this.showFNRelative = false; this.showDianNRelative = false; } this.showMNRelative = !this.showMNRelative; }, togglePNRelative() { if (!this.showPNRelative) { this.showRelative = false; this.showMNRelative = false; this.showSNRelative = false; this.showFNRelative = false; this.showDianNRelative = false; } this.showPNRelative = !this.showPNRelative; }, toggleSNRelative() { if (!this.showSNRelative) { this.showRelative = false; this.showMNRelative = false; this.showPNRelative = false; this.showFNRelative = false; this.showDianNRelative = false; } this.showSNRelative = !this.showSNRelative; }, toggleRelative() { if (this.showRelative) { this.showRelative = false; } else { this.showMNRelative = false; this.showPNRelative = false; this.showSNRelative = false; this.showFNRelative = false; this.showDianNRelative = false; this.showRelative = true; } }, toggleFNRelative() { if (!this.showFNRelative) { this.showRelative = false; this.showMNRelative = false; this.showPNRelative = false; this.showSNRelative = false; this.showDianNRelative = false; } this.showFNRelative = !this.showFNRelative; }, // 辨證关联器切换方法 toggleDianNRelative() { if (!this.showDianNRelative) { this.showRelative = false; this.showMNRelative = false; this.showPNRelative = false; this.showSNRelative = false; this.showFNRelative = false; } this.showDianNRelative = !this.showDianNRelative; }, // 辨證名称HTML格式化方法 (使用红色) formatDiantagValueHTML(diantagArray) { return diantagArray.map(tagObj => { const name = tagObj.dianname || tagObj.name || '未命名標籤'; return `<span style="color: rgb(255, 0, 0); font-weight: bold;">${this.escapeHtml(name)}</span>`; }).join(';'); }, // 病态名称HTML格式化方法 (使用橙色) formatDntagValueHTML(dntagArray) { return dntagArray.map(tagObj => { const name = tagObj.dnname || tagObj.name || '未命名標籤'; return `<span style="color: rgb(212, 107, 8); font-weight: bold;">${this.escapeHtml(name)}</span>`; }).join(';'); }, // 本草名称HTML格式化方法 (使用绿色) formatMntagValueHTML(mntagArray) { return mntagArray.map(tagObj => { const name = tagObj.mnname || tagObj.name || '未命名標籤'; return `<span style="color: rgb(0, 128, 0); font-weight: bold;">${this.escapeHtml(name)}</span>`; }).join(';'); }, // 方剂名称HTML格式化方法 (使用紫色) formatPntagValueHTML(pntagArray) { return pntagArray.map(tagObj => { const name = tagObj.pnname || tagObj.name || '未命名標籤'; return `<span style="color: rgb(128, 0, 128); font-weight: bold;">${this.escapeHtml(name)}</span>`; }).join(';'); }, // 出处名称HTML格式化方法 (使用蓝色) formatSntagValueHTML(sntagArray) { return sntagArray.map(tagObj => { const name = tagObj.snname || tagObj.name || '未命名標籤'; return `<span style="color: rgb(51, 102, 255); font-weight: bold;">${this.escapeHtml(name)}</span>`; }).join(';'); }, // 人物名称HTML格式化方法 (使用棕色) formatFntagValueHTML(fntagArray) { return fntagArray.map(tagObj => { const name = tagObj.fnname || tagObj.name || '未命名標籤'; return `<span style="color: #8B4513; font-weight: bold;">${this.escapeHtml(name)}</span>`; }).join(';'); }, escapeHtml(text) { const map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; return text.replace(/[&<>"']/g, m => map[m]); }, saveState() { const state = { version: this.stateVersion, currentPage: this.currentPage, pageSize: this.pageSize, searchQuery: this.searchQuery, timestamp: new Date().getTime() }; sessionStorage.setItem('mrviewerState', JSON.stringify(state)); }, restoreState() { const savedState = sessionStorage.getItem('mrviewerState'); if (!savedState) return; try { const state = JSON.parse(savedState); if (state.version !== this.stateVersion) return; this.currentPage = state.currentPage || 1; this.pageSize = state.pageSize || 1; this.searchQuery = state.searchQuery || ''; this.inputPage = this.currentPage; } catch (e) { sessionStorage.removeItem('mrviewerState'); } }, clearState() { sessionStorage.removeItem('mrviewerState'); }, // 修改后的fetchData方法:保留当前页码 async fetchData() { try { // 保存当前页码 const oldPage = this.currentPage; // 获取原有数据 const api1Response = await fetch("MRInfo/?format=json"); this.api1Data = await api1Response.json(); const api2Response = await fetch("DNTag/?format=json"); this.api2Data = await api2Response.json(); const api3Response = await fetch("MNTag/?format=json"); this.api3Data = await api3Response.json(); const api4Response = await fetch("SNTag/?format=json"); this.api4Data = await api4Response.json(); const api5Response = await fetch("PNTag/?format=json"); this.api5Data = await api5Response.json(); const api6Response = await fetch("FNTag/?format=json"); this.api6Data = await api6Response.json(); // 辨證数据获取 const api7Response = await fetch("DiaNTag/?format=json"); this.api7Data = await api7Response.json(); // 本草名称列表 this.mnNames = this.api3Data.map(item => item.mnname).filter(name => name && name.trim()); this.mnNames.sort((a, b) => b.length - a.length); // 方剂名称列表 this.pnNames = this.api5Data.map(item => item.pnname).filter(name => name && name.trim()); this.pnNames.sort((a, b) => b.length - a.length); // 病态名称列表 this.dnNames = this.api2Data.map(item => item.dnname).filter(name => name && name.trim()); this.dnNames.sort((a, b) => b.length - a.length); // 出处名称列表 this.snNames = this.api4Data.map(item => item.snname).filter(name => name && name.trim()); this.snNames.sort((a, b) => b.length - a.length); // 人物名称列表 this.fnNames = this.api6Data.map(item => item.fnname).filter(name => name && name.trim()); this.fnNames.sort((a, b) => b.length - a.length); // 辨證名称列表 this.dianNames = this.api7Data.map(item => item.dianname).filter(name => name && name.trim()); this.dianNames.sort((a, b) => b.length - a.length); this.mergeData(); // 计算新数据的总页数 const newTotalPages = Math.ceil(this.filteredData.length / this.pageSize) || 1; // 调整页码(不超过新总页数) if (oldPage > newTotalPages) { this.currentPage = newTotalPages; // 超过范围时设为最后一页 } else { this.currentPage = oldPage; // 保持原页码 } this.inputPage = this.currentPage; this.saveState(); } catch (error) { console.error("獲取數據失敗:", error); alert("數據加載失敗,請稍後重試"); } }, mergeData() { this.mergedData = this.api1Data.map((item) => { const newItem = { ...item }; // 处理病态标签 if (newItem.dntag && Array.isArray(newItem.dntag)) { newItem.dntag = newItem.dntag.map((tagId) => { const matchedItem = this.api2Data.find(api2Item => api2Item.id === tagId); return matchedItem || { id: tagId, dnname: "未找到匹配的數據" }; }); } // 处理本草标签 if (newItem.mntag && Array.isArray(newItem.mntag)) { newItem.mntag = newItem.mntag.map((tagId) => { const matchedItem = this.api3Data.find(api3Item => api3Item.id === tagId); return matchedItem || { id: tagId, mnname: "未找到匹配的數據" }; }); } // 处理方剂标签 if (newItem.pntag && Array.isArray(newItem.pntag)) { newItem.pntag = newItem.pntag.map((tagId) => { const matchedItem = this.api5Data.find(api5Item => api5Item.id === tagId); return matchedItem || { id: tagId, pnname: "未找到匹配的數據" }; }); } // 处理出处标签 if (newItem.sntag && Array.isArray(newItem.sntag)) { newItem.sntag = newItem.sntag.map((tagId) => { const matchedItem = this.api4Data.find(api4Item => api4Item.id === tagId); return matchedItem || { id: tagId, snname: "未找到匹配的數據" }; }); } // 处理人物标签 if (newItem.fntag && Array.isArray(newItem.fntag)) { newItem.fntag = newItem.fntag.map((tagId) => { const matchedItem = this.api6Data.find(api6Item => api6Item.id === tagId); return matchedItem || { id: tagId, fnname: "未找到匹配的數據" }; }); } // 处理辨證标签 if (newItem.diantag && Array.isArray(newItem.diantag)) { newItem.diantag = newItem.diantag.map((tagId) => { const matchedItem = this.api7Data.find(api7Item => api7Item.id === tagId); return matchedItem || { id: tagId, dianname: "未找到匹配的數據" }; }); } return newItem; }); // 初始化排序顺序 this.sortOrders = {}; if (this.mergedData.length > 0) { Object.keys(this.mergedData[0]).forEach(key => { this.sortOrders[key] = 1; }); } }, processFieldNames(item) { const result = {}; for (const key in item) { const newKey = this.fieldNames[key] || key; result[newKey] = item[key]; } return result; }, formatValue(value, fieldName) { if (value === null || value === undefined) return ''; // 醫案全文的高亮 if (fieldName === '醫案全文' && typeof value === 'string') { let highlighted = this.highlightMatches(value, this.dnNames, 'rgb(212, 107, 8)'); highlighted = this.highlightMatches(highlighted, this.mnNames, 'rgb(0, 128, 0)'); highlighted = this.highlightMatches(highlighted, this.pnNames, 'rgb(128, 0, 128)'); highlighted = this.highlightMatches(highlighted, this.snNames, 'rgb(51, 102, 255)'); highlighted = this.highlightMatches(highlighted, this.fnNames, '#8B4513'); highlighted = this.highlightMatches(highlighted, this.dianNames, 'rgb(255, 0, 0)'); // 辨證高亮 return highlighted; } // 醫案出處字段 else if (fieldName === '醫案出處' && typeof value === 'string') { return this.highlightMatches(value, this.snNames, 'rgb(51, 102, 255)'); } // 醫案醫者字段 else if (fieldName === '醫案醫者' && typeof value === 'string') { return this.highlightMatches(value, this.fnNames, '#8B4513'); } if (typeof value === 'string' && value.startsWith('http')) { return `<a href="${value}" target="_blank">${value}</a>`; } return value; }, highlightMatches(text, words, color) { if (!text || typeof text !== 'string' || words.length === 0) { return text; } const pattern = new RegExp( words .map(name => name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) .join('|'), 'gi' ); return text.replace(pattern, match => `<span style="color: ${color}; font-weight: bold;">${this.escapeHtml(match)}</span>` ); }, prevPage() { if (this.currentPage > 1) { this.currentPage--; this.saveState(); } }, nextPage() { if (this.currentPage < this.totalPages) { this.currentPage++; this.saveState(); } }, handlePageInput() { clearTimeout(this.inputTimeout); this.inputTimeout = setTimeout(() => { this.goToPage(); this.saveState(); }, 300); }, goToPage() { if (this.inputPage === null || this.inputPage === undefined || this.inputPage === '') { this.inputPage = this.currentPage; return; } const page = parseInt(this.inputPage); if (isNaN(page)) { this.inputPage = this.currentPage; return; } if (page < 1) { this.currentPage = 1; } else if (page > this.totalPages) { this.currentPage = this.totalPages; } else { this.currentPage = page; } this.inputPage = this.currentPage; } }, mounted() { this.restoreState(); this.fetchData(); }, activated() { this.restoreState(); }, deactivated() { this.saveState(); } }; </script> <style scoped> .container { max-width: 1200px; margin: 0px; padding: 0px; } .control-panel { margin-bottom: 0px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; position: fixed; bottom: 0; left: 0; width: 100%; background-color: #ffd800ff; z-index: 999; padding: 10px 20px; box-sizing: border-box; } .content-area { position: fixed; top: 56px; bottom: 45px; left: 0; width: 70%; background: white; padding: 1px; z-index: 100; overflow-y: auto; } .relative-area { position: fixed; top: 56px; bottom: 45px; right: 0; width: 30%; background: lightblue; padding: 1px; z-index: 100; overflow-y: auto; } .refresh-btn, .relative-btn { padding: 4px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; } .refresh-btn:hover, .relative-btn:hover { background-color: #45a049; } .search-input { padding: 8px; border: 1px solid #ddd; border-radius: 4px; flex-grow: 1; max-width: 300px; } .pagination-controls { display: flex; align-items: center; gap: 5px; } .page-size-select { padding: 4px; border-radius: 4px; width: 70px; } .page-input { width: 50px; padding: 4px; border: 1px solid #ddd; border-radius: 4px; text-align: center; } .horizontal-records { display: flex; flex-direction: column; gap: 20px; } .record-card { border: 1px solid #ddd; border-radius: 4px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.1); } .record-header { padding: 12px 16px; background-color: #f5f5f5; border-bottom: 1px solid #ddd; } .record-header h3 { margin: 0; font-size: 1.1em; } .record-body { padding: 16px; } .record-field { display: flex; margin-bottom: 12px; line-height: 1.5; } .record-field:last-child { margin-bottom: 0; } .field-name { font-weight: bold; min-width: 120px; color: #555; } .field-value { flex-grow: 1; display: flex; flex-wrap: wrap; gap: 8px; } .dntag-value { display: flex; flex-wrap: wrap; gap: 8px; } .mntag-value { display: flex; flex-wrap: wrap; gap: 8px; color: #006400; font-weight: 500; } .pntag-value { display: flex; flex-wrap: wrap; gap: 8px; color: #800080; font-weight: 500; } .sntag-value { display: flex; flex-wrap: wrap; gap: 8px; color: #0094ff; font-weight: 500; } .fntag-value { display: flex; flex-wrap: wrap; gap: 8px; color: #8B4513; font-weight: 500; } /* 辨證名称样式 */ .diantag-value { display: flex; flex-wrap: wrap; gap: 8px; color: rgb(255, 0, 0); font-weight: 500; } .array-value { display: flex; flex-wrap: wrap; gap: 8px; } .no-data { padding: 20px; text-align: center; color: #666; font-style: italic; } button:disabled { opacity: 0.5; cursor: not-allowed; } </style> mrdnrelate.vue: <!-- mrdnrelate.vue --> <template> <div class="mrdnrelate-container"> <!-- 相关病态区域(上方) --> <div class="tags-section"> <h3>尚未與此醫案關聯的病態列表</h3> <div class="filter-info" v-if="filteredTags.length > 0"> 顯示與當前醫案不同但相關的病態標籤({{ filteredTags.length }}個) </div> <div v-if="filteredTags.length > 0" class="dntag-list"> <div v-for="(tag, index) in filteredTags" :key="tag.id" class="dntag-item"> <div class="tag-content"> <span class="tag-index">{{ index + 1 }}.</span> <span class="tag-name">{{ tag.id }}: {{ tag.dnname || '未命名標籤' }}</span> </div> </div> </div> <div v-else class="no-tags"> 沒有符合條件的相關病態標籤 </div> </div> <!-- 分隔线 --> <div class="divider"></div> <!-- MRDN数据区域(下方) --> <div class="mrdn-section"> <h3>醫案病態關聯管理</h3> <!-- 操作按钮 --> <div class="mrdn-controls"> <button @click="fetchMRDNData" class="refresh-btn">刷新數據</button> <button @click="manualCreateMRDN" class="create-btn">手動新增關聯</button> </div> <!-- 数据列表 --> <div v-if="mrdnData.length > 0" class="mrdn-list"> <table class="mrdn-table"> <thead> <tr> <th>ID</th> <th>醫案ID</th> <th>病態ID</th> <th>操作</th> </tr> </thead> <tbody> <tr v-for="item in mrdnData" :key="item.id"> <td>{{ item.id }}</td> <td> <span v-if="!item.editing">{{ item.mrinfo }}</span> <textarea v-else v-model="item.editData.mrinfo" class="edit-textarea"></textarea> </td> <td> <span v-if="!item.editing">{{ item.dntag }}</span> <input v-else v-model="item.editData.dntag" type="text" class="edit-input"> </td> <td class="actions"> <template v-if="!item.editing"> <button @click="startEdit(item)" class="edit-btn">編輯</button> <button @click="confirmDelete(item.id)" class="delete-btn">刪除</button> </template> <template v-else> <button @click="saveEdit(item)" class="save-btn">保存</button> <button @click="cancelEdit(item)" class="cancel-btn">取消</button> </template> </td> </tr> </tbody> </table> </div> <div v-else class="no-data"> 沒有醫案病態關聯數據 </div> </div> </div> </template> <script> export default { name: 'mrdnrelate', props: { currentCase: { type: Object, default: null }, allTags: { type: Array, required: true } }, data() { return { mrdnData: [], isCreating: false, hasAutoCreated: false }; }, computed: { filteredTags() { if (!this.currentCase) return []; const currentTagIds = this.currentCase.dntag ? this.currentCase.dntag.map(tag => tag.id) : []; const caseContent = this.currentCase.mrcase || ''; const contentLower = caseContent.toLowerCase(); return this.allTags.filter(tag => { if (currentTagIds.includes(tag.id)) return false; if (!tag.dnname) return false; return contentLower.includes(tag.dnname.toLowerCase()); }); } }, watch: { currentCase: { immediate: true, handler(newVal) { if (newVal && newVal.id) { if (!this.hasAutoCreated) { this.autoCreateMRDN(); this.hasAutoCreated = true; } } } } }, methods: { async fetchMRDNData() { try { const response = await fetch("MRDN/?format=json"); const data = await response.json(); this.mrdnData = data.map(item => ({ id: item.id, mrinfo: item.mrinfo || '', dntag: item.dntag || '', editing: false, editData: { mrinfo: item.mrinfo || '', dntag: item.dntag || '' } })); } catch (error) { console.error("獲取MRDN數據失敗:", error); alert("MRDN數據加載失敗"); } }, async autoCreateMRDN() { if (this.isCreating) return; if (!this.currentCase || !this.currentCase.id) return; if (this.filteredTags.length === 0) return; try { this.isCreating = true; const createRequests = this.filteredTags.map(tag => { return fetch("MRDN/", { method: "POST", headers: { "Content-Type": "application/json", "X-CSRFToken": this.getCSRFToken() }, body: JSON.stringify({ mrinfo: `${this.currentCase.id}`, dntag: `${tag.id}` }) }); }); const responses = await Promise.all(createRequests); const allSuccess = responses.every(res => res.ok); if (allSuccess) { console.log(`成功新增 ${this.filteredTags.length} 筆MRDN數據!`); this.fetchMRDNData(); this.triggerDataUpdate(); } else { throw new Error("部分新增失敗"); } } catch (error) { console.error("批量新增MRDN失敗:", error); } finally { this.isCreating = false; } }, async manualCreateMRDN() { try { await this.autoCreateMRDN(); if (this.filteredTags.length > 0) { alert(`成功新增 ${this.filteredTags.length} 筆MRDN數據!`); } } catch (error) { alert("新增過程中發生錯誤"); } }, startEdit(item) { item.editing = true; item.editData = { mrinfo: item.mrinfo, dntag: item.dntag }; }, cancelEdit(item) { item.editing = false; }, async saveEdit(item) { try { const response = await fetch(`MRDN/${item.id}/`, { method: "PUT", headers: { "Content-Type": "application/json", "X-CSRFToken": this.getCSRFToken() }, body: JSON.stringify({ mrinfo: item.editData.mrinfo, dntag: item.editData.dntag }) }); if (response.ok) { item.mrinfo = item.editData.mrinfo; item.dntag = item.editData.dntag; item.editing = false; alert("更新成功!"); this.triggerDataUpdate(); } else { throw new Error("更新失敗"); } } catch (error) { console.error("更新MRDN失敗:", error); alert("更新失敗"); } }, confirmDelete(id) { if (confirm("確定要刪除此數據嗎?")) { this.deleteMRDN(id); } }, async deleteMRDN(id) { try { const response = await fetch(`MRDN/${id}/`, { method: "DELETE", headers: { "X-CSRFToken": this.getCSRFToken() } }); if (response.ok) { this.mrdnData = this.mrdnData.filter(item => item.id !== id); alert("刪除成功!"); this.triggerDataUpdate(); } else { throw new Error("刪除失敗"); } } catch (error) { console.error("刪除MRDN失敗:", error); alert("刪除失敗"); } }, getCSRFToken() { return document.querySelector('[name=csrfmiddlewaretoken]')?.value || ''; }, triggerDataUpdate() { this.$emit('data-updated'); } }, mounted() { this.fetchMRDNData(); if (this.currentCase && this.currentCase.id && !this.hasAutoCreated) { this.autoCreateMRDN(); this.hasAutoCreated = true; } } }; </script> <style scoped> .mrdnrelate-container { padding: 15px; background: #FFE0B2; /* 浅蓝色 -> 浅橙色 */ height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; } .tags-section { flex: 0 0 40%; overflow-y: auto; background: rgba(255, 255, 255, 0.3); border-radius: 8px; padding: 15px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); } .divider { height: 2px; background: #FF9800; /* 蓝色 -> 橙色 */ margin: 10px 0; } .mrdn-section { flex: 1; overflow-y: auto; background: rgba(255, 255, 255, 0.3); border-radius: 8px; padding: 15px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); } h3 { margin-top: 0; padding-bottom: 8px; color: #2c3e50; text-align: center; border-bottom: 2px solid #FF9800; /* 蓝色 -> 橙色 */ } .filter-info { text-align: center; margin: 10px 0; font-size: 0.9em; color: #555; background: rgba(255, 255, 255, 0.3); padding: 5px; border-radius: 4px; } .dntag-list { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 15px; } .dntag-item { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); overflow: hidden; transition: all 0.3s ease; border-left: 4px solid #FF9800; /* 蓝色 -> 橙色 */ } .tag-content { padding: 12px 15px; display: flex; align-items: center; } .tag-index { font-weight: bold; margin-right: 10px; min-width: 25px; height: 25px; display: flex; align-items: center; justify-content: center; background: #FF9800; /* 蓝色 -> 橙色 */ color: white; border-radius: 50%; } .tag-name { flex-grow: 1; font-weight: 500; color: #2c3e50; } .no-tags, .no-data { padding: 25px; text-align: center; color: #666; font-style: italic; margin-top: 20px; border: 1px dashed #FF9800; /* 蓝色 -> 橙色 */ border-radius: 8px; background: rgba(255, 255, 255, 0.5); } /* MRDN数据管理样式 */ .mrdn-controls { display: flex; justify-content: space-between; margin-bottom: 15px; } .mrdn-controls button { padding: 6px 12px; border-radius: 4px; border: none; cursor: pointer; font-weight: bold; } .refresh-btn { background-color: #4CAF50; color: white; } .create-btn { background-color: #FF9800; /* 蓝色 -> 橙色 */ color: white; } .mrdn-table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); } .mrdn-table th, .mrdn-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #eee; } .mrdn-table th { background-color: #FF9800; /* 蓝色 -> 橙色 */ color: white; font-weight: bold; } .mrdn-table tr:hover { background-color: #f5f5f5; } .actions { display: flex; gap: 5px; } .actions button { padding: 5px 10px; border: none; border-radius: 3px; cursor: pointer; font-size: 0.85em; } .edit-btn { background-color: #FFC107; color: #333; } .delete-btn { background-color: #F44336; color: white; } .save-btn { background-color: #4CAF50; color: white; } .cancel-btn { background-color: #9E9E9E; color: white; } .edit-input, .edit-textarea { width: 100%; padding: 5px; border: 1px solid #ddd; border-radius: 3px; } .edit-textarea { min-height: 60px; resize: vertical; } </style>
最新发布
08-04
<template> <div> <div ref="chartPanel" :style="{ width: 'calc(100vw - 200px)', height: 'calc(100vh - 200px)', padding: '100px', margin: '0 auto' }" ></div> </template> <script> import * as echarts from 'echarts' import 'echarts-gl' export default { name: 'ThreeDPieChart', data() { return { myChart: null, option: {}, selectedIndex: '', hoveredIndex: '' } }, mounted() { this.initChart() window.addEventListener('resize', this.handleResize) }, beforeDestroy() { if (this.myChart) { this.myChart.dispose() } window.removeEventListener('resize', this.handleResize) }, methods: { initChart() { this.myChart = echarts.init(this.$refs.chartPanel) const pieData = [ { name: 'cc', value: 47, itemStyle: { color: '#f77b66' } }, { name: 'aa', value: 44, itemStyle: { color: '#3edce0' } }, { name: 'bb', value: 32, itemStyle: { color: '#f94e76' } }, { name: 'ee', value: 16, itemStyle: { color: '#018ef1' } }, { name: 'dd', value: 23, itemStyle: { color: '#9e60f9' } } ] this.option = this.getPie3D(pieData, 0.59) this.myChart.setOption(this.option) // 事件监听 this.myChart.on('mouseover', this.handleMouseOver) this.myChart.on('globalout', this.handleGlobalOut) }, handleResize() { if (this.myChart) { this.myChart.resize() } }, getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, h) { const midRatio = (startRatio + endRatio) / 2 const startRadian = startRatio * Math.PI * 2 const endRadian = endRatio * Math.PI * 2 const midRadian = midRatio * Math.PI * 2 if (startRatio === 0 && endRatio === 1) { isSelected = false } k = typeof k !== 'undefined' ? k : 1 / 3 const offsetX = isSelected ? Math.cos(midRadian) * 0.1 : 0 const offsetY = isSelected ? Math.sin(midRadian) * 0.1 : 0 const hoverRate = isHovered ? 1.05 : 1 return { u: { min: -Math.PI, max: Math.PI * 3, step: Math.PI / 32 }, v: { min: 0, max: Math.PI * 2, step: Math.PI / 20 }, x(u, v) { if (u < startRadian) return offsetX + Math.cos(startRadian) * (1 + Math.cos(v) * k) * hoverRate if (u > endRadian) return offsetX + Math.cos(endRadian) * (1 + Math.cos(v) * k) * hoverRate return offsetX + Math.cos(u) * (1 + Math.cos(v) * k) * hoverRate }, y(u, v) { if (u < startRadian) return offsetY + Math.sin(startRadian) * (1 + Math.cos(v) * k) * hoverRate if (u > endRadian) return offsetY + Math.sin(endRadian) * (1 + Math.cos(v) * k) * hoverRate return offsetY + Math.sin(u) * (1 + Math.cos(v) * k) * hoverRate }, z(u, v) { if (u < -Math.PI * 0.5) return Math.sin(u) if (u > Math.PI * 2.5) return Math.sin(u) * h * 0.1 return Math.sin(v) > 0 ? 1 * h * 0.1 : -1 } } }, getPie3D(pieData, internalDiameterRatio) { const series = [] let sumValue = 0 let startValue = 0 let endValue = 0 const legendData = [] const k = typeof internalDiameterRatio !== 'undefined' ? (1 - internalDiameterRatio) / (1 + internalDiameterRatio) : 1 / 3 pieData.forEach((item, index) => { sumValue += item.value const seriesItem = { name: item.name || `series${index}`, type: 'surface', parametric: true, wireframe: { show: false }, pieData: item, pieStatus: { selected: false, hovered: false, k }, itemStyle: item.itemStyle || {} } series.push(seriesItem) }) series.forEach((seriesItem, index) => { endValue = startValue + seriesItem.pieData.value seriesItem.pieData.startRatio = startValue / sumValue seriesItem.pieData.endRatio = endValue / sumValue seriesItem.parametricEquation = this.getParametricEquation( seriesItem.pieData.startRatio, seriesItem.pieData.endRatio, false, false, k, seriesItem.pieData.value === series[0].pieData.value ? 35 : 10 ) startValue = endValue legendData.push(seriesItem.name) }) return { tooltip: { formatter: (params) => { if (params.seriesName !== 'mouseoutSeries') { return `${params.seriesName}<br/> <span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${params.color};"></span> ${this.option.series[params.seriesIndex].pieData.value}` } return '' } }, xAxis3D: { min: -1, max: 1 }, yAxis3D: { min: -1, max: 1 }, zAxis3D: { min: -1, max: 1 }, grid3D: { show: false, boxHeight: 5, top: '-20%', viewControl: { alpha: 35, rotateSensitivity: 1, zoomSensitivity: 0, panSensitivity: 0, autoRotate: true, distance: 150 }, postEffect: { enable: false, bloom: { enable: true, bloomIntensity: 0.1 }, SSAO: { enable: true, quality: 'medium', radius: 2 } } }, series } }, handleMouseOver(params) { if (this.hoveredIndex === params.seriesIndex) return if (this.hoveredIndex !== '') { const prevSeries = this.option.series[this.hoveredIndex] prevSeries.parametricEquation = this.getParametricEquation( prevSeries.pieData.startRatio, prevSeries.pieData.endRatio, prevSeries.pieStatus.selected, false, prevSeries.pieStatus.k, prevSeries.pieData.value === this.option.series[0].pieData.value ? 35 : 10 ) prevSeries.pieStatus.hovered = false this.hoveredIndex = '' } if (params.seriesName !== 'mouseoutSeries') { const currentSeries = this.option.series[params.seriesIndex] currentSeries.parametricEquation = this.getParametricEquation( currentSeries.pieData.startRatio, currentSeries.pieData.endRatio, currentSeries.pieStatus.selected, true, currentSeries.pieStatus.k, currentSeries.pieData.value + 5 ) currentSeries.pieStatus.hovered = true this.hoveredIndex = params.seriesIndex this.myChart.setOption(this.option) } }, handleGlobalOut() { if (this.hoveredIndex !== '') { const prevSeries = this.option.series[this.hoveredIndex] prevSeries.parametricEquation = this.getParametricEquation( prevSeries.pieData.startRatio, prevSeries.pieData.endRatio, prevSeries.pieStatus.selected, false, prevSeries.pieStatus.k, prevSeries.pieData.value === this.option.series[0].pieData.value ? 35 : 10 ) prevSeries.pieStatus.hovered = false this.hoveredIndex = '' this.myChart.setOption(this.option) } } } } </script> 这是我的代码我现在要在上面加一个引导线 并且引导线末端有圆点 代码要全
05-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值