import assert from 'assert'
import Comp from '../../../examples/SafePlan/comp'
import init from '../init'
import {HttpResetClass, trans} from 'vue-client'
import Vue from "vue";

describe('安检计划管理', () => {
  before( async () => {
    init()
    // 获取当前登录人信息
    // await Vue.$login.login('wzp','1')
    // 直接调用login方法会重复提交，所以采用直接调用rs/user，rs/user请求中传的data为登录时fiddler抓取的数据
    let http = new HttpResetClass()
    let ret = await http.load('POST', `/rs/user/userLogin/客服系统`,
      "jNkvo0bSFy935eq6LGfbhMUzZqtODSJOIA+CAwOXO4iX8L876IkTlPx7sjjsW4Nb3Ur2eC31aMCMMu2Uy7x3nDVHL/qt++C6K7cIKIOieRj+KxZAmMmv1TxS7s9fSm5DDJYaXEdlQQpQwSc5fKLvnjx/2NsGFbkDWvZq4EHaIaw=",
      {resolveMsg: null, rejectMsg: null})
    console.log('登陆获取Util', JSON.stringify(ret.data))
    Vue.$login.f = ret.data
    // 调用登录完成
    // setTimeout(await trans.begin(), 3000)
   // await trans.begin()
  })

  after( async () => {
   // await trans.rollback()
  })

  it.only('加载某个分公司下的所有安检计划', async () => {
    console.log("加载到的信息"+JSON.stringify(Vue.$login.f))
    let c=new Comp();
    c.checkplan.search.setField("f_filialeid",453)
    await c.loadCheckPlan(()=>{})
    assert.equal(20, c.checkplan.list.data.length)

    // 获取第一个安检计划安检单总数
    assert.equal(3, c.getSumItem(c.checkplan.list.data[0]))
  })

  it('加载未安检用户列表', async () => {
    let c=new Comp();
    c.setProperty("user", "f_userinfo_id", "1")
    await c.searchUser()

    assert.equal(1, c.user.list.data.length)

  })
  it('加载计划项列表', async () => {
    let c=new Comp();
    c.setProperty("checkplanitems","f_plan_id","2d3240ccf8584b6db07c949c2b517721")
    await c.searchPlanItems()
    assert.equal(20, c.checkplanitems.list.data.length)
  })

  it('加载更多', async () => {
    let c=new Comp();
    //c.setProperty("user", "f_userinfo_id", "1")
    await c.searchUser()
    while(c.user.list.loadMoreState){
      await c.loadMore("user")
    }
    assert.equal(234, c.user.list.data.length)
  })

  it('新建安检计划', async () => {
    let c = new Comp();
    c.setNewPlan("f_plan_name", "人民").setNewPlan("f_plan_year", "2014").setNewPlan("f_plan_month", "2")
    await c.addNewPlan(()=>{})
  })

  it('将用户拖入安检计划', async () => {
    let c = new Comp();
    await c.dragtoPlanItem(453,'106ded80b6ca42fcbf4865d24e9b20f4',453)
    assert.equal(234, c.user.list.data.length)

  })

  it('将安检计划项拖入未安检用户', async () => {
    let c = new Comp();
    await c.delPlanItem('12A87222-70D7-45F4-80D2-3F09B861237B')
    assert.equal(234, c.user.list.data.length)
  })

  it('将安检计划项拖入其他安检计划', async () => {
    let c = new Comp();
    await c.dragtouser(1,1)
    assert.equal(234, c.user.list.data.length)
  })

  it('查询安检员', async () => {
    let c = new Comp();
    console.log("----"+Vue.$login.f.id)
    await c.searchChecker(Vue.$login.f.id)

    assert.equal(234, c.user.list.data.length)
  })

  it('安检计划排序查询', async () => {
    let c = new Comp();
    c.setProperty("checkplan","f_plan_year","2020")
    await c.loadCheckPlan("",f)

    assert.equal(234,c.checkplan.list.data.length)
  })

  function f(){
    return ""
  }
  /*it('加载某个分公司下的所有安检计划', async () => {FetchUserFileByOrgChecker.sql
    let c=new Comp();
    c.setProperty("planitem","f_plan_id","2d3240ccf8584b6db07c949c2b517721")

    //await c.searchUser()
    //await c.loadMore("user")
    //await c.loadCheckPlan()
    //await c.delPlanItem()
    /!*await c.dragtoPlanItem()
    await c.dragtouser()
    await c.delPlanItem()*!/
    let str=await c.getCheckStatistic('2d3240ccf8584b6db07c949c2b517721')
    console.log("数据？"+str)

    assert.equal(10, 10)

  })*/


})
