prompt-cancel-reason.js 778 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * 作废原因选填弹窗(依赖基础库 editable Modal)。
  3. * @returns {Promise<string|null>} null=取消;字符串=确认(可空)
  4. */
  5. export function promptOptionalCancelReason(options = {}) {
  6. const {
  7. title = '作废确认',
  8. content = '作废原因选填,可直接确认。',
  9. confirmText = '作废',
  10. confirmColor = '#ef4444'
  11. } = options
  12. return new Promise((resolve) => {
  13. uni.showModal({
  14. title,
  15. content,
  16. editable: true,
  17. placeholderText: '选填作废原因',
  18. confirmText,
  19. confirmColor,
  20. success: (res) => {
  21. if (!res.confirm) {
  22. resolve(null)
  23. return
  24. }
  25. resolve(String(res.content || '').trim())
  26. },
  27. fail: () => resolve(null)
  28. })
  29. })
  30. }