import request from '../../utils/request_zc'

import {UploadUrl} from "../../utils/url"
import co from 'co'
export function getAuditChangeLogPageList(data) {
    return request({
        url: '/property/GetAuditChangeLogPageList',
        method: 'post',
        data
    });
}

export function auditOrRefund(data) {
    return request({
        url: '/property/AuditOrRefund',
        method: 'post',
        data
    });
}
export function getPropertyAuditDetail(data) {
    return request({
        url: '/property/GetPropertyAuditDetail',
        method: 'post',
        data
    });
}

//详情页接口
export function getPropertyLogPageList(data) {
    return request({
        url: '/property/GetPropertyLogPageList',
        method: 'post',
        data
    });
}

export function getPropertyInfo(data) {
    return request({
        url: '/property/GetPropertyInfo',
        method: 'post',
        data
    });
}
//设置经办人
export function setBuyingRequisitionManagers(data) {
  return request({
      url: '/property/SetBuyingRequisitionManagers',
      method: 'post',
      data
  });
}

//获取经办人的列表
export function getEmployeeList(data) {
  return request({
      url: '/User/GetEmployeeList',
      method: 'post',
      data
  });
}
// 请购单审核
export function bRAuditOrRefund(data) {
  return request({
      url: '/property/BRAuditOrRefund',
      method: 'post',
      data
  });
}
// 请购单审核
export function getBuyingRequisitionAuditDetail(data) {
  return request({
      url: '/property/GetBuyingRequisitionAuditDetail',
      method: 'post',
      data
  });
}

//耗材 入库单的审核
export function suppliesStockInAuditOrRefund(data) {
  return request({
      url: '/supplies/SuppliesStockInAuditOrRefund',
      method: 'post',
      data
  });
}
//耗材 入库单的详情
export function getSuppliesStockInAuditDetail(data) {
  return request({
      url: '/supplies/GetSuppliesStockInAuditDetail',
      method: 'post',
      data
  });
}

//资产 入库单的审核
export function propertyStockInAuditOrRefund(data) {
  return request({
      url: '/property/PropertyStockInAuditOrRefund',
      method: 'post',
      data
  });
}

//资产 入库单的详情
export function getPropertyStockInAuditDetail(data) {
  return request({
      url: '/property/GetPropertyStockInAuditDetail',
      method: 'post',
      data
  });
}






export  function UploadSelfFileT(path, files, successCall, ocr) {
    if (files && files.length > 0) {
      let nameList = new Array()
      for (let index = 0; index < files.length; index++) {
        nameList.push(this.random_string());
      }
      let that = this;
      co(function* () {
        for (let index = 0; index < files.length; index++) {
          let fileName = nameList[index]
          fileName = path + fileName + "." + files[index].name.split('.').pop()
          var formData = new FormData();
          var uploadUrl = UploadUrl + "/Upload?filePath=" + path + '&ocr=' + ocr;
          formData.append("myfile", files[index]);
          that.$http.post(uploadUrl, formData, {})
            .then(res => {
              successCall(res);
            }).catch(function (reason) {
              that.$refs['my-upload'].clearFiles();
              that.$message.error('上传失败！');
              that.MsgBus.$emit('UploadSelfFileErr')
            });
        }
      }).catch(function (err) {
        that.$refs['my-upload'].clearFiles();
        that.$message.error('上传失败！');
      });
    }
  }