<template>
  <div class="app-container">
    <div style="margin-bottom:10px">
      <el-button type="success" @click="addBtn">新增</el-button>
      <el-button type="info" @click="goSearchLogs">日志</el-button>
    </div>
    <!--搜索-->
    <el-form ref="form" class="mt_15" inline size="small">
      <el-form-item label="任务名称">
        <el-input v-model.trim="searchParm.jobName" clearable placeholder="任务名称" />
      </el-form-item>
      <el-date-picker
        v-model.trim="searchTime"
        type="daterange"
        range-separator=":"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        style="width:270px"
      />
      <el-form-item label="状态">
        <el-select v-model.trim="searchParm.isPause" placeholder="请选择">
          <el-option
            v-for="item in isPauseList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="goSearchByCondition">搜索</el-button>
        <el-button type="warning" @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <!--表格渲染-->
    <el-table
      ref="table"
      border
      size="small"
      :data="list"
      :header-cell-style="{textAlign:'center'}"
      :cell-style="{textAlign:'center'}"
    >
      <el-table-column label="序号" type="index" width="50" />
      <el-table-column label="任务ID" prop="jobId" />
      <el-table-column label="任务名称" prop="jobName" />
      <el-table-column label="SpringBean名称" prop="beanName" />
      <el-table-column label="方法名称" prop="methodName" />
      <el-table-column label="参数" prop="params">
        <template slot-scope="scope">
          <el-button type="text" @click="showParams(scope.row)">查看参数</el-button>
        </template>
      </el-table-column>
      <el-table-column label="cron表达式" prop="cronExpression" />
      <el-table-column label="运行状态" prop="isPause">
        <template slot-scope="scope">{{ scope.row.isPause | getStatus }}</template>
      </el-table-column>
      <el-table-column label="描述" prop="description" />
      <el-table-column label="创建时间" prop="createTime" />
      <el-table-column label="操作" width="310">
        <template slot-scope="scope">
          <!-- <el-button type="info" @click="modifyStatus(scope.row.jobId)">恢复</el-button> -->
          <el-button
            type="info"
            @click="modifyStatus(scope.row.jobId)"
          >{{ scope.row.isPause ?'恢复':'暂停' }}</el-button>
          <el-button type="primary" @click="executionById(scope.row.jobId)">执行</el-button>
          <el-button type="warning" @click="editById(scope.row)">修改</el-button>
          <el-button type="danger" @click="delById(scope.row.jobId)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--分页-->
    <div class="mt_15">
      <el-pagination
        :current-page="searchParm.page"
        :page-sizes="[10, 20, 30, 40, 50]"
        :page-size="searchParm.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>

    <!--新增弹窗-->
    <el-dialog :visible.sync="dialogAddVisible" :title="dialogAddTitle" center width="45%">
      <div class="dialog-content">
        <el-form ref="addParm" size="small" :model="addParm" :rules="rules" label-width="130px">
          <el-form-item label="任务名称" prop="jobName">
            <el-input v-model.trim="addParm.jobName" clearable />
          </el-form-item>
          <el-form-item label="SpringBean名称" hidden prop="beanName">
            <el-input v-model.trim="editParm.beanName" clearable />
          </el-form-item>
          <el-form-item label="方法名称" hidden prop="methodName">
            <el-input v-model.trim="editParm.methodName" clearable />
          </el-form-item>
          <el-form-item label="描述" prop="description">
            <el-input v-model.trim="addParm.description" clearable />
          </el-form-item>
          <el-form-item label="cron表达式" prop="cronExpression">
            <el-input v-model.trim="addParm.cronExpression" clearable />
          </el-form-item>
          <el-form-item label="子任务ID" prop="subTask">
            <el-input v-model.trim="addParm.subTask" clearable />
          </el-form-item>
          <el-form-item label="负责人" prop="personInCharge">
            <el-input v-model.trim="addParm.personInCharge" clearable />
          </el-form-item>
          <el-form-item label="报警邮箱" prop="email">
            <el-input v-model.trim="addParm.email" clearable />
          </el-form-item>
          <el-form-item label="失败后暂停" prop="pauseAfterFailure">
            <el-select v-model.trim="addParm.pauseAfterFailure" placeholder="请选择">
              <el-option
                v-for="item in pauseAfterFailureList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>`
          </el-form-item>
          <el-form-item label="运行状态" prop="isPause">
            <el-select v-model.trim="addParm.isPause" placeholder="请选择">
              <el-option
                v-for="item in isPauseList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="设备名称" prop="rebotName">
            <el-input v-model.trim="addParm.rebotName" disabled="true" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchRebot"
            >请选择设备</el-button>
          </el-form-item>
          <el-form-item label="应用名称" prop="applyId">
            <el-select v-model.trim="addParm.applyId" placeholder="请选择" @change="applyClick">
              <el-option
                v-for="item in applys"
                :key="item.name"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <!-- 先选择应用 后才能选择这个  根据应用调用不同的对应的 请求参数 分页查询 -->
          <el-form-item label="脚本参数" prop="paramsType">
            <el-radio-group v-model.trim="addParm.paramsType" @change="changeCheckRange">
              <el-radio :label="'1'">自定义输入</el-radio>
              <el-radio v-if="addParm.applyId==2" :label="'2'">速卖通-刷单</el-radio>
              <el-radio v-if="addParm.applyId==3" :label="'3'">速卖通-刷补</el-radio>
              <el-radio v-if="addParm.applyId==4" :label="'4'">速卖通-好评</el-radio>
              <el-radio v-if="addParm.applyId==5" :label="'5'">速卖通-收藏</el-radio>
              <el-radio v-if="addParm.applyId==6" :label="'6'">敦煌-加购</el-radio>
              <el-radio v-if="addParm.applyId==7" :label="'7'">敦煌-好评</el-radio>
              <el-radio v-if="addParm.applyId==8" :label="'8'">敦煌-抓单</el-radio>
            </el-radio-group>
          </el-form-item>

          <el-form-item v-if="labelVal === '1'" label="自定义参数">
            <div id="app">
              <el-form ref="baseForm" class="base-form" :model="baseForm">
                <el-table
                  ref="table-input"
                  class="table"
                  highlight-current-row
                  :data="baseForm.demoList"
                  @row-click="selectItem"
                >
                  <el-table-column label="参数名称">
                    <template slot-scope="scope">
                      <el-form-item :prop="'demoList.'+scope.$index+'.name'" class="all">
                        <el-input v-model.trim="scope.row.name" placeholder="请输入" :disabled="true" />
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="参数值">
                    <template slot-scope="scope">
                      <el-form-item :prop="'demoList.'+scope.$index+'.value'" class="all">
                        <el-input v-model.trim="scope.row.value" placeholder="请输入" />
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="参数类型">
                    <template slot-scope="scope">
                      <el-form-item :prop="'demoList.'+scope.$index+'.type'" class="all">
                        <el-input v-model.trim="scope.row.type" placeholder="请输入" :disabled="true" />
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <!-- <el-table-column prop label="操作">
                    <template>
                      <div class="flex-c-a">
                        <el-button type="primary" @click="addLine()">增加</el-button>
                        <el-button type="danger">删除</el-button>
                      </div>
                    </template>
                  </el-table-column>-->
                </el-table>
              </el-form>
            </div>
          </el-form-item>

          <el-form-item v-if="labelVal === '2'" label="速卖通-刷单">
            <el-input v-model.trim="item" disabled="true" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchClickFarm"
            >选择刷单信息</el-button>
          </el-form-item>

          <el-form-item v-if="labelVal === '3'" label="速卖通-刷补">
            <el-input v-model.trim="item" disabled="true" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchClickFarmSupplyMent"
            >选择刷单信息</el-button>
          </el-form-item>

          <el-form-item v-if="labelVal === '4'" label="速卖通-好评">
            <el-input v-model.trim="item" disabled="true" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchWellReceived"
            >选择订单信息</el-button>
          </el-form-item>

          <el-form-item v-if="labelVal === '5'" label="速卖通-收藏">
            <el-input v-model.trim="item" disabled="true" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchBrowse"
            >选择收藏信息</el-button>
          </el-form-item>

          <el-form-item v-if="labelVal === '6'" label="敦煌-加购">
            <el-input v-model.trim="item" disabled="true" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="dhGoSearchCarFarm"
            >选择刷单信息</el-button>
          </el-form-item>

          <el-form-item v-if="labelVal === '7'" label="敦煌-好评">
            <el-input v-model.trim="item" disabled="true" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="dhGoSearchWellReceived"
            >选择订单信息</el-button>
          </el-form-item>

          <el-form-item v-if="labelVal === '8'" label="敦煌-抓单">
            <el-input v-model.trim="item" disabled="true" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="dhGoSearchClickFarmOrder"
            >选择刷单信息</el-button>
          </el-form-item>

        </el-form>
      </div>
      <span slot="footer">
        <el-button type="info" @click="sureAddCancle('addParm')">取消</el-button>
        <el-button type="primary" @click="sureAdd('addParm')">确认</el-button>
      </span>
    </el-dialog>

    <!--修改弹窗-->
    <el-dialog :visible.sync="dialogEditVisible" :title="dialogEditTitle" center width="45%">
      <div class="dialog-content">
        <el-form ref="editParm" size="small" :model="editParm" :rules="rules" label-width="130px">
          <el-form-item label="任务名称" prop="jobName">
            <el-input v-model.trim="editParm.jobName" clearable />
          </el-form-item>
          <el-form-item label="描述" prop="description">
            <el-input v-model.trim="editParm.description" clearable />
          </el-form-item>
          <el-form-item label="SpringBean名称" hidden prop="beanName">
            <el-input v-model.trim="editParm.beanName" clearable />
          </el-form-item>
          <el-form-item label="方法名称" hidden prop="methodName">
            <el-input v-model.trim="editParm.methodName" hidden clearable />
          </el-form-item>
          <el-form-item label="cron表达式" prop="cronExpression">
            <el-input v-model.trim="editParm.cronExpression" clearable />
          </el-form-item>
          <el-form-item label="子任务ID" prop="subTask">
            <el-input v-model.trim="editParm.subTask" clearable />
          </el-form-item>
          <el-form-item label="负责人" prop="personInCharge">
            <el-input v-model.trim="editParm.personInCharge" clearable />
          </el-form-item>
          <el-form-item label="报警邮箱" prop="email">
            <el-input v-model.trim="editParm.email" clearable />
          </el-form-item>
          <el-form-item label="失败后暂停" prop="pauseAfterFailure">
            <el-select v-model.trim="editParm.pauseAfterFailure" placeholder="请选择">
              <el-option
                v-for="item in pauseAfterFailureList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>`
          </el-form-item>
          <el-form-item label="运行状态" prop="isPause">
            <el-select v-model.trim="editParm.isPause" placeholder="请选择">
              <el-option
                v-for="item in isPauseList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="设备名称" prop="rebotName">
            <el-input v-model.trim="editParm.rebotName" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchRebot"
            >请选择设备</el-button>
          </el-form-item>
          <el-form-item label="应用名称" prop="applyId">
            <el-select v-model.trim="editParm.applyId" placeholder="请选择" @change="applyClick">
              <el-option
                v-for="item in applys"
                :key="item.name"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="脚本参数" prop="paramsType">
            <el-radio-group v-model.trim="editParm.paramsType" @change="changeCheckRange">
              <el-radio :label="1">自定义输入</el-radio>
              <el-radio v-if="editParm.applyId==2" :label="2">速卖通-刷单</el-radio>
              <el-radio v-if="editParm.applyId==3" :label="3">速卖通-刷补</el-radio>
              <el-radio v-if="editParm.applyId==4" :label="4">速卖通-好评</el-radio>
              <el-radio v-if="editParm.applyId==5" :label="5">速卖通-收藏</el-radio>
              <el-radio v-if="editParm.applyId==6" :label="6">敦煌-加购</el-radio>
              <el-radio v-if="editParm.applyId==7" :label="7">敦煌-好评</el-radio>
              <el-radio v-if="editParm.applyId==8" :label="8">敦煌-抓单</el-radio>
            </el-radio-group>
          </el-form-item>

          <el-form-item v-if="editParm.paramsType == 1" label="刷单信息">
            <div id="app">
              <el-form ref="baseForm" class="base-form" :model="baseForm">
                <el-table
                  ref="table-input"
                  class="table"
                  highlight-current-row
                  :data="baseForm.demoList"
                  @row-click="selectItem"
                >
                  <el-table-column label="参数名称">
                    <template slot-scope="scope">
                      <el-form-item :prop="'demoList.'+scope.$index+'.name'" class="all">
                        <el-input v-model.trim="scope.row.name" placeholder="请输入" :disabled="true" />
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="参数值">
                    <template slot-scope="scope">
                      <el-form-item :prop="'demoList.'+scope.$index+'.value'" class="all">
                        <el-input v-model.trim="scope.row.value" placeholder="请输入" />
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="参数类型">
                    <template slot-scope="scope">
                      <el-form-item :prop="'demoList.'+scope.$index+'.type'" class="all">
                        <el-input v-model.trim="scope.row.type" placeholder="请输入" :disabled="true" />
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <!-- <el-table-column prop label="操作">
                    <template>
                      <div class="flex-c-a">
                        <el-button type="primary" @click="addLine()">增加</el-button>
                        <el-button type="danger">删除</el-button>
                      </div>
                    </template>
                  </el-table-column>-->
                </el-table>
              </el-form>
            </div>
          </el-form-item>
          <el-form-item v-if="editParm.paramsType == 2" label="刷单信息">
            <el-input v-model.trim="item" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchClickFarm"
            >选择刷单信息</el-button>
          </el-form-item>
          <el-form-item v-if="editParm.paramsType === 3" label="刷单补录信息">
            <el-input v-model.trim="item" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchClickFarmSupplyMent"
            >选择刷单信息</el-button>
          </el-form-item>

          <el-form-item v-if="editParm.paramsType === 4" label="订单信息">
            <el-input v-model.trim="item" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchWellReceived"
            >选择订单信息</el-button>
          </el-form-item>

          <el-form-item v-if="editParm.paramsType === 5" label="收藏信息">
            <el-input v-model.trim="item" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="goSearchBrowse"
            >选择收藏信息</el-button>
          </el-form-item>

          <el-form-item v-if="editParm.paramsType === 6" label="敦煌-加购">
            <el-input v-model.trim="item" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="dhGoSearchCarFarm"
            >选择刷单信息</el-button>
          </el-form-item>

          <el-form-item v-if="editParm.paramsType === 7" label="敦煌-好评">
            <el-input v-model.trim="item" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="dhGoSearchWellReceived"
            >选择订单信息</el-button>
          </el-form-item>

          <el-form-item v-if="editParm.paramsType === 8" label="敦煌-抓单">
            <el-input v-model.trim="item" style="width:200px" />
            <el-button
              type="primary"
              icon="el-icon-search"
              style="width:130px"
              @click="dhGoSearchClickFarmOrder"
            >选择刷单信息</el-button>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer">
        <el-button type="info" @click="sureEditCancle('editParm')">取消</el-button>
        <el-button type="primary" @click="sureEdit('editParm')">确认</el-button>
      </span>
    </el-dialog>

    <!--日志弹窗-->
    <el-dialog
      width="75%"
      :visible.sync="dialogLogsListVisible"
      :title="dialogLogsListTitle"
      center
      append-to-body
    >
      <!-- 搜索日志 -->
      <el-form ref="form" class="mt_15" inline size="small">
        <el-form-item label="任务名称">
          <el-input v-model.trim="searchLogsParm.jobName" clearable placeholder="任务名称" />
        </el-form-item>
        <el-date-picker
          v-model.trim="searchLogsTime"
          type="daterange"
          range-separator=":"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width:270px"
        />
        <el-form-item label="状态">
          <el-input v-model.trim="searchLogsParm.isSuccess" clearable placeholder="状态" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="goSearchLogsByCondition">搜索</el-button>
          <el-button type="warning" @click="resetLogsForm">重置</el-button>
        </el-form-item>
      </el-form>
      <!--表格渲染-->
      <el-table
        ref="table"
        border
        size="small"
        :data="logsList"
        :header-cell-style="{textAlign:'center'}"
        :cell-style="{textAlign:'center'}"
      >
        <el-table-column label="任务名称" prop="jobName" />
        <el-table-column label="Bean名称" prop="beanName" />
        <el-table-column label="执行方法" prop="methodName" />
        <el-table-column label="参数">
          <template slot-scope="scope">
            <el-button type="text" @click="showParams(scope.row)">查看参数</el-button>
          </template>
        </el-table-column>
        <el-table-column label="cron表达式" prop="cronExpression" />
        <el-table-column label="异常详情" prop="exceptionDetail">
          <template slot-scope="scope">
            <el-button type="text" @click="showDetail(scope.row)">查看异常详情</el-button>
          </template>
        </el-table-column>
        <el-table-column label="耗时(毫秒)" prop="time" />
        <el-table-column label="状态" prop="isSuccess">
          <template slot-scope="scope">{{ scope.row.isSuccess | getLogIsSuccess }}</template>
        </el-table-column>
        <el-table-column label="创建日期" prop="createTime" />
      </el-table>
      <!--分页-->
      <div class="mt_15">
        <el-pagination
          :current-page="searchLogsParm.page"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="searchLogsParm.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="logsTotal"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-dialog>

    <!--设备选择弹窗-->
    <el-dialog
      width="75%"
      :visible.sync="dialogRebotListVisible"
      :title="dialogRebotListTitle"
      center
      append-to-body
    >
      <!--搜索-->
      <el-form ref="form" class="mt_15" inline size="small">
        <el-form-item label="机器人账号">
          <el-input v-model.trim="searchRebotParm.accountName" clearable placeholder="机器人账号" />
        </el-form-item>
        <el-form-item label="uuid">
          <el-input v-model.trim="searchRebotParm.robotClientUuid" clearable placeholder="uuid" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="goSearchRebot">搜索</el-button>
          <el-button type="warning" @click="resetRebotForm">重置</el-button>
        </el-form-item>
      </el-form>
      <!--表格渲染-->
      <el-table
        ref="table"
        border
        size="small"
        :data="rebotList"
        :header-cell-style="{textAlign:'center'}"
        :cell-style="{textAlign:'center'}"
      >
        <el-table-column label="序号" type="index" width="50" />
        <el-table-column label="机器人账号" prop="accountName" />
        <el-table-column label="uuid信息" prop="robotClientUuid" />
        <el-table-column label="状态" prop="status">
          <template slot-scope="scope">{{ scope.row.status | getRebotStatus }}</template>
        </el-table-column>
        <el-table-column label="创建时间" prop="createdAt" />
        <el-table-column label="修改时间" prop="updatedAt" />
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button
              v-if="rebotName !== scope.row.accountName"
              type="success"
              @click="pickRebot(scope.row)"
            >选中</el-button>
            <div v-if="rebotName === scope.row.accountName">已选中</div>
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <div class="mt_15">
        <el-pagination
          :current-page="searchRebotParm.page"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="searchRebotParm.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="this.rebotTotal"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-dialog>

    <!--刷单信息弹窗-->
    <el-dialog
      width="75%"
      :visible.sync="dialogParamListVisible"
      :title="dialogParamListTitle"
      center
      append-to-body
    >
      <el-form ref="form" class="mt_15" inline size="small">
        <el-form-item label="关键词">
          <el-input v-model.trim="searchParamParm.keyWord" clearable placeholder="关键词" />
        </el-form-item>
        <el-form-item label="Item">
          <el-input v-model.trim="searchParamParm.item" clearable />
        </el-form-item>
        <el-form-item label="店铺名称">
          <el-input v-model.trim="searchParamParm.shopName" clearable />
        </el-form-item>
        <el-form-item label="支付订单ID">
          <el-input v-model.trim="searchParamParm.payOrderId" clearable />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="goClickFarmSearch">搜索</el-button>
          <el-button type="warning" @click="goClickFarmResetForm">重置</el-button>
        </el-form-item>
      </el-form>
      <!--表格渲染-->
      <el-table
        ref="table"
        border
        size="small"
        :data="paramList"
        :header-cell-style="{textAlign:'center'}"
        :cell-style="{textAlign:'center'}"
      >
        <el-table-column label="国家" prop="country" align="center" />
        <el-table-column label="账号" prop="account" align="center" />
        <el-table-column label="平台" prop="platformName" align="center" />
        <el-table-column label="商品属性" prop="paramsType" align="center">
          <template slot-scope="scope">
            {{ scope.row.paramsType | getparamsType }}
          </template>
        </el-table-column>
        <el-table-column label="店铺名称" prop="shopName" align="center" />
        <el-table-column label="关键词" prop="keyWord" align="center" />
        <el-table-column label="数量" prop="number" align="center" />
        <el-table-column label="规格" prop="specification" align="center" />
        <el-table-column label="颜色" prop="color" align="center" />
        <el-table-column label="Item" prop="item" align="center" />
        <el-table-column label="状态" prop="status" align="center">
          <template slot-scope="scope">{{ scope.row.status | getFarmingStatus }}</template>
        </el-table-column>
        <el-table-column label="创建时间" prop="createdAt" align="center" />
        <el-table-column label="修改时间" prop="updatedAt" align="center" />
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button
              v-if="item !== scope.row.item"
              type="success"
              @click="pickParam(scope.row)"
            >选中</el-button>
            <div v-if="item === scope.row.item">已选中</div>
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <div class="mt_15">
        <el-pagination
          :current-page="searchParamParm.page"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="searchParamParm.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="paramTotal"
          @size-change="clickHandleSizeChange"
          @current-change="clickHandleCurrentChange"
        />
      </div>
    </el-dialog>

    <!--敦煌加购信息弹窗-->
    <el-dialog
      width="75%"
      :visible.sync="dialogParamDhListVisible"
      :title="dialogParamDhListTitle"
      center
      append-to-body
    >
      <el-form ref="form" class="mt_15" inline size="small">
        <el-form-item label="商品参数">
          <el-select v-model.trim="searchParm.paramsType" placeholder="请选择">
            <el-option
              v-for="item in searchParamsTypeList"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="国家">
          <el-input v-model.trim="searchParm.country" clearable />
        </el-form-item>
        <el-form-item label="账号">
          <el-input v-model.trim="searchParm.account" clearable />
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model.trim="searchParm.status" placeholder="请选择">
            <el-option
              v-for="item in statusDhList"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="goSearch">搜索</el-button>
          <el-button type="warning" @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
      <!--表格渲染-->
      <el-table ref="table" border size="small" :data="dhAddCarList" :header-cell-style="{textAlign:'center'}">
        <el-table-column label="商品属性" prop="paramsType" align="center">
          <template slot-scope="scope">
            {{ scope.row.paramsType | getparamsType }}
          </template>
        </el-table-column>
        <el-table-column label="国家" prop="country" align="center" />
        <el-table-column label="账号" prop="account" align="center" />
        <el-table-column label="公司名称" prop="companyName" align="center" />
        <el-table-column label="加购商品" prop="carGoodIds" align="center" />
        <el-table-column label="状态" prop="status" align="center">
          <template slot-scope="scope">
            {{ scope.row.status | getDhStatus }}
          </template>
        </el-table-column>
        <el-table-column label="创建时间" prop="createdAt" align="center" />
        <el-table-column label="修改时间" prop="updatedAt" align="center" />
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button
              v-if="item !== scope.row.item"
              type="success"
              @click="dhAddCarParam(scope.row)"
            >选中</el-button>
            <div v-if="item === scope.row.item">已选中</div>
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <div class="mt_15">
        <el-pagination
          :current-page="searchParm.page"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="searchParm.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="dhAddCarTotal"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-dialog>

    <!--敦煌加购-好评信息弹窗-->
    <el-dialog
      width="75%"
      :visible.sync="dialogParamDhWellReceivedVisible"
      :title="dialogParamDhWellReceivedTitle"
      center
      append-to-body
    >
      <el-form ref="form" class="mt_15" inline size="small">
        <el-form-item label="订单id">
          <el-input v-model.trim="searchParm.orderId" clearable />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="dhGoSearchWellReceived">搜索</el-button>
          <el-button type="warning" @click="resetDhWellReceivedForm">重置</el-button>
        </el-form-item>
      </el-form>
      <!--表格渲染-->
      <el-table ref="table" border size="small" :data="dhAddCarList" :header-cell-style="{textAlign:'center'}">
        <el-table-column label="类型" prop="type" align="center">
          <template slot-scope="scope">
            {{ scope.row.type | getparamsOrderType }}
          </template>
        </el-table-column>
        <el-table-column label="总金额" prop="amount" align="center" />
        <el-table-column label="店铺名称" prop="shop" align="center" />
        <el-table-column label="订单id" prop="orderId" align="center" />
        <el-table-column label="订单时间" prop="orderDate" align="center" />
        <el-table-column label="状态" prop="status" align="center">
          <template slot-scope="scope">
            {{ scope.row.status | getOrderStatus }}
          </template>
        </el-table-column>
        <el-table-column label="创建时间" prop="createdAt" align="center" />
        <el-table-column label="修改时间" prop="updatedAt" align="center" />
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button
              v-if="item !== scope.row.item"
              type="success"
              @click="dhAddCarOrderParam(scope.row)"
            >选中</el-button>
            <div v-if="item === scope.row.item">已选中</div>
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <div class="mt_15">
        <el-pagination
          :current-page="searchParm.page"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="searchParm.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="dhAddCarTotal"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-dialog>

    <!--订单信息弹窗-->
    <el-dialog width="75%" :visible.sync="dialogWellReceivedVisible" :title="dialogWellReceivedTitle" center append-to-body>
      <el-form ref="form" class="mt_15" inline size="small">
        <el-form-item label="账号">
          <el-input v-model.trim="searchParm.account" clearable placeholder="账号" />
        </el-form-item>
        <el-form-item label="订单ID">
          <el-input v-model.trim="searchParm.orderId" clearable placeholder="orderId" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="goSearch">搜索</el-button>
          <el-button type="warning" @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>

      <!--表格渲染-->
      <el-table ref="table" border size="small" :data="wellReceivedList" :header-cell-style="{textAlign:'center'}" :cell-style="{textAlign:'center'}">
        <el-table-column label="序号" type="index" width="50" />
        <el-table-column label="平台名称" prop="platformName" />
        <el-table-column label="公司名称" prop="companyName" />
        <el-table-column label="总金额" prop="amount" />
        <el-table-column label="店铺名称" prop="shop" />
        <el-table-column label="店铺名称" prop="orderId" />
        <el-table-column label="评论" prop="comment" />
        <el-table-column label="状态" prop="status" align="center">
          <template slot-scope="scope">
            {{ scope.row.status | getOrderStatus }}
          </template>
        </el-table-column>
        <el-table-column label="创建时间" prop="createdAt" />
        <el-table-column label="修改时间" prop="updatedAt" />
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button
              v-if="item !== scope.row.id"
              type="success"
              @click="wallReceived(scope.row)"
            >选中</el-button>
            <div v-if="item === scope.row.id">已选中</div>
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <div class="mt_15">
        <el-pagination
          :current-page="searchParamParm.page"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="searchParamParm.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="paramTotal"
          @size-change="clickHandleSizeChange"
          @current-change="clickHandleCurrentChange"
        />
      </div>
    </el-dialog>

    <!--浏览收藏信息弹窗-->
    <el-dialog width="75%" :visible.sync="dialogBrowseVisible" :title="dialogBrowseTitle" center append-to-body>
      <!--搜索-->
      <el-form ref="form" class="mt_15" inline size="small">
        <el-form-item label="账号">
          <el-input v-model.trim="searchParm.account" clearable placeholder="关键词" />
        </el-form-item>
        <el-form-item label="收藏链接">
          <el-input v-model.trim="searchParm.linkUrl" clearable />
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model.trim="searchParm.status" placeholder="请选择">
            <el-option
              v-for="item in statusBrowseList"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="goSearch">搜索</el-button>
          <el-button type="warning" @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
      <!--表格渲染-->
      <el-table ref="table" border size="small" :data="broseList" :header-cell-style="{textAlign:'center'}">
        <el-table-column label="序号" type="index" width="50" />
        <el-table-column label="买家ID" prop="buyerId" align="center" />
        <el-table-column label="账号" prop="account" align="center" />
        <el-table-column label="国家" prop="country" align="center" />
        <el-table-column label="收藏链接" prop="linkUrl" align="center" />
        <el-table-column label="状态描述" prop="paymentResults" align="center" />
        <el-table-column label="状态" prop="status" align="center">
          <template slot-scope="scope">
            {{ scope.row.status | getStatus }}
          </template>
        </el-table-column>
        <el-table-column label="创建时间" prop="createdAt" align="center" />
        <el-table-column label="修改时间" prop="updatedAt" align="center" />
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button
              v-if="item !== scope.row.id"
              type="success"
              @click="brose(scope.row)"
            >选中</el-button>
            <div v-if="item === scope.row.id">已选中</div>
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <div class="mt_15">
        <el-pagination
          :current-page="searchParm.page"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="searchParm.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-dialog>

    <!--参数详情-->
    <el-dialog
      :title="dialogParamTitle"
      :visible.sync="dialogParamVisible"
      width="30%"
      center
      style="overflow: hidden"
    >
      <div style="overflow-y: auto; height: 310px">
        <json-viewer :value="paramJsonData" :expand-depth="5" copyable boxed sort />
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogParamVisible = false">确定</el-button>
      </span>
    </el-dialog>

    <!--异常详情-->
    <el-dialog :title="dialogExceTitle" :visible.sync="dialogExceVisible" center width="30%">
      <div v-text="this.exceptionDetail" />
    </el-dialog>
  </div>
