<template>
    <div class="toutiaoBatch">
        <div>
            <p class="breadcrumb">
                <a-breadcrumb style="display:block;width:100%">
                    <a-breadcrumb-item ><span class="muen" @click="goPlantForm()">策略</span></a-breadcrumb-item>
                    <!-- <a-breadcrumb-item>订单列表</a-breadcrumb-item> -->
                </a-breadcrumb>
            </p>
        </div>
        
        <div class="toolbox-automate-rules-create-content_title">
            <h3>广告策略</h3>
            <a-button type='primary' @click="goCreateStrategy" class="goCreateStrategy">新建策略</a-button>
        </div>
        
        <div class="topOptions">
            <div>
                <!-- <Treeselect :appId.sync="accountId" :multiple="false" request="2" reqUrl='/ctop/projectMember/getProjectAccountByUserId'  ref="treeSelect" style="margin-bottom:8px;width:600px " /> -->
                <a-select mode="multiple"
                    v-model="accountIds"
                    style="width: 600px"
                    placeholder="请选择账户"
                    :maxTagCount='1'
                    allowClear
                    show-search
                    option-filter-prop="children"
                    :filter-option="filterOption"
                    >
                    <a-select-option v-for="item in accountList" :key="item.account_id" :value='item.account_id'>
                    {{ item.auth_name+'_('+(item.project_name||"无所属项目")+')' }}
                    </a-select-option>
                </a-select>
            </div>
            <!-- <span class="OptinItem ">
                reqUrl='/ctop/userAllocation/getAccountIdListByUserId'
                <Treeselect :appId.sync="accountIds" :multiple="true" request="2,4" reqUrl='/ctop/userAllocation/getAccountIdsByUserId'  ref="treeSelect" style="margin-bottom:8px " />
                
            </span> -->
            <span class="OptinItem">
                <a-select  style="width: 180px" v-model="strategyState" @change="statusChange" placeholder="请选择策略状态">
                    <a-select-option :value='3' >
                        不限
                    </a-select-option>
                    <a-select-option :value="1" >
                        投放中
                    </a-select-option>
                    <a-select-option :value="2">
                        已关停
                    </a-select-option>
                </a-select>
            </span>

            <span class="OptinItem">
                <a-input-search placeholder="策略名称" v-model="strategyName" style="width: 280px"  />
            </span>
            <span class="OptinItem">
                <a-input-search placeholder="策略ID" v-model="strategyId" style="width: 280px"  />
            </span>
            <!-- <span class="OptinItem">
                <a-input-search placeholder="所属账户" v-model="accountId" style="width: 300px"  />
            </span> -->
            <span class="optionBtn">
                <a-button type='primary' @click="search" class="searchBtn">查询</a-button>
                <!-- <a-button type='default' @click="reset">重置</a-button> -->
            </span>
        </div>
        <div class="tableArea">
            <div class="tableOption">
                <span class="OptinItem">
                    <a-tooltip>
                        <template slot="title" >
                            这里可以批量启动、暂停、删除你的选择哦~
                        </template>
                        <!-- <a-button type="link" @click="changeSelectStatus">批量操作</a-button> -->
                        <span >批量操作：</span>
                    </a-tooltip>
                </span>
                <span class="OptinItem">
                    <a-select  style="width: 120px" @change="optChange" v-model="optValue" placeholder="请选择批量操作" :disabled='selectedRowKeys.length<=0'>
                        <a-select-option value="open" >
                            启动
                        </a-select-option>
                        <a-select-option value="pause">
                            暂停
                        </a-select-option>
                        <!-- <a-select-option value="delete">
                            删除
                        </a-select-option> -->
                    </a-select>
                </span>
                 <span class="OptinItem">
                    <a-popconfirm
                        title="确定要删除选择的内容吗？"
                        ok-text="删除"
                        cancel-text="取消"
                        @confirm="confirm"
                        @cancel="cancel"
                        v-if="optValue=='delete'"
                    >
                        <a-button type='primary' @click="isOkHandle" class="ok">确定</a-button>
                    </a-popconfirm>
                    <a-button type='primary' @click="isOkHandle" class="ok" v-else>确定</a-button>

                 </span>
                
            </div>
            <div class="table">
                <a-table
                    :columns="columns"
                    :data-source="data"
                    :rowSelection="{selectedRowKeys: selectedRowKeys,...rowSelection}"
                    bordered
                    :pagination="ipagination"
                    :loading="loading"
                    @change="sort"
                    :scroll="{'x':scrollX}"
                    
                >
                   
                    <span slot="switchStatus" slot-scope="text,record">
                        <a-spin :spinning="record.spin" size="small" >
                            <div class="spin-content">
                                <a-switch size="default" :checked=text  @change="switchChange(text,record)"/>
                            </div>
                        </a-spin>    
                        
                    </span>

                   
                   
                    <span slot="createImg" slot-scope="text,record">
                        
                        <a-popover placement="right">
                            <template slot="content">
                                
                                <video :src="record.videoId_dictText" style="width:250px" controls  ></video>
                            </template>
                            <template slot="title">
                           
                            </template>
                            
                            <img :src="record.imageId_dictText" alt="" style="width:100px">
                        </a-popover>
                        
                    </span>
                    
                    <span slot="status" slot-scope="text">
                        {{text |handlerStatus}}
                    </span>
                    <span slot="parentGroup" slot-scope="text">
                        <a href="javascript:;" >{{text}}</a>
                    </span>
                    <span slot="budget" slot-scope="text">
                        {{text || '不限'}}
                    </span>
                    <span slot="parentPlan" slot-scope="text">
                        <a href="javascript:;" >{{text}}</a>
                    </span>
                    <span slot="time" slot-scope="text,record">
                        {{record.startTime}}至{{record.endTime}}
                    </span>
                    <span slot="operator" slot-scope="text,record">
                        <a href="javascript:;"  @click="goPlanList(record)">详情</a>
                        <a-divider type="vertical" />
                        <a href="javascript:;"  @click="goAnalysis(record)">数据分析</a>
                    </span>
                    <span slot="scenes" slot-scope="text">
                        <span>{{text|scensFilter}}</span>
                    </span>
                    
                        <span slot="ctr" slot-scope="ctr">{{ ctr | toPercentage }}</span>
                        <span slot="cost" slot-scope="cost">{{ cost | decimalsHandle }}</span>
                        <span slot="clickMaterial" slot-scope="clickMaterial">{{ clickMaterial | formatCurrency }}</span>
                        <span slot="showMaterial" slot-scope="showMaterial">{{ showMaterial | formatCurrency }}</span>
                        <span slot="convertMaterial" slot-scope="convertMaterial">{{ convertMaterial | formatCurrency }}</span>
                        <span slot="play25FeedBreak" slot-scope="play25FeedBreak">{{ play25FeedBreak | formatCurrency }}</span>
                        <span slot="play50FeedBreak" slot-scope="play50FeedBreak">{{ play50FeedBreak | formatCurrency }}</span>
                        <span slot="play75FeedBreak" slot-scope="play75FeedBreak">{{ play75FeedBreak | formatCurrency }}</span>
                        <span slot="play100FeedBreak" slot-scope="play100FeedBreak">{{ play100FeedBreak | formatCurrency }}</span>
                        <span slot="nextDayOpen" slot-scope="nextDayOpen">{{ nextDayOpen | formatCurrency }}</span>
                        <span slot="downloadFinish" slot-scope="downloadFinish">{{ downloadFinish | formatCurrency }}</span>
                        <span slot="downloadStart" slot-scope="downloadStart">{{ downloadStart | formatCurrency }}</span>
                        <span slot="likeMaterial" slot-scope="likeMaterial">{{ likeMaterial | formatCurrency }}</span>
                        <span slot="shareMaterial" slot-scope="shareMaterial">{{ shareMaterial | formatCurrency }}</span>
                        <span slot="register" slot-scope="register">{{ register | formatCurrency }}</span>
                        <span slot="follow" slot-scope="follow">{{ follow | formatCurrency }}</span>
                        <span slot="formCount" slot-scope="formCount">{{ formCount | formatCurrency }}</span>
                        <span slot="formCountCost" slot-scope="formCountCost">{{ formCountCost | decimalsHandle }}</span>
                        <span slot="aClick" slot-scope="aClick">{{ aClick | formatCurrency }}</span>
                        <span slot="photoShow" slot-scope="photoShow">{{ photoShow | formatCurrency }}</span>
                        <span slot="photoClick" slot-scope="photoClick">{{ photoClick | formatCurrency }}</span>
                        <span slot="bClick" slot-scope="bClick">{{ bClick | formatCurrency }}</span>
                        <span slot="active" slot-scope="active">{{ active | formatCurrency }}</span>
                        <span slot="submit" slot-scope="submit">{{ submit | formatCurrency }}</span>
                        <span slot="nextDayOpen" slot-scope="nextDayOpen">{{ nextDayOpen | formatCurrency }}</span>
                        <span slot="eventCreditGrantLandingPage" slot-scope="eventCreditGrantLandingPage">{{ eventCreditGrantLandingPage | formatCurrency }}</span>
                        <span slot="submitCost" slot-scope="submitCost">{{ submitCost | decimalsHandle }}</span>
                        <span slot="eventCreditGrantLandingPageCost" slot-scope="eventCreditGrantLandingPageCost">{{ eventCreditGrantLandingPageCost | decimalsHandle }}</span>
                        <span slot="submitRate" slot-scope="submitRate">{{ submitRate | toPercentage }}</span>
                        <span slot="eventCreditGrantLandingPageRate" slot-scope="eventCreditGrantLandingPageRate">{{ eventCreditGrantLandingPageRate | toPercentage }}</span>
                        <span
                        slot="play25FeedBreakRate"
                        slot-scope="play25FeedBreakRate"
                        >{{ play25FeedBreakRate | toPercentage }}</span>
                        <span slot="playOverRate" slot-scope="playOverRate">{{ playOverRate | toPercentage }}</span>
                        <!-- 新加数据 -->

                        <span slot="convertRate" slot-scope="convertRate">{{ convertRate | toPercentage }}</span>
                        <span slot="nextDayOpenRate" slot-scope="nextDayOpenRate">{{ nextDayOpenRate | toPercentage }}</span>
                        <span slot="ctr" slot-scope="ctr">{{ ctr | toPercentage }}</span>
                        <span slot="cpc" slot-scope="cpc">{{ cpc | decimalsHandle }}</span>
                        <span slot="cpm" slot-scope="cpm">{{ cpm | decimalsHandle }}</span>
                        <span slot="activeRate" slot-scope="activeRate">{{ activeRate | toPercentage }}</span>
                        <span
                        slot="installFinishRate"
                        slot-scope="installFinishRate"
                        >{{ installFinishRate | toPercentage }}</span>
                        <span slot="validPlayRate" slot-scope="validPlayRate">{{ validPlayRate | toPercentage }}</span>
                        <span slot="activePayCost" slot-scope="activePayCost">{{ activePayCost | decimalsHandle }}</span>
                        <span slot="nextDayOpenCost" slot-scope="nextDayOpenCost">{{ nextDayOpenCost | decimalsHandle }}</span>
                        <span slot="validPlayCost" slot-scope="validPlayCost">{{ validPlayCost | decimalsHandle }}</span>
                        <span slot="activeCost" slot-scope="activeCost">{{ activeCost | decimalsHandle }}</span>
                        <span slot="nextDayOpenCost" slot-scope="nextDayOpenCost">{{ nextDayOpenCost | decimalsHandle }}</span>
                        <span
                        slot="gameAddictionCost"
                        slot-scope="gameAddictionCost"
                        >{{ gameAddictionCost | decimalsHandle }}</span>
                        <span
                        slot="downloadFinishCost"
                        slot-scope="downloadFinishCost"
                        >{{ downloadFinishCost | decimalsHandle }}</span>
                        <span
                        slot="downloadStartCost"
                        slot-scope="downloadStartCost"
                        >{{ downloadStartCost | decimalsHandle }}</span>
                        <span
                        slot="installFinishCost"
                        slot-scope="installFinishCost"
                        >{{ installFinishCost | decimalsHandle }}</span>
                        <span slot="convertCost" slot-scope="convertCost">{{ convertCost | decimalsHandle }}</span>

                        <!--  -->
                        <span
                        slot="downloadStartRate"
                        slot-scope="downloadStartRate"
                        >{{ downloadStartRate | toPercentage }}</span>
                        <span
                        slot="downloadFinishRate"
                        slot-scope="downloadFinishRate"
                        >{{ downloadFinishRate | toPercentage }}</span>
                        <span slot="activeRate" slot-scope="activeRate">{{ activeRate | toPercentage }}</span>
                        <span
                        slot="activeRegisterRate"
                        slot-scope="activeRegisterRate"
                        >{{ activeRegisterRate | toPercentage }}</span>
                        <span
                        slot="gameAddictionRate"
                        slot-scope="gameAddictionRate"
                        >{{ gameAddictionRate | toPercentage }}</span>
                        <span slot="nextDayOpenRate" slot-scope="nextDayOpenRate">{{ nextDayOpenRate | toPercentage }}</span>
                        <!-- <span slot="nextDayOpenRate" slot-scope="nextDayOpenRate">{{ nextDayOpenRate | toPercentage }}</span> -->

                </a-table>
            </div>
        </div>
        
       
              
    <!-- </a-spin> -->
    </div>
