| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- import { ref as c, reactive as _, computed as b, watch as f, resolveComponent as h, openBlock as O, createBlock as S, withCtx as o, createVNode as i, createTextVNode as $, toDisplayString as y } from "vue";
- import { a7 as A } from "./index2.js";
- import { _ as B } from "./index10.js";
- const j = {
- __name: "SEditorImageAdjust",
- emits: ["confirm"],
- setup(D, { expose: k, emit: C }) {
- const R = C, r = c(!1), m = c(null), p = c(null), n = _({ width: 0, height: 0 }), e = _({ scale: "1", width: 0, height: 0 }), x = [
- { label: window.$l("原图比例"), value: "1" },
- { label: window.$l("自由比例"), value: "2" },
- { label: "1:1", value: "3" },
- { label: "4:3", value: "4" },
- { label: "3:2", value: "5" },
- { label: "16:9", value: "6" },
- { label: window.$l("身份证"), value: "7" },
- { label: window.$l("护照"), value: "8" }
- ], H = {
- 3: 1 / 1,
- 4: 4 / 3,
- 5: 3 / 2,
- 6: 16 / 9,
- 7: 340 / 420,
- 8: 288 / 420
- }, M = b(() => !n.width || !n.height ? 1 : n.width / n.height), d = b(() => {
- var t;
- return e.scale === "1" ? M.value : e.scale === "2" ? null : (t = H[e.scale]) != null ? t : null;
- });
- f(
- () => e.scale,
- () => {
- const t = d.value;
- t && (e.width ? e.height = Math.ceil(e.width / t) : e.height && (e.width = Math.ceil(e.height * t)));
- }
- ), f(
- () => e.width,
- (t) => {
- const l = d.value;
- !l || !t || (e.height = Math.ceil(t / l));
- }
- ), f(
- () => e.height,
- (t) => {
- const l = d.value;
- !l || !t || (e.width = Math.ceil(t * l));
- }
- );
- function N(t) {
- const { editor: l, image: a } = t || {};
- !l || !a || (m.value = l, p.value = a, n.width = a.naturalWidth || a.offsetWidth || 0, n.height = a.naturalHeight || a.offsetHeight || 0, e.scale = "1", e.width = a.offsetWidth || n.width, e.height = a.offsetHeight || n.height, r.value = !0);
- }
- function w() {
- r.value = !1;
- }
- function U() {
- const t = Number(e.width), l = Number(e.height);
- if (!t || !l) {
- window.$message.warning(window.$l("高度或宽度不能为0"));
- return;
- }
- const a = p.value, u = m.value;
- !a || !u || (a.style.width = `${t}px`, a.style.height = `${l}px`, u.events.fire("change", u.value), r.value = !1, R("confirm", { width: t, height: l }));
- }
- return k({ open: N }), (t, l) => {
- const a = A, u = h("s-form-item"), v = B, W = h("s-form"), g = h("s-button"), I = h("s-modal");
- return O(), S(I, {
- value: r.value,
- "onUpdate:value": l[3] || (l[3] = (s) => r.value = s),
- title: t.$l("调整宽高"),
- width: 380,
- "show-full-screen": !1,
- "mask-closable": !1,
- onHandCancel: w
- }, {
- footer: o(() => [
- i(g, { onClick: w }, {
- default: o(() => [
- $(y(t.$l("取消")), 1)
- ]),
- _: 1
- }),
- i(g, {
- type: "primary",
- onClick: U
- }, {
- default: o(() => [
- $(y(t.$l("确定")), 1)
- ]),
- _: 1
- })
- ]),
- default: o(() => [
- i(W, {
- model: e,
- column: 1,
- labelWidth: "70px"
- }, {
- default: o(() => [
- i(u, {
- label: t.$l("比例"),
- prop: "scale"
- }, {
- default: o(() => [
- i(a, {
- value: e.scale,
- "onUpdate:value": l[0] || (l[0] = (s) => e.scale = s),
- options: x
- }, null, 8, ["value"])
- ]),
- _: 1
- }, 8, ["label"]),
- i(u, {
- label: t.$l("高度"),
- prop: "height"
- }, {
- default: o(() => [
- i(v, {
- value: e.height,
- "onUpdate:value": l[1] || (l[1] = (s) => e.height = s),
- min: 1,
- max: 4e3,
- style: { width: "100%" }
- }, null, 8, ["value"])
- ]),
- _: 1
- }, 8, ["label"]),
- i(u, {
- label: t.$l("宽度"),
- prop: "width"
- }, {
- default: o(() => [
- i(v, {
- value: e.width,
- "onUpdate:value": l[2] || (l[2] = (s) => e.width = s),
- min: 1,
- max: 4e3,
- style: { width: "100%" }
- }, null, 8, ["value"])
- ]),
- _: 1
- }, 8, ["label"])
- ]),
- _: 1
- }, 8, ["model"])
- ]),
- _: 1
- }, 8, ["value", "title"]);
- };
- }
- };
- export {
- j as default
- };
|