import {SearchList, date} from 'vue-client'
import {PagedList} from 'vue-client'
import {HttpResetClass} from 'vue-client'
import Vue from "vue"

export default class Comp {
  // 安检用户列表
  user = new SearchList()
  //
  checkSend = new SearchList()
  http = new HttpResetClass()
  async ready(){

  }
  changeField(modelname,key,val){
    this[modelname].search.setField(key,val)
  }
  // 查询待检用户
  async searchUser(f) {
    this.user.search.setField("f_filialeid", global.login.orgid)
    this.user.search.setField("f_user_state", "正常")
    await this.user.searchList("/api/af-safecheck/sql/FetchUserFileByOrgNoRuHuSXQ", {
      "f_filialeid": "ui.f_filialeid={}",
      "userinfocode": "ui.f_userinfo_code='{}'",
      "username": "ui.f_user_name like '%{}%'",
      "useraddress": "ua.f_address like '%{}%'",
      "f_user_state":"ui.f_user_state='{}'"
    }, {
      "orderitem": 'f_userinfo_id',
      "f_usertype": '',
      "month": '',
      "SafeCheckSX": {"f_check_start": '', "f_check_end": ''},
      "SafeCheckCQ": ''
    })
    f()
  }

  async getCheckSend(addressid,f){
    this.checkSend.search.setField("addressid",addressid)
    await this.checkSend.searchList("/api/af-safecheck/sql/getCheckSend", {"addressid": "it.f_addressid='{}'"}, {orderitem:'cs.f_date'})
    f()
  }




  async loadMore(modelname,f) {
      await this[modelname].list.loadMore()
    f()
  }
  // 取年的选择项目
  years() {
    return date.yearSelects
  }

  // 取月的选择项目
  months() {
    return date.monthSelects
  }
  getResult(val){
    let b=JSON.parse(val)
    console.log(val)
    if(val){
      return b.result
    }else{
      return ''
    }
  }
}