</template>

<script>
import moment from 'moment';
import { getAction, postAction, downFile, downFilePost } from '@/api/manage';
// import { JeecgListMixin } from '@/mixins/ipagination'
// import editableCell from './editableCell'
import Treeselect from '@/views/modules/Statistics/components/Treeselect.vue'
import qs from 'qs'
let typeValue='预算'


const strategyColumns = [
  {
    title: '开关',
    dataIndex: 'switchStatus',
    key: 'switchStatus',
    align: 'center',
    scopedSlots: { customRender: 'switchStatus' },
    width:80,
    fixed: 'left' ,
  },
  {
    title: '广告策略名称',
    dataIndex: 'strategyName',
    key: 'strategyName',
    align: 'center',
    scopedSlots: { customRender: 'strategyName' },
    width:150,
    fixed: 'left' ,
  },
  {
    title: '广告策略ID',
    dataIndex: 'id',
    key: 'id',
    align: 'center',
    scopedSlots: { customRender: 'id' },
    width:110,
    fixed: 'left' ,
  },
  
  {
    title: '操作',
    dataIndex: 'operator',
    key: 'operator',
    align: 'center',
    scopedSlots: { customRender: 'operator' },
    width:150,
    fixed: 'left' ,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    key: 'createTime',
    align: 'center',
    scopedSlots: { customRender: 'createTime' },
        
  },
  
  {
    title: '所属账户名称',
    dataIndex: 'authName',
    key: 'authName',
    align: 'center',
    scopedSlots: { customRender: 'authName' }, 
    width:200  
  },
  {
    title: '所属账户ID',
    dataIndex: 'accountId',
    key: 'accountId',
    align: 'center',
    scopedSlots: { customRender: 'accountId' },   
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    align: 'center',
    scopedSlots: { customRender: 'status' },    
  },
  {
    title: '创建场景',
    dataIndex: 'scenes',
    key: 'scenes',
    align: 'center',
    scopedSlots: { customRender: 'scenes' },   
  },
  {
    title: '策略预算',
    dataIndex: 'budget',
    key: 'budget',
    align: 'center',
    scopedSlots: { customRender: 'budget' },   
  },

];