</template>
<script>
import {
  getList,
  add,
  editById,
  delById,
  getById,
  modifyStatus,
  executionById,
  getLogsList,
  getWellReceivedList,
  getBrowseDataList,
  getDhCarList
} from '@/api/rpa/quartzJob'
import { getAll } from '@/api/rpa/apply'
import { getFreeList } from '@/api/rpa/rebot'
import { getClickFarmList } from '@/api/group/clickfarming'
import { getCarOrderlist } from '@/api/group/dhAddCarOrder'
import Vue from 'vue'
import JsonViewer from 'vue-json-viewer'
Vue.use(JsonViewer)
export default {
  filters: {
    getStatus: function(value) {
      if (value == 1) {
        return '已暂停'
      } else if (value == 0) {
        return '运行中'
      }
    },
    getLogIsSuccess: function(value) {
      if (value == 1) {
        return '成功'
      } else if (value == 0) {
        return '失败'
      }
    },
    getRebotStatus: function(value) {
      if (value == 0) {
        return '未占用'
      } else if (value == 1) {
        return '已占用'
      }
    },
    getFarmingStatus: function(value) {
      if (value == 1) {
        return '待执行'
      } else if (value == 2) {
        return '执行中'
      } else if (value == 3) {
        return '执行成功'
      } else if (value == 4) {
        return '执行失败异常'
      } else if (value == 5) {
        return '待支付异常'
      } else if (value == 6) {
        return '支付成功异常'
      } else {
        return '执行失败'
      }
    },
	  getparamsType: function(value) {
		   if (value == 1) {
		   	 return '关键词'
		   } else if (value == 2) {
		   	 return '链接'
		   }
	  },
	  getparamsOrderType: function(value) {
		   if (value == 1) {
		   	 return '导入'
		   } else if (value == 2) {
		   	 return '刷单'
		   }
	  },
    getOrderStatus: function(value) {
	  	// 状态 1.待执行 2.执行中 3.执行成功 4.执行失败
			   if (value == 1) {
			   		return '待执行'
			   } else if (value == 2) {
			   		return '执行中'
			   } else if (value == 3) {
			   		return '执行成功'
			   } else if (value == 4) {
			   		return '执行失败'
			   } else {
			   	 return '执行失败'
			   }
		  },
    getDhStatus: function(value) {
	  	// 状态 1.待执行 2.执行中 3.加购成功 4.加购失败 5.下单成功 6.支付成功 7.抓单成功 8.抓单失败
			   if (value == 1) {
			   		return '待执行'
			   } else if (value == 2) {
			   		return '执行中'
			   } else if (value == 3) {
			   		return '加购成功'
			   } else if (value == 4) {
			   		return '加购失败'
			   } else if (value == 5) {
			   		return '下单成功'
			   } else if (value == 6) {
			   		return '待抓单'
			   } else if (value == 7) {
			   		return '抓单中'
			   } else if (value == 8) {
			   		return '抓单成功'
			   } else if (value == 9) {
			   		return '抓单失败'
			   } else {
			   	 return '执行失败'
			   }
		  }
  },
  //	数据
  data() {
    return {
      searchParm: {
        page: 1,
        pageSize: 10,
        sort: 'job_id',
        order: 'desc',
        jobName: null,
        isPause: null,
        sTime: null,
        eTime: null,
        commentBoolean: false,
        inCatchorder: null
      },
      searchLogsParm: {
        page: 1,
        pageSize: 10,
        sort: 'log_id',
        order: 'desc',
        jobName: null,
        isSuccess: null,
        sTime: null,
        eTime: null
      },
      searchRebotParm: {
        page: 1,
        pageSize: 10,
        sort: 'id',
        order: 'desc',
        accountName: null,
        robotClientUuid: null
      },
      searchParamParm: {
        page: 1,
        pageSize: 10,
        sort: 'created_at',
        order: 'desc',
        keyWord: null,
        type: null,
        status: null,
        item: null,
        shopName: null,
        payOrderId: null,
        inStatusList: 1,
        account: null,
    		status: null,
    		linkUrl: null,
    		type: 1,
    		platformId: null,
    		orderId: null
      },
      rebotName: '',
      logsTotal: 0,
      rebotTotal: 0,
      paramTotal: 0,
      total: 0,
      logsList: [],
      list: [],
      labelVal: '0',
      baseForm: {
        demoList: [
          {
            name: null,
            value: null,
            type: null
          }
        ]
      },
      newParams: {
        name: '',
        value: '',
        type: ''
      },
      item: '',
      index: 0,
      // 新增、修改弹窗判断：1新增、2修改
      isEdit: 0,
      rebotList: [],
      paramList: [],
      dhAddCarList: [],
      dhAddCarTotal: 0,
      wellReceivedList: [],
      broseList: [],
      applys: [],
      searchTime: '',
      searchLogsTime: '',
      paramJsonData: '',
      params: [],
      taskParam: {
        name: null,
        value: null,
        type: null
      },
      requestParams: {
        accountName: null,
        applyId: null,
        params: null
      },
      exceptionDetail: '',
      dialogAddVisible: false,
      dialogAddTitle: '新增窗口',
      dialogEditVisible: false,
      dialogEditTitle: '修改窗口',
      dialogImportVisible: false,
      dialogLogsListTitle: '操作日志',
      dialogLogsListVisible: false,
      dialogRebotListTitle: '设备列表',
      dialogRebotListVisible: false,
      dialogParamListTitle: '刷单信息列表',
      dialogParamListVisible: false,
      dialogParamDhListTitle: '敦煌加购列表',
      dialogParamDhListVisible: false,
      dialogParamDhWellReceivedTitle: '敦煌好评列表',
      dialogParamDhWellReceivedVisible: false,
      dialogWellReceivedTitle: '订单信息列表',
      dialogWellReceivedVisible: false,
      dialogBrowseTitle: '浏览收藏列表',
      dialogBrowseVisible: false,
      dialogParamVisible: false,
      dialogParamTitle: '参数详情',
      dialogExceVisible: false,
      dialogExceTitle: '异常详情',
      dialogParamInputVisible: false,
      dialogParamInputTitle: '参数输入窗口',
      pauseAfterFailureList: [
        {
          value: 1,
          label: '是'
        },
        {
          value: 0,
          label: '否'
        }
      ],
      isPauseList: [
        {
          value: 1,
          label: '已暂停'
        },
        {
          value: 0,
          label: '运行中'
        }
      ],
      logIsSuccess: [
        {
          value: 0,
          label: '失败'
        },
        {
          value: 1,
          label: '成功'
        }
      ],
      statusBrowseList: [
      	{
      		value: 1,
          label: '待执行'
      	},
      	{
      		value: 2,
          label: '执行中'
      	},
      	{
      		value: 3,
          label: '执行成功'
      	},
      	{
      		value: 4,
          label: '执行失败'
      	}
      ],
      statusDhList: [
    		{
          id: null,
          name: '全部'
        },
        {
          id: 1,
          name: '待执行'
        },
	  		{
	          id: 2,
	          name: '执行中'
	  		},
	  		{
	          id: 3,
	          name: '加购成功'
	        },
	  		{
          id: 4,
          name: '加购失败'
        }, {
        	id: 5,
        	name: '下单成功'
        }, {
        	id: 6,
        	name: '支付成功'
        }, {
        	id: 7,
        	name: '抓单成功'
        }, {
        	id: 8,
        	name: '支付抓单失败成功'
        }],
      searchParamsTypeList: [
	    	{
	          id: null,
	          name: '全部'
	        },
	        {
	          id: 1,
	          name: '关键词'
	        },
      		{
	          id: 2,
	          name: '链接'
      		}
	    ],
      addListDemo: [],
      addParm: {
        jobId: null,
        jobName: null,
        description: null,
        beanName: null,
        methodName: null,
        cronExpression: null,
        subTask: null,
        personInCharge: null,
        email: null,
        pauseAfterFailure: null,
        isPause: null,
        rebotName: null,
        applyId: null,
        params: null,
        paramsType: null,
        paramId: null,
        item: null
      },
      editParm: {
        jobId: null,
        jobName: null,
        description: null,
        beanName: null,
        methodName: null,
        cronExpression: null,
        subTask: null,
        personInCharge: null,
        email: null,
        pauseAfterFailure: null,
        isPause: null,
        params: null,
        paramsType: null,
        item: null,
        applyId: null,
        rebotName: null
      },
      testTest: null,
      testTestStr: '',
      rules: {
        jobName: [
          { required: true, message: '请输入任务名称', trigger: 'blur' }
        ],
        description: [
          { required: true, message: '请输入任务描述', trigger: 'blur' }
        ],
        // beanName: [
        //     { required: true, message: '请输入SpringBean名称', trigger: 'blur' }
        //   ],
        // methodName: [
        //     { required: true, message: '请输入方法名称', trigger: 'blur' }
        //   ],
        cronExpression: [
          { required: true, message: '请输入cron表达式', trigger: 'blur' }
        ],
        personInCharge: [
          { required: true, message: '请输入负责人', trigger: 'blur' }
        ],
        pauseAfterFailure: [
          { required: true, message: '请选择失败后是否暂停', trigger: 'blur' }
        ],
        isPause: [
          { required: true, message: '请选择运行状态', trigger: 'blur' }
        ],
        rebotName: [{ required: true, message: '请选择设备', trigger: 'blur' }],
        applyId: [{ required: true, message: '请选择应用', trigger: 'blur' }],
        params: [{ required: true, message: '请输入脚本参数', trigger: 'blur' }]
      },
      paramsRules: {
        name: [
          {
            required: true,
            message: '请输入参数名称',
            trigger: 'blur'
          }
        ],
        value: [
          {
            required: true,
            message: '请输入参数值',
            trigger: 'blur'
          }
        ],
        type: [
          {
            required: true,
            message: '请输入参数类型',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  // 调用
  created() {
    this.goSearch()
  },
  // 方法
  methods: {
    changeCheckRange(val) {
      this.labelVal = val
      this.editParm.paramsType = val
    },
    goInputParam() {
      if (
        this.baseForm.demoList[0].name == '' ||
        this.baseForm.demoList[0].type == '' ||
        this.baseForm.demoList[0].value == ''
      ) {
        console.log(this.baseForm.demoList)
        this.$message.error('参数不能为空')
      } else {
        console.log(this.baseForm.demoList)
        this.requestParams.params = this.baseForm.demoList
        this.dialogParamInputVisible = false
        this.$message.success('参数输入成功')
      }
    },
    showDetail(data) {
      if (data.exceptionDetail == null || data.exceptionDetail == '') {
        this.$alert('无异常', '异常详情', {
          confirmButtonText: '确定',
          closeOnClickModal: true,
          closeOnPressEscape: true
        })
      } else {
        this.dialogExceVisible = true
        this.exceptionDetail = data.exceptionDetail
      }
    },
    showParams(data) {
      console.log(data)
      if (data.params == null || data.params == '') {
        this.$alert('无参数', '参数详情', {
          confirmButtonText: '确定',
          closeOnClickModal: true,
          closeOnPressEscape: true
        })
      } else {
        this.paramJsonData = JSON.parse(data.params)
        this.dialogParamVisible = true
      }
    },
    applyClick(value) {
      this.requestParams.applyId = value
      console.log(this.requestParams)
    },
    // 重置
    resetForm() {
      this.searchParm.jobName = null
      this.searchParm.isPause = null
      this.searchParm.sTime = null
      this.searchParm.eTime = null
      this.searchTime = null
      this.goSearch()
    },
    resetLogsForm() {
      this.searchLogsParm.jobName = null
      this.searchLogsParm.isSuccess = null
      this.searchLogsParm.sTime = null
      this.searchLogsParm.eTime = null
      this.searchLogsTime = null
      this.goSearchLogs()
    },
    resetRebotForm() {
      this.searchRebotParm.accountName = null
      this.searchRebotParm.robotClientUuid = null
      this.goSearchRebot()
    },
    resetParams() {
      this.requestParams.params = null
      this.baseForm.demoList = [
        {
          name: '',
          value: '',
          type: ''
        }
      ]
      this.$message.warning('重置成功')
    },
    //	查询
    goSearchByCondition() {
      this.searchParm.sTime = this.searchTime[0]
      this.searchParm.eTime = this.searchTime[1]
      console.log(this.searchParm)
      this.goSearch()
    },
    goSearch() {
      this.searchParm.page = 1
      this.getAllApply()
      this.getDataList()
    },
    goClickFarmSearch() {
      this.searchParamParm.page = 1
      this.getClickFarmDataList()
    },
    // 重置
    goClickFarmResetForm() {
      this.searchParamParm.keyWord = null
      this.searchParamParm.item = null
      this.searchParamParm.shopName = null
      this.searchParamParm.payOrderId = null
      this.searchParamParm.status = null

      this.goClickFarmSearch()
    },
    // 分页获取表格数据-刷单信息
    getClickFarmDataList() {
      getClickFarmList(this.searchParamParm).then(res => {
        if (res.code == 200) {
          this.paramList = res.data.list
          this.paramTotal = res.data.total
          console.log('paramTotal:' + paramTotal)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    // 分页敦煌加购
    getDhAddCarDataList() {
      getDhCarList(this.searchParamParm).then(res => {
        if (res.code == 200) {
          this.dhAddCarList = res.data.list
          this.dhAddCarTotal = res.data.total
          console.log('paramTotal:' + paramTotal)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    // 分页敦煌好评
    carOrderlist() {
      getCarOrderlist(this.searchParamParm).then(res => {
        if (res.code == 200) {
          this.dhAddCarList = res.data.list
          this.dhAddCarTotal = res.data.total
          console.log('paramTotal:' + paramTotal)
        }
      }).catch(err => {
        console.log(err)
      })
    },

    // 分页获取表格数据-订单信息
    getWellReceivedDataList() {
      getWellReceivedList(this.searchParamParm).then(res => {
        if (res.code == 200) {
          this.wellReceivedList = res.data.list
          this.paramTotal = res.data.total
          console.log('paramTotal:' + paramTotal)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    // 分页获取收藏-列表信息
    getBrowseDataSearchList() {
      getBrowseDataList(this.searchParamParm).then(res => {
        if (res.code == 200) {
          this.broseList = res.data.list
          this.paramTotal = res.data.total
          console.log('paramTotal:' + paramTotal)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    goSearchLogsByCondition() {
      this.searchLogsParm.sTime = this.searchLogsTime[0]
      this.searchLogsParm.eTime = this.searchLogsTime[1]
      this.goSearchLogs()
    },
    goSearchLogs() {
      this.dialogLogsListVisible = true
      this.searchLogsParm.page = 1
      this.getLogsDataList()
    },
    goSearchRebot() {
      this.dialogRebotListVisible = true
      this.searchRebotParm.page = 1
      this.getRebotDataList()
    },
    // 速卖通-刷单
    goSearchClickFarm() {
      this.dialogParamListVisible = true
      this.searchParamParm.page = 1
      this.searchParamParm.inStatusList = 1
      this.searchParamParm.status = null
      this.searchParamParm.type = 1
      this.searchParamParm.platformId = 2
      this.getClickFarmDataList()
    },
    // 速卖通-刷单补录
    goSearchClickFarmSupplyMent() {
    	this.dialogParamListVisible = true
      this.searchParamParm.page = 1
      this.searchParamParm.inStatusList = null
      this.searchParamParm.status = 5
      this.searchParamParm.type = 1
      this.searchParamParm.platformId = 2
      this.getClickFarmDataList()
    },
    // 速卖通-好评
    goSearchWellReceived() {
    	this.dialogWellReceivedVisible = true
      this.searchParamParm.page = 1
      this.searchParamParm.status = 1
      this.searchParamParm.type = 1
      this.searchParamParm.commentBoolean = true
      this.searchParamParm.platformId = 2
      this.getWellReceivedDataList()
    },
    // 速卖通-浏览收藏
    goSearchBrowse() {
    	this.dialogBrowseVisible = true
      this.searchParamParm.page = 1
      this.searchParamParm.inStatusList = 1
      this.searchParamParm.platformId = 2
      this.getBrowseDataSearchList()
    },
    // 敦煌-加购
    dhGoSearchCarFarm() {
      this.dialogParamDhListVisible = true
      this.dialogParamDhListTitle = '敦煌加购'
      this.searchParamParm.page = 1
      this.searchParamParm.inStatusList = 1
      this.getDhAddCarDataList()
    },
    // 敦煌-好评
    dhGoSearchWellReceived() {
    	this.dialogParamDhWellReceivedVisible = true
      this.searchParamParm.page = 1
      this.searchParamParm.type = 2
      this.searchParamParm.inStatusList = 1
      this.searchParamParm.orderId = this.searchParm.orderId
      this.carOrderlist()
    },
    // 敦煌-抓单
    dhGoSearchClickFarmOrder() {
      this.dialogParamDhListVisible = true
      this.dialogParamDhListTitle = '敦煌抓单'
      this.searchParamParm.page = 1
      this.searchParamParm.inStatusList = 2
      this.getDhAddCarDataList()
    },
    // 分页获取表格数据
    getDataList() {
      getList(this.searchParm)
        .then(res => {
          if (res.code == 200) {
            this.list = res.data.list
            this.total = res.data.total
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    getLogsDataList() {
      getLogsList(this.searchLogsParm)
        .then(res => {
          console.log(res)
          if (res.code == 200) {
            this.logsList = res.data.list
            this.logsTotal = res.data.total
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    getRebotDataList() {
      getFreeList(this.searchRebotParm)
        .then(res => {
          console.log(res)
          if (res.code == 200) {
            this.rebotList = res.data.list
            this.rebotTotal = res.data.total
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    getAllApply() {
      getAll().then(res => {
        if (res.code == 200) {
          this.applys = res.data
        }
      })
    },
    // 新增
    addBtn() {
    	this.buyerId = null
      this.addParm = {
        id: null,
        jobId: null,
        jobName: null,
        description: null,
        beanName: null,
        methodName: null,
        cronExpression: null,
        subTask: null,
        personInCharge: null,
        email: null,
        pauseAfterFailure: null,
        isPause: null,
        params: null,
        paramsType: null,
        applyId: null,
        rebotName: null
      }

      this.baseForm.demoList = [
        {
          name: 'id',
          value: '',
          type: 'str'
        },
        {
          name: 'country',
          value: '',
          type: 'str'
        },
        {
          name: 'account',
          value: '',
          type: 'str'
        },
        {
          name: 'pwd',
          value: '',
          type: 'str'
        },
        {
          name: 'keyWord',
          value: '',
          type: 'str'
        },
        {
          name: 'number',
          value: '',
          type: 'str'
        },
        {
          name: 'specification',
          value: '',
          type: 'str'
        },
        {
          name: 'color',
          value: '',
          type: 'str'
        },
        {
          name: 'item',
          value: '',
          type: 'str'
        },
        {
          name: 'vpnShare',
          value: '',
          type: 'str'
        }
      ]
      this.item = ''
      this.rebotName = ''
      this.labelVal = '0'
      this.requestParams.applyId = ''
      this.requestParams.accountName = ''
      this.requestParams.params = ''
      this.addParm.params = JSON.stringify(this.requestParams)
      this.isEdit = 1
      this.dialogAddVisible = true
      this.$refs.addParm.clearValidate()
    },
    sureAdd(addParm) {
    	this.$refs[addParm].validate((valid) => {
		  if (valid) {
		  	this.$refs.addParm.clearValidate()
          if (this.requestParams.accountName == 'undefined' || this.requestParams.accountName == null || this.requestParams.accountName == '' || this.requestParams.accountName == 'null') {
	    	 	this.requestParams.accountName = this.rebotName
	    	}
	      this.requestParams.applyId = this.addParm.applyId
	      if (this.labelVal == 1) {
	        this.requestParams.params = this.baseForm.demoList
	      }
	      this.addParm.params = JSON.stringify(this.requestParams)
	      console.log(this.addParm)
	      add(this.addParm)
	        .then(res => {
	          if (res.code == 200) {
	            this.dialogAddVisible = false
	            this.$message.success('新增成功!')
	            this.getDataList()
	          } else if (res.code == -1) {
	            this.$message.warning(res.message)
	          }
	        })
	        .catch(err => {
	          console.log(err)
	        })
		  } else {
          console.log('error submit!!')
          return false
		  }
      })
    },
    sureAddCancle(addParm) {
    	this.dialogAddVisible = flase
    	this.$refs.addParm.clearValidate()
    },
    //	根据id删除
    delById(id) {
      this.$confirm('确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          delById({ id })
            .then(res => {
              if (res.code == 200) {
                this.$message.success('删除成功!')
                this.getDataList()
              }
            })
            .catch(err => {
              console.log(err)
            })
        })
        .catch(() => {
          this.$message.info('取消删除')
        })
    },
    executionById(id) {
      executionById({ id })
        .then(res => {
          if (res.code == 200) {
            this.$message.success('执行成功')
            this.getDataList
          } else {
            this.$message.error('执行失败')
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    //	修改
    editById(data) {
      getById({ id: data.jobId })
        .then(res => {
          if (res.code == 200) {
            this.editParm.jobId = res.data.jobId
            this.editParm.jobName = res.data.jobName
            this.editParm.description = res.data.description
            this.editParm.beanName = res.data.beanName
            this.editParm.methodName = res.data.methodName
            this.editParm.cronExpression = res.data.cronExpression
            this.editParm.subTask = res.data.subTask
            this.editParm.personInCharge = res.data.personInCharge
            this.editParm.email = res.data.email
            this.editParm.pauseAfterFailure = res.data.pauseAfterFailure
            this.editParm.isPause = res.data.isPause
            this.editParm.params = res.data.params
            this.labelVal = res.data.paramsType
            this.editParm.paramsType = res.data.paramsType
            this.requestParams = JSON.parse(this.editParm.params)
            this.editParm.rebotName = this.requestParams.accountName
            this.editParm.applyId = this.requestParams.applyId
            if (res.data.paramsType == 1) {
              this.item = null
              this.baseForm.demoList = this.requestParams.params
            } else if (res.data.paramsType == 2) {
              if (this.requestParams.params[8].value != null) {
                this.item = this.requestParams.params[8].value
              }

              this.baseForm.demoList = [
                {
                  name: 'id',
                  value: '',
                  type: 'str'
                },
                {
                  name: 'country',
                  value: '',
                  type: 'str'
                },
                {
                  name: 'account',
                  value: '',
                  type: 'str'
                },
                {
                  name: 'pwd',
                  value: '',
                  type: 'str'
                },
                {
                  name: 'keyWord',
                  value: '',
                  type: 'str'
                },
                {
                  name: 'number',
                  value: '',
                  type: 'str'
                },
                {
                  name: 'specification',
                  value: '',
                  type: 'str'
                },
                {
                  name: 'color',
                  value: '',
                  type: 'str'
                },
                {
                  name: 'item',
                  value: '',
                  type: 'str'
                },
                {
                  name: 'vpnShare',
                  value: '',
                  type: 'str'
                }
              ]
            }

            this.isEdit = 2
            this.dialogEditVisible = true
            //          this.$refs.editParm.clearValidate();
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    // 确认修改
    sureEdit(editParm) {
    	this.$refs[editParm].validate((valid) => {
			  if (valid) {
			  	this.$refs.editParm.clearValidate()
          this.requestParams.accountName = this.editParm.rebotName
		      this.requestParams.applyId = this.editParm.applyId
		      if (this.labelVal == 1) {
		        this.requestParams.params = this.baseForm.demoList
		      }
		      this.editParm.params = JSON.stringify(this.requestParams)
		      editById(this.editParm)
	        .then(res => {
	          if (res.code == 200) {
	            this.dialogEditVisible = false
	            this.$message.success('修改成功!')
	            this.getDataList()
	          } else if (res.code == -1) {
	            this.$message.warning(res.message)
	          }
	        })
	        .catch(err => {
	          console.log(err)
	        })
			  } else {
          console.log('error submit!!')
          return false
			  }
      })
    },
    sureEditCancle(editParm) {
    	this.dialogEditVisible = flase
    	this.$refs.editParm.clearValidate()
    },
    modifyStatus(id) {
      modifyStatus({ id })
        .then(res => {
          if (res.code == 200) {
            this.$message.success('更改成功!')
            this.getDataList()
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    pickRebot(data) {
    	if (this.dialogAddVisible == true) {
    		 this.addParm.rebotName = data.accountName
    	}

    	if (this.dialogEditVisible == true) {
    		this.editParm.rebotName = data.accountName
    	}

      this.requestParams.accountName = data.accountName
      this.dialogRebotListVisible = false
      this.$message.success('选择成功')
    },
    pickParam(data) {
      this.requestParams.params = data.id
      this.item = data.id
      this.dialogParamListVisible = false
      this.$message.success('选择成功')
    },
    dhAddCarParam(data) {
      this.requestParams.params = data.id
      this.item = data.id
      this.dialogParamDhListVisible = false
      this.$message.success('选择成功')
    },
    // 敦煌好评
    dhAddCarOrderParam(data) {
      this.requestParams.params = data.id
      this.item = data.id
      this.dialogParamDhWellReceivedVisible = false
      this.$message.success('选择成功')
    },
    wallReceived(data) {
    	console.log(this.requestParams)
    	this.requestParams.params = data.id
      this.item = data.id
      this.dialogWellReceivedVisible = false
      this.$message.success('选择成功')
    },
    brose(data) {
    	console.log(this.requestParams)
    	this.requestParams.params = data.id
      this.item = data.id
      this.dialogBrowseVisible = false
      this.$message.success('选择成功')
    },
    //	分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.searchParm.pageSize = val
      this.getDataList()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.searchParm.page = val
      this.getDataList()
    },
    clickHandleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.searchParamParm.pageSize = val
      this.getDataList()
    },
    clickHandleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.searchParamParm.page = val
      this.getDataList()
    },
    // 选中某一行修改或移除
    selectItem(row, column, event) {
      this.selectedFundRow = row
      if (event.target.innerText == '删除') {
        this.removeFundBtn(this.selectedFundRow)
      }
    },
    // 删除指定行
    removeFundBtn(params) {
      this.baseForm.demoList = this.baseForm.demoList.filter(ele => {
        var flag = false
        // 如果不一致，则保留该行
        for (const key in params) {
          if (ele[key] != params[key]) {
            flag = true
            break
          }
        }
        return flag
      })
      // 如果全部删除后没有可以点击的一行了，需要加一行空行
      if (!this.baseForm.demoList.length) {
        this.addLine()
      }
    },
    // 增加一个空行, 用于录入或显示第一行
    addLine() {
      const newParams = {
        name: '',
        value: '',
        type: ''
      }
      this.index++
      this.baseForm.demoList.push(newParams)
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
</style>
