import Vue from 'vue' import iview from 'iview' export default function handleTrashList (payload = {}, option) { // 单个操作伪装成多个操作 payload = option.type && option.type === 'one' ? [payload] : payload return new Promise(async (resolve, reject) => { const saleName = payload.map(item => item.sale_name, {}) const ids = payload.map(item => item.id, {}) const tips = option.status === 0 ? '删除' : '还原' iview.Modal.confirm({ title: `${tips}商品`, content: `确定要${tips} "${saleName.join(',')}" 商品吗?`, onOk: async () => { try { await Vue.http.put(`/product/product/waste_status`, { 'status': option.status, ids }) iview.Message.success(`${tips}成功`) resolve('remove') } catch (e) { reject(e) } }, onCancel: (e) => { reject(e) }, }) }) }