271 lines
11 KiB
Vue
271 lines
11 KiB
Vue
<script>
|
|
/** 按商品 fields 渲染订购信息;explain 只读,其他字段按 id 写入父级 modelValue。 */
|
|
import "~/assets/styles/ProductCustomFields.B2QMnPil.css";
|
|
import { toDisplayString } from "vue";
|
|
import { renderList } from "vue";
|
|
import { createBlock } from "vue";
|
|
import { createCommentVNode } from "vue";
|
|
import { computed } from "vue";
|
|
import { createElementBlock } from "vue";
|
|
import { Fragment } from "vue";
|
|
import { createElementVNode } from "vue";
|
|
import { createTextVNode } from "vue";
|
|
import { unref } from "vue";
|
|
import { defineComponent } from "vue";
|
|
import { openBlock } from "vue";
|
|
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
|
|
import inputtext from "primevue/inputtext";
|
|
import select from "primevue/select";
|
|
import checkbox from "primevue/checkbox";
|
|
import textarea from "primevue/textarea";
|
|
var _ = {
|
|
key: 0,
|
|
class: `panel product-custom-fields`,
|
|
},
|
|
v = [`for`],
|
|
y = {
|
|
key: 0,
|
|
},
|
|
b = {
|
|
key: 4,
|
|
class: `field-note`,
|
|
},
|
|
x = Object.assign(
|
|
_plugin_vue_export_helper_t(
|
|
defineComponent({
|
|
__name: `ProductCustomFields`,
|
|
props: {
|
|
fields: {},
|
|
modelValue: {},
|
|
disabled: {
|
|
type: Boolean,
|
|
},
|
|
},
|
|
emits: [`update:modelValue`],
|
|
setup(u, { emit: f }) {
|
|
let x = u,
|
|
S = f,
|
|
C = computed(() => x.fields.filter((e) => e.kind !== `explain`));
|
|
function w(e, t) {
|
|
// 后端自定义字段采用字符串值;复制对象更新,不能直接修改父级传入的对象。
|
|
S(`update:modelValue`, {
|
|
...x.modelValue,
|
|
[e]: t == null ? `` : String(t),
|
|
});
|
|
}
|
|
return (i, f) => {
|
|
let x = textarea,
|
|
S = select,
|
|
T = checkbox,
|
|
E = inputtext;
|
|
return u.fields.length
|
|
? (openBlock(),
|
|
createElementBlock(`section`, _, [
|
|
(f[0] ||= createElementVNode(
|
|
`h2`,
|
|
{
|
|
class: `section-title`,
|
|
},
|
|
`订购信息`,
|
|
-1,
|
|
)),
|
|
(openBlock(!0),
|
|
createElementBlock(
|
|
Fragment,
|
|
null,
|
|
renderList(
|
|
u.fields.filter((e) => e.kind === `explain`),
|
|
(t) => (
|
|
openBlock(),
|
|
createElementBlock(
|
|
`p`,
|
|
{
|
|
key: `explain-${t.id}`,
|
|
class: `field-note`,
|
|
},
|
|
toDisplayString(t.explain || t.description),
|
|
1,
|
|
)
|
|
),
|
|
),
|
|
128,
|
|
)),
|
|
(openBlock(!0),
|
|
createElementBlock(
|
|
Fragment,
|
|
null,
|
|
renderList(
|
|
unref(C),
|
|
(t) => (
|
|
openBlock(),
|
|
createElementBlock(
|
|
`div`,
|
|
{
|
|
key: t.id,
|
|
class: `form-row`,
|
|
},
|
|
[
|
|
createElementVNode(
|
|
`label`,
|
|
{
|
|
for: `product-field-${t.id}`,
|
|
},
|
|
[
|
|
createTextVNode(toDisplayString(t.label), 1),
|
|
t.required
|
|
? (openBlock(),
|
|
createElementBlock(`span`, y, ` *`))
|
|
: createCommentVNode(``, !0),
|
|
],
|
|
8,
|
|
v,
|
|
),
|
|
t.kind === `textarea`
|
|
? (openBlock(),
|
|
createBlock(
|
|
x,
|
|
{
|
|
key: 0,
|
|
id: `product-field-${t.id}`,
|
|
"model-value": u.modelValue[t.id],
|
|
"aria-label": t.label,
|
|
required: t.required,
|
|
disabled: u.disabled,
|
|
rows: `3`,
|
|
class: `grow`,
|
|
"onUpdate:modelValue": (e) => w(t.id, e),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`id`,
|
|
`model-value`,
|
|
`aria-label`,
|
|
`required`,
|
|
`disabled`,
|
|
`onUpdate:modelValue`,
|
|
],
|
|
))
|
|
: t.kind === `select`
|
|
? (openBlock(),
|
|
createBlock(
|
|
S,
|
|
{
|
|
key: 1,
|
|
"input-id": `product-field-${t.id}`,
|
|
"model-value": u.modelValue[t.id],
|
|
"aria-label": t.label,
|
|
required: t.required,
|
|
options: t.options,
|
|
"option-label": `label`,
|
|
"option-value": `value`,
|
|
disabled: u.disabled,
|
|
class: `grow`,
|
|
"onUpdate:modelValue": (e) => w(t.id, e),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`input-id`,
|
|
`model-value`,
|
|
`aria-label`,
|
|
`required`,
|
|
`options`,
|
|
`disabled`,
|
|
`onUpdate:modelValue`,
|
|
],
|
|
))
|
|
: t.kind === `boolean`
|
|
? (openBlock(),
|
|
createBlock(
|
|
T,
|
|
{
|
|
key: 2,
|
|
"input-id": `product-field-${t.id}`,
|
|
"model-value":
|
|
u.modelValue[t.id] === `1`,
|
|
"aria-label": t.label,
|
|
required: t.required,
|
|
binary: ``,
|
|
disabled: u.disabled,
|
|
"onUpdate:modelValue": (e) =>
|
|
w(t.id, e ? `1` : ``),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`input-id`,
|
|
`model-value`,
|
|
`aria-label`,
|
|
`required`,
|
|
`disabled`,
|
|
`onUpdate:modelValue`,
|
|
],
|
|
))
|
|
: (openBlock(),
|
|
createBlock(
|
|
E,
|
|
{
|
|
key: 3,
|
|
id: `product-field-${t.id}`,
|
|
"model-value": u.modelValue[t.id],
|
|
"aria-label": t.label,
|
|
required: t.required,
|
|
type:
|
|
t.kind === `password`
|
|
? `password`
|
|
: t.kind === `link`
|
|
? `url`
|
|
: `text`,
|
|
disabled: u.disabled,
|
|
autocomplete:
|
|
t.kind === `password`
|
|
? `new-password`
|
|
: `off`,
|
|
class: `grow`,
|
|
"onUpdate:modelValue": (e) =>
|
|
w(t.id, e),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`id`,
|
|
`model-value`,
|
|
`aria-label`,
|
|
`required`,
|
|
`type`,
|
|
`disabled`,
|
|
`autocomplete`,
|
|
`onUpdate:modelValue`,
|
|
],
|
|
)),
|
|
t.description
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
`small`,
|
|
b,
|
|
toDisplayString(t.description),
|
|
1,
|
|
))
|
|
: createCommentVNode(``, !0),
|
|
],
|
|
)
|
|
),
|
|
),
|
|
128,
|
|
)),
|
|
]))
|
|
: createCommentVNode(``, !0);
|
|
};
|
|
},
|
|
}),
|
|
[[`__scopeId`, `data-v-9d2a6f70`]],
|
|
),
|
|
{
|
|
__name: `ProductCustomFields`,
|
|
},
|
|
);
|
|
export {};
|
|
export default x;
|
|
</script>
|