CouponCell.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var __defProp = Object.defineProperty;
  2. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  3. var __getOwnPropNames = Object.getOwnPropertyNames;
  4. var __hasOwnProp = Object.prototype.hasOwnProperty;
  5. var __export = (target, all) => {
  6. for (var name2 in all)
  7. __defProp(target, name2, { get: all[name2], enumerable: true });
  8. };
  9. var __copyProps = (to, from, except, desc) => {
  10. if (from && typeof from === "object" || typeof from === "function") {
  11. for (let key of __getOwnPropNames(from))
  12. if (!__hasOwnProp.call(to, key) && key !== except)
  13. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  14. }
  15. return to;
  16. };
  17. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  18. var stdin_exports = {};
  19. __export(stdin_exports, {
  20. couponCellProps: () => couponCellProps,
  21. default: () => stdin_default
  22. });
  23. module.exports = __toCommonJS(stdin_exports);
  24. var import_vue = require("vue");
  25. var import_vue2 = require("vue");
  26. var import_utils = require("../utils");
  27. var import_cell = require("../cell");
  28. const [name, bem, t] = (0, import_utils.createNamespace)("coupon-cell");
  29. const couponCellProps = {
  30. title: String,
  31. border: import_utils.truthProp,
  32. editable: import_utils.truthProp,
  33. coupons: (0, import_utils.makeArrayProp)(),
  34. currency: (0, import_utils.makeStringProp)("\xA5"),
  35. chosenCoupon: (0, import_utils.makeNumericProp)(-1)
  36. };
  37. function formatValue({
  38. coupons,
  39. chosenCoupon,
  40. currency
  41. }) {
  42. const coupon = coupons[+chosenCoupon];
  43. if (coupon) {
  44. let value = 0;
  45. if ((0, import_utils.isDef)(coupon.value)) {
  46. ({
  47. value
  48. } = coupon);
  49. } else if ((0, import_utils.isDef)(coupon.denominations)) {
  50. value = coupon.denominations;
  51. }
  52. return `-${currency} ${(value / 100).toFixed(2)}`;
  53. }
  54. return coupons.length === 0 ? t("noCoupon") : t("count", coupons.length);
  55. }
  56. var stdin_default = (0, import_vue2.defineComponent)({
  57. name,
  58. props: couponCellProps,
  59. setup(props) {
  60. return () => {
  61. const selected = props.coupons[+props.chosenCoupon];
  62. return (0, import_vue.createVNode)(import_cell.Cell, {
  63. "class": bem(),
  64. "value": formatValue(props),
  65. "title": props.title || t("title"),
  66. "border": props.border,
  67. "isLink": props.editable,
  68. "valueClass": bem("value", {
  69. selected
  70. })
  71. }, null);
  72. };
  73. }
  74. });