// import utilUC from './util_uc_all'
// 审核过后 状态为2 才能关闭订单
// 关闭订单(完结) 之后状态为6
const billUtil = {
  data() {
    return {
      bill_type: '',
      sendTxt: '送审'
      // methodType: [
      //   { key: 'send_bills', value: '送审', billStatus: '0' },
      //   { key: 'un_send_bills', value: '取消送审', billStatus: '1' },
      //   { key: 'audit_bills', value: '审核', billStatus: '2' },
      //   { key: 'un_audit_bills', value: '取消审核', billStatus: '3' },
      //   { key: 'close_bills', value: '关闭订单', billStatus: '4' },
      //   { key: 'un_close_bills', value: '取消关闭', billStatus: '5' },
      //   { key: 'invalid_bills', value: '作废', billStatus: '6' },
      //   { key: 'valid_bills', value: '取消作废', billStatus: '7' }
      // ]
    }
  },
  computed: {},
  methods: {
    // processor(billStatus, bill_type = this.bill_type, billIds, operatorId = 0) {
    //   const item = this.methodType.find(res => {
    //     return res.billStatus === billStatus
    //   })
    //   const url = `/mesAPI/${item.key}/${bill_type}/${billIds}/${operatorId}/`
    //   this.$fecth.get(url).then(res => {
    //     this.query_bill_hdr(this.bill_hdr.id, true)
    //   })
    // },
    send_bills(bill_ids, bill_type = this.bill_type, operator_id = 0) {
      const url = `mesAPI/send_bills/`
      return this.$API.post(url, {}, {}, {
        bill_ids,
        bill_type,
        operator_id
      })
    },
    un_send_bills(bill_ids, bill_type = this.bill_type, operator_id = 0) {
      const url = `mesAPI/un_send_bills/`
      return this.$API.post(
        url, {}, {}, {
          bill_ids,
          bill_type,
          operator_id
        }
      )
    },
    audit_bills(bill_ids, bill_type = this.bill_type, operator_id = 0) {
      const url = `mesAPI/audit_bills/`
      return this.$API.post(
        url, {}, {}, {
          bill_ids,
          bill_type,
          operator_id
        }
      )
    },
    // 发送单据
    sendedi_bills(ids_list, str) {
      const url = `mesAPI/${str}/send/`
      return this.$API.post(
        url, {}, {}, {
          ids_list
        }
      ).then(res => {
        let success = ''
        if (str === 'pu_order') {
          success = 'success_orders'
        } else {
          success = 'success_shipments'
        }
        const a = res.data[success].join(',')
        this.$message.success(`订单${a}已发送`)
      })
    },
    // 发送单据
    sendedi_un_bills(ids_list, str) {
      const url = `mesAPI/${str}/cancel/`
      return this.$API.post(
        url, {}, {}, {
          ids_list
        }
      ).then(res => {
        let success = ''
        if (str === 'pu_order') {
          success = 'success_orders'
        } else {
          success = 'success_shipments'
        }
        const a = res.data[success].join(',')
        this.$message.success(`订单${a}已撤回`)
      })
    },
    un_audit_bills(bill_ids, bill_type = this.bill_type, operator_id = 0) {
      const url = `mesAPI/un_audit_bills/`
      return this.$API.post(
        url, {}, {}, {
          bill_ids,
          bill_type,
          operator_id
        }
      )
    },
    edi_un_audit_bills(ids_list, str) {
      const url = `mesAPI/${str}/cancel/`
      return this.$API.post(
        url, {}, {}, {
          ids_list
        }
      ).then(res => {
        let success = ''
        if (str === 'pu_order') {
          success = 'success_orders'
        } else {
          success = 'success_shipments'
        }
        const a = res.data[success].join(',')
        this.$message.success(`订单${a}已撤回`)
      })
    },
    close_bills(bill_ids, bill_type = this.bill_type, operator_id = 0) {
      const url = `mesAPI/close_bills/`
      return this.$API.post(
        url, {}, {}, {
          bill_ids,
          bill_type,
          operator_id
        }
      )
    },
    un_close_bills(bill_ids, bill_type = this.bill_type, operator_id = 0) {
      const url = `mesAPI/un_close_bills/`
      return this.$API.post(
        url, {}, {}, {
          bill_ids,
          bill_type,
          operator_id
        }
      )
    },
    invalid_bills(bill_ids, bill_type = this.bill_type, operator_id = 0) {
      const url = `mesAPI/invalid_bills/`
      return this.$API.post(
        url, {}, {}, {
          bill_ids,
          bill_type,
          operator_id
        }
      )
    },
    valid_bills(bill_ids, bill_type = this.bill_type, operator_id = 0) {
      const url = `mesAPI/invalid_bills/`
      return this.$API.post(
        url, {}, {}, {
          bill_ids,
          bill_type,
          operator_id
        }
      )
    }
  }
}
export default billUtil
