// 专利挖掘-挖掘任务表格栏位
export const column = {
  data() {
    return {
      // 审核任务类型
      taskType: {
        1: '项目审核任务',
        2: '文件分配任务',
        3: '文件审核任务',
      },
      // 任务列表table栏位信息
      columnList: [
        {
          name: "任务名称",
          type: "String",
          value: "name",
        },
        {
          name: "任务类型",
          type: "Integer",
          value: "type",
        },
        {
          name: "发起人",
          type: "String",
          value: "createName",
        },
        {
          name: "处理人",
          type: "String",
          value: "handlerName",
        },
        {
          name: "创建时间",
          type: "DateTime",
          value: "createTime",
        },
        {
          name: "截止时间",
          type: "DateTime",
          value: "deadLineTime",
        },
        {
          name: "状态",
          type: "String",
          value: "status",
        },
        {
          name: "备注",
          type: "String",
          value: "description",
        },
      ],
      // 审核历史table栏位信息
      columnList2: [
        {
          name: "处理人",
          type: "String",
          value: "createName",
        },
        {
          name: "时间",
          type: "String",
          value: "createTime",
        },
        {
          name: "结果",
          type: "String",
          value: "description",
        },
      ]
    }
  },
  mounted() {

  },
  methods: {
    // 点击项目名称
    handleItem(row, key) { },
    // 遍历栏位为数组类型
    getArrJoin(data, type) {
      if (!data) {
        return '--'
      }

      if (Array.isArray(data)) {
        if (data.length == 0) {
          return '--'
        }
        let arr = data.map(item => {
          return item[type]
        })
        return arr.join('、')
      } else {
        return type[data]
      }
    },
  },
}


// 专利挖掘-人员-懒加载
export const personnelLoading = {
  data() {
    return {
      //人员列表懒加载
      personnelList: {
        queryParams: {
          current: 1,
          size: 10
        },
        data: []
      },
    }
  },
  mounted() {

  },
  methods: {
    /**
    * 人员（输入框形式）
    */
    // 懒加载人员方法
    personnelLoad() {
      if (this.personnelList.queryParams.current * this.personnelList.queryParams.size >= this.personnelList.queryParams.total) {
        return false
      }
      this.personnelList.queryParams.current++
      this.questionPersonnel()
    },
    // 查询人员
    async questionPersonnel() {
      let params = {
        ...this.personnelList.queryParams,
        name: this.personnelList.name
      }
      await this.$api.getPermissionPersonnel(params).then(res => {
        if (res.code == 200) {
          this.personnelList.data.push(...res.data)
          this.personnelList.queryParams.total = res.pageColumn.total
          this.personnelList.cb(this.personnelList.data);
        }
      })
    },
    //获取下拉建议人员数据
    async querySearchPersonnel(queryString, cb) {
      this.personnelList.queryParams.current = 1
      this.personnelList.name = queryString
      this.personnelList.data = []
      this.personnelList.cb = cb
      await this.questionPersonnel()
    },
    // 人员输入框失焦
    handleBlur(val) {
      if (this.form.handlerName.includes('@')) {
        this.form.handler = val
      }
    },
    // 人员输入框选择
    handleSelectPersonnel(val) {
      this.form.handler = val.id
    },



    /**
      * 人员列表（下拉框形式）
      * @param {*} query 
    */
    // 人员列表远程搜索
    remoteMethodPerson(query) {
      this.personnelList.data = []
      this.personnelList.queryParams.current = 1
      this.personnelList.queryParams.name = query
      this.getPermissionPersonnel()
    },
    // 获取所有人员列表懒加载
    lazyLoadingPerson() {
      if (this.personnelList.queryParams.current * this.personnelList.queryParams.size >= this.personnelList.queryParams.total) {
        return false
      }
      this.personnelList.queryParams.current += 1
      this.getPermissionPersonnel()
    },
    //获取所有人员列表（修改不要一次性获取，可以使用懒加载加远程搜索 ）
    async getPermissionPersonnel(type) {
      this.personnelList.loading = true;
      await this.$api.getPermissionPersonnel(this.personnelList.queryParams).then((response) => {
        if (response.code == 200) {
          this.personnelList.loading = false;
          if (!type) {
            if (this.form.handler) {
              var index = response.data.findIndex(item => {
                return item.id == this.form.handler
              })
              if (index != -1) {
                response.data.splice(index, 1)
              }
            }
            this.personnelList.queryParams.total = response.pageColumn.total
          }
          this.personnelList.data.push(...response.data)
          // this.personnelList.queryParams.total = response.pageColumn.total
        }
      })
    },
  },
}

// 专利挖掘-基本信息-流程
export const optionsData = {
  data() {
    return {
      pathOptions: [
        { label: '创新点梳理', value: 1 },
        { label: '查新检索', value: 2 },
        { label: '保护主题规划', value: 3 },
        { label: '独权撰写', value: 4 },
        { label: '从权撰写', value: 5 },
        { label: '申请文件定稿', value: 6 },
        { label: '说明书规划撰写', value: 7 },
      ],//流程
    }
  },
  mounted() {

  },
  methods: {

  },
}

