AddressEditDetail.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. var import_field = require("../field");
  28. const [name, bem] = (0, import_utils.createNamespace)("address-edit-detail");
  29. const t = (0, import_utils.createNamespace)("address-edit")[2];
  30. var stdin_default = (0, import_vue2.defineComponent)({
  31. name,
  32. props: {
  33. show: Boolean,
  34. rows: import_utils.numericProp,
  35. value: String,
  36. rules: Array,
  37. focused: Boolean,
  38. maxlength: import_utils.numericProp,
  39. searchResult: Array,
  40. showSearchResult: Boolean
  41. },
  42. emits: ["blur", "focus", "input", "select-search"],
  43. setup(props, {
  44. emit
  45. }) {
  46. const field = (0, import_vue2.ref)();
  47. const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
  48. const onSelect = (express) => {
  49. emit("select-search", express);
  50. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  51. };
  52. const renderSearchTitle = (express) => {
  53. if (express.name) {
  54. const text = express.name.replace(props.value, `<span class=${bem("keyword")}>${props.value}</span>`);
  55. return (0, import_vue.createVNode)("div", {
  56. "innerHTML": text
  57. }, null);
  58. }
  59. };
  60. const renderSearchResult = () => {
  61. if (!showSearchResult()) {
  62. return;
  63. }
  64. const {
  65. searchResult
  66. } = props;
  67. return searchResult.map((express) => (0, import_vue.createVNode)(import_cell.Cell, {
  68. "clickable": true,
  69. "key": express.name + express.address,
  70. "icon": "location-o",
  71. "label": express.address,
  72. "class": bem("search-item"),
  73. "border": false,
  74. "onClick": () => onSelect(express)
  75. }, {
  76. title: () => renderSearchTitle(express)
  77. }));
  78. };
  79. const onBlur = (event) => emit("blur", event);
  80. const onFocus = (event) => emit("focus", event);
  81. const onInput = (value) => emit("input", value);
  82. return () => {
  83. if (props.show) {
  84. return (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)(import_field.Field, {
  85. "autosize": true,
  86. "clearable": true,
  87. "ref": field,
  88. "class": bem(),
  89. "rows": props.rows,
  90. "type": "textarea",
  91. "rules": props.rules,
  92. "label": t("addressDetail"),
  93. "border": !showSearchResult(),
  94. "maxlength": props.maxlength,
  95. "modelValue": props.value,
  96. "placeholder": t("addressDetail"),
  97. "onBlur": onBlur,
  98. "onFocus": onFocus,
  99. "onUpdate:modelValue": onInput
  100. }, null), renderSearchResult()]);
  101. }
  102. };
  103. }
  104. });