const publicColumns = [
    {
          title: '消耗(元)',
          dataIndex: 'cost',
          width:150,
          tip: '广告在投放期间的花费总额',
          align: 'center',
          scopedSlots: { customRender: 'cost' },
        //   sorter: () => {}
        },
        {
          title: '封面曝光数',
          dataIndex: 'photoShow',
          tip: '广告在瀑布流被观看次数',
          align: 'center',       
          scopedSlots: { customRender: 'photoShow' },
        //   sorter:() => {}
        },
        {
          title: '封面点击数',
          dataIndex: 'photoClick',
          tip: '用户点击封面进入视频播放页的次数(数据会进行反作弊去重)',
          align: 'center',
        
          scopedSlots: { customRender: 'photoClick' },
        //   sorter: () => {}
        },
        {
          title: '素材曝光数',
          dataIndex: 'aclick',
          tip: '用户进入视频播放页观看的次数(数据会进行反作弊去重)',
          align: 'center',
       
          scopedSlots: { customRender: 'aClick' },
        //   sorter:() => {}
        },
        {
          title: '行为数',
          dataIndex: 'bclick',
          tip: '用户在视频播放页单击转化按钮的次数/展示数*100%',
          align: 'center',
        
          scopedSlots: { customRender: 'bClick' },
        //   sorter:() => {}
        },
        {
          title: '封面点击率',
          dataIndex: 'clickRate',
          tip: '封面点击数占封面展示数百分比',
          align: 'center',    
          scopedSlots: { customRender: 'clickRate' },
        //   sorter:() => {}
        },
        {
          title: '行为率',
          dataIndex: 'bClickRate',
          tip: '行为数占素材曝光数百分比',
          align: 'center',    
          scopedSlots: { customRender: 'bClickRate' },
        //   sorter:() => {}
        },
        {
          title: '平均千次封面曝光花费（元）',
          dataIndex: 'cpm',
          tip: '花费/封面曝光数*1000',
          align: 'center',    
          scopedSlots: { customRender: 'cpm' },
        //   sorter:() => {}
        },
        {
          title: '平均封面点击单价（元）',
          dataIndex: 'cpc',
          tip: '花费／封面点击数',
          align: 'center',    
          scopedSlots: { customRender: 'cpc' },
        //   sorter:() => {}
        },
        
        {
          title: '激活数',
          dataIndex: 'active',
          tip: '广告主回传的应用激活次数',
          align: 'center',    
          scopedSlots: { customRender: 'active' },
        //   sorter:() => {}
        },
        {
          title: '激活单价',
          dataIndex: 'activeCost',
          tip: '花费/激活数',
          align: 'center',    
          scopedSlots: { customRender: 'activeCost' },
        //   sorter:() => {}
        },
        {
          title: '下载完成激活率',
          dataIndex: 'activeRate',
          tip: '激活数/安卓下载完成数',
          align: 'center',    
          scopedSlots: { customRender: 'activeRate' },
        //   sorter:() => {}
        },
        {
          title: '注册数',
          dataIndex: 'register',
          tip: '付费金额/当日消耗',
          align: 'center',    
          scopedSlots: { customRender: 'register' },
        //   sorter:() => {}
        },
        {
          title: '注册成本',
          dataIndex: 'activeRegisterCost',
          tip: '当日消耗/当日回传注册数',
          align: 'center',    
          scopedSlots: { customRender: 'activeRegisterCost' },
        //   sorter:() => {}
        },
        {
          title: '注册率',
          dataIndex: 'activeRegisterRate',
          tip: '当日回传注册数/当日激活数',
          align: 'center',    
          scopedSlots: { customRender: 'activeRegisterRate' },
        //   sorter:() => {}
        },
        {
            title: '次留数',
            dataIndex: 'nextDayOpen',
            tip: '前一日激活用户在次日继续访问的PV',
            align: 'center',    
            scopedSlots: { customRender: 'nextDayOpen' },
            // sorter:() => {}
        },
        
        {
            title: '次留率',
            dataIndex: 'nextDayOpenRate',
            tip: '前一日激活用户在次日继续访问的PV/前一日激活数',
            align: 'center',    
            scopedSlots: { customRender: 'nextDayOpenRate' },
            // sorter:() => {}
        },
]

