local addonName, ZLAUTO = ...

local ZL = ZLAUTO.mainFrame
local background = ZL.background
local ScrollFrame_OnMouseWheel = ZL.ScrollFrame_OnMouseWheel
local btnDelay = ZL.btnDelay
local PlayerIsML = ZL.PlayerIsML
local Prefix = ZL.Prefix
local CreateButton = ZL.CreateButton
local pruneCrossRealm = ZL.pruneCrossRealm
local GetAuctioningCount = ZL.GetAuctioningCount
local ItemAuctionFrameIsShown = ZL.ItemAuctionFrameIsShown
local tableSort = ZL.tableSort
local emptytable = ZL.emptytable
local pad_left = ZL.pad_left
local GameTooltipShow = ZL.GameTooltipShow
local GameTooltipShowAnchor = ZL.GameTooltipShowAnchor
local ConvertSecondsToTime = ZL.ConvertSecondsToTime
local LoadItemDataByID = ZL.LoadItemDataByID
local GetClassColorName = ZL.GetClassColorName
local ParseClassColorName = ZL.ParseClassColorName
local GetAveWages = ZL.GetAveWages
local CreateEditBox = ZL.CreateEditBox
local CreateResizeButton = ZL.CreateResizeButton
local ZLCreateFrame = ZL.ZLCreateFrame
local CreateHeaderButton = ZL.CreateHeaderButton
local EditOnMouseWheel = ZL.EditOnMouseWheel
local sleep = ZL.sleep
local cGetItemInfo = C_Item and C_Item.GetItemInfo or GetItemInfo
local cGetItemIcon = C_Item and C_Item.GetItemIconByID or GetItemIcon
local GetItemInfoInstant = C_Item and C_Item.GetItemInfoInstant or GetItemInfoInstant
local MyAddon = ZL.MyAddon
local BUILD_DATA = floor(select(4, GetBuildInfo())/10000)

function ZL:CreateFloatAuctionFrame()
    ZL.FloatAuctionFrame = CreateFrame("Button", nil, ZL.AuctionFrame2, BackdropTemplateMixin and "BackdropTemplate")
    local FloatAuctionFrame = ZL.FloatAuctionFrame
    FloatAuctionFrame:SetPoint("LEFT", ZL.AuctionFrame2, "RIGHT", 1, 0)
    FloatAuctionFrame:SetFrameStrata("FULLSCREEN")
    FloatAuctionFrame:SetClampedToScreen(true)
    FloatAuctionFrame:SetAlpha(1)
    FloatAuctionFrame:SetScale(ZL.opt.ZLAuctionFrameScale)
    FloatAuctionFrame:SetBackdrop({
        bgFile = "Interface\\CharacterFrame\\UI-Party-Background",
        edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
        tile = true, tileSize = 32, edgeSize = 6,
        insets = { left = 1, right = 1, top = 1, bottom = 1 }
    })
    FloatAuctionFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
    FloatAuctionFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
    FloatAuctionFrame:SetSize(95, 59)
    FloatAuctionFrame.closeButton = CreateFrame("Button", nil, FloatAuctionFrame, "UIPanelCloseButton")
    FloatAuctionFrame.closeButton:SetPoint("BOTTOMRIGHT", FloatAuctionFrame, "TOPRIGHT", 3, -5)
    FloatAuctionFrame.closeButton:SetSize(20, 20)
    FloatAuctionFrame.closeButton:SetScript("OnClick", function (self)
        FloatAuctionFrame:Hide()
    end)

    FloatAuctionFrame.startbidEditbox = CreateEditBox(FloatAuctionFrame, 85, 22, 14, "RIGHT", true)
    local startbidEditbox = FloatAuctionFrame.startbidEditbox
    startbidEditbox:SetPoint("TOPLEFT", FloatAuctionFrame, "TOPLEFT", 5, -5)
    startbidEditbox.Background:SetColorTexture(0,0,0,0)
    startbidEditbox.startbidFont = startbidEditbox:CreateFontString()
    startbidEditbox.startbidFont:SetPoint("LEFT", startbidEditbox, "LEFT", 2, 0)
    startbidEditbox.startbidFont:SetHeight(18)
    startbidEditbox.startbidFont:SetFont(GameFontNormal:GetFont(), 13)
    startbidEditbox.startbidFont:SetText("|cff595959起拍价|r")
    startbidEditbox.startbidFont:SetWordWrap(false)
    startbidEditbox.startbidFont:SetJustifyH("LEFT")

    FloatAuctionFrame.incrementEditbox = CreateEditBox(FloatAuctionFrame, 85, 22, 14, "RIGHT", true)
    local incrementEditbox = FloatAuctionFrame.incrementEditbox
    incrementEditbox:SetPoint("TOPLEFT", startbidEditbox, "BOTTOMLEFT", 0, -5)
    incrementEditbox.Background:SetColorTexture(0,0,0,0)
    incrementEditbox.inrementFont = incrementEditbox:CreateFontString()
    incrementEditbox.inrementFont:SetPoint("LEFT", incrementEditbox, "LEFT", 2, 0)
    incrementEditbox.inrementFont:SetHeight(18)
    incrementEditbox.inrementFont:SetFont(GameFontNormal:GetFont(), 13)
    incrementEditbox.inrementFont:SetText("|cff595959加价|r")
    incrementEditbox.inrementFont:SetWordWrap(false)
    incrementEditbox.inrementFont:SetJustifyH("LEFT")

    FloatAuctionFrame:Hide()
    FloatAuctionFrame:SetScript("OnShow", function (self)
        FloatAuctionFrame:Update()
    end)
    FloatAuctionFrame:SetScript("OnEnter", function (self)
        ZL.AuctionFrame2.entries[ZL.FloatAuctionFrame.index].zlHighlight:Show()
    end)
    FloatAuctionFrame:SetScript("OnLeave", function (self)
        local Frame1 = ZL.AuctionFrame2.entries[ZL.FloatAuctionFrame.index]
        if (not Frame1:IsMouseOver()) and (not ZL.FloatAuctionFrame:IsMouseOver()) then
            Frame1.zlHighlight:Hide()
        end
    end)
    function FloatAuctionFrame:Update()
        if ZL.FloatAuctionFrame.index and self:IsShown() then
            local f = ZL.AuctionFrame2.entries[ZL.FloatAuctionFrame.index]
            local curAuction = ZL_CURRENT.auctionlist[ZL.FloatAuctionFrame.index]
            self:ClearAllPoints()
            -- self:SetPoint("TOPLEFT", f, "BOTTOMRIGHT", 20, 0)
            self:SetPoint("LEFT", f, "RIGHT", 20, 0)
            do
                local sbf = f.MLframe.startbidFrame
                startbidEditbox:SetNumber(sbf.startbidEditbox:GetNumber())
                incrementEditbox:SetNumber(sbf.incrementEditbox:GetNumber())
            end

            local sbf = f.MLframe.startbidFrame
            startbidEditbox:SetScript("OnEditFocusGained", sbf.startbidEditbox:GetScript("OnEditFocusGained"))
            startbidEditbox:SetScript("OnTextChanged", function (self)
                sbf.startbidEditbox:SetText(self:GetText())
                local startbid = self:GetNumber() or 0
                if startbid > 0 then
                    -- ZL_CURRENT.auctionlist[ZL.FloatAuctionFrame.index].startbidamount = startbid
                    curAuction.startbidamount = startbid
                    if curAuction.state == "waiting" or curAuction.state == "failed" then
                        f.bidderFrame.playerNameString:SetText("|cff00ff00起拍价:|r" .. ZL.formatNumber(startbid))
                    end
                end
            end)
            startbidEditbox:SetScript("OnMouseWheel", sbf.startbidEditbox:GetScript("OnMouseWheel"))
            startbidEditbox:SetScript("OnEnter", sbf.startbidEditbox:GetScript("OnEnter"))
            startbidEditbox:SetScript("OnLeave", sbf.startbidEditbox:GetScript("OnLeave"))
            startbidEditbox:SetScript("OnEditFocusLost", sbf.startbidEditbox:GetScript("OnEditFocusLost"))
            
            incrementEditbox:SetScript("OnEditFocusGained", sbf.incrementEditbox:GetScript("OnEditFocusGained"))
            incrementEditbox:SetScript("OnTextChanged", function (self)
                sbf.incrementEditbox:SetText(self:GetText())
                local increment = self:GetNumber() or 0
                if increment > 0 then
                    ZL_CURRENT.auctionlist[ZL.FloatAuctionFrame.index].bidIncrement = increment
                end
            end)
            incrementEditbox:SetScript("OnMouseWheel", sbf.incrementEditbox:GetScript("OnMouseWheel"))
            incrementEditbox:SetScript("OnEnter", sbf.incrementEditbox:GetScript("OnEnter"))
            incrementEditbox:SetScript("OnLeave", sbf.incrementEditbox:GetScript("OnLeave"))
            incrementEditbox:SetScript("OnEditFocusLost", sbf.incrementEditbox:GetScript("OnEditFocusLost"))
            incrementEditbox:SetScript("OnMouseDown", sbf.incrementEditbox:GetScript("OnMouseDown"))
        end
    end
end

function ZL:CreateAuctionFrame2()
    ZL.AuctionFrame2 = ZLCreateFrame(nil, ZL, nil, nil, nil, true, true, "AutoAuction(|cffffffff" .. ZL.addonVersion .. "|r)")
    local AuctionFrame = ZL.AuctionFrame2
    AuctionFrame:SetScale(ZL.opt.ZLAuctionFrameScale)
    AuctionFrame.Background:SetColorTexture(0.05, 0.05, 0.05, 1)
    if ZL.opt.ZLAuctionFrameIsShown then
        AuctionFrame:Show()
    else
        AuctionFrame:Hide()
    end
    AuctionFrame:SetScript("OnMouseUp", function (self)
        self:StopMovingOrSizing()
        if not ZL.db.global.ZLAuctionFrame then ZL.db.global.ZLAuctionFrame = {} end
        ZL.db.global.ZLAuctionFrame.point, _, ZL.db.global.ZLAuctionFrame.relative, ZL.db.global.ZLAuctionFrame.x, ZL.db.global.ZLAuctionFrame.y = self:GetPoint()
    end)
    AuctionFrame:SetScript("OnMouseDown", function (self)
        self:StartMoving()
    end)
    AuctionFrame:SetScript("OnShow", function (self)
        self:Update()
    end)
    AuctionFrame:SetScript("OnHide", function (self)
        ZL.BidderListFrame:Hide()
        ZL.FloatAuctionFrame:Hide()
        ZL.Print("界面呼出：|cffffffff/aa|r", true, true)
    end)
    AuctionFrame.closeButton:SetScript("OnClick", function (self)
        ZL.opt.ZLAuctionFrameIsShown = false
        AuctionFrame:Hide()
    end)
    local resizeButton = AuctionFrame.resizeButton
    -- 设置鼠标按下时开始调整大小
    resizeButton:SetScript("OnMouseDown", function(self, button)
        if button == "LeftButton" then
            AuctionFrame:StartSizing("BOTTOMRIGHT")
        end
    end)
    -- 鼠标松开时停止调整大小
    resizeButton:SetScript("OnMouseUp", function(self, button)
        AuctionFrame:StopMovingOrSizing()
        if not ZL.db.global.ZLAuctionFrame then ZL.db.global.ZLAuctionFrame = {} end
        ZL.db.global.ZLAuctionFrame.Width,  ZL.db.global.ZLAuctionFrame.Height= AuctionFrame:GetSize()
    end)
    AuctionFrame:ClearAllPoints()
    if ZL.db.global.ZLAuctionFrame and ZL.db.global.ZLAuctionFrame.point then
        AuctionFrame:SetPoint(ZL.db.global.ZLAuctionFrame.point, UIParent, ZL.db.global.ZLAuctionFrame.relative, ZL.db.global.ZLAuctionFrame.x, ZL.db.global.ZLAuctionFrame.y)
    else
        AuctionFrame:SetPoint("CENTER")
    end
    if ZL.db.global.ZLAuctionFrame and ZL.db.global.ZLAuctionFrame.Width and ZL.db.global.ZLAuctionFrame.Height then
        local w = min(ZL.db.global.ZLAuctionFrame.Width, GetScreenWidth()-30)
        w = w < 370 and 370 or w
        AuctionFrame:SetSize(w, min(ZL.db.global.ZLAuctionFrame.Height, GetScreenHeight()-50))
    end

    local auctionModeFontString = AuctionFrame:CreateFontString(nil, "OVERLAY")
    auctionModeFontString:SetPoint("TOPLEFT", AuctionFrame.TitleBottom, "TOPLEFT", 3, -7)
    auctionModeFontString:SetHeight(20)
    auctionModeFontString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
    auctionModeFontString:SetWordWrap(false)
    auctionModeFontString:SetJustifyH("LEFT")
    auctionModeFontString:SetTextColor(1, 0.82, 0, 1)
    auctionModeFontString:SetText("模式：")
    AuctionFrame.auctionModeDropdown = CreateFrame("Button", nil, AuctionFrame)
    local auctionModeDropdown = AuctionFrame.auctionModeDropdown
    auctionModeDropdown:SetPoint("LEFT", auctionModeFontString, "RIGHT", 2, 0)
    auctionModeDropdown:SetSize(70, 20)
    ZL.GUI:GetClass('Dropdown'):Bind(auctionModeDropdown)
    local auctionModeDropdownFontString = auctionModeDropdown:GetFontString()
    if auctionModeDropdownFontString then
	    auctionModeDropdownFontString:SetFont(GameFontNormal:GetFont(), 13)
    end
    auctionModeDropdown:SetMenuTable({
        {text="团队", value=1},
        {text="|cff00ff00明拍|r", value=2},
        {text="|cffff0000匿名|r", value=3},
    })
    auctionModeDropdown:SetDefaultText(ZL.opt.auctionMode)

    auctionModeDropdown:SetCallback('OnSelectChanged', function ()
        local auctionMode = auctionModeDropdown:GetText()
        if auctionMode == ZL.opt.auctionMode then return end
        local msgStr
        if PlayerIsML() then
            local addonVersion, WAVersion = 2201, 1101
            local function satisfyNumbers()
                local totalMembers = 0
                local hasAddon = 0
                if ZL_PLAYERLIST.GroupMembersVersion and next(ZL_PLAYERLIST.GroupMembersVersion) and IsInRaid(1) then
                    for i = 1, MAX_RAID_MEMBERS do
                        local name, _, _, _, _, _, _, online = GetRaidRosterInfo(i)
                        if name and online then
                            totalMembers = totalMembers + 1
                            local playerVer = ZL_PLAYERLIST.GroupMembersVersion[ZL.GetFullName(name)]
                            if playerVer then
                                playerVer = playerVer:gsub("|cffFFD100%(WA%-V[%d%.]+%)|r", "")
                                if strfind(playerVer, "WA%-V") then
                                    playerVer = playerVer:gsub("WA%-V", ""):gsub("%.", "")
                                    playerVer = tonumber(playerVer)
                                    if playerVer >= WAVersion then
                                        hasAddon = hasAddon + 1
                                    end
                                else
                                    playerVer = playerVer:gsub("V", ""):gsub("%.", "")
                                    playerVer = tonumber(playerVer)
                                    if playerVer >= addonVersion then
                                        hasAddon = hasAddon + 1
                                    end
                                end
                            end
                        end
                    end
                end
                return totalMembers, hasAddon
            end
            if auctionMode == "团队" then
                ZL.opt.auctionMode = auctionMode
                ZL.TransmitAddonInfo_Pro()
                if IsInRaid(1) then
                    msgStr = "已切换为【".. auctionMode .. "】拍卖模式！"
                    ZL.Print(msgStr)
                    SendChatMessage("已切换为【团队】拍卖模式！请直接在团队频道出价竞拍！", "RAID")
                end
            else
                local totalMembers, hasAddon = satisfyNumbers()
                if totalMembers > 0 then
                    if hasAddon == totalMembers then
                        if auctionMode == "|cffff0000匿名|r" then
                            --获取团队版本号
                            local data = {type="request"}
                            MyAddon:TransmitAddonInfo2("AUTOAUC VER", data, "RAID")
                            msgStr = "确定使用【" .. auctionMode .. "】拍卖模式么？\n确定后将发起投票，通过人数大于50%才可使用"
                            local data = {
                                type = "匿名",
                                totalMembers = totalMembers,
                            }
                            StaticPopup_Show("ZL_CHANGEAUCTIONMODE", msgStr, nil, data)
                        else
                            ZL.opt.auctionMode = auctionMode
                            ZL.TransmitAddonInfo_Pro()
                            if IsInRaid(1) then
                                msgStr = "已切换为插件【" .. auctionMode .. "】模式！未安装AutoAuction插件将看不到拍卖窗口"
                                ZL.Print(msgStr)
                                SendChatMessage("已切换为插件【明拍】模式！未安装插件或WA字符串的将看不到拍卖窗口", "RAID")
                            end
                        end
                    else
                        msgStr = "已切换为插件【" .. auctionMode .. "】模式！注意：有人未安装AutoAuction插件，无法参与竞拍！"
                        ZL.Print(msgStr, true, nil, 1, 0, 0)
                    end
                else
                    msgStr = "不在团队中，无法使用【" .. auctionMode .. "】拍卖模式！"
                    ZL.Print(msgStr)
                    auctionModeDropdown:SetValue(1)
                end
            end
        else
            msgStr = "ML功能，设置无效！"
            ZL.Print(msgStr, true, nil, 1, 0, 0)
            auctionModeDropdown:SetValue(1)
        end
    end)
    auctionModeDropdown:SetScript("OnEnter", function (self)
        local posLeft = AuctionFrame:GetLeft()
        local posRight = GetScreenWidth() - AuctionFrame:GetRight()
        if posLeft > posRight then
            GameTooltipShow(AuctionFrame, "TOPRIGHT", "TOPLEFT")
        else
            GameTooltipShow(AuctionFrame, "TOPLEFT", "TOPRIGHT")
        end
        GameTooltip:AddLine("拍卖模式")
        GameTooltip:AddLine("团队：|cffffffff团队频道出价|r|cff87CEEB(无需全团安装)|r")
        GameTooltip:AddLine("明拍：|cffffffff插件通信，在插件里可以看到出价人|r")
        GameTooltip:AddLine("匿名：|cffffffff插件通信，匿名拍卖，看不到出价人|r")
        GameTooltip:AddLine("|cff87CEEB明拍和匿名需全团安装插件或拍卖WA字符串\n否则无法看到拍卖信息|r")
        GameTooltip:AddLine("|cffff0000注：匿名拍卖需投票，通过人数大于全团\n在线人数一半才可以使用！|r")
        GameTooltip:Show()
    end)
    auctionModeDropdown:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    --批量流拍物品
    local function batchFailedItem()
        local msgStr = ""
        if not PlayerIsML() then
            msgStr = "你不是ML，无法使用这个功能！"
            ZL.Print(msgStr)
            return
        end
        if ZL.syncAll then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        AuctionFrame.iconHeaderBtn.checkBtn:SetChecked(false)
        local bathFailedList = {}
        local failedItemGUIDList = {}
        AuctionFrame.iconHeaderBtn.checkBtn:SetChecked(false)
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            for index, data in ipairs(ZL_CURRENT.auctionlist) do
                local f = AuctionFrame.entries[index]
                if data.state == "waiting" and (not data.lgnore) and (not data.isPackage) and data.bindType == 1
                and data.stackCount == 1 and f.infoFrame.checkBtn:GetChecked() then
                    tinsert(bathFailedList, {itemlink=data.itemlink, itemindex=data.itemindex})
                    if data["spawnUID"] then
                        for _, value in pairs(data["spawnUID"]) do
                            if value["itemGUID"] and next(value["itemGUID"], nil) then
                                for itemGUID in pairs(value["itemGUID"]) do
                                    tinsert(failedItemGUIDList, itemGUID)
                                end
                            end
                        end
                    end
                end
                f.infoFrame.checkBtn:SetChecked(false)
            end
        end
        if #bathFailedList > 0 then
            local data = {
                ["type"] = "bathFailed",
                ["data"] = bathFailedList,
                -- ["globalConfigData"] = ZL.globalConfigData(),
            }
            MyAddon:SYNCALL(data)
            ZL.syncAll =true
            AuctionFrame.piLiangBtn:Disable()
            --将流拍物品放到指定背包
            ZL.reportFailedItem(true)
        else
            msgStr = "没有需要批量流拍的物品！"
            ZL.Print(msgStr)
        end
    end
    --批量开始拍卖
    local function bathStart(type)
        --type  1:待拍卖，2：流拍，3：待拍卖和流拍， 4：勾选的
        type = type or 1
        if (not ZL_CURRENT.globalConfig.allowMultipleAuctions) then
            local link = format("|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "设置多拍", "设置多拍")
            ZL.Print("当前为单拍模式，不允许同时拍卖多个物品！" .. link, true)
            return
        end
        local msgStr = ""
        if not PlayerIsML() then
            msgStr = "你不是ML，无法使用这个功能！"
            ZL.Print(msgStr)
            return
        end
        if ZL.syncAll then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        ZL.GetLootItemGUID()
        AuctionFrame.iconHeaderBtn.checkBtn:SetChecked(false)
        local bathStartList = {}
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            for index, data in ipairs(ZL_CURRENT.auctionlist) do
                local f = AuctionFrame.entries[index]
                if (not data.lgnore) and (not data.isPackage) and data.bindType == 1 and data.stackCount == 1
                and ((type == 1 and data.state == "waiting") or (type == 2 and data.state == "failed")
                or (type == 3 and (data.state == "waiting" or data.state == "failed"))
                or (type == 4 and (data.state == "waiting" or data.state == "failed") and f.infoFrame.checkBtn:GetChecked())) then
                    tinsert(bathStartList, data)
                end
                f.infoFrame.checkBtn:SetChecked(false)
            end
        end
        if #bathStartList > 0 then
            local data = {
                ["type"] = "bathStart",
                ["data"] = bathStartList,
                ["globalConfigData"] = ZL.globalConfigData(),
            }
            MyAddon:SYNCALL(data)
            ZL.syncAll =true
            AuctionFrame.piLiangBtn:Disable()
        else
            ZL.Print("没有符合要求的拍卖物品！")
        end
    end
    --批量取消
    local function bathStop()
        local msgStr = ""
        if not PlayerIsML() then
            msgStr = "你不是ML，无法使用这个功能！"
            ZL.Print(msgStr)
            return
        end
        if ZL.syncAll then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        AuctionFrame.iconHeaderBtn.checkBtn:SetChecked(false)
        local bathStopList = {}
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            for index, data in ipairs(ZL_CURRENT.auctionlist) do
                local f = AuctionFrame.entries[index]
                if data.state == "auctioning" then
                    tinsert(bathStopList, {itemlink=data.itemlink, itemindex=data.itemindex})
                end
                f.infoFrame.checkBtn:SetChecked(false)
            end
        end
        if #bathStopList > 0 then
            local data = {
                ["type"] = "bathStop",
                ["data"] = bathStopList,
                -- ["globalConfigData"] = ZL.globalConfigData(),
            }
            MyAddon:SYNCALL(data)
            ZL.syncAll =true
            AuctionFrame.piLiangBtn:Disable()
        else
            ZL.Print("没有正在拍卖的物品！")
        end
    end
    --批量暂停
    local function bathPause()
        local msgStr = ""
        if not PlayerIsML() then
            msgStr = "你不是ML，无法使用这个功能！"
            ZL.Print(msgStr)
            return
        end
        if ZL.syncAll then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        AuctionFrame.iconHeaderBtn.checkBtn:SetChecked(false)
        local bathPauseList = {}
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            for index, data in ipairs(ZL_CURRENT.auctionlist) do
                local f = AuctionFrame.entries[index]
                if data.state == "auctioning" and (not data.isPaused) then
                    tinsert(bathPauseList, {itemlink=data.itemlink, itemindex=data.itemindex})
                end
                f.infoFrame.checkBtn:SetChecked(false)
            end
        end
        if #bathPauseList > 0 then
            local data = {
                ["type"] = "bathPause",
                ["data"] = bathPauseList,
                -- ["globalConfigData"] = ZL.globalConfigData(),
            }
            MyAddon:SYNCALL(data)
            ZL.syncAll =true
            AuctionFrame.piLiangBtn:Disable()
        else
            ZL.Print("没有需要暂停的拍卖物品！")
        end
    end
    --批量继续
    local function bathContinue()
        local msgStr = ""
        if not PlayerIsML() then
            msgStr = "你不是ML，无法使用这个功能！"
            ZL.Print(msgStr)
            return
        end
        if ZL.syncAll then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        AuctionFrame.iconHeaderBtn.checkBtn:SetChecked(false)
        local bathContinueList = {}
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            for index, data in ipairs(ZL_CURRENT.auctionlist) do
                local f = AuctionFrame.entries[index]
                if data.state == "auctioning" and data.isPaused then
                    tinsert(bathContinueList, {itemlink=data.itemlink, itemindex=data.itemindex})
                end
                f.infoFrame.checkBtn:SetChecked(false)
            end
        end
        if #bathContinueList > 0 then
            local data = {
                ["type"] = "bathContinue",
                ["data"] = bathContinueList,
                -- ["globalConfigData"] = ZL.globalConfigData(),
            }
            MyAddon:SYNCALL(data)
            ZL.syncAll =true
            AuctionFrame.piLiangBtn:Disable()
        else
            ZL.Print("没有需要继续的拍卖物品！")
        end
    end
    AuctionFrame.piLiangBtn = CreateFrame("Button", nil, AuctionFrame, "UIPanelButtonTemplate")
    local piLiangBtn = AuctionFrame.piLiangBtn
    piLiangBtn:SetPoint("LEFT", auctionModeDropdown, "RIGHT", 5, 2)
    piLiangBtn:SetSize(50, 26)
    piLiangBtn:SetText("批量")
    do
        local fontString = piLiangBtn:GetFontString()
        fontString:SetFont(GameFontNormal:GetFont(), 14)
    end
    piLiangBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    piLiangBtn:SetScript("OnClick", function (self, button)
        local function tempMenuTable()
            if not ZL.ModifyStartAmountEditboxs then ZL.CreateStaticPopupModifyStartAmountEditboxs() end
            local menuList = {
                {text = "ML功能", isTitle = true},
                {isSeparator = true},
                {
                    disabled = not PlayerIsML(),
                    text = "|T130866:15:15:2:0|t " .. "开始",
                    hasArrow = PlayerIsML(),
                    -- notClickable = 1,
                    tooltipText = "默认|cffffffff待拍卖|r物品",
                    func = function()
                        bathStart(1)
                    end,
                    menuTable = {
                        {
                            text = "待拍卖",
                            func = function()
                                bathStart(1)
                            end
                        },
                        {
                            text = "流拍",
                            func = function()
                                bathStart(2)
                            end
                        },
                        {
                            text = "以上两种",
                            func = function()
                                bathStart(3)
                            end
                        },
                        {
                            text = "以上两种勾选的",
                            func = function()
                                bathStart(4)
                            end
                        },
                    },
                },
                {
                    disabled = not PlayerIsML(),
                    text = "|T137048:15:15:2:0|t " .. "取消",
                    func = function ()
                        bathStop()
                    end
                },
                {
                    disabled = not PlayerIsML(),
                    text = "|T137047:15:15:2:0|t " .. "暂停",
                    func = function ()
                        bathPause()
                    end
                },
                {
                    disabled = not PlayerIsML(),
                    text = "|T130866:15:15:2:0|t " .. "继续",
                    func = function ()
                        bathContinue()
                    end
                },
                {
                    disabled = not PlayerIsML(),
                    text = "|T576625:15:15:2:0|t " .. "流拍",
                    func = function ()
                        batchFailedItem()
                    end
                },
                {
                    disabled = not PlayerIsML(),
                    text = "|T :15:15:2:0|t " .. "修改",
                    tooltipTitle = "|CFFFFDE00批量修改起拍价和加价幅度|r",
                    tooltipText = "|cffffffff点击：默认修改流拍物品|r",
                    hasArrow = PlayerIsML(),
                    -- notClickable = 1,
                    func = function()
                        StaticPopup_Show("ZL_MODIFYSTARTAMOUNT", ZL.opt.intervalBidIncrement and "请输入【|cffffde00流拍物品|r】起拍价：" or "请输入【|cffffde00流拍物品|r】起拍价和加价幅度：", nil, {type=2}, ZL.ModifyStartAmountEditboxs)
                    end,
                    menuTable = {
                        {
                            text = "待拍卖",
                            func = function()
                                StaticPopup_Show("ZL_MODIFYSTARTAMOUNT", ZL.opt.intervalBidIncrement and "请输入【|cffffde00待拍卖物品|r】起拍价：" or "请输入【|cffffde00待拍卖物品|r】起拍价和加价幅度：", nil, {type=1}, ZL.ModifyStartAmountEditboxs)
                            end
                        },
                        {
                            text = "流拍",
                            func = function()
                                StaticPopup_Show("ZL_MODIFYSTARTAMOUNT", ZL.opt.intervalBidIncrement and "请输入【|cffffde00流拍物品|r】起拍价：" or "请输入【|cffffde00流拍物品|r】起拍价和加价幅度：", nil, {type=2}, ZL.ModifyStartAmountEditboxs)
                            end
                        },
                        {
                            text = "以上两种",
                            func = function()
                                StaticPopup_Show("ZL_MODIFYSTARTAMOUNT", ZL.opt.intervalBidIncrement and "请输入【|cffffde00流拍和待拍卖物品|r】起拍价：" or "请输入【|cffffde00流拍和待拍卖物品|r】起拍价和加价幅度：", nil, {type=3}, ZL.ModifyStartAmountEditboxs)
                            end
                        },
                        {
                            text = "以上两种勾选的",
                            func = function()
                                StaticPopup_Show("ZL_MODIFYSTARTAMOUNT", ZL.opt.intervalBidIncrement and "请输入起拍价：" or "请输入起拍价和加价幅度：", nil, {type=4}, ZL.ModifyStartAmountEditboxs)
                            end
                        },
                    },
                },
            }
            tinsert(menuList, {isSeparator = true})
            tinsert(menuList, {text = "关闭"})
            return menuList
        end
        ZL.GUI:ToggleMenu(self, tempMenuTable(), 'TOPLEFT', self, 'BOTTOMLEFT', 0, 0)
    end)
    local commandFontString = AuctionFrame:CreateFontString(nil, "OVERLAY")
    commandFontString:SetPoint("LEFT", piLiangBtn, "RIGHT", 5, 0)
    commandFontString:SetHeight(20)
    commandFontString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
    commandFontString:SetWordWrap(false)
    commandFontString:SetJustifyH("LEFT")
    commandFontString:SetTextColor(1, 0.82, 0, 1)
    commandFontString:SetText("快捷命令：|cffffffff/aa|r")

    local titleBottomGapHeight = 30
    local btnTexture = [[Interface\ACHIEVEMENTFRAME\UI-Achievement-Parchment-Horizontal]]
    AuctionFrame.iconHeaderBtn = CreateButton(nil, AuctionFrame, "名称/状态", "TOPLEFT", AuctionFrame.TitleBottom, "BOTTOMLEFT", 3, -titleBottomGapHeight, 200, 21) --149
    local iconHeaderBtn = AuctionFrame.iconHeaderBtn
    iconHeaderBtn:GetFontString():SetFont(GameFontNormal:GetFont(), 14, "OUTLINE")
    iconHeaderBtn:SetNormalTexture(btnTexture)
    iconHeaderBtn:ClearHighlightTexture()
    iconHeaderBtn.infoBtn = CreateFrame("Button", nil, iconHeaderBtn)
    iconHeaderBtn.infoBtn:SetSize(20, 20)
    iconHeaderBtn.infoBtn:SetPoint("LEFT", iconHeaderBtn, "LEFT")
    iconHeaderBtn.infoBtn:SetNormalTexture(616343)
    iconHeaderBtn.infoBtn:SetHighlightTexture(616343)
    iconHeaderBtn.infoBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddLine("提示")
        GameTooltip:AddLine("物品图标快捷键")
        GameTooltip:AddLine("|cff00ff00双击：|r|cffff0000关注/取关|r该物品", 1, 1, 1)
        GameTooltip:AddLine("关注物品开始拍卖时会强制弹窗，并且有拍卖语音提醒", 1, 1, 1)
        GameTooltip:AddLine("|cff00ff00单击：|r", 1, 1, 1)
        GameTooltip:AddLine("交易窗口打开时，物品直接摆放到交易窗口", 1, 1, 1)
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("进度条快捷键")
        GameTooltip:AddLine("Shift+左键：|cffffffff重置倒计时|r")
        GameTooltip:Show()
    end)
    iconHeaderBtn.infoBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)

    iconHeaderBtn.checkBtn = CreateFrame("CheckButton", nil, iconHeaderBtn, "ChatConfigCheckButtonTemplate")
    iconHeaderBtn.checkBtn:SetPoint("TOPRIGHT", iconHeaderBtn, "TOPRIGHT")
    iconHeaderBtn.checkBtn:SetSize(20, 20)
    iconHeaderBtn.checkBtn:SetHitRectInsets(0, -iconHeaderBtn.checkBtn.Text:GetWidth(), 0, 0)
    iconHeaderBtn.checkBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddLine("全选")
        GameTooltip:AddLine("不含忽略和装绑物品", 1, 1, 1)
        GameTooltip:Show()
    end)
    iconHeaderBtn.checkBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    iconHeaderBtn.checkBtn:SetScript("OnClick", function (self)
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            local isChecked = self:GetChecked()
            for index, data in ipairs(ZL_CURRENT.auctionlist) do
                if (not data.lgnore) and (not data.isPackage) and data.bindType == 1 and data.stackCount == 1 then --data.state == "waiting" and 
                    local f = AuctionFrame.entries[index]
                    f.infoFrame.checkBtn:SetChecked(isChecked)
                end
            end
        end
    end)

    AuctionFrame.startbidHeaderBtn = CreateButton(nil, AuctionFrame, "起拍价/加价", "TOPRIGHT", AuctionFrame.TitleBottom, "BOTTOMRIGHT", -20, -titleBottomGapHeight, 100, 21)
    local startbidHeaderBtn = AuctionFrame.startbidHeaderBtn
    startbidHeaderBtn:GetFontString():SetFont(GameFontNormal:GetFont(), 14, "OUTLINE")
    startbidHeaderBtn:SetNormalTexture(btnTexture)
    startbidHeaderBtn:ClearHighlightTexture()

    AuctionFrame.bidderHeaderBtn = CreateButton(nil, AuctionFrame, "竞拍信息", "LEFT", iconHeaderBtn, "RIGHT", 0, 0, 147, 21)
    local bidderHeaderBtn = AuctionFrame.bidderHeaderBtn
    bidderHeaderBtn:GetFontString():SetFont(GameFontNormal:GetFont(), 14, "OUTLINE")
    bidderHeaderBtn:SetNormalTexture(btnTexture)
    bidderHeaderBtn:ClearHighlightTexture()

    do
        local texture = AuctionFrame:CreateTexture(nil, "BACKGROUND")
        texture:SetColorTexture(1, 1, 1, 0.5)
        texture:SetPoint("TOPLEFT", iconHeaderBtn, "BOTTOMLEFT", 0, 0)
        texture:SetPoint("BOTTOMRIGHT", startbidHeaderBtn, "BOTTOMRIGHT", 0, -1)
    end
    bidderHeaderBtn.infoBtn = CreateFrame("Button", nil, bidderHeaderBtn)
    bidderHeaderBtn.infoBtn:SetSize(20, 20)
    bidderHeaderBtn.infoBtn:SetPoint("LEFT", bidderHeaderBtn, "LEFT")
    bidderHeaderBtn.infoBtn:SetNormalTexture(616343)
    bidderHeaderBtn.infoBtn:SetHighlightTexture(616343)
    bidderHeaderBtn.infoBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddLine("【|cffff0000竞拍信息|r】栏快捷键")
        GameTooltip:AddLine(" ")
        GameTooltip:AddDoubleLine("左键双击:", "出价/申请重拍", nil, nil, nil, 1, 1, 1)
        GameTooltip:AddDoubleLine("右键单击:", "功能菜单", nil, nil, nil, 1, 1, 1)
        if PlayerIsML() then
            GameTooltip:AddLine(" ")
            GameTooltip:AddLine("以下为组合键+单击")
            GameTooltip:AddDoubleLine("Shift+左键:", "开始/重拍", nil, nil, nil, 1, 1, 1)
            GameTooltip:AddDoubleLine("Shift+右键:", "发送竞拍信息", nil, nil, nil, 1, 1, 1)
            GameTooltip:AddDoubleLine("Ctrl+右键:", "5秒倒数", nil, nil, nil, 1, 1, 1)
        end
        GameTooltip:Show()
    end)
    bidderHeaderBtn.infoBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    AuctionFrame.MLFrame = CreateFrame("Frame", nil, AuctionFrame)
    local MLFrame = AuctionFrame.MLFrame
    MLFrame:SetPoint("BOTTOMLEFT", AuctionFrame, "TOPLEFT")
    MLFrame:SetPoint("BOTTOMRIGHT", AuctionFrame, "TOPRIGHT")
    MLFrame:SetClampedToScreen(true)
    MLFrame:SetHeight(22)  --31
    MLFrame:SetScript("OnMouseUp", function (self)
        AuctionFrame:StopMovingOrSizing()
    end)
    MLFrame:SetScript("OnMouseDown", function (self)
        AuctionFrame:StartMoving()
    end)
    function ZL.saveRaidMembers()
        if not PlayerIsML() then
            local msgStr = "你不是ML，无法使用这个功能！"
            ZL.Print(msgStr)
            return
        end
        local msgStr = ""
        if IsInRaid(1) then
            ZL_CURRENT["GroupMembersList"] = ZL_CURRENT["GroupMembersList"] or {}
            tinsert(ZL_CURRENT["GroupMembersList"], 1, {
                saveTime = date("%Y-%m-%d %H:%M:%S", time()),
                list = ZL.GetCurrentRoster(true),
                ML = GetClassColorName(ZL.GetMLname()),
                RL = GetClassColorName(ZL.GetRLname()),
            })
            if ZL.opt.wagesGroupMembers == 0 then
                ZL.opt.wagesGroupMembers = 1
                ZL.TransmitAddonInfo_Pro()
                msgStr = "团队名单保存成功，并已选择|cffff0000最新历史1|r名单作为工资计算！"
            else
                msgStr = "团队名单保存成功，计算工资名单为：|cffff0000历史" .. ZL.opt.wagesGroupMembers .. "|r"
            end
            ZL.SpeakText("团队名单保存成功！")
        else
            msgStr = "不在团队中，无法保存团员名单！"
        end
        ZL.Print(msgStr, true)
    end
    local saveRaidMembers = ZL.saveRaidMembers
    local function statistics()
        if ZL_CURRENT.IncomeList and #ZL_CURRENT.IncomeList > 0 then
            local data = {
                ["type"] = "statistics",
                ["data"] = ZL_CURRENT,
            }
            MyAddon:SYNCALL(data)
        end
    end

    local function reportDetailIncome()
        ZL_CURRENT.incomeConfirm = true
        statistics()
        local numGroupMembers, RLBuTie, totalincome, totalpayout, totalamount, averageamount, BiLiList = GetAveWages()
        ZL.GetPlayerBuyList()
        local msgStr = ""
        if (not ZL_CURRENT["GroupMembersList"]) or #ZL_CURRENT["GroupMembersList"] == 0 then
            msgStr = "工资计算名单为：|cffff0000当前团员，请注意工资将会随人员变动而变动！\n注意：你还未保存团名名单，请注意及时保存！|r"
        elseif ZL.opt.wagesGroupMembers == 0 then
            msgStr = "工资计算名单为：|cffff0000当前团员，请注意工资将会随人员变动而变动！|r"
        end
        if #msgStr > 0 then
            ZL.Print(msgStr)
        end
        local function linshi()
            if not ZL_CURRENT["aveWages"] then
                msgStr = "没有工资成员记录！"
                ZL.Print(msgStr)
                return
            end
            local msglist = {}
            delay = BUILD_DATA >= 5 and 0.5 or 0.3
            if ZL_CURRENT.IncomeList and (#ZL_CURRENT.IncomeList > 0) then
                msgStr = "{rt6}<<<收支清单>>>{rt6}"
                tinsert(msglist, msgStr)
                for _, data in ipairs(ZL_CURRENT.IncomeList) do
                    if data["itemCount"] == 1 then
                        msgStr = data.notes .. "：" .. ParseClassColorName(data.player) .. "(" .. data.amount .. "g)"
                    else
                        msgStr = data.notes .. "x" .. data["itemCount"] .. "：" .. ParseClassColorName(data.player) .. "(" .. data.amount .. "g)"
                    end
                    tinsert(msglist, msgStr)
                end
                for _, data in ipairs(ZL_CURRENT.butie) do
                    msgStr = data.notes .. "：(" .. data["amount"] .. "g)"
                    tinsert(msglist, msgStr)
                end
                msgStr = "{rt6}<<<收支总览>>>{rt6}"
                tinsert(msglist, msgStr)
                msgStr = "总收入：" .. totalincome
                tinsert(msglist, msgStr)
                if -totalpayout > 0 and totalincome > 0 then
                    msgStr = format("总支出：%d（占比：%.2f%%）", -totalpayout, -totalpayout/totalincome*100)
                else
                    msgStr = "总支出：" .. (totalpayout == 0 and 0 or -totalpayout)
                end
                tinsert(msglist, msgStr)
                msgStr = "净收入：" .. totalamount
                tinsert(msglist, msgStr)
                if ZL.opt.NotieWagesBili then
                    msgStr = "{rt6}<<<工资比例总览>>>{rt6}"
                    tinsert(msglist, msgStr)
                    local tempList = {}
                    for key in pairs(BiLiList) do
                        tinsert(tempList, key)
                    end
                    sort(tempList, function (a, b)
                        return a > b
                    end)
                    for _, v in ipairs(tempList) do
                        if v > 0 then
                            tinsert(msglist, v/100 .. "倍工资：" .. #BiLiList[v] .. "人")
                        else
                            tinsert(msglist, "无工资：" .. #BiLiList[v] .. "人")
                        end
                    end
                end
                if ZL.opt.NoticeAveWages then
                    msgStr = "{rt6}<<<工资总览>>>{rt6}"
                    tinsert(msglist, msgStr)
                    local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
                    local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
                    if subsidyData["RL"] == "团双" then
                        msgStr = "工资人数(团双)：" .. numGroupMembers .. "人"
                    else
                        msgStr = "工资人数：" .. numGroupMembers .. "人"
                    end
                    tinsert(msglist, msgStr)
                    msgStr = "人均工资：" .. averageamount .. "(已抹零)"
                    tinsert(msglist, msgStr)
                    msgStr = "小队工资：" .. averageamount .. "x5=" .. (averageamount * 5)
                    tinsert(msglist, msgStr)
                end
                msgStr = "{rt6}感谢使用[AutoAuction]金团拍卖助手{rt6}"
                tinsert(msglist, msgStr)
                ZL.AuctionRecordFrame.playerBalanceFrame:Update()
                local index = 1
                local function sendMessage()
                    if index <= #msglist then
                        SendChatMessage(msglist[index], "RAID")
                        if index == #msglist then
                            if #msglist > 1 then
                                C_Timer.NewTicker(1, function (self)
                                    if ZL.billMsg then
                                        ZL.billMsg = nil
                                        self:Cancel()
                                        C_Timer.After(0.3, function ()
                                            SendChatMessage("安装AutoAuction插件后可查看账单总览和对账单", "RAID")
                                        end)
                                    end
                                end, 30)
                            end
                            wipe(msglist)
                        end
                        index = index + 1
                        C_Timer.After(ZL.opt.NoticeTimerJump, sendMessage)
                    end
                end
                sendMessage()
            else
                msgStr = "当前没有收支记录！"
                SendChatMessage(msgStr, "RAID")
            end
        end
        --当前团队名单时，把ML自己调到后面的小队去
        if ZL.opt.wagesGroupMembers == 0 and ZL.opt.MLChangeGroup and (not InCombatLockdown()) and (UnitIsGroupLeader("player") or UnitIsGroupAssistant("player")) then
            local _list = {UnitName("player")}
            ZL.ChangePlayerGroup(_list)
            C_Timer.After(0.5, linshi)
        else
            linshi()
        end
    end
    local function reportGroupIncome()
        ZL_CURRENT.incomeConfirm = true
        statistics()
        local _, _, _, _, _, averageamount = GetAveWages()
        local playerBuyList = ZL.GetPlayerBuyList()
        local msgStr = ""
        local function gourp()
            if not ZL_CURRENT["aveWages"] then
                msgStr = "没有工资成员记录！"
                ZL.Print(msgStr)
                return
            end
            local msglist = {}
            if ZL_CURRENT.IncomeList and (#ZL_CURRENT.IncomeList > 0) then
                msgStr = "{rt6}<<<小队工资>>>{rt6}"
                tinsert(msglist, msgStr)
                local currentRoster, _, MLName, RLName = ZL.GetWagesGroupMembers()
                -- 创建一个表来存储每个小队的成员信息
                local teamInfo = {}
                local amount
                local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
                local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
                local subsidyMoney = subsidyData["RL"]
                -- 遍历每个团队成员
                for subgroup = 1, 8 do
                    if #currentRoster[subgroup] > 0 then
                        -- 如果该小队还没有成员信息表，则创建一个新的表
                        if (not teamInfo[subgroup]) then
                            teamInfo[subgroup] = {}
                            teamInfo[subgroup]["list"] = {}
                            teamInfo[subgroup]["teamTotalAmount"] = 0
                            teamInfo[subgroup]["qiankuan"] = false
                            teamInfo[subgroup]["isMLGroup"] = false
                            teamInfo[subgroup]["isRLGroup"] = false
                            teamInfo[subgroup]["mail"] = false
                        end
                        for _, _name in ipairs(currentRoster[subgroup]) do
                            --消费老板不统计
                            local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[_name] and ZL_CURRENT.WagesBiLi[_name].biLi) and (ZL_CURRENT.WagesBiLi[_name].biLi/100) or 1
                            if biLi > 0 then
                                local name = ParseClassColorName(_name)
                                local balanceAmount = 0
                                local playerPayToMLamount = 0
                                if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[_name] then
                                    playerPayToMLamount = ZL_CURRENT.playerPayToML[_name]
                                end
                                local totalAmount = playerBuyList[_name] and playerBuyList[_name].totalAmount or 0
                                balanceAmount = playerPayToMLamount - totalAmount
                                if _name == MLName or balanceAmount > 0 then
                                    balanceAmount = 0
                                end
                                amount = floor(averageamount * biLi)
                                if _name == RLName then
                                    teamInfo[subgroup]["isRLGroup"] = true
                                    if subsidyMoney == "团双" then
                                        amount = amount + averageamount
                                    end
                                end
                                if balanceAmount < 0 then
                                    --有欠款，则从工资里面扣除
                                    amount = amount + balanceAmount
                                    teamInfo[subgroup]["qiankuan"] = true
                                end
                                local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[_name] and ZL_CURRENT.WagesBiLi[_name].buTie) and ZL_CURRENT.WagesBiLi[_name].buTie or 0
                                if buTie > 0 then
                                    amount = amount + buTie
                                end
                                teamInfo[subgroup]["teamTotalAmount"] = teamInfo[subgroup]["teamTotalAmount"] + amount
                                if buTie > 0 then
                                    amount = amount .. "(含补贴：" .. buTie .. ")"
                                end
                                if balanceAmount < 0 then amount = amount .. "(已扣除欠款：" .. -balanceAmount .. ")" end
                                if ZL_CURRENT.mailPlayers and ZL_CURRENT.mailPlayers[_name] ~= nil then
                                    amount = amount .. "(邮寄)"
                                    teamInfo[subgroup]["mail"] = true
                                end
                                if _name == MLName then
                                    teamInfo[subgroup]["isMLGroup"] = true
                                end
                                -- 将成员名字,工资加入对应小队的表中
                                tinsert(teamInfo[subgroup]["list"], {name=name, amount=amount})
                            end
                        end
                    end
                end
                for i = 1, 8 do
                    if teamInfo[i] and #teamInfo[i]["list"] > 0 then
                        if teamInfo[i]["qiankuan"] or teamInfo[i]["mail"] or teamInfo[i]["isRLGroup"] then
                            --小队有人欠款或需要邮寄工资则通知每个人的工资
                            local totalMembers = #teamInfo[i]["list"]
                            if subsidyMoney == "团双" then
                                totalMembers = totalMembers + 1
                            end
                            if teamInfo[i]["isMLGroup"] then
                                if subsidyMoney == "团双" then
                                    msgStr = ("===>>第%d队[M L]：%d人(含团双)，总工资：%d，"):format(i, totalMembers, teamInfo[i]["teamTotalAmount"])
                                else
                                    msgStr = ("===>>第%d队[M L]：%d人，总工资：%d，"):format(i, totalMembers, teamInfo[i]["teamTotalAmount"])
                                end
                            else
                                msgStr = ("===>>第%d队：%d人，总工资：%d，"):format(i, totalMembers, teamInfo[i]["teamTotalAmount"])
                            end
                            tinsert(msglist, msgStr)
                            for _, data in ipairs(teamInfo[i]["list"]) do
                                if data.name == ParseClassColorName(RLName) then
                                    if subsidyMoney == "团双" then
                                        msgStr = data.name .. "(RL团双)：" .. data.amount
                                    else
                                        msgStr = data.name .. "(RL)：" .. data.amount
                                    end
                                else
                                    msgStr = data.name .. "：" .. data.amount
                                end
                                tinsert(msglist, msgStr)
                            end
                        else
                            if teamInfo[i]["isMLGroup"] then
                                msgStr = ("===>>第%d队[M L]：%d人，总工资：%d，每人%d"):format(i, #teamInfo[i]["list"], teamInfo[i]["teamTotalAmount"], averageamount)
                            else
                                msgStr = ("===>>第%d队：%d人，总工资：%d，每人%d"):format(i, #teamInfo[i]["list"], teamInfo[i]["teamTotalAmount"], averageamount)
                            end
                            tinsert(msglist, msgStr)
                        end
                    end
                end
                msgStr = "{rt6}感谢使用[AutoAuction]金团拍卖助手{rt6}"
                tinsert(msglist, msgStr)
                ZL.AuctionRecordFrame.playerBalanceFrame:Update()
            else
                msgStr = "当前没有收支记录！"
                tinsert(msglist, msgStr)
            end
            local index = 1
            local function sendMessage()
                if index <= #msglist then
                    SendChatMessage(msglist[index], "RAID")
                    if index == #msglist then
                        if #msglist > 1 then
                            C_Timer.NewTicker(1, function (self)
                                if ZL.billMsg then
                                    ZL.billMsg = nil
                                    self:Cancel()
                                    C_Timer.After(delay, function ()
                                        SendChatMessage("安装AutoAuction插件后可查看账单总览和对账单", "RAID")
                                    end)
                                end
                            end, 30)
                        end
                        wipe(msglist)
                    end
                    index = index + 1
                    C_Timer.After(ZL.opt.NoticeTimerJump, sendMessage)
                end
            end
            sendMessage()
        end
        if (not ZL_CURRENT["GroupMembersList"]) or #ZL_CURRENT["GroupMembersList"] == 0 then
            msgStr = "工资计算名单为：|cffff0000当前团员，请注意工资将会随人员变动而变动！\n注意：你还未保存团名名单，请注意及时保存！|r"
        elseif ZL.opt.wagesGroupMembers == 0 then
            msgStr = "工资计算名单为：|cffff0000当前团员，请注意工资将会随人员变动而变动！|r"
        end
        ZL.ScrollingMessageFrame:AddMessage(msgStr)
        --当前团队名单时，把ML自己调到后面的小队去
        if ZL.opt.wagesGroupMembers == 0 and ZL.opt.MLChangeGroup and (not InCombatLockdown()) and (UnitIsGroupLeader("player") or UnitIsGroupAssistant("player")) then
            local _list = {UnitName("player")}
            ZL.ChangePlayerGroup(_list)
            C_Timer.After(0.5, gourp)
        else
            gourp()
        end
    end
    function ZL.reportIncomeConfirm(isGroup)
        if not IsInRaid(1) then
            ZL.Print("不在团队中，无法通报！")
            return
        end
        local WagesGroupMembers, msg = ZL.GetWagesGroupMembers()
        if not WagesGroupMembers then
            ZL.Print("没有团队成员数据，无法计算工资！", nil, nil, 1, 0, 0)
            return
        end
        msg = ParseClassColorName(msg)
        local numGroupMembers = GetAveWages()
        local msgStr
        local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
        local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
        if subsidyData["RL"] == "团双" then
            msgStr = "工资成员名单为：|cff00ff00" .. msg .. "|r\n工资人数为：|cff00ff00" .. numGroupMembers .. "|r人(团双)，请选择？\n\n"
        else
            msgStr = "工资成员名单为：|cff00ff00" .. msg .. "|r\n工资人数为：|cff00ff00" .. numGroupMembers .. "|r人，请选择？\n\n"
        end
        local wagesGroupMembersIndex = (ZL_CURRENT["globalConfig"] and ZL_CURRENT["globalConfig"]["wagesGroupMembers"]) and ZL_CURRENT["globalConfig"]["wagesGroupMembers"] or 0
        if wagesGroupMembersIndex == 0 then
            if not StaticPopupDialogs["ZL_reportDetailIncomeConfirm"] then
                StaticPopupDialogs["ZL_reportDetailIncomeConfirm"] = {
                    text = "%s",
                    button1 = "保存名单并通报",
                    button2 = "取消",
                    OnShow = function(self)
                        self:GetEditBox():SetNumeric(false)
                        self:GetEditBox():SetAutoFocus(false)
                    end,
                    OnAccept = function(self, data)
                        saveRaidMembers()
                        if data then
                            reportGroupIncome()
                        else
                            reportDetailIncome()
                        end
                    end,
                    OnCancel = function(self, data)
                    end,
                    whileDead = 1,
                    hideOnEscape = 1,
                }
            end
            StaticPopup_Show("ZL_reportDetailIncomeConfirm", msgStr, nil ,isGroup)
        else
            if not StaticPopupDialogs["ZL_reportDetailIncomeConfirm2"] then
                StaticPopupDialogs["ZL_reportDetailIncomeConfirm2"] = {
                    text = "%s",
                    button1 = "通报",
                    button2 = "取消",
                    OnShow = function(self)
                        self:GetEditBox():SetNumeric(false)
                        self:GetEditBox():SetAutoFocus(false)
                    end,
                    OnAccept = function(self, data)
                        if data then
                            reportGroupIncome()
                        else
                            reportDetailIncome()
                        end
                    end,
                    OnCancel = function(self, data)
                    end,
                    whileDead = 1,
                    hideOnEscape = 1,
                }
            end
            StaticPopup_Show("ZL_reportDetailIncomeConfirm2", msgStr, nil, isGroup)
        end
    end
    local reportIncomeConfirm = ZL.reportIncomeConfirm
    local function reportDebtPlayer()
        GetAveWages()
        local playerBuyList = ZL.GetPlayerBuyList()
        local msgStr = ""
        if next(playerBuyList, nil) then
            local count = 0
            local msglist = {}
            msgStr = "欠款通报："
            tinsert(msglist, msgStr)
            for name, data in pairs(playerBuyList) do
                local balanceAmount = 0
                local playerPayToMLamount = 0
                if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
                    playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
                end
                balanceAmount = playerPayToMLamount - data.totalAmount
                if balanceAmount < 0 and (not PlayerIsML(name)) then
                    msgStr = ("%s：%dg"):format(ParseClassColorName(name), -balanceAmount)
                    tinsert(msglist, msgStr)
                    count = count + 1
                end
            end
            msgStr = "请以上欠款人员仔细核对，如有误，请及时提出！"
            tinsert(msglist, msgStr)
            local index = 1
            local function sendMessage()
                if index <= #msglist then
                    SendChatMessage(msglist[index], "RAID")
                    if index == #msglist then
                        wipe(msglist)
                    end
                    index = index + 1
                    C_Timer.After(0.3, sendMessage)
                end
            end
            if count > 0 then
                sendMessage()
            else
                msgStr = "没有欠款成员！"
                ZL.Print(msgStr)
            end
        else
            msgStr = "没有欠款成员！"
            ZL.Print(msgStr)
        end
    end
    function ZL.reportConsumerRanking()
        GetAveWages()
        local playerBuyList = ZL.GetPlayerBuyList()
        local msgStr = ""
        if next(playerBuyList, nil) then
            local msglist = {}
            local tempList = {}
            for name, value in pairs(playerBuyList) do
                tinsert(tempList, {name=name, totalAmount=value.totalAmount})
            end
            if #tempList > 1 then
                table.sort(tempList, function (a, b)
                    return a.totalAmount > b.totalAmount
                end)
            end
            tinsert(msglist, "<<<消费排名>>>")
            for index, data in ipairs(tempList) do
                if data.totalAmount > 0 then
                    msgStr = index .. "、" .. ParseClassColorName(data.name) .. "：" .. data.totalAmount
                    tinsert(msglist, msgStr)
                end
            end
            local index = 1
            local function sendMessage()
                if index <= #msglist then
                    SendChatMessage(msglist[index], "RAID")
                    if index == #msglist then
                        wipe(msglist)
                    end
                    index = index + 1
                    C_Timer.After(0.3, sendMessage)
                end
            end
            sendMessage()
        else
            ZL.Print("没有消费记录")
        end
    end
    local reportConsumerRanking = ZL.reportConsumerRanking
    --流拍通报/将流拍物品放到指定背包
    function ZL.reportFailedItem(failedItemToBag)
        local msgStr = ""
        if not PlayerIsML() then
            msgStr = "你不是ML，无法使用这个功能！"
            ZL.Print(msgStr)
            return
        end
        local msglist = {}
        local failedCount = 0 --总的可以交易流拍物品数量
        local failedItemList = {}
        local failedItemGUIDList = {}
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            for _, data in ipairs(ZL_CURRENT.auctionlist) do
                if data.state == "failed" and data.bindType == 1 and data.spawnUID then
                    for _, value in pairs(data.spawnUID) do
                        if value.itemGUID and next(value.itemGUID, nil) then
                            for key, _ in pairs(value.itemGUID) do
                                --判断是否在背包
                                local bag, slot = ZL.FindItemInBag(key)
                                if bag then
                                    tinsert(failedItemGUIDList, key)
                                    --判断是否还有交易剩余时间
                                    if (not ZL.ToolTip) then
                                        ZL.ToolTip = CreateFrame("GameTooltip", "TradeTimeRemainingTooltip", nil, "GameTooltipTemplate")
                                    end
                                    ZL.ToolTip:SetOwner(UIParent, "ANCHOR_NONE")
                                    ZL.ToolTip:ClearLines()
                                    ZL.ToolTip:SetBagItem(bag, slot)
                                    for i = 1, ZL.ToolTip:NumLines() do
                                        local text = _G["TradeTimeRemainingTooltipTextLeft"..i]:GetText()
                                        if text then
                                            local timeRemaining = text:match(BIND_TRADE_TIME_REMAINING:gsub("%%s", "(.+)"))
                                            if timeRemaining then
                                                local hour = tonumber(timeRemaining:match("(%d+)" .. "小时")) or 0
                                                local min = tonumber(timeRemaining:match("(%d+)" .. "分钟")) or 0
                                                if not failedItemList[data.itemlink] then failedItemList[data.itemlink] = {timeRemaining={}, count=0} end
                                                failedItemList[data.itemlink].count = (failedItemList[data.itemlink].count or 0) + 1
                                                tinsert(failedItemList[data.itemlink].timeRemaining, hour*60+min)
                                                if not failedItemList[data.itemlink].startbidamount then failedItemList[data.itemlink].startbidamount = data.startbidamount end
                                                break
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end
        else
            msgStr = "没有流拍物品！"
            ZL.Print(msgStr)
            return
        end
        if failedItemToBag then
            if #failedItemGUIDList > 0 then
                --将流拍物品放到指定背包
                local index = 1
                local function changeBag()
                    if index <= #failedItemGUIDList then
                        local itemGUID = failedItemGUIDList[index]
                        local function linshi()
                            if InCombatLockdown() or UnitIsDeadOrGhost("player") then
                                C_Timer.After(0.5, linshi)
                            else
                                C_Timer.After(0.5, function ()
                                    local num = C_Container.GetContainerNumFreeSlots(ZL.opt.liupaiBagId)
                                    if num > 1 then
                                        ZL.PutAuctionItemInBag(itemGUID, ZL.opt.liupaiBagId, ZL.opt.liupaiDirection)
                                    else
                                        ZL.PutAuctionItemInBag(itemGUID, ZL.opt.liupaiBagId2, ZL.opt.liupaiDirection)
                                    end
                                    index = index + 1
                                    C_Timer.After(0.5, changeBag)
                                end)
                            end
                        end
                        linshi()
                    end
                end
                changeBag()
            end
        else
            if next(failedItemList, nil) then
                for itemlink, data in pairs(failedItemList) do
                    failedCount = failedCount + data.count
                    if data.count > 1 then
                        msgStr = itemlink .. "x" .. data.count .. "(" .. data.startbidamount .. ")"
                    else
                        msgStr = itemlink .. "(" .. data.startbidamount .. ")"
                    end
                    if #data.timeRemaining > 1 then
                        --剩余最小的时间排到最前面，默认为升序
                        table.sort(data.timeRemaining)
                    end
                    msgStr = msgStr .. "(" .. math.floor(data.timeRemaining[1] / 60) .. "小时" .. data.timeRemaining[1] % 60 .."分钟)"
                    tinsert(msglist, msgStr)
                end
                msgStr = "可交易流拍物品详细清单如下："
                SendChatMessage(msgStr, "RAID")
                C_Timer.After(0.3, function ()
                    for _, msg in ipairs(msglist) do
                        SendChatMessage(msg, "RAID")
                    end
                    wipe(msglist)
                    wipe(failedItemList)
                    C_Timer.After(0.5, function ()
                        msgStr = "以上流拍物品总件数：" .. failedCount .. "件，有需要的，在团队频道发送物品链接+出价！"
                        SendChatMessage(msgStr, "RAID")
                        MyAddon:TransmitAddonInfo("AUTOAUC SOUND", {type="系统", soundName=msgStr})
                        msgStr = "如有流拍未通报的可能是：已分解或已无法交易或不在背包。"
                        SendChatMessage(msgStr, "RAID")
                    end)
                end)
            else
                msgStr = "包里没有可交易的流拍物品，可能已分解、过期或不在背包！"
                ZL.Print(msgStr)
            end
        end
    end
    local reportFailedItem = ZL.reportFailedItem
    --重置拍卖清单
    function ZL.resetAuction()
        --"您确定要重置当前拍卖记录么？确定将清空当前拍卖记录，并保存到历史记录中！"
        if (ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0) or (ZL_CURRENT.WagesBiLi and next(ZL_CURRENT.WagesBiLi))
        or (ZL_CURRENT.buyerItemList and #ZL_CURRENT.buyerItemList > 0) then
            local msgStr = "|cffffff00重置并保存|r：可到|cff4080FF历史拍卖|r中恢复\n\n为当前拍卖记录输入一个名字"
            StaticPopup_Show("ZL_RESETCURRENT", msgStr)
        else
            local msgStr = "没有拍卖物品记录，已直接清空！"
            ZL.Print(msgStr, true)
            ZL_CURRENT = {}
            ZL_PLAYERLIST = {}
            ZL.CreateAuctionInfo()
            auctionModeDropdown:SetValue(1)
            local chatType
            if IsInRaid(1) then
                chatType = "RAID"
            elseif IsInGroup(1) then
                chatType = "PARTY"
            elseif IsInGuild() then
                chatType = "GUILD"
            end
            if chatType then
                --获取团队版本号
                local data = {type="request"}
                MyAddon:TransmitAddonInfo2("AUTOAUC VER", data, chatType, nil, "BULK")
            end
            if not PlayerIsML() and ZL.GetMLname() then
                MyAddon:TransmitAddonInfo2("AUTOAUC REQ", "auctioning", "WHISPER", ZL.GetMLname())
            end
        end
        if PlayerIsML() then
            MyAddon:TransmitAddonInfo("AUTOAUC RESET", "重置")
        end
    end
    local resetAuction = ZL.resetAuction

    --保存团队名单
    function ZL.saveGroupMembers()
        local msgStr = ""
        if IsInRaid(1) then
            if not ZL_CURRENT["GroupMembersList"] then ZL_CURRENT["GroupMembersList"] = {} end
            tinsert(ZL_CURRENT["GroupMembersList"], 1, {
                saveTime = date("%Y-%m-%d %H:%M:%S", time()),
                list = ZL.GetCurrentRoster(true),
                ML = GetClassColorName(ZL.GetMLname()),
                RL = GetClassColorName(ZL.GetRLname()),
            })
            if ZL.opt.wagesGroupMembers == 0 then
                ZL.opt.wagesGroupMembers = 1
                ZL.TransmitAddonInfo_Pro()
                msgStr = "团队名单保存成功，并已选择|cffff0000最新历史1|r名单作为工资计算！"
            else
                msgStr = "团队名单保存成功，计算工资名单为：|cffff0000历史" .. ZL.opt.wagesGroupMembers .. "|r"
            end
            ZL.SpeakText("团队名单保存成功！")
        else
            msgStr = "不在团队中，无法保存团员名单！"
        end
        ZL.Print(msgStr)
    end
    local saveGroupMembers = ZL.saveGroupMembers

    --同步数据
    function ZL.syncDada()
        local msgStr
        if not IsInRaid(1) then
            msgStr = "不在团队中，无法同步数据"
            ZL.Print(msgStr)
            return
        end
        if ZL.syncDadaCD and ZL.syncDadaCD > 0 then
            msgStr = "同步数据CD中，剩余|cffffffff" .. ZL.syncDadaCD .. "|r秒"
            ZL.Print(msgStr)
            return
        end
        if PlayerIsML() then
            if ZL.syncAll then
                ZL.Print("通信被占用，请稍后重试。")
                return
            end
            if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
                local data = {
                    ["type"] = "all",
                    ["data"] = ZL_CURRENT,
                }
                MyAddon:SYNCALL(data)
                ZL.syncAll = true
            else
                msgStr = "没有拍卖数据需要同步"
            end
            if msgStr then
                ZL.Print(msgStr)
            end
        else
            msgStr = "已发送同步拍卖中数据请求，等待回应..."
            ZL.Print(msgStr, true)
            MyAddon:TransmitAddonInfo2("AUTOAUC REQ", "auctioning", "WHISPER", ZL.GetMLname())
        end
        ZL.syncDadaCD = 15
        C_Timer.NewTicker(1, function (self)
            if ZL.syncDadaCD <= 0 then
                self:Cancel()
            else
                ZL.syncDadaCD = ZL.syncDadaCD - 1
            end
        end)
    end
    local syncDada = ZL.syncDada
    local btnWidth, btnHeight, btnFontSize = 43, 22, 14

    MLFrame.reportBtn = CreateButton(nil, MLFrame, "通报", "TOPLEFT", MLFrame, "TOPLEFT", 0, 0, btnWidth, btnHeight, btnFontSize) --"BOTTOMLEFT", recordBtn, "TOPLEFT", 0, 0, 
    local reportBtn = MLFrame.reportBtn
    reportBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    reportBtn.BorderTop:Hide()
    reportBtn.BorderLeft:Hide()
    reportBtn.BorderBottom:Hide()
    reportBtn.BorderRight:Hide()
    reportBtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            if PlayerIsML () then
                reportIncomeConfirm()
            else
                ZL.Print("你不是M L，无法发送收支详情。")
            end
        elseif button == "RightButton" then
            local function tempMenuTable()
                local menuList = {}
                menuList = {
                    {text = "ML功能", isTitle = true},
                    {
                        disabled = not PlayerIsML(),
                        text = "|T130781:13:13:0:0|t 详细收支",
                        func = function ()
                            reportIncomeConfirm()
                        end
                    },
                    {
                        disabled = not PlayerIsML(),
                        text = "|T384751:13:13:0:0|t 小队工资",  --526421
                        func = function ()
                            reportIncomeConfirm(true)
                        end
                    },
                    {isSeparator = true},
                    {
                        disabled = not PlayerIsML(),
                        text = "|TInterface\\AddOns\\" .. addonName .. "\\Images\\rem.png:13:13:0:0|t 欠款名单",
                        func = function ()
                            reportDebtPlayer()
                        end
                    },
                    {
                        disabled = not PlayerIsML(),
                        text = "|TInterface\\AddOns\\" .. addonName .. "\\Images\\consumeRanking.png:13:13:0:0|t 消费排名",
                        func = function ()
                            reportConsumerRanking()
                        end
                    },
                    {isSeparator = true},
                    {
                        disabled = not PlayerIsML(),
                        text = "|TInterface\\AddOns\\" .. addonName .. "\\Images\\rules.png:13:13:0:0|t " .. ((ZL.opt.rulesString and #ZL.opt.rulesString > 0) and "拍卖规则" or "设置拍卖规则"),
                        func = function ()
                            if ZL.opt.rulesString and #ZL.opt.rulesString > 0 then
                                local announceStrings = emptytable("")
                                for line in string.gmatch(ZL.opt.rulesString, "[^\n]+") do
                                    for word in string.gmatch(line, "%S+") do
                                        if strlen(announceStrings[#announceStrings]) + 1 + strlen(word) > 255 then
                                            tinsert(announceStrings, word)
                                        else
                                            if strlen(announceStrings[#announceStrings]) > 0 then
                                                announceStrings[#announceStrings] = announceStrings[#announceStrings] .. " " .. word
                                            else
                                                announceStrings[#announceStrings] = word
                                            end
                                        end
                                    end
                                    tinsert(announceStrings, "")
                                end
                                local index = 1
                                local function sendMessage()
                                    if index <= #announceStrings then
                                        SendChatMessage(announceStrings[index], "RAID")
                                        if index == #announceStrings then
                                            wipe(announceStrings)
                                            announceStrings = nil
                                            return
                                        end
                                        index = index + 1
                                        C_Timer.After(0.3, sendMessage)
                                    end
                                end
                                sendMessage()
                            else
                                ZL.Print("没有拍卖规则，请先输入！")
                                ZL.OpenAceConfigDialog("金团拍卖助手", "notification")
                            end
                        end,
                        tooltipMore = function(tip, data, button)
                            tip:AddLine("拍卖规则")
                            if ZL.opt.rulesString and #ZL.opt.rulesString>0 then
                                local announceStrings = emptytable("")
                                for line in string.gmatch(ZL.opt.rulesString, "[^\n]+") do
                                    for word in string.gmatch(line, "%S+") do
                                        if strlen(announceStrings[#announceStrings]) + 1 + strlen(word) > 255 then
                                            tinsert(announceStrings, word)
                                        else
                                            if strlen(announceStrings[#announceStrings]) > 0 then
                                                announceStrings[#announceStrings] = announceStrings[#announceStrings] .. " " .. word
                                            else
                                                announceStrings[#announceStrings] = word
                                            end
                                        end
                                    end
                                    tinsert(announceStrings, "")
                                end
                                for _, word in ipairs(announceStrings) do
                                    tip:AddLine(word, 1, 1, 1)
                                end
                            else
                                tip:AddLine("没有拍卖规则，请先设置", 1, 1, 1, true)
                            end
                        end,
                        hasArrow = (ZL.opt.rulesString and #ZL.opt.rulesString > 0) and true or nil,
                        menuTable = {
                            {
                                text = "修改拍卖规则",
                                func = function ()
                                    ZL.OpenAceConfigDialog("金团拍卖助手", "notification")
                                    ZL.GUI:CloseMenu()
                                end
                            }
                        }
                    },
                }
                tinsert(menuList, {isSeparator = true})
                tinsert(menuList, {text = "关闭"})
                return menuList
            end
            ZL.GUI:ToggleMenu(self, tempMenuTable(), 'TOPLEFT', self, 'BOTTOMLEFT', 0, 0)
        end
    end)
    reportBtn:SetScript("OnEnter", function (self)
        local numGroupMembers, _, totalincome, totalpayout = ZL.GetAveWages()
        if numGroupMembers and ZL_CURRENT.auctionlist then
            local left, _, width = AuctionFrame:GetRect()
            local right = GetScreenWidth() - (left + width)
            if left >= right then
                GameTooltipShow(AuctionFrame, "TOPRIGHT", "TOPLEFT", 0, btnHeight)
            else
                GameTooltipShow(AuctionFrame, "TOPLEFT", "TOPRIGHT", 0, btnHeight)
            end
            local playerBuyList = ZL.GetPlayerBuyList()
            local msg = select(2, ZL.GetWagesGroupMembers())
            if msg then
                GameTooltip:AddLine(msg)
            end
            local butie = ZL_CURRENT.butie
            local failedItemsList = {}
            local failedItemsTable = {}
            for _, data in ipairs(ZL_CURRENT.auctionlist) do
                if data.state == "failed" then
                    if not failedItemsTable[data.itemlink] then
                        failedItemsTable[data.itemlink] = 0
                        tinsert(failedItemsList, data.itemlink)
                    end
                    failedItemsTable[data.itemlink] = failedItemsTable[data.itemlink] + data.itemCount
                end
            end
            if #failedItemsList > 0 then
                sort(failedItemsList)
            end
            local count = (ZL_CURRENT["IncomeList"] and #ZL_CURRENT["IncomeList"] or 0)
            if (#butie + count) > 0 then
                GameTooltip:AddLine("当前收支记录：", 1, 1, 1)
                GameTooltip:AddDoubleLine("名称", "玩家(总金额/数量)")
                if count > 0 then
                    for _, data in ipairs(ZL_CURRENT.IncomeList) do
                        local itemId = string.match(data.notes, "|c.-|Hitem:(%d+):")
                        if itemId then
                            local itemLevel = select(4, cGetItemInfo(data.notes)) or "未知"
                            GameTooltip:AddDoubleLine(
                                "|T" .. cGetItemIcon(data.notes) .. ":12|t " .. data.notes .. "(" .. itemLevel .. ")",
                                ZL.GetNoRealmName(data.player, true) .. "(" .. data.amount .. "/" .. (data.itemCount or 1) .. ")", 1, 1, 1, 1, 1, 1
                            )
                        else
                            GameTooltip:AddDoubleLine(
                                "|T:12|t " .. data.notes,
                                ZL.GetNoRealmName(data.player, true) .. "(" .. data.amount .. ")", 1, 1, 1, 1, 1, 1
                            )
                        end
                    end
                end
                if #failedItemsList > 0 then
                    for _, itemlink in ipairs(failedItemsList) do
                        local itemId = string.match(itemlink, "|c.-|Hitem:(%d+):")
                        if itemId then
                            local itemLevel = select(4, cGetItemInfo(itemlink)) or "未知"
                            GameTooltip:AddDoubleLine(
                                "|T" .. cGetItemIcon(itemlink) .. ":12|t " .. itemlink .. "(" .. itemLevel .. ")",
                                "|cffff0000流拍|r(" .. failedItemsTable[itemlink] .. ")", 1, 1, 1, 1, 1, 1
                            )
                        else
                            GameTooltip:AddDoubleLine(
                                "|T:12|t " .. itemlink,
                                "|cffff0000流拍|r(" .. failedItemsTable[itemlink] .. ")", 1, 1, 1, 1, 1, 1
                            )
                        end
                    end
                end
                if #butie > 0 then
                    for _, data in ipairs(butie) do
                        local itemId = string.match(data.notes, "|c.-|Hitem:(%d+):")
                        if itemId then
                            GameTooltip:AddDoubleLine(
                                "|T" .. cGetItemIcon(data.notes) .. ":12|t " .. data.notes,
                                data.player .. "(" .. data.amount .. ")", 1, 1, 1, 1, 1, 1)
                        else
                            GameTooltip:AddDoubleLine(
                                "|T:12|t |cff9173ff" .. data.notes .. "|r",
                                data.player .. "(" .. data.amount .. ")", 1, 1, 1, 1, 1, 1)
                        end
                    end
                end
                GameTooltip:AddLine(" ")
                GameTooltip:AddDoubleLine("总收入：|cffffffff" .. totalincome .. "|rg", "总支出：|cffffffff" .. (totalpayout == 0 and 0 or -totalpayout) .. "|rg")
                local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
                local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
                if subsidyData["RL"] == "团双" then
                    GameTooltip:AddDoubleLine(
                        "净收入：|cffffffff" .. (totalincome + totalpayout) .. "|rg",
                        "人数(|cffffffff团双|r)：|cffffffff" .. numGroupMembers .. "|r人"
                    )
                else
                    GameTooltip:AddDoubleLine(
                        "净收入：|cffffffff" .. (totalincome + totalpayout) .. "|rg",
                        "人数：|cffffffff" .. numGroupMembers .. "|r人"
                    )
                end
                GameTooltip:AddLine(ZL_CURRENT["aveWages"] and "人均工资：|cffffffff" .. ZL_CURRENT["aveWages"] .. "|rg" or " ")
                GameTooltip:AddLine(" ")
                GameTooltip:AddDoubleLine("左键：|cffffffff详细收支|r", "右键：|cffffffff更多功能|r")
            else
                GameTooltip:AddLine("当前没有收入记录！")
                GameTooltip:AddLine(" ")
                GameTooltip:AddLine("左键：|cffffffff详细收支|r")
                GameTooltip:AddLine("右键：|cffffffff更多功能|r")
            end
            
            GameTooltip:Show()
            if not ZL.opt.xiaoFeiToolTipHide then
                if (not ZL.xiaoFeiToolTip) then
                    ZL.xiaoFeiToolTip = CreateFrame("GameTooltip", "xiaoFeiToolTip", UIParent, "GameTooltipTemplate") --GameTooltipTemplate,SharedTooltipTemplate
                    ZL.xiaoFeiToolTip:SetClampedToScreen(false)
                end
                _G["xiaoFeiToolTip"]:ClearAllPoints()
                _G["xiaoFeiToolTip"]:ClearLines()
                _G["xiaoFeiToolTip"]:SetOwner(self, "ANCHOR_NONE")
                if left >= right then
                    _G["xiaoFeiToolTip"]:SetPoint("TOPRIGHT", GameTooltip, "TOPLEFT", 0, 0)
                else
                    _G["xiaoFeiToolTip"]:SetPoint("TOPLEFT", GameTooltip, "TOPRIGHT", 0, 0)
                end
                _G["xiaoFeiToolTip"]:AddLine("消费排名(|cffffffff前10|r)：")
                if next(playerBuyList, nil) then
                    _G["xiaoFeiToolTip"]:AddDoubleLine("名字", "消费金额")
                    local tempList = {}
                    for name, value in pairs(playerBuyList) do
                        tinsert(tempList, {name=name, totalAmount=value.totalAmount})
                    end
                    if #tempList > 1 then
                        table.sort(tempList, function (a, b)
                            return a.totalAmount > b.totalAmount
                        end)
                    end
                    for index, data in ipairs(tempList) do
                        if data.totalAmount > 0  then
                            if index <= 3 then
                                _G["xiaoFeiToolTip"]:AddDoubleLine(ZL.GetNoRealmName(data.name, true), data.totalAmount, 1, 0, 0, 1, 0, 0)
                            elseif index <= 10 then
                                _G["xiaoFeiToolTip"]:AddDoubleLine(ZL.GetNoRealmName(data.name, true), data.totalAmount, 1, 1, 1, 1, 1, 1)
                            end
                        end
                    end
                else
                    _G["xiaoFeiToolTip"]:AddLine("暂时无人消费", 1, 1, 1)
                end
                _G["xiaoFeiToolTip"]:Show()
                
            end
            if not ZL.opt.debtToolTipHide then
                if (not ZL.debtToolTip) then
                    ZL.debtToolTip = CreateFrame("GameTooltip", "debtToolTip", UIParent, "GameTooltipTemplate") --GameTooltipTemplate,SharedTooltipTemplate
                    ZL.debtToolTip:SetClampedToScreen(false)
                end
                _G["debtToolTip"]:ClearAllPoints()
                _G["debtToolTip"]:ClearLines()
                _G["debtToolTip"]:SetOwner(self, "ANCHOR_NONE")
                if ZL.opt.xiaoFeiToolTipHide then
                    _G["debtToolTip"]:SetPoint("TOPRIGHT", GameTooltip, "TOPLEFT", 0, 0)
                else
                    _G["debtToolTip"]:SetPoint("TOPRIGHT", _G["xiaoFeiToolTip"], "BOTTOMRIGHT", 0, 0)
                end
                _G["debtToolTip"]:AddLine("欠款名单：")
                if next(playerBuyList, nil) then
                    _G["debtToolTip"]:AddDoubleLine("玩家名字", "欠款")
                    local isDebt = false
                    for name, data in pairs(playerBuyList) do
                        local balanceAmount = 0
                        local playerPayToMLamount = 0
                        if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
                            playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
                        end
                        balanceAmount = playerPayToMLamount - data.totalAmount
                        if PlayerIsML(name) then
                            balanceAmount = 0
                        end
                        if balanceAmount < 0 then
                            isDebt = true
                            local isExist = false
                            local text = ZL.GetNoRealmName(name, true)
                            for i = 1, MAX_RAID_MEMBERS do
                                local _name, _, subgroup = GetRaidRosterInfo(i)
                                if _name and GetClassColorName(_name) == name then
                                    text = text .. "(" .. subgroup .. "队)"
                                    isExist = true
                                    break
                                end
                            end
                            if (not isExist) then
                                text = text .. "(已离队)"
                            end
                            _G["debtToolTip"]:AddDoubleLine(text, balanceAmount, 1, 1, 1, 1, 1, 1)
                        end
                    end
                    if not isDebt then
                        _G["debtToolTip"]:AddLine("没有欠款记录！", 1, 1, 1)
                    end
                else
                    _G["debtToolTip"]:AddLine("没有欠款记录！", 1, 1, 1)
                end
                _G["debtToolTip"]:Show()
            end
            if ZL.xiaoFeiToolTip and ZL.debtToolTip then
                local maxWidth = max(_G["xiaoFeiToolTip"]:GetWidth(), _G["debtToolTip"]:GetWidth())
                _G["xiaoFeiToolTip"]:SetWidth(maxWidth)
                _G["debtToolTip"]:SetWidth(maxWidth)
            end
        else
            if not ZL.opt.hideBtnTooltip then
                GameTooltipShow(self, "BOTTOM", "TOP")
                GameTooltip:AddLine("提示")
                GameTooltip:AddLine("左键：|cffffffff详细收支|r")
                GameTooltip:AddLine("右键：|cffffffff更多功能|r")
                GameTooltip:Show()
            end
        end
    end)
    reportBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
        if ZL.debtToolTip then ZL.debtToolTip:Hide() end
        if ZL.xiaoFeiToolTip then ZL.xiaoFeiToolTip:Hide() end
    end)
    MLFrame.windowsBtn = CreateButton(nil, MLFrame, "窗口", "LEFT", reportBtn, "RIGHT", 0, 0, btnWidth, btnHeight, btnFontSize)
    local windowsBtn = MLFrame.windowsBtn
    windowsBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    windowsBtn.BorderTop:Hide()
    windowsBtn.BorderLeft:Hide()
    windowsBtn.BorderBottom:Hide()
    windowsBtn.BorderRight:Hide()
    windowsBtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            ZL.AuctionRecordFrame:Show()
            _G["ZLAuctionRecordFrameTab3"]:Click()
        elseif button == "RightButton" then
            local function tempMenuTable()
                local menuList = {}
                menuList = {
                    {
                        text = "|A::13:13|a 检查团队CD",
                        func = function ()
                            if not ZL.InstancesInfoFrame then ZL.CreateInstancesInfoFrame() end
                            ZL.InstancesInfoFrame:Show()
                        end
                        
                    },
                    {
                        text = "|A::13:13|a 导入/导出配置",
                        notClickable = 1,
                        hasArrow = 1,
                        menuTable = {
                            {
                                text = "导出",
                                func = function ()
                                    if not ZL.ExportProfilesFrame then
                                        ZL.CreateExportProfilesFrame()
                                    end
                                    ZL.ExportProfilesFrame.type = "export"
                                    ZL.ExportProfilesFrame:Hide()
                                    ZL.ExportProfilesFrame:Show()
                                end
                            },
                            {
                                text = "导入",
                                func = function ()
                                    if not ZL.ExportProfilesFrame then
                                        ZL.CreateExportProfilesFrame()
                                    end
                                    ZL.ExportProfilesFrame.type = "import"
                                    ZL.ExportProfilesFrame:Hide()
                                    ZL.ExportProfilesFrame:Show()
                                end
                            },
                        },
                    },
                    {
                        text = "|A::13:13|a 导入工资名单",
                        func = function ()
                            if not ZL.ImportWagesFrame then ZL:CreateImportWagesFrame() end
                            ZL.ImportWagesFrame:Show()
                        end
                    },
                    {
                        text = "|A:auctionhouse-icon-coin-gold:13:13|a 工资分配",
                        func = function ()
                            ZL.AuctionRecordFrame:Show()
                            _G["ZLAuctionRecordFrameTab3"]:Click()
                        end
                    },
                    {
                        text = "|TInterface\\AddOns\\AutoAuction\\Images\\shouzhi.png:13:13:0:0|t 当前收支",
                        func = function ()
                            ZL.AuctionRecordFrame:Show()
                            _G["ZLAuctionRecordFrameTab2"]:Click()
                        end
                    },
                    {
                        text = "|TInterface\\AddOns\\AutoAuction\\Images\\histroy.png:13:13:0:0|t 历史拍卖",
                        func = function ()
                            ZL.AuctionRecordFrame:Show()
                            _G["ZLAuctionRecordFrameTab1"]:Click()
                        end
                    },
                    {isSeparator = true},
                    {
                        text = "|T528409:13:13:0:0|t 账单总览",
                        func = function ()
                            ZL.ReconciliationFrame:Hide()
                            ZL.BillOverviewFrame:Update(ZL_CURRENT)
                            ZL.BillOverviewFrame:Show()
                        end
                    },
                    {
                        text = "|T132065:13:13:0:0|t 拾取记录",
                        func = function ()
                            ZL.ReconciliationFrame:Hide()
                            ZL.OverviewFrame:Update(ZL_PLAYERLIST.lootList)
                            ZL.OverviewFrame:Show()
                        end
                    },
                    {
                        text = "|TInterface\\AddOns\\AutoAuction\\Images\\bill.png:13:13:0:0|t 对账单",
                        func = function ()
                            ZL.BillOverviewFrame:Hide()
                            ZL.ReconciliationFrame:Show()
                        end
                    },
                    {isSeparator = true},
                    {
                        text = "|A:auctionhouse-icon-favorite:13:13:0:0|a 关注物品",
                        func = function ()
                            ZL.ConcernFrame:Show()
                        end
                    },
                }
                if PlayerIsML() then
                    tinsert(menuList, {
                        text = "|TInterface\\AddOns\\AutoAuction\\Images\\remain.png:13:13:0:0|t 剩余时间",
                        func = function ()
                            if not ZL.opt.remainingTradeTimeBtnValue then
                                ZL.opt.remainingTradeTimeBtnValue = true
                                ZL.ZLRemainingTradeTimeFrame:Show()
                                ZL.GetRemainingTradeTime()
                            else
                                ZL.opt.remainingTradeTimeBtnValue = false
                                ZL.ZLRemainingTradeTimeFrame:Hide()
                                if ZL.UpdateRemainingTradeTime then
                                    ZL.UpdateRemainingTradeTime:Cancel()
                                end
                            end
                        end
                    })
                end
                tinsert(menuList, {isSeparator = true})
                tinsert(menuList, {
                    text = "包装备设置",
                    func = function()
                        if not ZL.BuyItemsFrame then ZL:CreateBuyItemsFrame() end
                        ZL.BuyItemsFrame:Show()
                    end,
                })
                tinsert(menuList, {
                    text = "物品拍卖设置",
                    func = function()
                        ZL.ItemSettingFrame:Show()
                    end,
                })
                tinsert(menuList, {
                    text = "补贴设置",
                    hasArrow = 1,
                    menuTable = function ()
                        return {
                            {
                                text = "配置",
                                notClickable = 1,
                                hasArrow = 1,
                                menuTable = function ()
                                    local tempList = {}
                                    for index, profileName in ipairs(ZL.opt.subsidyProfileList.profileKeys) do
                                        tinsert(tempList, {
                                            text = profileName,
                                            checkable = 1,
                                            checked = ZL.opt.subsidyProfileSelect == index,
                                            func = function ()
                                                ZL.opt.subsidyProfileSelect = index
                                                ZL_CURRENT.subsidy = {}
                                                ZL_CURRENT.subsidyParent = {}
                                                ZL.SubsidyFrame.historyProfileDropdown:SetValue(ZL.opt.subsidyProfileSelect)
                                                ZL.SubsidyFrame:Update()
                                                if ZL_CURRENT.WagesBiLi then
                                                    for _, data in pairs(ZL_CURRENT.WagesBiLi) do
                                                        data["buTie"] = nil
                                                    end
                                                    if ZL.AuctionRecordFrame.playerBalanceFrame:IsShown() then
                                                        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
                                                    end
                                                end
                                            end
                                        })
                                    end
                                    return tempList
                                end
                            },
                            {
                                text = "补贴方案",
                                notClickable = 1,
                                hasArrow = 1,
                                menuTable = function ()
                                    local tempList = {}
                                    for i, text in ipairs({"无补贴", "|cfff58cba按父补贴金额|r"}) do
                                        tinsert(tempList, {
                                            text = text,
                                            checkable = 1,
                                            checked = ZL.opt.wagesSubsidyType == i,
                                            func = function ()
                                                ZL.opt.wagesSubsidyType = i
                                                ZL.SubsidyFrame.wagesSubsidyTypeDropdown:SetValue(ZL.opt.wagesSubsidyType)
                                                if ZL_CURRENT.WagesBiLi then
                                                    for _, data in pairs(ZL_CURRENT.WagesBiLi) do
                                                        data["buTie"] = nil
                                                    end
                                                    if ZL.AuctionRecordFrame.playerBalanceFrame:IsShown() then
                                                        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
                                                    end
                                                end
                                            end
                                        })
                                    end
                                    return tempList
                                end
                            },
                            {
                                text = "|cffffde00更多设置|r",
                                func = function ()
                                    ZL.SubsidyFrame:Show()
                                end
                            }
                        }
                    end,
                    func = function()
                        ZL.SubsidyFrame:Show()
                    end,
                })
                -- tinsert(menuList, {
                --     text = "AI任务分配",
                --     func = function()
                --         ZL.TaskFrame:Show()
                --     end,
                -- })
                -- tinsert(menuList, {
                --     text = "AI开团助手",
                --     func = function()
                --         ZL.RaidGroupsFrame:Show()
                --     end,
                -- })
                -- tinsert(menuList, {isSeparator = true})
                -- tinsert(menuList, {
                --     text = "|TInterface\\AddOns\\AutoAuction\\Images\\overview.png:13:13:0:0|t 信息总览",
                --     func = function()
                --         ZL.RolesOverViewFrame.locked = true
                --         ZL.opt.ZLRolesOverViewFrameIsShown = true
                --         ZL.GetOwnRolesData()
                --         ZL.RolesOverViewFrame:Show()
                --     end,
                -- })
                tinsert(menuList, {isSeparator = true})
                if ZL.opt.hideBtnTooltip then
                    tinsert(menuList, {
                        text = "打开按钮提示",
                        func = function()
                            ZL.opt.hideBtnTooltip = nil
                        end,
                    })
                else
                    tinsert(menuList, {
                        text = "关闭按钮提示",
                        func = function()
                            ZL.opt.hideBtnTooltip = true
                            GameTooltip:Hide()
                        end,
                    })
                end
                tinsert(menuList, {isSeparator = true})
                tinsert(menuList, {text = "关闭"})
                return menuList
            end
            ZL.GUI:ToggleMenu(self, tempMenuTable(), 'TOPLEFT', self, 'BOTTOMLEFT', 0, 0)
        end
    end)
    windowsBtn:SetScript("OnEnter", function (self)
        if PlayerIsML() then
            local left, _, width = AuctionFrame:GetRect()
            local right = GetScreenWidth() - (left + width)
            if left >= right then
                GameTooltipShow(AuctionFrame, "TOPRIGHT", "TOPLEFT", 0, btnHeight)
            else
                GameTooltipShow(AuctionFrame, "TOPLEFT", "TOPRIGHT", 0, btnHeight)
            end
            local RemainingTradeItems = ZL.GetRemainingTradeTime(true)
            if #RemainingTradeItems > 0 then
                GameTooltip:AddLine("装备交易剩余时间(ML功能)：", 1, 1, 1)
                GameTooltip:AddDoubleLine("名称", "剩余时间")
                for _, data in ipairs(RemainingTradeItems) do
                    if (data.hour*60 + data.min) <= 30 then
                        GameTooltip:AddDoubleLine(data.itemLink, "|cffff0000" .. data.timeRemaining .. "|r", 1, 1, 1, 1, 1, 1)
                    else
                        GameTooltip:AddDoubleLine(data.itemLink, data.timeRemaining, 1, 1, 1, 1, 1, 1)
                    end
                end
            else
                GameTooltip:AddLine("没有交易剩余时间的装备！")
            end
            GameTooltip:AddLine(" ")
            GameTooltip:AddDoubleLine("左键：|cffffffff工资分配|r", "右键：|cffffffff更多功能|r")
            GameTooltip:Show()
        else
            if not ZL.opt.hideBtnTooltip then
                GameTooltipShow(self, "BOTTOM", "TOP")
                GameTooltip:AddLine("提示")
                GameTooltip:AddLine("左键：|cffffffff工资分配|r")
                GameTooltip:AddLine("右键：|cffffffff更多功能|r")
                GameTooltip:Show()
            end
        end
    end)
    windowsBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    MLFrame.failedBtn2 = CreateButton(nil, MLFrame, "流拍", "LEFT", windowsBtn, "RIGHT", 0, 0, btnWidth, btnHeight, btnFontSize)
    local failedBtn2 = MLFrame.failedBtn2
    failedBtn2:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    failedBtn2.BorderTop:Hide()
    failedBtn2.BorderLeft:Hide()
    failedBtn2.BorderBottom:Hide()
    failedBtn2.BorderRight:Hide()
    failedBtn2:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            reportFailedItem()
        elseif button == "RightButton" then
            local function tempMenuTable()
                local menuList = {}
                menuList = {
                    {
                        disabled = not PlayerIsML(),
                        text = "|T130979:15:15:2:0|t " .. "流拍物品通报",
                        func = function ()
                            reportFailedItem()
                        end
                    },
                    {
                        disabled = not PlayerIsML(),
                        text = "|T576625:15:15:2:0|t " .. "批量流拍物品",
                        func = function ()
                            batchFailedItem()
                        end
                    },
                    {isSeparator=true},
                    {
                        disabled = (not PlayerIsML()) or InCombatLockdown(),
                        text = "|T132853:13:13:5:0|t " .. (InCombatLockdown() and "分解流拍物品(战斗中)" or "分解流拍物品"),
                        func = function ()
                            if not InCombatLockdown() then
                                if not ZL.DisenchantingFrame then ZL:CreateDisenchantingFrame() end
                                if not ZL.DisenchantingLgnoreFrame then ZL:CreateDisenchantingLgnoreFrame() end
                                ZL.DisenchantingFrame:Show()
                            else
                                ZL.Print("战斗中，无法使用分解功能！")
                            end
                        end
                    },
                    {
                        disabled = not PlayerIsML(),
                        text = "|T133633:13:13:5:0|t " .. "放到指定背包",
                        func = function ()
                            reportFailedItem(true)
                        end
                    },
                }
                tinsert(menuList, {isSeparator = true})
                if ZL.opt.hideBtnTooltip then
                    tinsert(menuList, {
                        text = "打开按钮提示",
                        func = function()
                            ZL.opt.hideBtnTooltip = nil
                        end,
                    })
                else
                    tinsert(menuList, {
                        text = "关闭按钮提示",
                        func = function()
                            ZL.opt.hideBtnTooltip = true
                            GameTooltip:Hide()
                        end,
                    })
                end
                tinsert(menuList, {isSeparator = true})
                tinsert(menuList, {text = "关闭"})
                return menuList
            end
            ZL.GUI:ToggleMenu(self, tempMenuTable(), 'TOPLEFT', self, 'BOTTOMLEFT', 0, 0)
        end
    end)
    failedBtn2:SetScript("OnEnter", function (self)
        if not ZL.opt.hideBtnTooltip then
            GameTooltipShow(self, "BOTTOM", "TOP")
            GameTooltip:AddLine("提示")
            GameTooltip:AddLine("左键：|cffffffff流拍通报|r")
            GameTooltip:AddLine("右键：|cffffffff更多功能|r")
            GameTooltip:Show()
        end
    end)
    failedBtn2:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    MLFrame.resetBtn = CreateButton(nil, MLFrame, "重置", "LEFT", failedBtn2, "RIGHT", 0, 0, btnWidth, btnHeight, btnFontSize)
    local resetBtn = MLFrame.resetBtn
    resetBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    resetBtn.BorderTop:Hide()
    resetBtn.BorderLeft:Hide()
    resetBtn.BorderBottom:Hide()
    resetBtn.BorderRight:Hide()
    resetBtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            if ZL.auctionStateCount() > 0 then
                StaticPopup_Show("ZL_RESETCURRENT2")
            else
                resetAuction()
            end
        elseif button == "RightButton" then
            local function tempMenuTable()
                local menuList = {}
                menuList = {
                    {
                        text = "|TInterface\\AddOns\\" .. addonName .. "\\Images\\reset.png:15:15:2:0|t " .. "重置拍卖清单",
                        func = function ()
                            if ZL.auctionStateCount() > 0 then
                                StaticPopup_Show("ZL_RESETCURRENT2")
                            else
                                resetAuction()
                            end
                        end
                    },
                    {
                        disabled = not PlayerIsML(),
                        text = "|TInterface\\AddOns\\" .. addonName .. "\\Images\\new.png:15:15:2:0|t " .. "创建拍卖物品",
                        tooltipMore = function(tip)
                            tip:AddLine("手动创建方法")
                            tip:AddLine("1、Ctr+右键：|cffffffff背包物品|r")
                            tip:AddLine("2、右键：|cffffffff物品链接|r")
                            tip:AddLine("3、直接点击按钮创建")
                        end,
                        func = function ()
                            if not PlayerIsML() then
                                local msgStr = "你不是ML，无法使用这个功能！"
                                ZL.Print(msgStr)
                                return
                            end
                            StaticPopup_Show("ZL_ADDAUCTIONITEM", nil, nil, nil, ZL.AddAuctionEditboxs)
                        end
                    },
                    {
                        text = "|T:15:15:2:0|t " .. "导出拍卖清单",
                        tooltipMore = function(tip)
                            tip:AddLine("导出格式：")
                            tip:AddLine("物品链接,玩家名,总金额,数量", 1, 1, 1)
                        end,
                        tooltipOnButton = 1,
                        func = function ()
                            local txt = ""
                            if ZL_CURRENT then
                                if ZL_CURRENT.IncomeList and #ZL_CURRENT.IncomeList > 0 then
                                    for _, data in ipairs(ZL_CURRENT.IncomeList) do
                                        if txt == "" then
                                            txt = format("%s,%s,%d,%d", data.notes:gsub("|", "||"), data.player:gsub("|", "||"), data.amount, data.itemCount)
                                        else
                                            txt = txt .. "\n" .. format("%s,%s,%d,%d", data.notes:gsub("|", "||"), data.player:gsub("|", "||"), data.amount, data.itemCount)
                                        end
                                    end
                                end
                                if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
                                    for _, data in ipairs(ZL_CURRENT.auctionlist) do
                                        if data.state == "failed" then
                                            if txt == "" then
                                                txt = format("%s,%s,%d,%d", data.itemlink:gsub("|", "||"), "流拍", 0, data.itemCount)
                                            else
                                                txt = txt .. "\n" .. format("%s,%s,%d,%d", data.itemlink:gsub("|", "||"), "流拍", 0, data.itemCount)
                                            end
                                        end
                                    end
                                end
                            end
                            if #txt > 0 then
                                if not  ZL.WaStringFrame then ZL:CreateWAStringFrame() end
                                ZL.WaStringFrame.Title:SetText("导出拍卖清单")
                                local editBox = ZL.WaStringFrame.scrollFrame.editBox
                                editBox:SetScript("OnTextChanged", function (self) self:HighlightText() end)
                                editBox:SetScript("OnMouseUp", function(self) self:HighlightText() end)
                                editBox:SetScript("OnEscapePressed", function() ZL.WaStringFrame:Hide() end)
                                editBox:SetText(txt)
                                editBox:HighlightText()
                                editBox:SetFocus()
                                ZL.WaStringFrame:Show()
                            else
                                ZL.Print("没有需要导出的数据！")
                            end
                        end
                    },
                    {isSeparator = true},
                    {
                        disabled = not PlayerIsML(),
                        text = "|TInterface\\AddOns\\" .. addonName .. "\\Images\\add.png:15:15:2:0|t " .. "手动登记收入",
                        func = function ()
                            if not PlayerIsML() then
                                local msgStr = "你不是ML，无法使用这个功能！"
                                ZL.ScrollingMessageFrame:AddMessage(msgStr)
                                return
                            end
                            local data = {
                                ["type"] = "收入"
                            }
                            StaticPopup_Show("ZL_ADDINCOME", "收入", nil, data, ZL.AddIncomeEditboxs)
                        end
                    },
                    {
                        disabled = not PlayerIsML(),
                        text = "|TInterface\\AddOns\\" .. addonName .. "\\Images\\rem.png:15:15:2:0|t " .. "手动登记支出",
                        func = function ()
                            if not PlayerIsML() then
                                local msgStr = "你不是ML，无法使用这个功能！"
                                ZL.ScrollingMessageFrame:AddMessage(msgStr)
                                return
                            end
                            local data = {
                                ["type"] = "支出"
                            }
                            StaticPopup_Show("ZL_ADDINCOME", "支出", nil, data, ZL.AddIncomeEditboxs)
                        end
                    },
                }
                tinsert(menuList, {isSeparator = true})
                if ZL.opt.hideBtnTooltip then
                    tinsert(menuList, {
                        text = "打开按钮提示",
                        func = function()
                            ZL.opt.hideBtnTooltip = nil
                        end,
                    })
                else
                    tinsert(menuList, {
                        text = "关闭按钮提示",
                        func = function()
                            ZL.opt.hideBtnTooltip = true
                            GameTooltip:Hide()
                        end,
                    })
                end
                tinsert(menuList, {isSeparator = true})
                tinsert(menuList, {text = "关闭"})
                return menuList
            end
            ZL.GUI:ToggleMenu(self, tempMenuTable(), 'TOPLEFT', self, 'BOTTOMLEFT', 0, 0)
        end
    end)
    resetBtn:SetScript("OnEnter", function (self)
        if not ZL.opt.hideBtnTooltip then
            GameTooltipShow(self, "BOTTOM", "TOP")
            GameTooltip:AddLine("提示")
            GameTooltip:AddLine("左键：|cffffffff重置拍卖清单|r")
            GameTooltip:AddLine("右键：|cffffffff更多功能|r")
            GameTooltip:Show()
        end
    end)
    resetBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    MLFrame.WABtn = CreateButton(nil, MLFrame, "版本", "LEFT", resetBtn, "RIGHT", 0, 0, btnWidth, btnHeight, btnFontSize)
    local WABtn = MLFrame.WABtn
    WABtn:RegisterForClicks("LeftButtonUp", "RightButtonUp") --, "RightButtonUp"
    WABtn.BorderTop:Hide()
    WABtn.BorderLeft:Hide()
    WABtn.BorderBottom:Hide()
    WABtn.BorderRight:Hide()
    WABtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            ZL_PLAYERLIST = ZL_PLAYERLIST or {}
            ZL_PLAYERLIST.GroupMembersVersion = {}
            local chatType
            if IsInRaid(1) then
                chatType = "RAID"
            elseif IsInGroup(1) then
                chatType = "PARTY"
            elseif IsInGuild() then
                chatType = "GUILD"
            end
            if chatType then
                local data = {type="request"}
                MyAddon:TransmitAddonInfo2("AUTOAUC VER", data, chatType, nil, "BULK")
            end
        else
            local tempList = {}
            for i, data in ipairs(ZL.updateList) do
                if i <= 20 then
                    tinsert(tempList, {
                        text = data.updateVer,
                        notClickable = 1,
                        tooltipMore = function (_, _, button)
                            GameTooltipShow(button, "TOPLEFT", "TOPRIGHT")
                            GameTooltip:AddLine(data.updateVer .. "    " .. data.updateDate)
                            GameTooltip:AddLine(data.updateContent, 1, 1, 1, true)
                        end
                    })
                else
                    break
                end
            end
            if #tempList > 0 then
                ZL.GUI:ToggleMenu(self, tempList, "cursor")
            end
        end
    end)
    WABtn:SetScript("OnEnter", function (self)
        if ZL_PLAYERLIST.GroupMembersVersion and next(ZL_PLAYERLIST.GroupMembersVersion) then
            local left, _, width = AuctionFrame:GetRect()
            local right = GetScreenWidth() - (left + width)
            if left >= right then
                GameTooltipShow(AuctionFrame, "TOPRIGHT", "TOPLEFT", 0, btnHeight)
            else
                GameTooltipShow(AuctionFrame, "TOPLEFT", "TOPRIGHT", 0, btnHeight)
            end
            if IsInRaid(1) then
                local totalMembers, hasAddon = ZL.GetGroupMembersAndHasAddon()
                GameTooltip:AddLine("团员版本信息|cffffffff(" .. hasAddon .. "/" .. totalMembers .. ")|r")
                for i = 1, MAX_RAID_MEMBERS do
                    local name, rank, _, _, _, _, _, online, _, _, isML = GetRaidRosterInfo(i)
                    if name then
                        local fullName = ZL.GetFullName(name)
                        local txt
                        if name == UnitName("player") then
                            txt = "你"
                        else
                            txt = ZL.GetNoRealmName(GetClassColorName(name), true)
                        end
                        if rank == 2 then
                            txt = txt .. "|TInterface\\GroupFrame\\UI-Group-LeaderIcon:12|t"
                        elseif rank == 1 then
                            txt = txt .. "|TInterface\\GroupFrame\\UI-GROUP-ASSISTANTICON:12|t"
                        end
                        if isML then
                            txt = txt .. "|TInterface\\GroupFrame\\UI-Group-MasterLooter:12|t"
                        end
                        if online then
                            if ZL_PLAYERLIST.GroupMembersVersion[fullName] then
                                GameTooltip:AddDoubleLine(txt, ZL_PLAYERLIST.GroupMembersVersion[fullName], 1, 1, 1, 1, 1, 1)
                            else
                                GameTooltip:AddDoubleLine(txt, "|cffffd100未安装|r", 1, 1, 1, 1, 1, 1)
                            end
                        else
                            GameTooltip:AddDoubleLine(txt, "|cffff0000离线|r", 1, 1, 1, 1, 1, 1)
                        end
                    end
                end
            elseif IsInGroup(1) then
                GameTooltip:AddLine("队伍版本信息")
                for i = 1, GetNumGroupMembers() do
                    local unitId
                    if i == 1 then
                        unitId = "player"  -- 玩家自己
                    else
                        unitId = "party"..(i-1)  -- 其他小队成员
                    end
                    local name = UnitName(unitId)
                    if name then
                        local fullName = ZL.GetFullName(name)
                        local txt = GetClassColorName(name)
                        if i == 1 then
                            txt = "你"
                        end
                        if UnitIsConnected(unitId) then
                            if ZL_PLAYERLIST.GroupMembersVersion[fullName] then
                                GameTooltip:AddDoubleLine(txt, ZL_PLAYERLIST.GroupMembersVersion[fullName], 1, 1, 1, 1, 1, 1)
                            else
                                GameTooltip:AddDoubleLine(txt, "|cffffd100未安装|r", 1, 1, 1, 1, 1, 1)
                            end
                        else
                            GameTooltip:AddDoubleLine(txt, "|cffff0000离线|r", 1, 1, 1, 1, 1, 1)
                        end
                    end
                end
            elseif IsInGuild() then
                C_GuildInfo.GuildRoster()
                ZL.GUILD_ROSTER_UPDATE = nil
                GameTooltip:AddLine("公会成员版本信息")
                for i = 1, GetNumGuildMembers() do
                    local name, _, _, _, _, _, _, _, isOnline, _, class = GetGuildRosterInfo(i)
                    if isOnline then
                        local fullName = name
                        local pruneName = ZL.pruneCrossRealm(name)
                        local txt = GetClassColorName(fullName, class)
                        if pruneName == UnitName("player") then
                            txt = "你"
                        end
                        if ZL_PLAYERLIST.GroupMembersVersion[fullName] then
                            GameTooltip:AddDoubleLine(txt, ZL_PLAYERLIST.GroupMembersVersion[fullName], 1, 1, 1, 1, 1, 1)
                        else
                            GameTooltip:AddDoubleLine(txt, "|cffffd100未安装|r", 1, 1, 1, 1, 1, 1)
                        end
                    end
                end
            else
                GameTooltip:AddLine("在团队、小队、工会中才可获取版本信息")
            end
            GameTooltip:AddLine(" ")
            GameTooltip:AddLine("左键：|cffffffff刷新团队或工会版本信息|r")
            GameTooltip:AddLine("右键：|cffffffff查看历史版本更新记录|r")
            GameTooltip:Show()
        else
            if not ZL.opt.hideBtnTooltip then
                GameTooltipShow(self, "BOTTOM", "TOP")
                GameTooltip:AddLine("提示")
                GameTooltip:AddLine("左键：|cffffffff刷新团队或工会版本信息|r")
                GameTooltip:AddLine("右键：|cffffffff查看历史版本更新记录|r")
                GameTooltip:Show()
            end
        end
    end)
    WABtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    MLFrame.saveBtn = CreateButton(nil, MLFrame, "保存", "LEFT", WABtn, "RIGHT", 0, 0, btnWidth, btnHeight, btnFontSize)
    local saveBtn = MLFrame.saveBtn
    saveBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    saveBtn.BorderTop:Hide()
    saveBtn.BorderLeft:Hide()
    saveBtn.BorderBottom:Hide()
    saveBtn.BorderRight:Hide()
    saveBtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            saveGroupMembers()
        elseif button == "RightButton" then
            local function tempMenuTable()
                ZL.opt.wagesGroupMembers = (ZL_CURRENT["globalConfig"] and ZL_CURRENT["globalConfig"]["wagesGroupMembers"]) and ZL_CURRENT["globalConfig"]["wagesGroupMembers"] or ZL.opt.wagesGroupMembers
                if ZL_CURRENT["GroupMembersList"] then
                    if ZL.opt.wagesGroupMembers > #ZL_CURRENT["GroupMembersList"] then
                        if #ZL_CURRENT["GroupMembersList"] > 0 then
                            ZL.opt.wagesGroupMembers = 1
                        else
                            ZL.opt.wagesGroupMembers = 0
                        end
                    end
                end
                local function groupmembers()
                    local menuList = {}
                    if IsInRaid(1) then
                        local members = ZL.GetCurrentRoster()
                        local groupList = {}
                        for i = 1, #members do
                            if #members[i] > 0 then
                                local memberList = {}
                                for _, name in ipairs(members[i]) do
                                    tinsert(memberList, {
                                        text = ZL.GetNoRealmName(name, true),
                                        func = function ()
                                            ZL.GUI:CloseMenu()
                                        end,
                                    })
                                end
                                tinsert(groupList, {
                                    text = "小队 " .. i,
                                    hasArrow = 1,
                                    menuTable = memberList,
                                    func = function ()
                                        ZL.GUI:CloseMenu()
                                    end,
                                })
                            end
                        end
                        tinsert(menuList, {
                            text = "当前成员",
                            checkable = 1,
                            isNotRadio = nil,
                            checked = ZL.opt.wagesGroupMembers == 0 and true or nil,
                            disabled = not PlayerIsML(),
                            hasArrow = 1,
                            menuTable = groupList,
                            func = function ()
                                ZL.opt.wagesGroupMembers = 0
                                ZL.TransmitAddonInfo_Pro()
                                ZL.GUI:CloseMenu()
                                ZL.Print("已选择|cffff0000当前成员|r作为工资计算名单", true)
                            end
                        })
                    end
                    --不在团队中时，按照最新保存时间生成历史保存名单
                    local currentRoster = ZL_CURRENT["GroupMembersList"]
                    if currentRoster and #currentRoster > 0 then
                        for index, data in ipairs(currentRoster) do
                            local groupList = {}
                            if data["saveTime"] then
                                tinsert(groupList, {text=data["saveTime"], isTitle=true})
                            end
                            local members = data.list
                            for i = 1, #members do
                                if #members[i] > 0 then
                                    local memberList = {}
                                    for _, name in ipairs(members[i]) do
                                        tinsert(memberList, {
                                            text = ZL.GetNoRealmName(name, true),
                                            func = function ()
                                                ZL.GUI:CloseMenu()
                                            end,
                                        })
                                    end
                                    tinsert(groupList, {
                                        text = "小队 " .. i,
                                        hasArrow = 1,
                                        menuTable = memberList,
                                        func = function ()
                                            ZL.GUI:CloseMenu()
                                        end,
                                    })
                                end
                            end
                            local checked
                            if ZL.opt.wagesGroupMembers == 0 and (not IsInRaid(1)) and index == 1 then
                                checked = true
                            else
                                checked = (ZL.opt.wagesGroupMembers == index and true or false)
                            end
                            tinsert(menuList, {
                                text = "历史" .. index,
                                checkable = 1,
                                isNotRadio = nil,
                                checked = checked,
                                disabled = not PlayerIsML(),
                                hasArrow = 1,
                                menuTable = groupList,
                                func = function ()
                                    ZL.opt.wagesGroupMembers = index
                                    ZL.TransmitAddonInfo_Pro()
                                    ZL.GUI:CloseMenu()
                                    ZL.Print("已选择|cffff0000历史" .. index .. "|r作为工资计算名单", true)
                                end
                            })
                        end
                    end
                    if #menuList == 0 then
                        tinsert(menuList, {text = "没有名单数据", isTitle = true})
                    end
                    return menuList
                end
                local menuList = {}
                menuList = {
                    {
                        -- disabled = not PlayerIsML(),
                        text = "|TInterface\\AddOns\\" .. addonName .. "\\Images\\save.png:15:15:2:0|t 保存团员名单",
                        func = function ()
                            saveGroupMembers()
                        end
                    },
                    {
                        disabled = not PlayerIsML(),
                        text = "|T:15:15:2:0|t 选择团员名单",
                        hasArrow = 1,
                        menuTable = groupmembers(),
                    },
                    {isSeparator = true},
                }
                tinsert(menuList, {
                    text = "|TInterface\\AddOns\\" .. addonName .. "\\Images\\sync.png:15:15:2:0|t " .. (PlayerIsML() and "同步所有数据" or "同步ML数据") .. ((ZL.syncDadaCD and ZL.syncDadaCD>0) and "(" .. ZL.syncDadaCD .. ")" or ""),
                    disabled = (ZL.syncDadaCD and ZL.syncDadaCD > 0) or (not IsInRaid(1)),
                    func = function ()
                        syncDada()
                    end
                })
                tinsert(menuList, {isSeparator = true})
                if ZL.opt.hideBtnTooltip then
                    tinsert(menuList, {
                        text = "打开按钮提示",
                        func = function()
                            ZL.opt.hideBtnTooltip = nil
                        end,
                    })
                else
                    tinsert(menuList, {
                        text = "关闭按钮提示",
                        func = function()
                            ZL.opt.hideBtnTooltip = true
                            GameTooltip:Hide()
                        end,
                    })
                end
                tinsert(menuList, {isSeparator = true})
                tinsert(menuList, {text = "关闭"})
                return menuList
            end
            ZL.GUI:ToggleMenu(self, tempMenuTable(), 'TOPLEFT', self, 'BOTTOMLEFT', 0, 0)
        end
    end)
    saveBtn:SetScript("OnEnter", function (self)
        if not ZL.opt.hideBtnTooltip then
            GameTooltipShow(self, "BOTTOM", "TOP")
            GameTooltip:AddLine("提示")
            GameTooltip:AddLine("左键：|cffffffff保存团员名单|r")
            GameTooltip:AddLine("右键：|cffffffff更多功能|r")
            GameTooltip:Show()
        end
    end)
    saveBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)

    AuctionFrame.settingBtn = CreateFrame("Button", nil, AuctionFrame)
    local settingBtn = AuctionFrame.settingBtn
    settingBtn:SetPoint("TOPLEFT", AuctionFrame, "TOPLEFT", 5, -6)
    settingBtn:SetSize(14, 14)
    local texture = "Interface\\Buttons\\UI-OptionsButton.blp"
    settingBtn:SetNormalTexture(texture)
    settingBtn:SetHighlightTexture(texture)
    settingBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    settingBtn:SetScript("OnClick", function (self, button)
        ZL.OpenAceConfigDialog("金团拍卖助手")
    end)
    settingBtn:SetScript("OnEnter", function (self)
        local posLeft = AuctionFrame:GetLeft()
        local posRight = GetScreenWidth() - AuctionFrame:GetRight()
        if posLeft > posRight then
            GameTooltipShow(AuctionFrame, "TOPRIGHT", "TOPLEFT")
        else
            GameTooltipShow(AuctionFrame, "TOPLEFT", "TOPRIGHT")
        end
        GameTooltip:AddLine("金团拍卖助手(|cffffffff" .. ZL.addonVersion .. "|r)")
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("点击：|cffffffff打开设置窗口|r")
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("温馨提示")
        GameTooltip:AddLine("|cff4080FF拍卖系统是通过插件通信同步数据|r，因API问题，插件通信有严格限制；", 1, 1, 1)
        GameTooltip:AddLine("频繁或传输大数据消息时可能存在通信延迟情况，并非BUG；", 1, 1, 1)
        GameTooltip:AddLine("登录和加载UI时会受到更严格限制，这时建议过2分钟后再使用拍卖功能", 1, 1, 1)
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("如需同时拍卖多个物品，建议使用批量拍卖功能，可极大减少通信资源占用")
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("本插件|cff4080FF团队频道出价|r时，只需ML安装插件即可；但每次出价|cff4080FF进位|r时建议", 1, 1, 1)
        GameTooltip:AddLine("带单位或出完整的价格，如：500直接过渡到1000，|cff4080FF需出价1K或1000或10|r，", 1, 1, 1)
        GameTooltip:AddLine("否则有可能识别错，其他情况都可以正常识别", 1, 1, 1)
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("有条件的话建议全团安装插件或者加载WA端拍卖字符串，支持同时拍卖\n多个物品，提高拍卖效率")
        GameTooltip:Show()
    end)
    settingBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    function ZL.sortRollNumber()
        local rollListArr = {}
        if next(ZL.rollList) then
            for key, value in pairs(ZL.rollList) do
                tinsert(rollListArr, {key, value[1], value[2]})
            end
            -- 自定义排序
            table.sort(rollListArr, function(a, b)
                if a[2] ~= b[2] then
                    return a[2] > b[2]  -- ROLL点数降序
                else
                    return a[3] < b[3]  -- ROLL时间升序
                end
            end)
        end
        return rollListArr
    end
    local sortRollNumber = ZL.sortRollNumber
    function ZL.updateRollGameToolTip(self)
        if not GameTooltip:IsShown() then return end
        GameTooltip:Hide()
        if ZL.rollList and next(ZL.rollList) then
            local posLeft = AuctionFrame:GetLeft()
            local posRight = GetScreenWidth() - AuctionFrame:GetRight()
            if posLeft > posRight then
                GameTooltipShow(AuctionFrame, "TOPRIGHT", "TOPLEFT")
            else
                GameTooltipShow(AuctionFrame, "TOPLEFT", "TOPRIGHT")
            end
        else
            GameTooltipShow(self, "BOTTOM", "TOP")
        end
        if PlayerIsML() then
            GameTooltip:AddLine("提示(" .. ZL.opt.rollCountDown .. "秒)")
        else
            GameTooltip:AddLine("提示")
        end
        if (ZL.rollTimer and (not ZL.rollTimer:IsCancelled())) or (not PlayerIsML()) or (not IsInRaid(1)) then
            GameTooltip:AddLine("左键:|cffffffffROLL|r")
        else
            GameTooltip:AddLine("左键:|cffffffff开始记录ROLL点数|r")
        end
        GameTooltip:AddLine("右键:|cffffffff设置ROLL时长|r")
        if ZL.rollList and next(ZL.rollList) then
            local arr = sortRollNumber()
            GameTooltip:AddDoubleLine("玩家名", "点数")
            for _, data in ipairs(arr) do
                GameTooltip:AddDoubleLine(data[1], data[2], 1, 1, 1, 1, 1, 1)
            end
        end
        GameTooltip:Show()
    end
    AuctionFrame.rollBtn = CreateFrame("Button", nil, AuctionFrame)
    local rollBtn = AuctionFrame.rollBtn
    rollBtn:SetPoint("LEFT", settingBtn, "RIGHT", 8, -1)
    rollBtn:SetSize(18, 18)
    rollBtn:SetNormalTexture(130772)
    rollBtn:SetHighlightTexture(130772)
    rollBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    rollBtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            if (ZL.rollTimer and (not ZL.rollTimer:IsCancelled())) or (not PlayerIsML()) or (not IsInRaid(1)) then
                RandomRoll(1, 100)
            else
                MyAddon:TransmitAddonInfo("AUTOAUC ROLL", {type="start", rollCountDown=ZL.opt.rollCountDown})
            end
        else
            StaticPopup_Show("ZL_ROLLCOUNTDOWN")
        end
    end)
    rollBtn:SetScript("OnEnter", function (self)
        if ZL.rollList and next(ZL.rollList) then
            local posLeft = AuctionFrame:GetLeft()
            local posRight = GetScreenWidth() - AuctionFrame:GetRight()
            if posLeft > posRight then
                GameTooltipShow(AuctionFrame, "TOPRIGHT", "TOPLEFT")
            else
                GameTooltipShow(AuctionFrame, "TOPLEFT", "TOPRIGHT")
            end
        else
            GameTooltipShow(self, "BOTTOM", "TOP")
        end
        if PlayerIsML() then
            GameTooltip:AddLine("提示(" .. ZL.opt.rollCountDown .. "秒)")
        else
            GameTooltip:AddLine("提示")
        end
        if (ZL.rollTimer and (not ZL.rollTimer:IsCancelled())) or (not PlayerIsML()) or (not IsInRaid(1)) then
            GameTooltip:AddLine("左键:|cffffffffROLL|r")
        else
            GameTooltip:AddLine("左键:|cffffffff开始记录ROLL点数|r")
        end
        GameTooltip:AddLine("右键:|cffffffff设置ROLL时长|r")
        if ZL.rollList and next(ZL.rollList) then
            local arr = sortRollNumber()
            GameTooltip:AddDoubleLine("玩家名", "点数")
            for _, data in ipairs(arr) do
                GameTooltip:AddDoubleLine(data[1], data[2], 1, 1, 1, 1, 1, 1)
            end
        end
        GameTooltip:Show()
    end)
    rollBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    AuctionFrame.WowTokenBtn = CreateFrame("Button", nil, AuctionFrame)
    local WowTokenBtn = AuctionFrame.WowTokenBtn
    WowTokenBtn:SetPoint("LEFT", rollBtn, "RIGHT", 8, -1)
    WowTokenBtn:SetSize(18, 18)
    WowTokenBtn:SetNormalTexture(1120721)
    WowTokenBtn:SetHighlightTexture(1120721)
    WowTokenBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        if self.price then
            GameTooltip:AddDoubleLine("当前时光徽章", GetMoneyString(self.price), nil, nil, nil, 1, 1, 1)
            GameTooltip:AddDoubleLine(
                GetMoneyString(10000) .. " ≈ ￥" .. format("%.6f", 900000/self.price) .. "元",
                "￥1元 ≈ " .. GetMoneyString(floor(self.price/90/10000)*10000),
                1, 1, 1, 1, 1, 1
            )
            GameTooltip:AddLine(" ")
            GameTooltip:AddLine("左键点击可手动输入数值相互换算")
        else
            GameTooltip:AddLine("时光徽章不可用")
        end
        GameTooltip:Show()
    end)
    WowTokenBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    WowTokenBtn:SetScript("OnClick", function (self)
        if not self.price then
            ZL.Print("当前时光徽章不可用！", true)
            return
        end
        if not ZL.WowTokenFrame then ZL.CreateWowTokenFrame() end
        ZL.WowTokenFrame:Show()
    end)

    ---时光徽章转换窗口
    function ZL.CreateWowTokenFrame()
        ZL.WowTokenFrame = ZLCreateFrame(nil, ZL, nil, nil, nil, true, true, "时光徽章换算")
        local WowTokenFrame = ZL.WowTokenFrame
        WowTokenFrame:SetSize(300, 130)
        WowTokenFrame:SetScript("OnMouseUp", function (self)
            self:StopMovingOrSizing()
            if not ZL.db.global.ZLWowTokenFrame then ZL.db.global.ZLWowTokenFrame = {} end
            ZL.db.global.ZLWowTokenFrame.point, _, ZL.db.global.ZLWowTokenFrame.relative, ZL.db.global.ZLWowTokenFrame.x, ZL.db.global.ZLWowTokenFrame.y = self:GetPoint()
        end)
        WowTokenFrame:SetScript("OnMouseDown", function (self)
            self:StartMoving()
        end)
        WowTokenFrame.resizeButton:Hide()
        WowTokenFrame:ClearAllPoints()
        if ZL.db.global.ZLWowTokenFrame and ZL.db.global.ZLWowTokenFrame.point then
            WowTokenFrame:SetPoint(ZL.db.global.ZLWowTokenFrame.point, UIParent, ZL.db.global.ZLWowTokenFrame.relative, ZL.db.global.ZLWowTokenFrame.x, ZL.db.global.ZLWowTokenFrame.y)
        else
            WowTokenFrame:SetPoint("CENTER")
        end
        local RMBString = WowTokenFrame:CreateFontString(nil, "OVERLAY")
        RMBString:SetPoint("TOPLEFT", WowTokenFrame.TitleBottom, "BOTTOMLEFT", 5, -10)
        RMBString:SetHeight(20)
        RMBString:SetFont(GameFontNormal:GetFont(), 14)
        RMBString:SetJustifyH("LEFT")
        RMBString:SetText("￥")
        local RMBEditBox = CreateEditBox(WowTokenFrame, 120, 20, 13, "RIGHT", true)
        RMBEditBox:SetPoint("LEFT", RMBString, "RIGHT", 5, 0)
        RMBEditBox:SetMaxLetters(6)
        RMBEditBox:SetScript("OnEnter", function (self)
            GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
            GameTooltip:AddLine("最高6位数字")
            GameTooltip:Show()
        end)
        RMBEditBox:SetScript("OnLeave", function ()
            GameTooltip:Hide()
        end)

        local goldString = WowTokenFrame:CreateFontString(nil, "OVERLAY")
        goldString:SetPoint("LEFT", RMBEditBox, "RIGHT", 5, 0)
        goldString:SetHeight(20)
        goldString:SetFont(GameFontNormal:GetFont(), 14)
        goldString:SetJustifyH("LEFT")
        goldString:SetText(" ≈ " .. GetMoneyString(0))
        RMBEditBox:SetScript("OnTextChanged", function (self)
            local count = self:GetNumber()
            goldString:SetText("元 ≈ " .. GetMoneyString(floor(WowTokenBtn.price*count/90/10000)*10000, true))
        end)
        local goldEditBox = CreateEditBox(WowTokenFrame, 120, 20, 13, "RIGHT", true)
        goldEditBox:SetPoint("TOPLEFT", RMBEditBox, "BOTTOMLEFT", 0, -10)
        goldEditBox:SetMaxLetters(10)
        goldEditBox:SetScript("OnEnter", function (self)
            GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
            GameTooltip:AddLine("最高10位数字")
            GameTooltip:Show()
        end)
        goldEditBox:SetScript("OnLeave", function ()
            GameTooltip:Hide()
        end)
        local RMBString2 = WowTokenFrame:CreateFontString(nil, "OVERLAY")
        RMBString2:SetPoint("LEFT", goldEditBox, "RIGHT", 5, 0)
        RMBString2:SetHeight(20)
        RMBString2:SetFont(GameFontNormal:GetFont(), 14)
        RMBString2:SetJustifyH("LEFT")
        RMBString2:SetText("|A:auctionhouse-icon-coin-gold:0:0|a ≈ ￥")
        goldEditBox:SetScript("OnTextChanged", function (self)
            local count = self:GetNumber()
            RMBString2:SetText("|A:auctionhouse-icon-coin-gold:0:0|a ≈ ￥" .. format("%.2f", count * 900000/WowTokenBtn.price) .. "元")
        end)
        WowTokenFrame:SetScript("OnShow", function (self)
            RMBEditBox:SetText("")
            goldString:SetText(" ≈ " .. GetMoneyString(0))
            goldEditBox:SetText("")
            RMBString2:SetText("|A:auctionhouse-icon-coin-gold:0:0|a ≈ ￥")
        end)
        local sendMsgBtn = CreateButton(nil, WowTokenFrame, "发送到", "BOTTOM", WowTokenFrame, "BOTTOM", 0, 5, 100, 20, 14, true, 0)
        sendMsgBtn:SetScript("OnClick", function (self)
            local RMBCount = RMBEditBox:GetNumber()
            local goldCount = goldEditBox:GetNumber()
            if RMBCount == 0 and goldCount == 0 then
                ZL.Print("请先输入转换数值。", true, true)
                return
            end
            local msg = ""
            if RMBCount > 0 then
                msg = "￥" .. RMBCount .. "元 ≈ " .. floor(WowTokenBtn.price*RMBCount/90/10000) .. "g"
            end
            if goldCount > 0 then
                if msg == "" then
                    msg = goldCount .. "g ≈ ￥"  .. format("%.2f", goldCount * 900000/WowTokenBtn.price) .. "元"
                else
                    msg = msg .. "，" .. goldCount .. "g ≈ ￥"  .. format("%.2f", goldCount * 900000/WowTokenBtn.price) .. "元"
                end
            end
            local menuList = {
                {
                    text = "团队",
                    disabled = not IsInRaid(1),
                    func = function ()
                        SendChatMessage(msg, "RAID")
                    end
                },
                {
                    text = "小队",
                    disabled = not IsInRaid(1) and not IsInGroup(1),
                    func = function ()
                        SendChatMessage(msg, "PARTY")
                    end
                },
                {
                    text = "说",
                    func = function ()
                        SendChatMessage(msg, "SAY")
                    end
                }
            }
            ZL.GUI:ToggleMenu(self, menuList, 'cursor')
        end)
    end

    AuctionFrame.helpBtn = CreateFrame("Button", nil, AuctionFrame)
    local helpBtn = AuctionFrame.helpBtn
    helpBtn:SetPoint("RIGHT", AuctionFrame.closeButton, "LEFT", -5, 0)
    helpBtn:SetSize(14, 14)
    local texture = [[Interface\GossipFrame\ActiveQuestIcon.blp]]
    helpBtn:SetNormalTexture(texture)
    helpBtn:SetHighlightTexture(texture)
    -- helpBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    helpBtn:SetScript("OnEnter", function (self)
        local posLeft = AuctionFrame:GetLeft()
        local posRight = GetScreenWidth() - AuctionFrame:GetRight()
        if posLeft > posRight then
            GameTooltipShow(AuctionFrame, "TOPRIGHT", "TOPLEFT")
        else
            GameTooltipShow(AuctionFrame, "TOPLEFT", "TOPRIGHT")
        end
        GameTooltip:AddLine("点击查看帮助反馈")
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("下面为斜杠快捷命令，可添加到宏里")
        for _, key in ipairs(ZL.commandInfoKeyList) do
            local value = ZL.commandInfo[key]
            if value and value.label then
                if value.key == "" then
                    GameTooltip:AddLine("|cffffaa00/aa|r - " .. value.label, 1, 1, 1)
                else
                    GameTooltip:AddLine("|cffffaa00/aa " .. value.key .. "|r - " .. value.label, 1, 1, 1)
                end
            end
        end
        GameTooltip:Show()
    end)
    helpBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    helpBtn:SetScript("OnClick", function (self)
        ZL.OpenAceConfigDialog("金团拍卖助手", "help")
    end)
    AuctionFrame.QQBtn = CreateFrame("Button", nil, AuctionFrame)
    local QQBtn = AuctionFrame.QQBtn
    QQBtn:SetPoint("RIGHT", helpBtn, "LEFT", 0, 0)
    QQBtn:SetSize(14, 14)
    local texture = [[Interface\AddOns\AutoAuction\Images\qqLogo.png]]
    QQBtn:SetNormalTexture(texture)
    QQBtn:SetHighlightTexture(texture)
    QQBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddLine("作者：潇湘凌风")
        GameTooltip:AddLine("原创插件：")
        GameTooltip:AddLine("正式服：|cffffde00AutoAuction|r[金团拍卖助手AA]", 1, 1, 1)
        GameTooltip:AddLine("时光服：|cffffde00FastAuction|r[拍卖行助手FA]", 1, 1, 1)
        GameTooltip:AddLine("反馈Q群：599711083，点击复制", 1, 1, 1)
        GameTooltip:AddLine(" ", 1, 1, 1)
        GameTooltip:AddLine("插件定制、魔改可加V：|cfffffffflostar_luo|r")
        GameTooltip:Show()
    end)
    QQBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    QQBtn:SetScript("OnClick", function (self)
        ChatEdit_ActivateChat(ChatEdit_ChooseBoxForSend())
        ChatEdit_InsertLink("599711083")
        ChatEdit_ChooseBoxForSend():HighlightText()
    end)

    AuctionFrame.StateFrame = CreateFrame("Frame", nil, AuctionFrame)
    local StateFrame = AuctionFrame.StateFrame
    StateFrame:SetPoint("BOTTOMLEFT", AuctionFrame, "BOTTOMLEFT")
    StateFrame:SetPoint("BOTTOMRIGHT", AuctionFrame, "BOTTOMRIGHT")
    StateFrame:SetHeight(50)
    StateFrame.BorderTop = StateFrame:CreateTexture(nil, "OVERLAY") --BACKGROUND  OVERLAY
    StateFrame.BorderTop:SetColorTexture(1, 1, 1, 0.5)
    StateFrame.BorderTop:SetPoint("TOPLEFT", 0, 1)
    StateFrame.BorderTop:SetPoint("BOTTOMRIGHT", StateFrame, "TOPRIGHT", 0, 0)

    local function StateFrameBtn_Set(self, button)
        local tableId = self:GetID()
        if button == "LeftButton" then
            local btnText = self:GetText()
            ZL.opt.ZLAuctionFrameTabId = tableId
            StateFrame.AllBtn:SetText("全部")
            StateFrame.WaitingBtn:SetText("待拍卖")
            StateFrame.AuctioningBtn:SetText("拍卖中")
            StateFrame.SuccessBtn:SetText("成功")
            StateFrame.FailedBtn:SetText("流拍")
            StateFrame.WaitingTradeBtn:SetText("待交易")
            StateFrame.LgnoreBtn:SetText("忽略")
            StateFrame.ConcernBtn:SetText("关注")
            self:SetText("|cffffffff" .. btnText .. "|r")
            ZL.AuctionListSort()
        else
            if tableId == 1 then
                ZL.GUI:ToggleMenu(self, {
                    {
                        text = "隐藏拍卖中不适合当前专精物品",
                        checkable = 1,
                        isNotRadio = 1,
                        checked = ZL.opt.hideWaitingAuctionCantUseItem,
                        keepShownOnClick = 1,
                        func = function (_, data)
                            ZL.opt.hideWaitingAuctionCantUseItem = data.checked
                            AuctionFrame:Update()
                        end
                    }
                }, 'cursor')
            end
        end
    end
    local function stateCounts()
        local total = 0 --总拍卖数：已经打包的不计算在内
        local waitingCounts = 0 --忽略的和已经打包的不计算在内
        local hideWaitingCounts = 0 --拍卖中的隐藏无法使用的物品个数
        local autioningCounts = 0 --忽略的和已经打包的不计算在内
        local successCounts = 0 --忽略的和已经打包的不计算在内
        local failedCounts = 0 --忽略的和已经打包的不计算在内
        local lgnoreCounts = 0 --已经打包的不计算在内
        local concernCounts = 0 --已经打包的不计算在内
        local packageCounts = 0 --打包物品数
        local tradeCounts = 0 --待交易拍卖数
        local itemId
        local isML = PlayerIsML()
        local selectCharKey = ZL.GetClassColorName() .. " - " .. GetRealmName()
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            for _, data in ipairs(ZL_CURRENT.auctionlist) do
                if data.isPackage then
                    packageCounts = packageCounts + 1
                else
                    total = total + 1
                    if data.lgnore then
                        lgnoreCounts = lgnoreCounts + 1
                    else
                        itemId = data.itemId
                        if ZL.opt.concernList and ZL.opt.concernList[selectCharKey]
                        and ZL.opt.concernList[selectCharKey]["itemList"][itemId] then
                            concernCounts = concernCounts + 1
                        end
                        if data.state == "waiting" then
                            waitingCounts = waitingCounts + 1
                        elseif data.state == "auctioning" then
                            autioningCounts = autioningCounts + 1
                            if ZL.opt.hideWaitingAuctionCantUseItem and not ZL.ItemCanUseBySpec(data.itemlink) then
                                hideWaitingCounts = hideWaitingCounts + 1
                            end
                        elseif data.state == "success" then
                            successCounts = successCounts + 1
                            if isML then
                                local isBreak
                                for _, incomeData in ipairs(ZL_CURRENT.IncomeList) do
                                    if incomeData.tradeId == data.tradeId then
                                        for _, data2 in pairs(incomeData.itemList) do
                                            if not data2.isTraded then
                                                tradeCounts = tradeCounts + 1
                                                isBreak = true
                                                break
                                            end
                                        end
                                        if isBreak then
                                            break
                                        end
                                    end
                                end
                            end
                        elseif data.state == "failed" then
                            failedCounts = failedCounts + 1
                        end
                    end
                end
            end
        end
        return total, waitingCounts, autioningCounts, successCounts, failedCounts, lgnoreCounts, concernCounts, packageCounts, tradeCounts, hideWaitingCounts
    end
    StateFrame.AllBtn = CreateButton("ZL_NewAuctionFrameTab0", StateFrame, "全部", "TOPLEFT", StateFrame, "TOPLEFT", 3, -5, 45, 20, 15)
    local AllBtn = StateFrame.AllBtn
    AllBtn:SetID(0)
    AllBtn:SetScript("OnClick", StateFrameBtn_Set)
    AllBtn:SetScript("OnEnter", function (self)
        local total, waitingCounts, autioningCounts, successCounts, failedCounts, lgnoreCounts, concernCounts, packageCounts, tradeCounts = stateCounts()
        GameTooltipShow(self, "BOTTOM", "TOP")
        -- GameTooltip:AddLine("统计")
        GameTooltip:AddDoubleLine("总计：", total, nil, nil, nil, 1, 1, 1)
        GameTooltip:AddDoubleLine("待拍卖：", waitingCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:AddDoubleLine("拍卖中：", autioningCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:AddDoubleLine("成功：", successCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:AddDoubleLine("流拍：", failedCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:AddDoubleLine("忽略：", lgnoreCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:AddDoubleLine("关注：", concernCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:AddDoubleLine("打包：", packageCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:AddDoubleLine("待交易：", tradeCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:Show()
    end)
    AllBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    StateFrame.WaitingBtn = CreateButton("ZL_NewAuctionFrameTab5", StateFrame, "待拍卖", "LEFT", AllBtn, "RIGHT", 3, 0, 65, 20, 15)
    local WaitingBtn = StateFrame.WaitingBtn
    WaitingBtn:SetID(5)
    WaitingBtn:SetScript("OnClick", StateFrameBtn_Set)
    WaitingBtn:SetScript("OnEnter", function (self)
        local waitingCounts = select(2, stateCounts())
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddDoubleLine("待拍卖：", waitingCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:Show()
    end)
    WaitingBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    StateFrame.AuctioningBtn = CreateButton("ZL_NewAuctionFrameTab1", StateFrame, "拍卖中", "LEFT", WaitingBtn, "RIGHT", 3, 0, 65, 20, 15)
    local AuctioningBtn = StateFrame.AuctioningBtn
    AuctioningBtn:SetID(1)
    AuctioningBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    AuctioningBtn:SetScript("OnClick", StateFrameBtn_Set)
    AuctioningBtn:SetScript("OnEnter", function (self)
        local autioningCounts, _, _, _, _, _, _, hideWaitingCounts = select(3, stateCounts())
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddDoubleLine("拍卖中：", autioningCounts, nil, nil, nil, 1, 1, 1)
        if ZL.opt.hideWaitingAuctionCantUseItem then
            GameTooltip:AddDoubleLine("无法使用已隐藏：", hideWaitingCounts, nil, nil, nil, 1, 1, 1)
        end
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("<右键设置>\n|cffffffff隐藏拍卖中不适合当前专精物品|r")
        GameTooltip:Show()
    end)
    AuctioningBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)
    AuctioningBtn.SpellHighlightTexture = AuctioningBtn:CreateTexture("SpellHighlightTexture1", "OVERLAY", nil, 1)
    local SpellHighlightTexture = AuctioningBtn.SpellHighlightTexture
    SpellHighlightTexture:SetAtlas("bags-newitem")
    SpellHighlightTexture:SetSize(85, 26)
    SpellHighlightTexture:SetPoint("CENTER")
    SpellHighlightTexture:SetBlendMode("ADD")  -- 通常 ADD 模式需要设置 BlendMode

    -- 创建 SpellHighlightAnim 动画组（循环播放）
    AuctioningBtn.SpellHighlightAnim = SpellHighlightTexture:CreateAnimationGroup() --"SpellHighlightAnim"
    local SpellHighlightAnim = AuctioningBtn.SpellHighlightAnim
    SpellHighlightAnim:SetLooping("REPEAT")

    -- 第一个 Alpha 动画（淡入）
    local alpha1 = SpellHighlightAnim:CreateAnimation("Alpha")
    alpha1:SetChildKey("SpellHighlightTexture")
    alpha1:SetSmoothing("OUT")
    alpha1:SetDuration(0.75)
    alpha1:SetOrder(1)
    alpha1:SetFromAlpha(0)
    alpha1:SetToAlpha(1)

    -- 第二个 Alpha 动画（淡出）
    local alpha2 = SpellHighlightAnim:CreateAnimation("Alpha")
    alpha2:SetChildKey("SpellHighlightTexture")
    alpha2:SetSmoothing("IN")
    alpha2:SetDuration(0.75)
    alpha2:SetOrder(2)
    alpha2:SetFromAlpha(1)
    alpha2:SetToAlpha(0)

    StateFrame.SuccessBtn = CreateButton("ZL_NewAuctionFrameTab2", StateFrame, "成功", "LEFT", AuctioningBtn, "RIGHT", 3, 0, 45, 20, 15)
    local SuccessBtn = StateFrame.SuccessBtn
    SuccessBtn:SetID(2)
    SuccessBtn:SetScript("OnClick", StateFrameBtn_Set)
    SuccessBtn:SetScript("OnEnter", function (self)
        local successCounts = select(4, stateCounts())
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddDoubleLine("成功：", successCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:Show()
    end)
    SuccessBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    StateFrame.FailedBtn = CreateButton("ZL_NewAuctionFrameTab3", StateFrame, "流拍", "LEFT", SuccessBtn, "RIGHT", 3, 0, 45, 20, 15)
    local FailedBtn = StateFrame.FailedBtn
    FailedBtn:SetID(3)
    FailedBtn:SetScript("OnClick", StateFrameBtn_Set)
    FailedBtn:SetScript("OnEnter", function (self)
        local failedCounts = select(5, stateCounts())
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddDoubleLine("流拍：", failedCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:Show()
    end)
    FailedBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    StateFrame.WaitingTradeBtn = CreateButton("ZL_NewAuctionFrameTab7", StateFrame, "待交易", "LEFT", FailedBtn, "RIGHT", 3, 0, 65, 20, 15)
    local WaitingTradeBtn = StateFrame.WaitingTradeBtn
    WaitingTradeBtn:SetID(7)
    WaitingTradeBtn:SetScript("OnClick", StateFrameBtn_Set)
    WaitingTradeBtn:SetScript("OnEnter", function (self)
        local tradeCounts = select(9, stateCounts())
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddDoubleLine("待交易：", tradeCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:Show()
    end)
    WaitingTradeBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)
    StateFrame.TksBtn = CreateButton(nil, StateFrame, "鸣谢", "TOPLEFT", WaitingTradeBtn, "BOTTOMLEFT", 0, -3, 65, 20, 15)
    local TksBtn = StateFrame.TksBtn
    TksBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "TOP", "BOTTOM")
        GameTooltip:AddLine("感谢名单(排名不分先后)：")
        GameTooltip:AddLine([[
艾萨拉金团、张大爷dayeKBS、千川魔兽、艾泽拉斯快讯、魔兽世界万花筒、往事丶如风、明月
]], 1, 1, 1, true)
        GameTooltip:AddLine("同时也感谢诸多赞助未留名\n和一直使用、支持本插件的朋友")
        GameTooltip:Show()
    end)
    TksBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    StateFrame.LgnoreBtn = CreateButton("ZL_NewAuctionFrameTab4", StateFrame, "忽略", "TOPLEFT", AllBtn, "BOTTOMLEFT", 0, -3, 45, 20, 15)
    local LgnoreBtn = StateFrame.LgnoreBtn
    LgnoreBtn:SetID(4)
    LgnoreBtn:SetScript("OnClick", StateFrameBtn_Set)
    LgnoreBtn:SetScript("OnEnter", function (self)
        local lgnoreCounts = select(6, stateCounts())
        GameTooltipShow(self, "TOP", "BOTTOM")
        GameTooltip:AddDoubleLine("忽略：", lgnoreCounts, nil, nil, nil, 1, 1, 1)
        GameTooltip:Show()
    end)
    LgnoreBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    StateFrame.levelSortBtn = CreateButton(nil, StateFrame, "装等|cff00ff00↓|r", "LEFT", LgnoreBtn, "RIGHT", 3, 0, 65, 20, 15)
    local levelSortBtn = StateFrame.levelSortBtn
    do
        local BtnName
        if ZL.opt.levelSort == "down" then
            BtnName = "|cffffffff装等↓|r"
        elseif ZL.opt.levelSort == "up" then
            BtnName = "|cffffffff装等↑|r"
        else
            BtnName = "装等"
        end
        levelSortBtn:SetText(BtnName)
    end
    levelSortBtn:SetScript("OnClick", function (self)
        ZL.opt.timeSort = false
        StateFrame.timeSortBtn:SetText("时间")
        if ZL.opt.levelSort == false then
            ZL.opt.levelSort = "down"
            levelSortBtn:SetText("|cffffffff装等↓|r")
        elseif ZL.opt.levelSort == "down" then
            ZL.opt.levelSort = "up"
            levelSortBtn:SetText("|cffffffff装等↑|r")
        else
            ZL.opt.levelSort = "down"
            levelSortBtn:SetText("|cffffffff装等↓|r")
        end
        ZL.AuctionListSort()
        if ZL.opt.levelSort then
            GameTooltipShow(self, "BOTTOM", "TOP")
            if ZL.opt.levelSort == "up" then
                GameTooltip:AddLine("装等高的在|cff00ff00后面|r排序", 1, 1, 1)
            else
                GameTooltip:AddLine("装等高的在|cff00ff00前面|r排序", 1, 1, 1)
            end
            GameTooltip:Show()
        end
    end)
    levelSortBtn:SetScript("OnEnter", function (self)
        if ZL.opt.levelSort then
            GameTooltipShow(self, "TOP", "BOTTOM")
            if ZL.opt.levelSort == "up" then
                GameTooltip:AddLine("装等高的在|cff00ff00后面|r", 1, 1, 1)
            else
                GameTooltip:AddLine("装等高的在|cff00ff00前面|r", 1, 1, 1)
            end
            GameTooltip:Show()
        end
    end)
    levelSortBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)

    StateFrame.timeSortBtn = CreateButton(nil, StateFrame, "时间↑", "LEFT", levelSortBtn, "RIGHT", 3, 0, 65, 20, 15)
    local timeSortBtn = StateFrame.timeSortBtn
    do
        local BtnName
        if ZL.opt.timeSort == "down" then
            BtnName = "|cffffffff时间↓|r"
        elseif ZL.opt.timeSort == "up" then
            BtnName = "|cffffffff时间↑|r"
        else
            BtnName = "时间"
        end
        timeSortBtn:SetText(BtnName)
    end
    timeSortBtn:SetScript("OnClick", function (self)
        ZL.opt.levelSort = false
        levelSortBtn:SetText("装等")
        if ZL.opt.timeSort == false then
            ZL.opt.timeSort = "up"
            timeSortBtn:SetText("|cffffffff时间↑|r")
        elseif ZL.opt.timeSort == "down" then
            ZL.opt.timeSort = "up"
            timeSortBtn:SetText("|cffffffff时间↑|r")
        else
            ZL.opt.timeSort = "down"
            timeSortBtn:SetText("|cffffffff时间↓|r")
        end
        ZL.AuctionListSort()
        if ZL.opt.timeSort then
            GameTooltipShow(self, "BOTTOM", "TOP")
            if ZL.opt.timeSort == "up" then
                GameTooltip:AddLine("新创建的在|cff00ff00后面|r排序", 1, 1, 1)
            else
                GameTooltip:AddLine("新创建的在|cff00ff00前面|r排序", 1, 1, 1)
            end
            GameTooltip:Show()
        end
    end)
    timeSortBtn:SetScript("OnEnter", function (self)
        if ZL.opt.timeSort then
            GameTooltipShow(self, "TOP", "BOTTOM")
            if ZL.opt.timeSort == "up" then
                GameTooltip:AddLine("新创建的在|cff00ff00后面|r", 1, 1, 1)
            else
                GameTooltip:AddLine("新创建的在|cff00ff00前面|r", 1, 1, 1)
            end
            GameTooltip:Show()
        end
    end)
    timeSortBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)

    StateFrame.ConcernBtn = CreateButton("ZL_NewAuctionFrameTab6", StateFrame, "关注", "LEFT", timeSortBtn, "RIGHT", 3, 0, 45, 20, 15)
    local ConcernBtn = StateFrame.ConcernBtn
    ConcernBtn:SetID(6)
    ConcernBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    ConcernBtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            StateFrameBtn_Set(self)
        else
            ZL.ConcernFrame:Show()
        end
    end)
    ConcernBtn:SetScript("OnEnter", function (self)
        local concernCounts = select(7, stateCounts())
        GameTooltipShow(self, "TOP", "BOTTOM")
        GameTooltip:AddLine("关注：|cffffffff" .. concernCounts .. "|r")
        GameTooltip:AddLine("右键：|cffffffff打开关注物品窗口|r")
        GameTooltip:Show()
    end)
    ConcernBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    StateFrame.BillBtn = CreateButton(nil, StateFrame, "|cff00aaff账单|r", "LEFT", ConcernBtn, "RIGHT", 3, 0, 45, 20, 15)  --"|cff00aaff账单|r"
    local BillBtn = StateFrame.BillBtn
    BillBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    BillBtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            if IsShiftKeyDown() then
                ZL.OverviewFrame:Hide()
                ZL.ReconciliationFrame:Show()
            else
                ZL.ReconciliationFrame:Hide()
                ZL.OverviewFrame:Update(ZL_CURRENT)
                ZL.OverviewFrame:Show()

                -- ZL.BillOverviewFrame:Update()
                -- ZL.BillOverviewFrame:Show()
            end
        elseif button == "RightButton" then
            ZL.ReconciliationFrame:Hide()
            ZL.OverviewFrame:Update(ZL_PLAYERLIST.lootList)
            ZL.OverviewFrame:Show()
        end
    end)
    BillBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "TOP", "BOTTOM")
        GameTooltip:AddLine("提示")
        GameTooltip:AddLine("左键：|cffffffff拍卖账单|r")
        GameTooltip:AddLine("右键：|cffffffff拾取记录|r")
        GameTooltip:AddLine("Shift+左键：|cffffffff对账单|r")
        if not PlayerIsML() then
            GameTooltip:AddLine("注意", 1, 0, 0)
            GameTooltip:AddLine("拍卖账单数据可能存在延迟", 1, 1, 1)
        end
        GameTooltip:Show()
    end)
    BillBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    --创建滚动条
    AuctionFrame.scrollFrame = CreateFrame("ScrollFrame", nil, AuctionFrame, "UIPanelScrollFrameTemplate")
    AuctionFrame.scrollFrame:SetFrameLevel(AuctionFrame:GetFrameLevel() + 1) -- 设置为比父框架高1级
    AuctionFrame.scrollFrame:SetPoint("TOPLEFT", iconHeaderBtn, "BOTTOMLEFT", -2, 0)
    AuctionFrame.scrollFrame:SetPoint("BOTTOMRIGHT", StateFrame, "TOPRIGHT", 0, 0)
    AuctionFrame.scrollFrame:SetClipsChildren(true) --必须设置为true，scrollFrame所有的子元素才会被剪切
    AuctionFrame.scrollFrame:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel) --重设滑动条鼠标滚轮事件
    --重设ScrollBar位置，放置到scrollFrame内，防止被剪切掉
    AuctionFrame.scrollFrame.ScrollBar:ClearAllPoints()
    AuctionFrame.scrollFrame.ScrollBar:SetPoint("TOPLEFT", startbidHeaderBtn, "BOTTOMRIGHT", 0, -18)
    AuctionFrame.scrollFrame.ScrollBar:SetPoint("BOTTOMRIGHT", AuctionFrame.scrollFrame, "BOTTOMRIGHT", 0, 15)
    AuctionFrame.scrollFrame.content = CreateFrame("Frame", nil, AuctionFrame.scrollFrame)
    local content = AuctionFrame.scrollFrame.content
    content:SetPoint("TOPLEFT", AuctionFrame.scrollFrame, "TOPLEFT", 0, 0)
    AuctionFrame.scrollFrame:SetScrollChild(content)
    --动态调整滚动框架中的子框架
    content:SetSize(AuctionFrame.scrollFrame:GetWidth()-AuctionFrame.scrollFrame.ScrollBar:GetWidth(), 500)
    local infoColumnWidth, bidderColumnWidth, startbidColumnWidth = iconHeaderBtn:GetWidth(), 130, startbidHeaderBtn:GetWidth()
    local function zlHighlightOnShow(v)
        local Frame1 = AuctionFrame.entries[v]
        Frame1.zlHighlight:Show()
    end
    local function zlHighlightOnHide(v)
        local Frame1 = AuctionFrame.entries[v]
        Frame1.zlHighlight:Hide()
        -- if (not Frame1:IsMouseOver()) and (not ZL.FloatAuctionFrame:IsMouseOver()) then
        --     Frame1.zlHighlight:Hide()
        -- end
    end
    function ZL.startOrCanelAuction(v, quickFailed, notCancel)
        local Frame1 = AuctionFrame.entries[v]
        if ZL.syncAll or Frame1.sync then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        local CancelBtn = Frame1.MLframe.functionFrame.CancelBtn
        if not CancelBtn:IsEnabled() then return end
        if IsInRaid(1) then
            local curAuctionList = ZL_CURRENT.auctionlist[v]
            if curAuctionList.state == "auctioning" then
                if (not notCancel) then
                    local data = {
                        type = "取消拍卖",
                        data2 = {itemlink=curAuctionList.itemlink, itemindex=curAuctionList.itemindex},
                        -- globalConfigData = ZL.globalConfigData(),
                    }
                    MyAddon:TransmitAddonInfo("AUTOAUC SYNC2", data)
                    Frame1.sync = true
                    CancelBtn:Disable()
                    C_Timer.After(10, function ()
                        Frame1.sync = nil
                        CancelBtn:Enable()
                    end)
                end
            else
                if (not quickFailed) and (not ZL_CURRENT.globalConfig.allowMultipleAuctions) and (GetAuctioningCount() > 0 )then
                    local link = format("|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "设置多拍", "设置多拍")
                    ZL.Print("当前为单拍模式，不允许同时拍卖多个物品！" .. link, true)
                    return
                end
                local isExist = false --判断是否有相同物品正在拍卖中
                if ZL_CURRENT.auctionlist then
                    for _, data in ipairs(ZL_CURRENT.auctionlist) do
                        if (data.index ~= v) and (data.itemId == curAuctionList.itemId) and (data.state == "auctioning") then
                            isExist = true
                            break
                        end
                    end
                end
                if isExist then
                    local msgStr = "已有相同的物品正在拍卖，无法同时进行！"
                    ZL.Print(msgStr)
                else
                    ZL.GetLootItemGUID()
                    -- local msgStr = ""
                    -- if not ZL.IsCanAuction(curAuctionList) then
                    --     msgStr = curAuctionList.itemlink .. "无法拍卖，原因可能是：物品不存在或已无法交易"
                    --     -- SendChatMessage(msgStr, ZL.MsgChannel())
                    --     ZL.Print(msgStr)
                    --     return
                    -- end
                    --如果是流拍的物品重新拍卖，检测流拍物品是否在流拍包里，如果在移动到其他包里
                    if curAuctionList.state == "failed" and ZL.opt.liupaiToggle and curAuctionList["spawnUID"] and next(curAuctionList["spawnUID"], nil) then
                        local itemList = {}
                        for _, value in pairs(curAuctionList["spawnUID"]) do
                            if value["itemGUID"] and next(value["itemGUID"], nil) then
                                for key, _ in pairs(value["itemGUID"]) do
                                    local bagID, slotIndex = ZL.FindItemInBag(key)
                                    if bagID and (bagID == ZL.opt.liupaiBagId or bagID == ZL.opt.liupaiBagId2) then
                                        --从第一个背包开始查询空闲的格子，如果不是流拍背包，也不是自己拍到的背包，则放进去
                                        local targetBagID, targetslotIndex
                                        local currentInfo
                                        for _bagID = 0, NUM_BAG_SLOTS do
                                            if _bagID ~= ZL.opt.liupaiBagId and (ZL.opt.selfToggle and _bagID ~= ZL.opt.selfBagId) then
                                                for _slotIndex = 1, C_Container.GetContainerNumSlots(_bagID) do
                                                    currentInfo = C_Container.GetContainerItemInfo(_bagID, _slotIndex)
                                                    if not currentInfo then
                                                        targetBagID = _bagID
                                                        targetslotIndex = _slotIndex
                                                        break
                                                    end
                                                end
                                            end
                                        end
                                        currentInfo = nil
                                        if targetBagID then
                                            tinsert(itemList, {
                                                bagID = bagID, slotIndex = slotIndex,
                                                targetBagID = targetBagID, targetslotIndex = targetslotIndex,
                                            })
                                        end
                                    end
                                end
                            end
                        end

                        if #itemList > 0 then
                            local index = 1
                            local function linshi()
                                if index <= #itemList then
                                    if not (InCombatLockdown() or UnitIsDeadOrGhost("player")) then
                                        C_Container.PickupContainerItem(itemList[index]["bagID"], itemList[index]["slotIndex"])
                                        C_Container.PickupContainerItem(itemList[index]["targetBagID"], itemList[index]["targetslotIndex"])
                                        index = index + 1
                                        C_Timer.After(1, linshi)
                                    else
                                        C_Timer.After(0.2, linshi)
                                    end
                                end
                            end
                            linshi()
                        end
                    end
                    local isRestart = curAuctionList.state
                    local tradeId = curAuctionList.tradeId
                    local data = {
                        type = "开始拍卖",
                        quickFailed = quickFailed,
                        isRestart = isRestart,
                        tradeId = tradeId,
                        data2 = ZL_CURRENT.auctionlist[v],
                        syncIndex = v,
                        globalConfigData = ZL.globalConfigData(),
                    }
                    if isRestart == "success" then
                        if not StaticPopupDialogs["ZL_STARTAUCTIONCONFIRM"] then
                            StaticPopupDialogs["ZL_STARTAUCTIONCONFIRM"] = {
                                text = "%s",
                                button1 = "重拍",
                                button2 = "取消",
                                whileDead = 1,
                                showAlert = 1,
                                hideOnEscape = 1,
                                OnAccept = function(self, _data)
                                    local _Frame1 = AuctionFrame.entries[_data.syncIndex]
                                    local _CancelBtn = _Frame1.MLframe.functionFrame.CancelBtn
                                    MyAddon:TransmitAddonInfo("AUTOAUC SYNC1", _data)
                                    _Frame1.sync = true
                                    _CancelBtn:Disable()
                                    C_Timer.After(10, function ()
                                        _Frame1.sync = nil
                                        _CancelBtn:Enable()
                                    end)
                                end,
                                OnCancel = function(self)
                                end,
                            }
                        end
                        StaticPopup_Show("ZL_STARTAUCTIONCONFIRM",
                            format("%s已拍卖成功，确认重拍？", curAuctionList.itemlink), nil, data)
                    else
                        MyAddon:TransmitAddonInfo("AUTOAUC SYNC1", data)
                        Frame1.sync = true
                        CancelBtn:Disable()
                        C_Timer.After(10, function ()
                            Frame1.sync = nil
                            CancelBtn:Enable()
                        end)
                    end

                end
            end
        else
            local msgStr = "团队模式才能进行拍卖行为！"
            ZL.Print(msgStr)
        end
    end
    local startOrCanelAuction = ZL.startOrCanelAuction
    function ZL.quickStartAuction(v)
        if IsInRaid(1) then
            if ZL_CURRENT.auctionlist[v].state == "waiting" or ZL_CURRENT.auctionlist[v].state == "failed" then
                local data = {
                    ["type"] = "指定人员",
                    ["index"] = v,
                }
                StaticPopup_Show("ZL_ADDINCOME", "收入", nil, data, ZL.AddIncomeEditboxs)
            end
        else
            local msgStr = "团队模式才能进行拍卖相关行为！"
            ZL.Print(msgStr)
        end
    end
    local quickStartAuction = ZL.quickStartAuction
    function ZL.pauseOrResumeAuction(v)
        local curAuctionList = ZL_CURRENT.auctionlist[v]
        if curAuctionList.state ~= "auctioning" then
            ZL.Print(curAuctionList.itemlink .. "未拍卖！")
            return
        end
        local Frame1 = AuctionFrame.entries[v]
        if ZL.syncAll or Frame1.sync then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        local CancelBtn = Frame1.MLframe.functionFrame.CancelBtn
        if not CancelBtn:IsEnabled() then return end
        
        local dateType
        if not curAuctionList.isPaused then
            dateType = "暂停拍卖"
        else
            dateType = "继续拍卖"
        end
        local data = {
            type = dateType,
            data2 = {itemlink=curAuctionList.itemlink, itemindex=curAuctionList.itemindex},
            -- globalConfigData = ZL.globalConfigData(),
        }
        MyAddon:TransmitAddonInfo("AUTOAUC SYNC3", data)
        Frame1.sync = true
        CancelBtn:Disable()
        C_Timer.After(10, function ()
            Frame1.sync = nil
            CancelBtn:Enable()
        end)
    end
    local pauseOrResumeAuction = ZL.pauseOrResumeAuction
    function ZL.packageAuction(v)
        local Frame1 = AuctionFrame.entries[v]
        if ZL.syncAll or Frame1.sync then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        local currentAuctionList = ZL_CURRENT.auctionlist[v]
        local itemlink = currentAuctionList.itemlink
        --拾取绑定的物品加入到打包里面，警告提醒
        if currentAuctionList.bindType == 1 then
            local msgStr = itemlink .. "为|cff00ff00拾取绑定|r物品，确认加入到打包拍卖里？"
            StaticPopup_Show("ZL_ISPACKAGE", msgStr, nil, v)
        else
            ZL.AddToPackage(v)
        end
    end
    local packageAuction = ZL.packageAuction
    function ZL.syncAuction(v)
        local Frame1 = AuctionFrame.entries[v]
        if ZL.syncAll or Frame1.sync then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        local syncBtn = Frame1.MLframe.functionFrame.syncBtn
        if not syncBtn:IsEnabled() then return end
        local data = {
            type = "同步单个",
            data2 = ZL_CURRENT.auctionlist[v],
            globalConfigData = ZL.globalConfigData(),
        }
        MyAddon:TransmitAddonInfo("AUTOAUC SYNC13", data)
        Frame1.sync = true
        syncBtn:Disable()
        C_Timer.After(10, function ()
            Frame1.sync = nil
            syncBtn:Enable()
        end)
    end
    local syncAuction = ZL.syncAuction
    function ZL.sendAuctionInfo(v)
        local Frame1 = AuctionFrame.entries[v]
        if ZL.syncAll or Frame1.sync then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        local syncBtn = Frame1.MLframe.functionFrame.syncBtn
        if not syncBtn:IsEnabled() then return end
        local auction = ZL_CURRENT.auctionlist[v]
        local data = {
            type = "竞拍信息",
            data2 = {itemlink=auction.itemlink, itemindex=auction.itemindex},
            -- globalConfigData = ZL.globalConfigData(),
        }
        MyAddon:TransmitAddonInfo("AUTOAUC SYNC4", data)
        Frame1.sync = true
        syncBtn:Disable()
        C_Timer.After(10, function ()
            Frame1.sync = nil
            syncBtn:Enable()
        end)
    end
    local sendAuctionInfo = ZL.sendAuctionInfo
    function ZL.revokeBidAmount(v)
        if ZL_CURRENT.globalConfig.auctionMode == "|cffff0000匿名|r" then
            ZL.Print("|cffff0000匿名|r模式不支持撤销出价。")
            return
        end
        local syncBtn = AuctionFrame.entries[v].MLframe.functionFrame.syncBtn
        if not syncBtn:IsEnabled() then return end
        local curAuctionList = ZL_CURRENT.auctionlist[v]
        if curAuctionList.state ~= "auctioning" then
            ZL.Print("不在拍卖中，无法撤销第一名出价，请使用右键修改出价功能！")
            return
        end
        local bidderlist = curAuctionList.bidderlist
        if bidderlist and #bidderlist > 0 then
            MyAddon:TransmitAddonInfo("AUTOAUC REVOKE", {
                itemlink=curAuctionList.itemlink, itemindex=curAuctionList.itemindex, playerName=bidderlist[1].bidder
            })
            -- ZL.Print("发送数据中，请稍等...")
            syncBtn:Disable()
            C_Timer.After(10, function ()
                syncBtn:Enable()
            end)
        else
            ZL.Print("没有人出价。")
        end
    end
    local revokeBidAmount = ZL.revokeBidAmount
    local function modifyBidRecord(v)
        if ZL_CURRENT.globalConfig.auctionMode == "|cffff0000匿名|r" then
            ZL.Print("|cffff0000匿名|r模式不支持修改出价记录。")
            return
        end
        if not ZL_CURRENT.auctionlist[v].bidderlist or #ZL_CURRENT.auctionlist[v].bidderlist == 0 then
            ZL.Print("没有人出价。")
            return
        end
        ZL.BidderListFrame.index = v
        local BidderListFrame = ZL.BidderListFrame
        local Frame1 = AuctionFrame.entries[v]
        BidderListFrame:ClearAllPoints()
        BidderListFrame:SetPoint("TOPRIGHT", Frame1.bidderFrame, "TOPRIGHT", 0, 0)
        BidderListFrame:Show()
        BidderListFrame:Update(v)
    end
    function ZL.coundownAuction(v)
        local curAuctionList = ZL_CURRENT.auctionlist[v]
        if curAuctionList.state ~= "auctioning" then
            ZL.Print(curAuctionList.itemlink .. "未拍卖！")
            return
        end
        local Frame1 = AuctionFrame.entries[v]
        if ZL.syncAll or Frame1.sync then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        local CountDownBtn = Frame1.MLframe.functionFrame.CountDownBtn
        if not CountDownBtn:IsEnabled() then return end
        local data = {
            type = "手动倒数",
            data2 = {itemlink=curAuctionList.itemlink, itemindex=curAuctionList.itemindex},
            -- globalConfigData = ZL.globalConfigData(),
        }
        MyAddon:TransmitAddonInfo("AUTOAUC SYNC5", data)
        Frame1.sync = true
        CountDownBtn:Disable()
        C_Timer.After(10, function ()
            Frame1.sync = nil
            CountDownBtn:Enable()
        end)
    end
    local coundownAuction = ZL.coundownAuction
    function ZL.resetAuctionTime(v)
        local curAuctionList = ZL_CURRENT.auctionlist[v]
        if curAuctionList.state ~= "auctioning" then
            ZL.Print(curAuctionList.itemlink .. "未拍卖！")
            return
        end
        local Frame1 = AuctionFrame.entries[v]
        if ZL.syncAll or Frame1.sync then
            ZL.Print("通信被占用，请稍后重试。")
            return
        end
        if (curAuctionList.endTime or 0) - time() > (ZL_CURRENT.globalConfig.auctionTimerRefresh or 0) then
            ZL.Print("当前剩余时间大于重置时间，无需重置！")
            return
        end
        local CountDownBtn = Frame1.MLframe.functionFrame.CountDownBtn
        if not CountDownBtn:IsEnabled() then return end
        --取消倒数，重置拍卖时间
        if (((curAuctionList.endTime or 0) - time() > 0) or curAuctionList.isPaused) then
            local data = {
                type = "取消倒数",
                data2 = {itemlink=curAuctionList.itemlink, itemindex=curAuctionList.itemindex},
                resetAuctionTimeTimer = curAuctionList.endTime,
                -- globalConfigData = ZL.globalConfigData(),
            }
            MyAddon:TransmitAddonInfo("AUTOAUC SYNC5", data)
            Frame1.sync = true
            CountDownBtn:Disable()
            C_Timer.After(10, function ()
                Frame1.sync = nil
                CountDownBtn:Enable()
            end)
        end
    end
    local resetAuctionTime = ZL.resetAuctionTime
    local function concernItem(itemId)
        local selectCharKey = ZL.GetClassColorName() .. " - " .. GetRealmName()
        if (not ZL.opt.concernList) or (not ZL.opt.concernList[selectCharKey]) or
        (not ZL.opt.concernList[selectCharKey]["itemList"][itemId]) then
            ZL.addItem(itemId)
        else
            ZL.deleteItem(itemId)
        end
    end

    AuctionFrame.entries = setmetatable({}, {
        __index = function (t, v)
            local Frame1 = CreateFrame("Button", nil, content)
            Frame1:Hide()
            Frame1.maxAutoBid = nil
            Frame1:SetScript("OnEnter", function (self)
                zlHighlightOnShow(v)
            end)
            Frame1:SetScript("OnLeave", function (self)
                zlHighlightOnHide(v)
            end)
            if v > 1 then
                Frame1:SetPoint("TOPLEFT", t[v - 1], "BOTTOMLEFT", 0, -1)
                Frame1:SetPoint("BOTTOMRIGHT", t[v - 1], "BOTTOMRIGHT", 0, -71)
            else
                Frame1:SetPoint("TOPLEFT", content, "TOPLEFT", 3, -1)
                Frame1:SetPoint("BOTTOMRIGHT", content, "TOPRIGHT", -1, -71)
            end

            ZL.CreateBorder(Frame1, 1, 1, 1, 0.5, "OVERLAY")
            Frame1.auctioningFrame = CreateFrame("Frame", nil, Frame1)
            local auctioningFrame = Frame1.auctioningFrame
            auctioningFrame:SetAllPoints()
            ZL.CreateBorder(auctioningFrame, 0, 1, 0, 1, "OVERLAY")
            auctioningFrame:Hide()
            do
                local texture = Frame1:CreateTexture(nil, "BACKGROUND")
                texture:SetColorTexture(1, 0.82, 0, 0.2)
                texture:SetPoint("TOPLEFT")
                texture:SetPoint("BOTTOMRIGHT")
                texture:SetBlendMode("ADD")
                Frame1.zlHighlight = texture
                Frame1.zlHighlight:Hide()
            end

            Frame1.Background = Frame1:CreateTexture(nil,"BACKGROUND")
            Frame1.Background:SetPoint("TOPLEFT")
            Frame1.Background:SetPoint("BOTTOMRIGHT")
            if v%2 == 0 then
                Frame1.Background:SetColorTexture(0, 0, 0, .8)
            else
                Frame1.Background:SetColorTexture(0.15, 0.15, 0.15, .8)
            end
            Frame1.infoFrame = CreateFrame("Frame", nil, Frame1)
            local infoFrame = Frame1.infoFrame
            infoFrame:SetPoint("TOPLEFT")
            infoFrame.timerBtn = CreateFrame("Button", nil, infoFrame)
            local timerBtn = infoFrame.timerBtn
            timerBtn:SetSize(40, 40)
            timerBtn:SetPoint("TOPLEFT", Frame1, "TOPLEFT", 2, -3)
            timerBtn:SetScript("OnEnter", function (self)
                zlHighlightOnShow(v)
                local itemlink = ZL_CURRENT.auctionlist[v].itemlink
                if itemlink == "[打包拍卖]" then
                    ZL.PackageListFrame.index = v
                    local itemList = ZL_CURRENT.auctionlist[v]["itemList"]
                    if itemList and next(itemList, nil) then
                        ZL.PackageListFrame:Update(v)
                        ZL.PackageListFrame.OnShow()
                    else
                        GameTooltip:AddLine("没有打包拍卖物品", 1, 1, 1)
                    end
                else
                    local uiScale, x, y = UIParent:GetEffectiveScale(), GetCursorPosition()
                    x, y = x/uiScale, y/uiScale
                    local screenWidth = GetScreenWidth() / 2
                    ZL.OnEnterBagHighLight(v)
                    if x < screenWidth then
                        GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT", 5)
                    else
                        GameTooltipShow(self, "TOPRIGHT", "TOPLEFT", -5)
                    end
                    GameTooltip:SetHyperlink(itemlink)
                    GameTooltip:Show()
                    if _G["ShoppingTooltip1"] and _G["ShoppingTooltip1"]:IsShown() then
                        _G["ShoppingTooltip1"]:ClearAllPoints()
                        if x < screenWidth then
                            _G["ShoppingTooltip1"]:SetPoint("TOPLEFT", GameTooltip, "TOPRIGHT", 0, 0)
                        else
                            _G["ShoppingTooltip1"]:SetPoint("TOPRIGHT", GameTooltip, "TOPLEFT", 0, 0)
                        end
                    end
                    if _G["ShoppingTooltip2"] and _G["ShoppingTooltip2"]:IsShown() then
                        _G["ShoppingTooltip2"]:ClearAllPoints()
                        if x < screenWidth then
                            _G["ShoppingTooltip2"]:SetPoint("TOPLEFT", _G["ShoppingTooltip1"], "TOPRIGHT", 0, 0)
                        else
                            _G["ShoppingTooltip2"]:SetPoint("TOPRIGHT", _G["ShoppingTooltip1"], "TOPLEFT", 0, 0)
                        end
                    end
                end
            end)
            timerBtn:SetScript("OnLeave", function (self)
                zlHighlightOnHide(v)
                GameTooltip:Hide()

                if ZL.PackageListFrame and ZL.PackageListFrame.time and (not ZL.PackageListFrame.time:IsCancelled()) then
                    ZL.PackageListFrame.time:Cancel()
                end
                if ZL.PackageListFrame:IsShown() then
                    ZL.PackageListFrame.time = C_Timer.NewTimer(0.01, function (self)
                        ZL.PackageListFrame.OnHide(timerBtn)
                    end)
                end
            end)
            timerBtn:SetScript("OnClick", function (self, button)
                local auctionlist = ZL_CURRENT.auctionlist[v]
                if _G["TradeFrame"]:IsShown() then
                    local itemList = {}
                    for _, data1 in pairs(auctionlist.spawnUID) do
                        for itemGuid in pairs(data1.itemGUID) do
                            local bagID, slotIndex = ZL.FindItemInBag(itemGuid)
                            if bagID and slotIndex then
                                tinsert(itemList, {bagID, slotIndex})
                            end
                        end
                    end
                    if #itemList > 0 then
                        local function PickupContainerItemToTrade(ibag, islot)
                            C_Container.PickupContainerItem(ibag, islot)
                            for i = 1, 6 do
                                local name = GetTradePlayerItemInfo(i)
                                if (not name) then
                                    ClickTradeButton(i)
                                    break
                                end
                            end
                        end
                        local index = 1
                        local function linshi()
                            if index <= #itemList then
                                PickupContainerItemToTrade(itemList[index][1], itemList[index][2])
                                index = index + 1
                                C_Timer.After(0.3, linshi)
                            end
                        end
                        linshi()
                    else
                        ZL.Print(format("背包没有%s", auctionlist.itemlink))
                    end
                else
                    HandleModifiedItemClick(auctionlist.itemlink)
                end
            end)
            timerBtn:SetScript("OnDoubleClick", function (self, button)
                local itemId = ZL_CURRENT.auctionlist[v].itemId
                concernItem(itemId)
            end)
            timerBtn.icon = timerBtn:CreateTexture(nil, "OVERLAY")
            local icon = timerBtn.icon
            icon:SetAllPoints(timerBtn)
            -- icon:SetTexture(cGetItemIcon(itemId))
            timerBtn.itemNumbersIcon = timerBtn:CreateTexture(nil, "OVERLAY", nil, 7)
            local itemNumbersIcon = timerBtn.itemNumbersIcon
            itemNumbersIcon:SetSize(20, 20)
            itemNumbersIcon:SetPoint("TOPLEFT", timerBtn, "TOPLEFT")
            do
                timerBtn.concern = timerBtn:CreateTexture(nil, "OVERLAY", nil, 7)
                local concern = timerBtn.concern
                concern:SetPoint("CENTER")
                concern:SetHeight(13)
                concern:SetWidth(13)
                concern:SetAtlas("auctionhouse-icon-favorite")
                concern:Hide()
            end

            timerBtn.level = timerBtn:CreateFontString(nil, "OVERLAY")
            timerBtn.level:SetPoint("BOTTOMRIGHT", timerBtn, "BOTTOMRIGHT", -2, -2)
            timerBtn.level:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
            timerBtn.level:SetWordWrap(false)
            timerBtn.level:SetHeight(18)
            timerBtn.level:SetJustifyH("RIGHT")
            timerBtn.level:SetTextColor(0.95, 0.95, 0.95, 1)

            timerBtn.itemindex = timerBtn:CreateFontString(nil, "OVERLAY")
            timerBtn.itemindex:SetPoint("BOTTOMLEFT", timerBtn, "BOTTOMLEFT", 2, -2)
            timerBtn.itemindex:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
            timerBtn.itemindex:SetWordWrap(false)
            timerBtn.itemindex:SetHeight(18)
            timerBtn.itemindex:SetJustifyH("RIGHT")
            timerBtn.itemindex:SetTextColor(0.95, 0.95, 0.95, 1)

            timerBtn.count = timerBtn:CreateFontString(nil, "OVERLAY")
            timerBtn.count:SetPoint("TOPRIGHT", timerBtn, "TOPRIGHT", -2, 0)
            timerBtn.count:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
            timerBtn.count:SetWordWrap(false)
            timerBtn.count:SetHeight(18)
            timerBtn.count:SetJustifyH("LEFT")
            timerBtn.count:SetTextColor(0.95, 0.95, 0.95, 1)
        
            infoFrame.itemName = infoFrame:CreateFontString(nil, "OVERLAY")
            infoFrame.itemName:SetPoint("TOPLEFT", timerBtn, "TOPRIGHT", 2, 1)
            infoFrame.itemName:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            infoFrame.itemName:SetWordWrap(false)
            infoFrame.itemName:SetSize(120, 20) --93
            infoFrame.itemName:SetJustifyH("LEFT")

            infoFrame.sb = CreateFrame("StatusBar", nil, Frame1) --infoFrame
            local sb = infoFrame.sb
            -- sb:SetPoint("TOPLEFT", infoFrame.itemName, "BOTTOMLEFT", 0, -1)
            -- sb:SetPoint("BOTTOMRIGHT", infoFrame.itemName, "BOTTOMRIGHT", 8, -20)
            -- ZL.CreateBorder(sb, 1, 1, 1, 1, "OVERLAY", 1)
            do
                local texture = sb:CreateTexture(nil,"BACKGROUND")
                texture:SetColorTexture(1, 1, 1, 1)
                texture:SetPoint("TOPLEFT")
                texture:SetPoint("BOTTOMRIGHT")
                sb:SetStatusBarTexture(texture)
            end
            sb:SetStatusBarColor(0.68, 0.87, 0.68)
            sb:SetScript("OnMouseDown", function (self, button)
                if button == "LeftButton" and IsShiftKeyDown() then
                    resetAuctionTime(v)
                end
            end)
            sb:SetScript("OnEnter", function (self)
                zlHighlightOnShow(v)
                GameTooltipShowAnchor(self)
                GameTooltip:AddLine("进度条")
                GameTooltip:AddLine("Shift+左键：|cffffffff重置倒计时|r")
                GameTooltip:Show()
            end)
            sb:SetScript("OnLeave", function ()
                zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            sb.timeString = sb:CreateFontString(nil, "OVERLAY")
            local timeString = sb.timeString
            timeString:SetPoint("RIGHT", sb, "RIGHT", -2, 0)
            timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            timeString:SetWordWrap(false)
            timeString:SetJustifyH("RIGHT")
            timeString:SetTextColor(0.95, 0.95, 0.95, 1)

            sb.buweiString = sb:CreateFontString(nil, "OVERLAY")
            local buweiString = sb.buweiString
            buweiString:SetPoint("LEFT", sb, "LEFT", 44, 0)
            buweiString:SetWidth(50)
            buweiString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            buweiString:SetWordWrap(false)
            buweiString:SetJustifyH("LEFT")
            buweiString:SetTextColor(0.95, 0.95, 0.95, 1)
            infoFrame:SetSize(15+timerBtn:GetWidth()+infoFrame.itemName:GetWidth(), Frame1:GetHeight()-24)
            infoFrame.checkBtn = CreateFrame("CheckButton", nil, infoFrame, "ChatConfigCheckButtonTemplate")
            infoFrame.checkBtn:SetPoint("TOPRIGHT", infoFrame, "TOPRIGHT")
            infoFrame.checkBtn:SetSize(15, 15)
            infoFrame.checkBtn.Text:SetText("")
            infoFrame.checkBtn:SetHitRectInsets(0, -infoFrame.checkBtn.Text:GetWidth(), 0, 0)

            Frame1.bidFrame = CreateFrame("Frame", nil, Frame1)
            local bidFrame = Frame1.bidFrame
            bidFrame:SetPoint("TOPLEFT", infoFrame, "BOTTOMLEFT", 0, 0)
            bidFrame:SetSize(infoFrame:GetWidth(), 21)
            bidFrame.bidEditBox = CreateEditBox(bidFrame, 68, 18, 14, "RIGHT", true)
            local bidEditBox = bidFrame.bidEditBox
            bidEditBox:SetPoint("TOPLEFT", bidFrame, "TOPLEFT", 2, 0)
            bidEditBox.Font = bidEditBox:CreateFontString()
            bidEditBox.Font:SetPoint("LEFT", bidEditBox, "LEFT", 2, 0)
            bidEditBox.Font:SetHeight(18)
            bidEditBox.Font:SetFont(GameFontNormal:GetFont(), 12)
            bidEditBox.Font:SetText("|cff595959一口价|r")
            bidEditBox.Font:SetWordWrap(false)
            bidEditBox.Font:SetJustifyH("LEFT")
            bidEditBox:SetScript("OnTextChanged", function (self)
                if strlen(self:GetText()) > 0 then
                    bidEditBox.Font:Hide()
                else
                    bidEditBox.Font:Show()
                end
            end)
            bidEditBox:SetScript("OnEnter", function (self)
                -- zlHighlightOnShow(v)
                GameTooltipShow(self, "TOPRIGHT", "BOTTOMLEFT")
                GameTooltip:AddLine("一口价")
                GameTooltip:AddLine("支持鼠标滚轮\n按Enter键或右键直接竞价", 1, 1, 1)
                GameTooltip:Show()
            end)
            bidEditBox:SetScript("OnLeave", function (self)
                -- zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            bidEditBox:SetScript("OnMouseWheel", function(self, delta)
                if self:HasFocus() then
                    local curAuctionList = ZL_CURRENT.auctionlist[v]
                    local itemCount = curAuctionList.itemCount
                    local bidderlist = curAuctionList.bidderlist
                    tableSort(bidderlist)
                    local bidCount = bidFrame.bidCounts:GetNumber()
                    bidCount = bidCount > 0 and bidCount or 1
                    bidCount = bidCount > itemCount and itemCount or bidCount
                    local _, bidIncrement, tarbidamount, _bidCount, successList = ZL.GetNewBidAmount(v)
                    if bidCount > _bidCount and #successList > 0 then
                        for i = #successList, 1, -1 do
                            if successList[i][2] >= bidCount then
                                tarbidamount = successList[i][1] + bidIncrement
                                break
                            end
                        end
                    end
                    local number = self:GetNumber()
                    if delta > 0 then
                        number = number + bidIncrement
                    else
                        number = number - bidIncrement
                    end
                    if number < tarbidamount then
                        number = tarbidamount
                    end
                    self:SetNumber(number)
                end
            end)
            bidEditBox:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
            bidEditBox:SetScript("OnEnterPressed", function (self)
                Frame1.bidFrame.bidBtn:Click()
                self:ClearFocus()
            end)
            bidEditBox:SetScript("OnMouseDown", function(self, button)
                if button == "RightButton" and self:HasFocus() then
                    Frame1.bidFrame.bidBtn:Click()
                    C_Timer.After(0.5, function ()
                        self:ClearFocus()
                    end)
                elseif button == "LeftButton" then
                    local curAuctionList = ZL_CURRENT.auctionlist[v]
                    if curAuctionList.state == "auctioning" and not curAuctionList.isPaused then
                        local function BidMenuTable(index)
                            local menuList = {{text="快速出价", isTitle=true}}
                            local curAuctionList = ZL_CURRENT.auctionlist[index]
                            local Frame1 = ZL.AuctionFrame2.entries[index]
                            local itemCount = curAuctionList.itemCount
                            local bidCount = Frame1.bidFrame.bidCounts:GetNumber()
                            bidCount = bidCount > 0 and bidCount or 1
                            bidCount = bidCount > itemCount and itemCount or bidCount
                            local _, bidIncrement, tarbidamount, _bidCount, successList = ZL.GetNewBidAmount(index)
                            if bidCount > _bidCount and #successList > 0 then
                                for i = #successList, 1, -1 do
                                    if successList[i][2] >= bidCount then
                                        tarbidamount = successList[i][1] + bidIncrement
                                        break
                                    end
                                end
                            end
                            bidIncrement = max(bidIncrement, ZL.opt.quickBidIncrement)
                            tarbidamount = math.ceil(tarbidamount / bidIncrement) * bidIncrement
                            for i = 1, 10 do
                                local wantBid = tarbidamount + bidIncrement * (i-1)
                                tinsert(menuList, {
                                    text = wantBid,
                                    func = function ()
                                        bidEditBox:SetNumber(wantBid)
                                        bidFrame.bidBtn:Click()
                                        ZL.GUI:CloseMenu()
                                    end
                                })
                            end
                            tinsert(menuList, {isSeparator = true})
                            tinsert(menuList, {
                                text = "设置幅度",
                                func = function ()
                                    ZL.GUI:CloseMenu()
                                    StaticPopup_Show("ZL_QUICKBIDINCREMENT", nil, nil)
                                end
                            })
                            tinsert(menuList, {isSeparator = true})
                            tinsert(menuList, {text="关闭", func = function ()
                                ZL.GUI:CloseMenu()
                            end})
                            return menuList
                        end
                        ZL.GUI:ToggleMenu(self, BidMenuTable(v), 'TOPLEFT', self, 'BOTTOMRIGHT')
                    end
                end
            end)
            bidEditBox:SetScript("OnEditFocusLost",function (self)
                self:HighlightText(0, 0)
            end)

            bidFrame.bidCounts = CreateEditBox(bidFrame, 38, 18, 14, "RIGHT", true)
            local bidCounts = bidFrame.bidCounts
            bidCounts:SetPoint("LEFT", bidEditBox, "RIGHT", 3, 0)
            bidCounts.Font = bidCounts:CreateFontString()
            bidCounts.Font:SetPoint("LEFT", bidCounts, "LEFT", 2, 0)
            bidCounts.Font:SetHeight(18)
            bidCounts.Font:SetFont(GameFontNormal:GetFont(), 12)
            bidCounts.Font:SetText("|cff595959数量|r")
            bidCounts.Font:SetWordWrap(false)
            bidCounts.Font:SetJustifyH("LEFT")
            bidCounts:SetScript("OnTextChanged", function (self)
                if strlen(self:GetText()) > 0 then
                    bidCounts.Font:Hide()
                    local itemCount = ZL_CURRENT["auctionlist"][v].itemCount
                    local number = self:GetNumber()
                    if number < 1 then
                        number = 1
                    elseif number > itemCount then
                        number = itemCount
                    end
                    self:SetNumber(number)
                else
                    bidCounts.Font:Show()
                end
            end)
            bidCounts:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
            bidCounts:SetScript("OnEnterPressed", function(self) self:ClearFocus() end)
            bidCounts:SetScript("OnEditFocusLost",function (self)
                self:HighlightText(0, 0)
            end)
            bidCounts:SetScript("OnMouseWheel", function(self, delta)
                if self:HasFocus() then
                    local itemCount = ZL_CURRENT["auctionlist"][v].itemCount
                    local number = self:GetNumber()
                    if delta > 0 then
                        number = number + 1
                    else
                        number = number - 1
                    end
                    if number < 1 then
                        number = 1
                    elseif number > itemCount then
                        number = itemCount
                    end
                    self:SetNumber(number)
                end
            end)
            bidCounts:SetScript("OnMouseDown", function(self, button)
                if button == "RightButton" and self:HasFocus() then
                    C_Timer.After(0.5, function ()
                        self:ClearFocus()
                    end)
                end
            end)
            bidCounts:SetScript("OnEnter", function (self)
                -- zlHighlightOnShow(v)
                GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
                GameTooltip:AddLine("竞拍数量")
                GameTooltip:AddLine("默认为1", 1, 1, 1)
                GameTooltip:AddLine("支持鼠标滚轮", 1, 1, 1)
                GameTooltip:Show()
            end)
            bidCounts:SetScript("OnLeave", function (self)
                -- zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)

            bidFrame.bidBtn = CreateButton(nil, bidFrame, "出价", "LEFT", bidCounts, "RIGHT", 3, 0, 59, 18)
            local bidBtn = bidFrame.bidBtn
            bidBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
            bidBtn:SetScript("OnEnter", function (self)
                -- zlHighlightOnShow(v)
                GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
                if bidBtn:GetText() == "出价" then
                    local itemCount = ZL_CURRENT.auctionlist[v].itemCount
                    local _, bidIncrement, tarbidamount, bidCount, successList = ZL.GetNewBidAmount(v)
                    GameTooltip:AddLine("出价方式")
                    GameTooltip:AddLine("|cffffd100左键：|r直接点击出价或双\n击右侧信息栏；", 1, 1, 1)
                    GameTooltip:AddLine("一口价：为空或小于最低\n出价则按最低出价；", 1, 1, 1)
                    GameTooltip:AddLine("一口价：大于最低出价则\n按照一口价；", 1, 1, 1)
                    GameTooltip:AddLine(" ")
                    GameTooltip:AddLine("|cffffd100右键：|r自动出价", 1, 1, 1)
                    if itemCount > 1 then
                        GameTooltip:AddLine("-------------------", 1, 1, 1)
                        GameTooltip:AddDoubleLine("出价", "最大数量")
                        if #successList == 0 then
                            GameTooltip:AddDoubleLine(tarbidamount, bidCount, 1, 1, 1, 1, 1, 1)
                        else
                            local bidamount = 0
                            for index, data in ipairs(successList) do
                                if data[1] ~= bidamount then
                                    GameTooltip:AddDoubleLine(data[1]+bidIncrement, data[2], 1, 1, 1, 1, 1, 1)
                                    bidamount = data[1]
                                end
                                if index == #successList and data[3] < itemCount then
                                    GameTooltip:AddDoubleLine(tarbidamount, itemCount-data[3], 1, 1, 1, 1, 1, 1)
                                end
                            end
                        end
                    end
                elseif bidBtn:GetText() == "停止" then
                    GameTooltip:AddLine("自动出价模式")
                    GameTooltip:AddLine("心里价：|cffffd100" .. Frame1.maxAutoBid .."|rg", 1, 1, 1)
                    GameTooltip:AddLine("每2秒按照最低加价幅度竞价", 1, 1, 1)
                else
                    GameTooltip:AddLine("申请重拍")
                end
                GameTooltip:Show()
            end)
            bidBtn:SetScript("OnLeave", function (self)
                -- zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            local function stopAutoBid()
                local curAuctionList = ZL_CURRENT.auctionlist[v]
                Frame1.maxAutoBid = nil
                bidEditBox:Enable()
                bidBtn:SetText("出价")
                bidFrame.lgnoreBtn:Enable()
                if Frame1.autoBid then
                    if (not Frame1.autoBid:IsCancelled()) then
                        Frame1.autoBid:Cancel()
                    end
                    Frame1.autoBid = nil
                    local bidderlist = curAuctionList.bidderlist
                    local isSelf
                    local totalBidCount = 0
                    local msgStr = ""
                    for _, bidData in ipairs(bidderlist) do
                        if totalBidCount < curAuctionList.itemCount then
                            local count = bidData["bidCount"] or 1
                            local newTotalBidCount = totalBidCount + count
                            if newTotalBidCount > curAuctionList.itemCount then
                                count = curAuctionList.itemCount - totalBidCount
                            end
                            totalBidCount = newTotalBidCount
                            if ParseClassColorName(bidData.bidder) == ZL.GetFullName() then
                                isSelf = true
                                break
                            end
                        else
                            break
                        end
                    end
                    if isSelf then
                        msgStr = curAuctionList.itemlink .. "自动出价结束，竞价|cff00ff00成功|r！"
                    else
                        msgStr = curAuctionList.itemlink .. "自动出价结束，竞价|cffff0000失败|r！"
                    end
                    ZL.ScrollingMessageFrame:AddMessage(msgStr)
                end
            end
            bidBtn:SetScript("OnClick", function(self, button)
                local curAuctionList = ZL_CURRENT.auctionlist[v]
                local itemCount = curAuctionList.itemCount
                if bidBtn:GetText() == "出价" then
                    if not curAuctionList.canUseConfirgBid then
                        if not ZL.ItemCanUseBySpec(curAuctionList.itemlink) then
                            local msgStr2 = format("%s不适合您当前专精，是否继续竞价？", curAuctionList.itemlink)
                            StaticPopup_Show("ZL_CANUSECONFIRMBID", msgStr2, nil, {
                                itemlink=curAuctionList.itemlink, itemindex=curAuctionList.itemindex,
                                btn = button,
                            })
                            return
                        else
                            curAuctionList.canUseConfirgBid = true
                        end
                    end
                    if button == "LeftButton" then
                        local bidderlist = curAuctionList.bidderlist
                        tableSort(bidderlist)
                        local isSelf = false
                        local totalBidCount = 0
                        local bidCount = bidCounts:GetNumber()
                        bidCount = bidCount > 0 and bidCount or 1
                        bidCount = bidCount > itemCount and itemCount or bidCount
                        for _, bidData in ipairs(bidderlist) do
                            if totalBidCount < curAuctionList.itemCount then
                                local count = bidData["bidCount"] or 1
                                local newTotalBidCount = totalBidCount + count
                                if newTotalBidCount > curAuctionList.itemCount then
                                    count = curAuctionList.itemCount - totalBidCount
                                end
                                totalBidCount = newTotalBidCount
                                if ParseClassColorName(bidData["bidder"]) == ZL.GetFullName() then
                                    if bidData.bidCount >= bidCount then
                                        isSelf = true
                                    end
                                    break
                                end
                            else
                                break
                            end
                        end
                        local _, bidIncrement, newBid, _bidCount, successList = ZL.GetNewBidAmount(v)
                        if bidCount > _bidCount and #successList > 0 then
                            for i = #successList, 1, -1 do
                                if successList[i][2] >= bidCount then
                                    newBid = successList[i][1] + bidIncrement
                                    break
                                end
                            end
                        end
                        newBid = (bidEditBox:GetNumber() > newBid) and bidEditBox:GetNumber() or newBid
                        if (not isSelf) then
                            local msgStr = ""
                            if bidCount == 1 then
                                msgStr = tostring(newBid)
                            else
                                msgStr = tostring(newBid) .. "x" .. bidCount
                            end
                            local inventoryCount, bagCount, itemBankCount, itemTotalCount = ZL.GetItemNumbers(curAuctionList.itemId)
                            if inventoryCount and itemTotalCount >= 1 and (not curAuctionList.confirmBid) then
                                --弹出警告窗口
                                local msgStr2 = "你总共拥有" .. curAuctionList.itemlink .. "|cff00ff00" .. itemTotalCount .. "|r个\n|cff00ff00装备:|r" .. inventoryCount .. "，|cff00ff00背包:|r" .. bagCount .. "，|cff00ff00银行:|r" .. itemBankCount .. "\n确定继续竞价？"
                                StaticPopup_Show("ZL_CONFIRMBID", msgStr2, nil, {itemlink=curAuctionList.itemlink, msgStr=msgStr, index=v})
                                return
                            end
                            if ZL_CURRENT.globalConfig.auctionMode == "团队" then
                                if not ZL_CURRENT.globalConfig.allowMultipleAuctions then
                                    SendChatMessage(msgStr, "RAID")
                                else
                                    SendChatMessage(curAuctionList.itemlink .. msgStr, "RAID")
                                end
                            else
                                MyAddon:TransmitAddonInfo2("AUTOAUC BID", curAuctionList.itemlink .. msgStr)
                            end
                        else
                            StaticPopup_Show(
                                "ZL_BIDAMOUNTCONFIRM",
                                format("%s你已经是最高出价者，是否继续以|cffffde00%d|rg竞价？", curAuctionList.itemlink, newBid),
                                nil,
                                {
                                    wantBid = newBid,
                                    newBid = newBid,
                                    bidCount = bidCount,
                                    index = v,
                                }
                            )
                        end
                        local editbox = GetCurrentKeyBoardFocus()
                        if editbox then
                            editbox:ClearFocus()
                        end
                    else
                        local data = {index=v, f=Frame1}
                        StaticPopup_Show("ZL_AUTOBID", curAuctionList.itemlink, nil, data)
                    end
                elseif bidBtn:GetText() == "停止" then
                    stopAutoBid()
                else
                    SendChatMessage("申请重拍：" .. curAuctionList.itemlink, "WHISPER", nil, ZL.GetMLname())
                    local data = {
                        itemlink = curAuctionList.itemlink,
                        itemindex = curAuctionList.itemindex,
                    }
                    MyAddon:TransmitAddonInfo2("AUTOAUC RETAKE", data, "WHISPER", ZL.GetMLname())
                    bidBtn:Disable()
                    C_Timer.After(1, function ()
                        bidBtn:Enable()
                    end)
                end
                ZL.FloatAuctionFrame:Update()
            end)

            bidFrame.lgnoreBtn = CreateButton(nil, bidFrame, "忽略", "LEFT", bidBtn, "RIGHT", 5, 0, 40, 18)
            local lgnoreBtn = bidFrame.lgnoreBtn
            lgnoreBtn:Hide()
            lgnoreBtn:SetScript("OnClick", function(self)
                if lgnoreBtn:GetText() == "忽略" then
                    lgnoreBtn:SetText("恢复")
                    ZL_CURRENT.auctionlist[v].lgnore = true
                    --如果关注物品则取消关注
                    local itemId = ZL_CURRENT.auctionlist[v].itemId
                    ZL.deleteItem(itemId)
                else
                    lgnoreBtn:SetText("忽略")
                    ZL_CURRENT.auctionlist[v].lgnore = false
                end
                AuctionFrame:Update()
                ZL.miniMapIconAnimation()
            end)

            infoFrame.line1 = infoFrame:CreateTexture(nil, "OVERLAY")
            infoFrame.line1:SetColorTexture(0.3, 0.3, 0.3, 1)
            infoFrame.line1:SetPoint("TOPRIGHT", 1, -1)
            infoFrame.line1:SetSize(1, Frame1:GetHeight()-4)
            iconHeaderBtn:SetWidth(infoFrame:GetWidth())

            sb:SetPoint("TOPLEFT", Frame1, "TOPLEFT", 1, -1)
            sb:SetPoint("BOTTOMRIGHT", bidFrame, "BOTTOMRIGHT", -1, 0)

            Frame1.MLframe = CreateFrame("Frame", nil, Frame1)
            local MLframe = Frame1.MLframe
            MLframe:SetPoint("TOPRIGHT")
            MLframe:SetSize(1, 1)

            MLframe.startbidFrame = CreateFrame("Frame", nil, MLframe)
            local startbidFrame = MLframe.startbidFrame
            startbidFrame:SetPoint("TOPRIGHT")
            startbidFrame.startbidEditbox = CreateEditBox(startbidFrame, 90, 22, 14, "RIGHT", true)
            local startbidEditbox = startbidFrame.startbidEditbox
            startbidEditbox:SetPoint("TOPRIGHT", startbidFrame, "TOPRIGHT", -5, -11)
            startbidEditbox.startbidFont = startbidEditbox:CreateFontString()
            startbidEditbox.startbidFont:SetPoint("LEFT", startbidEditbox, "LEFT", 2, 0)
            startbidEditbox.startbidFont:SetHeight(18)
            startbidEditbox.startbidFont:SetFont(GameFontNormal:GetFont(), 13)
            -- startbidEditbox.startbidFont:SetTextColor(0.95, 0.95, 0.95, 1)
            startbidEditbox.startbidFont:SetText("|cff595959起拍价|r")
            startbidEditbox.startbidFont:SetWordWrap(false)
            startbidEditbox.startbidFont:SetJustifyH("LEFT")

            startbidEditbox:SetScript("OnEditFocusGained", function (self)
                self.startbidFont:Hide()
                self:HighlightText()
                ZL.FloatAuctionFrame.startbidEditbox.startbidFont:Hide()
            end)
            startbidEditbox:SetScript("OnTextChanged", function (self)
                local startbid = self:GetNumber() or 0
                if startbid > 0 then
                    local curAuction = ZL_CURRENT.auctionlist[v]
                    curAuction.startbidamount = startbid
                    if curAuction.state == "waiting" or curAuction.state == "failed" then
                        Frame1.bidderFrame.playerNameString:SetText("|cff00ff00起拍价:|r" .. ZL.formatNumber(startbid))
                    end
                end
            end)
            startbidEditbox:SetScript("OnMouseWheel", function(self, delta)
                EditOnMouseWheel(self, delta)
            end)
            startbidEditbox:SetScript("OnEnter", function (self)
                -- zlHighlightOnShow(v)
                GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
                GameTooltip:AddLine("起拍价")
                GameTooltip:AddLine("支持鼠标滚轮调价", 1, 1, 1)
                GameTooltip:Show()
            end)
            startbidEditbox:SetScript("OnLeave", function (self)
                -- zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            startbidEditbox:SetScript("OnEditFocusLost", function (self)
                self:HighlightText(0, 0)
                startbidEditbox.startbidFont:Show()
                ZL.FloatAuctionFrame.startbidEditbox.startbidFont:Show()
            end)
            
            startbidFrame.incrementEditbox = CreateEditBox(startbidFrame, 90, 22, 14, "RIGHT", true)
            local incrementEditbox = startbidFrame.incrementEditbox
            incrementEditbox:SetPoint("TOPRIGHT", startbidEditbox, "BOTTOMRIGHT", 0, -4)
            incrementEditbox.inrementFont = incrementEditbox:CreateFontString()
            incrementEditbox.inrementFont:SetPoint("LEFT", incrementEditbox, "LEFT", 2, 0)
            incrementEditbox.inrementFont:SetHeight(18)
            incrementEditbox.inrementFont:SetFont(GameFontNormal:GetFont(), 13)
            -- incrementEditbox.inrementFont:SetTextColor(0.95, 0.95, 0.95, 1)
            incrementEditbox.inrementFont:SetText("|cff595959加价|r")
            incrementEditbox.inrementFont:SetWordWrap(false)
            incrementEditbox.inrementFont:SetJustifyH("LEFT")
            incrementEditbox:SetScript("OnEditFocusGained", function (self)
                self.inrementFont:Hide()
                self:HighlightText()
                ZL.FloatAuctionFrame.incrementEditbox.inrementFont:Hide()
            end)
            incrementEditbox:SetScript("OnTextChanged", function (self)
                local increment = self:GetNumber() or 0
                if increment > 0 then
                    ZL_CURRENT.auctionlist[v].bidIncrement = increment
                end
            end)
            incrementEditbox:SetScript("OnMouseWheel", function(self, delta)
                EditOnMouseWheel(self, delta)
            end)
            incrementEditbox:SetScript("OnEnter", function (self)
                -- zlHighlightOnShow(v)
                GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
                GameTooltip:AddLine("加价幅度")
                GameTooltip:AddLine("支持鼠标滚轮调价", 1, 1, 1)
                GameTooltip:AddLine(" ")
                if ZL.opt.intervalBidIncrement then
                    GameTooltip:AddLine("已开启按区间自动调整加价幅度，\n手动设置不生效", 1, 0, 0)
                    GameTooltip:AddLine(" ")
                    GameTooltip:AddLine("Shift+左键：|cffffffff关闭自动调整加价幅度|r")
                else
                    GameTooltip:AddLine("Shift+左键：|cffffffff开启自动调整加价幅度|r")
                end
                GameTooltip:AddLine("Shift+右键：|cffffffff设置区间加价幅度|r")
                GameTooltip:Show()
            end)
            incrementEditbox:SetScript("OnLeave", function (self)
                -- zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            incrementEditbox:SetScript("OnEditFocusLost", function (self)
                self:HighlightText(0, 0)
                incrementEditbox.inrementFont:Show()
                ZL.FloatAuctionFrame.incrementEditbox.inrementFont:Show()
            end)
            incrementEditbox:SetScript("OnMouseDown", function (self, button)
                if IsShiftKeyDown() then
                    if button == "LeftButton" then
                        if ZL.opt.intervalBidIncrement then
                            ZL.opt.intervalBidIncrement = nil
                            ZL.Print("已|cff4080FF关闭|r按区间自动调整加价幅度。")
                        else
                            ZL.opt.intervalBidIncrement = true
                            ZL.Print("已|cff4080FF开启|r按区间自动调整加价幅度。")
                        end
                        GameTooltip:Hide()
                    elseif button == "RightButton" then
                        ZL.OpenAceConfigDialog("金团拍卖助手", "behaviour")
                    end
                end
            end)

            startbidFrame:SetSize(10+startbidFrame.startbidEditbox:GetWidth(), Frame1:GetHeight())
            do
                local line = startbidFrame:CreateTexture(nil, "OVERLAY")
                line:SetColorTexture(0.3, 0.3, 0.3, 1)
                line:SetPoint("TOPLEFT", 0, -1)
                line:SetSize(1, Frame1:GetHeight()-4)
            end

            Frame1.bidderFrame = CreateFrame("Button", nil, Frame1)
            local bidderFrame = Frame1.bidderFrame
            bidderFrame:SetNormalFontObject("GameFontNormal")
            bidderFrame:SetText(" ")
            bidderFrame:SetPoint("TOPLEFT", infoFrame, "TOPRIGHT")
            bidderFrame:SetPoint("BOTTOMRIGHT", startbidFrame, "BOTTOMLEFT", 0, 21)
            bidderFrame.playerNameString = bidderFrame:GetFontString()
            local playerNameString = bidderFrame.playerNameString
            playerNameString:SetPoint("TOPLEFT", bidderFrame, "TOPLEFT", 5, -2)
            playerNameString:SetPoint("BOTTOMRIGHT", bidderFrame, "BOTTOMRIGHT", -5, 2)
            playerNameString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            playerNameString:SetWordWrap(true)
            playerNameString:SetJustifyH("LEFT")
            -- playerNameString:SetJustifyV("TOP")
            playerNameString:SetTextColor(0.95, 0.95, 0.95, 1)
            bidderFrame:SetHyperlinksEnabled(true)
            bidderFrame:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp")
            bidderFrame:SetScript("OnEnter", function (self)
                if PlayerIsML() then
                    GameTooltipShow(self, "TOPRIGHT", "BOTTOMRIGHT", 0, -21)
                else
                    GameTooltipShow(self, "TOPRIGHT", "BOTTOMRIGHT", 0, 0)
                end
                local auctionList = ZL_CURRENT["auctionlist"][v]
                if (not PlayerIsML()) or (not ZL.BidderListFrame:IsShown()) then
                    if auctionList and auctionList.bidderlist and (#auctionList.bidderlist > 0)then
                        local bidderlist = auctionList.bidderlist
                        tableSort(bidderlist)
                        GameTooltip:AddLine("出价记录")
                        GameTooltip:AddDoubleLine("名字", "单价*数量")
                        local totalBidCount = 0
                        for _, bidData in ipairs(bidderlist) do
                            local bidderName
                            local bidderAmount
                            if ParseClassColorName(bidData["bidder"]) == ZL.GetFullName() then
                                bidderName = "|cff00ff00你|r"
                            else
                                if ZL_CURRENT.globalConfig.auctionMode == "|cffff0000匿名|r" and auctionList.state == "auctioning" then
                                    bidderName = "***"
                                else
                                    bidderName = bidData["bidder"]
                                end
                            end
                            if totalBidCount < auctionList.itemCount then
                                local count = bidData["bidCount"] or 1
                                local newTotalBidCount = totalBidCount + count
                                if newTotalBidCount > auctionList.itemCount then
                                    count = auctionList.itemCount - totalBidCount
                                end
                                bidderAmount = "|cffff0000" .. tostring(bidData.bidamount) .. "x" .. tostring(count) .. "|r"
                                totalBidCount = newTotalBidCount
                            else
                                bidderAmount = bidData.bidamount  .. "x" .. bidData.bidCount
                            end
                            GameTooltip:AddDoubleLine(bidderName, bidderAmount, 1, 1, 1, 1, 1, 1)
                        end
                        GameTooltip:AddLine(" ")
                    end
                end
                if auctionList.state == "auctioning" then
                    GameTooltip:AddLine("左键双击可|cff00ff00直接出价|r", 1, 1, 1)
                elseif auctionList.state == "failed" then
                    if not PlayerIsML() then
                        GameTooltip:AddLine("左键双击可|cff00ff00申请重拍|r", 1, 1, 1)
                    end
                end
                GameTooltip:AddLine("<右键> 更多功能", 1, 1, 1)
                GameTooltip:Show()
                zlHighlightOnShow(v)
                ZL.BagHighLight()
                ZL.OnEnterBagHighLight(v)
            end)
            bidderFrame:SetScript("OnLeave", function (self)
                zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            bidderFrame:SetScript("OnClick", function (self, button)
                if PlayerIsML() and IsModifierKeyDown() then
                    local curAuctionList = ZL_CURRENT.auctionlist[v]
                    if button == "LeftButton" then
                        if IsShiftKeyDown() and (not IsControlKeyDown()) and (not IsAltKeyDown()) then
                            --只按下Shift+左键点击：开始/重拍
                            startOrCanelAuction(v, nil, true)
                        elseif (not IsShiftKeyDown()) and IsControlKeyDown() and (not IsAltKeyDown()) then
                            --只按下Ctr+左键点击：停止5秒倒数 ，刷新拍卖计时
                            resetAuctionTime(v)
                        elseif (not IsShiftKeyDown()) and (not IsControlKeyDown()) and IsAltKeyDown() then
                            --只按下Alt+左键：快速流拍

                        end
                    elseif button == "RightButton" then
                        if IsShiftKeyDown() and (not IsControlKeyDown()) and (not IsAltKeyDown()) and PlayerIsML() then
                            --只按下Shift+右键点击：竞拍信息
                            if curAuctionList.state == "auctioning" then
                                sendAuctionInfo(v)
                            end
                        elseif (not IsShiftKeyDown()) and IsControlKeyDown() and (not IsAltKeyDown()) then
                            --只按下Ctr+右键点击：5秒倒数
                            if (curAuctionList.endTime or 0) - time() > 5 then
                                coundownAuction(v)
                            end
                        elseif (not IsShiftKeyDown()) and (not IsControlKeyDown()) and IsAltKeyDown() then
                            --只按下Alt+右键点击：撤销出价
                            MLframe.functionFrame.reverseBidBtn:Click()
                        end
                    end
                    return
                end
                if button == "RightButton" and (not IsModifierKeyDown()) then
                    local function BidMenuTable(index)
                        local menuList = {}
                        local curAuctionList = ZL_CURRENT.auctionlist[index]
                        local Frame1 = ZL.AuctionFrame2.entries[index]
                        local itemCount = curAuctionList.itemCount
                        local bidCount = Frame1.bidFrame.bidCounts:GetNumber()
                        bidCount = bidCount > 0 and bidCount or 1
                        bidCount = bidCount > itemCount and itemCount or bidCount
                        local _, bidIncrement, tarbidamount, _bidCount, successList = ZL.GetNewBidAmount(index)
                        if bidCount > _bidCount and #successList > 0 then
                            for i = #successList, 1, -1 do
                                if successList[i][2] >= bidCount then
                                    tarbidamount = successList[i][1] + bidIncrement
                                    break
                                end
                            end
                        end
                        bidIncrement = max(bidIncrement, ZL.opt.quickBidIncrement)
                        tarbidamount = math.ceil(tarbidamount / bidIncrement) * bidIncrement
                        for i = 1, 10 do
                            local wantBid = tarbidamount + bidIncrement * (i-1)
                            tinsert(menuList, {
                                text = wantBid,
                                func = function ()
                                    bidEditBox:SetNumber(wantBid)
                                    bidFrame.bidBtn:Click()
                                    ZL.GUI:CloseMenu()
                                end
                            })
                        end
                        tinsert(menuList, {isSeparator = true})
                        tinsert(menuList, {
                            text = "设置幅度",
                            func = function ()
                                ZL.GUI:CloseMenu()
                                StaticPopup_Show("ZL_QUICKBIDINCREMENT", nil, nil)
                            end
                        })
                        tinsert(menuList, {isSeparator = true})
                        tinsert(menuList, {text="关闭", func = function ()
                            ZL.GUI:CloseMenu()
                        end})
                        return menuList
                    end
                    local function tempMenuTable()
                        local selectCharKey = ZL.GetClassColorName() .. " - " .. GetRealmName()
                        local curAuctionList = ZL_CURRENT.auctionlist[v]
                        local itemId = curAuctionList.itemId
                        local bidderlist = curAuctionList.bidderlist
                        local menuList = {{text="左键双击出价", isTitle=true}}
                        if curAuctionList.state == "auctioning" then
                            if not Frame1.maxAutoBid then
                                tinsert(menuList, {
                                    text = "自动出价",
                                    func = function()
                                        local data = {index=v, f=Frame1}
                                        StaticPopup_Show("ZL_AUTOBID", curAuctionList.itemlink, nil, data)
                                    end
                                })
                            else
                                tinsert(menuList, {
                                    text = "停止自动出价",
                                    func = function()
                                        stopAutoBid()
                                    end
                                })
                            end

                            tinsert(menuList, {
                                text = "快速出价",
                                hasArrow = 1,
                                -- notClickable = 1,
                                menuTable = BidMenuTable(v),
                            })
                        end
                        if PlayerIsML() then
                            tinsert(menuList, {isSeparator = true})
                            if curAuctionList.state == "waiting" or curAuctionList.state == "failed" then
                                tinsert(menuList, {
                                    text = "|T130866:18:18:2:0|t " .. "开始拍卖",
                                    func =function ()
                                        startOrCanelAuction(v)
                                    end
                                })
                                if curAuctionList.state == "waiting" then
                                    tinsert(menuList, {
                                        text = "|T576625:18:18:2:0|t " .. "直接流拍",
                                        func =function ()
                                            startOrCanelAuction(v, true)
                                        end
                                    })
                                end
                                tinsert(menuList, {
                                    text = "|T384756:18:18:2:0|t " .. "快速拍卖",
                                    func =function ()
                                        quickStartAuction(v)
                                    end
                                })
                            elseif curAuctionList.state == "success" then
                                tinsert(menuList, {
                                    text = "|T130866:18:18:2:0|t " .. "重拍",
                                    func =function ()
                                        startOrCanelAuction(v)
                                    end
                                })
                                tinsert(menuList, {
                                    text = "|T576625:18:18:2:0|t " .. "快速流拍",
                                    func =function ()
                                        startOrCanelAuction(v, true)
                                    end
                                })
                            elseif curAuctionList.state == "auctioning" then
                                tinsert(menuList, {
                                    text = "|T137048:18:18:2:0|t " .. "取消",
                                    func =function ()
                                        startOrCanelAuction(v)
                                    end
                                })
                                if curAuctionList["isPaused"] then
                                    tinsert(menuList, {
                                        text = "|T130866:18:18:2:0|t " .. "继续",
                                        func =function ()
                                            pauseOrResumeAuction(v)
                                        end
                                    })
                                else
                                    tinsert(menuList, {
                                        text = "|T137047:18:18:2:0|t " .. "暂停",
                                        func =function ()
                                            pauseOrResumeAuction(v)
                                        end
                                    })
                                end
                            end

                            if curAuctionList.state == "auctioning" then
                                tinsert(menuList, {isSeparator = true})
                                tinsert(menuList, {
                                    text = "|TInterface\\AddOns\\AutoAuction\\Images\\5countdown_normal.png:14:14:2:2|t " .. "5秒倒数",
                                    func = function ()
                                        coundownAuction(v)
                                    end
                                })
                                tinsert(menuList, {
                                    text = "|TInterface\\AddOns\\AutoAuction\\Images\\reset_time.png:14:14:2:0|t " .. "重置倒计时",
                                    func = function ()
                                        resetAuctionTime(v)
                                    end
                                })
                            end

                            if curAuctionList.state == "waiting" or curAuctionList.state == "failed" then
                                tinsert(menuList, {isSeparator = true})
                                if curAuctionList.itemlink ~= "[打包拍卖]" then
                                    tinsert(menuList, {
                                        text = "|T346111:16:16:2:0|t " .. "打包拍卖",
                                        func = function ()
                                            packageAuction(v)
                                        end
                                    })
                                end
                                tinsert(menuList, {
                                    text = "|T136813:16:16:2:0|t " .. "删除拍卖",
                                    func = function ()
                                        if ZL.syncAll or Frame1.sync then
                                            ZL.Print("通信被占用，请稍后重试。")
                                            return
                                        end
                                        local msgStr = "警告！确定删除" .. ZL_CURRENT.auctionlist[v].itemlink .. "的拍卖记录?"
                                        StaticPopup_Show("ZL_DELETEAUCTIONWARNING", msgStr, nil, v)
                                    end
                                })
                            elseif curAuctionList.state == "auctioning" then
                                tinsert(menuList, {isSeparator = true})
                                tinsert(menuList, {
                                    text = "|A:chatframe-button-icon-voicechat:16:16:2:0|a 通报竞拍信息",
                                    func = function ()
                                        sendAuctionInfo(v)
                                    end
                                })
                                if #bidderlist > 0 then
                                    tinsert(menuList, {isSeparator = true})
                                    tinsert(menuList, {
                                        text = "撤销第一名出价",
                                        func = function ()
                                            revokeBidAmount(v)
                                        end
                                    })
                                    tinsert(menuList, {
                                        text = "修改出价记录",
                                        func = function ()
                                            modifyBidRecord(v)
                                        end
                                    })
                                end
                            elseif curAuctionList.state == "success" then
                                tinsert(menuList, {isSeparator = true})
                                tinsert(menuList, {
                                    text = "修改出价记录",
                                    func = function ()
                                        modifyBidRecord(v)
                                    end
                                })
                            end
                            tinsert(menuList, {isSeparator = true})
                            tinsert(menuList, {
                                text = "|TInterface\\AddOns\\AutoAuction\\Images\\sync.png:16:16:2:-1|t " .. "同步数据",
                                func = function ()
                                    syncAuction(v)
                                end
                            })
                        end
                        tinsert(menuList, {isSeparator = true})
                        if (not ZL.opt.concernList) or (not ZL.opt.concernList[selectCharKey]) or
                        (not ZL.opt.concernList[selectCharKey]["itemList"][itemId]) then
                            tinsert(menuList, {
                                text = "|A:auctionhouse-icon-favorite:15:15:2:2|a " .. "关注", --VignetteKill
                                func = function ()
                                    ZL.addItem(itemId)
                                end
                            })
                        else
                            tinsert(menuList, {
                                text = "|A:auctionhouse-icon-favorite-off:15:15:2:2|a " .. "取消关注",
                                func = function ()
                                    ZL.deleteItem(itemId)
                                end
                            })
                        end
                        tinsert(menuList, {
                            text = "|T130775:15:15:2:0|t " .. (curAuctionList["lgnore"] and "取消忽略" or "忽略"),
                            func = function ()
                                lgnoreBtn:Click()
                            end
                        })
                        tinsert(menuList, {isSeparator = true})
                        tinsert(menuList, {text = "关闭"})
                        return menuList
                    end
                    ZL.GUI:ToggleMenu(self, tempMenuTable(), 'TOPLEFT', self, 'TOPRIGHT', 0, 30)
                end
            end)
            bidderFrame:SetScript("OnDoubleClick", function (self, button)
                if (not IsModifierKeyDown()) then
                    if button == "LeftButton" then
                        bidBtn:Click()
                    end
                end
            end)
            bidderFrame:SetScript("OnHyperlinkClick", function (self, link, _, button)
                local linkType, missionID, txt, playerName = strsplit(":", link)
                if linkType == "garrmission" then
                    if missionID == "AutoAuction" then
                        if txt == "TRADEITEM" and playerName then
                            InitiateTrade(playerName)
                        end
                    end
                end
            end)
            Frame1.icon = bidderFrame:CreateTexture()
            Frame1.icon:SetPoint("TOPRIGHT", -3, -3)
            Frame1.icon:SetSize(20, 20)
            Frame1.icon:Hide()

            MLframe.functionFrame = CreateFrame("Frame", nil, MLframe)
            local functionFrame = MLframe.functionFrame
            functionFrame:SetPoint("TOPLEFT", bidderFrame, "BOTTOMLEFT")
            functionFrame:SetSize(132, bidderFrame:GetHeight())
            functionFrame.CancelBtn = CreateFrame("Button", nil, functionFrame, "UIPanelButtonTemplate")
            local CancelBtn = functionFrame.CancelBtn
            CancelBtn:SetPoint("LEFT", bidBtn, "RIGHT", 3, 0)
            CancelBtn:SetSize(23, 23)
            -- CancelBtn:SetText("|T130866:15:15|t")
            CancelBtn:SetNormalTexture(130866)
            CancelBtn.Left:Hide()
            CancelBtn.Middle:Hide()
            CancelBtn.Right:Hide()
            CancelBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
            CancelBtn:SetScript("OnEnter", function (self)
                -- zlHighlightOnShow(v)
                if not ZL.opt.hideBtnTooltip then
                    local state = ZL_CURRENT.auctionlist[v].state
                    GameTooltipShow(self, "TOPRIGHT", "BOTTOMLEFT")
                    GameTooltip:AddLine("提示：")
                    if state == "waiting" then
                        GameTooltip:AddLine("|cff00ff00左键|r：开始", 1, 1, 1)
                        GameTooltip:AddLine("|cff00ff00Shift+左键|r：流拍", 1, 1, 1)
                        GameTooltip:AddLine("|cff00ff00Shift+右键|r：快速拍卖", 1, 1, 1)
                        GameTooltip:AddLine("|cff00ff00右键|r：更多功能", 1, 1, 1)
                    elseif state == "auctioning" then
                        GameTooltip:AddLine("|cff00ff00左键|r：取消拍卖", 1, 1, 1)
                    elseif state == "failed" then
                        GameTooltip:AddLine("|cff00ff00左键|r：开始", 1, 1, 1)
                        GameTooltip:AddLine("|cff00ff00Shift+右键|r：快速拍卖", 1, 1, 1)
                        GameTooltip:AddLine("|cff00ff00右键|r：更多功能", 1, 1, 1)
                    elseif state == "success" then
                        GameTooltip:AddLine("|cff00ff00左键|r：重拍", 1, 1, 1)
                        GameTooltip:AddLine("|cff00ff00Shift+左键|r：流拍", 1, 1, 1)
                        GameTooltip:AddLine("|cff00ff00右键|r：更多功能", 1, 1, 1)
                    end
                    
                    GameTooltip:Show()
                end
            end)
            CancelBtn:SetScript("OnLeave", function (self)
                -- zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            CancelBtn:SetScript("OnClick", function (self, button)
                if IsInRaid(1) then
                    local curAuctionList = ZL_CURRENT.auctionlist[v]
                    if button == "LeftButton" then
                        ZL.GUI:CloseMenu()
                        if (not IsModifierKeyDown()) then
                            startOrCanelAuction(v)
                        elseif IsShiftKeyDown() and (not IsControlKeyDown()) and (not IsAltKeyDown()) then
                            if ZL_CURRENT.auctionlist[v].state == "waiting" or ZL_CURRENT.auctionlist[v].state == "success" then
                                startOrCanelAuction(v, true)
                            end
                        end
                    elseif button == "RightButton" then
                        if (not IsModifierKeyDown()) then
                            if curAuctionList.state ~= "auctioning" then
                                local function tempMenuTable()
                                    local menuList = {}
                                    if curAuctionList.state == "waiting" or curAuctionList.state == "failed" then
                                        tinsert(menuList, {
                                            text = "|T130866:18:18:2:0|t " .. "开始拍卖",
                                            func =function ()
                                                startOrCanelAuction(v)
                                            end
                                        })
                                        if curAuctionList.state == "waiting" then
                                            tinsert(menuList, {
                                                text = "|T576625:18:18:2:0|t " .. "直接流拍",
                                                func =function ()
                                                    startOrCanelAuction(v, true)
                                                end
                                            })
                                        end
                                        tinsert(menuList, {
                                            text = "|T384756:18:18:2:0|t " .. "快速拍卖",
                                            func =function ()
                                                quickStartAuction(v)
                                            end
                                        })
                                    elseif curAuctionList.state == "success" then
                                        tinsert(menuList, {
                                            text = "|T130866:18:18:2:0|t " .. "重拍",
                                            func =function ()
                                                startOrCanelAuction(v)
                                            end
                                        })
                                        tinsert(menuList, {
                                            text = "|T576625:18:18:2:0|t " .. "快速流拍",
                                            func =function ()
                                                startOrCanelAuction(v, true)
                                            end
                                        })
                                    elseif curAuctionList.state == "auctioning" then
                                        tinsert(menuList, {
                                            text = "|T137048:18:18:2:0|t " .. "取消",
                                            func =function ()
                                                startOrCanelAuction(v)
                                            end
                                        })
                                    end
                                    tinsert(menuList, {isSeparator = true})
                                    if ZL.opt.hideBtnTooltip then
                                        tinsert(menuList, {
                                            text = "打开按钮提示",
                                            func = function()
                                                ZL.opt.hideBtnTooltip = nil
                                            end,
                                        })
                                    else
                                        tinsert(menuList, {
                                            text = "关闭按钮提示",
                                            func = function()
                                                ZL.opt.hideBtnTooltip = true
                                                GameTooltip:Hide()
                                            end,
                                        })
                                    end
                                    tinsert(menuList, {isSeparator = true})
                                    tinsert(menuList, {text = "关闭"})
                                    return menuList
                                end
                                ZL.GUI:ToggleMenu(self, tempMenuTable(), 'TOPLEFT', self, 'BOTTOMRIGHT', 0, 0)
                            end
                        elseif IsShiftKeyDown() and (not IsControlKeyDown()) and (not IsAltKeyDown()) then
                            quickStartAuction(v)
                        end
                    end
                else
                    local msgStr = "团队模式才能进行拍卖相关行为！"
                    ZL.Print(msgStr)
                end
            end)

            functionFrame.PauseBtn = CreateFrame("Button", nil, functionFrame, "UIPanelButtonTemplate")
            local PauseBtn = functionFrame.PauseBtn
            PauseBtn:SetPoint("LEFT", CancelBtn, "RIGHT", -1, 0)
            PauseBtn:SetSize(23, 23)
            -- PauseBtn:SetText("|T137047:25:25|t")
            PauseBtn:SetNormalTexture(137047)
            -- PauseBtn:SetHighlightTexture(137047)
            PauseBtn:SetScript("OnEnter", function (self)
                -- zlHighlightOnShow(v)
                GameTooltipShow(self, "TOPRIGHT", "BOTTOMLEFT")
                if ZL_CURRENT.auctionlist[v].isPaused then
                    GameTooltip:AddLine("继续")
                else
                    GameTooltip:AddLine("暂停")
                end
                GameTooltip:Show()
            end)
            PauseBtn:SetScript("OnLeave", function (self)
                -- zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            PauseBtn:SetScript("OnClick", function (self, button)
                pauseOrResumeAuction(v)
                btnDelay(self)
            end)
            PauseBtn.Left:Hide()
            PauseBtn.Middle:Hide()
            PauseBtn.Right:Hide()

            functionFrame.CountDownBtn = CreateFrame("Button", nil, functionFrame, "UIPanelButtonTemplate")
            local CountDownBtn = functionFrame.CountDownBtn
            CountDownBtn:SetPoint("LEFT", PauseBtn, "RIGHT", 0, 0)
            CountDownBtn:SetSize(20, 20)
            CountDownBtn:SetText("|TInterface\\AddOns\\AutoAuction\\Images\\5countdown_normal.png:12:12:0:0|t")
            CountDownBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
            CountDownBtn:SetScript("OnEnter", function (self)
                -- zlHighlightOnShow(v)
                if not ZL.opt.hideBtnTooltip then
                    GameTooltipShow(self, "TOPRIGHT", "BOTTOMLEFT")
                    GameTooltip:AddLine("提示：")
                    GameTooltip:AddLine("左键：|cffffffff有人出价5秒倒数|r")
                    GameTooltip:AddLine("　　　|cffffffff没人出价直接流拍|r")
                    GameTooltip:AddLine("右键：|cffffffff重置倒计时|r")
                    GameTooltip:Show()
                end
            end)
            CountDownBtn:SetScript("OnLeave", function (self)
                -- zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            CountDownBtn:SetScript("OnClick", function (self, button)
                if button == "LeftButton" then
                    coundownAuction(v)
                elseif button == "RightButton" then
                    resetAuctionTime(v)
                end
            end)

            functionFrame.syncBtn = CreateFrame("Button", nil, functionFrame, "UIPanelButtonTemplate")
            local syncBtn = functionFrame.syncBtn
            syncBtn:SetPoint("LEFT", CountDownBtn, "RIGHT", 2, 0)
            syncBtn:SetSize(20, 20)
            syncBtn:SetText("|A:chatframe-button-icon-voicechat:12:12:0:0|a")
            syncBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
            syncBtn:SetScript("OnEnter", function (self)
                -- zlHighlightOnShow(v)
                if not ZL.opt.hideBtnTooltip then
                    GameTooltipShow(self, "TOPRIGHT", "BOTTOMLEFT")
                    GameTooltip:AddLine("提示：")
                    GameTooltip:AddLine("|cff00ff00左键|r：通报竞拍信息", 1, 1, 1)
                    GameTooltip:AddLine("|cff00ff00右键|r：更多功能", 1, 1, 1)
                    GameTooltip:Show()
                end
            end)
            syncBtn:SetScript("OnLeave", function (self)
                -- zlHighlightOnHide(v)
                GameTooltip:Hide()
            end)
            syncBtn:SetScript("OnClick", function (self, button)
                local curAuctionList = ZL_CURRENT.auctionlist[v]
                local itemlink = curAuctionList.itemlink
                if button == "RightButton" then
                    local function tempMenuTable2()
                        local menuList = {}
                        if curAuctionList.state == "waiting" or curAuctionList.state == "failed" then
                            if curAuctionList.itemlink ~= "[打包拍卖]" then
                                tinsert(menuList, {
                                    text = "|T346111:16:16:2:0|t " .. "打包拍卖",
                                    func = function ()
                                        packageAuction(v)
                                    end
                                })
                            end
                            tinsert(menuList, {
                                text = "|T136813:16:16:2:0|t " .. "删除拍卖",
                                func = function ()
                                    if ZL.syncAll or Frame1.sync then
                                        ZL.Print("通信被占用，请稍后重试。")
                                        return
                                    end
                                    local msgStr = "警告！确定删除" .. ZL_CURRENT.auctionlist[v].itemlink .. "的拍卖记录?"
                                    StaticPopup_Show("ZL_DELETEAUCTIONWARNING", msgStr, nil, v)
                                end
                            })
                        elseif curAuctionList.state == "success" then

                        elseif curAuctionList.state == "auctioning" then
                            tinsert(menuList, {
                                text = "|A:chatframe-button-icon-voicechat:16:16:2:0|a 通报竞拍信息",
                                func = function ()
                                    sendAuctionInfo(v)
                                end
                            })
                        end
                        if #menuList > 0 then
                            tinsert(menuList, {isSeparator = true})
                        end
                        tinsert(menuList, {
                            text = "|TInterface\\AddOns\\AutoAuction\\Images\\sync.png:16:16:2:-1|t " .. "同步数据",
                            func = function ()
                                syncAuction(v)
                            end
                        })
                        tinsert(menuList, {isSeparator = true})
                        if ZL.opt.hideBtnTooltip then
                            tinsert(menuList, {
                                text = "打开按钮提示",
                                func = function()
                                    ZL.opt.hideBtnTooltip = nil
                                end,
                            })
                        else
                            tinsert(menuList, {
                                text = "关闭按钮提示",
                                func = function()
                                    ZL.opt.hideBtnTooltip = true
                                    GameTooltip:Hide()
                                end,
                            })
                        end
                        tinsert(menuList, {isSeparator = true})
                        tinsert(menuList, {text = "关闭"})
                        return menuList
                    end
                    ZL.GUI:ToggleMenu(self, tempMenuTable2(), 'TOPLEFT', self, 'BOTTOMRIGHT', 0, 0)
                elseif button == "LeftButton" then
                    ZL.GUI:CloseMenu()
                    local msgStr
                    if curAuctionList.state == "waiting" then
                        msgStr = itemlink .. "待拍卖状态，无法发送竞拍信息"
                    elseif curAuctionList.state == "failed" then
                        msgStr = itemlink .. "已流拍，无法发送竞拍信息"
                    elseif curAuctionList.state == "success" then
                        msgStr = itemlink .. "已拍卖成功，无法发送竞拍信息"
                    else
                        sendAuctionInfo(v)
                    end
                    if msgStr then ZL.Print(msgStr) end
                end
            end)

            functionFrame.reverseBidBtn = CreateFrame("Button", nil, functionFrame, "UIPanelButtonTemplate")
            local reverseBidBtn = functionFrame.reverseBidBtn
            reverseBidBtn:SetPoint("LEFT", syncBtn, "RIGHT", 2, 0)
            reverseBidBtn:SetSize(20, 20)
            reverseBidBtn:SetText("撤")
            do
                local fontString = reverseBidBtn:GetFontString()
                fontString:SetFont(GameFontNormal:GetFont(), 12)
            end
            reverseBidBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
            reverseBidBtn:SetScript("OnEnter", function (self)
                GameTooltipShow(self, "TOPRIGHT", "BOTTOMLEFT")
                GameTooltip:AddLine("提示：")
                GameTooltip:AddLine("左键：|cffffffff撤销第一名出价|r")
                GameTooltip:AddLine("右键：|cffffffff修改出价记录|r")
                GameTooltip:Show()
            end)
            reverseBidBtn:SetScript("OnLeave", function (self)
                GameTooltip:Hide()
            end)
            reverseBidBtn:SetScript("OnClick", function (self, button)
                if button == "LeftButton" then
                    revokeBidAmount(v)
                elseif button == "RightButton" then
                    modifyBidRecord(v)
                end
            end)

            functionFrame.startBidAmountBtn = CreateFrame("Button", nil, functionFrame, "UIPanelButtonTemplate")
            local startBidAmountBtn = functionFrame.startBidAmountBtn
            startBidAmountBtn:SetPoint("LEFT", reverseBidBtn, "RIGHT", 2, 0)
            startBidAmountBtn:SetSize(20, 20)
            startBidAmountBtn:SetText("起")
            do
                local fontString = startBidAmountBtn:GetFontString()
                fontString:SetFont(GameFontNormal:GetFont(), 12)
            end
            startBidAmountBtn:SetScript("OnEnter", function (self)
                GameTooltipShow(self, "TOPRIGHT", "BOTTOMLEFT")
                GameTooltip:AddLine("提示：")
                GameTooltip:AddLine("打开/关闭起拍价和加价幅度窗口", 1, 1, 1)
                GameTooltip:Show()
            end)
            startBidAmountBtn:SetScript("OnLeave", function (self)
                GameTooltip:Hide()
            end)
            startBidAmountBtn:SetScript("OnClick", function (self)
                if ZL.FloatAuctionFrame.index ~= v then
                    ZL.FloatAuctionFrame:Hide()
                    ZL.FloatAuctionFrame.index = v
                    ZL.FloatAuctionFrame:Show()
                else
                    if ZL.FloatAuctionFrame:IsShown() then
                        ZL.FloatAuctionFrame:Hide()
                    else
                        ZL.FloatAuctionFrame.index = v
                        ZL.FloatAuctionFrame:Show()
                    end
                end
            end)
            
            startbidHeaderBtn:SetWidth(startbidFrame:GetWidth())

            infoColumnWidth, bidderColumnWidth, startbidColumnWidth = infoFrame:GetWidth(), 130, startbidFrame:GetWidth()

            local totalWidth = infoColumnWidth + bidderColumnWidth --固定最小尺寸
            local function updateUI(width)
                if PlayerIsML() then
                    if ZL.opt.startbidColumnHide then
                        startbidFrame:Hide()
                    else
                        local width1 = totalWidth + startbidColumnWidth
                        if width >= width1 then
                            startbidFrame:Show()
                        else
                            startbidFrame:Hide()
                        end
                    end
                else
                    startbidFrame:Hide()
                end
                if startbidFrame:IsShown() then
                    startBidAmountBtn:Hide()
                else
                    startBidAmountBtn:Show()
                end
                do
                    if ZL.opt.itemLevelHide then
                        timerBtn.level:Hide()
                    else
                        timerBtn.level:Show()
                    end

                    if ZL.opt.itemCountHide then
                        timerBtn.count:Hide()
                    else
                        timerBtn.count:Show()
                    end

                    if ZL.opt.itemIndexHide then
                        timerBtn.itemindex:Hide()
                    else
                        timerBtn.itemindex:Show()
                    end

                    if ZL.opt.itemNameHide then
                        infoFrame.itemName:Hide()
                    else
                        infoFrame.itemName:Show()
                    end
                end

                -- if infoFrame.itemName:IsShown() then
                --     sb:SetPoint("TOPLEFT", infoFrame.itemName, "BOTTOMLEFT", 0, -1)
                --     sb:SetPoint("BOTTOMRIGHT", infoFrame.itemName, "BOTTOMRIGHT", 8, -20)
                -- else
                --     sb:SetPoint("TOPLEFT", infoFrame.itemName, "TOPLEFT", 0, -2)
                --     sb:SetPoint("BOTTOMRIGHT", infoFrame.itemName, "BOTTOMRIGHT", 8, -20)
                -- end
                bidderFrame:ClearAllPoints()
                bidderFrame:SetPoint("TOPLEFT", infoFrame, "TOPRIGHT")
                local offsetY = PlayerIsML() and 21 or 0
                local relativeTo = startbidFrame:IsShown() and startbidFrame or Frame1
                local relativePoint = startbidFrame:IsShown() and "BOTTOMLEFT" or "BOTTOMRIGHT"
                bidderFrame:SetPoint("BOTTOMRIGHT", relativeTo, relativePoint, 0, offsetY)
            end
            Frame1:SetScript("OnShow", function (self)
                local width = self:GetWidth()
                updateUI(width)
            end)
            Frame1:SetScript("OnSizeChanged", function (self, width)
                updateUI(width)
            end)
            function Frame1:SetValues(index)
                self.index = index  --框架在数组中的索引
                local curAuction = ZL_CURRENT.auctionlist[index]
                local itemId = curAuction.itemId
                local itemlink = curAuction.itemlink
                local itemindex = curAuction.itemindex
                local state = curAuction.state
                local startbidamount = curAuction.startbidamount
                local bidIncrement = curAuction.bidIncrement
                local countdownremaining = (curAuction.endTime or 0) - time()
                local isPaused = curAuction.isPaused
                local itemCount = curAuction.itemCount
                local bidderlist = curAuction.bidderlist
                local lgnore = curAuction.lgnore
                local itemSubType = curAuction.itemSubType
                local bindType = curAuction.bindType
                local itemLevel = curAuction.itemLevel
                local isPackage = curAuction.isPackage
                local selectCharKey = ZL.GetClassColorName() .. " - " .. GetRealmName()
                if (not ZL.opt.concernList) or (not ZL.opt.concernList[selectCharKey]) or
                (not ZL.opt.concernList[selectCharKey]["itemList"][itemId]) then
                    self.infoFrame.timerBtn.concern:Hide()
                else
                    self.infoFrame.timerBtn.concern:Show()
                    curAuction.lgnore = false
                end
                --bindType == 2 表示装绑
                local _itemlink = itemlink
                if itemlink == "[打包拍卖]" then _itemlink = "|cff0000ff[打包拍卖]|r" end
                if itemLevel and itemLevel > 0 then
                    timerBtn.level:SetText(tostring(itemLevel))
                else
                    timerBtn.level:SetText(" ")
                end
                if itemSubType then
                    buweiString:SetTextScale(1)
                    if bindType == 2 then
                        buweiString:SetText("|cffffd100" .. itemSubType .. "|r")
                    else
                        buweiString:SetText(itemSubType)
                    end
                    do
                        local bili = buweiString:GetWidth()/(buweiString:GetUnboundedStringWidth()+5)
                        if bili < 1 then
                            buweiString:SetTextScale(bili)
                        else
                            buweiString:SetTextScale(1)
                        end
                    end
                else
                    buweiString:SetText(" ")
                end
                if itemCount ~= 1 then
                    timerBtn.count:SetText(tostring(itemCount))
                else
                    timerBtn.count:SetText(" ")
                end

                if itemindex ~= 1 then
                    timerBtn.itemindex:SetText(tostring(itemindex))
                else
                    timerBtn.itemindex:SetText(" ")
                end
                infoFrame.itemName:SetTextScale(1)
                infoFrame.itemName:SetText(_itemlink)
                local bili = infoFrame.itemName:GetWidth()/(infoFrame.itemName:GetUnboundedStringWidth()+5)
                if bili < 1 then
                    infoFrame.itemName:SetTextScale(bili)
                else
                    infoFrame.itemName:SetTextScale(1)
                end
                if itemId ~= 0 then
                    icon:SetTexture(cGetItemIcon(itemId)) --   C_Item.GetItemIconByID不需要先缓存，C_Item.GetItemInfo需要先缓存
                    local itemTotalCount = select(4, ZL.GetItemNumbers(itemId))
                    if itemTotalCount > 0 then
                        itemNumbersIcon:SetTexture([[interface/raidframe/readycheck-ready]])
                    else
                        itemNumbersIcon:SetTexture()
                    end
                else
                    icon:SetTexture(ZL.LogoPath2)
                    itemNumbersIcon:SetTexture()
                end

                startbidEditbox:SetNumber(startbidamount)
                incrementEditbox:SetNumber(bidIncrement)

                if lgnore then
                    lgnoreBtn:SetText("恢复")
                else
                    lgnoreBtn:SetText("忽略")
                end
                if state == "waiting" or state == "failed" then
                    Frame1.auctioningFrame:Hide()
                    Frame1.icon:Hide()
                    if Frame1.countDownTimer then
                        if not Frame1.countDownTimer:IsCancelled() then
                            Frame1.countDownTimer:Cancel()
                        end
                        Frame1.countDownTimer = nil
                    end
                    curAuction.confirmBid = nil
                    curAuction.canUseConfirgBid = nil
                    if state == "waiting" then
                        timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
                        timeString:SetTextColor(0.95, 0.95, 0.95, 1)
                        timeString:SetText("待拍卖")
                        bidBtn:Disable()
                        bidBtn:SetText("出价")
                    elseif state == "failed" then
                        timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
                        timeString:SetTextColor(0.95, 0.95, 0.95, 1)
                        timeString:SetText("|cffff0000流拍！|r")
                        if PlayerIsML() then
                            bidBtn:Disable()
                            bidBtn:SetText("出价")
                        else
                            bidBtn:Enable()
                            bidBtn:SetText("重拍")
                        end
                        
                    end
                    playerNameString:SetText("|cff00ff00起拍价:|r" .. ZL.formatNumber(startbidamount))
                    bidEditBox:SetNumber(startbidamount)
                    bidEditBox:Disable()

                    Frame1.maxAutoBid = nil
                    lgnoreBtn:Enable()
                    PauseBtn:SetNormalTexture(137047)
                    -- PauseBtn:Disable()
                    CancelBtn:SetNormalTexture(130866)
                    CancelBtn:Enable()
                    -- CountDownBtn:Disable()
                    reverseBidBtn:Disable()
                    sb:SetMinMaxValues(0, 1)
                    sb:SetValue(0)
                elseif (state == "auctioning") then
                    Frame1.auctioningFrame:Show()
                    if countdownremaining > 0 then
                        sb:SetValue(countdownremaining)
                        timeString:SetText(ConvertSecondsToTime(countdownremaining))
                        if not Frame1.countDownTimer then
                            Frame1.countDownTimer = C_Timer.NewTicker(1, function (self)
                                AuctionFrame:CountDown(v)
                            end)
                        end
                    end
                    if isPaused then
                        timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
                        timeString:SetTextColor(0.95, 0.95, 0.95, 1)
                        timeString:SetText("|cffff0000暂停中|r")
                        bidEditBox:Disable()
                        bidBtn:Disable()
                        if self.maxAutoBid then
                            bidBtn:SetText("停止")
                            lgnoreBtn:Disable()
                        else
                            bidBtn:SetText("出价")
                            lgnoreBtn:Enable()
                        end
                        PauseBtn:SetNormalTexture(130866)
                        PauseBtn:Enable()
                    else
                        if ZL.IsCandidate(index) then
                            if self.maxAutoBid then
                                bidEditBox:Disable()
                                bidBtn:Enable()
                                bidBtn:SetText("停止")
                                lgnoreBtn:Disable()
                            else
                                bidEditBox:Enable()
                                bidBtn:Enable()
                                bidBtn:SetText("出价")
                                lgnoreBtn:Enable()
                            end
                        else
                            timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
                            timeString:SetTextColor(0.95, 0.95, 0.95, 1)
                            timeString:SetText("|cffff0000无法竞拍|r")
                            bidEditBox:Disable()
                            bidBtn:Disable()
                            bidBtn:SetText("出价")
                            lgnoreBtn:Enable()
                        end
                        PauseBtn:SetNormalTexture(137047)
                        PauseBtn:Enable()
                    end
                    local auctionTimer = ZL_CURRENT.globalConfig.auctionTimer
                    local auctionTimerRefresh = ZL_CURRENT.globalConfig.auctionTimerRefresh
                    if bidderlist and (#bidderlist > 0) then --如果有人出价
                        if countdownremaining > 6 then
                            sb:SetMinMaxValues(0, auctionTimerRefresh)
                        else
                            sb:SetMinMaxValues(0, 6)
                        end
                        tableSort(bidderlist)
                        local bidderText = ""
                        local totalBidCount = 0
                        local isBidder, isSuccess
                        for num, bidData in ipairs(bidderlist) do
                            if totalBidCount < itemCount then
                                local count = bidData["bidCount"] or 1
                                local newTotalBidCount = totalBidCount + count
                                if newTotalBidCount > itemCount then
                                    count = itemCount - totalBidCount
                                end
                                if ParseClassColorName(bidData["bidder"]) == ZL.GetFullName() then
                                    isBidder = true
                                    isSuccess = true
                                    if num == 1 then
                                        if count > 1 then
                                            bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r"
                                        else
                                            bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r"
                                        end
                                    else
                                        if count > 1 then
                                            bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r\n" .. bidderText
                                        else
                                            bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r\n" .. bidderText
                                        end
                                    end
                                else
                                    if ZL_CURRENT.globalConfig.auctionMode == "|cffff0000匿名|r" then
                                        if num == 1 then
                                            if count > 1 then
                                                bidderText = "*|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r"
                                            else
                                                bidderText = "*|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r"
                                            end
                                        else
                                            if count > 1 then
                                                bidderText = bidderText .. "\n*|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r"
                                            else
                                                bidderText = bidderText .. "\n*|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r"
                                            end
                                        end
                                    else
                                        local _bidder = ZL.GetNoRealmName(bidData.bidder, true)
                                        if num == 1 then
                                            if count > 1 then
                                                bidderText = _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r"
                                            else
                                                bidderText = _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r"
                                            end
                                        else
                                            if count > 1 then
                                                bidderText = bidderText .. "\n" .. _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r"
                                            else
                                                bidderText = bidderText .. "\n" .. _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r"
                                            end
                                        end
                                    end
                                end
                                totalBidCount = newTotalBidCount
                            else
                                if ParseClassColorName(bidData["bidder"]) == ZL.GetFullName() then
                                    isBidder = true
                                end
                            end
                        end
                        if isBidder then
                            if isSuccess then
                                Frame1.icon:SetTexture([[Interface\AddOns\AutoAuction\Images\victory.tga]])
                            else
                                Frame1.icon:SetTexture([[Interface\AddOns\AutoAuction\Images\tears.tga]])
                            end
                            Frame1.icon:Show()
                        else
                            Frame1.icon:Hide()
                        end
                        playerNameString:SetText(bidderText)
                    else
                        if countdownremaining > 6 then
                            sb:SetMinMaxValues(0, auctionTimer)
                        else
                            sb:SetMinMaxValues(0, 6)
                        end
                        Frame1.icon:Hide()
                        playerNameString:SetText("|cff00ff00起拍价:|r" .. ZL.formatNumber(startbidamount))
                    end
                    PauseBtn:Enable()
                    CancelBtn:Enable()
                    CancelBtn:SetNormalTexture(137048)
                    CountDownBtn:Enable()
                    reverseBidBtn:Enable()
                elseif state == "success" then
                    Frame1.auctioningFrame:Hide()
                    if Frame1.countDownTimer then
                        if not Frame1.countDownTimer:IsCancelled() then
                            Frame1.countDownTimer:Cancel()
                        end
                        Frame1.countDownTimer = nil
                    end
                    curAuction.confirmBid = nil
                    curAuction.canUseConfirgBid = nil
                    timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
                    timeString:SetTextColor(0.95, 0.95, 0.95, 1)
                    timeString:SetText("|cff00ff00成功|r")
                    if bidderlist and (#bidderlist > 0) then --如果有人出价
                        tableSort(bidderlist)
                        local bidderText = ""
                        local totalBidCount = 0
                        local isBidder, isSuccess
                        local tradeId = curAuction.tradeId
                        for num, bidData in ipairs(bidderlist) do
                            if totalBidCount < itemCount then
                                local count = bidData["bidCount"] or 1
                                local newTotalBidCount = totalBidCount + count
                                if newTotalBidCount > itemCount then
                                    count = itemCount - totalBidCount
                                end
                                if PlayerIsML() then
                                    if ParseClassColorName(bidData["bidder"]) == ZL.GetFullName() then
                                        isBidder = true
                                        isSuccess = true
                                        if num == 1 then
                                            if count > 1 then
                                                bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r"
                                            else
                                                bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r"
                                            end
                                        else
                                            if count > 1 then
                                                bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r\n" .. bidderText
                                            else
                                                bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r\n" .. bidderText
                                            end
                                        end
                                    else
                                        local isTraded = format("|cff87CEEB|Hgarrmission:%s:%s:%s|h%s|h|r", "AutoAuction", "TRADEITEM", ParseClassColorName(bidData.bidder), "交易")
                                        for _, incomeData in ipairs(ZL_CURRENT.IncomeList) do
                                            if incomeData.tradeId == tradeId and incomeData.player == bidData.bidder then
                                                if incomeData.itemList[itemlink] and incomeData.itemList[itemlink].isTraded then
                                                    isTraded = ""
                                                end
                                            end
                                        end
                                        local _bidder = ZL.GetNoRealmName(bidData.bidder, true)
                                        if num == 1 then
                                            if count > 1 then
                                                bidderText = _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. isTraded .. ")|r"
                                            else
                                                bidderText = _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. isTraded .. ")|r"
                                            end
                                        else
                                            if count > 1 then
                                                bidderText = bidderText .. "\n" .. _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. isTraded .. ")|r"
                                            else
                                                bidderText = bidderText .. "\n" .. _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. isTraded .. ")|r"
                                            end
                                        end
                                    end
                                else
                                    if ParseClassColorName(bidData["bidder"]) == ZL.GetFullName() then
                                        isBidder = true
                                        isSuccess = true
                                        if num == 1 then
                                            if count > 1 then
                                                bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r"
                                            else
                                                bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r"
                                            end
                                        else
                                            if count > 1 then
                                                bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r\n" .. bidderText
                                            else
                                                bidderText = "你|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r\n" .. bidderText
                                            end
                                        end
                                    else
                                        local _bidder = ZL.GetNoRealmName(bidData.bidder, true)
                                        if num == 1 then
                                            if count > 1 then
                                                bidderText = _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r"
                                            else
                                                bidderText = _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r"
                                            end
                                        else
                                            if count > 1 then
                                                bidderText = bidderText .. "\n" .. _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. "x" .. count .. ")|r"
                                            else
                                                bidderText = bidderText .. "\n" .. _bidder .. "|cffffd100(" .. ZL.formatNumber(bidData.bidamount) .. ")|r"
                                            end
                                        end
                                    end
                                end
                                totalBidCount = newTotalBidCount
                            else
                                if ParseClassColorName(bidData["bidder"]) == ZL.GetFullName() then
                                    isBidder = true
                                end
                            end
                            if isBidder then
                                if isSuccess then
                                    Frame1.icon:SetTexture([[Interface\AddOns\AutoAuction\Images\victory.tga]])
                                else
                                    Frame1.icon:SetTexture([[Interface\AddOns\AutoAuction\Images\tears.tga]])
                                end
                                Frame1.icon:Show()
                            else
                                Frame1.icon:Hide()
                            end
                        end
                        playerNameString:SetText(bidderText)
                        -- bidderFrame:SetText(bidderText)
                    end
                    bidEditBox:SetNumber(startbidamount)
                    bidEditBox:Disable()
                    bidBtn:Disable()
                    bidBtn:SetText("出价")
                    Frame1.maxAutoBid = nil
                    lgnoreBtn:Enable()
                    PauseBtn:SetNormalTexture(137047)
                    -- PauseBtn:Disable()
                    CancelBtn:SetNormalTexture(130866)
                    CancelBtn:Enable()
                    -- CountDownBtn:Disable()
                    reverseBidBtn:Enable()
                    sb:SetMinMaxValues(0, 1)
                    sb:SetValue(0)
                end
            end
            t[v] = Frame1
            return Frame1
        end
    })

    local function AuctionFrameSizeChange(width)
        local totalWidth = infoColumnWidth + bidderColumnWidth + 22 --固定最小尺寸
        AuctionFrame.scrollFrame.content:SetWidth(width-AuctionFrame.scrollFrame.ScrollBar:GetWidth())
        if PlayerIsML() then
            if ZL.opt.startbidColumnHide then
                startbidHeaderBtn:Hide()
            else
                local width1 = totalWidth + startbidColumnWidth
                if width >= width1 then
                    startbidHeaderBtn:Show()
                else
                    startbidHeaderBtn:Hide()
                end
            end
        else
            startbidHeaderBtn:Hide()
        end
        bidderHeaderBtn:ClearAllPoints()
        bidderHeaderBtn:SetPoint("TOPLEFT", iconHeaderBtn, "TOPRIGHT", 0, 0)
        if startbidHeaderBtn:IsShown() then
            bidderHeaderBtn:SetPoint("BOTTOMRIGHT", startbidHeaderBtn, "BOTTOMLEFT", 1, 0)
            ZL.FloatAuctionFrame:Hide()
        else
            bidderHeaderBtn:SetPoint("TOPRIGHT", AuctionFrame.TitleBottom, "BOTTOMRIGHT", -20, -titleBottomGapHeight)
        end
    end
    AuctionFrame.scrollFrame:SetScript("OnSizeChanged", function (self, width)
        AuctionFrameSizeChange(width)
    end)
    function AuctionFrame:CountDown(_index)
        local curAuction = ZL_CURRENT.auctionlist[_index]
        local Frame1 = AuctionFrame.entries[_index]
        local sb = Frame1.infoFrame.sb
        local timeString = sb.timeString
        if curAuction.isPaused then
            timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            timeString:SetText("|cffff0000暂停中|r")
            return
        end
        local itemId = curAuction.itemId
        local itemlink = curAuction.itemlink
        local itemindex = curAuction.itemindex
        local countdownremaining = (curAuction.endTime or 0) - time()
        local bidderlist = curAuction.bidderlist
        countdownremaining = countdownremaining > 0 and countdownremaining  or 0
        sb:SetValue(countdownremaining)
        local isCandidate = ZL.IsCandidate(_index)
        if isCandidate then
            timeString:SetText(ConvertSecondsToTime(countdownremaining))
        else
            timeString:SetText("|cffff0000无法竞拍|r")
        end
        if countdownremaining > 59 then
            timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            timeString:SetTextColor(0.95, 0.95, 0.95, 1)
            sb:SetStatusBarColor(0.68, 0.87, 0.68)
        elseif countdownremaining > 5 then
            if isCandidate then
                timeString:SetFont(GameFontNormal:GetFont(), 28, "OUTLINE")
            else
                timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            end
            timeString:SetTextColor(0, 1, 0, 1)
            sb:SetStatusBarColor(0.55, 0, 0)
        elseif countdownremaining > 0 then
            if isCandidate then
                timeString:SetFont(GameFontNormal:GetFont(), 28, "OUTLINE")
            else
                timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            end
            timeString:SetTextColor(0, 1, 0, 1)
            sb:SetStatusBarColor(0.55, 0, 0)
            -- 5秒倒数
            local msgStr = ""
            tableSort(bidderlist)
            if #bidderlist > 0 then
                local totalBidCount = 0
                for _, bidData in ipairs(bidderlist) do
                    if totalBidCount < curAuction.itemCount then
                        local count = bidData["bidCount"] or 1
                        local newTotalBidCount = totalBidCount + count
                        if newTotalBidCount > curAuction.itemCount then
                            count = curAuction.itemCount - totalBidCount
                        end
                        if ZL_CURRENT.globalConfig.auctionMode == "|cffff0000匿名|r" then
                            if count  > 1 then
                                msgStr = msgStr .. "匿名(" .. bidData.bidamount .. "x" .. count .. ")，"
                            else
                                msgStr = msgStr .. "匿名(" .. bidData.bidamount .. ")，"
                            end
                        else
                            if count  > 1 then
                                msgStr = msgStr .. ZL.GetNoRealmName(bidData.bidder) .. "(" .. bidData.bidamount .. "x" .. count .. ")，"
                            else
                                msgStr = msgStr .. ZL.GetNoRealmName(bidData.bidder) .. "(" .. bidData.bidamount .. ")，"
                            end
                        end
                        totalBidCount = newTotalBidCount
                    else
                        break
                    end
                end
                if not ZL_CURRENT.globalConfig.allowMultipleAuctions then
                    msgStr = ("%s倒数：%d"):format(msgStr, countdownremaining)
                else
                    msgStr = ("%s%s倒数：%d"):format(curAuction.itemlink, msgStr, countdownremaining)
                end
            else
                if not ZL_CURRENT.globalConfig.allowMultipleAuctions then
                    msgStr = ("无人出价，倒数：%d" ):format(countdownremaining)
                else
                    msgStr = ("%s无人出价，倒数：%d" ):format(curAuction.itemlink, countdownremaining)
                end
            end
            ZL.Print(msgStr)
            if PlayerIsML() then
                SendChatMessage(msgStr, ZL.MsgChannel())
            end
            if ZL.opt.IsVoiceReminder and (((not ZL_CURRENT.globalConfig) or (not ZL_CURRENT.globalConfig.YYSound)) or PlayerIsML()) then
                C_VoiceChat.StopSpeakingText()
                local auctioningCount = GetAuctioningCount()
                if not ZL_CURRENT.globalConfig.allowMultipleAuctions or auctioningCount then
                    PlaySoundFile("Interface\\AddOns\\" .. addonName .. "\\sound\\" .. ZL.SoundType .. "\\count\\" .. tostring(countdownremaining) .. ".mp3", "Master")
                end
            end
        else
            if Frame1.countDownTimer then
                Frame1.countDownTimer:Cancel()
                Frame1.countDownTimer = nil
            end
            curAuction.confirmBid = nil
            curAuction.canUseConfirgBid = nil
            curAuction.endTime = nil
            curAuction.index = nil
            timeString:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            timeString:SetTextColor(0.95, 0.95, 0.95, 1)
            sb:SetStatusBarColor(0.68, 0.87, 0.68)
            local msgStr = ""
            local info
            if bidderlist and #bidderlist > 0 then --如果有人出价
                tableSort(bidderlist)
                local isSelf = false
                local failedSpawnUIDList = {}
                local successSpawnUIDList = {}
                local successBidderList = {}
                local successBidderCount = 0
                local successIndex
                for _successIndex, bidData in ipairs(bidderlist) do
                    if successBidderCount < curAuction.itemCount then
                        local count = bidData["bidCount"] or 1
                        if (successBidderCount + count) >= curAuction.itemCount then
                            count = curAuction.itemCount - successBidderCount
                            ZL_CURRENT.auctionlist[_index].bidderlist[_successIndex].bidCount = count
                        end
                        successIndex = _successIndex
                        successBidderCount = successBidderCount + count
                        if PlayerIsML(bidData.bidder) then
                            isSelf = true
                            --ML拍到的物品直接记录到已支付
                            if not ZL_CURRENT.playerPayToML then ZL_CURRENT.playerPayToML = {} end
                            local oldPayToML = ZL_CURRENT.playerPayToML[bidData.bidder] and ZL_CURRENT.playerPayToML[bidData.bidder] or 0
                            ZL_CURRENT.playerPayToML[bidData.bidder] = oldPayToML + bidData.bidamount*bidData.bidCount
                            ZL.AuctionRecordFrame.playerBalanceFrame:Update()
                        end
                        if count == 1 then
                            msgStr = msgStr .. ZL.GetNoRealmName(bidData.bidder) .. "(" .. bidData.bidamount .. ")，"
                        else
                            msgStr = msgStr .. ZL.GetNoRealmName(bidData.bidder) .. "(" .. bidData.bidamount .. "x" .. count .. ")，"
                        end
                        --判断获胜者可以交易哪几个物品
                        if curAuction["spawnUID"] and next(curAuction["spawnUID"], nil) then
                            local linshiList = {[bidData.bidder]={}}
                            for key, spawnData in pairs(curAuction["spawnUID"]) do
                                if (not spawnData["candidates"]) or (not next(spawnData["candidates"], nil)) or (spawnData["candidates"][bidData.bidder] == true) then
                                    tinsert(linshiList[bidData.bidder], key)
                                end
                            end
                            linshiList.spawnUIDCount = #linshiList[bidData.bidder]
                            tinsert(successBidderList, linshiList)
                        end
                    else
                        break
                    end
                end
                curAuction = ZL_CURRENT.auctionlist[_index]
                --按照可交易物品数量升序排列，交易物品数量少的优先选择
                table.sort(successBidderList, function (a, b)
                    return a.spawnUIDCount < b.spawnUIDCount
                end)
                --将获胜者数据添加到收支数据库
                local tradeId = tostring(curAuction.itemId) .. tostring(time())
                ZL_CURRENT.auctionlist[_index].tradeId = tradeId
                local stackCount = curAuction.stackCount
                local itmeGUIDUsedList = {}
                if not ZL_CURRENT["IncomeList"] then ZL_CURRENT["IncomeList"] = {} end
                for i = 1, successIndex do
                    local itemGUID
                    local name = bidderlist[i].bidder
                    local bidCount = bidderlist[i].bidCount
                    local hasCount = 0
                    if #successBidderList > 0 then
                        for _, data in ipairs(successBidderList) do
                            local isBreak
                            if data[name] and #data[name] > 0 then
                                for _, spawnkey in ipairs(data[name]) do
                                    local spawnData = curAuction["spawnUID"][spawnkey]
                                    if stackCount == 1 then
                                        if not spawnData["successBidder"] then
                                            spawnData["successBidder"] = {
                                                [name] = {
                                                    count = 1,
                                                    amount = bidderlist[i]["bidamount"], --因为数量是1，所以要填单价
                                                },
                                            }
                                            for key, value in pairs(spawnData["itemGUID"]) do
                                                if not itmeGUIDUsedList[key] then
                                                    itemGUID = key
                                                    itmeGUIDUsedList[key] = true
                                                    value["isUsed"] = name
                                                    break
                                                end
                                            end
                                            hasCount = hasCount + 1
                                        end
                                    else
                                        --堆叠数大于1，拾取绑定的物品目前是橙片，会提前分配给获胜者
                                        --堆叠数大于1，统一放在“其他”里面，只有一个spawnkey
                                        if not spawnData["successBidder"] then spawnData["successBidder"] = {} end
                                        spawnData["successBidder"][name] = {
                                            count = bidCount,
                                            amount = bidderlist[i]["bidamount"] * bidCount,
                                        }
                                        for key, value in pairs(spawnData["itemGUID"]) do
                                            if not itmeGUIDUsedList[key] then
                                                itemGUID = key
                                                itmeGUIDUsedList[key] = true
                                                value["isUsed"] = name
                                                break
                                            end
                                        end
                                        local bagID, slotIndex = ZL.FindItemInBag(itemGUID)
                                        if bagID and slotIndex then
                                            info = C_Container.GetContainerItemInfo(bagID, slotIndex)
                                            hasCount = hasCount + info.stackCount
                                        end
                                    end
                                    if hasCount >= bidCount then
                                        --如果已经分配的数量大于竞拍数量，需要将此堆物品进行分堆，待完善
                                        isBreak = true
                                        break
                                    end
                                end
                            end
                            if isBreak then break end
                        end
                    end
                    curAuction = ZL_CURRENT.auctionlist[_index]
                    local itemList = {}
                    if curAuction.itemlink == "[打包拍卖]" then
                        itemList = curAuction.itemList
                        for _itemlink, _ in pairs(itemList) do
                            itemList[_itemlink].isTraded = (curAuction.itemId==45038 or curAuction.itemId==50274 or PlayerIsML(name)) and true or false
                        end
                    else
                        local itemGUIDList = {}
                        local spawnUIDList = {}
                        for key, value in pairs(curAuction["spawnUID"]) do
                            if value["successBidder"] and value["successBidder"][name] then
                                if not spawnUIDList[key] then spawnUIDList[key]= {} end
                                spawnUIDList[key]["bossName"] = value["bossName"]
                                if value["itemGUID"] and next(value["itemGUID"], nil) then
                                    for itemGUID_key, itemGUID_value in pairs(value["itemGUID"]) do
                                        if itemGUID_value["isUsed"] == name then
                                            tinsert(itemGUIDList, itemGUID_key)
                                        end
                                    end
                                end
                            end
                        end
                        itemList[itemlink] = {
                            itemCount = bidderlist[i].bidCount,
                            stackCount = curAuction.stackCount,
                            itemindex = {itemindex},
                            itemGUID = itemGUIDList,
                            spawnUID = spawnUIDList,
                            isTraded = (curAuction.itemId==45038 or curAuction.itemId==50274 or PlayerIsML(name)) and true or false,
                        }
                    end
                    tinsert(ZL_CURRENT["IncomeList"], {
                        player=name, amount=bidderlist[i].bidamount*bidderlist[i].bidCount, notes=itemlink,
                        tradeId = tradeId, itemList = itemList,itemCount = bidderlist[i].bidCount
                    })
                end
                ZL.AuctionRecordFrame.currentIncomeFrame:Update()
                ZL.AuctionRecordFrame.playerBalanceFrame:Update()
                if PlayerIsML() and isSelf then
                    local selfList = {}
                    for _, value in pairs(curAuction["spawnUID"]) do
                        if value["itemGUID"] and next(value["itemGUID"], nil) then
                            for itemGUID_key, itemGUID_value in pairs(value["itemGUID"]) do
                                if itemGUID_value.isUsed == GetClassColorName(UnitName("player")) then
                                    --将自己拍卖到的物品添加到数据库，交易剩余时间提醒的时候过滤
                                    if not ZL_CURRENT.SelfAuction then ZL_CURRENT.SelfAuction = {} end
                                    ZL_CURRENT.SelfAuction[itemGUID_key] = true
                                    tinsert(selfList, itemGUID_key)
                                end
                            end
                        end
                    end
                    local selfIndex = 1
                    --自己拍卖到的物品放到指定背包
                    local function linshi()
                        if selfIndex <= #selfList then
                            if not (InCombatLockdown() or UnitIsDeadOrGhost("player")) then
                                local itemGUID_key = selfList[selfIndex]
                                ZL.PutAuctionItemInBag(itemGUID_key, ZL.opt.selfBagId, ZL.opt.selfDirection)
                                selfIndex = selfIndex + 1
                                
                            end
                            C_Timer.After(0.5, linshi)
                        end
                    end
                    linshi()
                end
                --如果获胜物品总数小于拍卖物品数量则拆单，没拍卖的创建流拍
                if successBidderCount < curAuction.itemCount then
                    if stackCount == 1 then
                        for key, value in pairs(curAuction["spawnUID"]) do
                            if (not value["successBidder"]) or (value["successBidder"] and (not next(value["successBidder"], nil))) then
                                failedSpawnUIDList[key] = {
                                    ["bossName"] = value["bossName"],
                                    ["itemGUID"] = value["itemGUID"],
                                }
                            else
                                successSpawnUIDList[key] = value
                            end
                        end
                    else
                        for key, value in pairs(curAuction["spawnUID"]) do
                            if not failedSpawnUIDList[key] then failedSpawnUIDList[key] = {["bossName"] = value["bossName"], ["itemGUID"]={}} end
                            if value["itemGUID"] and next(value["itemGUID"], nil) then
                                for itemGUID_key, itemGUID_value in pairs(value["itemGUID"]) do
                                    if not itemGUID_value["isUsed"] then
                                        failedSpawnUIDList[key]["itemGUID"][itemGUID_key] = {}
                                    end
                                end
                            end
                            successSpawnUIDList[key] = value
                            if successSpawnUIDList[key]["itemGUID"] and next(successSpawnUIDList[key]["itemGUID"], nil) then
                                for _, itemGUID_value in pairs(successSpawnUIDList[key]["itemGUID"]) do
                                    if not itemGUID_value["isUsed"] then
                                        itemGUID_value = nil
                                    end
                                end
                            end
                        end
                    end

                    local liuPaiItemCount = curAuction.itemCount - successBidderCount
                    local data = {}
                    ZL_CURRENT.auctionlist[_index].state = "success"
                    ZL_CURRENT.auctionlist[_index].endTime = nil
                    ZL_CURRENT.auctionlist[_index].itemCount = successBidderCount
                    ZL_CURRENT.auctionlist[_index].spawnUID = successSpawnUIDList
                    Frame1:SetValues(_index)
                    data = {
                        type = "拍卖成功",
                        data2 = ZL_CURRENT.auctionlist[_index],
                    }
                    --开始创建流拍拍卖记录
                    local _itemindex = 1
                    if ZL_CURRENT.auctionlist and (#ZL_CURRENT.auctionlist > 0) then
                        for _, _data in ipairs(ZL_CURRENT.auctionlist) do
                            if (_data.itemlink == itemlink) then
                                _itemindex = _itemindex + 1
                            end
                        end
                    end
                    local data2 = ZL_CURRENT.auctionlist[_index]
                    data = {
                        type = "流拍",
                        data2 = {
                            ["type"] = data2.type,
                            ["itemId"] = data2.itemId,
                            ["itemlink"] = data2.itemlink,
                            ["itemindex"] = _itemindex,
                            ["itemCount"] = liuPaiItemCount,
                            ["itemLevel"] = data2.itemLevel,
                            ["bindType"] = data2.bindType,
                            ["startbidamount"] = data2.startbidamount,
                            ["bidIncrement"] = data2.bidIncrement,
                            ["state"] = "failed",
                            ["endTime"] = data2.endTime,
                            ["isPaused"] = data2.isPaused,
                            ["stackCount"] = data2.stackCount,
                            ["spawnUID"] = failedSpawnUIDList,
                            ["bidderlist"] = {},
                            ["sourceGUID"] = data2.sourceGUID,
                            ["tradeId"] = nil,
                            ["lgnore"] = false,
                            ["itemSubType"] = data2.itemSubType,
                            ["createTime"] = date("%Y-%m-%d %H:%M:%S", GetServerTime()),
                        },
                    }
                    tinsert(ZL_CURRENT.auctionlist, data.data2)
                    -- local itemGUIDList = {}
                    -- curAuction= ZL_CURRENT.auctionlist[#ZL_CURRENT.auctionlist]
                    -- for _, value in pairs(curAuction["spawnUID"]) do
                    --     if value["itemGUID"] and next(value["itemGUID"], nil) then
                    --         for itemGUID_key in pairs(value["itemGUID"]) do
                    --             tinsert(itemGUIDList, itemGUID_key)
                    --         end
                    --     end
                    -- end
                    msgStr = ("%s%d个拍卖成功！获胜者：%s祝贺！%d个流拍！"):format(itemlink, successBidderCount, msgStr, liuPaiItemCount)
                    if PlayerIsML() then
                        --将流拍物品放到指定背包
                        ZL.reportFailedItem(true)
                    end
                else
                    ZL_CURRENT.auctionlist[_index].state = "success"
                    ZL_CURRENT.auctionlist[_index].endTime = nil
                    msgStr = ("%s拍卖成功！获胜者：%s祝贺！"):format(itemlink, msgStr)
                end
                if PlayerIsML() then
                    SendChatMessage(msgStr, ZL.MsgChannel())
                end
                ZL.Print(msgStr)
                if ZL.opt.IsVoiceReminder and (((not ZL_CURRENT.globalConfig) or (not ZL_CURRENT.globalConfig.YYSound)) or PlayerIsML()) then
                    C_VoiceChat.StopSpeakingText()
                    PlaySoundFile("Interface\\AddOns\\" .. addonName .. "\\sound\\" .. ZL.SoundType .. "\\paimaichenggong.mp3", "Master")
                end
                timeString:SetText("|cff00FF00成功|r")
            else
                ZL_CURRENT.auctionlist[_index].state = "failed"
                ZL_CURRENT.auctionlist[_index].endTime = nil
                timeString:SetText("|cffff0000流拍|r")
                ZL.Print(itemlink .. "已流拍")
                if ZL.opt.IsVoiceReminder and (((not ZL_CURRENT.globalConfig) or (not ZL_CURRENT.globalConfig.YYSound)) or PlayerIsML()) then
                    C_VoiceChat.StopSpeakingText()
                    PlaySoundFile("Interface\\AddOns\\" .. addonName .. "\\sound\\" .. ZL.SoundType .. "\\wupinyiliupai.mp3", "Master")
                end
                if PlayerIsML() then
                    ZL.reportFailedItem(true)
                    msgStr = ("%s 已流拍！"):format(itemlink)
                    SendChatMessage(msgStr, ZL.MsgChannel())
                end
            end
            ZL.AuctionListSort()
            if info then info = nil end
            if ZL.DisenchantingFrame and (not ZL.DisenchantingFrame.hasSpellcastSucceeded) and ZL.DisenchantingFrame:IsShown() then
                ZL.DisenchantingFrame:Update()
            end
            if PlayerIsML() and (not ZL_CURRENT.globalConfig.allowMultipleAuctions) then _G["ZL_NewAuctionFrameTab5"]:Click() end
            ZL.miniMapIconAnimation()
        end
    end
    function AuctionFrame:Update()
        local height = 0
        local auctionMode
        if IsInRaid(1) then
            if ZL_CURRENT.globalConfig and ZL_CURRENT.globalConfig.auctionMode then
                auctionMode = ZL_CURRENT.globalConfig.auctionMode
            else
                auctionMode = ZL.opt.auctionMode
            end
        else
            auctionMode = ZL.opt.auctionMode
        end
        auctionModeDropdown:SetDefaultText(auctionMode)
        if PlayerIsML() then
            auctionModeDropdown:Enable()
        else
            auctionModeDropdown:Disable()
        end
        for _, f in ipairs(AuctionFrame.entries) do f:Hide() end
        if ZL_CURRENT.auctionlist and (#ZL_CURRENT.auctionlist > 0) then
            for num, data in ipairs(ZL_CURRENT.auctionlist) do
                local f = AuctionFrame.entries[num]
                f:SetValues(num)
                if ItemAuctionFrameIsShown(data) then
                    f:Show()
                    zlHighlightOnHide(num)
                    f:SetPoint("TOPLEFT", content, "TOPLEFT", 2, -height)
                    f:SetPoint("BOTTOMRIGHT", content, "TOPRIGHT", 0, -68-height)
                    if PlayerIsML() and (not data.lgnore) and (not data.isPackage) and data.bindType == 1 and data.stackCount == 1 then -- and data.state == "waiting"
                        f.infoFrame.checkBtn:Show()
                    else
                        f.infoFrame.checkBtn:SetChecked(false)
                        f.infoFrame.checkBtn:Hide()
                    end
                    if PlayerIsML() then
                        f.MLframe.functionFrame:Show()
                    else
                        f.MLframe.functionFrame:Hide()
                    end
                    height = height + f:GetHeight() + 5
                end
            end
        end
        height = height > 0 and height or 50
        content:SetSize(AuctionFrame.scrollFrame:GetWidth()-AuctionFrame.scrollFrame.ScrollBar:GetWidth(), height)
        if not ZL.FloatAuctionFrame.index or not AuctionFrame.entries[ZL.FloatAuctionFrame.index]:IsShown() then
            ZL.FloatAuctionFrame:Hide()
        end
        if not ZL.BidderListFrame.index or not AuctionFrame.entries[ZL.BidderListFrame.index]:IsShown() then
            ZL.BidderListFrame:Hide()
        end
        if ZL.BidderListFrame:IsShown() and ZL.BidderListFrame.index then
            ZL.BidderListFrame:Update(ZL.BidderListFrame.index)
        end
        if ZL.opt.ZLAuctionFrameTabId ~= 1 and GetAuctioningCount() >= 1 then
            StateFrame.AuctioningBtn.SpellHighlightTexture:Show()
            StateFrame.AuctioningBtn.SpellHighlightAnim:Play()
        else
            StateFrame.AuctioningBtn.SpellHighlightTexture:Hide()
            StateFrame.AuctioningBtn.SpellHighlightAnim:Stop()
        end
        AuctionFrameSizeChange(AuctionFrame:GetWidth())
        ZL.miniMapIconAnimation()
        if ZL.BillOverviewFrame and ZL.BillOverviewFrame:IsShown() then
            ZL.BillOverviewFrame:Update()
        end
    end
end

--导出导出字符串窗口
function ZL:CreateWAStringFrame()
    ZL.WaStringFrame = ZLCreateFrame(nil, nil, nil, nil, nil, true, true)
    local WaStringFrame = ZL.WaStringFrame
    WaStringFrame:SetPoint("CENTER")
    WaStringFrame:SetResizable(false)
    WaStringFrame:SetSize(GetScreenWidth()-100, GetScreenHeight()-100)
    WaStringFrame.resizeButton:Hide()
    --创建滚动条
    WaStringFrame.scrollFrame = CreateFrame("ScrollFrame", nil, WaStringFrame, "UIPanelScrollFrameTemplate")
    WaStringFrame.scrollFrame:SetFrameLevel(WaStringFrame:GetFrameLevel() + 1) -- 设置为比父框架高1级
    WaStringFrame.scrollFrame:SetPoint("TOPLEFT", WaStringFrame.TitleBottom, "BOTTOMLEFT", 0, -2)
    WaStringFrame.scrollFrame:SetPoint("BOTTOMRIGHT", WaStringFrame, "BOTTOMRIGHT", 0, 2)
    WaStringFrame.scrollFrame:SetClipsChildren(true) --必须设置为true，scrollFrame所有的子元素才会被剪切
    WaStringFrame.scrollFrame:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel) --重设滑动条鼠标滚轮事件
    --重设ScrollBar位置，放置到scrollFrame内，防止被剪切掉
    WaStringFrame.scrollFrame.ScrollBar:ClearAllPoints()
    WaStringFrame.scrollFrame.ScrollBar:SetPoint("TOPLEFT", WaStringFrame.scrollFrame, "TOPRIGHT", -10, -16)
    WaStringFrame.scrollFrame.ScrollBar:SetPoint("BOTTOMRIGHT", WaStringFrame.scrollFrame, "BOTTOMRIGHT", -10, 15)

    WaStringFrame.scrollFrame.editBox = CreateFrame("EditBox", nil, WaStringFrame.scrollFrame)
    local editBox = WaStringFrame.scrollFrame.editBox
    editBox:SetPoint("TOPLEFT", WaStringFrame.scrollFrame, "TOPLEFT", 0, 0)
    editBox:SetSize(WaStringFrame.scrollFrame:GetWidth()-20, 100)
    WaStringFrame.scrollFrame:SetScrollChild(editBox)
    editBox:EnableMouse(true)
    editBox:SetAutoFocus(true)
    editBox:SetMultiLine(true)
    editBox:HighlightText()
    editBox:SetCursorPosition(0)
    editBox:SetTextInsets(4, 4, 0, 0)
    editBox:SetFont(GameFontNormal:GetFont(), 12, "")
    editBox:SetTextColor(0.95, 0.95, 0.95)
end

--创建显示交易剩余时间窗口
function ZL:CreateZLRemainingTradeTimeFrame()
    ZL.ZLRemainingTradeTimeFrame = CreateFrame("Frame", "ZLRemainingTradeTimeFrame", self, "BackdropTemplate")
    local ZLRemainingTradeTimeFrame = ZL.ZLRemainingTradeTimeFrame
    ZLRemainingTradeTimeFrame:SetSize(200, 50)
    ZLRemainingTradeTimeFrame:SetPoint("CENTER")
    ZLRemainingTradeTimeFrame:SetClampedToScreen(true)
    ZLRemainingTradeTimeFrame:SetFrameStrata("HIGH")
    ZLRemainingTradeTimeFrame:SetMovable(true)
    ZLRemainingTradeTimeFrame:SetScale(ZL.opt.ZLRemainingTradeTimeFrameScale)
    ZLRemainingTradeTimeFrame:SetScript("OnMouseDown", function(self)
        self:StartMoving()
    end)
    ZLRemainingTradeTimeFrame:SetScript("OnMouseUp", function(self)
        self:StopMovingOrSizing()
        if not ZL.db.global.ZLRemainingTradeTimeFrame then ZL.db.global.ZLRemainingTradeTimeFrame = {} end
        ZL.db.global.ZLRemainingTradeTimeFrame.point, _, ZL.db.global.ZLRemainingTradeTimeFrame.relative, ZL.db.global.ZLRemainingTradeTimeFrame.x, ZL.db.global.ZLRemainingTradeTimeFrame.y = self:GetPoint()
    end)
    ZLRemainingTradeTimeFrame:ClearAllPoints()
    if ZL.db.global.ZLRemainingTradeTimeFrame and ZL.db.global.ZLRemainingTradeTimeFrame.point then
        ZLRemainingTradeTimeFrame:SetPoint(ZL.db.global.ZLRemainingTradeTimeFrame.point, UIParent, ZL.db.global.ZLRemainingTradeTimeFrame.relative, ZL.db.global.ZLRemainingTradeTimeFrame.x, ZL.db.global.ZLRemainingTradeTimeFrame.y)
    else
        ZLRemainingTradeTimeFrame:SetPoint("CENTER")
    end
    ZLRemainingTradeTimeFrame.closeButton = CreateFrame("Button", nil, ZLRemainingTradeTimeFrame, "UIPanelCloseButton")
    ZLRemainingTradeTimeFrame.closeButton:SetPoint("TOPLEFT", ZLRemainingTradeTimeFrame, "TOPLEFT", -3, 20)
    ZLRemainingTradeTimeFrame.closeButton:SetSize(20, 20)
    ZLRemainingTradeTimeFrame.closeButton:SetScript("OnClick", function (self)
        ZL.opt.remainingTradeTimeBtnValue = false
        ZLRemainingTradeTimeFrame:Hide()
        if ZL.UpdateRemainingTradeTime then
            ZL.UpdateRemainingTradeTime:Cancel()
        end
    end)
    ZLRemainingTradeTimeFrame.RemainingTradeTimeText = ZLRemainingTradeTimeFrame:CreateFontString()
    local RemainingTradeTimeText = ZLRemainingTradeTimeFrame.RemainingTradeTimeText
    RemainingTradeTimeText:SetFontObject(GameFontHighlightLarge)
    RemainingTradeTimeText:SetSize(200, 75)
    RemainingTradeTimeText:SetPoint("TOPLEFT", ZLRemainingTradeTimeFrame, "TOPLEFT")
    RemainingTradeTimeText:SetFont(GameFontNormal:GetFont(), 12)
    RemainingTradeTimeText:SetWordWrap(true)
    RemainingTradeTimeText:SetJustifyH("LEFT")
    RemainingTradeTimeText:SetJustifyV("TOP")

    if ZL.opt.remainingTradeTimeBtnValue then
        ZLRemainingTradeTimeFrame:Show()
    else
        ZLRemainingTradeTimeFrame:Hide()
    end
   
end
--创建物品拍卖设置框架
function ZL:CreateItemSettingFrame()
    ZL.ItemSettingFrame = ZLCreateFrame("ItemSettingFrame", ZL, nil, nil, nil, true, true, "物品拍卖设置")
    -- ZL.ItemSettingFrame = CreateFrame("Frame", "ItemSettingFrame", ZL, "UIPanelDialogTemplate")
    local ItemSettingFrame = ZL.ItemSettingFrame
    ItemSettingFrame:SetSize(460, 350)
    ItemSettingFrame:SetResizeBounds(460, 350, 460, GetScreenHeight()/ZL.opt.ZLItemSettingFrameScale-110)
    ItemSettingFrame:SetScale(ZL.opt.ZLItemSettingFrameScale)
    -- ItemSettingFrame:SetPoint("CENTER", UIParent, "CENTER")
    -- ItemSettingFrame:SetFrameStrata("DIALOG")
    -- ItemSettingFrame:SetClampedToScreen(true)  --不能超出游戏屏幕，false可以超出游戏屏幕
    -- ItemSettingFrame:SetMovable(true)
    -- ItemSettingFrame:SetToplevel(true)
    -- ItemSettingFrame:SetHitRectInsets(0, 0, 0, ItemSettingFrameDialogBG:GetHeight()+3) --设置鼠标可点击区域
    
    ItemSettingFrame:SetScript("OnMouseUp", function (self)
        self:StopMovingOrSizing()
        if not ZL.db.global.ZLItemSettingFrame then ZL.db.global.ZLItemSettingFrame = {} end
        ZL.db.global.ZLItemSettingFrame.point, _, ZL.db.global.ZLItemSettingFrame.relative, ZL.db.global.ZLItemSettingFrame.x, ZL.db.global.ZLItemSettingFrame.y = self:GetPoint()
    end)
    ItemSettingFrame:SetScript("OnMouseDown", function (self)
        self:StartMoving()
    end)
    ItemSettingFrame:SetScript("OnShow", function (self)
        ZL.opt.ItemSettingFrameIsShown = true
        self.itemIdFrame:Update()
        self.itemLevelFrame:Update()
        self.filterFrame:Update()
    end)
    local resizeButton = ItemSettingFrame.resizeButton
    -- 设置鼠标按下时开始调整大小
    resizeButton:SetScript("OnMouseDown", function(self, button)
        if button == "LeftButton" then
            ItemSettingFrame:StartSizing("BOTTOMRIGHT")
        end
    end)
    -- 鼠标松开时停止调整大小
    resizeButton:SetScript("OnMouseUp", function(self)
        ItemSettingFrame:StopMovingOrSizing()
        if not ZL.db.global.ZLItemSettingFrame then ZL.db.global.ZLItemSettingFrame = {} end
        ZL.db.global.ZLItemSettingFrame.Width,  ZL.db.global.ZLItemSettingFrame.Height= ItemSettingFrame:GetSize()
    end)
    ItemSettingFrame.closeButton:HookScript("OnClick", function ()
        ZL.opt.ItemSettingFrameIsShown = false
    end)
    ItemSettingFrame:ClearAllPoints()
    if ZL.db.global.ZLItemSettingFrame and ZL.db.global.ZLItemSettingFrame.point then
        ItemSettingFrame:SetPoint(ZL.db.global.ZLItemSettingFrame.point, UIParent, ZL.db.global.ZLItemSettingFrame.relative, ZL.db.global.ZLItemSettingFrame.x, ZL.db.global.ZLItemSettingFrame.y)
    else
        ItemSettingFrame:SetPoint("CENTER")
    end
    if ZL.db.global.ZLItemSettingFrame and ZL.db.global.ZLItemSettingFrame.Width and ZL.db.global.ZLItemSettingFrame.Height then
        ItemSettingFrame:SetSize(460, min(ZL.db.global.ZLItemSettingFrame.Height, GetScreenHeight()/ZL.opt.ZLItemSettingFrameScale-110))
    else
        ItemSettingFrame:SetSize(460, 350)
    end
    ItemSettingFrame:Hide()

    ItemSettingFrame.itemIdFrame = CreateFrame("Frame", nil, ItemSettingFrame)
    local itemIdFrame = ItemSettingFrame.itemIdFrame
    itemIdFrame:SetPoint("TOPLEFT", ItemSettingFrame.TitleBottom, "TOPLEFT")
    itemIdFrame:SetSize(ItemSettingFrame:GetWidth(), 50)

    itemIdFrame.itemIdEditbox = CreateEditBox(itemIdFrame, 60, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "itemIdFrameitemIdEditbox")
    local itemIdEditbox = itemIdFrame.itemIdEditbox
    itemIdEditbox:SetPoint("TOPLEFT", itemIdFrame, "TOPLEFT", 28, -5)
    itemIdEditbox:SetScript("OnEnterPressed", function ()
        itemIdFrame.SerchBtn:Click()
    end)
    itemIdEditbox:SetScript("OnMouseUp", function (self)
        if (select(1, GetCursorInfo())) == "item" then
            self:SetText(select(2, GetCursorInfo()))
            ClearCursor()
        end
    end)
    itemIdFrame.itemIdFont = itemIdFrame:CreateFontString()
    local itemIdFont = itemIdFrame.itemIdFont
    itemIdFont:SetPoint("TOP", itemIdEditbox, "BOTTOM", -2, -5)
    itemIdFont:SetFont(GameFontNormal:GetFont(), 12)
    itemIdFont:SetTextColor(1, 0.82, 0)
    itemIdFont:SetText("物品ID")
    itemIdFont:SetWordWrap(false)
    itemIdFont:SetJustifyH("LEFT")

    itemIdFrame.startBidEditbox = CreateEditBox(itemIdFrame, 55, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "itemIdFramestartBidEditbox")
    local startBidEditbox = itemIdFrame.startBidEditbox
    startBidEditbox:SetPoint("LEFT", itemIdEditbox, "RIGHT", 10, 0)

    itemIdFrame.startBidFont = itemIdFrame:CreateFontString()
    local startBidFont = itemIdFrame.startBidFont
    startBidFont:SetPoint("TOP", startBidEditbox, "BOTTOM", -2, -5)
    startBidFont:SetFont(GameFontNormal:GetFont(), 12)
    startBidFont:SetTextColor(1, 0.82, 0)
    startBidFont:SetText("起拍价")
    startBidFont:SetWordWrap(false)
    startBidFont:SetJustifyH("LEFT")

    itemIdFrame.incrementEditbox = CreateEditBox(itemIdFrame, 55, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "itemIdFrameincrementEditbox")
    local incrementEditbox = itemIdFrame.incrementEditbox
    incrementEditbox:SetPoint("LEFT", startBidEditbox, "RIGHT", 9, 0)

    itemIdFrame.incrementFont = itemIdFrame:CreateFontString()
    local incrementFont = itemIdFrame.incrementFont
    incrementFont:SetPoint("TOP", incrementEditbox, "BOTTOM", -2, -5)
    incrementFont:SetFont(GameFontNormal:GetFont(), 12)
    incrementFont:SetTextColor(1, 0.82, 0)
    incrementFont:SetText("加价")
    incrementFont:SetWordWrap(false)
    incrementFont:SetJustifyH("LEFT")

    itemIdFrame.itemNameFont = itemIdFrame:CreateFontString()
    local itemNameFont = itemIdFrame.itemNameFont
    itemNameFont:SetPoint("LEFT", incrementFont, "RIGHT", 15, 0)
    itemNameFont:SetFont(GameFontNormal:GetFont(), 12)
    itemNameFont:SetTextColor(1, 0.82, 0)
    itemNameFont:SetText("名称")
    itemNameFont:SetWordWrap(false)
    itemNameFont:SetJustifyH("LEFT")

    itemIdFrame.AddBtn = CreateButton(nil, itemIdFrame, "添加", "LEFT", incrementEditbox, "RIGHT", 5, 0, 40)
    itemIdFrame.AddBtn:SetScript("OnClick", function ()
        local itemId = itemIdEditbox:GetNumber() or 0
        local startbid = startBidEditbox:GetNumber() or 0
        local increment = incrementEditbox:GetNumber() or 100
        local ZL_SETTING = ZL.opt.ZL_SETTING
        if (itemId > 0) and (startbid > 0) then
            local isExist = false
            for index, data in ipairs(ZL_SETTING.itemIdSetting) do
                if data.itemId == itemId then
                    isExist = true
                    ZL_SETTING.itemIdSetting[index].startbid = startbid
                    ZL_SETTING.itemIdSetting[index].increment = increment
                end
            end
            if isExist then
                for _, f in ipairs(itemIdFrame.entries) do
                    f:Hide()
                end
                local f = itemIdFrame.entries[1]
                f:Show()
                f:SetValues(itemId, startbid, increment, select(2, cGetItemInfo(itemId)))
                local msgStr = Prefix("物品ID已存在！起拍价和每次最低出价已更新！")
                ZL.Print(msgStr)
            else
                local function func(itemlink)
                    tinsert(ZL_SETTING.itemIdSetting, {itemId=itemId, startbid=startbid, increment=increment, itemlink=itemlink})
                    itemIdFrame:Update()
                end
                LoadItemDataByID(itemId, func, itemIdFrame.AddBtn)
            end
            itemIdEditbox:SetText("")
            startBidEditbox:SetText("")
            incrementEditbox:SetText("")
        else
            local msgStr = "信息填写不完整！"
            ZL.Print(msgStr)
            GameTooltipShow(self, "BOTTOM", "TOP")
            GameTooltip:AddLine(msgStr)
            GameTooltip:Show()
            C_Timer.After(3, function ()
                GameTooltip:Hide()
            end)
        end
    end)
    itemIdFrame.AddBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
        GameTooltip:AddLine("添加物品的三种方式：")
        GameTooltip:AddLine("1、直接输入物品ID，起拍价和加价，按\"添加\"按钮；", 1, 1, 1, false)
        GameTooltip:AddLine("2、鼠标点击物品到\"物品ID\"输入框，自动获取物品ID，\n     然后输入起拍价和加价，按\"添加\"按钮；", 1, 1, 1, false)
        GameTooltip:AddLine("3、鼠标点击物品到已存在物品的图标上，自动替换为\n     新的物品ID，保留原起拍价和加价。", 1, 1, 1, false)
        GameTooltip:Show()
    end)
    itemIdFrame.AddBtn:SetScript("OnLeave", function () GameTooltip:Hide() end)
    itemIdFrame.SerchBtn = CreateButton(nil, itemIdFrame, "搜索", "LEFT", itemIdFrame.AddBtn, "RIGHT", 0, 0, 40)
    itemIdFrame.SerchBtn:SetScript("OnClick", function ()
        local itemId = itemIdEditbox:GetNumber() or 0
        if itemId > 0 then
            local isExist = false
            local startbid, increment, itemlink
            for _, data in ipairs(ZL.opt.ZL_SETTING.itemIdSetting) do
                if data.itemId == itemId then
                    isExist = true
                    startbid = data.startbid
                    increment = data.increment
                    itemlink = data.itemlink
                end
            end
            if isExist then
                for _, f in ipairs(itemIdFrame.entries) do f:Hide() end
                local f = itemIdFrame.entries[1]
                f:Show()
                f:SetValues(itemId, startbid, increment, itemlink)
            else
                local msgStr = "物品ID不存在！"
                ZL.Print(msgStr)
                GameTooltipShow(self, "BOTTOM", "TOP")
                GameTooltip:AddLine(msgStr)
                GameTooltip:Show()
                C_Timer.After(3, function ()
                    GameTooltip:Hide()
                end)
            end
        else
            itemIdFrame:Update()
        end
    end)
    itemIdFrame.SerchBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
        GameTooltip:AddLine("物品ID如果为空，则展示所有存在的；否则只展示输入的物品ID！", 1, 1, 1, true)
        GameTooltip:Show()
    end)
    itemIdFrame.SerchBtn:SetScript("OnLeave", function () GameTooltip:Hide() end)
    itemIdFrame.autoAddStartBid = CreateFrame("CheckButton", nil, itemIdFrame, "ChatConfigCheckButtonTemplate")
    itemIdFrame.autoAddStartBid:Hide()
    itemIdFrame.autoAddStartBid:SetPoint("LEFT", itemIdFrame.SerchBtn, "RIGHT", 20, 0)
    itemIdFrame.autoAddStartBid.Text:SetText("自动添加")
    itemIdFrame.autoAddStartBid.Text:SetFont(GameFontNormal:GetFont(), 12, "")
    itemIdFrame.autoAddStartBid:SetHitRectInsets(0, -itemIdFrame.autoAddStartBid.Text:GetWidth(), 0, 0)
    itemIdFrame.autoAddStartBid:SetChecked(ZL.opt.autoAddStartBid)
    itemIdFrame.autoAddStartBid:SetScript("OnClick", function (self)
        ZL.opt.autoAddStartBid = self:GetChecked()
    end)
    itemIdFrame.autoAddStartBid:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "LEFT", "RIGHT", itemIdFrame.autoAddStartBid.Text:GetWidth(), 0)
        GameTooltip:AddLine("作者专用：", 1, 0, 0)
        GameTooltip:AddLine("当拍卖成交价大于1万，自动添加到\n这里，下次起步价不低于5000", 1, 1, 1)
        GameTooltip:Show()
    end)
    itemIdFrame.autoAddStartBid:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)

    --设置TAB事件
    do
        local editboxList = {"itemIdFrameitemIdEditbox", "itemIdFramestartBidEditbox", "itemIdFrameincrementEditbox"}
        local function OnTabPressed(self)
            EditBox_HandleTabbing(self, editboxList)
        end
        itemIdEditbox:SetScript("OnTabPressed", OnTabPressed)
        startBidEditbox:SetScript("OnTabPressed", OnTabPressed)
        incrementEditbox:SetScript("OnTabPressed", function (self)
            local itemId = itemIdEditbox:GetNumber() or 0
            local startbid = startBidEditbox:GetNumber() or 0
            local increment = incrementEditbox:GetNumber() or 0
            if (itemId > 0) and (startbid > 0) and (increment > 0) then
                itemIdFrame.AddBtn:Click()
            else
                OnTabPressed(self)
            end
        end)
    end
    ItemSettingFrame.itemLevelFrame = CreateFrame("Frame", nil, ItemSettingFrame)
    local itemLevelFrame = ItemSettingFrame.itemLevelFrame
    itemLevelFrame:SetPoint("TOPLEFT", ItemSettingFrame.TitleBottom, "TOPLEFT")
    itemLevelFrame:SetSize(ItemSettingFrame:GetWidth(), 50)

    itemLevelFrame.minLevelEditbox = CreateEditBox(itemLevelFrame, 45, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "itemLevelFrameminLevelEditbox")
    local minLevelEditbox = itemLevelFrame.minLevelEditbox
    minLevelEditbox:SetPoint("TOPLEFT", itemLevelFrame, "TOPLEFT", 10, -5)

    itemLevelFrame.minLevelEditbox.linefont = itemLevelFrame.minLevelEditbox:CreateFontString()
    local linefont = itemLevelFrame.minLevelEditbox.linefont
    linefont:SetPoint("LEFT", minLevelEditbox, "RIGHT", 2, 0)
    linefont:SetFont(GameFontNormal:GetFont(), 12)
    linefont:SetTextColor(1, 0.82, 0)
    linefont:SetText("-")
    linefont:SetWordWrap(false)
    linefont:SetJustifyH("CENTER")

    itemLevelFrame.minLevelFont = itemLevelFrame:CreateFontString()
    local minLevelFont = itemLevelFrame.minLevelFont
    minLevelFont:SetPoint("TOP", minLevelEditbox, "BOTTOM", -2, -5)
    minLevelFont:SetFont(GameFontNormal:GetFont(), 12)
    minLevelFont:SetTextColor(1, 0.82, 0)
    minLevelFont:SetText("最小装等")
    minLevelFont:SetWordWrap(false)
    minLevelFont:SetJustifyH("LEFT")

    itemLevelFrame.maxLevelEditbox = CreateEditBox(itemLevelFrame, 45, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "itemLevelFramemaxLevelEditbox")
    local maxLevelEditbox = itemLevelFrame.maxLevelEditbox
    maxLevelEditbox:SetPoint("LEFT", linefont, "RIGHT", 8, 0)

    itemLevelFrame.maxLevelFont = itemLevelFrame:CreateFontString()
    local maxLevelFont = itemLevelFrame.maxLevelFont
    maxLevelFont:SetPoint("TOP", maxLevelEditbox, "BOTTOM", -2, -5)
    maxLevelFont:SetFont(GameFontNormal:GetFont(), 12)
    maxLevelFont:SetTextColor(1, 0.82, 0)
    maxLevelFont:SetText("最大装等")
    maxLevelFont:SetWordWrap(false)
    maxLevelFont:SetJustifyH("LEFT")

    itemLevelFrame.sanJianStartBidEditbox = CreateEditBox(itemLevelFrame, 60, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "itemLevelFrameSanJianStartBidEditbox")
    local sanJianStartBidEditbox = itemLevelFrame.sanJianStartBidEditbox
    sanJianStartBidEditbox:SetPoint("LEFT", maxLevelEditbox, "RIGHT", 10, 0)

    itemLevelFrame.sanJianStartBidFont = itemLevelFrame:CreateFontString()
    local sanJianStartBidFont = itemLevelFrame.sanJianStartBidFont
    sanJianStartBidFont:SetPoint("TOP", sanJianStartBidEditbox, "BOTTOM", -2, -5)
    sanJianStartBidFont:SetFont(GameFontNormal:GetFont(), 12)
    sanJianStartBidFont:SetTextColor(1, 0.82, 0)
    sanJianStartBidFont:SetText("散件")
    sanJianStartBidFont:SetWordWrap(false)
    sanJianStartBidFont:SetJustifyH("LEFT")

    itemLevelFrame.taoZhuangStartBidEditbox = CreateEditBox(itemLevelFrame, 60, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "itemLevelFrameTaoZhuangStartBidEditbox")
    local taoZhuangStartBidEditbox = itemLevelFrame.taoZhuangStartBidEditbox
    taoZhuangStartBidEditbox:SetPoint("LEFT", sanJianStartBidEditbox, "RIGHT", 10, 0)

    itemLevelFrame.taoZhuangStartBidFont = itemLevelFrame:CreateFontString()
    local taoZhuangStartBidFont = itemLevelFrame.taoZhuangStartBidFont
    taoZhuangStartBidFont:SetPoint("TOP", taoZhuangStartBidEditbox , "BOTTOM", -2, -5)
    taoZhuangStartBidFont:SetFont(GameFontNormal:GetFont(), 12)
    taoZhuangStartBidFont:SetTextColor(1, 0.82, 0)
    taoZhuangStartBidFont:SetText("套装")
    taoZhuangStartBidFont:SetWordWrap(false)
    taoZhuangStartBidFont:SetJustifyH("LEFT")

    itemLevelFrame.wuQiStartBidEditbox = CreateEditBox(itemLevelFrame, 60, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "itemLevelFrameWuQiStartBidEditbox")
    local wuQiStartBidEditbox = itemLevelFrame.wuQiStartBidEditbox
    wuQiStartBidEditbox:SetPoint("LEFT", taoZhuangStartBidEditbox, "RIGHT", 10, 0)

    itemLevelFrame.wuQiStartBidFont = itemLevelFrame:CreateFontString()
    local wuQiStartBidFont = itemLevelFrame.wuQiStartBidFont
    wuQiStartBidFont:SetPoint("TOP", wuQiStartBidEditbox , "BOTTOM", -2, -5)
    wuQiStartBidFont:SetFont(GameFontNormal:GetFont(), 12)
    wuQiStartBidFont:SetTextColor(1, 0.82, 0)
    wuQiStartBidFont:SetText("武器/饰品")
    wuQiStartBidFont:SetWordWrap(false)
    wuQiStartBidFont:SetJustifyH("LEFT")

    itemLevelFrame.incrementEditbox = CreateEditBox(itemLevelFrame, 60, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "itemLevelFrameincrementEditbox")
    local incrementEditbox = itemLevelFrame.incrementEditbox
    incrementEditbox:SetPoint("LEFT", wuQiStartBidEditbox , "RIGHT", 10, 0)

    itemLevelFrame.incrementFont = itemLevelFrame:CreateFontString()
    local incrementFont = itemLevelFrame.incrementFont
    incrementFont:SetPoint("TOP", incrementEditbox, "BOTTOM", -2, -5)
    incrementFont:SetFont(GameFontNormal:GetFont(), 12)
    incrementFont:SetTextColor(1, 0.82, 0)
    incrementFont:SetText("最低加价")
    incrementFont:SetWordWrap(false)
    incrementFont:SetJustifyH("LEFT")
    itemLevelFrame.AddBtn = CreateButton(nil, itemLevelFrame, "+", "LEFT", incrementEditbox, "RIGHT", 2, 0, 24)
    itemLevelFrame.AddBtn:SetScript("OnClick", function (self)
        local minLevel = minLevelEditbox:GetNumber() or 0
        local maxLevel = maxLevelEditbox:GetNumber() or 0
        local sanJianStartBid = sanJianStartBidEditbox:GetNumber() or 0
        local taoZhuangStartBid = taoZhuangStartBidEditbox:GetNumber() or 0
        local wuQiStartBid = wuQiStartBidEditbox:GetNumber() or 0
        local increment = incrementEditbox:GetNumber() or 0
        local ZL_SETTING = ZL.opt.ZL_SETTING
        if minLevel <= 0 or maxLevel <= 0 or increment <= 0 then
            GameTooltipShow(self, "LEFT", "RIGHT")
            GameTooltip:AddLine("错误")
            GameTooltip:AddLine("请输入大于0的数！", 1, 1, 1)
            GameTooltip:Show()
            C_Timer.After(2, function ()
                GameTooltip:Hide()
            end)
            return
        end
        if sanJianStartBid == 0 and taoZhuangStartBid == 0 and wuQiStartBid == 0 then
            GameTooltipShow(self, "LEFT", "RIGHT")
            GameTooltip:AddLine("错误")
            GameTooltip:AddLine("散件、套装、武器/饰品至少一项输入大于0的数", 1, 1, 1)
            GameTooltip:Show()
            C_Timer.After(2, function ()
                GameTooltip:Hide()
            end)
            return
        end
        if maxLevel < minLevel then
            GameTooltipShow(self, "LEFT", "RIGHT")
            GameTooltip:AddLine("错误")
            GameTooltip:AddLine("最大装等不能小于最小装等！", 1, 1, 1)
            GameTooltip:Show()
            C_Timer.After(2, function ()
                GameTooltip:Hide()
            end)
        end
        for _, d in ipairs(ZL_SETTING["itemLevelSetting"]) do
            if ((d.minLevel <= minLevel) and (d.maxLevel >= minLevel)) or ((d.minLevel <= maxLevel) and (d.maxLevel >= maxLevel)) then
                GameTooltipShow(self, "LEFT", "RIGHT")
                GameTooltip:AddLine("警告")
                GameTooltip:AddLine("装等存在重叠范围，请修改！", 1, 1, 1)
                GameTooltip:Show()
                C_Timer.After(2, function ()
                    GameTooltip:Hide()
                end)
                return
            end
        end
        tinsert(ZL_SETTING["itemLevelSetting"], {
            minLevel = minLevel, maxLevel = maxLevel,
            sanJianStartBid = sanJianStartBid, taoZhuangStartBid = taoZhuangStartBid,
            wuQiStartBid = wuQiStartBid, increment = increment,
        })
        table.sort(ZL_SETTING["itemLevelSetting"], function (a, b)
            return a.minLevel < b.minLevel
        end)
        itemLevelFrame:Update()
        minLevelEditbox:SetText("")
        maxLevelEditbox:SetText("")
        sanJianStartBidEditbox:SetText("")
        taoZhuangStartBidEditbox:SetText("")
        wuQiStartBidEditbox:SetText("")
        incrementEditbox:SetText("")
    end)
    itemLevelFrame.AddBtn:SetScript("onLeave", function ()
        GameTooltip:Hide()
    end)
    itemLevelFrame:Hide()
    --设置TAB事件
    do
        local editboxList = {
            "itemLevelFrameminLevelEditbox", "itemLevelFramemaxLevelEditbox",
            "itemLevelFrameSanJianStartBidEditbox", "itemLevelFrameTaoZhuangStartBidEditbox",
            "itemLevelFrameWuQiStartBidEditbox", "itemLevelFrameincrementEditbox"
        }
        local function OnTabPressed(self)
            EditBox_HandleTabbing(self, editboxList)
        end
        minLevelEditbox:SetScript("OnTabPressed", OnTabPressed)
        maxLevelEditbox:SetScript("OnTabPressed", OnTabPressed)
        sanJianStartBidEditbox:SetScript("OnTabPressed", OnTabPressed)
        taoZhuangStartBidEditbox:SetScript("OnTabPressed", OnTabPressed)
        wuQiStartBidEditbox:SetScript("OnTabPressed", OnTabPressed)
        incrementEditbox:SetScript("OnTabPressed", OnTabPressed)
    end

    ItemSettingFrame.filterFrame = CreateFrame("Frame", nil, ItemSettingFrame)
    local filterFrame = ItemSettingFrame.filterFrame
    filterFrame:SetPoint("TOPLEFT", ItemSettingFrame.TitleBottom, "TOPLEFT")
    filterFrame:SetSize(ItemSettingFrame:GetWidth(), 50)

    filterFrame.filterItemIdEditbox = CreateEditBox(filterFrame, 100, 20, 12, "RIGHT", true, nil, nil, nil, nil, nil, "filterFrameFilterItemIdEditbox")
    local filterItemIdEditbox = filterFrame.filterItemIdEditbox
    filterItemIdEditbox:SetPoint("TOPLEFT", filterFrame, "TOPLEFT", 31, -5)
    filterItemIdEditbox:SetScript("OnEnterPressed", function ()
        filterFrame.AddBtn:Click()
    end)
    filterItemIdEditbox:SetScript("OnMouseUp", function (self)
        if (select(1, GetCursorInfo())) == "item" then
            self:SetText(select(2, GetCursorInfo()))
            ClearCursor()
        end
    end)

    filterFrame.AddBtn = CreateButton(nil, filterFrame, "添加", "LEFT", filterItemIdEditbox, "RIGHT", 5, 0, 40)
    filterFrame.AddBtn:SetScript("OnClick", function (self)
        local itemId = filterItemIdEditbox:GetNumber() or 0
        if (itemId > 0) then
            local ZL_SETTING = ZL.opt.ZL_SETTING
            local isExist = false
            for _, data in ipairs(ZL_SETTING.filterItemId) do
                if data.itemId == itemId then
                    isExist = true
                end
            end
            if isExist then
                for _, f in ipairs(filterFrame.entries) do
                    f:Hide()
                end
                local f = filterFrame.entries[1]
                f:Show()
                f:SetValues(itemId, select(2, cGetItemInfo(itemId)))
                local msgStr = "物品ID已存在！"
                ZL.Print(msgStr)
                GameTooltipShow(self, "BOTTOM", "TOP")
                GameTooltip:AddLine(msgStr)
                GameTooltip:Show()
                C_Timer.After(3, function ()
                    GameTooltip:Hide()
                end)
            else
                local function func(itemlink)
                    tinsert(ZL_SETTING.filterItemId, {itemId=itemId, itemlink=itemlink, loot=true, auction=true})
                    filterFrame:Update()
                end
                LoadItemDataByID(itemId, func, filterFrame.AddBtn)
            end
            filterItemIdEditbox:SetText("")
        else
            local msgStr = "信息填写不完整！"
            ZL.Print(msgStr)
            GameTooltipShow(self, "BOTTOM", "TOP")
            GameTooltip:AddLine(msgStr)
            GameTooltip:Show()
            C_Timer.After(3, function ()
                GameTooltip:Hide()
            end)
        end
        filterItemIdEditbox:ClearFocus()
    end)
    filterFrame.AddBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
        GameTooltip:AddLine("添加物品的三种方式：")
        GameTooltip:AddLine("1、直接输入物品ID，按\"添加\"按钮；", 1, 1, 1, false)
        GameTooltip:AddLine("2、鼠标点击物品到\"物品ID\"输入框，自动获取物品ID，\n     按\"添加\"按钮；", 1, 1, 1, false)
        GameTooltip:AddLine("3、鼠标点击物品到已存在物品的图标上，自动替换为\n     新的物品ID", 1, 1, 1, false)
        GameTooltip:Show()
    end)
    filterFrame.AddBtn:SetScript("OnLeave", function () GameTooltip:Hide() end)
    filterFrame.SerchBtn = CreateButton(nil, filterFrame, "搜索", "LEFT", filterFrame.AddBtn, "RIGHT", 0, 0, 40)
    filterFrame.SerchBtn:SetScript("OnClick", function ()
        local itemId = filterItemIdEditbox:GetNumber() or 0
        if itemId > 0 then
            local isExist = false
            local itemlink
            for _, data in ipairs(ZL.opt.ZL_SETTING.filterItemId) do
                if data.itemId == itemId then
                    isExist = true
                    itemlink = data.itemlink
                end
            end
            if isExist then
                for _, f in ipairs(filterFrame.entries) do f:Hide() end
                local f = filterFrame.entries[1]
                f:Show()
                f:SetValues(itemId, itemlink)
            else
                local msgStr = "物品ID不存在！"
                ZL.Print(msgStr)
                GameTooltipShow(self, "BOTTOM", "TOP")
                GameTooltip:AddLine(msgStr)
                GameTooltip:Show()
                C_Timer.After(3, function ()
                    GameTooltip:Hide()
                end)
            end
        else
            filterFrame:Update()
        end
    end)
    filterFrame.SerchBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
        GameTooltip:AddLine("物品ID如果为空，则展示所有存在的；否则只展示输入的物品ID！", 1, 1, 1, true)
        GameTooltip:Show()
    end)
    filterFrame.SerchBtn:SetScript("OnLeave", function () GameTooltip:Hide() end)

    filterFrame.filterItemIdFont = filterFrame:CreateFontString()
    local filterItemIdFont = filterFrame.filterItemIdFont
    filterItemIdFont:SetPoint("TOPLEFT", filterItemIdEditbox, "BOTTOMLEFT", 5, -5)
    filterItemIdFont:SetFont(GameFontNormal:GetFont(), 12)
    filterItemIdFont:SetTextColor(1, 0.82, 0)
    filterItemIdFont:SetText("物品ID")
    filterItemIdFont:SetWordWrap(false)
    filterItemIdFont:SetJustifyH("LEFT")

    filterFrame.filterItemNameFont = filterFrame:CreateFontString()
    local filterItemNameFont = filterFrame.filterItemNameFont
    filterItemNameFont:SetPoint("LEFT", filterItemIdFont, "RIGHT", 50, 0)
    filterItemNameFont:SetFont(GameFontNormal:GetFont(), 12)
    filterItemNameFont:SetTextColor(1, 0.82, 0)
    filterItemNameFont:SetText("名称")
    filterItemNameFont:SetWordWrap(false)
    filterItemNameFont:SetJustifyH("LEFT")
    filterFrame:Hide()

    --创建滚动条
    ItemSettingFrame.scrollFrame = CreateFrame("ScrollFrame", nil, ItemSettingFrame, "UIPanelScrollFrameTemplate")
    ItemSettingFrame.scrollFrame:SetPoint("TOPLEFT", ItemSettingFrame.TitleBottom, "TOPLEFT", 3, -50)
    ItemSettingFrame.scrollFrame:SetPoint("BOTTOMRIGHT", ItemSettingFrame, "BOTTOMRIGHT", -3, 4)
    ItemSettingFrame.scrollFrame:SetClipsChildren(true) --必须设置为true，scrollFrame所有的子元素才会被剪切
    ItemSettingFrame.scrollFrame:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel) --重设滑动条鼠标滚轮事件
    --重设ScrollBar位置，放置到scrollFrame内，防止被剪切掉
    ItemSettingFrame.scrollFrame.ScrollBar:ClearAllPoints()
    ItemSettingFrame.scrollFrame.ScrollBar:SetPoint("TOPLEFT", ItemSettingFrame.scrollFrame, "TOPRIGHT", -10, -15)
    ItemSettingFrame.scrollFrame.ScrollBar:SetPoint("BOTTOMRIGHT", ItemSettingFrame.scrollFrame, "BOTTOMRIGHT", -5, 15)

    local function Tab_OnClick(self)
        local frame = self:GetParent()
        local tabId = self:GetID()
        if tabId == 1 then
            itemIdFrame:Show()
            itemLevelFrame:Hide()
            filterFrame:Hide()
        elseif tabId == 2 then
            itemIdFrame:Hide()
            itemLevelFrame:Show()
            filterFrame:Hide()
        elseif tabId == 3 then
            itemIdFrame:Hide()
            itemLevelFrame:Hide()
            filterFrame:Show()
        end
        PanelTemplates_SetTab(frame, tabId)
        local scrollchild = frame.scrollFrame:GetScrollChild()
        if scrollchild then
            scrollchild:Hide()
        end
        frame.scrollFrame:SetScrollChild(self.content)
        self.content:Show()
    end

    local function CreateTab(frame, numTabs, ...)
        frame.numTabs = numTabs
        local contents = {}
        local frameName = frame:GetName()
        local template = ""
        for i = 1, numTabs do
            if WOW_PROJECT_ID == 1 then
                template = "PanelTabButtonTemplate"
            else --if WOW_PROJECT_ID == 11 or WOW_PROJECT_ID == 2 then
                template = "CharacterFrameTabButtonTemplate"
            end
            local tab = CreateFrame("Button", frameName.."Tab"..i, frame, template)
            tab:SetID(i)
            tab:SetText(select(i, ...))
            tab:SetScript("OnClick", Tab_OnClick)
            if WOW_PROJECT_ID == 1 then
                if i ==1 then
                    tab:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, 0)
                else
                    tab:SetPoint("TOPLEFT", _G[frameName.."Tab"..(i-1)], "TOPRIGHT", 1, 0)
                end
            else
                if i ==1 then
                    tab:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, 5)
                else
                    tab:SetPoint("TOPLEFT", _G[frameName.."Tab"..(i-1)], "TOPRIGHT", -20, 0)
                end
            end
            tab.content = CreateFrame("Frame", nil, frame.scrollFrame)
            tab.content:SetPoint("TOPLEFT", frame.scrollFrame, "TOPLEFT")
            tab.content:SetSize(frame.scrollFrame:GetWidth() - 40, 600)
            tab.content:Hide()
            tinsert(contents, tab.content)
        end
        Tab_OnClick(_G[frameName.."Tab1"])
        return unpack(contents)
    end

    local itemIdContent, itemLevelContent, itemFilterContent = CreateTab(ItemSettingFrame, 3, "按物品", "按装等", "过滤")

    itemIdFrame.entries = setmetatable({}, {
        __index = function(t, v)
            local f = CreateFrame("Frame", nil, itemIdContent)
            if v > 1 then
                f:SetPoint("TOPLEFT", t[v - 1], "BOTTOMLEFT", 0, -8)
                f:SetPoint("TOPRIGHT", t[v - 1], "BOTTOMRIGHT", 0, -8)
            else
                f:SetPoint("TOPLEFT", itemIdContent, "TOPLEFT", 0, -5)
                f:SetPoint("TOPRIGHT", itemIdContent, "TOPRIGHT", 0, -5)
            end
            f:SetHeight(15)

            f.itemicon = CreateFrame("Button", nil, f)
            f.itemicon:SetSize(18, 18)
            f.itemicon:EnableMouse(true)
            f.itemicon:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square")
            f.itemicon:SetPoint("LEFT", f, "LEFT", 2, 0)
            f.itemicon:SetScript("OnEnter", function()
                GameTooltip:ClearAllPoints()
                GameTooltip:ClearLines()
                GameTooltip:SetOwner(f, "ANCHOR_NONE")
                GameTooltip:SetHyperlink("item:" .. f.itemId)
                GameTooltip:SetPoint("RIGHT", f, "LEFT", -5, 0)
                GameTooltip:Show()
            end)
            f.itemicon:SetScript("OnLeave", function() GameTooltip:Hide() end)
            f.itemicon:SetScript("OnMouseUp", function (self)
                if (select(1, GetCursorInfo())) == "item" then
                    local _, itemId, itemlink = GetCursorInfo()
                    local isExist = false
                    local ZL_SETTING = ZL.opt.ZL_SETTING
                    for _, data in ipairs(ZL_SETTING.itemIdSetting) do
                        if data.itemId == itemId then
                            isExist = true
                            break
                        end
                    end
                    if (not isExist) then
                        ZL_SETTING.itemIdSetting[v].itemId = itemId
                        ZL_SETTING.itemIdSetting[v].itemlink = itemlink
                        itemIdFrame:Update()
                        ClearCursor()
                    else
                        local msgStr = "物品ID已存在！"
                        ZL.Print(msgStr)
                        GameTooltipShow(self, "BOTTOM", "TOP")
                        GameTooltip:AddLine(msgStr)
                        GameTooltip:Show()
                        C_Timer.After(3, function ()
                            GameTooltip:Hide()
                        end)
                    end
                    
                end
            end)

            f.itemIdBox = CreateEditBox(itemIdContent, 60, 20, 12, "LEFT", true)
            f.itemIdBox:SetPoint("LEFT", f.itemicon, "RIGHT", 5, 0)
            f.itemIdBox:SetTextColor(1, 1, 1)
            f.itemIdBox:Disable()

            f.startBidBox = CreateEditBox(itemIdContent, 55, 20, 12, "RIGHT", true)
            f.startBidBox:SetPoint("LEFT", f.itemIdBox, "RIGHT", 9, 0)
            f.startBidBox:SetTextColor(1, 1, 1)
            f.startBidBox:SetScript("OnEnterPressed", function(self)
                ZL.opt.ZL_SETTING.itemIdSetting[v].startbid = self:GetNumber() > 0 and self:GetNumber() or ZL_SETTING.itemIdSetting[v].startbid
                self:ClearFocus()
            end)
            f.startBidBox:SetScript("OnEscapePressed", function(self)
                self:SetNumber(ZL.opt.ZL_SETTING.itemIdSetting[v].startbid)
                self:ClearFocus()
            end)

            f.incrementBox = CreateEditBox(itemIdContent, 40, 20, 12, "RIGHT", true)
            f.incrementBox:SetPoint("LEFT", f.startBidBox, "RIGHT", 9, 0)
            f.incrementBox:SetTextColor(1, 1, 1)
            f.incrementBox:SetScript("OnEnterPressed", function(self)
                ZL.opt.ZL_SETTING.itemIdSetting[v].increment = self:GetNumber() > 0 and self:GetNumber() or ZL_SETTING.itemIdSetting[v].increment
                self:ClearFocus()
            end)
            f.incrementBox:SetScript("OnEscapePressed", function(self)
                self:SetNumber(ZL.opt.ZL_SETTING.itemIdSetting[v].increment)
                self:ClearFocus()
            end)

            f.itemNameFont = f:CreateFontString(nil, "BACKGROUND")
            f.itemNameFont:SetPoint("LEFT", f.incrementBox, "RIGHT", 5, 0)
            f.itemNameFont:SetSize(120, 15)
            f.itemNameFont:SetFont(GameFontNormal:GetFont(), 12)
            f.itemNameFont:SetTextColor(1, 1, 1)
            f.itemNameFont:SetWordWrap(false)
            f.itemNameFont:SetJustifyH("LEFT")

            f.del = CreateButton(nil, f, "-", "LEFT", f.itemNameFont, "RIGHT", 2, 0, 20, 20)
            f.del:SetScript("OnClick", function (self)
                table.remove(ZL.opt.ZL_SETTING.itemIdSetting, v)
                itemIdFrame:Update()
            end)
            function f:SetValues(itemId, startbid, increment, itemlink)
                self.itemicon:SetNormalTexture(cGetItemIcon(itemId))
				self.itemIdBox:SetNumber(itemId)
                self.startBidBox:SetNumber(startbid)
                self.incrementBox:SetNumber(increment)
                self.itemNameFont:SetTextScale(1)
                self.itemNameFont:SetText(itemlink)
                local bili = self.itemNameFont:GetWidth()/(self.itemNameFont:GetUnboundedStringWidth()+5)
                bili = bili <= 1 and bili or 1
                self.itemNameFont:SetTextScale(bili)
				self.itemId = itemId
            end
            t[v] = f
            return f
        end
    })
    function itemIdFrame:Update()
        local ZL_SETTING = ZL.opt.ZL_SETTING
        for _, f in ipairs(itemIdFrame.entries) do f:Hide() end
        if ZL_SETTING.itemIdSetting and #ZL_SETTING.itemIdSetting > 0 then
            table.sort(ZL_SETTING.itemIdSetting, function (a, b)
                if a.itemId < b.itemId then
                    return true
                end
                return false
            end)
            for num, data in ipairs(ZL_SETTING.itemIdSetting) do
                local f = itemIdFrame.entries[num]
                f:Show()
                f:SetValues(data.itemId, data.startbid, data.increment, data.itemlink)
            end
            itemIdContent:SetHeight(20 * #ZL_SETTING.itemIdSetting - 5)
        end
    end

    itemLevelFrame.entries = setmetatable({}, {
        __index = function(t, v)
            local f = CreateFrame("Frame", nil, itemLevelContent)
            if v > 1 then
                f:SetPoint("TOPLEFT", t[v - 1], "BOTTOMLEFT", 0, -8)
                f:SetPoint("TOPRIGHT", t[v - 1], "BOTTOMRIGHT", 0, -8)
            else
                f:SetPoint("TOPLEFT", itemLevelContent, "TOPLEFT", 0, -5)
                f:SetPoint("TOPRIGHT", itemLevelContent, "TOPRIGHT", 0, -5)
            end
            f:SetHeight(15)

            f.minLevelbox = CreateEditBox(itemLevelContent, 45, 20, 12, "LEFT", true)
            f.minLevelbox:SetPoint("TOPLEFT", f, "TOPLEFT", 7, 0)
            f.minLevelbox:SetTextColor(0.57, 0.45, 1)
            f.minLevelbox:Disable()

            f.minLevelbox.linefont = f.minLevelbox:CreateFontString(nil, "BACKGROUND")
            local linefontf = f.minLevelbox.linefont
            linefontf:SetPoint("LEFT", f.minLevelbox, "RIGHT", 2, 0)
            linefontf:SetFont(GameFontNormal:GetFont(), 12)
            linefontf:SetTextColor(1, 0.82, 0)
            linefontf:SetText("-")
            linefontf:SetWordWrap(false)
            linefontf:SetJustifyH("CENTER")

            f.maxLevelbox = CreateEditBox(itemLevelContent, 45, 20, 12, "LEFT", true)
            f.maxLevelbox:SetPoint("LEFT", linefontf, "RIGHT", 8, 0)
            f.maxLevelbox:SetTextColor(0.57, 0.45, 1)
            f.maxLevelbox:Disable()

            f.sanJianStartbidbox = CreateEditBox(itemLevelContent, 60, 20, 12, "LEFT", true)
            f.sanJianStartbidbox:SetPoint("LEFT", f.maxLevelbox, "RIGHT", 10, 0)
            f.sanJianStartbidbox:SetTextColor(1, 1, 1)
            f.sanJianStartbidbox:SetScript("OnEnterPressed", function(self)
                ZL.opt.ZL_SETTING.itemLevelSetting[v].sanJianStartBid= self:GetNumber() > 0 and self:GetNumber() or ZL_SETTING.itemLevelSetting[v].sanJianStartBid
                self:ClearFocus()
            end)
            f.sanJianStartbidbox:SetScript("OnEscapePressed", function(self)
                self:SetNumber(ZL.opt.ZL_SETTING.itemLevelSetting[v].sanJianStartBid)
                self:ClearFocus()
            end)

            f.taoZhuangStartbidbox = CreateEditBox(itemLevelContent, 60, 20, 12, "LEFT", true)
            f.taoZhuangStartbidbox:SetPoint("LEFT", f.sanJianStartbidbox, "RIGHT", 10, 0)
            f.taoZhuangStartbidbox:SetTextColor(1, 1, 1)
            f.taoZhuangStartbidbox:SetScript("OnEnterPressed", function(self)
                ZL.opt.ZL_SETTING.itemLevelSetting[v].taoZhuangStartBid= self:GetNumber() > 0 and self:GetNumber() or ZL_SETTING.itemLevelSetting[v].taoZhuangStartBid
                self:ClearFocus()
            end)
            f.taoZhuangStartbidbox:SetScript("OnEscapePressed", function(self)
                self:SetNumber(ZL.opt.ZL_SETTING.itemLevelSetting[v].taoZhuangStartBid)
                self:ClearFocus()
            end)

            f.wuQiStartbidbox = CreateEditBox(itemLevelContent, 60, 20, 12, "LEFT", true)
            f.wuQiStartbidbox:SetPoint("LEFT", f.taoZhuangStartbidbox, "RIGHT", 10, 0)
            f.wuQiStartbidbox:SetTextColor(1, 1, 1)
            f.wuQiStartbidbox:SetScript("OnEnterPressed", function(self)
                ZL.opt.ZL_SETTING.itemLevelSetting[v].wuQiStartBid= self:GetNumber() > 0 and self:GetNumber() or ZL_SETTING.itemLevelSetting[v].wuQiStartBid
                self:ClearFocus()
            end)
            f.wuQiStartbidbox:SetScript("OnEscapePressed", function(self)
                self:SetNumber(ZL.opt.ZL_SETTING.itemLevelSetting[v].wuQiStartBid)
                self:ClearFocus()
            end)

            f.incrementbox = CreateEditBox(itemLevelContent, 60, 20, 12, "LEFT", true)
            f.incrementbox:SetPoint("LEFT", f.wuQiStartbidbox, "RIGHT", 10, 0)
            f.incrementbox:SetTextColor(1, 1, 1)
            f.incrementbox:SetScript("OnEnterPressed", function(self)
                ZL.opt.ZL_SETTING.itemLevelSetting[v].increment = self:GetNumber() > 0 and self:GetNumber() or ZL_SETTING.itemLevelSetting[v].increment
                self:ClearFocus()
            end)
            f.incrementbox:SetScript("OnEscapePressed", function(self)
                self:SetNumber(ZL.opt.ZL_SETTING.itemLevelSetting[v].increment)
                self:ClearFocus()
            end)
            f.del = CreateButton(nil, f, "-", "LEFT", f.incrementbox, "RIGHT", 2, 0, 24)
            f.del:SetScript("OnClick", function (self)
                table.remove(ZL.opt.ZL_SETTING.itemLevelSetting, v)
                itemLevelFrame:Update()
            end)

            function f:SetValues(minLevel, maxLevel, sanJianStartBid, taoZhuangStartBid, wuQiStartBid, increment)
                self.minLevelbox:SetNumber(minLevel)
                self.maxLevelbox:SetNumber(maxLevel)
                self.sanJianStartbidbox:SetNumber(sanJianStartBid)
                self.taoZhuangStartbidbox:SetNumber(taoZhuangStartBid)
                self.wuQiStartbidbox:SetNumber(wuQiStartBid)
                self.incrementbox:SetNumber(increment)
            end

            t[v] = f
            return f
        end
    })
    function itemLevelFrame:Update()
        for _, f in ipairs(itemLevelFrame.entries) do f:Hide() end
        for num, data in ipairs(ZL.opt.ZL_SETTING.itemLevelSetting) do
            local f = itemLevelFrame.entries[num]
            f:Show()
            f:SetValues(data.minLevel, data.maxLevel, data.sanJianStartBid, data.taoZhuangStartBid, data.wuQiStartBid, data.increment)
        end
        itemLevelContent:SetHeight(20 * #ZL.opt.ZL_SETTING.itemLevelSetting - 5)
    end

    filterFrame.entries = setmetatable({}, {
        __index = function(t, v)
            local f = CreateFrame("Frame", nil, itemFilterContent)
            if v > 1 then
                f:SetPoint("TOPLEFT", t[v - 1], "BOTTOMLEFT", 0, -8)
                f:SetPoint("TOPRIGHT", t[v - 1], "BOTTOMRIGHT", 0, -8)
            else
                f:SetPoint("TOPLEFT", itemFilterContent, "TOPLEFT", 0, -5)
                f:SetPoint("TOPRIGHT", itemFilterContent, "TOPRIGHT", 0, -5)
            end
            f:SetHeight(15)

            f.itemicon = CreateFrame("Button", nil, f)
            f.itemicon:SetSize(18, 18)
            f.itemicon:EnableMouse(true)
            f.itemicon:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square")
            f.itemicon:SetPoint("LEFT", f, "LEFT", 2, 0)
            f.itemicon:SetScript("OnEnter", function()
                GameTooltip:ClearAllPoints()
                GameTooltip:ClearLines()
                GameTooltip:SetOwner(f, "ANCHOR_NONE")
                GameTooltip:SetHyperlink("item:" .. f.itemId)
                GameTooltip:SetPoint("RIGHT", f, "LEFT", -5, 0)
                GameTooltip:Show()
            end)
            f.itemicon:SetScript("OnLeave", function() GameTooltip:Hide() end)
            f.itemicon:SetScript("OnMouseUp", function (self)
                if (select(1, GetCursorInfo())) == "item" then
                    local ZL_SETTING = ZL.opt.ZL_SETTING
                    local _, itemId, itemlink = GetCursorInfo()
                    local isExist = false
                    for _, data in ipairs(ZL_SETTING.filterItemId) do
                        if data.itemId == itemId then
                            isExist = true
                        end
                    end
                    if (not isExist) then
                        ZL_SETTING.filterItemId[v].itemId = itemId
                        ZL_SETTING.filterItemId[v].itemlink = itemlink
                        filterFrame:Update()
                        ClearCursor()
                    else
                        local msgStr = "物品ID已存在！"
                        ZL.Print(msgStr)
                        GameTooltipShow(self, "BOTTOM", "TOP")
                        GameTooltip:AddLine(msgStr)
                        GameTooltip:Show()
                        C_Timer.After(3, function ()
                            GameTooltip:Hide()
                        end)
                    end
                    
                end
            end)

            f.itemIdBox = CreateEditBox(itemFilterContent, 60, 20, 12, "LEFT", true)
            f.itemIdBox:SetPoint("LEFT", f.itemicon, "RIGHT", 8, 0)
            f.itemIdBox:SetTextColor(1, 1, 1)
            f.itemIdBox:Disable()

            f.itemNameFont = f:CreateFontString(nil, "BACKGROUND")
            f.itemNameFont:SetPoint("LEFT", f.itemIdBox, "RIGHT", 5, 0)
            f.itemNameFont:SetSize(130, 15)
            f.itemNameFont:SetFont(GameFontNormal:GetFont(), 12)
            f.itemNameFont:SetTextColor(1, 1, 1)
            f.itemNameFont:SetWordWrap(false)
            f.itemNameFont:SetJustifyH("LEFT")

            f.lootCheckButton = CreateFrame("CheckButton", nil, f, "ChatConfigCheckButtonTemplate")
            f.lootCheckButton:SetPoint("LEFT", f.itemNameFont, "RIGHT", -3, 0)
            f.lootCheckButton.Text:SetText("不自动拾取")
            f.lootCheckButton.Text:SetFont(GameFontNormal:GetFont(), 10, "")
            f.lootCheckButton.tooltip = "勾选后不自动分配给ML"
            f.lootCheckButton:SetHitRectInsets(0, -f.lootCheckButton.Text:GetWidth(), 0, 0)
            f.lootCheckButton:SetScript("OnClick", function (self)
                ZL.opt.ZL_SETTING["filterItemId"][v].loot = f.lootCheckButton:GetChecked()
            end)
            f.auctionCheckButton = CreateFrame("CheckButton", nil, f, "ChatConfigCheckButtonTemplate")
            f.auctionCheckButton:SetPoint("LEFT", f.lootCheckButton, "RIGHT", f.lootCheckButton.Text:GetWidth(), 0)
            f.auctionCheckButton.Text:SetText("不自动创建拍卖")
            f.auctionCheckButton.Text:SetFont(GameFontNormal:GetFont(), 10, "")
            f.auctionCheckButton.tooltip = "勾选后不自动创建拍卖"
            f.auctionCheckButton:SetHitRectInsets(0, -f.auctionCheckButton.Text:GetWidth(), 0, 0)
            f.auctionCheckButton:SetScript("OnClick", function (self)
                ZL.opt.ZL_SETTING["filterItemId"][v].auction = f.auctionCheckButton:GetChecked()
            end)

            f.del = CreateButton(nil, f, "-", "LEFT", f.auctionCheckButton, "RIGHT", f.auctionCheckButton.Text:GetWidth()+5, 0, 20, 20)
            f.del:SetScript("OnClick", function (self)
                table.remove(ZL.opt.ZL_SETTING.filterItemId, v)
                filterFrame:Update()
            end)
            function f:SetValues(v, itemId, itemlink)
                self.itemicon:SetNormalTexture(cGetItemIcon(itemId))
				self.itemIdBox:SetNumber(itemId)
                self.itemNameFont:SetTextScale(1)
                self.itemNameFont:SetText(itemlink)
                self.lootCheckButton:SetChecked(ZL.opt.ZL_SETTING["filterItemId"][v].loot)
                self.auctionCheckButton:SetChecked(ZL.opt.ZL_SETTING["filterItemId"][v].auction)
                local bili = self.itemNameFont:GetWidth()/(self.itemNameFont:GetUnboundedStringWidth()+5)
                bili = bili <= 1 and bili or 1
                self.itemNameFont:SetTextScale(bili)
				self.itemId = itemId
            end
            t[v] = f
            return f
        end
    })
    function filterFrame:Update()
        for _, f in ipairs(filterFrame.entries) do f:Hide() end
        local ZL_SETTING = ZL.opt.ZL_SETTING
        for num, data in ipairs(ZL_SETTING.filterItemId) do
            local f = filterFrame.entries[num]
            f:Show()
            f:SetValues(num, data.itemId, data.itemlink)
        end
        itemFilterContent:SetHeight(20 * #ZL_SETTING.filterItemId - 5)
    end
end

--创建历史拍卖记录和当前拍卖收入记录框架
function ZL:CreateAuctionRecordFrame()
    ZL.AuctionRecordFrame = ZLCreateFrame("ZLAuctionRecordFrame", ZL, nil, nil, nil, true, true, "拍卖记录")
    -- ZL.AuctionRecordFrame = CreateFrame("Frame", "ZLAuctionRecordFrame", ZL, "UIPanelDialogTemplate")
    local AuctionRecordFrame = ZL.AuctionRecordFrame
    AuctionRecordFrame:SetScale(ZL.opt.ZLAuctionRecordFrameScale)
    AuctionRecordFrame:SetSize(595, 500) --330, 350
    AuctionRecordFrame:SetResizeBounds(595, 300, 595, GetScreenHeight()/ZL.opt.ZLAuctionRecordFrameScale-110)
    AuctionRecordFrame:SetScript("OnMouseUp", function (self)
        self:StopMovingOrSizing()
        if not ZL.db.global.ZLAuctionRecordFrame then ZL.db.global.ZLAuctionRecordFrame = {} end
        ZL.db.global.ZLAuctionRecordFrame.point, _, ZL.db.global.ZLAuctionRecordFrame.relative, ZL.db.global.ZLAuctionRecordFrame.x, ZL.db.global.ZLAuctionRecordFrame.y = self:GetPoint()
    end)
    AuctionRecordFrame:SetScript("OnMouseDown", function (self)
        self:StartMoving()
    end)
    AuctionRecordFrame:SetScript("OnShow", function (self)
        ZL.opt.ZLAuctionRecordFrameIsShown = true
        self.historyFrame:Update()
        self.currentIncomeFrame:Update()
        self.playerBalanceFrame:Update()
    end)
    local resizeButton = AuctionRecordFrame.resizeButton
    -- 设置鼠标按下时开始调整大小
    resizeButton:SetScript("OnMouseDown", function(self, button)
        if button == "LeftButton" then
            AuctionRecordFrame:StartSizing("BOTTOMRIGHT")
        end
    end)
    -- 鼠标松开时停止调整大小
    resizeButton:SetScript("OnMouseUp", function(self)
        AuctionRecordFrame:StopMovingOrSizing()
        if not ZL.db.global.ZLAuctionRecordFrame then ZL.db.global.ZLAuctionRecordFrame = {} end
        ZL.db.global.ZLAuctionRecordFrame.Width,  ZL.db.global.ZLAuctionRecordFrame.Height= AuctionRecordFrame:GetSize()
    end)

    AuctionRecordFrame.closeButton:HookScript("OnClick", function ()
        ZL.opt.ZLAuctionRecordFrameIsShown = false
    end)

    AuctionRecordFrame:ClearAllPoints()
    if ZL.db.global.ZLAuctionRecordFrame and ZL.db.global.ZLAuctionRecordFrame.point then
        AuctionRecordFrame:SetPoint(ZL.db.global.ZLAuctionRecordFrame.point, UIParent, ZL.db.global.ZLAuctionRecordFrame.relative, ZL.db.global.ZLAuctionRecordFrame.x, ZL.db.global.ZLAuctionRecordFrame.y)
    else
        AuctionRecordFrame:SetPoint("CENTER")
    end
    if ZL.db.global.ZLAuctionRecordFrame and ZL.db.global.ZLAuctionRecordFrame.Width and ZL.db.global.ZLAuctionRecordFrame.Height then
        AuctionRecordFrame:SetSize(595, min(ZL.db.global.ZLAuctionRecordFrame.Height, GetScreenHeight()/ZL.opt.ZLAuctionRecordFrameScale-50))
    else
        AuctionRecordFrame:SetSize(595, 500)
    end
    AuctionRecordFrame:Hide()

    AuctionRecordFrame.historyFrame = CreateFrame("Frame", nil, AuctionRecordFrame)
    local historyFrame = AuctionRecordFrame.historyFrame
    historyFrame:SetPoint("TOPLEFT", AuctionRecordFrame.TitleBottom, "TOPLEFT")
    historyFrame:SetSize(AuctionRecordFrame:GetWidth(), 50)
    -- background(historyFrame)

    historyFrame.ClearHistoryBtn = CreateButton(nil, historyFrame, "清空历史记录", "TOPLEFT", historyFrame, "TOPLEFT", 5, -5, 100, 20, 14, true, 0)
    local ClearHistoryBtn = historyFrame.ClearHistoryBtn
    ClearHistoryBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    ClearHistoryBtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            StaticPopup_Show("ZL_CLEARHISTORYWARNING")
        elseif button == "RightButton" then
            ZL.OpenAceConfigDialog("金团拍卖助手", "dataSave")
        end
    end)
    ClearHistoryBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddLine("提示：")
        GameTooltip:AddLine("左键：|cffffffff清空全部拍卖记录|r")
        GameTooltip:AddLine("右键：|cffffffff设置保存拍卖记录天数|r")
        GameTooltip:Show()
    end)
    ClearHistoryBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    historyFrame.nameFont = historyFrame:CreateFontString()
    local nameFont = historyFrame.nameFont
    nameFont:SetPoint("TOPLEFT", ClearHistoryBtn, "BOTTOMLEFT", 5, -8)
    nameFont:SetWidth(170)
    nameFont:SetFont(GameFontNormal:GetFont(), 15)
    nameFont:SetTextColor(1, 0.82, 0)
    nameFont:SetText("名       称")
    nameFont:SetWordWrap(false)
    nameFont:SetJustifyH("CENTER")

    historyFrame.TotalIncomeFont = historyFrame:CreateFontString()
    local TotalIncomeFont = historyFrame.TotalIncomeFont
    TotalIncomeFont:SetPoint("LEFT", nameFont, "RIGHT", 5, 0)
    TotalIncomeFont:SetWidth(80)
    TotalIncomeFont:SetFont(GameFontNormal:GetFont(), 15)
    TotalIncomeFont:SetTextColor(1, 0.82, 0)
    TotalIncomeFont:SetText("净收入(g)")
    TotalIncomeFont:SetWordWrap(false)
    TotalIncomeFont:SetJustifyH("CENTER")

    historyFrame.auctionDateFont = historyFrame:CreateFontString()
    local auctionDateFont = historyFrame.auctionDateFont
    auctionDateFont:SetPoint("LEFT", TotalIncomeFont, "RIGHT", 5, 0)
    auctionDateFont:SetWidth(170)
    auctionDateFont:SetFont(GameFontNormal:GetFont(), 15)
    auctionDateFont:SetTextColor(1, 0.82, 0)
    auctionDateFont:SetText("创建时间")
    auctionDateFont:SetWordWrap(false)
    auctionDateFont:SetJustifyH("CENTER")
    historyFrame:Hide()

    AuctionRecordFrame.currentIncomeFrame = CreateFrame("Frame", nil, AuctionRecordFrame)
    local currentIncomeFrame = AuctionRecordFrame.currentIncomeFrame
    currentIncomeFrame:SetPoint("TOPLEFT", AuctionRecordFrame.TitleBottom, "TOPLEFT")
    currentIncomeFrame:SetSize(AuctionRecordFrame:GetWidth(), 50)
    currentIncomeFrame:SetScript("OnMouseDown", function ()
        -- ClearFocus()
    end)

    currentIncomeFrame.totalIncomeFont = currentIncomeFrame:CreateFontString()
    local totalIncomeFont = currentIncomeFrame.totalIncomeFont
    totalIncomeFont:SetPoint("TOPLEFT", currentIncomeFrame, "TOPLEFT", 5, -5)
    totalIncomeFont:SetFont(GameFontNormal:GetFont(), 14)
    totalIncomeFont:SetTextColor(1, 1, 1)
    totalIncomeFont:SetText("净收入:")
    totalIncomeFont:SetWordWrap(false)
    totalIncomeFont:SetJustifyH("LEFT")

    currentIncomeFrame.notesFont = currentIncomeFrame:CreateFontString()
    local notesFont = currentIncomeFrame.notesFont
    notesFont:SetPoint("TOPLEFT", totalIncomeFont, "BOTTOMLEFT", 0, -8)
    notesFont:SetWidth(210)
    notesFont:SetFont(GameFontNormal:GetFont(), 15)
    notesFont:SetTextColor(1, 0.82, 0)
    notesFont:SetText("名      称")
    notesFont:SetWordWrap(false)
    notesFont:SetJustifyH("CENTER")

    currentIncomeFrame.playerFont = currentIncomeFrame:CreateFontString()
    local playerFont = currentIncomeFrame.playerFont
    playerFont:SetPoint("LEFT", notesFont, "RIGHT", 0, 0)
    playerFont:SetWidth(135)
    playerFont:SetFont(GameFontNormal:GetFont(), 15)
    playerFont:SetTextColor(1, 0.82, 0)
    playerFont:SetText("玩家名字")
    playerFont:SetWordWrap(false)
    playerFont:SetJustifyH("CENTER")

    currentIncomeFrame.amountFont = currentIncomeFrame:CreateFontString()
    local amountFont = currentIncomeFrame.amountFont
    amountFont:SetPoint("LEFT", playerFont, "RIGHT", 0, 0)
    amountFont:SetWidth(80)
    amountFont:SetFont(GameFontNormal:GetFont(), 15)
    amountFont:SetTextColor(1, 0.82, 0)
    amountFont:SetText("总金额")
    amountFont:SetWordWrap(false)
    amountFont:SetJustifyH("CENTER")

    currentIncomeFrame.bidCountFont = currentIncomeFrame:CreateFontString()
    local bidCountFont = currentIncomeFrame.bidCountFont
    bidCountFont:SetPoint("LEFT", amountFont, "RIGHT", -5, 0)
    bidCountFont:SetWidth(45)
    bidCountFont:SetFont(GameFontNormal:GetFont(), 15)
    bidCountFont:SetTextColor(1, 0.82, 0)
    bidCountFont:SetText("数量")
    bidCountFont:SetWordWrap(false)
    bidCountFont:SetJustifyH("CENTER")
    currentIncomeFrame:Hide()

    AuctionRecordFrame.playerBalanceFrame = CreateFrame("Frame", nil, AuctionRecordFrame)
    local playerBalanceFrame = AuctionRecordFrame.playerBalanceFrame
    playerBalanceFrame:SetPoint("TOPLEFT", AuctionRecordFrame.TitleBottom, "TOPLEFT")
    playerBalanceFrame:SetSize(AuctionRecordFrame:GetWidth(), 50)

    playerBalanceFrame.wagesCheckButton = CreateFrame("CheckButton", nil, playerBalanceFrame, "ChatConfigCheckButtonTemplate")
    playerBalanceFrame.wagesCheckButton:SetPoint("TOPLEFT", playerBalanceFrame, "TOPLEFT", 5, -8)
    playerBalanceFrame.wagesCheckButton.Text:SetText("欠款人工资")
    playerBalanceFrame.wagesCheckButton.Text:SetFont(GameFontNormal:GetFont(), 13, "")
    playerBalanceFrame.wagesCheckButton.Text:SetTextColor(1, 0.82, 0)
    playerBalanceFrame.wagesCheckButton.Text:ClearAllPoints()
    playerBalanceFrame.wagesCheckButton.Text:SetPoint("LEFT", playerBalanceFrame.wagesCheckButton , "RIGHT", -3, 0)
    playerBalanceFrame.wagesCheckButton:SetHitRectInsets(0, -playerBalanceFrame.wagesCheckButton.Text:GetWidth(), 0, 0)
    playerBalanceFrame.wagesCheckButton.tooltip = "勾选将显示欠款人工资\n|cffffffff打开邮箱或交易中不生效|r"
    playerBalanceFrame.wagesCheckButton:SetChecked(ZL.opt.showAllWages)
    playerBalanceFrame.wagesCheckButton:SetScript("OnClick", function ()
        ZL.opt.showQianKuanWages = playerBalanceFrame.wagesCheckButton:GetChecked()
        playerBalanceFrame:Update()
    end)

    playerBalanceFrame.wagesNumberFont = playerBalanceFrame:CreateFontString()
    local wagesNumberFont = playerBalanceFrame.wagesNumberFont
    wagesNumberFont:SetPoint("LEFT", playerBalanceFrame.wagesCheckButton, "RIGHT", 80, 0)
    wagesNumberFont:SetHeight(20)
    wagesNumberFont:SetFont(GameFontNormal:GetFont(), 13)
    wagesNumberFont:SetTextColor(1, 0.82, 0)
    wagesNumberFont:SetWordWrap(false)
    wagesNumberFont:SetJustifyH("LEFT")
    wagesNumberFont:SetText("人数")

    playerBalanceFrame.wagesNumber = CreateEditBox(playerBalanceFrame, 45, 20, 14, "RIGHT", true)
    local wagesNumber = playerBalanceFrame.wagesNumber
    wagesNumber:SetPoint("LEFT", wagesNumberFont, "RIGHT", 5, 0)
    wagesNumber:SetScript("OnTextChanged", function (self)
        playerBalanceFrame:Update()
    end)
    wagesNumber:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "LEFT", "RIGHT")
        GameTooltip:AddLine("注意：非特殊情况不需要手动输入！", 1, 0, 0)
        GameTooltip:AddLine("手动输入后，无论是当前名单还是历史名单\n都将按照输入人数计算工资！\n并且工资比例不生效！")
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("仅在忘记保存团员名单时使用\n并且所有成员都将按照100%比例计算工资", 1, 0, 0)
        GameTooltip:Show()
    end)
    wagesNumber:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    playerBalanceFrame.SendMsgBtn = CreateButton(nil, playerBalanceFrame, "通报", "LEFT", wagesNumber, "RIGHT", 5, 0, 40, 20, 14, true, 0)
    local SendMsgBtn = playerBalanceFrame.SendMsgBtn
    SendMsgBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    SendMsgBtn:SetScript("OnClick", function (self, button)
        local msgStr
        if not PlayerIsML() then
            msgStr = "你不是ML，无法使用该功能！"
            ZL.Print(msgStr)
            return
        end
        if button == "LeftButton" then
            if IsShiftKeyDown() then
                ZL.reportConsumerRanking()
            else
                ZL.reportIncomeConfirm()
            end
        elseif button == "RightButton" then
            ZL.reportIncomeConfirm(true)
        end
    end)
    SendMsgBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "LEFT", "RIGHT")
        local playerBuyList = ZL.GetPlayerBuyList()
        local msg = select(2, ZL.GetWagesGroupMembers())
        if msg then
            GameTooltip:AddLine(msg)
        end
        if next(playerBuyList, nil) then
            GameTooltip:AddLine("消费排名(前10)：")
            GameTooltip:AddDoubleLine("名字", "消费金额")
            local tempList = {}
            for name, value in pairs(playerBuyList) do
                tinsert(tempList, {name=name, totalAmount=value.totalAmount})
            end
            if #tempList > 1 then
                table.sort(tempList, function (a, b)
                    return a.totalAmount > b.totalAmount
                end)
            end
            for index, data in ipairs(tempList) do
                if data.totalAmount > 0  then
                    if index <= 3 then
                        GameTooltip:AddDoubleLine(data.name, data.totalAmount, 1, 0, 0, 1, 0, 0)
                    elseif index <= 10 then
                        GameTooltip:AddDoubleLine(data.name, data.totalAmount, 1, 1, 1, 1, 1, 1)
                    end
                end
            end
        else
            GameTooltip:AddLine("暂时无人消费")
        end
        GameTooltip:AddLine(" ")
        GameTooltip:AddLine("左键：|cffffffff通报详细清单工资|r")
        GameTooltip:AddLine("右键：|cffffffff通报小队工资|r")
        GameTooltip:AddLine("Shift+左键：|cffffffff通报消费排名|r")
        GameTooltip:Show()
    end)
    SendMsgBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)

    playerBalanceFrame.WCLSettingBtn = CreateButton(nil, playerBalanceFrame, "WCL设置", "LEFT", SendMsgBtn, "RIGHT", 5, 0, 75, 20, 14, true, 0)
    local WCLSettingBtn = playerBalanceFrame.WCLSettingBtn
    WCLSettingBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
    WCLSettingBtn:SetScript("OnClick", function (self, button)
        if button == "LeftButton" then
            if not ZL.ImportWCLFrame then ZL:CreateImportWCLFrame() end
            ZL.ImportWCLFrame:Show()
        else
            local menuList = {
                {
                    text = "|cffffde00刷新工资比例|r",
                    func = function ()
                        ZL.UpdateWagesBiliFromWCL()
                    end
                },
                {
                    text = "|cffffde00按比例调整队伍|r",
                    func = function ()
                        if not IsInRaid(1) then return end
                        if not (UnitIsGroupLeader("player") or UnitIsGroupAssistant("player")) then
                            ZL.Print("团长或助理权限才可以调整队伍。", true)
                            return
                        end
                        for i = 1, MAX_RAID_MEMBERS do
                            if UnitAffectingCombat("raid" .. i) then
                                ZL.Print("有队员正在战斗中，无法调整队伍。", true)
                                return
                            end
                        end
                        local function tempfunc()
                            local continue = true
                            local startTime = time()
                            ZL.Print("开始调整队伍，预计需要5-10秒钟左右, |cffff0000期间鼠标不要操作其它事情！|r", true)
                            while continue and (time() - startTime <= 10) do
                                continue = false
                                local WagesGroupMembers = ZL.GetWagesGroupMembers()
                                if (not WagesGroupMembers) then return end
                                local bill = ZL_CURRENT
                                local BiLiList = {}
                                local tempBiLiList = {}
                                local wagesMembers = {}
                                local biLi = 0
                                local pruneName, raidIndex
                                for _, data in ipairs(WagesGroupMembers) do
                                    if #data > 0 then
                                        for _, name in ipairs(data) do
                                            pruneName = ZL.pruneCrossRealm(name)
                                            raidIndex = UnitInRaid(pruneName)
                                            if raidIndex then
                                                if (not bill.WagesBiLi) or (not bill.WagesBiLi[name]) or (not bill.WagesBiLi[name]["biLi"]) then
                                                    biLi = 100
                                                elseif bill.WagesBiLi[name]["biLi"] <= 0 then
                                                    biLi = 0
                                                else
                                                    biLi = bill.WagesBiLi[name]["biLi"]
                                                end
                                                if biLi > 0  then
                                                    if not BiLiList[biLi] then
                                                        BiLiList[biLi] = {}
                                                        tinsert(tempBiLiList, biLi)
                                                    end
                                                    tinsert(BiLiList[biLi], pruneName)
                                                    wagesMembers[pruneName] = true
                                                end
                                            end
                                        end
                                    end
                                end
                                sort(tempBiLiList, function (a, b)
                                    return a > b
                                end)
                                local roster = {}
                                for i = 1, 8 do roster[i] = {} end
                                local group = 1
                                for j, v in ipairs(tempBiLiList) do
                                    for i, name in ipairs(BiLiList[v]) do
                                        tinsert(roster[group], name)
                                        if #roster[group] == 5 and i ~= #BiLiList[v] then
                                            group = group + 1
                                        end
                                    end
                                    if j ~= #tempBiLiList then
                                        group = group + 1
                                    end
                                    if group > 8 then
                                        ZL.Print("|cffff0000工资比例种类太多，无法按小队调整队伍！|r", true)
                                        return
                                    end
                                end
                                --调整到对应的队伍
                                local raidIndex1, raidIndex2, subgroup1, slotBtn, newName
                                local RLName = GetRaidRosterInfo(1)
                                for i = 1, 8 do
                                    for j, playerName in ipairs(roster[i]) do
                                        raidIndex1 = UnitInRaid(playerName)
                                        if raidIndex1 then
                                            subgroup1 = select(3, GetRaidRosterInfo(raidIndex1))
                                            if i ~= subgroup1 then
                                                continue = true
                                                if roster[i][1] ~= RLName and playerName ~= RLName and _G["RaidGroup" .. i.. "Slot1"].button and _G[_G["RaidGroup" .. i.. "Slot1"].button].name == RLName then
                                                    j = j + 1
                                                end
                                                slotBtn = _G["RaidGroup" .. i.. "Slot" .. j].button
                                                if slotBtn then
                                                    raidIndex2 = tonumber(strmatch(slotBtn, "^RaidGroupButton(%d+)$"))
                                                    if raidIndex2 then
                                                        if raidIndex1 ~= raidIndex2 then
                                                            if i ~= subgroup1 then
                                                                --不在一队，直接对调
                                                                newName = nil
                                                                SwapRaidSubgroup(raidIndex2, raidIndex1)
                                                                while newName ~= playerName do
                                                                    sleep(0.2)
                                                                    newName = _G[slotBtn].name
                                                                end
                                                            end
                                                        end
                                                    end
                                                else
                                                    SetRaidSubgroup(raidIndex1, i)
                                                    newName = nil
                                                    while newName ~= playerName do
                                                        sleep(0.2)
                                                        for k = 1, 5 do
                                                            slotBtn = _G["RaidGroup" .. i.. "Slot" .. k].button
                                                            if slotBtn then
                                                                newName = _G[slotBtn].name
                                                                if newName == playerName then
                                                                    break
                                                                end
                                                            end
                                                        end
                                                    end
                                                end
                                            end
                                        end
                                    end
                                end
                                --将没有工资成员移动到后面队伍(需位置够)
                                local removeList = {}
                                local name, _
                                for i = 1, MAX_RAID_MEMBERS do
                                    name = GetRaidRosterInfo(i)
                                    if name and not wagesMembers[name] then
                                        tinsert(removeList, name)
                                    end
                                end
                                if #removeList > 0 then
                                    local startGroup = 8
                                    for _, v in ipairs(removeList) do
                                        raidIndex1 = UnitInRaid(v)
                                        subgroup1 = select(3, GetRaidRosterInfo(raidIndex1))
                                        while true do
                                            if subgroup1 == startGroup then
                                                break
                                            end
                                            if startGroup <= group then
                                                ZL.Print("|cffff0000小队位置不够，无法调整没有工资成员队伍！|r", true)
                                                return
                                            end
                                            local hasSlot
                                            for k = 1, 5 do
                                                slotBtn = _G["RaidGroup" .. startGroup.. "Slot" .. k].button
                                                if not slotBtn then
                                                    hasSlot = true
                                                    break
                                                end
                                            end
                                            if not hasSlot then
                                                startGroup = startGroup - 1
                                            else
                                                continue = true
                                                SetRaidSubgroup(raidIndex1, startGroup)
                                                newName = nil
                                                while newName ~= v do
                                                    sleep(0.2)
                                                    for k = 1, 5 do
                                                        slotBtn = _G["RaidGroup" .. startGroup.. "Slot" .. k].button
                                                        if slotBtn then
                                                            newName = _G[slotBtn].name
                                                            if newName == v then
                                                                break
                                                            end
                                                        end
                                                    end
                                                end
                                                break
                                            end
                                        end
                                    end
                                end
                                --如果使用的是快照名单，调整当前快照名单顺序
                                local wagesGroupMembersIndex = (bill["globalConfig"] and bill["globalConfig"]["wagesGroupMembers"]) and bill["globalConfig"]["wagesGroupMembers"] or 0
                                if wagesGroupMembersIndex ~= 0 then
                                    local newList = {}
                                    local afterList = {}
                                    for i = 1, 8 do newList[i] = {} end
                                    for _, data in ipairs(WagesGroupMembers) do
                                        for _, name in ipairs(data) do
                                            pruneName = ZL.pruneCrossRealm(name)
                                            raidIndex = UnitInRaid(pruneName)
                                            if raidIndex then
                                                subgroup1 = select(3, GetRaidRosterInfo(raidIndex))
                                                for k = 1, 5 do
                                                    slotBtn = _G["RaidGroup" .. subgroup1.. "Slot" .. k].button
                                                    if slotBtn then
                                                        newName = _G[slotBtn].name
                                                        if newName == pruneName then
                                                            newList[subgroup1][k] = name
                                                            break
                                                        end
                                                    end
                                                end
                                            else
                                                tinsert(afterList, name)
                                            end
                                        end
                                    end
                                    --不在团队中的放到队伍后面
                                    if #afterList > 0 then
                                        for ii = #afterList, 1, -1 do
                                            local isbreak
                                            for i = 8, 1, -1 do
                                                for j = 5, 1, -1 do
                                                    if not newList[i][j] then
                                                        newList[i][j] = afterList[ii]
                                                        isbreak = true
                                                        break
                                                    end
                                                end
                                                if isbreak then break end
                                            end
                                        end
                                    end
                                    local GroupMembersList = {}
                                    for i = 1, 8 do GroupMembersList[i] = {} end
                                    for i, data in ipairs(newList) do
                                        for j = 1, 5 do
                                            if data[j] then
                                                tinsert(GroupMembersList[i], data[j])
                                            end
                                        end
                                    end
                                    bill["GroupMembersList"][wagesGroupMembersIndex]["list"] = GroupMembersList
                                end
                                if continue and (time() - startTime <= 10) then sleep(0.5) end
                            end
                            if playerBalanceFrame:IsShown() then
                                playerBalanceFrame:Update()
                            end
                            if continue then
                                ZL.Print("|cffff0000队伍调整已超时，如未调整完成，请重新尝试！", true)
                            else
                                ZL.Print("队伍调整完成！", true)
                            end
                        end
                        local co = coroutine.create(tempfunc)
                        local success, reason = coroutine.resume(co)
                        -- print("线程结束", success, reason)
                    end
                },
                {
                    text = "自动更新工资比例",
                    tooltipTitle = "|cffffde00成功导入WCL分数后自动更新工资比例|r",
                    tooltipOnButton = 1,
                    checkable = 1,
                    isNotRadio = 1,
                    checked = ZL.opt.AutoUpdateWagesBiliByWCL,
                    keepShownOnClick= 1,
                    func = function (_, data)
                        ZL.opt.AutoUpdateWagesBiliByWCL = data.checked
                    end
                }
            }
            ZL.GUI:ToggleMenu(self, menuList, "cursor")
        end
    end)
    WCLSettingBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOMRIGHT", "TOPRIGHT")
        GameTooltip:AddLine(">>右键更多功能<<", 1, 1, 1)
        GameTooltip:Show()
    end)
    WCLSettingBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    function ZL.inputSubsidy()
        if ZL_CURRENT.subsidy and next(ZL_CURRENT.subsidy) then
            local RLBuTie = select(2, ZL.GetAveWages())
            ZL_CURRENT.WagesBiLi = ZL_CURRENT.WagesBiLi or {}
            for _, data in pairs(ZL_CURRENT.WagesBiLi) do
                data["buTie"] = nil
            end
            local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
            local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
            for subsidyName, data in pairs(ZL_CURRENT.subsidy) do
                local subsidyMoney = subsidyData[subsidyName]
                if subsidyName == "RL" then
                    subsidyMoney = RLBuTie
                end
                for playerName in pairs(data) do
                    ZL_CURRENT.WagesBiLi[playerName] = ZL_CURRENT.WagesBiLi[playerName] or {}
                    ZL_CURRENT.WagesBiLi[playerName]["buTie"] = (ZL_CURRENT.WagesBiLi[playerName]["buTie"] or 0) + (subsidyMoney or 0)
                end
            end
            if playerBalanceFrame:IsShown() then
                playerBalanceFrame:Update()
            end
        end
    end
    playerBalanceFrame.autoSubsidy = CreateButton(nil, playerBalanceFrame, "填写补贴", "LEFT", SendMsgBtn, "RIGHT", 5, 0, 75, 20, 14, true, 0)
    local autoSubsidy = playerBalanceFrame.autoSubsidy
    autoSubsidy:Hide()
    autoSubsidy:SetScript("OnClick", function ()
        ZL.inputSubsidy()
    end)

    playerBalanceFrame.subsidySetting = CreateButton(nil, playerBalanceFrame, "补贴设置", "LEFT", autoSubsidy, "RIGHT", 5, 0, 75, 20, 14, true, 0)
    local subsidySetting = playerBalanceFrame.subsidySetting
    subsidySetting:SetScript("OnClick", function (self)
        if ZL.SubsidyFrame:IsShown() then
            ZL.SubsidyFrame:Hide()
        else
            ZL.SubsidyFrame:Show()
        end
    end)

    playerBalanceFrame.autoSubsidyCheckButton = CreateFrame("CheckButton", nil, playerBalanceFrame, "ChatConfigCheckButtonTemplate")
    playerBalanceFrame.autoSubsidyCheckButton:Hide()
    playerBalanceFrame.autoSubsidyCheckButton:SetPoint("TOPLEFT", playerBalanceFrame.wagesCheckButton, "BOTTOMLEFT", 0, -5)
    playerBalanceFrame.autoSubsidyCheckButton.Text:SetText("根据|cff4080FF子补贴类型|r自动填写补贴")
    playerBalanceFrame.autoSubsidyCheckButton.Text:SetFont(GameFontNormal:GetFont(), 13, "")
    playerBalanceFrame.autoSubsidyCheckButton.Text:SetTextColor(1, 0.82, 0)
    playerBalanceFrame.autoSubsidyCheckButton.Text:ClearAllPoints()
    playerBalanceFrame.autoSubsidyCheckButton.Text:SetPoint("LEFT", playerBalanceFrame.autoSubsidyCheckButton , "RIGHT", -3, 0)
    playerBalanceFrame.autoSubsidyCheckButton:SetHitRectInsets(0, -playerBalanceFrame.autoSubsidyCheckButton.Text:GetWidth(), 0, 0)
    -- playerBalanceFrame.autoSubsidyCheckButton.tooltip = "勾选将显示全部成员工资\n不勾选显示欠款或有需要交易装备名单\n|cffffffff打开邮箱或交易中不生效|r"
    playerBalanceFrame.autoSubsidyCheckButton:SetChecked(ZL.opt.autoInputSubsidy)
    playerBalanceFrame.autoSubsidyCheckButton:SetScript("OnClick", function ()
        ZL.opt.autoInputSubsidy = playerBalanceFrame.autoSubsidyCheckButton:GetChecked()
        if ZL.opt.autoInputSubsidy then
            ZL.inputSubsidy()
        end
    end)

    playerBalanceFrame.butieMail = playerBalanceFrame:CreateFontString()
    local butieMail = playerBalanceFrame.butieMail
    butieMail:SetPoint("LEFT", playerBalanceFrame.autoSubsidyCheckButton , "RIGHT", playerBalanceFrame.autoSubsidyCheckButton.Text:GetWidth() + 15, 0)
    butieMail:SetFont(GameFontNormal:GetFont(), 13)
    butieMail:SetTextColor(1, 0.82, 0)
    butieMail:SetWordWrap(false)
    butieMail:SetJustifyH("LEFT")

    playerBalanceFrame.groupFont = playerBalanceFrame:CreateFontString()
    local groupFont = playerBalanceFrame.groupFont
    groupFont:SetPoint("TOPLEFT", playerBalanceFrame.autoSubsidyCheckButton, "BOTTOMLEFT", 0, -10)
    groupFont:SetWidth(15)
    groupFont:SetFont(GameFontNormal:GetFont(), 15)
    groupFont:SetTextColor(1, 0.82, 0)
    groupFont:SetTextScale(1)
    groupFont:SetText("队")
    groupFont:SetWordWrap(false)
    groupFont:SetJustifyH("CENTER")
    local bili = groupFont:GetWidth()/(groupFont:GetUnboundedStringWidth()+3)
    bili = bili <= 1 and bili or 1
    groupFont:SetTextScale(bili)

    playerBalanceFrame.playerNameFont = playerBalanceFrame:CreateFontString()
    local playerNameFont = playerBalanceFrame.playerNameFont
    playerNameFont:SetPoint("LEFT", groupFont, "RIGHT", 8, 0)
    playerNameFont:SetWidth(130)
    playerNameFont:SetFont(GameFontNormal:GetFont(), 15)
    playerNameFont:SetTextColor(1, 0.82, 0)
    playerNameFont:SetText("玩家名字")
    playerNameFont:SetWordWrap(false)
    playerNameFont:SetJustifyH("CENTER")

    playerBalanceFrame.playerBalanceFont = playerBalanceFrame:CreateFontString()
    local playerBalanceFont = playerBalanceFrame.playerBalanceFont
    playerBalanceFont:SetPoint("LEFT", playerNameFont, "RIGHT", 5, 0)
    playerBalanceFont:SetWidth(70)
    playerBalanceFont:SetFont(GameFontNormal:GetFont(), 15)
    playerBalanceFont:SetTextColor(1, 0.82, 0)
    playerBalanceFont:SetText("工资")
    playerBalanceFont:SetWordWrap(false)
    playerBalanceFont:SetJustifyH("CENTER")

    playerBalanceFrame.biLiFont = playerBalanceFrame:CreateFontString()
    local biLiFont = playerBalanceFrame.biLiFont
    biLiFont:SetPoint("LEFT", playerBalanceFont, "RIGHT", 0, 0)
    biLiFont:SetWidth(60)
    biLiFont:SetFont(GameFontNormal:GetFont(), 14)
    biLiFont:SetTextColor(1, 0.82, 0)
    biLiFont:SetTextScale(1)
    biLiFont:SetText("比例(%)")
    biLiFont:SetWordWrap(false)
    biLiFont:SetJustifyH("CENTER")
    local _bili = biLiFont:GetWidth()/(biLiFont:GetUnboundedStringWidth()+5)
    _bili = _bili <= 1 and _bili or 1
    biLiFont:SetTextScale(_bili)

    playerBalanceFrame.qianKuanFont = playerBalanceFrame:CreateFontString()
    local qianKuanFont = playerBalanceFrame.qianKuanFont
    qianKuanFont:SetPoint("LEFT", biLiFont, "RIGHT", 5, 0)
    qianKuanFont:SetWidth(80)
    qianKuanFont:SetFont(GameFontNormal:GetFont(), 15)
    qianKuanFont:SetTextColor(1, 0.82, 0)
    qianKuanFont:SetText("欠款")
    qianKuanFont:SetWordWrap(false)
    qianKuanFont:SetJustifyH("CENTER")

    playerBalanceFrame.buTieFont = playerBalanceFrame:CreateFontString()
    local buTieFont = playerBalanceFrame.buTieFont
    buTieFont:SetPoint("LEFT", qianKuanFont, "RIGHT", 0, 0)
    buTieFont:SetWidth(50)
    buTieFont:SetFont(GameFontNormal:GetFont(), 15)
    buTieFont:SetTextColor(1, 0.82, 0)
    buTieFont:SetText("补贴")
    buTieFont:SetWordWrap(false)
    buTieFont:SetJustifyH("CENTER")

    playerBalanceFrame.totalFont = playerBalanceFrame:CreateFontString()
    local totalFont = playerBalanceFrame.totalFont
    totalFont:SetPoint("LEFT", buTieFont, "RIGHT", 5, 0)
    totalFont:SetWidth(70)
    totalFont:SetFont(GameFontNormal:GetFont(), 15)
    totalFont:SetTextColor(1, 0.82, 0)
    totalFont:SetText("总计")
    totalFont:SetWordWrap(false)
    totalFont:SetJustifyH("CENTER")

    playerBalanceFrame:Hide()

    --创建滚动条
    AuctionRecordFrame.scrollFrame = CreateFrame("ScrollFrame", nil, AuctionRecordFrame, "UIPanelScrollFrameTemplate")
    AuctionRecordFrame.scrollFrame:SetPoint("TOPLEFT", AuctionRecordFrame.TitleBottom, "TOPLEFT", 3, -50)
    AuctionRecordFrame.scrollFrame:SetPoint("BOTTOMRIGHT", AuctionRecordFrame, "BOTTOMRIGHT", -3, 5)
    AuctionRecordFrame.scrollFrame:SetClipsChildren(true)
    AuctionRecordFrame.scrollFrame:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
    AuctionRecordFrame.scrollFrame.ScrollBar:ClearAllPoints()
    AuctionRecordFrame.scrollFrame.ScrollBar:SetPoint("TOPLEFT", AuctionRecordFrame.scrollFrame, "TOPRIGHT", -10, -16)
    AuctionRecordFrame.scrollFrame.ScrollBar:SetPoint("BOTTOMRIGHT", AuctionRecordFrame.scrollFrame, "BOTTOMRIGHT", -5, 16)

    local function Tab_OnClick(self)
        local frame = self:GetParent()
        local tabId = self:GetID()
        AuctionRecordFrame.scrollFrame:ClearAllPoints()
        if tabId == 1 then
            AuctionRecordFrame.scrollFrame:SetPoint("TOPLEFT", AuctionRecordFrame.TitleBottom, "TOPLEFT", 3, -50)
            historyFrame:Show()
            currentIncomeFrame:Hide()
            playerBalanceFrame:Hide()
            if historyFrame.Update then historyFrame:Update() end
        elseif tabId == 2 then
            AuctionRecordFrame.scrollFrame:SetPoint("TOPLEFT", AuctionRecordFrame.TitleBottom, "TOPLEFT", 3, -50)
            historyFrame:Hide()
            currentIncomeFrame:Show()
            playerBalanceFrame:Hide()
            currentIncomeFrame:Update()
        elseif tabId == 3 then
            AuctionRecordFrame.scrollFrame:SetPoint("TOPLEFT", AuctionRecordFrame.TitleBottom, "TOPLEFT", 3, -85)
            historyFrame:Hide()
            currentIncomeFrame:Hide()
            playerBalanceFrame:Show()
            playerBalanceFrame:Update()
        end
        AuctionRecordFrame.scrollFrame:SetPoint("BOTTOMRIGHT", AuctionRecordFrame, "BOTTOMRIGHT", -3, 4)
        PanelTemplates_SetTab(frame, tabId)
        local scrollchild = frame.scrollFrame:GetScrollChild()
        if scrollchild then
            scrollchild:Hide()
        end
        frame.scrollFrame:SetScrollChild(self.content)
        self.content:Show()
    end

    local function CreateTab(frame, numTabs, ...)
        frame.numTabs = numTabs
        local contents = {}
        local frameName = frame:GetName()
        local template = ""
        for i = 1, numTabs do
            if WOW_PROJECT_ID == 1 then
                template = "PanelTabButtonTemplate"
            else --if WOW_PROJECT_ID == 11 or WOW_PROJECT_ID == 2 then
                template = "CharacterFrameTabButtonTemplate"
            end
            local tab = CreateFrame("Button", frameName.."Tab"..i, frame, template)
            tab:SetID(i)
            tab:SetText(select(i, ...))
            local fontString = tab:GetFontString()
            fontString:SetFont(GameFontNormal:GetFont(), 14)
            tab:SetScript("OnClick", Tab_OnClick)
            if WOW_PROJECT_ID == 1 then
                if i ==1 then
                    tab:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, 0)
                else
                    tab:SetPoint("TOPLEFT", _G[frameName.."Tab"..(i-1)], "TOPRIGHT", 1, 0)
                end
            else --if WOW_PROJECT_ID == 11 or WOW_PROJECT_ID == 2 then
                if i ==1 then
                    tab:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, 5)
                else
                    tab:SetPoint("TOPLEFT", _G[frameName.."Tab"..(i-1)], "TOPRIGHT", -20, 0)
                end
            end
            tab.content = CreateFrame("Frame", nil, frame.scrollFrame)
            tab.content:SetPoint("TOPLEFT", frame.scrollFrame, "TOPLEFT")
            tab.content:SetSize(frame.scrollFrame:GetWidth() - 40, 600)
            tab.content:Hide()
            tinsert(contents, tab.content)
        end
        Tab_OnClick(_G[frameName.."Tab1"])
        return unpack(contents)
    end

    local historyContent, currentIncomeContent, playerBalanceContent = CreateTab(AuctionRecordFrame, 3, "历史", "收支", "工资")

    currentIncomeFrame.dropDown = CreateFrame("FRAME", "ZLcurrentIncomeFrameDropDown", currentIncomeContent, "UIDropDownMenuTemplate")
    UIDropDownMenu_SetWidth(currentIncomeFrame.dropDown, 8)
    currentIncomeFrame.dropDown:SetScale(1)
    currentIncomeFrame.dropDown:Hide()
    UIDropDownMenu_Initialize(currentIncomeFrame.dropDown, function (self, level, menuList)
        local currentRoster, msg = ZL.GetWagesGroupMembers()
        if not currentRoster then return end
        local info = UIDropDownMenu_CreateInfo()
        if (level or 1) == 1 then
            if msg then
                info.text = msg
                info.notCheckable = 1
                UIDropDownMenu_AddButton(info, level)
            end
            info.isTitle = nil
            info.notCheckable = nil
            info.disabled = nil
            for i = 1, #currentRoster do
                if #currentRoster[i] > 0 then
                    info.text = "小队 " .. i
                    info.hasArrow = true
                    info.menuList = currentRoster[i]
                    UIDropDownMenu_AddButton(info, level)
                end
            end
        else
            for _, name in ipairs(menuList) do
                info.text = name
                info.hasArrow = false
                info.func = function()
                    --如果原来的名字是ML，则需将SelfAuction数据清除掉, ZL_CURRENT.IncomeList[v].isTraded改成false
                    local v = currentIncomeFrame.currenIndex
                    local f = currentIncomeFrame.entries[v]
                    local textName = f.playerbox:GetText()
                    local incomelist = ZL_CURRENT.IncomeList[v]
                    if PlayerIsML(textName) then
                        if ZL_CURRENT["playerPayToML"] and ZL_CURRENT["playerPayToML"][textName] then
                            ZL_CURRENT["playerPayToML"][textName] = ZL_CURRENT["playerPayToML"][textName] - incomelist.amount
                        end
                        if incomelist["itemList"] and next(incomelist["itemList"], nil) then
                            for key, data in pairs(incomelist["itemList"]) do
                                local itemId = string.match(key, "|c.-|Hitem:(%d+):")
                                if itemId and (tonumber(itemId)==45038 or tonumber(itemId)==50274) then
                                    ZL_CURRENT.IncomeList[v]["itemList"][key].isTraded = true
                                else
                                    ZL_CURRENT.IncomeList[v]["itemList"][key].isTraded = false
                                end
                                if data.itemGUID and #data.itemGUID > 0 then
                                    for _, value in ipairs(data.itemGUID) do
                                        ZL_CURRENT["SelfAuction"][value] = nil
                                    end
                                end
                            end
                        end
                    end
                    if incomelist.tradeId then
                        --修改拍卖清单的记录
                        local spawnLIst = {}
                        if incomelist.itemList and next(incomelist.itemList, nil) then
                            for _, value in pairs(incomelist.itemList) do
                                if value["spawnUID"] and next(value["spawnUID"], nil) then
                                    for key2 in pairs(value["spawnUID"]) do
                                        spawnLIst[key2] = true
                                    end
                                end
                            end
                        end
                        if ZL_CURRENT.auctionlist then
                            for _, data in ipairs(ZL_CURRENT.auctionlist) do
                                if data.tradeId == incomelist.tradeId then
                                    if data["spawnUID"] and next(data["spawnUID"], nil) then
                                        for key, value in pairs(data["spawnUID"]) do
                                            if spawnLIst[key] then
                                                if value.successBidder and next(value.successBidder, nil) then
                                                    for palyerName, value2 in pairs(value.successBidder) do
                                                        if palyerName == textName then
                                                            value.successBidder[name] = value2
                                                            value.successBidder[palyerName] = nil
                                                        end
                                                    end
                                                end
                                                if value["itemGUID"] and next(value["itemGUID"], nil) then
                                                    for _, value2 in pairs(value["itemGUID"]) do
                                                        if value2["isUsed"] == textName then
                                                            value2["isUsed"] = name
                                                        end
                                                    end
                                                end
                                            end
                                        end
                                    end
                                    break
                                end
                            end
                        end
                    end
                    f.playerbox:SetText(name)
                    ZL_CURRENT.IncomeList[v].player = name
                    if PlayerIsML(name) then
                        if not ZL_CURRENT["playerPayToML"] then ZL_CURRENT["playerPayToML"] = {} end
                        ZL_CURRENT["playerPayToML"][name] = ZL_CURRENT["playerPayToML"][name] + incomelist.amount
                        if incomelist["itemList"] and next(incomelist["itemList"], nil) then
                            for key, data in pairs(incomelist["itemList"]) do
                                ZL_CURRENT.IncomeList[v]["itemList"][key].isTraded = true
                                if data.itemGUID and #data.itemGUID > 0 then
                                    for _, value in ipairs(data.itemGUID) do
                                        ZL_CURRENT["SelfAuction"][value] = true
                                    end
                                end
                            end
                        end
                    end
                    info.checked = true
                    CloseDropDownMenus()
                end
                UIDropDownMenu_AddButton(info, level)
            end
        end
    end)
    local function OnEnter(self)
        self:GetParent():SetNormalTexture("Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar")
    end
    local function OnLeave(self)
        local normalTexture = self:GetParent():GetNormalTexture()
        if normalTexture then
            normalTexture:Hide()
        end
    end
    historyFrame.entries = setmetatable({}, {
        __index = function(t, v)
            local f = CreateFrame("Button", nil, historyContent)
            if v > 1 then
                f:SetPoint("TOPLEFT", t[v - 1], "BOTTOMLEFT", 0, 0)
                f:SetPoint("TOPRIGHT", t[v - 1], "BOTTOMRIGHT", 0, 0)
            else
                f:SetPoint("TOPLEFT", historyContent, "TOPLEFT", 0, -8)
                f:SetPoint("TOPRIGHT", historyContent, "TOPRIGHT", 0, -8)
            end
            f:SetHeight(25)
            f:SetScript("OnEnter", function (self)
                self:SetNormalTexture("Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar")
            end)
            f:SetScript("OnLeave", function (self)
                local normalTexture = self:GetNormalTexture()
                if normalTexture then
                    normalTexture:Hide()
                end
            end)
            f.nameEditBox = CreateEditBox(f, 170, 25, 13, "LEFT")
            f.nameEditBox:SetPoint("LEFT", f, "LEFT", 5, 0)
            f.nameEditBox:Disable()
            f.nameEditBox:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self, "RIGHT", "LEFT")
                GameTooltip:AddLine(self:GetText())
                GameTooltip:Show()
            end)
            f.nameEditBox:SetScript("OnLeave", function (self)
                OnLeave(self)
                GameTooltip:Hide()
            end)

            f.totalIncomeBox = CreateEditBox(f, 80, 25, 13, "RIGHT")
            f.totalIncomeBox:SetPoint("LEFT", f.nameEditBox, "RIGHT", 0, 0)
            f.totalIncomeBox:SetTextInsets(0, 2, 0, 0)
            f.totalIncomeBox:Disable()
            f.totalIncomeBox:SetScript("OnEnter", function (self)
                OnEnter(self)
            end)
            f.totalIncomeBox:SetScript("OnLeave", function (self)
                OnLeave(self)
            end)

            f.auctiondateBox = CreateEditBox(f, 170, 25, 13, "RIGHT")
            f.auctiondateBox:SetPoint("LEFT", f.totalIncomeBox, "RIGHT", 0, 0)
            f.auctiondateBox:SetTextInsets(0, 2, 0, 0)
            f.auctiondateBox:Disable()
            f.auctiondateBox:SetScript("OnEnter", function (self)
                OnEnter(self)
            end)
            f.auctiondateBox:SetScript("OnLeave", function (self)
                OnLeave(self)
            end)

            f.del = CreateButton(nil, f, "-", "LEFT", f.auctiondateBox, "RIGHT", 0, 0, 25, 25)
            f.del:RegisterForClicks("LeftButtonUp", "RightButtonUp")
            f.del:SetScript("OnClick", function (self, button)
                if button == "LeftButton" then
                    StaticPopup_Show("ZL_DELETEHISTORYWARNING", nil, nil, v)
                elseif button == "RightButton" then
                    ZL.OverviewFrame:Show()
                    ZL.OverviewFrame:Update(ZL_HISTORY[v])
                end
            end)
            f.del:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self, "LEFT", "RIGHT")
                local count1 = ZL_HISTORY[v].IncomeList and #ZL_HISTORY[v].IncomeList or 0
                local count2 = ZL_HISTORY[v].butie and #ZL_HISTORY[v].butie or 0
                if count1 + count2 > 0 then
                    GameTooltip:AddLine("收支记录：")
                    GameTooltip:AddDoubleLine("名称", "玩家    ".. pad_left("金额", 20))
                    if count1 > 0 then
                        for _, data in ipairs(ZL_HISTORY[v].IncomeList) do
                            local itemId = string.match(data.notes, "|c.-|Hitem:(%d+):")
                            local amount = ""
                            if data.amount > 0 then
                                amount = pad_left(tostring(data.amount), 9)
                            else
                                amount = pad_left(tostring(data.amount), 8)
                            end
                            if itemId then
                                GameTooltip:AddDoubleLine(
                                    "|T" .. cGetItemIcon(data.notes) .. ":12|t " .. data.notes,
                                    data.player .. "        " .. amount .. "|cffffd100g|r", 1, 1, 1, 1, 1, 1)
                            else
                                GameTooltip:AddDoubleLine(
                                    "|T:12|t " .. data.notes,
                                    data.player .. "        " .. amount .. "|cffffd100g|r", 1, 1, 1, 1, 1, 1)
                            end
                        end
                    end
                    if count2 > 0 then
                        for _, data in ipairs(ZL_HISTORY[v].butie) do
                            local itemId = string.match(data.notes, "|c.-|Hitem:(%d+):")
                            local amount = ""
                            if data.amount > 0 then
                                amount = pad_left(tostring(data.amount), 9)
                            else
                                amount = pad_left(tostring(data.amount), 8)
                            end
                            if itemId then
                                GameTooltip:AddDoubleLine(
                                    "|T" .. cGetItemIcon(data.notes) .. ":12|t " .. data.notes,
                                    data.player .. "        " .. amount .. "|cffffd100g|r", 1, 1, 1, 1, 1, 1)
                            else
                                GameTooltip:AddDoubleLine(
                                    "|T:12|t " .. data.notes,
                                    data.player .. "        " .. amount .. "|cffffd100g|r", 1, 1, 1, 1, 1, 1)
                            end
                        end
                    end
                else
                    GameTooltip:AddLine("没有收支记录！")
                end
                GameTooltip:AddLine(" ")
                GameTooltip:AddLine("左键：|cffffffff删除该条拍卖记录，注意无法恢复！|r")
                GameTooltip:AddLine("右键：|cffffffff查看账单|r")
                GameTooltip:Show()
            end)
            f.del:SetScript("OnLeave", function (self)
                GameTooltip:Hide()
                OnLeave(self)
            end)
            f.res = CreateButton(nil, f, "", "LEFT", f.del, "RIGHT", 0, 0, 25, 25)
            f.res:SetNormalTexture("Interface\\Buttons\\UI-RotationLeft-Button-Up")
            f.res:SetPushedTexture("Interface\\Buttons\\UI-RotationLeft-Button-Down")
            f.res:SetScript("OnClick", function ()
                local msgStr
                if PlayerIsML() or (not IsInRaid(1)) then
                    if GetAuctioningCount() > 0 then
                        ZL.Print("存在正在拍卖中的物品，无法切换！")
                        return
                    end
                    if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
                        local totalincome = 0
                        if ZL_CURRENT.IncomeList and #ZL_CURRENT.IncomeList > 0 then
                            for _, fdata in ipairs(ZL_CURRENT.IncomeList) do
                                totalincome = totalincome + fdata.amount
                            end
                        end
                        ZL_CURRENT.totalincome = totalincome
                        tinsert(ZL_HISTORY, ZL_CURRENT)
                    end
                    ZL_CURRENT = ZL_HISTORY[v]
                    table.remove(ZL_HISTORY, v)
                    do
                        if ZL_CURRENT.auctionlist and (#ZL_CURRENT.auctionlist > 0) then
                            for num, _ in ipairs(ZL_CURRENT.auctionlist) do
                                local ff = ZL.AuctionFrame2.entries[num]
                                ff:SetValues(num)
                            end
                        end
                    end
                    ZL.AuctionFrame2:Update()
                    C_Timer.After(ZL.syncDadaCD or 0, function ()
                        ZL.syncDada() --ML切换后需要全团同步数据
                    end)
                    historyFrame:Update()
                    currentIncomeFrame:Update()
                    playerBalanceFrame:Update()
                else
                    msgStr = "团队中ML才能切换。"
                    ZL.Print(msgStr)
                end
            end)
            f.res:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self, "LEFT", "RIGHT", 3, 0)
                GameTooltip:AddLine("恢复到当前拍卖清单")
                GameTooltip:AddLine("注意：当前拍卖清单会转为历史清单！", 1, 1, 1)
                GameTooltip:Show()
            end)
            f.res:SetScript("OnLeave", function (self)
                GameTooltip:Hide()
                OnLeave(self)
            end)
            function f:SetValues(name, totalincome, auctiondate)
                self.nameEditBox:SetText(name)
                self.totalIncomeBox:SetNumber(totalincome or 0)
                self.auctiondateBox:SetText(auctiondate)
            end
            t[v] = f
            return f
        end
    })
    function historyFrame:Update()
        for _, f in ipairs(historyFrame.entries) do f:Hide() end
        if next(ZL_HISTORY, nil) then
            if #ZL_HISTORY > 1 then
                table.sort(ZL_HISTORY, function (a, b)
                    return a.auctiondate > b.auctiondate
                end)
            end
            for num, data in ipairs(ZL_HISTORY) do
                local f = historyFrame.entries[num]
                f:Show()
                f:SetValues(data.name, data.totalincome, data.auctiondate)
            end
            historyContent:SetHeight(20 * #ZL_HISTORY - 5)
        else
            historyContent:SetHeight(5)
        end
    end
    currentIncomeFrame.entries = setmetatable({}, {
        __index = function(t, v)
            local f = CreateFrame("Button", nil, currentIncomeContent)
            if v > 1 then
                f:SetPoint("TOPLEFT", t[v - 1], "BOTTOMLEFT", 0, 0)
                f:SetPoint("TOPRIGHT", t[v - 1], "BOTTOMRIGHT", 0, 0)
            else
                f:SetPoint("TOPLEFT", currentIncomeContent, "TOPLEFT", 0, -8)
                f:SetPoint("TOPRIGHT", currentIncomeContent, "TOPRIGHT", 0, -8)
            end
            f:SetHeight(25)
            f:SetScript("OnEnter", function (self)
                self:SetNormalTexture("Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar")
            end)
            f:SetScript("OnLeave", function (self)
                local normalTexture = self:GetNormalTexture()
                if normalTexture then
                    normalTexture:Hide()
                end
            end)
            f.itemicon = CreateFrame("Button", nil, f)
            f.itemicon:SetSize(24, 24)
            f.itemicon:EnableMouse(true)
            f.itemicon:SetPoint("LEFT", f, "LEFT", 0, 0)
            f.itemicon:SetScript("OnEnter", function(self)
                OnEnter(self)
                local itemId = string.match(f.notes, "|c.-|Hitem:(%d+):")
                if itemId then
                    GameTooltipShow(self, "RIGHT", "LEFT", -5)
                    GameTooltip:SetHyperlink(f.notes)
                    GameTooltip:Show()
                elseif f.notes == "[打包拍卖]" then
                    GameTooltipShow(self, "RIGHT", "LEFT", -5)
                    local data, index = ZL.FetchDataFromItemId(f.notes, 1)
                    if data then
                        local itemList = data["itemList"]
                        if itemList and next(itemList, nil) then
                            GameTooltip:AddLine("打包拍卖清单")
                            GameTooltip:AddLine(" ")
                            for _itemlink, _data in pairs(itemList) do
                                local _itemId = string.match(_itemlink, "|c.-|Hitem:(%d+):")
                                if _itemId then
                                    GameTooltip:AddDoubleLine(
                                        "|T" .. cGetItemIcon(_itemlink) .. ":12|t " .. _itemlink,
                                        _data.itemCount, 1, 1, 1, 1, 1, 1
                                    )
                                else
                                    GameTooltip:AddDoubleLine(_itemlink, _data.itemCount, 1, 1, 1, 1, 1, 1)
                                end
                            end
                        end
                    end
                    GameTooltip:Show()
                end
                
            end)
            f.itemicon:SetScript("OnLeave", function(self)
                GameTooltip:Hide()
                OnLeave(self)
            end)

            f.notesbox = CreateEditBox(f, 180, 25, 14, "LEFT")
            f.notesbox:SetPoint("LEFT", f.itemicon, "RIGHT", 5, 0)
            f.notesbox:Disable()
            f.notesbox:SetScript("OnEnterPressed", function (self)
                if (strlen(self:GetText()) > 0) then
                    if (self:GetText() ~= ZL_CURRENT.IncomeList[v].notes) then
                        ZL_CURRENT.IncomeList[v].notes = self:GetText()
                    end
                else
                    self:SetText(ZL_CURRENT.IncomeList[v].notes)
                end
                self:ClearFocus()
                currentIncomeFrame:Update()
            end)
            f.notesbox:SetScript("OnEscapePressed", function (self)
                self:SetText(ZL_CURRENT.IncomeList[v].notes)
                self:ClearFocus()
            end)
            f.notesbox:SetScript("OnMouseUp", function (self)
                if (select(1, GetCursorInfo())) == "item" then
                    self:SetText(select(3, GetCursorInfo()))
                    ClearCursor()
                end
            end)
            -- f.notesbox:SetScript("OnEditFocusGained", function (self)
            --     ZL.focusEditBox = self
            -- end)
            -- f.notesbox:SetScript("OnEditFocusLost", function (self)
            --     if ZL.focusEditBox == self then ZL.focusEditBox = nil end
            -- end)
            f.notesbox:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self,"BOTTOM", "TOP")
                GameTooltip:AddLine("如需输入物品名，|cffffd100Shift+左键|r\n点击背包物品或拍卖图标", 1, 1, 1)
                GameTooltip:Show()
            end)
            f.notesbox:SetScript("OnLeave", function (self)
                GameTooltip:Hide()
                OnLeave(self)
            end)

            f.playerbox = CreateEditBox(f, 135, 25, 14, "LEFT")
            f.playerbox:SetPoint("LEFT", f.notesbox, "RIGHT", 0, 0)
            f.playerbox:Disable()
            -- f.playerbox:SetScript("OnEnterPressed", function (self)
            --     self:ClearFocus()
            -- end)
            -- f.playerbox:SetScript("OnEscapePressed", function (self)
            --     self:SetText(ZL_CURRENT.IncomeList[v].player)
            --     self:ClearFocus()
            -- end)
            -- f.playerbox:SetScript("OnEnter", function (self)
            --     OnEnter(self)
            --     if PlayerIsML() then
            --         currentIncomeFrame.currenIndex = v
            --         currentIncomeFrame.dropDown:SetPoint("RIGHT", self, "RIGHT", 18, -2)
            --         _G["ZLcurrentIncomeFrameDropDown"]:SetFrameLevel(f.playerbox:GetFrameLevel() + 1)
            --         currentIncomeFrame.dropDown:Show()
            --     else
            --         currentIncomeFrame.dropDown:Hide()
            --     end
            -- end)
            f.playerbox:SetScript("OnLeave", function (self)
                OnLeave(self)
            end)
            -- f.playerbox:SetScript("OnEditFocusLost", function (self)
            --     currentIncomeFrame.dropDown:Hide()
            -- end)
            f.amountbox = CreateEditBox(f, 80, 25, 14, "RIGHT")
            f.amountbox:SetPoint("LEFT", f.playerbox, "RIGHT", 0, 0)
            f.amountbox:SetTextInsets(0, 2, 0, 0)
            f.amountbox:SetScript("OnEnterPressed", function (self)
                if (strlen(self:GetText()) > 0) then
                    if (self:GetNumber() ~= ZL_CURRENT.IncomeList[v].amount) then
                        ZL_CURRENT.IncomeList[v].amount = self:GetNumber()
                        local incomelist = ZL_CURRENT.IncomeList[v]
                        local textName = incomelist["player"]
                        if incomelist.tradeId then
                            local spawnLIst = {}
                            if incomelist.itemList and next(incomelist.itemList, nil) then
                                for _, value in pairs(incomelist.itemList) do
                                    if value["spawnUID"] and next(value["spawnUID"], nil) then
                                        for key2 in pairs(value["spawnUID"]) do
                                            spawnLIst[key2] = true
                                        end
                                    end
                                end
                            end
                            if ZL_CURRENT.auctionlist then
                                for _, data in ipairs(ZL_CURRENT.auctionlist) do
                                    if data.tradeId == incomelist.tradeId then
                                        if data["spawnUID"] and next(data["spawnUID"], nil) then
                                            for key, value in pairs(data["spawnUID"]) do
                                                if spawnLIst[key] then
                                                    if value.successBidder and next(value.successBidder, nil) then
                                                        for palyerName in pairs(value.successBidder) do
                                                            if palyerName == textName then
                                                                value.successBidder[palyerName ].amount = incomelist["amount"]
                                                            end
                                                        end
                                                    end
                                                end
                                            end
                                        end
                                        break
                                    end
                                end
                            end
                        end
                    end
                else
                    self:SetText(ZL_CURRENT.IncomeList[v].amount)
                end
                self:ClearFocus()
                currentIncomeFrame:Update()
            end)
            f.amountbox:SetScript("OnEscapePressed", function (self)
                self:SetText(ZL_CURRENT.IncomeList[v].amount)
                self:ClearFocus()
            end)
            f.amountbox:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self, "LEFT", "RIGHT")
                GameTooltip:AddLine("注意：")
                GameTooltip:AddLine("如需修改，只允许填写|cffffd100数字|r！", 1, 1, 1)
                GameTooltip:AddLine("按Enter键保存", 1, 1, 1)
                GameTooltip:Show()
            end)
            f.amountbox:SetScript("OnLeave", function (self)
                OnLeave(self)
                GameTooltip:Hide()
            end)
            f.bidCountBox = CreateEditBox(f, 35, 25, 14, "RIGHT")
            f.bidCountBox:Disable()
            f.bidCountBox:SetPoint("LEFT", f.amountbox, "RIGHT", 0, 0)
            f.bidCountBox:SetTextInsets(0, 2, 0, 0)
            f.bidCountBox:SetScript("OnEnterPressed", function (self)
                local incomeData = ZL_CURRENT.IncomeList[v]
                if (strlen(self:GetText()) > 0) then
                    if (self:GetNumber() ~= incomeData.itemCount) then
                        ZL_CURRENT.IncomeList[v].itemCount = self:GetNumber()
                        if incomeData.itemList and incomeData.itemList[incomeData.notes] then
                            ZL_CURRENT.IncomeList[v].itemList[incomeData.notes].itemCount = self:GetNumber()
                        end
                    end
                else
                    self:SetText(ZL_CURRENT.IncomeList[v].itemCount)
                end
                self:ClearFocus()
                currentIncomeFrame:Update()
            end)
            f.bidCountBox:SetScript("OnEscapePressed", function (self)
                self:SetText(ZL_CURRENT.IncomeList[v].itemCount)
                self:ClearFocus()
            end)
            f.bidCountBox:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self, "LEFT", "RIGHT")
                GameTooltip:AddLine("注意：")
                GameTooltip:AddLine("不允许直接修改数量", 1, 1, 1)
                GameTooltip:AddLine("如需修改请重新拍卖", 1, 1, 1)
                -- GameTooltip:AddLine("如需修改，只允许填写|cffffd100数字|r！", 1, 1, 1)
                -- GameTooltip:AddLine("按Enter键保存", 1, 1, 1)
                GameTooltip:Show()
            end)
            f.bidCountBox:SetScript("OnLeave", function (self)
                OnLeave(self)
                GameTooltip:Hide()
            end)

            f.del = CreateButton(nil, f, "-", "LEFT", f.bidCountBox, "RIGHT", 0, 0, 25, 25)
            f.del:SetScript("OnClick", function (self)
                local incomedata = ZL_CURRENT["IncomeList"][v]
                if incomedata then
                    if incomedata["tradeId"] then
                        if ZL_CURRENT.auctionlist and next(ZL_CURRENT.auctionlist, nil) then
                            for num, data in pairs(ZL_CURRENT.auctionlist) do
                                if data["tradeId"] == incomedata["tradeId"] then
                                    local frame = ZL.AuctionFrame2.entries[num]
                                    frame.MLframe.functionFrame.CancelBtn:Click()
                                    break
                                end
                            end
                        end
                    else
                        table.remove(ZL_CURRENT["IncomeList"], v)
                        ZL.AuctionRecordFrame.currentIncomeFrame:Update()
                        ZL.AuctionRecordFrame.playerBalanceFrame:Update()
                        local data = {
                            type = "删除拍卖记录",
                            index = v,
                            globalConfigData = ZL.globalConfigData(),
                        }
                        MyAddon:TransmitAddonInfo("AUTOAUC SYNC12", data)
                    end
                end
            end)
            f.del:SetScript("OnLeave", function (self)
                GameTooltip:Hide()
                OnLeave(self)
            end)
            function f:SetValues(notes, player, amount, itemCount)
                local itemId = string.match(notes, "|c.-|Hitem:(%d+):")
                f.itemicon:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square")
                if itemId then
                    self.itemicon:SetNormalTexture(cGetItemIcon(notes))
                elseif notes == "[打包拍卖]" then
                    self.itemicon:SetNormalTexture(ZL.LogoPath)
                else
                    self.itemicon:ClearNormalTexture()
                end
                self.notesbox:SetText(notes)
                self.playerbox:SetText(ZL.GetNoRealmName(player, true))
                self.amountbox:SetNumber(amount)
                if itemCount then
                    self.bidCountBox:SetNumber(itemCount)
                end
            end

            t[v] = f
            return f
        end
    })
    function currentIncomeFrame:Update()
        for _, f in ipairs(currentIncomeFrame.entries) do f:Hide() end
        -- if PlayerIsML() then
        --     currentIncomeFrame.dropDown:Hide()
        -- end
        local _, RLBuTie, _, _, totalamount, averageamount = ZL.GetAveWages()
        if (not ZL_CURRENT["aveWages"]) then return end
        local count = (ZL_CURRENT["IncomeList"] and #ZL_CURRENT["IncomeList"] or 0)
        if count > 0 then
            for num, data in ipairs(ZL_CURRENT["IncomeList"]) do
                local f = currentIncomeFrame.entries[num]
                f:Show()
                if PlayerIsML() then
                    if data["tradeId"] then
                        f.notesbox:Disable()
                        f.notesbox:SetScript("OnEnter", function (self)
                            OnEnter(self)
                            GameTooltipShow(self,"BOTTOM", "TOP")
                            GameTooltip:AddLine("拍卖自动录入")
                            GameTooltip:AddLine("禁止直接修改名称\n不同物品可以通过手动录入添加", 1, 1, 1)
                            GameTooltip:Show()
                        end)
                        f.bidCountBox:Disable()
                        f.bidCountBox:SetScript("OnEnter", function (self)
                            OnEnter(self)
                            GameTooltipShow(self, "LEFT", "RIGHT")
                            GameTooltip:AddLine("拍卖自动录入")
                            GameTooltip:AddLine("不允许直接修改数量", 1, 1, 1)
                            GameTooltip:AddLine("如需修改请重新拍卖", 1, 1, 1)
                            GameTooltip:Show()
                        end)
                        f.del:SetScript("OnEnter", function (self)
                            OnEnter(self)
                            GameTooltipShow(self, "LEFT", "RIGHT")
                            GameTooltip:AddLine("拍卖自动录入")
                            GameTooltip:AddLine("不可手动删除，如需删除可重新拍卖", 1, 0, 0)
                            GameTooltip:AddLine("点击后会自动重新拍卖", 1, 0, 0)
                            GameTooltip:AddLine("注意：重拍后此拍卖所有关联收入将都被删除", 1, 0, 0)
                            GameTooltip:Show()
                        end)
                    else
                        f.notesbox:Enable()
                        f.notesbox:SetScript("OnEnter", function (self)
                            OnEnter(self)
                            GameTooltipShow(self,"BOTTOM", "TOP")
                            GameTooltip:AddLine("手动录入")
                            GameTooltip:AddLine("如需输入物品名，|cffffd100Shift+左键|r\n点击背包物品或拍卖图标", 1, 1, 1)
                            GameTooltip:Show()
                        end)
                        f.bidCountBox:Enable()
                        f.bidCountBox:SetScript("OnEnter", function (self)
                            OnEnter(self)
                            GameTooltipShow(self, "LEFT", "RIGHT")
                            GameTooltip:AddLine("手动录入")
                            GameTooltip:AddLine("如需修改，只允许填写|cffffd100数字|r！", 1, 1, 1)
                            GameTooltip:AddLine("按Enter键保存", 1, 1, 1)
                            GameTooltip:Show()
                        end)
                        f.del:SetScript("OnEnter", function (self)
                            OnEnter(self)
                            GameTooltipShow(self, "LEFT", "RIGHT")
                            GameTooltip:AddLine("手动录入")
                            GameTooltip:AddLine("点击可删除，不可恢复！", 1, 0, 0)
                            GameTooltip:AddLine("如需修改，直接在文本框编辑后按Enter键", 1, 1, 1)
                            GameTooltip:Show()
                        end)
                    end
                    -- f.playerbox:Enable()
                    f.playerbox:SetScript("OnEnter", function (self)
                        OnEnter(self)
                        if PlayerIsML() then
                            currentIncomeFrame.currenIndex = num
                            currentIncomeFrame.dropDown:SetPoint("RIGHT", self, "RIGHT", 18, -2)
                            _G["ZLcurrentIncomeFrameDropDown"]:SetFrameLevel(f.playerbox:GetFrameLevel() + 1)
                            currentIncomeFrame.dropDown:Show()
                        else
                            currentIncomeFrame.dropDown:Hide()
                        end
                    end)
                    f.amountbox:Enable()
                    f.amountbox:SetScript("OnEnter", function (self)
                        OnEnter(self)
                        GameTooltipShow(self, "LEFT", "RIGHT")
                        GameTooltip:AddLine("注意：")
                        GameTooltip:AddLine("如需修改，只允许填写|cffffd100数字|r！", 1, 1, 1)
                        GameTooltip:AddLine("按Enter键保存", 1, 1, 1)
                        GameTooltip:Show()
                    end)
                    f.del:Show()

                else
                    f.notesbox:Disable()
                    f.notesbox:SetScript("OnEnter", function (self)
                        OnEnter(self)
                    end)
                    f.playerbox:Disable()
                    f.playerbox:SetScript("OnEnter", function (self)
                        OnEnter(self)
                    end)
                    f.amountbox:Disable()
                    f.amountbox:SetScript("OnEnter", function (self)
                        OnEnter(self)
                    end)
                    f.bidCountBox:Disable()
                    f.bidCountBox:SetScript("OnEnter", function (self)
                        OnEnter(self)
                    end)
                    f.del:Hide()
                end
                f:SetValues(data.notes, data.player, data.amount, data.itemCount)
                f.notes = data.notes
            end
        end
        local butie = ZL_CURRENT.butie
        if butie and #butie > 0 then
            for num, data in ipairs(butie) do
                local f = currentIncomeFrame.entries[num+count]
                f:Show()
                f.notesbox:Disable()
                f.playerbox:Disable()
                f.amountbox:Disable()
                f.bidCountBox:Disable()
                f.del:Hide()
                f:SetValues("|cff9173ff" .. data.notes .. "|r", data.player, data.amount)
                f.notes = data.notes
                f.notesbox:SetScript("OnEnter", function (self)
                    OnEnter(self)
                    GameTooltip:Hide()
                end)
                f.playerbox:SetScript("OnEnter", function (self)
                    OnEnter(self)
                    currentIncomeFrame.dropDown:Hide()
                end)
                f.amountbox:SetScript("OnEnter", function (self)
                    OnEnter(self)
                    GameTooltip:Hide()
                end)
                f.bidCountBox:SetScript("OnEnter", function (self)
                    OnEnter(self)
                    GameTooltip:Hide()
                end)
            end
        end
        local height = 5
        count = (count + #butie)
        if count > 0 then
            height = 20 * count - 5
        end
        currentIncomeContent:SetHeight(height)
        totalIncomeFont:SetText("净收入:|cffffd100" .. totalamount .. "|r")
    end
    playerBalanceFrame.entries = setmetatable({}, {
        __index = function(t, v)
            local f = CreateFrame("Button", nil, playerBalanceContent)
            if v > 1 then
                f:SetPoint("TOPLEFT", t[v - 1], "BOTTOMLEFT", 0, 0)
                f:SetPoint("TOPRIGHT", t[v - 1], "BOTTOMRIGHT", 0, 0)
            else
                f:SetPoint("TOPLEFT", playerBalanceContent, "TOPLEFT", 0, -8)
                f:SetPoint("TOPRIGHT", playerBalanceContent, "TOPRIGHT", 25, -8)
            end
            f:SetHeight(25)
            f:SetScript("OnEnter", function (self)
                self:SetNormalTexture("Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar")
            end)
            f:SetScript("OnLeave", function (self)
                local normalTexture = self:GetNormalTexture()
                if normalTexture then
                    normalTexture:Hide()
                end
            end)
            f.groupFont = f:CreateFontString()
            f.groupFont:SetPoint("LEFT", f, "LEFT", 5, 0)
            f.groupFont:SetWidth(15)
            f.groupFont:SetFont(GameFontNormal:GetFont(), 14)
            f.groupFont:SetTextColor(1, 1, 1)
            -- f.groupFont:SetText("1")
            f.groupFont:SetWordWrap(false)
            f.groupFont:SetJustifyH("LEFT")
            --ZL.CreateEditBox(parent, width, heigth, fontSize, justifyH, numeric, multiLine)
            f.nameEditBox = CreateEditBox(f, 130, 25, 14, "LEFT")
            f.nameEditBox:SetPoint("LEFT", f.groupFont, "RIGHT", 5, 0)
            f.nameEditBox:Disable()
            f.nameEditBox:SetScript("OnMouseDown", function (self, button)
                if IsShiftKeyDown() then
                    ChatEdit_ActivateChat(ChatEdit_ChooseBoxForSend())
                    HandleModifiedItemClick(ZL.ParseClassColorName(f.playerName))
                    ChatEdit_ChooseBoxForSend():HighlightText()
                    local msgStr = "已发送到聊天窗口，按Ctr+C复制"
                    ZL.ScrollingMessageFrame:AddMessage(msgStr, 1, 1, 0)
                end
            end)
            f.nameEditBox:SetScript("OnEnter", function (self)
                GameTooltipShow(self,"LEFT", "RIGHT")
                GameTooltip:AddLine("Shift+左键：|cffffffff获取名字|r")
                GameTooltip:Show()
                OnEnter(self)
            end)
            f.nameEditBox:SetScript("OnLeave", function (self)
                GameTooltip:Hide()
                OnLeave(self)
            end)
            f.balanceEditBox = CreateEditBox(f, 70, 25, 14, "RIGHT")
            f.balanceEditBox:SetPoint("LEFT", f.nameEditBox, "RIGHT")
            f.balanceEditBox:SetTextInsets(0, 3, 0, 0)
            f.balanceEditBox:Disable()
            f.balanceEditBox:SetScript("OnEnter", function (self)
                OnEnter(self)
            end)
            f.balanceEditBox:SetScript("OnLeave", function (self)
                OnLeave(self)
            end)

            f.biLiEditBox = CreateEditBox(f, 55, 25, 14, "RIGHT", true)
            f.biLiEditBox:SetPoint("LEFT", f.balanceEditBox, "RIGHT", 0, 0)
            f.biLiEditBox:SetTextInsets(0, 3, 0, 0)
            f.biLiEditBox:SetNumber(100)
            f.biLiEditBox:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self,"LEFT", "RIGHT")
                GameTooltip:AddLine("输入0-100的任意整数(ML功能)")
                GameTooltip:AddLine("0：|cffffffff表示老板，不参与工资人数计算|r")
                GameTooltip:AddLine("50：|cffffffff半G，按全工资的50%|r")
                GameTooltip:AddLine("100：|cffffffff全工资|r")
                GameTooltip:AddLine(" ")
                GameTooltip:AddLine("激活输入框，输入或鼠标滚轮设置\n工资比例，按|cffffffffEnter键或右键|r保存！")
                GameTooltip:Show()
            end)
            f.biLiEditBox:SetScript("OnLeave", function (self)
                self:HighlightText(0, 0)
                OnLeave(self)
                GameTooltip:Hide()
            end)
            f.biLiEditBox:SetScript("OnEscapePressed",function (self)
                local name = f.playerName
                local WagesBiLi = ZL_CURRENT.WagesBiLi
                if WagesBiLi and WagesBiLi[name] and WagesBiLi[name]["biLi"] then
                    self:SetNumber(WagesBiLi[name]["biLi"])
                else
                    self:SetNumber(100)
                end
                self:ClearFocus()
            end)
            f.biLiEditBox:SetScript("OnEnterPressed", function (self)
                local biLi = self:GetNumber()
                if biLi <= 0 then
                    self:SetNumber(0)
                -- elseif biLi > 100 then
                --     self:SetNumber(100)
                end
                self:HighlightText(0, 0)
                biLi = self:GetNumber()
                local name = f.playerName
                local WagesBiLi = ZL_CURRENT.WagesBiLi
                if ((not WagesBiLi) or (not WagesBiLi[name]) or (not WagesBiLi[name]["biLi"]) or (WagesBiLi[name]["biLi"] ~= biLi)) then
                    if not ZL_CURRENT.WagesBiLi then ZL_CURRENT.WagesBiLi = {} end
                    if not ZL_CURRENT.WagesBiLi[name] then ZL_CURRENT.WagesBiLi[name] = {} end
                    ZL_CURRENT.WagesBiLi[name]["biLi"] = biLi
                    playerBalanceFrame:Update()
                end
                self:ClearFocus()
            end)
            f.biLiEditBox:SetScript("OnMouseWheel", function (self, delta)
                if self:HasFocus() then
                    local number = self:GetNumber()
                    if delta > 0 then
                        number = number + 10
                    else
                        number = number - 10
                    end
                    if number < 0 then
                        number = 0
                    -- elseif number > 100 then
                    --     number = 100
                    end
                    self:SetNumber(number)
                end
            end)
            f.biLiEditBox:SetScript("OnMouseDown", function(self, button)
                if button == "RightButton" and self:HasFocus() then
                    local biLi = self:GetNumber()
                    if biLi <= 0 then
                        self:SetNumber(0)
                    -- elseif biLi > 100 then
                    --     self:SetNumber(100)
                    end
                    biLi = self:GetNumber()
                    local name = f.playerName
                    local WagesBiLi = ZL_CURRENT.WagesBiLi
                    if ((not WagesBiLi) or (not WagesBiLi[name]) or (not WagesBiLi[name]["biLi"]) or (WagesBiLi[name]["biLi"] ~= biLi)) then
                        if not ZL_CURRENT.WagesBiLi then ZL_CURRENT.WagesBiLi = {} end
                        if not ZL_CURRENT.WagesBiLi[name] then ZL_CURRENT.WagesBiLi[name] = {} end
                        if biLi == 100 then
                            ZL_CURRENT.WagesBiLi[name]["biLi"] = nil
                        else
                            ZL_CURRENT.WagesBiLi[name]["biLi"] = biLi
                        end
                        playerBalanceFrame:Update()
                    end
                    C_Timer.After(0.3, function ()
                        self:ClearFocus()
                    end)
                end
            end)
            f.biLiEditBox:SetScript("OnTextChanged", function (self)
                local biLi = self:GetNumber()
                if biLi <= 0 then
                    self:SetNumber(0)
                -- elseif biLi > 100 then
                --     self:SetNumber(100)
                end
            end)
            f.biLiEditBox:SetScript("OnEditFocusLost",function (self)
                self:HighlightText(0, 0)
                local biLi = self:GetNumber()
                local name = f.playerName
                local WagesBiLi = ZL_CURRENT.WagesBiLi
                if (not WagesBiLi) or (not WagesBiLi[name]) or (not WagesBiLi[name]["biLi"]) or (wagesNumber:GetNumber() > 0) then
                    self:SetNumber(100)
                elseif biLi ~= WagesBiLi[name]["biLi"] then
                    self:SetNumber(WagesBiLi[name]["biLi"])
                end
            end)

            f.qianKuanEditBox = CreateEditBox(f, 85, 25, 14, "RIGHT")
            f.qianKuanEditBox:SetPoint("LEFT", f.biLiEditBox, "RIGHT")
            f.qianKuanEditBox:SetTextInsets(0, 3, 0, 0)
            f.qianKuanEditBox:Disable()
            f.qianKuanEditBox:SetScript("OnEnter", function (self)
                OnEnter(self)
            end)
            f.qianKuanEditBox:SetScript("OnLeave", function (self)
                OnLeave(self)
            end)

            f.buTieEditBox = CreateEditBox(f, 55, 25, 14, "RIGHT", true)
            f.buTieEditBox:SetPoint("LEFT", f.qianKuanEditBox, "RIGHT", 0, 0)
            f.buTieEditBox:SetTextInsets(0, 3, 0, 0)
            f.buTieEditBox:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self, "LEFT", "RIGHT")
                GameTooltip:AddLine("注意(ML功能)：", 1, 0, 0)
                GameTooltip:AddLine("仅供邮寄或交易补贴用，不参与工资计算！", 1, 1, 1)
                GameTooltip:AddLine("如需计算补贴支出，请到补贴设置里面进行添加！", 1, 1, 1)
                GameTooltip:AddLine(" ")
                GameTooltip:AddLine("激活输入框，输入或鼠标滚轮设置\n补贴金额，按Enter键或右键保存！")
                GameTooltip:Show()
            end)
            f.buTieEditBox:SetScript("OnLeave", function (self)
                OnLeave(self)
                GameTooltip:Hide()
                self:HighlightText(0, 0)
            end)
            f.buTieEditBox:SetScript("OnEscapePressed",function (self)
                local name = f.playerName
                local WagesBiLi = ZL_CURRENT.WagesBiLi
                if WagesBiLi and WagesBiLi[name] and WagesBiLi[name]["buTie"] then
                    self:SetNumber(WagesBiLi[name]["buTie"])
                else
                    self:SetText("")
                end
                self:ClearFocus()
            end)
            f.buTieEditBox:SetScript("OnMouseWheel", function (self, delta)
                if self:HasFocus() then
                    local number = self:GetNumber()
                    if delta > 0 then
                        number = number + 100
                    else
                        number = number - 100
                    end
                    if number < 0 then
                        number = 0
                    end
                    self:SetNumber(number)
                end
            end)
            f.buTieEditBox:SetScript("OnMouseDown", function(self, button)
                if button == "RightButton" and self:HasFocus() then
                    local buTie = self:GetNumber()
                    if buTie <= 0 then
                        self:SetNumber(0)
                    end
                    buTie = self:GetNumber()
                    local name = f.playerName
                    local WagesBiLi = ZL_CURRENT.WagesBiLi
                    if ((not WagesBiLi) or (not WagesBiLi[name]) or (not WagesBiLi[name]["buTie"]) or (WagesBiLi[name]["buTie"] ~= buTie)) then
                        if not ZL_CURRENT.WagesBiLi then ZL_CURRENT.WagesBiLi = {} end
                        if not ZL_CURRENT.WagesBiLi[name] then ZL_CURRENT.WagesBiLi[name] = {} end
                        if buTie == 0 then
                            ZL_CURRENT.WagesBiLi[name]["buTie"] = nil
                        else
                            ZL_CURRENT.WagesBiLi[name]["buTie"] = buTie
                        end
                        playerBalanceFrame:Update()
                    end
                    C_Timer.After(0.3, function ()
                        -- self:HighlightText(0, 0)
                        self:ClearFocus()
                    end)
                end
            end)
            f.buTieEditBox:SetScript("OnEnterPressed", function (self)
                local buTie = self:GetNumber()
                if buTie <= 0 then
                    self:SetNumber(0)
                end
                self:HighlightText(0, 0)
                buTie = self:GetNumber()
                local name = f.playerName
                local WagesBiLi = ZL_CURRENT.WagesBiLi
                if ((not WagesBiLi) or (not WagesBiLi[name]) or (not WagesBiLi[name]["buTie"]) or (WagesBiLi[name]["buTie"] ~= buTie)) then
                    if not ZL_CURRENT.WagesBiLi then ZL_CURRENT.WagesBiLi = {} end
                    if not ZL_CURRENT.WagesBiLi[name] then ZL_CURRENT.WagesBiLi[name] = {} end
                    if buTie == 0 then
                        ZL_CURRENT.WagesBiLi[name]["buTie"] = nil
                    else
                        ZL_CURRENT.WagesBiLi[name]["buTie"] = buTie
                    end
                    playerBalanceFrame:Update()
                end
            end)
            f.buTieEditBox:SetScript("OnTextChanged", function (self)
                local biLi = self:GetNumber()
                if biLi <= 0 then
                    self:SetNumber(0)
                end
            end)
            f.buTieEditBox:SetScript("OnEditFocusLost",function (self)
                self:HighlightText(0, 0)
                local buTie = self:GetNumber()
                local name = f.playerName
                local WagesBiLi = ZL_CURRENT.WagesBiLi
                if (not WagesBiLi) or (not WagesBiLi[name]) or (not WagesBiLi[name]["buTie"]) then
                    self:SetNumber(0)
                elseif buTie ~= WagesBiLi[name]["buTie"] then
                    self:SetNumber(WagesBiLi[name]["buTie"])
                end
            end)

            f.totalEditBox = CreateEditBox(f, 75, 25, 14, "RIGHT")
            f.totalEditBox:SetPoint("LEFT", f.buTieEditBox, "RIGHT", 0, 0)
            f.totalEditBox:SetTextInsets(0, 3, 0, 0)
            f.totalEditBox:Disable()
            f.totalEditBox:SetScript("OnEnter", function (self)
                OnEnter(self)
            end)
            f.totalEditBox:SetScript("OnLeave", function (self)
                OnLeave(self)
            end)
            f.add = CreateButton(nil, f, "平账", "LEFT", f.totalEditBox, "RIGHT", 2, 0, 30, 25, 10)
            f.add:SetScript("OnClick", function (self)
                if not PlayerIsML() then
                    local msgStr = "你不是ML，无法使用这个功能！"
                    ZL.Print(msgStr)
                    return
                end
                local qiankuan = tonumber(ParseClassColorName(f.qiankuan))
                if qiankuan < 0 then
                    ZL_CURRENT.playerPayToML = ZL_CURRENT.playerPayToML or {}
                    ZL_CURRENT.playerPayToML[f.playerName]= (ZL_CURRENT.playerPayToML[f.playerName] or 0 ) - qiankuan
                    ZL.AuctionRecordFrame.playerBalanceFrame:Update()
                end
            end)
            f.add:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self, "LEFT", "RIGHT")
                GameTooltip:AddLine("平账")
                GameTooltip:AddLine("清除欠款", 1, 1, 1)
                GameTooltip:Show()
            end)
            f.add:SetScript("OnLeave", function (self)
                OnLeave(self)
                GameTooltip:Hide()
            end)
            f.rem = CreateButton(nil, f, "-", "LEFT", f.add, "RIGHT", 0, 0, 20, 25)
            f.rem:Hide()
            f.rem:SetScript("OnClick", function (self)
                if not PlayerIsML() then
                    local msgStr = "你不是ML，无法使用这个功能！"
                    ZL.Print(msgStr)
                    return
                end
                StaticPopup_Show("ZL_REMFROMPLAYER", f.playerName, nil, f.playerName)
            end)
            f.rem:SetScript("OnEnter", function (self)
                OnEnter(self)
                GameTooltipShow(self, "LEFT", "RIGHT")
                GameTooltip:AddLine("扣除收入")
                GameTooltip:Show()
            end)
            f.rem:SetScript("OnLeave", function (self)
                OnLeave(self)
                GameTooltip:Hide()
            end)
            f.trade = CreateButton(nil, f, "交易", "LEFT", f.add, "RIGHT", 0, 0, 30, 25, 10)
            f.trade:SetScript("OnEnter",function (self)
                OnEnter(self)
                GameTooltipShow(self, "LEFT", "RIGHT")
                local name = f.playerName
                local playerBuyList = ZL.GetPlayerBuyList()
                local _, _, ML, RL = ZL.GetWagesGroupMembers()
                local _, RLBuTie = GetAveWages()
                local name_table = playerBuyList[name]
                local balance = 0 --欠款
                if name_table and name_table.items and #name_table.items > 0 then
                    if ML and name == ML then
                        GameTooltip:AddLine("消费清单|cffffffff(ML)|r:")
                    elseif RL and name == RL then
                        GameTooltip:AddLine("消费清单|cffffffff(RL)|r:")
                    else
                        GameTooltip:AddLine("消费清单:")
                    end
                    GameTooltip:AddDoubleLine("名称", "是否已交易")
                    local items = name_table.items
                    for _, data in ipairs(items) do
                        local itemId = tonumber(string.match(data.notes, "|c.-|Hitem:(%d+):"))
                        if itemId then
                            if data.isTraded then
                                GameTooltip:AddDoubleLine(data["notes"], "是", 1, 1, 1, 1, 1, 1)
                            else
                                GameTooltip:AddDoubleLine(data["notes"], "否", 1, 1, 1, 1, 0, 0)
                            end
                        else
                            GameTooltip:AddDoubleLine(data["notes"], "-", 1, 1, 1, 1, 1, 1)
                        end
                    end
                    GameTooltip:AddLine(" ")
                    local playerPayToMLamount = 0
                    if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
                        playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
                    end
                    balance = playerPayToMLamount - name_table.totalAmount
                    if PlayerIsML(name) or balance > 0 then
                        balance = 0
                    end
                    if balance < 0 then
                        GameTooltip:AddLine(("总消费：|cffffffff%d|rg，欠款：|cffffffff%d|rg"):format(name_table.totalAmount, -balance))
                    else
                        GameTooltip:AddLine(("总消费：|cffffffff%d|rg，已全部结清！"):format(name_table.totalAmount))
                    end
                else
                    GameTooltip:AddLine("没有消费记录")
                end
                local balanceAmount = 0 --工资
                local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].biLi) and (ZL_CURRENT.WagesBiLi[name].biLi/100) or 1
                local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].buTie) and ZL_CURRENT.WagesBiLi[name].buTie or 0
                local text = ""
                if biLi <= 0 then
                    text = "工　资：|cffffffff消费老板|r"
                else
                    if RL and RL == name then
                        local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
                        local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
                        local subsidyMoney = subsidyData["RL"]
                        if subsidyMoney == "团双" then
                            balanceAmount = math.floor(ZL_CURRENT["aveWages"] * biLi * 2) + balance
                            text = "工　资：|cffffffff" .. balanceAmount .. "|rg，|cffffffff团双|r"
                        elseif type(subsidyMoney) == "string" and subsidyMoney:match("%d+%%") then
                            balanceAmount = math.floor(ZL_CURRENT["aveWages"] * biLi) + balance
                            text = "工　资：|cffffffff" .. balanceAmount .. "|rg，提成：|cffffffff" .. RLBuTie .. "|rg"
                        elseif type(subsidyMoney) == "number" then
                            balanceAmount = math.floor(ZL_CURRENT["aveWages"] * biLi) + balance
                            text = "工　资：|cffffffff" .. balanceAmount .. "|rg，补贴：|cffffffff" .. RLBuTie .. "|rg"
                        else
                            balanceAmount = math.floor(ZL_CURRENT["aveWages"] * biLi) + balance
                            text = "工　资：|cffffffff" .. balanceAmount .. "|rg"
                        end
                    else
                        balanceAmount = math.floor(ZL_CURRENT["aveWages"] * biLi) + balance
                        text = "工　资：|cffffffff" .. balanceAmount .. "|rg"
                        -- if buTie > 0 then
                        --     text = text .. "，补贴：|cffffffff" .. buTie .. "|rg"
                        -- end
                    end
                end
                GameTooltip:AddLine(text)
                if (not ZL_CURRENT["mailPlayers"]) or (ZL_CURRENT["mailPlayers"][name] == nil) then
                    if ZL_CURRENT.tradeGongZi and ZL_CURRENT.tradeGongZi[name] then
                        GameTooltip:AddLine("工资已交易")
                    else
                        GameTooltip:AddLine("等待交易工资")
                    end
                elseif ZL_CURRENT["mailPlayers"][name] == false then
                    GameTooltip:AddLine("待邮寄")
                elseif ZL_CURRENT["mailPlayers"][name] == true then
                    GameTooltip:AddLine("已邮寄")
                end

                -- GameTooltip:AddLine(" ")
                -- GameTooltip:AddLine("左键：|cffffffff交易装备和欠款|r")
                -- GameTooltip:AddLine("右键：|cffffffff交易工资和补贴|r")
                GameTooltip:Show()
            end)
            f.trade:SetScript("OnLeave", function (self)
                GameTooltip:Hide()
                OnLeave(self)
            end)
            f.trade:SetScript("OnClick", function (self)
                if not PlayerIsML() then
                    ZL.Print("你不是ML，无法使用该功能！")
                    return
                end
                local total = f.total
                if not total or total <= 0 then
                    ZL.Print(f.playerName .. "没有工资！")
                    return
                end
                local name = f.playerName
                local pruneName = ZL.pruneCrossRealm(name)
                if UnitIsUnit("player", pruneName) then
                    ZL.Print("|cffff0000不能与自己交易！|r")
                    return
                end
                if ZL_CURRENT.tradeGongZi and ZL_CURRENT.tradeGongZi[name] then
                    ZL.Print(name .. "|cffff0000已交易过工资！|r")
                    return
                end
                if ZL_CURRENT["mailPlayers"] and ZL_CURRENT["mailPlayers"][name] == true then
                    ZL.Print(name .. "|cffff0000工资已经邮寄！|r")
                    return
                end
                if GetMoney() < total*10000 then
                    ZL.Print("|cffff0000金币不足，无法交易工资！|r")
                    return
                end
                local hasOpenTrade, hasCloseTrade
                local function startTrade()
                    if TradeFrame and TradeFrame:IsShown() then
                        if not hasCloseTrade and not hasOpenTrade then
                            TradeFrame:Hide()
                            hasCloseTrade = true
                            C_Timer.After(0.3, startTrade)
                        end
                        if hasOpenTrade then
                            ClickTradeButton(1)
                            C_Timer.After(0.3, function ()
                                AcceptTrade()
                            end)
                            SendChatMessage("工资：" .. total .. "，请及时确认交易！", "WHISPER", nil, pruneName)
                        end
                    else
                        if not hasOpenTrade then
                            ZL.tradeGroupGongZi = nil
                            ZL.tradeGroup = nil
                            if PlayerIsML() then
                                ZL.tradeGongZi = total
                                ZL.otherTradeGongZi = nil
                            else
                                ZL.tradeGongZi = nil
                                ZL.otherTradeGongZi = total
                            end
                            ZL.tradeName = name
                            PickupPlayerMoney(total*10000)
                            InitiateTrade(pruneName)
                            hasOpenTrade = true
                        end
                        C_Timer.After(0.1, startTrade)
                    end
                end
                startTrade()
            end)
            f.mail = CreateButton(nil, f, "邮寄", "LEFT", f.trade, "RIGHT", 0, 0, 30, 25, 10)
            f.mail:Hide()
            f.mail:SetScript("OnClick", function (self)
                if not PlayerIsML() then
                    local msgStr = "你不是ML，无法使用这个功能！"
                    ZL.Print(msgStr)
                    return
                end
                if (not _G["MailFrame"]) or (not _G["MailFrame"]:IsShown()) then
                    ZL.Print("先打开邮箱！")
                    return
                end
                local wagesGroupMembersIndex = (ZL_CURRENT["globalConfig"] and ZL_CURRENT["globalConfig"]["wagesGroupMembers"]) and ZL_CURRENT["globalConfig"]["wagesGroupMembers"] or 0
                if wagesGroupMembersIndex == 0 and ZL.AuctionRecordFrame.playerBalanceFrame.wagesNumber:GetNumber() <= 0 then
                    local msgStr = "你选择的是：|cffff0000当前团队名单|r，请输入具体的工资人数后再邮寄工资！"
                    ZL.Print(msgStr, true)
                    return
                end
                if ZL.Recipient then
                    ZL.Print("前面邮件发送还未结束，请稍后重试！")
                    return
                end
                local targetName = ParseClassColorName(f.playerName)
                local moneyToMail = tonumber(f.totalEditBox:GetText())
                if moneyToMail <= 0 then return end
                local gongZi = tonumber(f.balanceEditBox:GetText())
                local buTie = f.buTieEditBox:GetNumber()
                if (GetMoney() < (moneyToMail*10000 + 30)) then
                    ZL.ScrollingMessageFrame:AddMessage("身上G不够，已停止邮寄！", 1, 0, 0)
                    return
                end
                ZL.Recipient = f.playerName
                ZL.moneyToMail = moneyToMail
                ClearSendMail()
                SetSendMailMoney(moneyToMail * 10000)
                local contentText = ""
                if buTie > 0 then
                    contentText = "尊敬的" .. targetName .. "勇士：\n\n　　感谢您的付出，这是您的工资：" .. gongZi .. "g，补贴：" .. buTie .. "g，请及时查收，期待您下次加入！\n\n\n　　　　　　　" .. date("%Y-%m-%d %H:%M", GetServerTime())
                else
                    contentText = "尊敬的" .. targetName .. "勇士：\n\n　　感谢您的付出，这是您的工资，请及时查收，期待您下次加入！\n\n\n　　　　　　　" .. date("%Y-%m-%d %H:%M", GetServerTime())
                    -- contentText = "尊敬的" .. targetName .. "勇士：\n\n　　感谢您的付出，补发[堕落黑暗之刃]拍卖所得3000G，这是您的补发工资：" .. gongZi .. "g，请及时查收，期待您下次加入！\n\n\n　　　　　　　" .. date("%Y-%m-%d %H:%M", GetServerTime())
                end
                --添加为好友
                local UnitGuid = ZL_CURRENT["UnitGUID"] and ZL_CURRENT["UnitGUID"][f.playerName]
                local isFriend = C_FriendList.IsFriend(UnitGuid)
                local delay = 0
                if UnitGuid and (not isFriend) then
                    C_FriendList.AddFriend(targetName)
                    delay = 0.5
                end
                local function linshi()
                    if C_FriendList.IsFriend(UnitGuid) then
                        C_Timer.After(delay, function ()
                            SendMail(targetName, "<AutoAuction>工资：" .. moneyToMail .. " g", contentText)
                            --删除刚添加的好友
                            if not isFriend then
                                C_Timer.After(1, function ()
                                    C_FriendList.RemoveFriend(targetName)
                                end)
                            end
                            -- ZL_CURRENT["mailPlayers"][f.playerName] = true
                            -- playerBalanceFrame:Update()
                        end)
                    else
                        C_Timer.After(0.3, linshi)
                    end
                end
                linshi()
            end)
            f.mail:SetScript("OnEnter", function (self)
                OnEnter(self)
            end)
            f.mail:SetScript("OnLeave", function (self)
                OnLeave(self)
            end)
            function f:SetValues(playerName, balanceAmount, group, biLi, buTie, qianKuan, RL)
                local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
                local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
                local subsidyMoney = subsidyData["RL"]
                group = group or 1
                if group % 2 == 0 then
                    group = "|cff0070de" .. tostring(group) .. "|r"
                else
                    group = tostring(group)
                end
                f.playerName = playerName
                f.qiankuan = qianKuan
                self.groupFont:SetText(group)
                local pruneName = ZL.pruneCrossRealm(playerName)
                playerName = ZL.GetNoRealmName(playerName, true)
                if subsidyMoney == "团双" and f.playerName == RL then
                    playerName = playerName .. "(团双)"
                end
                self.nameEditBox:SetText(playerName)
                self.balanceEditBox:SetText(balanceAmount)
                self.biLiEditBox:SetNumber(biLi)
                self.qianKuanEditBox:SetText(qianKuan)
                self.buTieEditBox:SetNumber(buTie)
                local total = tonumber(ParseClassColorName(balanceAmount)) + tonumber(ParseClassColorName(qianKuan)) + buTie
                f.trade:Enable()
                f.total = total
                if total <= 0 or UnitIsUnit("player", pruneName) or
                (ZL_CURRENT.tradeGongZi and ZL_CURRENT.tradeGongZi[f.playerName]) or
                ZL_CURRENT["mailPlayers"] and ZL_CURRENT["mailPlayers"][f.playerName] == true or not PlayerIsML() then
                    f.trade:Disable()
                end
                if total <= 0 then
                    total = "|cffff0000" .. tostring(total) .. "|r"
                    f.mail:Disable()
                else
                    if _G["MailFrame"] and _G["MailFrame"]:IsShown() then
                        f.mail:Enable()
                    else
                        f.mail:Disable()
                    end
                end
                self.totalEditBox:SetText(total)
                if PlayerIsML() then
                    f.biLiEditBox:Enable()
                    f.buTieEditBox:Enable()
                else
                    f.biLiEditBox:Disable()
                    f.buTieEditBox:Disable()
                end
            end
            t[v] = f
            return f
        end
    })
    function playerBalanceFrame:Update()
        for _, f in ipairs(playerBalanceFrame.entries) do f:Hide() end
        local playerBuyList = ZL.GetPlayerBuyList()
        local WagesGroupMembers, _, _, RL = ZL.GetWagesGroupMembers()
        local _, _, _, totalpayout, _, averageamount = GetAveWages()
        if not averageamount then return end
        local index = 1
        local totalBuTieMail = 0
        local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
        local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
        local subsidyMoney = subsidyData["RL"]
        if _G["MailFrame"] and _G["MailFrame"]:IsShown() then --如果是打开邮箱了，则只显示名单内需要邮寄的
            -- playerBalanceFont:SetText("工资")
            if (not ZL_CURRENT["aveWages"]) then return end
            if ZL_CURRENT["mailPlayers"] and next(ZL_CURRENT["mailPlayers"], nil) and WagesGroupMembers then
                playerBalanceFrame.SendMailBtn:Enable()
                local group
                for _group, data in ipairs(WagesGroupMembers) do
                    if #data > 0 then
                        for _, name in ipairs(data) do
                            if ZL_CURRENT["mailPlayers"][name] == false then
                                group = _group
                                local balanceAmount = 0
                                local playerPayToMLamount = 0
                                local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].biLi) and (ZL_CURRENT.WagesBiLi[name].biLi/100) or 1
                                biLi = wagesNumber:GetNumber() > 0 and 1 or biLi
                                local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].buTie) and ZL_CURRENT.WagesBiLi[name].buTie or 0
                                totalBuTieMail = totalBuTieMail + buTie
                                if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
                                    playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
                                end
                                local amount = playerPayToMLamount - (playerBuyList[name] and playerBuyList[name].totalAmount or 0)
                                amount = amount > 0 and 0 or amount
                                if PlayerIsML(name) then amount = 0 end
                                balanceAmount = ZL_CURRENT["aveWages"] * biLi
                                if subsidyMoney == "团双" and name == RL then
                                    balanceAmount = balanceAmount + ZL_CURRENT["aveWages"]
                                end
                                balanceAmount = math.floor(balanceAmount)
                                if balanceAmount + amount + buTie ~= 0 then
                                    local f = playerBalanceFrame.entries[index]
                                    f:Show()
                                    local _balanceAmount
                                    if balanceAmount < 0 then
                                        _balanceAmount = "|cffff0000" .. tostring(balanceAmount) .. "|r"
                                    else
                                        _balanceAmount = balanceAmount
                                    end
                                    if amount < 0 then
                                        amount = "|cffff0000" .. tostring(amount) .. "|r"
                                    end
                                    f:SetValues(name, _balanceAmount, group, biLi*100, buTie, amount, RL)
                                    index = index + 1
                                end
                            end
                        end
                    end
                end
            end
        elseif ZL.isTrading and ZL.tradePartner and (playerBuyList[ZL.tradePartner]) then --如果在交易中则工资窗口第一个显示交易对象的记录
            -- playerBalanceFont:SetText("欠款")
            local balanceAmount = 0
            local playerPayToMLamount = 0
            local name = ZL.tradePartner
            local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].biLi) and (ZL_CURRENT.WagesBiLi[name].biLi/100) or 1
            biLi = wagesNumber:GetNumber() > 0 and 1 or biLi
            local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].buTie) and ZL_CURRENT.WagesBiLi[name].buTie or 0
            if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[ZL.tradePartner] then
                playerPayToMLamount = ZL_CURRENT.playerPayToML[ZL.tradePartner]
            end
            local amount = playerPayToMLamount - (playerBuyList[name] and playerBuyList[name].totalAmount or 0)
            amount = amount > 0 and 0 or amount
            if amount < 0 then
                amount = "|cffff0000" .. tostring(amount) .. "|r"
            end
            local group
            for _group, data in ipairs(WagesGroupMembers) do
                if #data > 0 then
                    for _, _name in ipairs(data) do
                        if name == _name then
                            group = _group
                            break
                        end
                    end
                end
            end
            balanceAmount = ZL_CURRENT["aveWages"] * biLi
            if subsidyMoney == "团双" and name == RL then
                balanceAmount = balanceAmount + ZL_CURRENT["aveWages"]
            end
            balanceAmount = math.floor(balanceAmount)
            if balanceAmount < 0 then
                balanceAmount = "|cffff0000" .. tostring(balanceAmount) .. "|r"
            end
            local f = playerBalanceFrame.entries[index]
            f:Show()
            f:SetValues(name, balanceAmount, group, biLi*100, buTie, amount, RL)
            -- f.mail:Disable()
            index = index + 1
        elseif ZL.opt.showQianKuanWages then
            for name, data in pairs(playerBuyList) do
                local balanceAmount = 0
                local playerPayToMLamount = 0
                local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].biLi) and (ZL_CURRENT.WagesBiLi[name].biLi/100) or 1
                biLi = wagesNumber:GetNumber() > 0 and 1 or biLi
                local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].buTie) and ZL_CURRENT.WagesBiLi[name].buTie or 0
                if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
                    playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
                end
                local amount = playerPayToMLamount - (playerBuyList[name] and playerBuyList[name].totalAmount or 0)
                amount = amount > 0 and 0 or amount
                balanceAmount = ZL_CURRENT["aveWages"] * biLi
                if subsidyMoney == "团双" and name == RL  then
                    balanceAmount = balanceAmount + ZL_CURRENT["aveWages"]
                end
                balanceAmount = math.floor(balanceAmount)
                if balanceAmount < 0 then
                    balanceAmount = "|cffff0000" .. tostring(balanceAmount) .. "|r"
                end
                local group
                for _group, _data in ipairs(WagesGroupMembers) do
                    if #_data > 0 then
                        for _, _name in ipairs(_data) do
                            if name == _name then
                                group = _group
                                break
                            end
                        end
                    end
                end
                local IsNotTrade = false
                for _, items in ipairs(data) do
                    if items.isTraded == false then
                        IsNotTrade = true
                        break
                    end
                end
                if PlayerIsML(name) then
                    amount = 0
                    IsNotTrade = false
                end
                if amount < 0 or IsNotTrade then
                    amount = "|cffff0000" .. tostring(amount) .. "|r"
                    local f = playerBalanceFrame.entries[index]
                    f:Show()
                    f:SetValues(name, balanceAmount, group, biLi*100, buTie, amount, RL)
                    -- f.mail:Disable()
                    index = index + 1
                end
            end
        else
            if (not ZL_CURRENT["aveWages"]) then return end
            if WagesGroupMembers then
                for group, data in ipairs(WagesGroupMembers) do
                    if #data > 0 then
                        for _, name in ipairs(data) do
                            local balanceAmount
                            local playerPayToMLamount = 0
                            local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].biLi) and (ZL_CURRENT.WagesBiLi[name].biLi/100) or 1
                            biLi = wagesNumber:GetNumber() > 0 and 1 or biLi
                            local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].buTie) and ZL_CURRENT.WagesBiLi[name].buTie or 0
                            totalBuTieMail = totalBuTieMail + buTie
                            if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
                                playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
                            end
                            local amount = playerPayToMLamount - (playerBuyList[name] and playerBuyList[name].totalAmount or 0)
                            amount = amount > 0 and 0 or amount
                            if PlayerIsML(name) then amount = 0 end
                            if amount < 0 then
                                amount = "|cffff0000" .. tostring(amount) .. "|r"
                            end
                            balanceAmount = ZL_CURRENT["aveWages"] * biLi
                            if subsidyMoney == "团双" and RL == name then
                                balanceAmount = balanceAmount + ZL_CURRENT["aveWages"]
                            end
                            balanceAmount = math.floor(balanceAmount)
                            local f = playerBalanceFrame.entries[index]
                            f:Show()
                            local _balanceAmount
                            if balanceAmount < 0 then
                                _balanceAmount = "|cffff0000" .. tostring(balanceAmount) .. "|r"
                            else
                                _balanceAmount = balanceAmount
                            end
                            f:SetValues(name, _balanceAmount, group, biLi*100, buTie, amount, RL)
                            -- if ZL_CURRENT["mailPlayers"] and ZL_CURRENT["mailPlayers"][name] == false and balanceAmount > 0 then
                            --     f.mail:Enable()
                            -- else
                            --     f.mail:Disable()
                            -- end
                            index = index + 1
                        end
                    end
                end
            end
        end
        if index > 1 then
            playerBalanceContent:SetHeight(25 * (index-1) - 5)
        else
            playerBalanceContent:SetHeight(5)
        end
        local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
        local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
        if subsidyData["RL"] == "团双" then
            totalpayout = totalpayout - averageamount
        end
        if totalBuTieMail > 0 then
            butieMail:Show()
            if totalBuTieMail <= -totalpayout then
                butieMail:SetText("输入补贴：|cffffffff" .. totalBuTieMail .. "|r， 总支出：|cffffffff" .. (totalpayout < 0 and -totalpayout or 0) .. "|r")
            else
                butieMail:SetText("输入补贴：|cffff0000" .. totalBuTieMail .. "|r， 总支出：|cffffffff" .. (totalpayout < 0 and -totalpayout or 0) .. "|r")
            end
        else
            butieMail:Hide()
        end
    end
end

--创建出价记录框架
function ZL:CreateBidderListFrame()
    ZL.BidderListFrame = CreateFrame("Frame", "ZLBidderListFrame", ZL.AuctionFrame2, BackdropTemplateMixin and "BackdropTemplate") --
    local BidderListFrame = ZL.BidderListFrame
    BidderListFrame:SetMovable(true)
    BidderListFrame:SetSize(262, 68)
    BidderListFrame:SetPoint("CENTER")
    BidderListFrame:SetToplevel(true)
    BidderListFrame:SetFrameStrata("DIALOG")
    BidderListFrame:SetFrameLevel(ZL.AuctionFrame2:GetFrameLevel() + 10)
    BidderListFrame:SetAlpha(1)
    BidderListFrame:SetBackdrop({
        bgFile = "Interface\\CharacterFrame\\UI-Party-Background",
        edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Gold-Border", --"Interface\\Tooltips\\UI-Tooltip-Border",
        tile = true, tileSize = 32, edgeSize = 6,
        insets = { left = 0, right = 0, top = 0, bottom = 0 }
    })
    BidderListFrame.closeButton = CreateFrame("Button", nil, BidderListFrame, "UIPanelCloseButton")
    BidderListFrame.closeButton:SetPoint("TOPRIGHT", BidderListFrame, "TOPRIGHT", 2, 2)
    BidderListFrame.closeButton:SetSize(20, 20)
    BidderListFrame.closeButton:SetScript("OnClick", function (self)
        BidderListFrame:Hide()
    end)
    BidderListFrame:SetScript("OnShow", function (self)
        if ZL.BidderListFrame.index then
            BidderListFrame:Update(ZL.BidderListFrame.index)
        end
    end)
    BidderListFrame:SetScript("OnEnter", function (self)
        ZL.AuctionFrame2.entries[ZL.BidderListFrame.index].zlHighlight:Show()
        -- ZL.BidderListFrame.OnShow()
    end)
    BidderListFrame:SetScript("OnLeave", function (self)
        ZL.AuctionFrame2.entries[ZL.BidderListFrame.index].zlHighlight:Hide()
    end)
    BidderListFrame:SetScript("OnShow", function ()

    end)

    BidderListFrame.PlayerNameFont = BidderListFrame:CreateFontString()
    local PlayerNameFont = BidderListFrame.PlayerNameFont
    PlayerNameFont:SetPoint("TOPLEFT", BidderListFrame, "TOPLEFT", 3, -5)
    PlayerNameFont:SetWidth(120)
    PlayerNameFont:SetFont(GameFontNormal:GetFont(), 12)
    PlayerNameFont:SetTextColor(1, 0.82, 0)
    PlayerNameFont:SetText("玩家名")
    PlayerNameFont:SetWordWrap(false)
    PlayerNameFont:SetJustifyH("CENTER")

    BidderListFrame.BidAmountFont = BidderListFrame:CreateFontString()
    local BidAmountFont = BidderListFrame.BidAmountFont
    BidAmountFont:SetPoint("LEFT", PlayerNameFont, "RIGHT", 3, 0)
    BidAmountFont:SetWidth(70)
    BidAmountFont:SetFont(GameFontNormal:GetFont(), 12)
    BidAmountFont:SetTextColor(1, 0.82, 0)
    BidAmountFont:SetText("单价")
    BidAmountFont:SetWordWrap(false)
    BidAmountFont:SetJustifyH("CENTER")

    BidderListFrame.BidCountFont = BidderListFrame:CreateFontString()
    local BidCountFont = BidderListFrame.BidCountFont
    BidCountFont:SetPoint("LEFT", BidAmountFont, "RIGHT", 3, 0)
    BidCountFont:SetWidth(40)
    BidCountFont:SetFont(GameFontNormal:GetFont(), 12)
    BidCountFont:SetTextColor(1, 0.82, 0)
    BidCountFont:SetText("数量")
    BidCountFont:SetWordWrap(false)
    BidCountFont:SetJustifyH("CENTER")

    BidderListFrame:Hide()
    BidderListFrame.entries = setmetatable({}, {
        __index = function(t, v)
            local f = CreateFrame("Frame", nil, BidderListFrame)
            if v > 1 then
                f:SetPoint("TOPLEFT", t[v - 1], "BOTTOMLEFT", 0, -1)
                f:SetPoint("TOPRIGHT", t[v - 1], "BOTTOMRIGHT", 0, -1)
            else
                f:SetPoint("TOPLEFT", PlayerNameFont, "BOTTOMLEFT", 0, -3)
                f:SetPoint("TOPRIGHT", PlayerNameFont, "BOTTOMRIGHT", 0, -3)
            end
            f:SetHeight(16)

            f.nameEditBox = CreateEditBox(f, 120, 16, 12, "CENTER")
            f.nameEditBox:SetPoint("LEFT", f, "LEFT", 0, 0)
            f.nameEditBox:Disable()
            f.nameEditBox:SetScript("OnMouseDown", function (self)
                local index = ZL.BidderListFrame.index
                local function tempfunc()
                    local menuList = {}
                    local WagesGroupMembers, msg = ZL.GetWagesGroupMembers()
                    if WagesGroupMembers and msg then
                        tinsert(menuList, {text=msg, isTitle = true})
                        local curAuctionList = ZL_CURRENT.auctionlist[index]
                        local bidderlist = curAuctionList.bidderlist
                        for i, _data in ipairs(WagesGroupMembers) do
                            if #_data > 0 then
                                local memberList = {}
                                for _, playerName in ipairs(_data) do
                                    local isCandidate = ZL.IsCandidate(index, playerName)
                                    local nameIsExist
                                    for _, data in ipairs(bidderlist) do
                                        if data.bidder == playerName then
                                            nameIsExist = true
                                            break
                                        end
                                    end
                                    tinsert(memberList, {
                                        text = function ()
                                            if nameIsExist then
                                                return ZL.GetNoRealmName(playerName).."(已存在)"
                                            else
                                                if isCandidate then
                                                    return ZL.GetNoRealmName(playerName, true)
                                                else
                                                    return ZL.GetNoRealmName(playerName).."(不可交易)"
                                                end
                                            end
                                        end,
                                        disabled = function ()
                                            if not isCandidate or nameIsExist then return true end
                                        end,
                                        func = function ()
                                            f.nameEditBox:SetText(ZL.GetNoRealmName(playerName, true))
                                            f.nameEditBox:ClearFocus()
                                            local data = {
                                                type = "修改名字",
                                                data2 = {
                                                    itemlink = curAuctionList.itemlink,
                                                    itemindex = curAuctionList.itemindex,
                                                    oldName = curAuctionList.bidderlist[v].bidder,
                                                    newName = playerName,
                                                },
                                            }
                                            MyAddon:TransmitAddonInfo("AUTOAUC SYNC6", data)
                                            for _, ff in ipairs(BidderListFrame.entries) do
                                                ff.bidAmountEditBox:Disable()
                                                ff.delBtn:Disable()
                                            end
                                        end,
                                    })
                                end
                                tinsert(menuList, {
                                    text = i .. "队",
                                    func = function ()
                                        self:ClearFocus()
                                    end,
                                    hasArrow = true,
                                    menuTable = memberList,
                                })
                            end
                        end
                        tinsert(menuList, {isSeparator = true})
                        tinsert(menuList, {text = CANCEL, func = function() self:ClearFocus() end})
                    end
                    return menuList
                end
                local menuList = tempfunc()
                if #menuList > 0 then
                    ZL.GUI:ToggleMenu(self, menuList, 'cursor')
                end
            end)

            f.nameEditBox:SetScript("OnEnter", function (self)
                local index = ZL.BidderListFrame.index
                ZL.AuctionFrame2.entries[index].zlHighlight:Show()
            end)
            f.nameEditBox:SetScript("OnLeave", function ()
                local index = ZL.BidderListFrame.index
                ZL.AuctionFrame2.entries[index].zlHighlight:Hide()
            end)

            f.bidAmountEditBox = CreateEditBox(f, 70, 16, 12, "RIGHT")
            f.bidAmountEditBox:SetPoint("LEFT", f.nameEditBox, "RIGHT", 3, 0)
            f.bidAmountEditBox:SetScript("OnEnter", function (self)
                local index = ZL.BidderListFrame.index
                ZL.AuctionFrame2.entries[index].zlHighlight:Show()
                GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
                GameTooltip:AddLine("修改出价")
                GameTooltip:AddLine("支持鼠标滚轮修改\n按Enter或右键保存", 1, 1, 1)
                GameTooltip:Show()
            end)
            f.bidAmountEditBox:SetScript("OnLeave", function (self)
                local index = ZL.BidderListFrame.index
                ZL.AuctionFrame2.entries[index].zlHighlight:Hide()
                GameTooltip:Hide()
            end)
            f.bidAmountEditBox:SetScript("OnMouseWheel", function(self, delta)
                if self:HasFocus() then
                    local number = tonumber(ParseClassColorName(self:GetText())) or 0
                    if delta > 0 then
                        number = number + 100
                    else
                        number = number - 100
                    end
                    if number < 0 then
                        number = 0
                    end
                    self:SetNumber(number)
                end
            end)
            f.bidAmountEditBox:SetScript("OnEditFocusGained", function (self)
                self:SetText("")
            end)
            local function changeBidAmount(self)
                if not IsInRaid(1) then
                    ZL.Print("不在团队中，无法修改！")
                    return
                end
                local index = ZL.BidderListFrame.index
                local curAuctionList = ZL_CURRENT.auctionlist[index]
                local bidAmount = self:GetText()
                bidAmount = bidAmount:gsub("|cffff0000", ""):gsub("|r", "")
                bidAmount = tonumber(bidAmount)
                bidAmount = (bidAmount > 0 and bidAmount) or 0
                if bidAmount> 0 and bidAmount ~= curAuctionList.bidderlist[v].bidamount then
                    local data = {
                        type = "修改出价",
                        data2 = {
                            itemlink = curAuctionList.itemlink,
                            itemindex = curAuctionList.itemindex,
                            oldName = curAuctionList.bidderlist[v].bidder,
                            newBidAmount = bidAmount,
                        },
                    }
                    MyAddon:TransmitAddonInfo("AUTOAUC SYNC6", data)
                    for _, ff in ipairs(BidderListFrame.entries) do
                        ff.bidAmountEditBox:Disable()
                        ff.delBtn:Disable()
                    end
                else
                    self:SetText(ZL_CURRENT.auctionlist[index].bidderlist[v].bidamount)
                end
                self:ClearFocus()
            end
            f.bidAmountEditBox:SetScript("OnEnterPressed", function (self)
                changeBidAmount(self)
            end)
            f.bidAmountEditBox:SetScript("OnMouseDown", function (self, button)
                if button == "RightButton" and self:HasFocus() then
                    C_Timer.After(0.5, function ()
                        changeBidAmount(self)
                    end)
                end
            end)
            f.bidAmountEditBox:SetScript("OnEscapePressed", function (self)
                local index = ZL.BidderListFrame.index
                BidderListFrame:Update(index)
            end)

            f.bidCountEditBox = CreateEditBox(f, 40, 16, 12, "RIGHT")
            f.bidCountEditBox:SetPoint("LEFT", f.bidAmountEditBox, "RIGHT", 3, 0)
            f.bidCountEditBox:Disable()
            f.bidCountEditBox:SetScript("OnEnter", function (self)
                ZL.AuctionFrame2.entries[ZL.BidderListFrame.index].zlHighlight:Show()
            end)
            f.bidCountEditBox:SetScript("OnLeave", function (self)
                ZL.AuctionFrame2.entries[ZL.BidderListFrame.index].zlHighlight:Hide()
            end)
            f.bidCountEditBox:SetScript("OnMouseDown", function (self, button)
                local curAuctionList = ZL_CURRENT.auctionlist[ZL.BidderListFrame.index]
                local itemCount = curAuctionList.itemCount
                if button == "LeftButton" and itemCount > 1 then
                    local function tempfunc()
                        local maxCount
                        if v == 1 then
                            maxCount = itemCount
                        else
                            local bidderList = curAuctionList.bidderlist
                            local totalBidCount = 0
                            for index, bidData in ipairs(bidderList) do
                                if index < v then
                                    if totalBidCount < curAuctionList.itemCount then
                                        local count = bidData["bidCount"] or 1
                                        local newTotalBidCount = totalBidCount + count
                                        if newTotalBidCount > curAuctionList.itemCount then
                                            count = curAuctionList.itemCount - totalBidCount
                                        end
                                        totalBidCount = newTotalBidCount
                                    else
                                        break
                                    end
                                else
                                    break
                                end
                            end
                            maxCount = itemCount - totalBidCount
                        end
                        maxCount = maxCount == 0 and itemCount or maxCount
                        local menuList = {}
                        for i = 1, maxCount do
                            tinsert(menuList, {
                                text = i,
                                func = function ()
                                    if not IsInRaid(1) then
                                        ZL.Print("不在团队中，无法修改！")
                                        return
                                    end
                                    local data = {
                                        type = "修改数量",
                                        data2 = {
                                            itemlink = curAuctionList.itemlink,
                                            itemindex = curAuctionList.itemindex,
                                            oldName = curAuctionList.bidderlist[v].bidder,
                                            newBidCount = i,
                                        },
                                    }
                                    MyAddon:TransmitAddonInfo("AUTOAUC SYNC6", data)
                                    for _, ff in ipairs(BidderListFrame.entries) do
                                        ff.bidAmountEditBox:Disable()
                                        ff.delBtn:Disable()
                                    end
                                end
                            })
                        end
                        return menuList
                    end
                    ZL.GUI:ToggleMenu(self, tempfunc(), "cursor")
                end
            end)

            f.delBtn = CreateButton(nil, f, "-", "LEFT", f.bidCountEditBox, "RIGHT", 3, 0, 16, 16)
            f.delBtn:SetScript("OnEnter", function (self)
                local index = ZL.BidderListFrame.index
                ZL.AuctionFrame2.entries[index].zlHighlight:Show()
                GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
                GameTooltip:AddLine("撤销出价")
                GameTooltip:Show()
            end)
            f.delBtn:SetScript("OnLeave", function ()
                local index = ZL.BidderListFrame.index
                ZL.AuctionFrame2.entries[index].zlHighlight:Hide()
                GameTooltip:Hide()
            end)
            f.delBtn:SetScript("OnClick", function (self)
                local index = ZL.BidderListFrame.index
                local curAuctionList = ZL_CURRENT.auctionlist[index]
                if curAuctionList.state ~= "auctioning" then
                    ZL.Print("不在拍卖中，无法撤销出价，请使用修改出价功能！")
                    return
                end
                local playerName = f.nameEditBox:GetText()
                if playerName and #playerName > 0 then
                    MyAddon:TransmitAddonInfo("AUTOAUC REVOKE", {
                        itemlink=curAuctionList.itemlink, itemindex=curAuctionList.itemindex, playerName=playerName
                    })
                end
            end)

            function f:SetValues(player, amount, state, count)
                self.nameEditBox:SetText(player)
                self.bidAmountEditBox:SetText(amount)
                self.bidCountEditBox:SetText(count)
                self.bidAmountEditBox:Enable()
                self.delBtn:Enable()
                f:Show()
            end

            t[v] = f
            return f
        end
    })

    function BidderListFrame:Update(v)
        if not v then return end
        for _, f in ipairs(BidderListFrame.entries) do f:Hide() end
        local curAuctionList = ZL_CURRENT.auctionlist[v]
        local bidderList = curAuctionList.bidderlist
        tableSort(bidderList)
        local totalBidCount = 0
        for index, bidData in ipairs(bidderList) do
            local f = BidderListFrame.entries[index]
            if totalBidCount < curAuctionList.itemCount then
                local count = bidData["bidCount"] or 1
                local newTotalBidCount = totalBidCount + count
                if newTotalBidCount > curAuctionList.itemCount then
                    count = curAuctionList.itemCount - totalBidCount
                end
                f:SetValues(bidData.bidder, "|cffff0000" .. tostring(bidData.bidamount) .. "|r", curAuctionList.state, count)
                totalBidCount = newTotalBidCount
            else
                f:SetValues(bidData.bidder, bidData.bidamount, curAuctionList.state, bidData["bidCount"] or 1)
            end
        end
        local height = 20 + BidAmountFont:GetHeight()
        height = height + #bidderList * 15
        height = height < 68 and 68 or height
        self:SetHeight(height)
    end
end

--创建打包拍卖清单框架
function ZL:CreatePackageListFrame()
    ZL.PackageListFrame = CreateFrame("Frame", "ZLPackageListFrame", ZL, BackdropTemplateMixin and "BackdropTemplate")
    local PackageListFrame = ZL.PackageListFrame
    PackageListFrame:SetSize(190, 100)
    PackageListFrame:SetPoint("CENTER")
    PackageListFrame:SetFrameStrata("DIALOG")
    PackageListFrame:SetFrameLevel(ZL.AuctionFrame2:GetFrameLevel() + 10)
    PackageListFrame:SetAlpha(1)
    PackageListFrame:SetBackdrop({
        bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark",
        edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
        tile = true, tileSize = 32, edgeSize = 6,
        insets = { left = 0, right = 0, top = 0, bottom = 0 }
    })
    PackageListFrame:SetScript("OnEnter", function (self)
        ZL.PackageListFrame.OnShow()
    end)
    PackageListFrame:SetScript("OnLeave", function (self)
        if ZL.PackageListFrame.time and (not ZL.PackageListFrame.time:IsCancelled()) then
            ZL.PackageListFrame.time:Cancel()
        end
        ZL.PackageListFrame.time = C_Timer.NewTimer(0.01, function (self)
            ZL.PackageListFrame.OnHide()
        end)
    end)
    PackageListFrame.TitleFont = PackageListFrame:CreateFontString()
    local TitleFont = PackageListFrame.TitleFont
    TitleFont:SetPoint("TOP", PackageListFrame, "TOP", 0, -5)
    TitleFont:SetFont(GameFontNormal:GetFont(), 14)
    TitleFont:SetTextColor(1, 0.82, 0)
    TitleFont:SetText("打包清单")
    TitleFont:SetWordWrap(false)
    TitleFont:SetJustifyH("LEFT")

    PackageListFrame.ItemNameFont = PackageListFrame:CreateFontString()
    local ItemNameFont = PackageListFrame.ItemNameFont
    ItemNameFont:SetPoint("TOPLEFT", PackageListFrame, "TOPLEFT", 10, -10-TitleFont:GetHeight())
    ItemNameFont:SetWidth(120)
    ItemNameFont:SetFont(GameFontNormal:GetFont(), 12)
    ItemNameFont:SetTextColor(1, 0.82, 0)
    ItemNameFont:SetText("名称")
    ItemNameFont:SetWordWrap(false)
    ItemNameFont:SetJustifyH("LEFT")

    PackageListFrame.ItemCount = PackageListFrame:CreateFontString()
    local ItemCount = PackageListFrame.ItemCount
    ItemCount:SetPoint("LEFT", ItemNameFont, "RIGHT", 5, 0)
    ItemCount:SetWidth(30)
    ItemCount:SetFont(GameFontNormal:GetFont(), 12)
    ItemCount:SetTextColor(1, 0.82, 0)
    ItemCount:SetText("数量")
    ItemCount:SetWordWrap(false)
    ItemCount:SetJustifyH("RIGHT")
    PackageListFrame:Hide()

    function PackageListFrame.OnShow()
        if ZL.PackageListFrame.time and (not ZL.PackageListFrame.time:IsCancelled()) then
            ZL.PackageListFrame.time:Cancel()
        end
        if not PackageListFrame:IsShown() then
            PackageListFrame:Show()
        end
    end
    function PackageListFrame.OnHide(frame)
        if ((not frame) or (not frame:IsMouseOver())) and (not PackageListFrame:IsMouseOver()) then
            PackageListFrame:Hide()
        end
    end
    PackageListFrame.entries = setmetatable({}, {
        __index = function(t, v)
            local f = CreateFrame("Frame", nil, PackageListFrame)
            if v > 1 then
                f:SetPoint("TOPLEFT", t[v - 1], "BOTTOMLEFT", 0, 0)
                f:SetPoint("TOPRIGHT", t[v - 1], "BOTTOMRIGHT", 0, 0)
            else
                f:SetPoint("TOPLEFT", ItemNameFont, "BOTTOMLEFT", 0, -3)
                f:SetPoint("TOPRIGHT", ItemNameFont, "BOTTOMRIGHT", 0, -3)
            end
            f:SetHeight(15)

            f.itemicon = CreateFrame("Button", nil, f)
            f.itemicon:SetSize(14, 14)
            f.itemicon:EnableMouse(true)
            f.itemicon:SetPoint("LEFT", f, "LEFT", 0, 0)
            f.itemicon:SetScript("OnEnter", function(self)
                local itemLink = f.ItemName:GetText()
                local itemId = string.match(itemLink, "|c.-|Hitem:(%d+):")
                if itemId then
                    GameTooltip:ClearAllPoints()
                    GameTooltip:ClearLines()
                    GameTooltip:SetOwner(self, "ANCHOR_NONE")
                    GameTooltip:SetHyperlink(itemLink)
                    GameTooltip:SetPoint("RIGHT", f, "LEFT", -5, 0)
                    GameTooltip:Show()
                end
            end)
            f.itemicon:SetScript("OnLeave", function() GameTooltip:Hide() end)

            f.ItemName = f:CreateFontString()
            f.ItemName:SetPoint("LEFT", f.itemicon, "RIGHT", 3, 0)
            f.ItemName:SetWidth(103)
            f.ItemName:SetFont(GameFontNormal:GetFont(), 12)
            f.ItemName:SetWordWrap(false)
            f.ItemName:SetJustifyH("LEFT")

            f.ItemCount = f:CreateFontString()
            f.ItemCount:SetPoint("LEFT", f.ItemName, "RIGHT", 5, 0)
            f.ItemCount:SetWidth(30)
            f.ItemCount:SetFont(GameFontNormal:GetFont(), 12)
            f.ItemCount:SetWordWrap(false)
            f.ItemCount:SetJustifyH("RIGHT")

            f.del = CreateButton(nil, f, "-", "LEFT", f.ItemCount, "RIGHT", 4, 2, 14, 14)
            f.del:SetScript("OnClick", function ()
                local itemLink = f.ItemName:GetText()
                local itemindexList = ZL_CURRENT.auctionlist[ZL.PackageListFrame.index]["itemList"][itemLink]["itemindex"]
                --先把需要剔除的物品isPackage清除
                if itemindexList and #itemindexList > 0 then
                    for _, _itemindex in ipairs(itemindexList) do
                        local _, index = ZL.FetchDataFromItemId(itemLink, _itemindex)
                        if index then
                            ZL_CURRENT.auctionlist[index]["isPackage"] = nil
                        end
                    end
                end
                --将需要删除的打包物品发送给其他成员
                local fdata = {
                    type = "删除打包里面的物品",
                    itemLink = itemLink,
                    globalConfigData = ZL.globalConfigData(),
                }
                MyAddon:TransmitAddonInfo("AUTOAUC SYNC15", fdata, "BULK")
                --ML开始删除自己的打包物品
                ZL_CURRENT.auctionlist[ZL.PackageListFrame.index]["itemList"][itemLink] = nil
                PackageListFrame:Update(ZL.PackageListFrame.index)
                ZL.AuctionFrame2:Update()
            end)

            function f:SetValues(itemName, itemCount)
                local itemId = string.match(itemName, "|c.-|Hitem:(%d+):")
                if itemId then
                    self.itemicon:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square")
                    self.itemicon:SetNormalTexture(cGetItemIcon(itemName))
                end
                self.ItemName:SetText(itemName)
                self.ItemCount:SetText(itemCount)
                if PlayerIsML() then
                    f.del:Show()
                else
                    f.del:Hide()
                end
                f:Show()
            end

            t[v] = f
            return f
        end
    })

    function PackageListFrame:Update(v)
        for _, f in ipairs(PackageListFrame.entries) do f:Hide() end
        local itemList = ZL_CURRENT.auctionlist[v]["itemList"]
        local index = 0
        if itemList and next(itemList, nil) then
            for itemlink, data in pairs(itemList) do
                index = index + 1
                local f = PackageListFrame.entries[index]
                f:SetValues(itemlink, data.itemCount)
                if ZL_CURRENT.auctionlist[v].state == "auctioning" then
                    f.del:Hide()
                end
            end
        end
        local height = 20 + TitleFont:GetHeight() + ItemCount:GetHeight()
        height = height + index * 15
        if height < 100 then
            height = 100
        end
        self:SetHeight(height)
        PackageListFrame:ClearAllPoints()
        PackageListFrame:SetPoint("RIGHT", ZL.AuctionFrame2.entries[v].infoFrame.timerBtn, "LEFT", 0, -10)
    end
end

--创建交易时显示拍卖记录框架选择按钮
function ZL:CreateShowAuctionRecordFrame()
    ZL.ShowAuctionRecordFrame = CreateFrame("Frame", nil, ZL)
    local ShowAuctionRecordFrame = ZL.ShowAuctionRecordFrame
    ShowAuctionRecordFrame:SetSize(100, 20)
    ShowAuctionRecordFrame:SetPoint("CENTER", UIParent, "CENTER")
    ShowAuctionRecordFrame:SetFrameStrata("HIGH")

    ShowAuctionRecordFrame.CheckButton = CreateFrame("CheckButton", nil, ShowAuctionRecordFrame, "ChatConfigCheckButtonTemplate")
    ShowAuctionRecordFrame.CheckButton:SetPoint("LEFT", ShowAuctionRecordFrame, "LEFT")
    ShowAuctionRecordFrame.CheckButton.Text:SetText("工资窗口")
    ShowAuctionRecordFrame.CheckButton.Text:SetFont(GameFontNormal:GetFont(), 14, "")
    ShowAuctionRecordFrame.CheckButton:SetHitRectInsets(0, -ShowAuctionRecordFrame.CheckButton.Text:GetWidth(), 0, 0)
    ShowAuctionRecordFrame.CheckButton.tooltip = "勾选交易时显示工资窗口"
    ShowAuctionRecordFrame.CheckButton:SetChecked(ZL.opt.ShowAuctionRecordFrameCheckButtonValue)
    ShowAuctionRecordFrame.CheckButton:SetScript("OnClick", function (self)
        ZL.opt.ShowAuctionRecordFrameCheckButtonValue = ShowAuctionRecordFrame.CheckButton:GetChecked()
        if ZL.opt.ShowAuctionRecordFrameCheckButtonValue then
            if (not ZL.AuctionRecordFrame:IsShown()) then
                ZL.AuctionRecordFrame:Show()
            else
                ZL.AuctionRecordFrame.playerBalanceFrame:Update()
            end
            _G["ZLAuctionRecordFrameTab3"]:Click()
            ZL.AuctionRecordFrame:ClearAllPoints()
            ZL.AuctionRecordFrame:SetPoint("TOPLEFT", _G["TradeFrame"], "TOPRIGHT")
        else
            ZL.AuctionRecordFrame:Hide()
            ZL.opt.ZLAuctionRecordFrameIsShown = false
        end
    end)
    local function GetPlayerSubgroupAndMembers(playerName)
        -- 查找指定成员所在的队伍
        playerName = ZL.pruneCrossRealm(playerName)
        local subgroup
        for i = 1, MAX_RAID_MEMBERS do
            local name, _, group = GetRaidRosterInfo(i)
            if name and name == playerName then
                subgroup = group
                break
            end
        end
        if not subgroup then
            return nil, nil -- 如果未找到成员
        end
        -- 获取该队伍的所有成员名字
        local members = {}
        for i = 1, MAX_RAID_MEMBERS do
            local name, _, group = GetRaidRosterInfo(i)
            if name and group == subgroup then
                tinsert(members, GetClassColorName(ZL.GetFullName(name)))
            end
        end
        return subgroup, members
    end
    ShowAuctionRecordFrame.DisenchantingBtn = CreateButton(nil, ShowAuctionRecordFrame, "流拍", "RIGHT", ShowAuctionRecordFrame.CheckButton, "LEFT", -45, 0, 50)
    ShowAuctionRecordFrame.DisenchantingBtn:SetScript("OnClick", function (self)
        local msgStr = ""
        if not PlayerIsML() then
            msgStr = "你不是ML，无法使用这个功能！"
            ZL.Print(msgStr)
            return
        end
        local function PickupContainerItemToTrade(ibag, islot)
            C_Container.PickupContainerItem(ibag, islot)
            for i = 1, 6 do
                local name = GetTradePlayerItemInfo(i)
                if (not name) then
                    ClickTradeButton(i)
                    break
                end
            end
        end
        local function GetFailedItemList()
            local failedItemList = {}
            if ZL_CURRENT.auctionlist then
                for _, data in ipairs(ZL_CURRENT.auctionlist) do
                    local itemId = data.itemId
                    if data.state == "failed" and data.bindType == 1 and data.spawnUID and ((not ZL.disenchantingLgnoreList) or (not ZL.disenchantingLgnoreList[tostring(itemId)]))
                    and ((not ZL.opt.disenchantingLgnoreList) or (not ZL.opt.disenchantingLgnoreList[tostring(itemId)])) and (not ZL.NON_DISENCHANTABLE_ITEMS[tostring(itemId)]) and ZL.IsDisenchantAble(itemId) then
                        for _, value in pairs(data.spawnUID) do
                            if value.itemGUID and next(value.itemGUID, nil) then
                                for key, _ in pairs(value.itemGUID) do
                                    --判断是否在背包
                                    local bag, slot = ZL.FindItemInBag(key)
                                    if bag then
                                        tinsert(failedItemList, {bag, slot})
                                        if #failedItemList >= 6 then  --每次最多只能交易6个
                                            return failedItemList
                                        end
                                        break
                                    end
                                end
                            end
                        end
                    end
                end
            end
            return failedItemList
        end
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            local failedItemList = GetFailedItemList()
            if #failedItemList > 0 then
                local index = 1
                local function tempfuc()
                    if index <= #failedItemList then
                        PickupContainerItemToTrade(failedItemList[index][1], failedItemList[index][2])
                        index = index + 1
                        C_Timer.After(0.3, tempfuc)
                    end
                end
                tempfuc()
            else
                msgStr = "没有流拍物品！"
                ZL.Print(msgStr)
            end
        else
            msgStr = "没有流拍物品！"
            ZL.Print(msgStr)
        end
    end)
    ShowAuctionRecordFrame.DisenchantingBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddLine("快速交易流拍物品给\n其他人分解(|cffffffffML功能|r)")
        GameTooltip:Show()
    end)
    ShowAuctionRecordFrame.DisenchantingBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)
    ShowAuctionRecordFrame.TradeGroupWagesBtn = CreateButton(nil, ShowAuctionRecordFrame, "小队", "RIGHT", ShowAuctionRecordFrame.DisenchantingBtn, "LEFT", -5, 0, 50)
    ShowAuctionRecordFrame.TradeGroupWagesBtn:SetScript("OnClick", function (self)
        if not PlayerIsML() then
            local msgStr = "小队交易工资为ML功能，您无法使用，请使用单个交易功能！"
            ZL.Print(msgStr)
            return
        end
        if not ZL_CURRENT.incomeConfirm then
            local link = format("|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "通报详细收支", "通报详细收支")
            local msgStr = "还未通报过|cffffffff详细收支|r，无法使用小队交易功能！" .. link
            ZL.Print(msgStr, true)
            return
        end
        local wagesGroupMembersIndex = (ZL_CURRENT["globalConfig"] and ZL_CURRENT["globalConfig"]["wagesGroupMembers"]) and ZL_CURRENT["globalConfig"]["wagesGroupMembers"] or 0
        if wagesGroupMembersIndex == 0 and ZL.AuctionRecordFrame.playerBalanceFrame.wagesNumber:GetNumber() <= 0 then
            ZL.AuctionRecordFrame:Show()
            _G["ZLAuctionRecordFrameTab3"]:Click()
            ZL.AuctionRecordFrame.playerBalanceFrame.wagesNumber:SetFocus()
            local msgStr = "你选择的是：|cffff0000当前团队名单|r，请输入具体的工资人数后再邮寄工资！"
            ZL.Print(msgStr, true)
            return
        end
        local noColorName = ZL.GetFullName(GetUnitName("npc", true))
        local tradePartner = GetClassColorName(noColorName)
        local pruneName = ZL.pruneCrossRealm(noColorName)
        local playerBuyList = ZL.GetPlayerBuyList()
        ZL.GetWagesGroupMembers()
        GetAveWages()
        local msgStr
        if (not ZL_CURRENT["aveWages"]) then
            msgStr = "无法计算工资！"
            ZL.Print(msgStr)
            return
        end
        if not IsInRaid(1) then
            msgStr = "不在团队中，无法小队交易工资！"
            ZL.Print(msgStr)
            return
        end
        local subgroup, members = GetPlayerSubgroupAndMembers(noColorName)
        if not subgroup then
            msgStr = "【" .. tradePartner .. "】不在团队中，无法小队交易工资！"
            ZL.Print(msgStr)
            return
        end
        local _subgroup = GetPlayerSubgroupAndMembers(UnitName("player"))
        if subgroup == _subgroup then
            msgStr = "【" .. tradePartner .. "】跟你在一个小队，无法小队交易工资，请使用单个交易！"
            ZL.Print(msgStr)
            return
        end
        if ZL_CURRENT.tradeGroupGongZi and ZL_CURRENT.tradeGroupGongZi[tostring(subgroup)] then
            msgStr = subgroup .. "队|cffff0000已交易过工资，不要重复交易哦！|r"
            ZL.Print(msgStr)
            return
        end
        local groupTotal = 0
        local gongziList = {}
        local isFuGongzi, isMail = {}, {}
        for _, name in ipairs(members) do
            local balanceAmount
            local playerPayToMLamount = 0
            local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].biLi) and (ZL_CURRENT.WagesBiLi[name].biLi/100) or 1
            local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].buTie) and ZL_CURRENT.WagesBiLi[name].buTie or 0
            if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
                playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
            end
            local amount = playerPayToMLamount - (playerBuyList[name] and playerBuyList[name].totalAmount or 0)  --欠款
            amount = amount > 0 and 0 or amount
            if PlayerIsML(name) then amount = 0 end
            balanceAmount = ZL_CURRENT["aveWages"] * biLi
            balanceAmount = math.floor(balanceAmount)
            local total = balanceAmount+amount+buTie
            groupTotal = groupTotal + total
            gongziList[name] = total
            if total < 0 then
                isFuGongzi[name] = total
            end
            if ZL_CURRENT["mailPlayers"] and ZL_CURRENT["mailPlayers"][name] ~= nil then
                tinsert(isMail, name)
            end
        end
        if next(isFuGongzi) then
            msgStr = "存在负工资成员："
            for name, gongzi in pairs(isFuGongzi) do
                msgStr = msgStr .. name .. "(" .. gongzi .. ")，"
            end
            msgStr = msgStr .. "无法交易工资！"
            ZL.Print(msgStr)
            return
        end
        if #isMail > 0 then
            msgStr = "存在需邮寄工资成员：" .. table.concat(isMail, "，") .. "，无法交易工资"
            ZL.Print(msgStr)
            return
        end
        if groupTotal <= 0 then
            msgStr = "【" .. subgroup .. "队】工资合计：" .. groupTotal .. "，无法交易工资！"
            ZL.Print(msgStr)
            return
        end
        if GetMoney() < groupTotal*10000 then
            msgStr = "|cffff0000金币不足，无法交易工资！|r"
            ZL.Print(msgStr)
            return
        end
        -- ChatEdit_ActivateChat(ChatEdit_ChooseBoxForSend())
        -- ChatEdit_InsertLink(groupTotal)
        -- ChatEdit_ChooseBoxForSend():HighlightText()
        -- ZL.Print("请复制然后直接粘贴")

        local hasOpenTrade, hasCloseTrade
        local function startTrade()
            if TradeFrame and TradeFrame:IsShown() then
                if not hasCloseTrade and not hasOpenTrade then
                    TradeFrame:Hide()
                    hasCloseTrade = true
                    C_Timer.After(0.3, startTrade)
                end
                if hasOpenTrade then
                    ClickTradeButton(1)
                    C_Timer.After(0.3, function ()
                        AcceptTrade()
                    end)
                    ZL.tradeGroupMsg = {}
                    msgStr =  "【" .. subgroup .. "队】工资合计：" .. groupTotal .. "，负责发工资人：{rt4}" .. noColorName .. "{rt4}，清单如下："
                    tinsert(ZL.tradeGroupMsg, msgStr)
                    for name, gongzi in pairs(gongziList) do
                        msgStr = ParseClassColorName(name) .. "：" .. gongzi
                        tinsert(ZL.tradeGroupMsg, msgStr)
                    end
                end
            else
                if not hasOpenTrade then
                    ZL.tradeGongZi = nil
                    ZL.tradeName = noColorName
                    ZL.tradeGroupGongZi = gongziList
                    ZL.tradeGroup = subgroup
                    PickupPlayerMoney(groupTotal*10000)
                    InitiateTrade(pruneName)
                    hasOpenTrade = true
                end
                C_Timer.After(0.1, startTrade)
            end
        end
        startTrade()
    end)
    ShowAuctionRecordFrame.TradeGroupWagesBtn:SetScript("OnEnter", function (self)
        local noColorName
        if PlayerIsML() then
            noColorName = GetUnitName("npc", true)
        else
            noColorName = UnitName("player")
        end
        local tradePartner = GetClassColorName(noColorName)
        local playerBuyList = ZL.GetPlayerBuyList()
        local _, _, _, RL = ZL.GetWagesGroupMembers()
        GetAveWages()
        GameTooltipShow(self, "LEFT", "RIGHT")
        if (not ZL_CURRENT["aveWages"]) then
            GameTooltip:AddLine("无法计算工资！")
        else
            if not IsInRaid(1) then
                GameTooltip:AddLine("不在团队中，无法小队交易工资！")
            else
                local subgroup, members = GetPlayerSubgroupAndMembers(noColorName)
                if not subgroup then
                    GameTooltip:AddLine("【" .. tradePartner .. "】不在团队中，无法小队交易工资！")
                else
                    if PlayerIsML() then
                        GameTooltip:AddLine("【|cffffffff" .. subgroup .. "队|r】工资")
                    else
                        GameTooltip:AddLine("【|cffffffff本队|r】工资(|cffffffff" .. subgroup .. "队|r)")
                    end
                    GameTooltip:AddDoubleLine("玩家名", "工资合计")
                    local groupTotal = 0
                    for _, name in ipairs(members) do
                        local balanceAmount
                        local playerPayToMLamount = 0
                        local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].biLi) and (ZL_CURRENT.WagesBiLi[name].biLi/100) or 1
                        local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].buTie) and ZL_CURRENT.WagesBiLi[name].buTie or 0
                        if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
                            playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
                        end
                        local amount = playerPayToMLamount - (playerBuyList[name] and playerBuyList[name].totalAmount or 0)  --欠款
                        amount = amount > 0 and 0 or amount
                        if PlayerIsML(name) then amount = 0 end
                        balanceAmount = ZL_CURRENT["aveWages"] * biLi
                        balanceAmount = math.floor(balanceAmount)
                        local total = balanceAmount+amount+buTie
                        groupTotal = groupTotal + total
                        if total <= 0 then
                            total = "|cffff0000" .. tostring(total) .. "|r"
                        end
                        if ZL_CURRENT["mailPlayers"] and ZL_CURRENT["mailPlayers"][name] ~= nil then
                            total = total .. "(邮寄)"
                        end
                        if PlayerIsML() then
                            GameTooltip:AddDoubleLine(name, total, 1, 1, 1, 1, 1, 1)
                        else
                            if ZL_PLAYERLIST.otherTradeGongZi and ZL_PLAYERLIST.otherTradeGongZi[name] then
                                GameTooltip:AddDoubleLine(name .. "|cffff0000(已交易)|r", total, 1, 1, 1, 1, 1, 1)
                            else
                                GameTooltip:AddDoubleLine(name, total, 1, 1, 1, 1, 1, 1)
                            end
                        end
                    end
                    GameTooltip:AddDoubleLine("小队总计", groupTotal)
                    if ZL_CURRENT.tradeGroupGongZi and ZL_CURRENT.tradeGroupGongZi[tostring(subgroup)] and PlayerIsML() then
                        GameTooltip:AddLine("已交易过小队工资！", 1, 0, 0)
                    end
                end
            end
            
        end
        GameTooltip:Show()
    end)
    ShowAuctionRecordFrame.TradeGroupWagesBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    ShowAuctionRecordFrame.TradePlayerWagesBtn = CreateButton(nil, ShowAuctionRecordFrame, "单个", "RIGHT", ShowAuctionRecordFrame.TradeGroupWagesBtn, "LEFT", -5, 0, 50)
    ShowAuctionRecordFrame.TradePlayerWagesBtn:SetScript("OnClick", function (self)
        local wagesGroupMembersIndex = (ZL_CURRENT["globalConfig"] and ZL_CURRENT["globalConfig"]["wagesGroupMembers"]) and ZL_CURRENT["globalConfig"]["wagesGroupMembers"] or 0
        if wagesGroupMembersIndex == 0 and ZL.AuctionRecordFrame.playerBalanceFrame.wagesNumber:GetNumber() <= 0 then
            ZL.AuctionRecordFrame:Show()
            _G["ZLAuctionRecordFrameTab3"]:Click()
            local msgStr = "你选择的是：|cffff0000当前团队名单|r，请输入具体的工资人数后再交易工资！"
            ZL.Print(msgStr, true)
            return
        end
        local noColorName = ZL.GetFullName(GetUnitName("npc", true))
        local name = GetClassColorName(noColorName)
        local pruneName = ZL.pruneCrossRealm(noColorName)
        local playerBuyList = ZL.GetPlayerBuyList()
        ZL.GetWagesGroupMembers()
        -- local numGroupMembers, RLBuTie, totalincome, totalpayout, totalamount, averageamount = GetAveWages()
        local msgStr
        if (not ZL_CURRENT["aveWages"]) then
            msgStr = "无法计算工资！"
            ZL.Print(msgStr)
            return
        end
        if PlayerIsML() then
            if ZL_CURRENT.tradeGongZi and ZL_CURRENT.tradeGongZi[name] then
                msgStr = name .. "|cffff0000已交易过工资！|r"
                ZL.Print(msgStr)
                return
            end
        else
            if not ZL_PLAYERLIST.groupGongZi then
                msgStr = "未指定你交易本小队工资！"
                ZL.Print(msgStr)
                return
            elseif ZL_PLAYERLIST.otherTradeGongZi and ZL_PLAYERLIST.otherTradeGongZi[name] then
                msgStr = name .. "|cffff0000已交易过工资！|r"
                ZL.Print(msgStr)
                return
            else
                local subgroup = GetPlayerSubgroupAndMembers(noColorName)
                local _subgroup = GetPlayerSubgroupAndMembers(UnitName("player"))
                if subgroup ~= _subgroup then
                    msgStr = name .. "|cffff0000不是本队成员，无法交易工资！|r"
                    ZL.Print(msgStr)
                    return
                end
            end
        end
        if ZL_CURRENT["mailPlayers"] and ZL_CURRENT["mailPlayers"][name] == true then
            msgStr = name .. "|cffff0000工资已经邮寄！|r"
            ZL.Print(msgStr)
            return
        end

        local balanceAmount
        local playerPayToMLamount = 0
        local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].biLi) and (ZL_CURRENT.WagesBiLi[name].biLi/100) or 1
        local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].buTie) and ZL_CURRENT.WagesBiLi[name].buTie or 0
        if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
            playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
        end
        local amount = playerPayToMLamount - (playerBuyList[name] and playerBuyList[name].totalAmount or 0)  --欠款
        amount = amount > 0 and 0 or amount
        if PlayerIsML(name) then amount = 0 end
        balanceAmount = ZL_CURRENT["aveWages"] * biLi
        balanceAmount = math.floor(balanceAmount)
        local total = balanceAmount+amount+buTie
        if total <= 0 then
            msgStr = "【" .. name .. "】合计工资为：" .. total .. "，无法交易工资！"
            ZL.Print(msgStr)
            return
        end
        if GetMoney() < total*10000 then
            msgStr = "|cffff0000金币不足，无法交易工资！|r"
            ZL.Print(msgStr)
            return
        end

        -- pcall(ChatEdit_ActivateChat, ChatEdit_ChooseBoxForSend())
        -- ChatEdit_InsertLink(total)
        -- ChatEdit_ChooseBoxForSend():HighlightText()
        -- ZL.Print("请复制然后直接粘贴")

        local hasOpenTrade, hasCloseTrade
        local function startTrade()
            if TradeFrame and TradeFrame:IsShown() then
                if not hasCloseTrade and not hasOpenTrade then
                    TradeFrame:Hide()
                    hasCloseTrade = true
                    C_Timer.After(0.3, startTrade)
                end
                if hasOpenTrade then
                    ClickTradeButton(1)
                    C_Timer.After(0.3, function ()
                        AcceptTrade()
                    end)
                    msgStr = "工资：" .. balanceAmount
                    if amount < 0 then
                        msgStr = msgStr .. "，欠款：" .. amount
                    end
                    if buTie > 0 then
                        msgStr = msgStr .. "，补贴：" .. buTie
                    end
                    if amount < 0 or buTie > 0 then
                        msgStr = msgStr .. "，合计：" .. total
                    end
                    msgStr = msgStr .. "，请及时确认交易！"
                    SendChatMessage(msgStr, "WHISPER", nil, noColorName)
                end
            else
                if not hasOpenTrade then
                    ZL.tradeGroupGongZi = nil
                    ZL.tradeGroup = nil
                    if PlayerIsML() then
                        ZL.tradeGongZi = total
                        ZL.otherTradeGongZi = nil
                    else
                        ZL.tradeGongZi = nil
                        ZL.otherTradeGongZi = total
                    end
                    ZL.tradeName = name
                    PickupPlayerMoney(total*10000)
                    InitiateTrade(pruneName)
                    hasOpenTrade = true
                end
                C_Timer.After(0.1, startTrade)
            end
        end
        startTrade()
    end)
    ShowAuctionRecordFrame.TradePlayerWagesBtn:SetScript("OnEnter", function (self)
        local noColorName = ZL.GetFullName(GetUnitName("npc", true))
        local name = GetClassColorName(noColorName)
        local pruneName = ZL.pruneCrossRealm(noColorName)
        local playerBuyList = ZL.GetPlayerBuyList()
        ZL.GetWagesGroupMembers()
        GetAveWages()
        GameTooltipShow(self, "BOTTOM", "TOP")
        if (not ZL_CURRENT["aveWages"]) then
            GameTooltip:AddLine("无法计算工资！")
        else
            GameTooltip:AddLine("【" .. name .. "】工资")
            local balanceAmount
            local playerPayToMLamount = 0
            local biLi = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].biLi) and (ZL_CURRENT.WagesBiLi[name].biLi/100) or 1
            local buTie = (ZL_CURRENT.WagesBiLi and ZL_CURRENT.WagesBiLi[name] and ZL_CURRENT.WagesBiLi[name].buTie) and ZL_CURRENT.WagesBiLi[name].buTie or 0
            if ZL_CURRENT.playerPayToML and ZL_CURRENT.playerPayToML[name] then
                playerPayToMLamount = ZL_CURRENT.playerPayToML[name]
            end
            local amount = playerPayToMLamount - (playerBuyList[name] and playerBuyList[name].totalAmount or 0)  --欠款
            amount = amount > 0 and 0 or amount
            if PlayerIsML(name) then amount = 0 end
            balanceAmount = ZL_CURRENT["aveWages"] * biLi
            balanceAmount = math.floor(balanceAmount)
            local total = balanceAmount+amount+buTie
            if total <= 0 then
                total = "|cffff0000" .. tostring(total) .. "|r"
            end
            GameTooltip:AddDoubleLine("工资：", balanceAmount, 1, 1, 1, 1, 1, 1)
            GameTooltip:AddDoubleLine("欠款：", amount, 1, 1, 1, 1, 1, 1)
            GameTooltip:AddDoubleLine("补贴：", buTie, 1, 1, 1, 1, 1, 1)
            GameTooltip:AddDoubleLine("合计：", total)
            if PlayerIsML() then
                if ZL_CURRENT.tradeGongZi and ZL_CURRENT.tradeGongZi[name] then
                    GameTooltip:AddLine("|cffff0000已交易过工资！|r")
                elseif ZL_CURRENT["mailPlayers"] and ZL_CURRENT["mailPlayers"][name] == true then
                    GameTooltip:AddLine("|cffff0000工资已经邮寄！|r")
                end
            else
                if ZL_PLAYERLIST.otherTradeGongZi and ZL_PLAYERLIST.otherTradeGongZi[name] then
                    GameTooltip:AddLine("|cffff0000已交易过工资！|r")
                else
                    local subgroup = GetPlayerSubgroupAndMembers(noColorName)
                    local _subgroup = GetPlayerSubgroupAndMembers(UnitName("player"))
                    if subgroup ~= _subgroup then
                        GameTooltip:AddLine("|cffff0000警告！不是小队成员！|r")
                    end
                end
            end
        end
        GameTooltip:Show()
    end)
    ShowAuctionRecordFrame.TradePlayerWagesBtn:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)

    ShowAuctionRecordFrame:Hide()
end

--创建提示保存数据框架
function ZL:CreateReloadUIFrame()
    ZL.ReloadUIFrame = CreateFrame("Frame", nil, self, "BackdropTemplate")
    local ReloadUIFrame = ZL.ReloadUIFrame
    ReloadUIFrame:SetSize(50, 50)
    ReloadUIFrame:SetPoint("TOP", UIParent, "TOP", 0, -80)
    ReloadUIFrame:SetClampedToScreen(true)
    ReloadUIFrame:SetFrameStrata("HIGH")

    ReloadUIFrame.remindText = ReloadUIFrame:CreateFontString()
    local remindText = ReloadUIFrame.remindText
    remindText:SetFontObject(GameFontHighlightLarge)
    remindText:SetHeight(75)
    remindText:SetPoint("CENTER", ReloadUIFrame, "CENTER")
    remindText:SetFont(GameFontNormal:GetFont(), 20)
    remindText:SetWordWrap(false)
    remindText:SetJustifyH("CENTER")
    remindText:SetText("|T137006:20|t|cfffffff0提醒：请及时加载用户界面(|r|cffffd100/rl|r|cfffffff0)保存数据哦|r|T137006:20|t")

    -- local texture1 = ReloadUIFrame:CreateTexture(nil, "BACKGROUND")
    -- texture1:SetPoint("RIGHT", remindText, "LEFT")
    -- texture1:SetSize(20, 20)
    -- texture1:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcon_6")
    
    -- local texture2 = ReloadUIFrame:CreateTexture(nil, "BACKGROUND")
    -- texture2:SetPoint("LEFT", remindText, "RIGHT")
    -- texture2:SetSize(20, 20)
    -- texture2:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcon_6")
    -- ZL.ReloadUIFrame:Hide()
end

--创建滚动消息框架
function ZL:CreateScrollingMessageFrame()
    ZL.ScrollingMessageFrame = CreateFrame("ScrollingMessageFrame", "MyScrollingMessageFrame", UIParent)
    local ScrollingMessageFrame = ZL.ScrollingMessageFrame
    ScrollingMessageFrame:SetSize(1000, 150)
    ScrollingMessageFrame:SetPoint("TOP", UIParent, "TOP", 0, 0)
    ScrollingMessageFrame:SetFrameStrata("FULLSCREEN_DIALOG")
    ScrollingMessageFrame:SetClampedToScreen(true)  --不能超出游戏屏幕，false可以超出游戏屏幕
    ScrollingMessageFrame:SetFont(GameFontNormal:GetFont(), 20, "OUTLINE")
    ScrollingMessageFrame:SetJustifyH("CENTER")
    ScrollingMessageFrame:SetJustifyV("TOP")
    ScrollingMessageFrame:SetMaxLines(5)
    ScrollingMessageFrame:SetSpacing(3)
    ScrollingMessageFrame:SetFadeDuration(2)
    ScrollingMessageFrame:SetTimeVisible(6)
    ScrollingMessageFrame:SetHyperlinksEnabled(true)
    ScrollingMessageFrame:SetScript("OnHyperlinkEnter", function(self, link)
        local itemID = GetItemInfoInstant(link)
        if itemID then
            GameTooltip:SetOwner(self, "ANCHOR_CURSOR", 0, 0)
            GameTooltip:ClearLines()
            GameTooltip:SetHyperlink(link)
            GameTooltip:Show()
        end
    end)
    ScrollingMessageFrame:SetScript("OnHyperlinkLeave", function(self)
        GameTooltip:Hide()
    end)
    ScrollingMessageFrame:SetScript("OnHyperlinkClick", function (self, link, _, button)
        local linkType, missionID, txt, arg4, arg5 = strsplit(":", link)
        if linkType == "garrmission" then
            if missionID == "AutoAuction" then
                if txt == "通报详细收支" then
                    ZL.reportIncomeConfirm()
                elseif txt == "保存团员名单" then
                    ZL.saveGroupMembers()
                elseif txt == "设置多拍" then
                    ZL.opt.allowMultipleAuctions = true
                    ZL.TransmitAddonInfo_Pro()
                    C_Timer.NewTicker(0.2, function (self)
                        if ZL_CURRENT.globalConfig.allowMultipleAuctions then
                            self:Cancel()
                            local _link = format("|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "设置单拍", "改为单拍")
                            local msg = "已切换为|cffffffff多拍模式|r "
                            ZL.Print(msg .. _link, true)
                            ZL.SpeakText(msg)
                        end
                    end)
                elseif txt == "设置单拍" then
                    ZL.opt.allowMultipleAuctions = false
                    ZL.TransmitAddonInfo_Pro()
                    C_Timer.NewTicker(0.2, function (self)
                        if not ZL_CURRENT.globalConfig.allowMultipleAuctions then
                            self:Cancel()
                            local _link = format("|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "设置多拍", "设置多拍")
                            local msg = "已切换为|cffffffff单拍模式|r "
                            ZL.Print(msg .. _link, true)
                            ZL.SpeakText(msg)
                        end
                    end)
                elseif txt == "历史记录" then
                    ZL.AuctionRecordFrame:Show()
                    _G["ZLAuctionRecordFrameTab1"]:Click()
                elseif txt == "CLOSENOTICEFOOD" then
                    ZL.opt.autoNoticeFoodInRaid = false
                    local _link = format("已关闭食物、修理机器人团队通报|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "OPENNOTICEFOOD", "打开提醒")
                    ZL.Print(_link, true)
                    if IsInRaid(1) then
                        local data = {type="request"}
                        MyAddon:TransmitAddonInfo2("AUTOAUC VER", data, "RAID", nil, "BULK")
                    end
                elseif txt == "OPENNOTICEFOOD" then
                    ZL.opt.autoNoticeFoodInRaid = true
                    local _link = format("已打开食物、修理机器人团队通报|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "CLOSENOTICEFOOD", "关闭提醒")
                    ZL.Print(_link, true)
                    if IsInRaid(1) then
                        local data = {type="request"}
                        MyAddon:TransmitAddonInfo2("AUTOAUC VER", data, "RAID", nil, "BULK")
                    end
                elseif txt == "unAuctionSortLock" then
                    ZL.HookAuctionFrame.lockBtn:Click()
                    local _link = "搜索排序已解锁，可能无法自动获取到最低一口价" .. format("|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "AuctionSortLock", "锁定")
                    ZL.Print(_link)
                elseif txt == "AuctionSortLock" then
                    ZL.HookAuctionFrame.lockBtn:Click()
                    local _link = "搜索排序已锁定" .. format("|cff87CEEB|Hgarrmission:%s:%s|h[%s]|h|r", "AutoAuction", "unAuctionSortLock", "解锁")
                    ZL.Print(_link)
                elseif txt == "欠款" then
                    if arg4 and arg5 then
                        local hasOpenTrade, hasCloseTrade
                        if GetMoney() < (tonumber(arg4) or 0)*10000 then
                            ZL.Print("金币不足，无法支付！")
                            return
                        end
                        local function startTrade()
                            if TradeFrame and TradeFrame:IsShown() then
                                if not hasCloseTrade and not hasOpenTrade then
                                    TradeFrame:Hide()
                                    hasCloseTrade = true
                                    C_Timer.After(0.3, startTrade)
                                end
                                if hasOpenTrade then
                                    ClickTradeButton(1)
                                    C_Timer.After(0.3, function ()
                                        AcceptTrade()
                                    end)
                                end
                            else
                                if not hasOpenTrade then
                                    PickupPlayerMoney((tonumber(arg4) or 0)*10000)
                                    InitiateTrade(ZL.pruneCrossRealm(arg5))
                                    hasOpenTrade = true
                                end
                                C_Timer.After(0.1, startTrade)
                            end
                        end
                        startTrade()
                    end
                end
            end
        end
    end)
end


--创建总览界面
function ZL:CreateOverviewFrame()
    ZL.OverviewFrame = ZLCreateFrame("ZLOverviewFrame", ZL, nil, nil, "DIALOG", false, true, "账单总览")
    local OverviewFrame = ZL.OverviewFrame
    OverviewFrame.Background:SetColorTexture(0, 0, 0, 0.95)
    OverviewFrame:SetPoint("CENTER")
    OverviewFrame:SetResizable(false)
    local maxlevel = ZL.AuctionFrame2:GetFrameLevel()
    OverviewFrame:SetFrameLevel(maxlevel + 10)
    OverviewFrame.resizeButton:Hide()
    OverviewFrame:SetSize(GetScreenWidth()-65, GetScreenHeight()-50)
    OverviewFrame:Hide()

    -- 注册 ESC 键关闭窗口
    tinsert(UISpecialFrames, OverviewFrame:GetName())

    local UIScale = UIParent:GetScale()
    local height = 20
    local gapwidth = 20/UIScale
    local gapheight = 0
    local itemNamewidth = 160/UIScale
    local playerNamewidth = 100/UIScale
    local amountwidth = 70/UIScale
    local BOSSwidth =(GetScreenWidth()-40-23-2*gapwidth-3*(itemNamewidth+playerNamewidth+amountwidth-3))/3
    BOSSwidth = BOSSwidth > 160 and 160 or BOSSwidth
    local board_r, board_g, board_b, board_a = 0.24, 0.25, 0.3, 1
    OverviewFrame.BOSSHeaderBtn1 = CreateHeaderButton(OverviewFrame, BOSSwidth, 21)
    local BOSSHeaderBtn1 = OverviewFrame.BOSSHeaderBtn1
    BOSSHeaderBtn1:SetPoint("TOPLEFT", OverviewFrame.TitleBottom, "BOTTOMLEFT", 3, -5)
    BOSSHeaderBtn1:SetText("|cff00aaff项目|r")

    OverviewFrame.itemNameHeaderBtn1 = CreateHeaderButton(OverviewFrame, itemNamewidth, 21)
    local itemNameHeaderBtn1 = OverviewFrame.itemNameHeaderBtn1
    itemNameHeaderBtn1:SetPoint("TOPLEFT", BOSSHeaderBtn1, "TOPRIGHT", -1, 0)
    itemNameHeaderBtn1:SetText("|cff00d100物品名称×数量|r")

    OverviewFrame.playerNameHeaderBtn1 = CreateHeaderButton(OverviewFrame, playerNamewidth, 21)
    local playerNameHeaderBtn1 = OverviewFrame.playerNameHeaderBtn1
    playerNameHeaderBtn1:SetPoint("TOPLEFT", itemNameHeaderBtn1, "TOPRIGHT", -1, 0)
    playerNameHeaderBtn1:SetText("|cff00d100买家名字|r")

    OverviewFrame.amountHeaderBtn1 = CreateHeaderButton(OverviewFrame, amountwidth, 21)
    local amountHeaderBtn1 = OverviewFrame.amountHeaderBtn1
    amountHeaderBtn1:SetPoint("TOPLEFT", playerNameHeaderBtn1, "TOPRIGHT", -1, 0)
    amountHeaderBtn1:SetText("|cff00d100总金额|r")

    do
        local texture = amountHeaderBtn1:CreateTexture(nil, "BACKGROUND")
        texture:SetColorTexture(1,1,1,0.5)
        texture:SetPoint("TOPLEFT", BOSSHeaderBtn1, "BOTTOMLEFT", 0, 0)
        texture:SetPoint("BOTTOMRIGHT", amountHeaderBtn1, "BOTTOMRIGHT", 0, -1)
    end

    OverviewFrame.BOSSHeaderBtn2 = CreateHeaderButton(OverviewFrame, BOSSwidth, 21)
    local BOSSHeaderBtn2 = OverviewFrame.BOSSHeaderBtn2
    BOSSHeaderBtn2:SetPoint("TOPLEFT", amountHeaderBtn1, "TOPRIGHT", gapwidth, 0)
    BOSSHeaderBtn2:SetText("|cff00aaff项目|r")

    OverviewFrame.itemNameHeaderBtn2 = CreateHeaderButton(OverviewFrame, itemNamewidth, 21)
    local itemNameHeaderBtn2 = OverviewFrame.itemNameHeaderBtn2
    itemNameHeaderBtn2:SetPoint("TOPLEFT", BOSSHeaderBtn2, "TOPRIGHT", -1, 0)
    itemNameHeaderBtn2:SetText("|cff00d100物品名称×数量|r")

    OverviewFrame.playerNameHeaderBtn2 = CreateHeaderButton(OverviewFrame, playerNamewidth, 21)
    local playerNameHeaderBtn2 = OverviewFrame.playerNameHeaderBtn2
    playerNameHeaderBtn2:SetPoint("TOPLEFT", itemNameHeaderBtn2, "TOPRIGHT", -1, 0)
    playerNameHeaderBtn2:SetText("|cff00d100买家名字|r")

    OverviewFrame.amountHeaderBtn2 = CreateHeaderButton(OverviewFrame, amountwidth, 21)
    local amountHeaderBtn2 = OverviewFrame.amountHeaderBtn2
    amountHeaderBtn2:SetPoint("TOPLEFT", playerNameHeaderBtn2, "TOPRIGHT", -1, 0)
    amountHeaderBtn2:SetText("|cff00d100总金额|r")

    do
        local texture = amountHeaderBtn2:CreateTexture(nil, "BACKGROUND")
        texture:SetColorTexture(1,1,1,0.5)
        texture:SetPoint("TOPLEFT", BOSSHeaderBtn2, "BOTTOMLEFT", 0, 0)
        texture:SetPoint("BOTTOMRIGHT", amountHeaderBtn2, "BOTTOMRIGHT", 0, -1)
    end

    OverviewFrame.BOSSHeaderBtn3 = CreateHeaderButton(OverviewFrame, BOSSwidth, 21)
    local BOSSHeaderBtn3 = OverviewFrame.BOSSHeaderBtn3
    BOSSHeaderBtn3:SetPoint("TOPLEFT", amountHeaderBtn2, "TOPRIGHT", gapwidth, 0)
    BOSSHeaderBtn3:SetText("|cff00aaff项目|r")

    OverviewFrame.itemNameHeaderBtn3 = CreateHeaderButton(OverviewFrame, itemNamewidth, 21)
    local itemNameHeaderBtn3 = OverviewFrame.itemNameHeaderBtn3
    itemNameHeaderBtn3:SetPoint("TOPLEFT", BOSSHeaderBtn3, "TOPRIGHT", -1, 0)
    itemNameHeaderBtn3:SetText("|cff00d100物品名称×数量|r")

    OverviewFrame.playerNameHeaderBtn3 = CreateHeaderButton(OverviewFrame, playerNamewidth, 21)
    local playerNameHeaderBtn3 = OverviewFrame.playerNameHeaderBtn3
    playerNameHeaderBtn3:SetPoint("TOPLEFT", itemNameHeaderBtn3, "TOPRIGHT", -1, 0)
    playerNameHeaderBtn3:SetText("|cff00d100买家名字|r")

    OverviewFrame.amountHeaderBtn3 = CreateHeaderButton(OverviewFrame, amountwidth, 21)
    local amountHeaderBtn3 = OverviewFrame.amountHeaderBtn3
    amountHeaderBtn3:SetPoint("TOPLEFT", playerNameHeaderBtn3, "TOPRIGHT", -1, 0)
    amountHeaderBtn3:SetText("|cff00d100总金额|r")
    do
        local texture = amountHeaderBtn3:CreateTexture(nil, "BACKGROUND")
        texture:SetColorTexture(1,1,1,0.5)
        texture:SetPoint("TOPLEFT", BOSSHeaderBtn3, "BOTTOMLEFT", 0, 0)
        texture:SetPoint("BOTTOMRIGHT", amountHeaderBtn3, "BOTTOMRIGHT", 0, -1)
    end

    --创建滚动条
    OverviewFrame.scrollFrame = CreateFrame("ScrollFrame", nil, OverviewFrame, "UIPanelScrollFrameTemplate")
    OverviewFrame.scrollFrame:SetFrameLevel(OverviewFrame:GetFrameLevel() + 1) -- 设置为比父框架高1级
    OverviewFrame.scrollFrame:SetPoint("TOPLEFT", BOSSHeaderBtn1, "BOTTOMLEFT", 0, 0)
    OverviewFrame.scrollFrame:SetPoint("BOTTOMRIGHT", OverviewFrame, "BOTTOMRIGHT", 0, 3)
    OverviewFrame.scrollFrame:SetClipsChildren(true) --必须设置为true，scrollFrame所有的子元素才会被剪切
    OverviewFrame.scrollFrame:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel) --重设滑动条鼠标滚轮事件
    --重设ScrollBar位置，放置到scrollFrame内，防止被剪切掉
    OverviewFrame.scrollFrame.ScrollBar:ClearAllPoints()
    OverviewFrame.scrollFrame.ScrollBar:SetPoint("TOPLEFT", OverviewFrame.scrollFrame, "TOPRIGHT", -20, -16)
    OverviewFrame.scrollFrame.ScrollBar:SetPoint("BOTTOMRIGHT", OverviewFrame.scrollFrame, "BOTTOMRIGHT", 0, 16)
    OverviewFrame.scrollFrame.content = CreateFrame("Frame", nil, OverviewFrame.scrollFrame)
    local content = OverviewFrame.scrollFrame.content
    content:SetPoint("TOPRIGHT", OverviewFrame.scrollFrame, "TOPRIGHT", 0, 0)
    content:SetSize(OverviewFrame.scrollFrame:GetWidth()-20, 100)
    OverviewFrame.scrollFrame:SetScrollChild(content)

    OverviewFrame.playerModel = CreateFrame("PlayerModel", "ZLPlayerModel", OverviewFrame)
    local playerModel = OverviewFrame.playerModel
    playerModel:SetPoint("CENTER")
    playerModel:SetSize(200, 200)
    -- playerModel:SetUnit("player")
    playerModel:SetCreature(25305)
    playerModel:SetFacing(-0.4)
    playerModel:SetAnimation(69)
    playerModel:SetAlpha(0.4)
    playerModel:SetFrameLevel(content:GetFrameLevel()+5)
    if ZL.opt.overviewFramePlayerModelHide then
        playerModel:Hide()
    else
        playerModel:Show()
    end

    local function OnEnter(self)
        self:GetParent():SetNormalTexture("Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar")
    end
    local function OnLeave(self)
        self:GetParent():ClearNormalTexture()
    end
    local function GroupMembersActivityMenu(self)
        local menuList = {}
        local WagesGroupMembers, msg = ZL.GetWagesGroupMembers()
        if WagesGroupMembers and msg then
            tinsert(menuList, {text=msg, isTitle = true})
            for i, data in ipairs(WagesGroupMembers) do
                if #data > 0 then
                    local memberList = {}
                    for _, playerName in ipairs(data) do
                        tinsert(memberList, {
                            text=playerName,
                            func = function ()
                                self:SetText(playerName)
                                OverviewFrame.playerNameChange(self)
                            end,
                        })
                    end
                    tinsert(menuList, {
                        text = i .. "队",
                        func = function ()
                            self:ClearFocus()
                        end,
                        hasArrow = true,
                        menuTable = memberList,
                    })
                end
            end
            tinsert(menuList, {isSeparator = true})
            tinsert(menuList, {text = CANCEL, func = function() self:ClearFocus() end})
        end
        return menuList
    end
    OverviewFrame.entries = setmetatable({}, {
        __index = function (t, v)
            local f = CreateFrame("Button", nil, content)
            f:SetSize((BOSSwidth+itemNamewidth+playerNamewidth+amountwidth-3), height)
            
            f.Background = f:CreateTexture(nil,"BACKGROUND")
            f.Background:SetPoint("TOPLEFT")
            f.Background:SetPoint("BOTTOMRIGHT")
            f.Background:SetColorTexture(0.15, 0.15, 0.15, 1)
            f:SetScript("OnEnter", function (self)
                self:SetNormalTexture("Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar")
            end)
            f:SetScript("OnLeave", function (self)
                self:ClearNormalTexture()
            end)

            f.bossfontstring = f:CreateFontString(nil, "OVERLAY")
            f.bossfontstring:SetPoint("TOPLEFT", 3, 0)
            -- f.bossfontstring:SetPoint("BOTTOMLEFT", 0, 0)
            f.bossfontstring:SetWidth(BOSSwidth-6)
            f.bossfontstring:SetFont(GameFontNormal:GetFont(), 15, "THICKOUTLINE")
            f.bossfontstring:SetWordWrap(true)
            f.bossfontstring:SetJustifyH("CENTER")
            f.bossfontstring:SetJustifyV("MIDDLE")
            f.bossfontstring:SetTextColor(0.95, 0.95, 0.95, 1)

            f.itemicon = CreateButton(nil, f, "", "TOPLEFT", f.bossfontstring, "TOPRIGHT", 2, 0, 20, 20)
            f.itemicon:SetScript("OnEnter", function(self)
                OnEnter(self)
            end)
            f.itemicon:SetScript("OnLeave", function(self)
                OnLeave(self)
            end)
            f.itemicon:SetScript("OnDoubleClick", function (self, button)
                local itemlink = f.itemlink
                if (not itemlink) or itemlink == "" then return end
                local itemId = tonumber(itemlink:match("|Hitem:(%d+):"))
                if itemId then
                    local selectCharKey = ZL.GetClassColorName() .. " - " .. GetRealmName()
                    if (not ZL.opt.concernList) or (not ZL.opt.concernList[selectCharKey]) or
                    (not ZL.opt.concernList[selectCharKey]["itemList"][itemId]) then
                        ZL.addItem(itemId)
                    else
                        ZL.deleteItem(itemId)
                    end
                    ZL.AuctionFrame2:Update()
                end
            end)
            
            f.itemicon.itemNumbersIcon = f.itemicon:CreateTexture(nil, "OVERLAY")
            local itemNumbersIcon = f.itemicon.itemNumbersIcon
            itemNumbersIcon:SetPoint("TOP", f.itemicon, "TOP")
            itemNumbersIcon:SetSize(15,15)
            -- itemNumbersIcon:SetAllPoints(f.itemicon)

            f.level = f.itemicon:CreateFontString(nil, "OVERLAY")
            f.level:SetPoint("BOTTOMLEFT", 1, 0)
            f.level:SetPoint("BOTTOMRIGHT", -1, 0)
            f.level:SetFont(GameFontNormal:GetFont(), 8, "OUTLINE")
            f.level:SetWordWrap(true)
            f.level:SetJustifyH("LEFT")
            f.level:SetTextColor(0.95, 0.95, 0.95, 1)

            f.itemNamebox = CreateEditBox(f, itemNamewidth-f.itemicon:GetWidth()-1, 20, 12, "RIGHT", nil, nil, board_r, board_g, board_b, board_a)
            f.itemNamebox:SetPoint("LEFT", f.itemicon, "RIGHT", 0, 0)
            f.itemNamebox.Background:SetColorTexture(0,0,0,0)
            f.itemNamebox.BorderRight:Hide()
            -- f.itemNamebox:Disable()
            f.itemNamebox:SetScript("OnEnter", function (self)
                OnEnter(self)
                if self:HasFocus() and ZL_PLAYERLIST.lootList then
                    local txt = f.itemNamebox.fontstring:GetText()
                    local itemName, itemCount
                    if string.match(txt, "|cff00ff00×") then
                        itemName, itemCount = string.match(txt, "^(.-)|cff00ff00×(%d+)|r$")
                        itemCount = tonumber(itemCount)
                    else
                        itemName = txt
                        itemCount = 1
                    end
                    local bossName = ParseClassColorName(f.bossfontstring:GetText())
                    local data = ZL_PLAYERLIST.lootList[bossName][itemName]
                    local playerName = f.playerNamebox.fontstring:GetText()
                    local maxCount
                    if playerName == "拾取1" then
                        maxCount = data["拾取1"]["counts"]
                    else
                        maxCount = data["拾取1"]["counts"] + itemCount
                    end
                    GameTooltipShow(self, "TOPLEFT", "TOPRIGHT")
                    GameTooltip:AddLine("修改数量")
                    GameTooltip:AddLine("最大不超过|cff00ff00" .. maxCount .. "|r", 1, 1, 1)
                    GameTooltip:AddLine("物品名称不可修改", 1, 0, 0)
                    GameTooltip:AddLine("激活输入框，输入或鼠标滚轮修改\n数量，按Enter键或右键保存！", 1, 1, 1)
                    GameTooltip:Show()
                else
                    local itemlink = f.itemlink
                    if (not itemlink) or itemlink == "" then return end
                    local itemId = tonumber(itemlink:match("|Hitem:(%d+):"))
                    if itemId then
                        local uiScale, x, y = UIParent:GetEffectiveScale(), GetCursorPosition()
                        x, y = x/uiScale, y/uiScale
                        local screenWidth = GetScreenWidth() / 2
                        if x < screenWidth then
                            GameTooltipShow(self, "TOPLEFT", "TOPRIGHT")
                        else
                            GameTooltipShow(self, "TOPRIGHT", "TOPLEFT")
                        end
                        GameTooltip:ClearLines()
                        GameTooltip:SetHyperlink(itemlink)
                        GameTooltip:Show()
                        if _G["ShoppingTooltip1"] and _G["ShoppingTooltip1"]:IsShown() then
                            _G["ShoppingTooltip1"]:ClearAllPoints()
                            if x < screenWidth then
                                _G["ShoppingTooltip1"]:SetPoint("TOPLEFT", GameTooltip, "TOPRIGHT", 0, 0)
                            else
                                _G["ShoppingTooltip1"]:SetPoint("TOPRIGHT", GameTooltip, "TOPLEFT", 0, 0)
                            end
                        end
                        if _G["ShoppingTooltip2"] and _G["ShoppingTooltip2"]:IsShown() then
                            _G["ShoppingTooltip2"]:ClearAllPoints()
                            if x < screenWidth then
                                _G["ShoppingTooltip2"]:SetPoint("TOPLEFT", _G["ShoppingTooltip1"], "TOPRIGHT", 0, 0)
                            else
                                _G["ShoppingTooltip2"]:SetPoint("TOPRIGHT", _G["ShoppingTooltip1"], "TOPLEFT", 0, 0)
                            end
                        end
                    end
                end
            end)
            f.itemNamebox:SetScript("OnLeave", function (self)
                OnLeave(self)
                GameTooltip:Hide()
            end)
            f.itemNamebox:SetScript("OnEditFocusGained", function (self)
                if not ZL_PLAYERLIST.lootList then return end
                f.itemNamebox.fontstring:Hide()
                GameTooltip:Hide()
                local txt = f.itemNamebox.fontstring:GetText()
                local itemName, itemCount
                if string.match(txt, "|cff00ff00×") then
                    itemName, itemCount = string.match(txt, "^(.-)|cff00ff00×(%d+)|r$")
                    itemCount = tonumber(itemCount)
                else
                    itemName = txt
                    itemCount = 1
                end
                if f.playerNamebox.fontstring:GetText() ~= "拾取1" then
                    self:SetText(itemCount)
                else
                    self:SetText(1)
                end
                self:HighlightText()
                local bossName = ParseClassColorName(f.bossfontstring:GetText())
                local data = ZL_PLAYERLIST.lootList[bossName][itemName]
                local playerName = f.playerNamebox.fontstring:GetText()
                local maxCount
                if playerName == "拾取1" then
                    maxCount = data["拾取1"]["counts"]
                else
                    maxCount = data["拾取1"]["counts"] + itemCount
                end
                GameTooltipShow(self, "TOPLEFT", "TOPRIGHT")
                GameTooltip:AddLine("修改数量")
                GameTooltip:AddLine("最大不超过|cff00ff00" .. maxCount .. "|r", 1, 1, 1)
                GameTooltip:AddLine("物品名称不可修改", 1, 0, 0)
                GameTooltip:AddLine("激活输入框，输入或鼠标滚轮修改\n数量，按Enter键或右键保存！", 1, 1, 1)
                GameTooltip:Show()
            end)
            f.itemNamebox:SetScript("OnEditFocusLost", function (self)
                self:HighlightText(0, 0)
                f.itemNamebox.fontstring:Show()
                self:SetText("")
            end)
            f.itemNamebox:SetScript("OnMouseWheel", function (self, delta)
                if self:HasFocus() then
                    local number = self:GetNumber()
                    local txt = f.itemNamebox.fontstring:GetText()
                    local itemCount = tonumber(txt:match("×(%d+)")) or 1
                    local playerName = f.playerNamebox.fontstring:GetText()
                    if playerName ~= "拾取1" then
                        number = number > 0 and number or itemCount
                    end
                    if delta > 0 then
                        number = number + 1
                    else
                        number = number - 1
                    end
                    number = number > 0 and number or 0
                    self:SetNumber(number)
                end
            end)
            f.itemNamebox:SetScript("OnTextChanged", function (self)
                if OverviewFrame.dataType == 2 and ZL_PLAYERLIST.lootList then
                    local txt = f.itemNamebox.fontstring:GetText()
                    local itemName, itemCount
                    if string.match(txt, "|cff00ff00×") then
                        itemName, itemCount = string.match(txt, "^(.-)|cff00ff00×(%d+)|r$")
                        itemCount = tonumber(itemCount)
                    else
                        itemName = txt
                        itemCount = 1
                    end
                    local bossName = ParseClassColorName(f.bossfontstring:GetText())
                    local data = ZL_PLAYERLIST.lootList[bossName][itemName]
                    local playerName = f.playerNamebox.fontstring:GetText()
                    local maxCount
                    if playerName == "拾取1" then
                        maxCount = data["拾取1"]["counts"]
                    else
                        maxCount = data["拾取1"]["counts"] + itemCount
                    end
                    local newCount = self:GetNumber() or 0
                    if newCount >= maxCount then
                        self:SetNumber(maxCount)
                    end
                end
            end)
            local function itemCountChange(self)
                if not ZL_PLAYERLIST.lootList then return end
                local txt = f.itemNamebox.fontstring:GetText()
                local itemName, itemCount
                if string.match(txt, "|cff00ff00×") then
                    itemName, itemCount = string.match(txt, "^(.-)|cff00ff00×(%d+)|r$")
                    itemCount = tonumber(itemCount)
                else
                    itemName = txt
                    itemCount = 1
                end

                local playerName = f.playerNamebox.fontstring:GetText()
                local newItemCount = self:GetNumber()
                if OverviewFrame.dataType == 2 and newItemCount ~= itemCount and newItemCount > 0 then
                    local bossName = ParseClassColorName(f.bossfontstring:GetText())
                    local data = ZL_PLAYERLIST.lootList[bossName][itemName]
                    if playerName == "拾取1" then
                        if newItemCount < itemCount then
                            local i = 1
                            while true do
                                if not data["未知" .. i] then
                                    data["未知" .. i] = {
                                        counts = newItemCount,
                                    }
                                    break
                                end
                                i = i + 1
                            end
                            data["拾取1"]["counts"] = data["拾取1"]["counts"] - newItemCount
                            OverviewFrame:Update(ZL_PLAYERLIST.lootList)
                        else
                            self:ClearFocus()
                        end
                    else
                        if newItemCount <= itemCount + data["拾取1"]["counts"] and newItemCount ~= itemCount then
                            data[playerName]["counts"] = newItemCount
                            data["拾取1"]["counts"] = data["拾取1"]["counts"] - (newItemCount - itemCount)
                            OverviewFrame:Update(ZL_PLAYERLIST.lootList)
                        else
                            self:ClearFocus()
                        end
                    end
                else
                    self:ClearFocus()
                end
            end
            f.itemNamebox:SetScript("OnEnterPressed", function (self)
                itemCountChange(self)
            end)
            f.itemNamebox:SetScript("OnMouseDown", function (self, button)
                if button == "RightButton" and self:HasFocus() then
                    C_Timer.After(0.5, function ()
                        itemCountChange(self)
                    end)
                end
            end)
            f.itemNamebox.fontstring = f.itemNamebox:CreateFontString(nil, "OVERLAY")
            f.itemNamebox.fontstring:SetPoint("TOPLEFT", 3, -1)
            f.itemNamebox.fontstring:SetPoint("BOTTOMRIGHT", -3, 1)
            f.itemNamebox.fontstring:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            f.itemNamebox.fontstring:SetWordWrap(true)
            f.itemNamebox.fontstring:SetJustifyH("LEFT")
            f.itemNamebox.fontstring:SetJustifyV("MIDDLE")
            f.itemNamebox.fontstring:SetTextColor(0.95, 0.95, 0.95, 1)
            
            f.playerNamebox = CreateEditBox(f, playerNamewidth-1, 20, 12, "LEFT", nil, nil, board_r, board_g, board_b, board_a)
            f.playerNamebox:SetPoint("LEFT", f.itemNamebox, "RIGHT", 0, 0)
            f.playerNamebox.Background:SetColorTexture(0,0,0,0)
            f.playerNamebox.BorderRight:Hide()
            -- f.playerNamebox:Disable()
            f.playerNamebox:SetScript("OnEnter", function (self)
                OnEnter(self)
                if f.lootName and (not self:HasFocus()) and OverviewFrame.dataType == 2 and ParseClassColorName(f.bossfontstring:GetText()) ~= "拍卖合计" then
                    GameTooltipShow(self, "TOPLEFT", "BOTTOMRIGHT")
                    GameTooltip:AddLine("拾取人：" .. f.lootName)
                    GameTooltip:AddLine("激活输入框，输入或选择买家\n，按Enter键或右键保存！", 1, 1, 1)
                    GameTooltip:Show()
                end
            end)
            f.playerNamebox:SetScript("OnLeave", function (self)
                OnLeave(self)
                GameTooltip:Hide()
            end)
            f.playerNamebox:SetScript("OnEditFocusGained", function (self)
                f.playerNamebox.fontstring:Hide()
                if f.playerNamebox.fontstring:GetText() ~= "拾取1" then
                    self:SetText(f.playerNamebox.fontstring:GetText())
                    self:HighlightText()
                end
                local groupMembers = GroupMembersActivityMenu(self)
                if #groupMembers > 0 then
                    ZL.GUI:ToggleMenu(self, GroupMembersActivityMenu(self), 'cursor')
                end
                GameTooltip:Hide()
            end)
            f.playerNamebox:SetScript("OnEditFocusLost", function (self)
                ZL.GUI:CloseMenu()
                self:HighlightText(0, 0)
                if f.playerNamebox.fontstring:GetText() == "拾取1" then
                    f.playerNamebox.fontstring:Hide()
                else
                    f.playerNamebox.fontstring:Show()
                end
                self:SetText("")
            end)
            f.playerNamebox:SetScript("OnTextChanged", function (self)
                if self:GetText() == "拾取1" then self:SetText("") end
            end)
            function OverviewFrame.playerNameChange(self)
                local newPlayerName = self:GetText() or ""
                local pf = self:GetParent()
                local oldPlayerName = pf.playerNamebox.fontstring:GetText()
                if OverviewFrame.dataType == 2 and newPlayerName ~= "" and GetClassColorName(newPlayerName) ~= oldPlayerName then
                    local txt = pf.itemNamebox.fontstring:GetText()
                    local itemName, itemCount
                    if string.match(txt, "|cff00ff00×") then
                        itemName, itemCount = string.match(txt, "^(.-)|cff00ff00×(%d+)|r$")
                        itemCount = tonumber(itemCount)
                    else
                        itemName = txt
                        itemCount = 1
                    end
                    local bossName = ParseClassColorName(pf.bossfontstring:GetText())
                    local data = ZL_PLAYERLIST.lootList[bossName][itemName]
                    if oldPlayerName == "拾取1" then
                        if not data[newPlayerName] then
                            data[newPlayerName] = {
                                counts = 1,
                            }
                        else
                            data[newPlayerName]["counts"] = data[newPlayerName]["counts"] + 1
                        end
                        data["拾取1"]["counts"] = data["拾取1"]["counts"] - 1
                    else
                        data[newPlayerName] = {
                            counts = (data[newPlayerName] and data[newPlayerName]["counts"] or 0) + data[oldPlayerName]["counts"],
                            totalAmount = ((data[newPlayerName] and data[newPlayerName]["totalAmount"]) and data[newPlayerName]["totalAmount"] or 0) + (data[oldPlayerName]["totalAmount"] or 0),
                        }
                        data[oldPlayerName] = nil
                    end
                    OverviewFrame:Update(ZL_PLAYERLIST.lootList)
                else
                    self:ClearFocus()
                end
            end
            f.playerNamebox:SetScript("OnEnterPressed", function (self)
                OverviewFrame.playerNameChange(self)
            end)
            f.playerNamebox:SetScript("OnMouseDown", function (self, button)
                if button == "RightButton" and self:HasFocus() then
                    C_Timer.After(0.5, function ()
                        OverviewFrame.playerNameChange(self)
                    end)
                end
            end)
            f.playerNamebox.fontstring = f.playerNamebox:CreateFontString(nil, "OVERLAY")
            f.playerNamebox.fontstring:SetPoint("TOPLEFT", 3, -1)
            f.playerNamebox.fontstring:SetPoint("BOTTOMRIGHT", -3, 1)
            f.playerNamebox.fontstring:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            f.playerNamebox.fontstring:SetWordWrap(true)
            f.playerNamebox.fontstring:SetJustifyH("LEFT")
            f.playerNamebox.fontstring:SetJustifyV("MIDDLE")
            f.playerNamebox.fontstring:SetTextColor(0.95, 0.95, 0.95, 1)

            f.amountbox = CreateEditBox(f, amountwidth, 20, 12, "RIGHT", nil, nil, board_r, board_g, board_b, board_a)
            f.amountbox:SetPoint("LEFT", f.playerNamebox, "RIGHT", 0, 0)
            f.amountbox.Background:SetColorTexture(0,0,0,0)
            -- f.amountbox:Disable()
            f.amountbox:SetScript("OnEnter", function (self)
                OnEnter(self)
                if OverviewFrame.dataType == 2 and ParseClassColorName(f.bossfontstring:GetText()) ~= "拍卖合计" then
                    GameTooltipShow(self, "LEFT", "RIGHT")
                    GameTooltip:AddLine("提示")
                    GameTooltip:AddLine("激活输入框，输入或鼠标滚轮设置\n总金额，按Enter键或右键保存！", 1, 1, 1)
                    if f.playerNamebox.fontstring:GetText() ~= "拾取1" then
                        GameTooltip:AddLine(" ")
                        GameTooltip:AddLine("留空或者输入0直接删除本条记录")
                    end
                    GameTooltip:Show()
                end
            end)
            f.amountbox:SetScript("OnLeave", function (self)
                OnLeave(self)
                GameTooltip:Hide()
            end)
            f.amountbox:SetScript("OnEditFocusGained", function (self)
                f.amountbox.fontstring:Hide()
                if f.amountbox.fontstring:GetText() then
                    self:SetText(f.amountbox.fontstring:GetText())
                end
                self:HighlightText()
            end)
            f.amountbox:SetScript("OnEditFocusLost", function (self)
                self:HighlightText(0, 0)
                f.amountbox.fontstring:Show()
                self:SetText("")
            end)
            f.amountbox:SetScript("OnMouseWheel", function (self, delta)
                EditOnMouseWheel(self, delta)
            end)
            f.amountbox:SetScript("OnTextChanged", function (self)
                if OverviewFrame.dataType == 2 and ZL_PLAYERLIST.lootList then
                    local newAmount = self:GetNumber()
                    if newAmount < 0 then self:SetNumber(0) end
                end
            end)
            local function amountChange(self)
                local oldAmount = tonumber(f.amountbox.fontstring:GetText()) or 0
                local newAmount = self:GetNumber() or 0
                if OverviewFrame.dataType == 2 and ZL_PLAYERLIST.lootList and newAmount ~= oldAmount then
                    local txt = f.itemNamebox.fontstring:GetText()
                    local itemName, itemCount
                    if string.match(txt, "|cff00ff00×") then
                        itemName, itemCount = string.match(txt, "^(.-)|cff00ff00×(%d+)|r$")
                        itemCount = tonumber(itemCount)
                    else
                        itemName = txt
                        itemCount = 1
                    end
                    local bossName = ParseClassColorName(f.bossfontstring:GetText())
                    local data = ZL_PLAYERLIST.lootList[bossName][itemName]
                    local playerName = f.playerNamebox.fontstring:GetText()
                    if newAmount > 0 then
                        if playerName == "拾取1" then
                            local i = 1
                            while true do
                                if not data["未知" .. i] then
                                    data["未知" .. i] = {
                                        counts = 1,
                                        totalAmount = newAmount,
                                    }
                                    break
                                end
                                i = i + 1
                            end
                            data["拾取1"]["counts"] = data["拾取1"]["counts"] - 1
                        else
                            data[playerName]["totalAmount"] = newAmount
                        end
                    else --输入为0的时候，删除记录
                        data[playerName] = nil
                        data["拾取1"]["counts"] = data["拾取1"]["counts"] + itemCount
                    end
                    OverviewFrame:Update(ZL_PLAYERLIST.lootList)
                else
                    self:ClearFocus()
                end
            end
            f.amountbox:SetScript("OnEnterPressed", function (self)
                amountChange(self)
            end)
            f.amountbox:SetScript("OnMouseDown", function (self, button)
                if button == "RightButton" and self:HasFocus() then
                    C_Timer.After(0.5, function ()
                        amountChange(self)
                    end)
                end
            end)
            f.amountbox.fontstring = f.amountbox:CreateFontString(nil, "OVERLAY")
            f.amountbox.fontstring:SetPoint("TOPLEFT", 3, -1)
            f.amountbox.fontstring:SetPoint("BOTTOMRIGHT", -3, 1)
            f.amountbox.fontstring:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            f.amountbox.fontstring:SetWordWrap(true)
            f.amountbox.fontstring:SetJustifyH("RIGHT")
            f.amountbox.fontstring:SetJustifyV("MIDDLE")
            f.amountbox.fontstring:SetTextColor(0.95, 0.95, 0.95, 1)

            t[v] = f
            return f
        end
    })

    function OverviewFrame:Update(bill)
        for _, f in ipairs(OverviewFrame.entries) do f:Hide() end
        local recordList = {}
        local itemLevelList = {}
        if bill == ZL_CURRENT then
            OverviewFrame.dataType = 1
        elseif bill == ZL_PLAYERLIST.lootList then
            OverviewFrame.dataType = 2
        else
            OverviewFrame.dataType = 3
        end
        local profileName = ZL.opt.subsidyProfileList["profileKeys"][ZL.opt.subsidyProfileSelect]
        local subsidyData = ZL.opt.subsidyProfileList["profile"][profileName]["child"]
        local subsidyMoney = subsidyData["RL"]
        if bill and bill.auctionlist and #bill.auctionlist > 0 then
            local numGroupMembers, RLBuTie, totalincome, totalpayout, totalamount, averageamount = GetAveWages(bill)
            for _, data in ipairs(bill.auctionlist) do
                local itemlink = data.itemlink
                local spawnUID = data.spawnUID
                local bossName, playerName, counts, totalAmount, itemList
                itemLevelList[itemlink] = data.itemLevel
                itemList = data.itemList
                if spawnUID and (not data.isPackage) then
                    for _, value in pairs(spawnUID) do
                        bossName = value["bossName"] or value["bossname"]
                        if not recordList[bossName] then recordList[bossName] = {} end
                        if not recordList[bossName][itemlink] then recordList[bossName][itemlink] = {} end
                        if (not value["successBidder"]) or (value["successBidder"] and (not next(value["successBidder"]))) then
                            -- counts = data["itemCount"]
                            counts = 1
                            if data.state == "waiting" then
                                playerName = "待拍卖"
                            elseif data.state == "auctioning" then
                                playerName = "拍卖中"
                            elseif data.state == "failed" or data.state == "success" then
                                playerName = "流拍"
                            end
                            playerName = playerName or "流拍"
                            if not recordList[bossName][itemlink][playerName] then recordList[bossName][itemlink][playerName] = {} end
                            recordList[bossName][itemlink][playerName]["counts"] = counts + (recordList[bossName][itemlink][playerName]["counts"] or 0)
                            recordList[bossName][itemlink][playerName]["itemList"] = itemList
                        else
                            for _palyer, value2 in pairs(value["successBidder"]) do
                                playerName = _palyer
                                totalAmount = value2.amount
                                counts = value2.count
                                if not recordList[bossName][itemlink][playerName] then recordList[bossName][itemlink][playerName] = {} end
                                recordList[bossName][itemlink][playerName]["counts"] = counts + (recordList[bossName][itemlink][playerName]["counts"] or 0)
                                recordList[bossName][itemlink][playerName]["totalAmount"] = totalAmount + (recordList[bossName][itemlink][playerName]["totalAmount"] or 0)
                                recordList[bossName][itemlink][playerName]["itemList"] = itemList
                            end
                        end

                    end
                end
            end
            if bill.IncomeList and #bill.IncomeList > 0 then
                local bossName, playerName
                for _, data in ipairs(bill.IncomeList) do
                    if not data["tradeId"] then
                        bossName = "手动添加"
                        if not recordList[bossName] then recordList[bossName] = {} end
                        if not recordList[bossName][data["notes"]] then recordList[bossName][data["notes"]] = {} end
                        playerName = data["player"] or "其他"
                        if not recordList[bossName][data["notes"]][playerName] then recordList[bossName][data["notes"]][playerName] = {} end
                        recordList[bossName][data["notes"]][playerName]["totalAmount"] = (recordList[bossName][data["notes"]][playerName]["totalAmount"] or 0) + data["amount"]
                        recordList[bossName][data["notes"]][playerName]["counts"] = (recordList[bossName][data["notes"]][playerName]["counts"] or 0) + data["itemCount"]
                    end
                end
            end
            if bill["aveWages"] then
                recordList["收支总览"] = {
                    ["总收入"] = {
                        [" "] = {
                            ["totalAmount"] = totalincome,
                            ["counts"] = " ",
                        },
                    },
                    ["总支出"] = {
                        [" "] = {
                            ["totalAmount"] = totalpayout,
                            ["counts"] = " ",
                        },
                    },
                    ["浄收入"] = {
                        [" "] = {
                            ["totalAmount"] = totalamount,
                            ["counts"] = " ",
                        },
                    },
                }
                recordList["工资分配"] = {
                    [subsidyMoney == "团双" and "工资人数(团双)" or "工资人数"] = {
                        [" "] = {
                            ["totalAmount"] = numGroupMembers,
                            ["counts"] = " ",
                        },
                    },
                    ["人均工资"] = {
                        [" "] = {
                            ["totalAmount"] = averageamount,
                            ["counts"] = " ",
                        },
                    },
                    ["小队工资"] = {
                        [averageamount .. "×5"] = {
                            ["totalAmount"] = averageamount*5,
                            ["counts"] = " ",
                        },
                    },
                }
            end
            if bill["butie"] and #bill["butie"]  > 0 then
                local bossName = "补贴支出"
                local playerName
                if not recordList[bossName] then recordList[bossName] = {} end
                for _, data in ipairs(bill["butie"]) do
                    local notes = data["notes"]
                    if notes ~= "RL补贴(团双)" then
                        if notes:match("RL补贴") then
                            notes = "RL补贴"
                        end
                        if not recordList[bossName][notes] then recordList[bossName][notes] = {} end
                        playerName = data["player"]
                        if not recordList[bossName][notes][playerName] then recordList[bossName][notes][playerName] = {} end
                        recordList[bossName][notes][playerName]["totalAmount"] = (recordList[bossName][notes][playerName]["totalAmount"] or 0) + data["amount"]
                        recordList[bossName][notes][playerName]["counts"] = (recordList[bossName][notes][playerName]["counts"] or 0) + (data["itemCount"] or 1)
                    end
                end
            end
            local playerBuyList = ZL.GetPlayerBuyList(bill)
            local debtList = {}
            for name, data in pairs(playerBuyList) do
                local balanceAmount = 0
                local playerPayToMLamount = 0
                if bill.playerPayToML and bill.playerPayToML[name] then
                    playerPayToMLamount = bill.playerPayToML[name]
                end
                balanceAmount = playerPayToMLamount - data.totalAmount
                if PlayerIsML(name) then
                    balanceAmount = 0
                end
                if balanceAmount < 0 then
                    debtList[name] = balanceAmount
                end
            end
            if next(debtList) then
                local bossName = "欠款名单"
                if not recordList[bossName] then recordList[bossName] = {} end
                if not recordList[bossName][" "] then recordList[bossName][" "] = {} end
                for name, debt in pairs(debtList) do
                    if not recordList[bossName][" "][name] then recordList[bossName][" "][name] = {} end
                    recordList[bossName][" "][name]["totalAmount"] = debt
                    recordList[bossName][" "][name]["counts"] = 1
                end
            end
            wipe(debtList)
            wipe(playerBuyList)
            debtList = nil
            playerBuyList = nil
        elseif bill and bill.type == "拾取记录" then
            recordList = bill
            recordList["拍卖合计"] = {}
            local totalAmount = 0
            for _, value1 in pairs(recordList) do
                if type(value1) == "table" then
                    for _, value2 in pairs(value1) do
                        for playerName, value3 in pairs(value2) do
                            if playerName ~= "拾取1" then
                                totalAmount = totalAmount + (value3.totalAmount or 0)
                            end
                        end
                    end
                end
            end
            local groupMembers = GetNumGroupMembers(1) == 0 and 1 or GetNumGroupMembers(1)
            recordList["拍卖合计"] = {
                ["总收入"] = {
                    ["拾取1"] = {
                        ["lootName"] = " ",
                        ["counts"] = 0,
                        ["itemLevel"] = 1,
                    },
                    [" "] = {
                        counts = 1,
                        totalAmount = totalAmount,
                    }
                },
                ["预估人数"] = {
                    ["拾取1"] = {
                        ["lootName"] = " ",
                        ["counts"] = 0,
                        ["itemLevel"] = 1,
                    },
                    [" "] = {
                        counts = 1,
                        totalAmount = groupMembers,
                    }
                },
                ["人均预估"] = {
                    ["拾取1"] = {
                        ["lootName"] = " ",
                        ["counts"] = 0,
                        ["itemLevel"] = 1,
                    },
                    [" "] = {
                        counts = 1,
                        totalAmount = floor(totalAmount/groupMembers),
                    }
                }
            }
        end
        if recordList and next(recordList, nil) then
            OverviewFrame:SetSize(GetScreenWidth()-65, GetScreenHeight()-50)
            local maxrows = math.floor(OverviewFrame.scrollFrame:GetHeight() / (height+gapheight)) --全屏支持的最大行数
            local bossNameRowsList = {}
            local bossMaxRows = 0
            for bossName, value1 in pairs(recordList) do
                local rows = 0
                if type(value1) == "table" then
                    for _, value2 in pairs(value1) do
                        for _, value3 in pairs(value2) do
                            rows = rows + 1
                            bossMaxRows = bossMaxRows + 1
                            if bossName == "打包拍卖" then
                                for _ in pairs(value3["itemList"]) do
                                    rows = rows + 1
                                    bossMaxRows = bossMaxRows + 1
                                end
                            end
                        end
                    end
                    bossNameRowsList[bossName] = rows
                    bossMaxRows = bossMaxRows + 1
                end
            end
            bossMaxRows = bossMaxRows - 1
            local aveMaxRows = math.floor(bossMaxRows/3) + 3
            maxrows = aveMaxRows > maxrows and aveMaxRows or maxrows
            local index = 1
            local bili = 1
            local bossindex = 0
            local oldbossindex = 1
            local f
            local column = 0
            local row = 1
            local rowMax = 1 --取每列中最大的行
            for _, bossName in ipairs(ZL.encounterNameList) do
                local value1 = recordList[bossName]
                if value1 and type(value1) == "table" then
                    bossindex = bossindex + 1
                    local index2 = 1
                    oldbossindex = index
                    if next(value1) then
                        local itemList = {}
                        if bossName == "收支总览" then
                            itemList = {"总收入", "总支出", "浄收入"}
                        elseif bossName == "工资分配" then
                            itemList = { subsidyMoney == "团双" and "工资人数(团双)" or "工资人数", "人均工资", "小队工资"}
                        elseif bossName == "补贴支出" then
                            itemList = {"RL补贴", "T补贴", "N补贴", "DPS补贴", "食物补贴", "工具人补贴", "其它补贴"}
                        elseif bossName == "拍卖合计" then
                            itemList = {"总收入", "预估人数", "人均预估"}
                        else
                            for itemlink in pairs(value1) do
                                tinsert(itemList, itemlink)
                            end
                            table.sort(itemList)
                        end
                        for _, itemlink in ipairs(itemList) do
                            local value2 = value1[itemlink]
                            if value2 then
                                local itemId = tonumber(itemlink:match("|Hitem:(%d+):"))
                                local lootName = value2["拾取1"] and value2["拾取1"]["lootName"] or nil
                                local itemLevel = value2["拾取1"] and value2["拾取1"]["itemLevel"] or nil
                                if next(value2, nil) then
                                    local playerNameList = {}
                                    for playerName in pairs(value2) do
                                        tinsert(playerNameList, playerName)
                                    end
                                    table.sort(playerNameList)
                                    for _, playerName in ipairs(playerNameList) do
                                        local value3 = value2[playerName]
                                        if playerName ~= "拾取1" or (playerName == "拾取1" and value3["counts"] > 0) then
                                            f = OverviewFrame.entries[index]
                                            f:ClearAllPoints()
                                            if lootName then f.lootName = lootName end
                                            if index2 == 1 then
                                                if index == 1 or (row + bossNameRowsList[bossName]) > maxrows then
                                                    f:SetPoint("TOPLEFT", content, "TOPLEFT", (BOSSwidth+itemNamewidth+playerNamewidth+amountwidth+gapwidth-3)*column, 0)
                                                    column = column + 1
                                                    if row > maxrows then
                                                        maxrows = row
                                                    end
                                                    if row > rowMax then
                                                        rowMax = row
                                                    end
                                                    row = 1
                                                else
                                                    f:SetPoint("TOPLEFT", OverviewFrame.entries[index-1], "BOTTOMLEFT", 0, -gapheight)
                                                    row = row + 1
                                                    if row > rowMax then
                                                        rowMax = row
                                                    end
                                                end
                                                if bossName == "打包拍卖" then
                                                    f.bossfontstring:SetText(bossName)
                                                elseif bossName == "总览" or bossName == "工资" then
                                                    f.bossfontstring:SetText("|cff00aaff" .. bossName .. "|r")
                                                elseif bossName == "欠款名单" then
                                                    f.bossfontstring:SetText("|TInterface\\DialogFrame\\DialogAlertIcon.blp:20|t|cffff0000" .. bossName .. "|r")
                                                else
                                                    if bossindex % 2 == 0 then
                                                        f.bossfontstring:SetText("|cffADDFAD" .. bossName .. "|r")
                                                    else
                                                        f.bossfontstring:SetText("|cffFFD700" .. bossName .. "|r")
                                                    end
                                                end
                                                f.bossfontstring:Show()
                                                -- f.itemNamebox.BorderTop:Show()
                                                -- f.playerNamebox.BorderTop:Show()
                                                -- f.amountbox.BorderTop:Show()
                                            else
                                                f:SetPoint("TOPLEFT", OverviewFrame.entries[index-1], "BOTTOMLEFT", 0, -gapheight)
                                                f.bossfontstring:SetText(bossName)
                                                f.bossfontstring:Hide()
                                                -- f.itemNamebox.BorderTop:Hide()
                                                -- f.playerNamebox.BorderTop:Hide()
                                                -- f.amountbox.BorderTop:Hide()
                                                row = row + 1
                                            end
                                            f.playerNamebox.fontstring:Show()
                                            f.amountbox.fontstring:Show()
                                            if OverviewFrame.dataType == 2 and bossName ~= "拍卖合计" then
                                                f.itemNamebox:Enable()
                                                f.playerNamebox:Enable()
                                                f.amountbox:Enable()
                                            else
                                                f.itemNamebox:Disable()
                                                f.playerNamebox:Disable()
                                                f.amountbox:Disable()
                                            end
                                            f:Show()
                                            index = index + 1
                                            f.itemlink = itemlink
                                            if itemId then
                                                f.itemicon:SetNormalTexture(cGetItemIcon(itemlink))
                                                local itemTotalCount = select(4, ZL.GetItemNumbers(itemId))
                                                if itemTotalCount > 0 then
                                                    f.itemicon.itemNumbersIcon:SetTexture([[interface/raidframe/readycheck-ready]])
                                                else
                                                    f.itemicon.itemNumbersIcon:SetTexture()
                                                end
                                            elseif itemlink == "[打包拍卖]" then
                                                f.itemicon:SetNormalTexture(ZL.LogoPath)
                                                f.itemicon.itemNumbersIcon:SetTexture()
                                            else
                                                f.itemicon:ClearNormalTexture()
                                                f.itemicon.itemNumbersIcon:SetTexture()
                                            end
                                            f.level:SetTextScale(1)
                                            f.itemNamebox.fontstring:SetTextScale(1)
                                            f.playerNamebox.fontstring:SetTextScale(1)
                                            f.amountbox.fontstring:SetTextScale(1)
                                            if itemLevel and itemLevel >= 30 then
                                                f.level:SetText(itemLevel)
                                            elseif itemLevelList[itemlink] and itemLevelList[itemlink] >= 30 then
                                                f.level:SetText(itemLevelList[itemlink])
                                            else
                                                f.level:SetText("")
                                            end
                                            if type(value3["counts"]) == "number" and value3["counts"] > 1 then
                                                f.itemNamebox.fontstring:SetText(itemlink .. "|cff00ff00×" .. value3["counts"] .. "|r")
                                            else
                                                if itemlink == "RL补贴" then
                                                    if type(subsidyMoney) == "number" then
                                                        f.itemNamebox.fontstring:SetText(itemlink)
                                                    elseif subsidyMoney == "团双" then
                                                        f.itemNamebox.fontstring:SetText(itemlink .. "(团双)")
                                                    elseif type(subsidyMoney) == "string" and subsidyMoney:match("(%d+%%)") then
                                                        f.itemNamebox.fontstring:SetText(itemlink .. "(" .. subsidyMoney:match("(%d+%%)") .. ")")
                                                    end
                                                else
                                                    f.itemNamebox.fontstring:SetText(itemlink)
                                                end
                                            end
                                            f.playerNamebox.fontstring:SetText(ZL.GetNoRealmName(playerName, true))
                                            if playerName == "拾取1" or string.match(playerName, "^未知%d+$") then
                                                f.playerNamebox.fontstring:Hide()
                                            else
                                                f.playerNamebox.fontstring:Show()
                                            end

                                            f.amountbox.fontstring:SetText(value3["totalAmount"] and format("%.0f", value3["totalAmount"]) or "")
                                            bili = f.level:GetStringWidth()>0 and f.level:GetWidth()/(f.level:GetUnboundedStringWidth()+5) or 1
                                            if bili < 1 then
                                                f.level:SetTextScale(bili)
                                            else
                                                f.level:SetTextScale(1)
                                            end
                                            bili = f.itemNamebox.fontstring:GetStringWidth()>0 and f.itemNamebox.fontstring:GetWidth()/(f.itemNamebox.fontstring:GetUnboundedStringWidth()+5) or 1
                                            if bili < 1 then
                                                f.itemNamebox.fontstring:SetTextScale(bili)
                                            else
                                                f.itemNamebox.fontstring:SetTextScale(1)
                                            end
                                            bili = f.playerNamebox.fontstring:GetStringWidth()>0 and f.playerNamebox.fontstring:GetWidth()/(f.playerNamebox.fontstring:GetUnboundedStringWidth()+5) or 1
                                            if bili < 1 then
                                                f.playerNamebox.fontstring:SetTextScale(bili)
                                            else
                                                f.playerNamebox.fontstring:SetTextScale(1)
                                            end
                                            bili = f.amountbox.fontstring:GetStringWidth()>0 and f.amountbox.fontstring:GetWidth()/(f.amountbox.fontstring:GetUnboundedStringWidth()+5) or 1
                                            if bili < 1 then
                                                f.amountbox.fontstring:SetTextScale(bili)
                                            else
                                                f.amountbox.fontstring:SetTextScale(1)
                                            end
                                            index2 = index2 + 1
                                            if bossName == "打包拍卖" and value3["itemList"] then
                                                -- index2 = 1
                                                for _itemlink, value4 in pairs(value3["itemList"]) do
                                                    local _itemId = tonumber(_itemlink:match("|Hitem:(%d+):"))
                                                    f = OverviewFrame.entries[index]
                                                    f:ClearAllPoints()
                                                    f:SetPoint("TOPLEFT", OverviewFrame.entries[index-1], "BOTTOMLEFT", 0, -gapheight)
                                                    f.bossfontstring:SetText(bossName)
                                                    f.bossfontstring:Hide()
                                                    if OverviewFrame.dataType == 2 then
                                                        f.itemNamebox:Enable()
                                                        f.playerNamebox:Enable()
                                                        f.amountbox:Enable()
                                                    else
                                                        f.itemNamebox:Disable()
                                                        f.playerNamebox:Disable()
                                                        f.amountbox:Disable()
                                                    end

                                                    -- f.itemNamebox.BorderTop:Hide()
                                                    -- f.playerNamebox.BorderTop:Hide()
                                                    -- f.amountbox.BorderTop:Hide()

                                                    f:Show()
                                                    index = index + 1
                                                    row = row + 1
                                                    if row > rowMax then
                                                        rowMax = row
                                                    end
                                                    f.itemlink = _itemlink
                                                    if _itemId then
                                                        f.itemicon:SetNormalTexture(cGetItemIcon(_itemlink))
                                                    else
                                                        f.itemicon:ClearNormalTexture()
                                                    end
                                                    f.level:SetTextScale(1)
                                                    f.itemNamebox.fontstring:SetTextScale(1)
                                                    f.playerNamebox.fontstring:SetTextScale(1)
                                                    f.amountbox.fontstring:SetTextScale(1)
                                                    if itemLevelList[_itemlink] and itemLevelList[_itemlink] >= 30 then
                                                        f.level:SetText(itemLevelList[_itemlink])
                                                    else
                                                        f.level:SetText("")
                                                    end
                                                    if value4["itemCount"] > 1 then
                                                        f.itemNamebox.fontstring:SetText(_itemlink .. "|cff00ff00×" .. value4["itemCount"] .. "|r")
                                                    else
                                                        f.itemNamebox.fontstring:SetText(_itemlink)
                                                    end
                                                    f.playerNamebox.fontstring:SetText("")
                                                    f.amountbox.fontstring:SetText("")
                                                    bili = f.level:GetStringWidth()>0 and (f.level:GetWidth())/(f.level:GetUnboundedStringWidth()+5) or 1
                                                    if bili < 1 then
                                                        f.level:SetTextScale(bili)
                                                    else
                                                        f.level:SetTextScale(1)
                                                    end
                                                    bili = f.itemNamebox.fontstring:GetStringWidth()>0 and f.itemNamebox.fontstring:GetWidth()/(f.itemNamebox.fontstring:GetUnboundedStringWidth()+5) or 1
                                                    if bili < 1 then
                                                        f.itemNamebox.fontstring:SetTextScale(bili)
                                                    else
                                                        f.itemNamebox.fontstring:SetTextScale(1)
                                                    end
                                                    bili = f.playerNamebox.fontstring:GetStringWidth()>0 and f.playerNamebox.fontstring:GetWidth()/(f.playerNamebox.fontstring:GetUnboundedStringWidth()+5) or 1
                                                    if bili < 1 then
                                                        f.playerNamebox.fontstring:SetTextScale(bili)
                                                    else
                                                        f.playerNamebox.fontstring:SetTextScale(1)
                                                    end
                                                    bili = f.amountbox.fontstring:GetStringWidth()>0 and f.amountbox.fontstring:GetWidth()/(f.amountbox.fontstring:GetUnboundedStringWidth()+5) or 1
                                                    if bili < 1 then
                                                        f.amountbox.fontstring:SetTextScale(bili)
                                                    else
                                                        f.amountbox.fontstring:SetTextScale(1)
                                                    end
                                                    index2 = index2 + 1
                                                end
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end
                    f= OverviewFrame.entries[oldbossindex]
                    f.bossfontstring:SetHeight((index2-1)*(height+gapheight))
                    if row <= maxrows then
                        f = OverviewFrame.entries[index]
                        f:SetPoint("TOPLEFT", OverviewFrame.entries[index-1], "BOTTOMLEFT", 0, -gapheight)
                        f:Hide()
                        index = index + 1
                        row = row + 1
                        if row > rowMax then
                            rowMax = row
                        end
                    end
                end
            end
            rowMax = rowMax - 1
            rowMax = rowMax > 20 and rowMax or 20 --最低显示20行高度
            local contetHeight = (height+gapheight)*rowMax
            content:SetHeight(contetHeight)
            if column == 1 then
                BOSSHeaderBtn2:Hide()
                itemNameHeaderBtn2:Hide()
                playerNameHeaderBtn2:Hide()
                amountHeaderBtn2:Hide()

                BOSSHeaderBtn3:Hide()
                itemNameHeaderBtn3:Hide()
                playerNameHeaderBtn3:Hide()
                amountHeaderBtn3:Hide()
            elseif column == 2 then
                BOSSHeaderBtn2:Show()
                itemNameHeaderBtn2:Show()
                playerNameHeaderBtn2:Show()
                amountHeaderBtn2:Show()

                BOSSHeaderBtn3:Hide()
                itemNameHeaderBtn3:Hide()
                playerNameHeaderBtn3:Hide()
                amountHeaderBtn3:Hide()
            elseif column == 3 then
                BOSSHeaderBtn2:Show()
                itemNameHeaderBtn2:Show()
                playerNameHeaderBtn2:Show()
                amountHeaderBtn2:Show()

                BOSSHeaderBtn3:Show()
                itemNameHeaderBtn3:Show()
                playerNameHeaderBtn3:Show()
                amountHeaderBtn3:Show()
            end
            local OverviewFrameHeight = contetHeight + BOSSHeaderBtn1:GetHeight() + 42
            OverviewFrameHeight = OverviewFrameHeight > (GetScreenHeight()-50) and (GetScreenHeight()-50) or OverviewFrameHeight
            OverviewFrame:SetSize(23+(column-1)*gapwidth+column*(itemNamewidth+playerNamewidth+amountwidth+BOSSwidth-3), OverviewFrameHeight)
        else
            BOSSHeaderBtn2:Hide()
            itemNameHeaderBtn2:Hide()
            playerNameHeaderBtn2:Hide()
            amountHeaderBtn2:Hide()

            BOSSHeaderBtn3:Hide()
            itemNameHeaderBtn3:Hide()
            playerNameHeaderBtn3:Hide()
            amountHeaderBtn3:Hide()
            local OverviewFrameHeight = (height+gapheight)*20 + BOSSHeaderBtn1:GetHeight() + 42
            OverviewFrame:SetSize(23+(itemNamewidth+playerNamewidth+amountwidth+BOSSwidth-3), OverviewFrameHeight)
        end
        if bill and bill.name and bill.auctiondate then
            OverviewFrame.Title:SetText("拍卖账单总览|cffffffff—|r" .. bill.name .. "|cffffffff—|r" .. bill.auctiondate)
        elseif bill and bill.type == "拾取记录" then
            OverviewFrame.Title:SetText("拾取记录")
        else
            OverviewFrame.Title:SetText("没有记录")
        end
        recordList = nil
        itemLevelList = nil
        OverviewFrame:ClearAllPoints()
        OverviewFrame:SetPoint("CENTER")
    end

end

--分解流拍物品界面
function ZL:CreateDisenchantingFrame()
    ZL.DisenchantingFrame = ZLCreateFrame("ZLDisenchantingFrame", ZL, nil, nil, nil, true, true, "流拍物品窗口")
    local DisenchantingFrame = ZL.DisenchantingFrame
    DisenchantingFrame:Hide()
    tinsert(UISpecialFrames, DisenchantingFrame:GetName())
    DisenchantingFrame:SetScript("OnMouseUp", function (self)
        self:StopMovingOrSizing()
        if not ZL.glb.ZLDisenchantingFrame then ZL.glb.ZLDisenchantingFrame = {} end
        ZL.glb.ZLDisenchantingFrame.point, _, ZL.glb.ZLDisenchantingFrame.relative, ZL.glb.ZLDisenchantingFrame.x, ZL.glb.ZLDisenchantingFrame.y = self:GetPoint()
    end)
    DisenchantingFrame:SetScript("OnMouseDown", function (self)
        self:StartMoving()
    end)
    DisenchantingFrame:SetScript("OnShow", function (self)
        DisenchantingFrame:Update()
    end)
    DisenchantingFrame:SetScript("OnHide", function (self)
        ClearOverrideBindings(DisenchantingFrame.disenchantingBtn)
    end)
    DisenchantingFrame:SetScript("OnSizeChanged", function (self, _, height)
        if ZL.DisenchantingLgnoreFrame then
            ZL.DisenchantingLgnoreFrame:SetHeight(height+5)
        end
    end)
    DisenchantingFrame:ClearAllPoints()
    if ZL.glb.ZLDisenchantingFrame and ZL.glb.ZLDisenchantingFrame.point then
        DisenchantingFrame:SetPoint(ZL.glb.ZLDisenchantingFrame.point, UIParent, ZL.glb.ZLDisenchantingFrame.relative, ZL.glb.ZLDisenchantingFrame.x, ZL.glb.ZLDisenchantingFrame.y)
    else
        DisenchantingFrame:SetPoint("CENTER")
    end
    DisenchantingFrame:SetResizeBounds(305, 350, 305, GetScreenHeight()-110)
    local btnTexture = [[Interface\ACHIEVEMENTFRAME\UI-Achievement-Parchment-Horizontal]]
    DisenchantingFrame.hideBtn = CreateButton(nil, DisenchantingFrame, "隐藏", "TOPLEFT", DisenchantingFrame.TitleBottom, "BOTTOMLEFT", 3, -5, 47)
    local hideBtn = DisenchantingFrame.hideBtn
    hideBtn:GetFontString():SetFont(GameFontNormal:GetFont(), 14, "OUTLINE")
    hideBtn:SetNormalTexture(btnTexture)
    hideBtn:ClearHighlightTexture()

    DisenchantingFrame.itemNameBtn = CreateButton(nil, DisenchantingFrame, "物品名称", "LEFT", hideBtn, "RIGHT", 0, 0, 185)
    local itemNameBtn = DisenchantingFrame.itemNameBtn
    itemNameBtn:GetFontString():SetFont(GameFontNormal:GetFont(), 14, "OUTLINE")
    itemNameBtn:SetNormalTexture(btnTexture)
    itemNameBtn:ClearHighlightTexture()

    DisenchantingFrame.itemLevelBtn = CreateButton(nil, DisenchantingFrame, "装等", "LEFT", itemNameBtn, "RIGHT", 0, 0, 50)
    local itemLevelBtn = DisenchantingFrame.itemLevelBtn
    itemLevelBtn:GetFontString():SetFont(GameFontNormal:GetFont(), 14, "OUTLINE")
    itemLevelBtn:SetNormalTexture(btnTexture)
    itemLevelBtn:ClearHighlightTexture()

    DisenchantingFrame.disenchantingBtn = CreateFrame("Button", "ZLDisenchantButton", DisenchantingFrame, "SecureActionButtonTemplate") --, "SecureActionButtonTemplate"
    local disenchantingBtn = DisenchantingFrame.disenchantingBtn
    disenchantingBtn:SetSize(DisenchantingFrame:GetWidth() - 46, 30)
    disenchantingBtn:SetPoint("BOTTOM", DisenchantingFrame, "BOTTOM", 0, 10)
    -- 设置按钮外观
    do
        local texture = disenchantingBtn:CreateTexture()
        texture:SetColorTexture(0.25,0.25,0.27, 1)
        texture:SetAllPoints()
        disenchantingBtn:SetNormalTexture(texture)
    end
    do
        local texture = disenchantingBtn:CreateTexture()
        texture:SetColorTexture(0.36,0.36,0.38,0.5)
        texture:SetAllPoints()
        disenchantingBtn:SetHighlightTexture(texture)
    end
    disenchantingBtn:SetText("分解流拍物品")

	disenchantingBtn:SetNormalFontObject("GameFontNormal")
	disenchantingBtn:SetHighlightFontObject("GameFontHighlight")
	disenchantingBtn:SetDisabledFontObject("GameFontDisable")
    local fontString = disenchantingBtn:GetFontString()
    if fontString then
	    fontString:SetFont(GameFontNormal:GetFont(), 16)
    end
    -- 设置宏命令
    disenchantingBtn:SetAttribute("type", "macro")
    do
        local line = DisenchantingFrame:CreateLine()
        line:SetColorTexture(1, 1, 1, 0.5)
        line:SetStartPoint("BOTTOMLEFT", 0, 20+disenchantingBtn:GetHeight())
        line:SetEndPoint("BOTTOMRIGHT", 0, 20+disenchantingBtn:GetHeight())
        line:SetThickness(1)
    end

    DisenchantingFrame:RegisterEvent("UNIT_SPELLCAST_START")
    DisenchantingFrame:RegisterEvent("UNIT_SPELLCAST_STOP")
    DisenchantingFrame:RegisterEvent("UNIT_SPELLCAST_FAILED")
    DisenchantingFrame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
    DisenchantingFrame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
    DisenchantingFrame:RegisterEvent("BAG_UPDATE_DELAYED")
    DisenchantingFrame:SetScript("OnEvent", function (self, event, unitTarget, _, spellID)
        if unitTarget and unitTarget == "player" and spellID and spellID == 13262 then
            if event == "UNIT_SPELLCAST_START" then
                disenchantingBtn:Disable()
                DisenchantingFrame.hasSpellcastSucceeded = nil
                DisenchantingFrame.startDisenchant = true
            elseif event == "UNIT_SPELLCAST_STOP" then
                DisenchantingFrame.startDisenchant = nil
            elseif event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_INTERRUPTED" then
                disenchantingBtn:Enable()
                DisenchantingFrame.hasSpellcastSucceeded = nil
            elseif event == "UNIT_SPELLCAST_SUCCEEDED" then
                DisenchantingFrame.hasSpellcastSucceeded = true
            end
        end
        if event == "BAG_UPDATE_DELAYED" then
            if DisenchantingFrame.hasSpellcastSucceeded then
                C_Timer.After(0.5, function ()
                    DisenchantingFrame:Update()
                    DisenchantingFrame.hasSpellcastSucceeded = nil
                end)
            elseif (not DisenchantingFrame.startDisenchant) and (ZL.DisenchantingFrame and ZL.DisenchantingFrame:IsShown()) then
                DisenchantingFrame:Update()
            end
        end
    end)

    DisenchantingFrame.lgnoreBtn = CreateFrame("Button", nil, DisenchantingFrame)
    local lgnoreBtn = DisenchantingFrame.lgnoreBtn
    lgnoreBtn:SetPoint("TOPLEFT", 3, -5)
    lgnoreBtn:SetSize(20, 20)
    local lgnoreBtnTexture = [[Interface\MONEYFRAME\Arrow-Left-Up.blp]]
    lgnoreBtn:SetNormalTexture(lgnoreBtnTexture)
    lgnoreBtn:SetHighlightTexture(lgnoreBtnTexture)
    lgnoreBtn:SetScript("OnClick", function ()
        if not ZL.DisenchantingLgnoreFrame then ZL:CreateDisenchantingLgnoreFrame() end
        if ZL.DisenchantingLgnoreFrame:IsShown() then
            ZL.DisenchantingLgnoreFrame:Hide()
            lgnoreBtnTexture = [[Interface\MONEYFRAME\Arrow-Left-Up.blp]]
            lgnoreBtn:SetNormalTexture(lgnoreBtnTexture)
            lgnoreBtn:SetHighlightTexture(lgnoreBtnTexture)
        else
            ZL.DisenchantingLgnoreFrame:Show()
            lgnoreBtnTexture = [[Interface\MONEYFRAME\Arrow-Right-Up.blp]]
            lgnoreBtn:SetNormalTexture(lgnoreBtnTexture)
            lgnoreBtn:SetHighlightTexture(lgnoreBtnTexture)
        end
    end)
    lgnoreBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP", 0, 4)
        GameTooltip:AddLine("永久隐藏物品")
        GameTooltip:Show()
    end)
    lgnoreBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)

    --创建滚动条
    DisenchantingFrame.scrollFrame = CreateFrame("ScrollFrame", nil, DisenchantingFrame, "UIPanelScrollFrameTemplate")
    DisenchantingFrame.scrollFrame:SetFrameLevel(DisenchantingFrame:GetFrameLevel() + 1) -- 设置为比父框架高1级
    DisenchantingFrame.scrollFrame:SetPoint("TOPLEFT", DisenchantingFrame.TitleBottom, "BOTTOMLEFT", 0, -5-hideBtn:GetHeight())
    DisenchantingFrame.scrollFrame:SetPoint("BOTTOMRIGHT", DisenchantingFrame, "BOTTOMRIGHT", 0, 21+disenchantingBtn:GetHeight())
    DisenchantingFrame.scrollFrame:SetClipsChildren(true) --必须设置为true，scrollFrame所有的子元素才会被剪切
    DisenchantingFrame.scrollFrame:SetScript("OnMouseWheel", ZL.ScrollFrame_OnMouseWheel) --重设滑动条鼠标滚轮事件
    --重设ScrollBar位置，放置到scrollFrame内，防止被剪切掉
    DisenchantingFrame.scrollFrame.ScrollBar:ClearAllPoints()
    DisenchantingFrame.scrollFrame.ScrollBar:SetPoint("TOPLEFT", DisenchantingFrame.scrollFrame, "TOPRIGHT", -20, -17)
    DisenchantingFrame.scrollFrame.ScrollBar:SetPoint("BOTTOMRIGHT", DisenchantingFrame.scrollFrame, "BOTTOMRIGHT", 0, 16)
    DisenchantingFrame.scrollFrame.content = CreateFrame("Frame", nil, DisenchantingFrame.scrollFrame)
    local content = DisenchantingFrame.scrollFrame.content
    content:SetPoint("TOPLEFT", DisenchantingFrame.scrollFrame, "TOPLEFT", 0, 0)
    content:SetSize(DisenchantingFrame.scrollFrame:GetWidth()-20, 100)
    DisenchantingFrame.scrollFrame:SetScrollChild(content)
    DisenchantingFrame.scrollFrame.ScrollBar:SetFrameLevel(content:GetFrameLevel()+100)
    local btnWidth = hideBtn:GetWidth() + itemNameBtn:GetWidth() + itemLevelBtn:GetWidth()
    local btnHeight = 16
    DisenchantingFrame.entries = setmetatable({}, {
        __index = function (t, v)
            local f = CreateFrame("Button", nil, content)
            f:SetSize(btnWidth, btnHeight)
            if v == 1 then
                f:SetPoint("TOPLEFT", content, "TOPLEFT", 3, -1)
            else
                f:SetPoint("TOPLEFT", t[v-1], "BOTTOMLEFT")
            end
            do
                local texture = f:CreateTexture()
                texture:SetColorTexture(0, 0, 0, 1)
                texture:SetAllPoints()
                f:SetNormalTexture(texture)
            end
            do
                local texture = f:CreateTexture()
                texture:SetColorTexture(0.36, 0.36, 0.38, 0.8)
                texture:SetAllPoints()
                f:SetHighlightTexture(texture)
            end
            f:SetScript("OnEnter", function(self)
                if not f.itemLink then return end
                local uiScale, x, y = UIParent:GetEffectiveScale(), GetCursorPosition()
                x, y = x/uiScale, y/uiScale
                local screenWidth = GetScreenWidth() / 2
                if x < screenWidth then
                    GameTooltipShow(self, "TOPLEFT", "TOPRIGHT")
                else
                    GameTooltipShow(self, "TOPRIGHT", "TOPLEFT")
                end
                GameTooltip:ClearLines()
                GameTooltip:SetHyperlink(f.itemLink)
                GameTooltip:Show()
                if _G["ShoppingTooltip1"] and _G["ShoppingTooltip1"]:IsShown() then
                    _G["ShoppingTooltip1"]:ClearAllPoints()
                    if x < screenWidth then
                        _G["ShoppingTooltip1"]:SetPoint("TOPLEFT", GameTooltip, "TOPRIGHT", 0, 0)
                    else
                        _G["ShoppingTooltip1"]:SetPoint("TOPRIGHT", GameTooltip, "TOPLEFT", 0, 0)
                    end
                end
                if _G["ShoppingTooltip2"] and _G["ShoppingTooltip2"]:IsShown() then
                    _G["ShoppingTooltip2"]:ClearAllPoints()
                    if x < screenWidth then
                        _G["ShoppingTooltip2"]:SetPoint("TOPLEFT", _G["ShoppingTooltip1"], "TOPRIGHT", 0, 0)
                    else
                        _G["ShoppingTooltip2"]:SetPoint("TOPRIGHT", _G["ShoppingTooltip1"], "TOPLEFT", 0, 0)
                    end
                end
            end)
            f:SetScript("OnLeave", function(self)
                GameTooltip:Hide()
            end)
            f.hideIcon = CreateFrame("Button", nil, f)
            f.hideIcon:SetSize(btnHeight, btnHeight)
            f.hideIcon:SetPoint("LEFT", f, "LEFT", 7, 0)
            f.hideIcon:SetNormalTexture("Interface\\AddOns\\" .. addonName .. "\\Images\\hide.png")
            f.hideIcon:SetHighlightTexture("Interface\\AddOns\\" .. addonName .. "\\Images\\hide.png")
            f.hideIcon:SetScript("OnEnter", function (self)
                GameTooltipShow(self, "RIGHT", "LEFT", -10, 0)
                GameTooltip:AddLine("左键：|cffffffff角色登出或加载UI前隐藏|r\nShift+左键：|cffffffff永久隐藏|r")
                GameTooltip:Show()
            end)
            f.hideIcon:SetScript("OnLeave", function (self)
                GameTooltip:Hide()
            end)
            f.hideIcon:SetScript("OnClick", function (self)
                if not f.itemLink then return end
                local itemId = tonumber(f.itemLink:match("item:(%d+):"))
                if not itemId then return end
                if IsShiftKeyDown() then
                    if not ZL.opt.disenchantingLgnoreList then ZL.opt.disenchantingLgnoreList = {} end
                    ZL.opt.disenchantingLgnoreList[tostring(itemId)] = f.itemLink
                    ZL.DisenchantingLgnoreFrame:Update()
                    ZL.Print("已永久忽略分解，可到左侧隐藏窗口恢复！", true)
                else
                    if not ZL.disenchantingLgnoreList then ZL.disenchantingLgnoreList = {} end
                    ZL.disenchantingLgnoreList[tostring(itemId)] = f.itemLink
                    ZL.Print("已临时忽略分解，重新加载UI后会显示！", true)
                end
                DisenchantingFrame:Update()
            end)
            f.itemIcon = f:CreateTexture(nil, "OVERLAY")
            f.itemIcon:SetSize(13, 13)
            f.itemIcon:SetPoint("LEFT", f.hideIcon, "RIGHT", 7, 0)

            f.itemName = f:CreateFontString(nil, "OVERLAY")
            f.itemName:SetPoint("LEFT", f.itemIcon, "RIGHT", 7, 0)
            f.itemName:SetWidth(itemNameBtn:GetWidth())
            f.itemName:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            f.itemName:SetWordWrap(false)
            f.itemName:SetJustifyH("LEFT")
            
            f.itemLevel = f:CreateFontString(nil, "OVERLAY")
            f.itemLevel:SetPoint("LEFT", f.itemName, "RIGHT", 0, 0)
            f.itemLevel:SetWidth(itemLevelBtn:GetWidth()-3)
            f.itemLevel:SetFont(GameFontNormal:GetFont(), 13, "OUTLINE")
            f.itemLevel:SetWordWrap(false)
            f.itemLevel:SetJustifyH("RIGHT")
            f.itemLevel:SetTextColor(0.95, 0.95, 0.95, 1)
            -- f.itemLevel:SetText(select(4, cGetItemInfo(itemId)))


            t[v] = f
            return f
        end
    })
    function DisenchantingFrame.UpdateMacro()
        local bag = DisenchantingFrame.bag
        local slot = DisenchantingFrame.slot
        local spellName, spellIcon, _
        if GetSpellInfo then
            spellName, _, spellIcon = GetSpellInfo(13262)
        else
            local info = C_Spell.GetSpellInfo(13262)
            spellName = info.name
            spellIcon = info.iconID
        end
        local macroName = "AAdes"
        local bodytext
        if bag and slot then
            bodytext = format("/click ZLDisenchantButton LeftButton 1;\n/cast %s;\n/use %d %d", spellName, bag, slot)
        else
            bodytext = ""
        end
        if GetMacroBody(macroName) then
            EditMacro(macroName, macroName, spellIcon, bodytext)
        else
            if GetNumMacros() >= MAX_ACCOUNT_MACROS then
                ZL.Print("|cffffffff" .. macroName .. "|r宏无法创建，因为你的宏数量已达上限。请先删除一个现有宏后再试。", true, true)
            else
                CreateMacro(macroName, spellIcon, bodytext)
            end
        end
        SetOverrideBindingMacro(DisenchantingFrame.disenchantingBtn, true, "MOUSEWHEELDOWN", macroName)
    end
    function DisenchantingFrame:Update()
        for _, f in ipairs(DisenchantingFrame.entries) do f:Hide() end
        disenchantingBtn:Disable()
        self.bag = nil
        self.slot = nil
        if ZL_CURRENT.auctionlist and #ZL_CURRENT.auctionlist > 0 then
            local index = 1
            local itemId
            for _, data in ipairs(ZL_CURRENT.auctionlist) do
                itemId = data.itemId
                if data.state == "failed" and data.bindType == 1 and data.spawnUID and ((not ZL.disenchantingLgnoreList) or (not ZL.disenchantingLgnoreList[tostring(itemId)]))
                and ((not ZL.opt.disenchantingLgnoreList) or (not ZL.opt.disenchantingLgnoreList[tostring(itemId)])) and (not ZL.NON_DISENCHANTABLE_ITEMS[tostring(itemId)]) and ZL.IsDisenchantAble(itemId) then
                    for _, value in pairs(data.spawnUID) do
                        if value.itemGUID and next(value.itemGUID) then
                            for key in pairs(value.itemGUID) do
                                --判断是否在背包
                                local bag, slot = ZL.FindItemInBag(key)
                                if bag then
                                    if index == 1 then
                                        DisenchantingFrame.bag = bag
                                        DisenchantingFrame.slot = slot
                                        C_Timer.After(0.3, function ()
                                            disenchantingBtn:Enable()
                                            disenchantingBtn:SetAttribute("macrotext", "/施放 分解\n/use " .. bag .. " " .. slot)
                                        end)
                                    end
                                    local f = DisenchantingFrame.entries[index]
                                    local itemlink = data.itemlink
                                    f.itemLink = itemlink
                                    f.itemIcon:SetTexture(cGetItemIcon(itemlink))
                                    f.itemName:SetText(itemlink)
                                    f.itemLevel:SetText(data.itemLevel)
                                    f:Show()
                                    index = index + 1
                                end
                            end
                        end
                    end
                end
            end
        end
        DisenchantingFrame.UpdateMacro()
    end
end

--创建不分解物品窗口
function ZL:CreateDisenchantingLgnoreFrame()
    ZL.DisenchantingLgnoreFrame = CreateFrame("Frame", nil, ZL.DisenchantingFrame, "BackdropTemplate")
    local DisenchantingLgnoreFrame = ZL.DisenchantingLgnoreFrame
    DisenchantingLgnoreFrame:SetPoint("TOPRIGHT", ZL.DisenchantingFrame, "TOPLEFT", 0, 2)
    DisenchantingLgnoreFrame:SetSize(200, 300)
    DisenchantingLgnoreFrame:SetBackdrop({
        bgFile = "Interface/ChatFrame/ChatFrameBackground",
        edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
        edgeSize = 16,
        insets = { left = 3, right = 3, top = 3, bottom = 3 }
    })
    DisenchantingLgnoreFrame:SetBackdropColor(0, 0, 0, 0.9)
    DisenchantingLgnoreFrame:SetBackdropBorderColor(0.9, 0.9, 0.9)
    DisenchantingLgnoreFrame:SetScript("OnShow", function (self)
        self:Update()
    end)
    DisenchantingLgnoreFrame.fontString = DisenchantingLgnoreFrame:CreateFontString(nil, "OVERLAY")
    DisenchantingLgnoreFrame.fontString:SetPoint("TOPLEFT", DisenchantingLgnoreFrame, "TOPLEFT", 10, -10)
    DisenchantingLgnoreFrame.fontString:SetWidth(DisenchantingLgnoreFrame:GetWidth() - 20)
    DisenchantingLgnoreFrame.fontString:SetFont(GameFontNormal:GetFont(), 14, "OUTLINE")
    DisenchantingLgnoreFrame.fontString:SetWordWrap(false)
    DisenchantingLgnoreFrame.fontString:SetJustifyH("LEFT")
    DisenchantingLgnoreFrame.fontString:SetText("右键：恢复显示")
    DisenchantingLgnoreFrame:Hide()
    --创建滚动条
    DisenchantingLgnoreFrame.scrollFrame = CreateFrame("ScrollFrame", nil, DisenchantingLgnoreFrame, "UIPanelScrollFrameTemplate")
    DisenchantingLgnoreFrame.scrollFrame:SetFrameLevel(DisenchantingLgnoreFrame:GetFrameLevel() + 1) -- 设置为比父框架高1级
    DisenchantingLgnoreFrame.scrollFrame:SetPoint("TOPLEFT", DisenchantingLgnoreFrame, "TOPLEFT", 5, -20 - DisenchantingLgnoreFrame.fontString:GetHeight())
    DisenchantingLgnoreFrame.scrollFrame:SetPoint("BOTTOMRIGHT", DisenchantingLgnoreFrame, "BOTTOMRIGHT", 0, 3)
    DisenchantingLgnoreFrame.scrollFrame:SetClipsChildren(true) --必须设置为true，scrollFrame所有的子元素才会被剪切
    DisenchantingLgnoreFrame.scrollFrame:SetScript("OnMouseWheel", ZL.ScrollFrame_OnMouseWheel) --重设滑动条鼠标滚轮事件
    
    --重设ScrollBar位置，放置到scrollFrame内，防止被剪切掉
    DisenchantingLgnoreFrame.scrollFrame.ScrollBar:ClearAllPoints()
    DisenchantingLgnoreFrame.scrollFrame.ScrollBar:SetPoint("TOPLEFT", DisenchantingLgnoreFrame.scrollFrame, "TOPRIGHT", -22, -17)
    DisenchantingLgnoreFrame.scrollFrame.ScrollBar:SetPoint("BOTTOMRIGHT", DisenchantingLgnoreFrame.scrollFrame, "BOTTOMRIGHT", -2, 17)
    DisenchantingLgnoreFrame.scrollFrame.content = CreateFrame("Frame", nil, DisenchantingLgnoreFrame.scrollFrame)
    local content = DisenchantingLgnoreFrame.scrollFrame.content
    content:SetPoint("TOPRIGHT", DisenchantingLgnoreFrame.scrollFrame, "TOPRIGHT", 0, 0)
    content:SetSize(DisenchantingLgnoreFrame.scrollFrame:GetWidth()-20, 100)
    DisenchantingLgnoreFrame.scrollFrame:SetScrollChild(content)
    DisenchantingLgnoreFrame.scrollFrame.ScrollBar:SetFrameLevel(content:GetFrameLevel()+100)
    local contentWidth = content:GetWidth()
    DisenchantingLgnoreFrame.entries = setmetatable({}, {
        __index = function (t, v)
            local f = CreateFrame("Button", nil, content)
            f:SetSize(contentWidth, 20)
            if v == 1 then
                f:SetPoint("TOPLEFT", content, "TOPLEFT", 0, 0)
            else
                f:SetPoint("TOPLEFT", t[v-1], "BOTTOMLEFT", 0, 0)
            end
            f:SetNormalFontObject("GameFontNormal")
            f:SetHighlightFontObject("GameFontHighlight")
            f:SetText(" ")
            local font = f:GetFontString()
            if font then
                font:SetPoint("LEFT", 5, 0)
                font:SetTextColor(1, 0.82, 0)
            end
            f:SetHighlightTexture([[Interface\QuestFrame\UI-QuestLogTitleHighlight]])
            f:SetScript("OnEnter", function (self)
                if not f.itemLink then return end
                local uiScale, x, y = UIParent:GetEffectiveScale(), GetCursorPosition()
                x, y = x/uiScale, y/uiScale
                local screenWidth = GetScreenWidth() / 2
                if x < screenWidth then
                    GameTooltipShow(self, "TOPLEFT", "TOPRIGHT")
                else
                    GameTooltipShow(self, "TOPRIGHT", "TOPLEFT")
                end
                GameTooltip:ClearLines()
                GameTooltip:SetHyperlink(f.itemLink)
                GameTooltip:Show()
                if _G["ShoppingTooltip1"] and _G["ShoppingTooltip1"]:IsShown() then
                    _G["ShoppingTooltip1"]:ClearAllPoints()
                    if x < screenWidth then
                        _G["ShoppingTooltip1"]:SetPoint("TOPLEFT", GameTooltip, "TOPRIGHT", 0, 0)
                    else
                        _G["ShoppingTooltip1"]:SetPoint("TOPRIGHT", GameTooltip, "TOPLEFT", 0, 0)
                    end
                end
                if _G["ShoppingTooltip2"] and _G["ShoppingTooltip2"]:IsShown() then
                    _G["ShoppingTooltip2"]:ClearAllPoints()
                    if x < screenWidth then
                        _G["ShoppingTooltip2"]:SetPoint("TOPLEFT", _G["ShoppingTooltip1"], "TOPRIGHT", 0, 0)
                    else
                        _G["ShoppingTooltip2"]:SetPoint("TOPRIGHT", _G["ShoppingTooltip1"], "TOPLEFT", 0, 0)
                    end
                end
            end)
            f:SetScript("OnLeave", function ()
                GameTooltip:Hide()
            end)
            f:RegisterForClicks("RightButtonUp")
            f:SetScript("OnClick", function (self)
                if f.itemId and ZL.opt.disenchantingLgnoreList then
                    ZL.opt.disenchantingLgnoreList[tostring(f.itemId)] = nil
                    ZL.DisenchantingFrame:Update()
                    DisenchantingLgnoreFrame:Update()
                end
            end)
            t[v] = f
            return f
        end
    })

    function DisenchantingLgnoreFrame:Update()
        for _, f in ipairs(DisenchantingLgnoreFrame.entries) do
            f:Hide()
        end
        local index = 1
        if ZL.opt.disenchantingLgnoreList and next(ZL.opt.disenchantingLgnoreList) then
            for itemId, itemLink in pairs(ZL.opt.disenchantingLgnoreList) do
                local f = DisenchantingLgnoreFrame.entries[index]
                f:SetText(itemLink)
                f.itemId = itemId
                f.itemLink = itemLink
                f:Show()
                index = index + 1
            end
        end
        content:SetHeight(index*20)
        DisenchantingLgnoreFrame:SetHeight(ZL.DisenchantingFrame:GetHeight()+5)
    end
end
