@icreate/ics-mui
Version:
京东风格的轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)
201 lines (200 loc) • 8.3 kB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
import { defineComponent, computed, openBlock, createElementBlock, createElementVNode, createVNode, withCtx, Fragment, renderList, createBlock, createTextVNode, unref } from "vue";
import "../input/Input.js";
import { _ as _sfc_main$4 } from "../form.vue_vue_type_script_setup_true_lang-_R4v_pqp.js";
import { _ as _sfc_main$2 } from "../swipe.vue_vue_type_script_setup_true_lang-CmJC1O6r.js";
import { _ as _sfc_main$1 } from "../swipe-group.vue_vue_type_script_setup_true_lang-Dxpitxl3.js";
import { _ as _sfc_main$3 } from "../button.vue_vue_type_script_setup_true_lang-yMATZ2Sk.js";
import { _ as _sfc_main$5 } from "../form-item.vue_vue_type_script_setup_true_lang-CZ2WA8l9.js";
import { showDialog } from "../dialog/Dialog.js";
import { _ as _sfc_main$6 } from "../input.vue_vue_type_script_setup_true_lang-CUVjcKoZ.js";
import { w as withInstall } from "../with-install-DWwOiZS3.js";
const _hoisted_1 = { class: "medical-advice" };
const _hoisted_2 = { class: "medical-advice-box" };
const _hoisted_3 = { class: "content-list" };
const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
name: "IcsMedicalAdvice"
}), {
__name: "index",
props: {
modelValue: {
type: Array,
default: () => {
}
},
template: {
type: Object,
default: () => {
}
}
},
emits: ["update:modelValue", "click"],
setup(__props, { emit: __emit }) {
const props = __props;
const emits = __emit;
const getShowName = (value) => {
var _a;
return template.value && ((_a = template.value.children.filter((item) => item.id === value)[0]) == null ? void 0 : _a.showName);
};
const filteredEntries = (item) => {
return Object.entries(item).filter(([key]) => getShowName(key)).map(([key, value]) => ({ key, value }));
};
const template = computed(() => props.template);
const executeList = computed(() => props.modelValue);
const deleteItem = (item, index) => {
const del = () => {
const findMatchingIndex = (list, startIndex, direction, marker) => {
let i = startIndex;
while (i >= 0 && i < list.length) {
if (list[i].VENOUS_CATHETERIZATION.indexOf(marker) !== -1) {
return i;
}
i += direction;
}
return -1;
};
const executeListArray = executeList.value;
if (item.VENOUS_CATHETERIZATION.indexOf("┌") !== -1) {
const endIndex = findMatchingIndex(executeListArray, index + 1, 1, "└");
const deleteCount = endIndex !== -1 ? endIndex - index + 1 : 1;
executeListArray.splice(index, deleteCount);
} else if (item.VENOUS_CATHETERIZATION.indexOf("│") !== -1) {
const startIndex = findMatchingIndex(executeListArray, index - 1, -1, "┌");
const endIndex = findMatchingIndex(executeListArray, index + 1, 1, "└");
const start = startIndex !== -1 ? startIndex : index;
const end = endIndex !== -1 ? endIndex : index;
const deleteCount = end - start + 1;
executeListArray.splice(start, deleteCount);
} else if (item.VENOUS_CATHETERIZATION.indexOf("└") !== -1) {
const startIndex = findMatchingIndex(executeListArray, index - 1, -1, "┌");
const deleteCount = startIndex !== -1 ? index - startIndex + 1 : 1;
executeListArray.splice(startIndex !== -1 ? startIndex : index, deleteCount);
} else {
executeListArray.splice(index, 1);
}
};
showDialog({
title: "提示",
content: `确认要删除吗?`,
popClass: "nut-dialog-class",
onOk: () => __async(this, null, function* () {
del();
setTimeout(() => {
emits("update:modelValue", executeList.value);
}, 100);
})
});
};
const onPicker = () => {
emits("click");
};
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1, [
createElementVNode("div", _hoisted_2, [
createVNode(_sfc_main$1, { lock: "" }, {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(executeList.value, (item, index) => {
return openBlock(), createBlock(_sfc_main$2, {
key: item.VISIT_ID + "_" + index,
name: item.VISIT_ID + "_" + index,
class: "medical-advice-list",
onClick: onPicker
}, {
right: withCtx(() => [
createVNode(_sfc_main$3, {
shape: "square",
class: "del_btn",
type: "danger",
onClick: ($event) => deleteItem(item, index)
}, {
default: withCtx(() => [
createTextVNode(" 删除 ")
]),
_: 2
}, 1032, ["onClick"])
]),
default: withCtx(() => [
createVNode(_sfc_main$4, null, {
default: withCtx(() => [
createElementVNode("div", _hoisted_3, [
createVNode(_sfc_main$5, {
label: template.value.showName,
class: "list"
}, null, 8, ["label"]),
(openBlock(true), createElementBlock(Fragment, null, renderList(filteredEntries(item), (entry) => {
return openBlock(), createBlock(_sfc_main$5, {
key: entry.key,
class: "list",
label: getShowName(entry.key)
}, {
default: withCtx(() => [
createVNode(unref(_sfc_main$6), {
modelValue: entry.value,
"onUpdate:modelValue": ($event) => entry.value = $event,
border: false,
readonly: "",
class: "input"
}, null, 8, ["modelValue", "onUpdate:modelValue"])
]),
_: 2
}, 1032, ["label"]);
}), 128))
])
]),
_: 2
}, 1024)
]),
_: 2
}, 1032, ["name"]);
}), 128))
]),
_: 1
})
])
]);
};
}
}));
withInstall(_sfc_main);
export {
_sfc_main as MedicalAdvice,
_sfc_main as default
};