export default {
    name:'strategy-list',
    components: {
        // editableCell,
        Treeselect,
    },
    // mixins: [JeecgListMixin],
    data() {
        return {
            accountId:[],
            accountList:[],
            strategyState:undefined,
            strategyName:'',
            strategyId:undefined,
            accountIds:[],
            scrollX:3500,
            ipagination: {
                current: 1,
                pageSize: 10,
                //   pageSizeOptions: ['10', '20', '30'],
                showTotal: (total, range) => {
                    return range[0] + "-" + range[1] + " 共" + total + "条"
                },
                showQuickJumper: true,
                showSizeChanger:true,
                pageSizeOptions: ['10', '30', '50'],
                total: 0,
                onChange: (current, pageSize) => {
                    // 切换分页时的回调，
                    // 当在页面定义change事件时，切记要把此处的事件清除，因为这两个事件重叠了，可能到时候会导致一些莫名的bug
                    this.ipagination.current = current;
                    this.ipagination.pageSize= pageSize;
                }
            },
           
            spinning:false,
            moment,
           
            optionId:'',//input输入的id或关键词
          
           
            selectDisable:true,
            optValue:undefined,//操作设置的值 删除 暂停 开启
            visible: false,//出价里的弹出框

            //主页的表格
            data:[],
            columns:[...strategyColumns,...publicColumns],
            selectedRowKeys:[],
            selectedRows:[],
            loading:false,
            editID:0,

            url: {               
                planList: "/ai/list/pageCampaign",
                groupList:'/ai/list/pageUnit',
                strategyList:'/ai/list/pageStrategy'
            },


            xiugaiData:[],//存分别修改时候的数组
        }
    },
    computed: {
        rowSelection(){
            return {
                onChange: (selectedRowKeys, selectedRows) => {
                    // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
                    this.selectedRowKeys=selectedRowKeys;
                    this.selectedRows=selectedRows;
                },
                onSelect: (record, selected, selectedRows) => {
                    // console.log(record, selected, selectedRows);
                    this.modifyTableData=selectedRows;

                    this.selectedRows=selectedRows;
                },
                onSelectAll: (selected, selectedRows, changeRows) => {
                    // console.log(selected, selectedRows, changeRows);
                    this.modifyTableData=selectedRows
                    this.selectedRows=selectedRows;
                },
            }

        },
    },
    methods: {
        goCreateStrategy(){
            this.$router.push('/autoLaunch/newStrategy')
        },
        goPlanList(record){
            console.log(record)
            this.$parent.currentStrategyId=record.id;
            this.$parent.currentTabComponent='planList'
        },
        goAnalysis(record){
            console.log(record)
            localStorage.setItem('currentStrategy',JSON.stringify(record))
            // this.$router.push('/autoLaunch/autoLaunchReport')
            this.$router.push('/autoLaunch/autoReportIndex')
        },
        filterOption(input, option) {
            return (
                option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
            );
        },
        //状态改变
        statusChange(value){
            console.log(value);

        },
        
        //查询按钮事件
        search(){
            this.ipagination.current=1;
            this.getStrategyList()            
        },
        //点击分页
        sort(pagination, filters, sorter, { currentDataSource }){
            console.log(pagination)
            this.ipagination.current=pagination.current;

            this.ipagination.pageSize=pagination.pageSize;
            this.getStrategyList()
        },
        
        //状态改变
        switchChange(text,record){
            // this.spinning=true;
            console.log(text,record)
            record.spin=true;
            
            let ids=record.id;
            let state=text?'2':'1';
            postAction('/kuaishouStrategy/edit',{
                ids:[record.id],
                state
            }).then((res)=>{
                
                    record.spin=false;
                if(res.success){
                    this.getStrategyList()
                    this.$message.success(res.message)
                }else{
                    this.$message.error(res.message)
                }
            })
           

        },


        //改变批量操作的按钮
        changeSelectStatus(){
            this.selectDisable=false;
        },
        //批量操作下的启动 删除 暂停
        optChange(value){
            // console.log(value)
            this.optValue=value;
        },
        
        //批量操作的确定按钮
        isOkHandle(){
            console.log(this.optValue,this.selectedRowKeys)
            if(this.optValue&&this.selectedRowKeys.length>0){
                // this.selectedRows.forEach(item=>{
                //     item.spin=true;
                // })
                let params   ={}
                if(this.optValue=='pause'){   
                    this.loading=true;                  
                       
                        // if(this.selectedRowKeys.length>0){
                        //     this.selectedRows.forEach((item)=>{
                        //         item.optStatus='AD_STATUS_DISABLE'
                        //     })
                        // }  
                        params['ids']= this.selectedRowKeys
                        params.state='2'       
                        this.batchEditHttp(params)
                }else if(this.optValue=='open'){
                    this.loading=true;
                   
                        // if(this.selectedRowKeys.length>0){
                        //     this.selectedRows.forEach((item)=>{
                        //         item.optStatus='AD_STATUS_ENABLE'
                        //     })
                        // }
                        params['ids']= this.selectedRowKeys
                        params.state='1'    
                        this.batchEditHttp(params)
                    
                }
         
            }
            
        },
        //确定删除
        confirm(e) {
            // console.log(e);
                this.loading=true;
                if(this.optValue=='delete'){
                    
                   
                        // if(this.selectedRowKeys.length>0){
                        //     this.selectedRows.forEach((item)=>{
                        //         item.optStatus='AD_STATUS_DELETE'
                        //     })
                        // }
                        this.batchEditHttp(this.selectedRows)
                        this.$message.success('删除成功');
                   

                }



        },
        
        batchEditHttp(params){
            postAction(`/kuaishouStrategy/edit`,params).then((res)=>{
                // console.log(res);
                this.optValue=undefined;
                if(res.success){
                    
                    this.getStrategyList()
                    // params.spin=false;
                    // params.forEach(item=>{
                    //     item.spin=false;
                    // })
                    this.optValue=undefined;
                    this.selectedRowKeys=[];
                    this.$message.success(res.message)
                }else{
                    // params.spin=false;
                    // params.forEach(item=>{
                    //     item.spin=false;
                    // })
                    this.loading=false;
                    this.getStrategyList()
                    this.$message.error(res.message)
                }
            })
        },
        


        getStrategyList(){
            this.loading = true
            console.log(this.accountId)
            postAction(this.url.strategyList,{
                strategyId:this.strategyId==undefined?null:this.strategyId,
                strategyName:this.strategyName,
                strategyState:this.strategyState==3?null:this.strategyState,
                accountIds:this.accountIds,
                pageNo:this.ipagination.current,
                pageSize:this.ipagination.pageSize
            }).then((res)=>{
                this.data=[]
                console.log(res)
                this.loading = false
                if(res.success){

                    this.ipagination.total = res.result.total
                    
                    res.result.list.forEach((item)=>{
                        item.key=item.id
                    })

                    this.data = res.result.list.map(item=>{

                        return {
                            ...item,
                            spin:false,
                            switchStatus:item.strategyState=='1'?true:false,
                        }
                    });
                    // console.log(this.data)
                    this.selectedRowKeys=[];
                }
            })
        },
      
        getAccountList(){
            let userInfo=localStorage.getItem('pro__Login_Userinfo');
            let userId=''
            if(userInfo){
                userId=JSON.parse(userInfo).value.id
            }
            getAction('/ctop/userAllocation/getAccountIdsByUserId',{
                userId,
            }).then(res=>{
                console.log(res)
                if(res.success){
                    this.accountList=res.result
                }
            })
        }
    },
    mounted() {
        this.getAccountList()
        this.getStrategyList()
    },
    
    activated() {
        this.getStrategyList()
    },
    beforeDestroy() {

    },
    filters: {
        toPercentage(val) {
            if(val){
                if(typeof val != 'string'){
                    return (val * 100).toFixed(2) + '%'
                }else{
                    return val
                }
            }else if(typeof val =='string'){
                    return val
                }
            else{
                return 0
            }
        },
        //保留两位小数并且变成货币格式
        decimalsHandle(val){

            if(val && typeof val !='string'){
                if(val>=0){
                    val=parseFloat(val).toFixed(2);
                    let numberStr = val.toString()
                    let str = numberStr.split('.')

                    let str0=str[0].split('').reverse();
                    for (let i = 0; i < str0.length; i++) {
                        if ((i + 1) % 4 === 0) {
                            str0.splice(i, 0, ',')
                        }
                    }
                    str0.reverse()
                    let handleResult = ''
                    for (let j = 0; j < str0.length; j++) {
                        handleResult += str0[j]
                    }

                    return handleResult+'.'+str[1]
                }else{
                    val=parseFloat(val).toFixed(2);
                    let numberStr = val.toString()
                    let str = numberStr.split('.')

                    let str0=str[0].substr(1).split('').reverse();
                    for (let i = 0; i < str0.length; i++) {
                        if ((i + 1) % 4 === 0) {
                            str0.splice(i, 0, ',')
                        }
                    }
                    str0.reverse()
                    let handleResult = ''
                    for (let j = 0; j < str0.length; j++) {
                        handleResult += str0[j]
                    }

                    return '-'+handleResult+'.'+str[1]
                }

            }else if(typeof val =='string'){
                return val
            }
            else{
                return 0
            }
        },
        //变成货币格式
        formatCurrency(val){
            if((val||val==0)&& typeof val !='string'){
                let numberStr = val.toString()
                let str = numberStr.split('').reverse()
                for (let i = 0; i < str.length; i++) {
                    if ((i + 1) % 4 === 0) {
                    str.splice(i, 0, ',')
                    }
                }
                str.reverse()
                let handleResult = ''
                for (let j = 0; j < str.length; j++) {
                    handleResult += str[j]
                }
                return handleResult
            }else if(typeof val =='string'){
                    return val
            }
            else{
                return '-'
            }

        },
        scensFilter(val){
            let str='';
            switch (val) {
                case '1':
                     str='素材+出价'
                    break;
                case '2':
                     str='素材+定向'
                    break;
                case '3':
                     str='时间+出价'
                    break;
            
                default:
                    break;
            }
            return str
        },
        handlerStatus(val){
            let str=''
            if(val){
                switch (val) {
                    case 1:
                        str='投放中'
                        break;
                    case 2:
                        str='已暂停'
                        break;
                    // case 3:
                    //     str='已删除'
                    //     break;
                    // case 3:
                    //     str='已删除'
                    //     break;
                    // case 3:
                    //     str='已删除'
                    //     break;
                
                    default:
                        break;
                }
                return str
            }else{
                return '-'
            }
        }
    }
}
</script>
<style lang="scss">
    #closeIcon{
         color: #0E74D2;
    }
    .toutiaoBatch{
        .ant-tag .anticon-close {      
            color: #1890ff;        
        }
        .ant-tag .anticon-close:hover{      
            color: rgba(0, 0, 0, 0.85);    
        }

    }
    
    .ant-tooltip-inner,.ant-tooltip-arrow::before{
        background-color: #fff;
        color: #333;
    }
    #batchModal{
        .rules,.totalPrice{
            font-weight: 600;
        }

        .selectePlan{
            font-size: 14px;
            font-weight: 700;
            color: #333;
            padding: 20px 0;
        }
        .totalPrice{
            margin-left: 20px;
        }
        .modifyTable{
            margin-top: 20px;
            width: 100%;
            height: 400px;
            overflow: auto;
            font-weight: 600;
        }
    }
    #copyModal{
        .ant-modal-header{
            text-align: center;
        }
        .copyTip{
            font-size: 12px;
            color: #999;
        }
        .copyName{
            width: 118px;
            display: inline-block;
            text-align: right;
            .copyKeyStart{
                color: red;
            }
        }
        // font-weight: 600;
    }
