handleTrashList.js 912 B

123456789101112131415161718192021222324252627282930
  1. import Vue from 'vue'
  2. import iview from 'iview'
  3. export default function handleTrashList (payload = {}, option) {
  4. // 单个操作伪装成多个操作
  5. payload = option.type && option.type === 'one' ? [payload] : payload
  6. return new Promise(async (resolve, reject) => {
  7. const saleName = payload.map(item => item.sale_name, {})
  8. const ids = payload.map(item => item.id, {})
  9. const tips = option.status === 0 ? '删除' : '还原'
  10. iview.Modal.confirm({
  11. title: `${tips}商品`,
  12. content: `确定要${tips} "${saleName.join(',')}" 商品吗?`,
  13. onOk: async () => {
  14. try {
  15. await Vue.http.put(`/product/product/waste_status`, { 'status': option.status, ids })
  16. iview.Message.success(`${tips}成功`)
  17. resolve('remove')
  18. } catch (e) {
  19. reject(e)
  20. }
  21. },
  22. onCancel: (e) => {
  23. reject(e)
  24. },
  25. })
  26. })
  27. }