CouponCell.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. default: () => stdin_default
  21. });
  22. module.exports = __toCommonJS(stdin_exports);
  23. var import_vue = require("vue");
  24. var import_vue2 = require("vue");
  25. var import_utils = require("../utils");
  26. var import_cell = require("../cell");
  27. const [name, bem, t] = (0, import_utils.createNamespace)("coupon-cell");
  28. const couponCellProps = {
  29. title: String,
  30. border: import_utils.truthProp,
  31. editable: import_utils.truthProp,
  32. coupons: (0, import_utils.makeArrayProp)(),
  33. currency: (0, import_utils.makeStringProp)("\xA5"),
  34. chosenCoupon: (0, import_utils.makeNumericProp)(-1)
  35. };
  36. function formatValue({
  37. coupons,
  38. chosenCoupon,
  39. currency
  40. }) {
  41. const coupon = coupons[+chosenCoupon];
  42. if (coupon) {
  43. let value = 0;
  44. if ((0, import_utils.isDef)(coupon.value)) {
  45. ({
  46. value
  47. } = coupon);
  48. } else if ((0, import_utils.isDef)(coupon.denominations)) {
  49. value = coupon.denominations;
  50. }
  51. return `-${currency} ${(value / 100).toFixed(2)}`;
  52. }
  53. return coupons.length === 0 ? t("noCoupon") : t("count", coupons.length);
  54. }
  55. var stdin_default = (0, import_vue2.defineComponent)({
  56. name,
  57. props: couponCellProps,
  58. setup(props) {
  59. return () => {
  60. const selected = props.coupons[+props.chosenCoupon];
  61. return (0, import_vue.createVNode)(import_cell.Cell, {
  62. "class": bem(),
  63. "value": formatValue(props),
  64. "title": props.title || t("title"),
  65. "border": props.border,
  66. "isLink": props.editable,
  67. "valueClass": bem("value", {
  68. selected
  69. })
  70. }, null);
  71. };
  72. }
  73. });