</style>
<style lang="scss" scoped>
.toutiaoBatch{
    .breadcrumb{
            height: 22px;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #000000;
            line-height: 22px;
        }
    background-color: #fff;
    padding: 10px 20px;
    position: relative;
    width: 100%;
    .OptinItem{
        display: inline-block;
        margin-right: 15px;
        margin-top: 15px;
        .ok{
            margin-right: 15px;
        }
    }
    .OptinItem:first-child{
        margin-right: 10px;
    }
    .topOptions{
        padding: 15px 0;
        .topOpt{
            width: 100%;
            margin-bottom: 10px;
        }
    }
    .optionBtn{
        // display: inline-block;
        float: right;
        // .searchBtn{
            // margin-right: 10px;
        // }
    }
    .tableArea{
        .tableOption{
            padding: 20px 0;
        }
    }
    .toolbox-automate-rules-create-content_title {
        background-color: #fff;
        display: flex;
        flex-flow: row nowrap;
        justify-content: flex-start;
        align-items: center;
        margin-bottom: 28px;
        position: relative;
        h3 {
            font-size: 22px;
            margin: 0;
            font-weight: 400;
            height: 30px;
            line-height: 30px;
        }
        .goCreateStrategy{
            position: absolute;
            right: 0;
            top: 4px;
        }
    }

}

</style>