AddressEditDetail.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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", "selectSearch"],
  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("selectSearch", express);
  50. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  51. };
  52. const renderSearchResult = () => {
  53. if (!showSearchResult()) {
  54. return;
  55. }
  56. const {
  57. searchResult
  58. } = props;
  59. return searchResult.map((express) => (0, import_vue.createVNode)(import_cell.Cell, {
  60. "clickable": true,
  61. "key": (express.name || "") + (express.address || ""),
  62. "icon": "location-o",
  63. "title": express.name,
  64. "label": express.address,
  65. "class": bem("search-item"),
  66. "border": false,
  67. "onClick": () => onSelect(express)
  68. }, null));
  69. };
  70. const onBlur = (event) => emit("blur", event);
  71. const onFocus = (event) => emit("focus", event);
  72. const onInput = (value) => emit("input", value);
  73. return () => {
  74. if (props.show) {
  75. return (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)(import_field.Field, {
  76. "autosize": true,
  77. "clearable": true,
  78. "ref": field,
  79. "class": bem(),
  80. "rows": props.rows,
  81. "type": "textarea",
  82. "rules": props.rules,
  83. "label": t("addressDetail"),
  84. "border": !showSearchResult(),
  85. "maxlength": props.maxlength,
  86. "modelValue": props.value,
  87. "placeholder": t("addressDetail"),
  88. "onBlur": onBlur,
  89. "onFocus": onFocus,
  90. "onUpdate:modelValue": onInput
  91. }, null), renderSearchResult()]);
  92. }
  93. };
  94. }
  95. });