import { d as defineComponent, c as createVNode, m as mergeProps, z as nextTick, A as useStoreOfUserInfo, r as ref, o as onMounted, b as createElementBlock, e as createBaseVNode, B as unref, f as withCtx, s as createTextVNode, F as Fragment, x as renderList, k as createBlock, C as createCommentVNode, j as openBlock, Q as refreshCurrentRoute } from "./index-5e4623ce.js"; import { P as Picker } from "./index-0f48f786.js"; import { B as BackTop } from "./index-9e456003.js"; import { B as Button } from "./index-b1054607.js"; import { C as CellGroup } from "./index-3a8cf159.js"; import { C as Cell } from "./index-8540448e.js"; import { F as Field } from "./index-41ec7e28.js"; import { C as CusNavigation } from "./CusNavigation-87012716.js"; import { p as post_promise } from "./index-18735c56.js"; import { a as showConfirmDialog } from "./index-fefbbdb7.js"; import { c as createNamespace, e as extend, t as truthProp, o as makeArrayProp, z as makeStringProp, y as pick, I as Icon, H as HAPTICS_FEEDBACK, w as withInstall } from "./index-487cde8c.js"; import { p as popupSharedProps, a as popupSharedPropKeys, P as Popup } from "./index-eef3af38.js"; import { L as Loading } from "./index-217c49a0.js"; import { s as showToast } from "./function-call-dc072a29.js"; import { F as Form } from "./index-0229ad12.js"; import "./use-scope-id-0b5b8615.js"; import "./use-route-726f0d0b.js"; import "./axios-8cd254ce.js"; import "./mount-component-2b0f7b23.js"; import "./use-placeholder-16d7c5d7.js"; import "./on-popup-reopen-c5ca1603.js"; const [name, bem] = createNamespace("action-sheet"); const actionSheetProps = extend({}, popupSharedProps, { title: String, round: truthProp, actions: makeArrayProp(), closeIcon: makeStringProp("cross"), closeable: truthProp, cancelText: String, description: String, closeOnPopstate: truthProp, closeOnClickAction: Boolean, safeAreaInsetBottom: truthProp }); const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"]; var stdin_default = defineComponent({ name, props: actionSheetProps, emits: ["select", "cancel", "update:show"], setup(props, { slots, emit }) { const updateShow = (show) => emit("update:show", show); const onCancel = () => { updateShow(false); emit("cancel"); }; const renderHeader = () => { if (props.title) { return createVNode("div", { "class": bem("header") }, [props.title, props.closeable && createVNode(Icon, { "name": props.closeIcon, "class": [bem("close"), HAPTICS_FEEDBACK], "onClick": onCancel }, null)]); } }; const renderCancel = () => { if (slots.cancel || props.cancelText) { return [createVNode("div", { "class": bem("gap") }, null), createVNode("button", { "type": "button", "class": bem("cancel"), "onClick": onCancel }, [slots.cancel ? slots.cancel() : props.cancelText])]; } }; const renderIcon = (action) => { if (action.icon) { return createVNode(Icon, { "class": bem("item-icon"), "name": action.icon }, null); } }; const renderActionContent = (action, index2) => { if (action.loading) { return createVNode(Loading, { "class": bem("loading-icon") }, null); } if (slots.action) { return slots.action({ action, index: index2 }); } return [createVNode("span", { "class": bem("name") }, [action.name]), action.subname && createVNode("div", { "class": bem("subname") }, [action.subname])]; }; const renderAction = (action, index2) => { const { color, loading, callback, disabled, className } = action; const onClick = () => { if (disabled || loading) { return; } if (callback) { callback(action); } if (props.closeOnClickAction) { updateShow(false); } nextTick(() => emit("select", action, index2)); }; return createVNode("button", { "type": "button", "style": { color }, "class": [bem("item", { loading, disabled }), className], "onClick": onClick }, [renderIcon(action), renderActionContent(action, index2)]); }; const renderDescription = () => { if (props.description || slots.description) { const content = slots.description ? slots.description() : props.description; return createVNode("div", { "class": bem("description") }, [content]); } }; return () => createVNode(Popup, mergeProps({ "class": bem(), "position": "bottom", "onUpdate:show": updateShow }, pick(props, popupInheritKeys)), { default: () => { var _a; return [renderHeader(), renderDescription(), createVNode("div", { "class": bem("content") }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()]; } }); } }); const ActionSheet = withInstall(stdin_default); const index = ""; var byteToHex = []; for (var i = 0; i < 256; ++i) { byteToHex.push((i + 256).toString(16).slice(1)); } function unsafeStringify(arr, offset = 0) { return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); } var getRandomValues; var rnds8 = new Uint8Array(16); function rng() { if (!getRandomValues) { getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); if (!getRandomValues) { throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported"); } } return getRandomValues(rnds8); } var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto); const native = { randomUUID }; function v4(options, buf, offset) { if (native.randomUUID && !buf && !options) { return native.randomUUID(); } options = options || {}; var rnds = options.random || (options.rng || rng)(); rnds[6] = rnds[6] & 15 | 64; rnds[8] = rnds[8] & 63 | 128; if (buf) { offset = offset || 0; for (var i = 0; i < 16; ++i) { buf[offset + i] = rnds[i]; } return buf; } return unsafeStringify(rnds); } const selColumns = [ { text: "WiFi", value: "WiFi" }, { text: "NB-IOT", value: "NB-IOT" }, { text: "4G", value: "4G" } ]; const platformColumns = [ { text: "阿里云", value: "阿里云" }, { text: "驼人", value: "驼人" }, { text: "本地", value: "本地" } ]; const _hoisted_1 = { class: "pages" }; const _hoisted_2 = { class: "mains" }; const _hoisted_3 = { class: "form" }; const _hoisted_4 = { class: "submit-btn" }; const _hoisted_5 = { class: "title" }; const _hoisted_6 = { class: "form" }; const _hoisted_7 = { class: "title" }; const _hoisted_8 = { class: "form" }; const _hoisted_9 = { class: "container", style: { "overflow-y": "auto", "flex-grow": "1", "background-color": "#f7f8fa" } }; const _hoisted_10 = { class: "form" }; const _hoisted_11 = { style: { "margin": "0.25rem 10%", "width": "80%" } }; const _hoisted_12 = { class: "form" }; const _hoisted_13 = { style: { "margin": "0.25rem 10%", "width": "80%" } }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "Index", setup(__props) { const userInfo = useStoreOfUserInfo(); const cusNavigation = ref(); const wifiAction = ref(false); const wifiTitle = ref(""); const addressAction = ref(false); const addressTitle = ref(""); const formData = ref({}); const wifiInfo = ref({}); const addressInfo = ref({}); const wifiDatas = ref([]); const addressDatas = ref([]); const showPicker = ref(false); const showPlatfromPicker = ref(false); const validator20 = (val) => val && val.length > 20 ? false : true; function onSubmit() { var _a; formData.value.wifi = JSON.stringify(wifiDatas.value); (_a = addressDatas == null ? void 0 : addressDatas.value) == null ? void 0 : _a.forEach((item) => { switch (item.platform) { case "阿里云": item.platform = "1"; break; case "驼人": item.platform = "2"; break; case "本地": item.platform = "3"; break; } }); formData.value.address = JSON.stringify(addressDatas.value); if (!formData.value.id) { formData.value.id = userInfo.id; } debugger; post_promise({ url: "/userConfig/config", data: formData.value }).then( (res) => { if (res.code === 0) { showToast({ message: "WIFI信息配置成功!", onClose: () => { refreshCurrentRoute(); } }); wifiAction.value = false; } } ); } const onConfirm = (selectedOptions) => { showPicker.value = false; addressInfo.value.networkType = selectedOptions.selectedValues[0]; }; const onConfirmPlatfrom = (selectedOptions) => { showPlatfromPicker.value = false; addressInfo.value.platform = selectedOptions.selectedValues[0]; }; function handleBlur() { wifiInfo.value.name = wifiInfo.value.name.trim(); } function handleCancel(flag) { if (flag === "wifi") { wifiInfo.value = {}; wifiAction.value = false; } else { addressInfo.value = {}; addressAction.value = false; } } function onWifiSubmit() { let tip = "新增"; if (!wifiInfo.value.password) { wifiInfo.value.password = ""; } if (wifiInfo.value && wifiInfo.value.id) { for (let i = 0; i < wifiDatas.value.length; i++) { if (wifiDatas.value[i].id === wifiInfo.value.id) { wifiDatas.value[i] = wifiInfo.value; tip = "编辑"; } } } else { wifiInfo.value = { ...wifiInfo.value, id: v4() }; wifiDatas.value.push(wifiInfo.value); } showToast("WIFI信息" + tip + "成功,保存后生效"); wifiAction.value = false; wifiInfo.value = {}; } function onAddressSubmit() { let tip = "新增"; if (addressInfo.value && addressInfo.value.id) { for (let i = 0; i < addressDatas.value.length; i++) { if (addressDatas.value[i].id === addressInfo.value.id) { addressDatas.value[i] = addressInfo.value; tip = "编辑"; } } } else { addressInfo.value = { ...addressInfo.value, id: v4() }; addressDatas.value.push(addressInfo.value); } showToast("对接配置" + tip + "成功,保存后生效"); addressAction.value = false; addressInfo.value = {}; } function handleAdd(addType) { if (addType === "wifi") { wifiTitle.value = "添加WIFI配置"; wifiAction.value = true; } else { addressTitle.value = "添加对接配置"; addressAction.value = true; } } function handleEdit(editType, record) { if (editType === "wifi") { wifiInfo.value = { ...record }; wifiTitle.value = "编辑WIFI配置"; wifiAction.value = true; } else { addressInfo.value = { ...record }; addressTitle.value = "编辑对接配置"; addressAction.value = true; } } function handleDel(record, delType) { if (delType === "wifi") { showConfirmDialog({ title: "提示", message: "是否删除" + record.name + "?" }).then(() => { wifiDatas.value = wifiDatas.value.filter( (obj) => obj.id != record.id ); }).catch(() => { console.log("删除WFIFI方法关闭..."); }); } else { showConfirmDialog({ title: "提示", message: "是否删除" + record.address + "对接配置?" }).then(() => { addressDatas.value = addressDatas.value.filter( (obj) => obj.id != record.id ); }).catch(() => { console.log("删除WFIFI方法关闭..."); }); } } onMounted(() => { getWifiInfo(); }); function getWifiInfo() { if (userInfo && userInfo.id) { post_promise({ url: "/userConfig/detailById", data: { id: userInfo.id } }).then((result) => { var _a; console.log("result::::", result); if (result && result.data) { formData.value = result.data; wifiDatas.value = JSON.parse(result.data.wifi); addressDatas.value = JSON.parse(result.data.address); (_a = addressDatas == null ? void 0 : addressDatas.value) == null ? void 0 : _a.forEach((item) => { switch (item.platform) { case "1": item.platform = "阿里云"; break; case "2": item.platform = "驼人"; break; case "3": item.platform = "本地"; break; } }); } }).catch((err) => { console.log("err:::", err); }); } } return (_ctx, _cache) => { const _component_van_field = Field; const _component_van_cell = Cell; const _component_van_cell_group = CellGroup; const _component_van_button = Button; const _component_van_form = Form; const _component_van_icon = Icon; const _component_van_back_top = BackTop; const _component_van_action_sheet = ActionSheet; const _component_van_picker = Picker; const _component_van_popup = Popup; return openBlock(), createElementBlock(Fragment, null, [ createBaseVNode("div", _hoisted_1, [ createVNode(unref(CusNavigation), { ref_key: "cusNavigation", ref: cusNavigation, gobackabled: "", title: "WIFI配置" }, null, 512), createBaseVNode("div", _hoisted_2, [ _cache[23] || (_cache[23] = createBaseVNode("div", { class: "title" }, "医院配置", -1)), createBaseVNode("div", _hoisted_3, [ createVNode(_component_van_form, { onSubmit }, { default: withCtx(() => [ createVNode(_component_van_cell_group, { inset: "" }, { default: withCtx(() => [ createVNode(_component_van_cell, null, { default: withCtx(() => [ createVNode(_component_van_field, { modelValue: formData.value.deviceSecret, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formData.value.deviceSecret = $event), name: "deviceSecret", label: "密钥", placeholder: "请填写密钥配置" }, null, 8, ["modelValue"]) ]), _: 1 }) ]), _: 1 }), createBaseVNode("div", _hoisted_4, [ createVNode(_component_van_button, { round: "", block: "", type: "primary", "native-type": "submit" }, { default: withCtx(() => _cache[20] || (_cache[20] = [ createTextVNode(" 提交 ") ])), _: 1 }) ]) ]), _: 1 }) ]), createBaseVNode("div", _hoisted_5, [ _cache[21] || (_cache[21] = createTextVNode(" 对接配置 ")), createBaseVNode("div", null, [ createBaseVNode("a", { onClick: _cache[1] || (_cache[1] = ($event) => handleAdd("address")), style: { "margin-left": "20px" } }, "添加配置") ]) ]), createBaseVNode("div", _hoisted_6, [ (openBlock(true), createElementBlock(Fragment, null, renderList(addressDatas.value, (item, index2) => { return openBlock(), createElementBlock("div", { class: "wifi-info", style: {}, key: index2 }, [ createVNode(_component_van_icon, { "class-prefix": "iconfont", name: item.networkType, size: 46 }, null, 8, ["name"]), createVNode(_component_van_cell, { title: item.platform === "阿里云" ? item.productKey : item.address + ":" + item.port, label: item.platform, style: { "margin": "0.625rem 0 0 1rem" } }, { default: withCtx(() => [ createVNode(_component_van_button, { plain: "", hairline: "", size: "small", text: "编辑", onClick: ($event) => handleEdit("address", item), type: "primary" }, null, 8, ["onClick"]), createVNode(_component_van_button, { size: "small", plain: "", hairline: "", text: "删除", type: "danger", onClick: ($event) => handleDel(item, "address"), class: "delete-button" }, null, 8, ["onClick"]) ]), _: 2 }, 1032, ["title", "label"]) ]); }), 128)) ]), createBaseVNode("div", _hoisted_7, [ _cache[22] || (_cache[22] = createTextVNode(" WIFI配置 ")), createBaseVNode("div", null, [ createBaseVNode("a", { onClick: _cache[2] || (_cache[2] = ($event) => handleAdd("wifi")), style: { "margin-left": "20px" } }, "添加网络") ]) ]), createBaseVNode("div", _hoisted_8, [ (openBlock(true), createElementBlock(Fragment, null, renderList(wifiDatas.value, (item, index2) => { return openBlock(), createElementBlock("div", { class: "wifi-info", style: {}, key: index2 }, [ createVNode(_component_van_icon, { "class-prefix": "iconfont", name: "WIFIE", size: 46 }), createVNode(_component_van_cell, { title: item.name, label: item.password, "title-class": "wifi-name", style: { "margin": "0.625rem 0 0 1rem" } }, { default: withCtx(() => [ createVNode(_component_van_button, { plain: "", hairline: "", size: "small", text: "编辑", onClick: ($event) => handleEdit("wifi", item), type: "primary" }, null, 8, ["onClick"]), createVNode(_component_van_button, { size: "small", plain: "", hairline: "", text: "删除", type: "danger", onClick: ($event) => handleDel(item, "wifi"), class: "delete-button" }, null, 8, ["onClick"]) ]), _: 2 }, 1032, ["title", "label"]) ]); }), 128)) ]) ]), createBaseVNode("div", _hoisted_9, [ createVNode(_component_van_back_top, { target: ".container", right: "5vw", bottom: "80px" }) ]) ]), wifiAction.value ? (openBlock(), createBlock(_component_van_action_sheet, { key: 0, show: wifiAction.value, "onUpdate:show": _cache[5] || (_cache[5] = ($event) => wifiAction.value = $event), title: wifiTitle.value, onCancel: _cache[6] || (_cache[6] = ($event) => handleCancel("wifi")), "close-on-click-overlay": false }, { default: withCtx(() => [ createBaseVNode("div", _hoisted_10, [ createVNode(_component_van_form, { onSubmit: onWifiSubmit }, { default: withCtx(() => [ createVNode(_component_van_cell_group, { inset: "" }, { default: withCtx(() => [ createVNode(_component_van_cell, null, { default: withCtx(() => [ createVNode(_component_van_field, { modelValue: wifiInfo.value.name, "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => wifiInfo.value.name = $event), name: "name", label: "名称", onBlur: handleBlur, placeholder: "请输入WIFI名称", rules: [ { required: true, message: "请输入WIFI名称" }, { validator: validator20, message: "WIFI名称不得大于8位" } ] }, null, 8, ["modelValue", "rules"]) ]), _: 1 }), createVNode(_component_van_cell, null, { default: withCtx(() => [ createVNode(_component_van_field, { modelValue: wifiInfo.value.password, "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => wifiInfo.value.password = $event), name: "password", label: "密码", placeholder: "请填写WIFI密码", rules: [ { validator: validator20, message: "WIFI密码不得大于20位" } ] }, null, 8, ["modelValue", "rules"]) ]), _: 1 }) ]), _: 1 }), createBaseVNode("div", _hoisted_11, [ createVNode(_component_van_button, { round: "", block: "", type: "primary", "native-type": "submit" }, { default: withCtx(() => _cache[24] || (_cache[24] = [ createTextVNode(" 确认 ") ])), _: 1 }) ]) ]), _: 1 }) ]) ]), _: 1 }, 8, ["show", "title"])) : createCommentVNode("", true), addressAction.value ? (openBlock(), createBlock(_component_van_action_sheet, { key: 1, show: addressAction.value, "onUpdate:show": _cache[18] || (_cache[18] = ($event) => addressAction.value = $event), title: addressTitle.value, onCancel: _cache[19] || (_cache[19] = ($event) => handleCancel("address")), "close-on-click-overlay": false }, { default: withCtx(() => [ createBaseVNode("div", _hoisted_12, [ createVNode(_component_van_form, { onSubmit: onAddressSubmit }, { default: withCtx(() => [ createVNode(_component_van_cell_group, { inset: "" }, { default: withCtx(() => [ createVNode(_component_van_cell, null, { default: withCtx(() => [ createVNode(_component_van_field, { modelValue: addressInfo.value.networkType, "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => addressInfo.value.networkType = $event), name: "networkType ", label: "对接类型", placeholder: "请选择对接类型", onClick: _cache[8] || (_cache[8] = ($event) => showPicker.value = true), rules: [{ required: true, message: "请选择对接类型" }] }, null, 8, ["modelValue"]), createVNode(_component_van_popup, { show: showPicker.value, "onUpdate:show": _cache[10] || (_cache[10] = ($event) => showPicker.value = $event), round: "", position: "bottom" }, { default: withCtx(() => [ createVNode(_component_van_picker, { columns: unref(selColumns), onCancel: _cache[9] || (_cache[9] = ($event) => showPicker.value = false), onConfirm }, null, 8, ["columns"]) ]), _: 1 }, 8, ["show"]) ]), _: 1 }), createVNode(_component_van_cell, null, { default: withCtx(() => [ createVNode(_component_van_field, { modelValue: addressInfo.value.platform, "onUpdate:modelValue": _cache[11] || (_cache[11] = ($event) => addressInfo.value.platform = $event), name: "platform ", label: "对接平台", placeholder: "请选择对接平台", onClick: _cache[12] || (_cache[12] = ($event) => showPlatfromPicker.value = true) }, null, 8, ["modelValue"]), createVNode(_component_van_popup, { show: showPlatfromPicker.value, "onUpdate:show": _cache[14] || (_cache[14] = ($event) => showPlatfromPicker.value = $event), round: "", position: "bottom" }, { default: withCtx(() => [ createVNode(_component_van_picker, { columns: unref(platformColumns), onCancel: _cache[13] || (_cache[13] = ($event) => showPlatfromPicker.value = false), onConfirm: onConfirmPlatfrom }, null, 8, ["columns"]) ]), _: 1 }, 8, ["show"]) ]), _: 1 }), createVNode(_component_van_cell, null, { default: withCtx(() => [ addressInfo.value.platform === "阿里云" ? (openBlock(), createBlock(_component_van_field, { key: 0, modelValue: addressInfo.value.productKey, "onUpdate:modelValue": _cache[15] || (_cache[15] = ($event) => addressInfo.value.productKey = $event), name: "productKey", label: "产品编码", placeholder: "请输入产品编码", rules: [{ required: true, message: "请输入产品编码" }] }, null, 8, ["modelValue"])) : (openBlock(), createBlock(_component_van_field, { key: 1, modelValue: addressInfo.value.address, "onUpdate:modelValue": _cache[16] || (_cache[16] = ($event) => addressInfo.value.address = $event), name: "address", label: "对接地址", placeholder: "请输入对接地址", rules: [{ required: true, message: "请输入对接地址" }] }, null, 8, ["modelValue"])) ]), _: 1 }), createVNode(_component_van_cell, null, { default: withCtx(() => [ createVNode(_component_van_field, { modelValue: addressInfo.value.port, "onUpdate:modelValue": _cache[17] || (_cache[17] = ($event) => addressInfo.value.port = $event), name: "port", label: "对接端口", placeholder: "请输入对接端口", rules: [{ required: true, message: "请输入对接端口" }] }, null, 8, ["modelValue"]) ]), _: 1 }) ]), _: 1 }), createBaseVNode("div", _hoisted_13, [ createVNode(_component_van_button, { round: "", block: "", type: "primary", "native-type": "submit" }, { default: withCtx(() => _cache[25] || (_cache[25] = [ createTextVNode(" 确认 ") ])), _: 1 }) ]) ]), _: 1 }) ]) ]), _: 1 }, 8, ["show", "title"])) : createCommentVNode("", true) ], 64); }; } }); const Index_vue_vue_type_style_index_0_lang = ""; export { _sfc_main as default };