import { d as defineComponent, r as ref, n as reactive, o as onMounted, a as computed, b as createElementBlock, e as createBaseVNode, c as createVNode, t as toDisplayString, F as Fragment, x as renderList, C as createCommentVNode, f as withCtx, h as withDirectives, v as vShow, u as useRouter, j as openBlock, k as createBlock, s as createTextVNode, _ as _export_sfc } from "./index-5e4623ce.js"; import { Q as QRScreen, S as Stepper } from "./Index-847fa614.js"; import { B as Button } from "./index-b1054607.js"; import { S as SwipeCell } from "./index-73d5a905.js"; import { C as CellGroup } from "./index-3a8cf159.js"; import { C as Cell } from "./index-8540448e.js"; import { p as post } from "./request-76e4192b.js"; import { s as stdin_default, a as showConfirmDialog } from "./index-fefbbdb7.js"; import { w as withInstall, I as Icon } from "./index-487cde8c.js"; import { O as Overlay } from "./index-eef3af38.js"; import { s as showToast } from "./function-call-dc072a29.js"; import { L as Loading } from "./index-217c49a0.js"; import "./on-popup-reopen-c5ca1603.js"; import "./use-route-726f0d0b.js"; import "./use-scope-id-0b5b8615.js"; import "./axios-8cd254ce.js"; import "./mount-component-2b0f7b23.js"; import "./use-placeholder-16d7c5d7.js"; withInstall(stdin_default); const _hoisted_1 = { style: { "display": "flex", "flex-direction": "column", "height": "100vh" } }; const _hoisted_2 = { style: { "border-bottom": "1px solid #eee", "padding": "20px 16px 10px 16px" } }; const _hoisted_3 = { style: { "opacity": "0.5" } }; const _hoisted_4 = { key: 0, style: { "color": "red" } }; const _hoisted_5 = { key: 1 }; const _hoisted_6 = { key: 0, style: { "color": "red" } }; const _hoisted_7 = { key: 1 }; const _hoisted_8 = { style: { "flex-grow": "1", "overflow-y": "auto" } }; const _hoisted_9 = { key: 0 }; const _hoisted_10 = { style: { "color": "#aaa", "display": "flex", "align-items": "center", "justify-content": "center", "padding": "40px 0px 0px 0px" } }; const _hoisted_11 = { key: 1, class: "scanlist" }; const _hoisted_12 = { style: { "text-align": "left" } }; const _hoisted_13 = { style: { "display": "flex", "flex-direction": "column", "justify-content": "space-between", "flex-grow": "1", "overflow-x": "hidden", "word-break": "break-all" } }; const _hoisted_14 = { style: { "width": "100%" } }; const _hoisted_15 = { style: { "display": "flex", "justify-content": "space-between" } }; const _hoisted_16 = { style: { "font-size": "16px", "color": "#000", "font-weight": "bold" } }; const _hoisted_17 = { style: { "font-size": "16px" } }; const _hoisted_18 = { style: { "display": "flex", "justify-content": "space-between" } }; const _hoisted_19 = { style: { "color": "blue" } }; const _hoisted_20 = { style: { "margin-left": "3px", "font-weight": "bold" } }; const _hoisted_21 = ["onClick"]; const _hoisted_22 = { key: 0, style: { "border-top": "1px solid #eee", "padding": "10px 16px" } }; const _hoisted_23 = { style: { "padding": "0px 16px", "display": "flex", "justify-content": "flex-end", "align-items": "center" } }; const _hoisted_24 = { style: { "display": "inline-block", "text-align": "right", "margin-left": "6px", "color": "red", "font-size": "24px", "font-weight": "bold" } }; const _hoisted_25 = { style: { "padding": "0px 16px" } }; const _hoisted_26 = { style: { "position": "absolute", "width": "100vw", "height": "100vh", "top": "0", "left": "0", "z-index": "99", "background-color": "#ccc" } }; const _hoisted_27 = { style: { "height": "100%", "width": "100%", "display": "flex", "align-items": "center", "justify-content": "center" } }; const _hoisted_28 = { style: { "height": "60%", "width": "80%", "background-color": "#ffffff", "display": "flex", "flex-direction": "column" } }; const _hoisted_29 = { style: { "flex-grow": "1", "overflow-y": "auto", "word-break": "break-all", "padding": "10px 16px 16px 16px" } }; const _hoisted_30 = { style: { "padding-right": "16px" } }; const _hoisted_31 = { key: 0, style: { "display": "flex", "align-items": "center", "justify-content": "center", "margin-top": "30px" } }; const _hoisted_32 = { key: 1 }; const _hoisted_33 = { style: { "margin-top": "10px" } }; const _hoisted_34 = { style: { "margin-top": "10px" } }; const _hoisted_35 = { style: { "margin-top": "10px" } }; const _hoisted_36 = { style: { "margin-top": "10px" } }; const _hoisted_37 = { style: { "margin-top": "10px" } }; const _hoisted_38 = { style: { "margin-top": "10px" } }; const _hoisted_39 = { style: { "margin-top": "10px" } }; const _hoisted_40 = { style: { "margin-top": "10px" } }; const _hoisted_41 = { style: { "border-top": "1px solid #eee", "border-bottom": "1px solid #eee", "padding": "8px 0px 6px 0px" } }; const _hoisted_42 = { style: { "display": "flex", "align-items": "center", "justify-content": "flex-end" } }; const _hoisted_43 = { style: { "padding-right": "16px" } }; const _hoisted_44 = { style: { "padding": "0px 16px" } }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "Index", setup(__props) { const router = useRouter(); const show = ref(false); const scanQR = ref(); const customer = reactive({ isAnonymous: true, name: "", mobile: "" }); const scan_list = ref([]); const scan_result_show = ref(false); const isLoading = ref(false); const scan_content = reactive({ scan_result: "", registCode: "", register: "", id: "", physicType: "", name: "", typeName: "", validDate: "", concent: "", amount: 1 }); onMounted(() => { const query = router.currentRoute.value.query; customer.isAnonymous = query.isAnonymous == "true" ? true : false; customer.name = query.name; customer.mobile = query.mobile; console.log(router.currentRoute.value.query); }); const clickCell = (event) => { console.log("clickCell", event.id); let ind = -1; for (let i = 0; i < scan_list.value.length; i++) { if (scan_list.value[i].id == event.id) { ind = i; break; } } console.log(ind); if (ind >= 0) { Object.assign(scan_content, scan_list.value[ind]); scan_result_show.value = true; } }; const deleteCell = (event) => { console.log("deleteCell", event.id); showConfirmDialog({ message: "确定删除吗?" }).then(() => { console.log(event.id); let ind = -1; for (let i = 0; i < scan_list.value.length; i++) { if (scan_list.value[i].id == event.id) { ind = i; break; } } console.log(ind); if (ind >= 0) { scan_list.value.splice(ind, 1); } }, () => { console.log("取消"); }); }; const clickScan = () => { console.log("clickScan"); show.value = true; scanQR.value.open(); }; const submit = () => { console.log("submit"); console.log("提交"); const formData = []; for (let i = 0; i < scan_list.value.length; i++) { const item = scan_list.value[i]; const formItem = {}; formItem.info = item.scan_result; formItem.num = item.amount; formItem.pesticideName = item.name; formItem.pesticideRegistCode = item.registCode; formItem.clientName = customer.name; formItem.clientPhone = customer.mobile; formItem.realnameFlag = customer.isAnonymous ? 0 : 1; formData[i] = formItem; } console.log(formData); if (formData.length == 0) { showToast("列表不能为空"); return; } showConfirmDialog({ message: "确定提交吗?" }).then(() => { post("/saleRecord/batchAddRecord", formData).then(({ data }) => { console.log(data); if (data.code == 0) { showToast("提交成功"); setTimeout(() => { router.push("/"); }, 500); } else { showToast(data.msg); } }); }, () => { console.log("取消"); }); }; const total = computed(() => { let sum = 0; for (let i = 0; i < scan_list.value.length; i++) { sum += scan_list.value[i].amount; } return sum; }); const scanSuccess = (e) => { show.value = false; console.log(e); scan_content.scan_result = e.decodedText; getPesticideInfo(scan_content.scan_result); }; const getPesticideInfo = (scan_result) => { post("/pesticide/getPesticideInfo", { scanResult: scan_result }).then(({ data }) => { console.log(data); if (data.code == 0) { const result = data.data; Object.assign(scan_content, result); scan_result_show.value = true; scan_content.amount = 1; return; } }); }; const cancel = () => { console.log("取消"); scan_result_show.value = false; }; const confirm = (event) => { console.log("添加", scan_content); console.log(event); let ind = -1; for (let i = 0; i < scan_list.value.length; i++) { if (scan_list.value[i].id == scan_content.id) { ind = i; break; } } const item = Object.assign({}, scan_content); if (ind >= 0) { scan_list.value[ind] = item; } else { scan_list.value.push(item); } console.log(scan_list.value); scan_result_show.value = false; }; return (_ctx, _cache) => { const _component_van_icon = Icon; const _component_van_cell = Cell; const _component_van_cell_group = CellGroup; const _component_van_swipe_cell = SwipeCell; const _component_van_button = Button; const _component_van_loading = Loading; const _component_van_stepper = Stepper; const _component_van_overlay = Overlay; return openBlock(), createElementBlock(Fragment, null, [ createBaseVNode("div", _hoisted_1, [ createBaseVNode("div", _hoisted_2, [ createBaseVNode("div", _hoisted_3, [ createBaseVNode("div", null, [ createVNode(_component_van_icon, { name: "user-o" }), _cache[1] || (_cache[1] = createBaseVNode("span", { style: { "margin-left": "6px" } }, "姓 名: ", -1)), customer.isAnonymous ? (openBlock(), createElementBlock("span", _hoisted_4, "匿名")) : (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(customer.name), 1)) ]), createBaseVNode("div", null, [ createVNode(_component_van_icon, { name: "phone-o" }), _cache[2] || (_cache[2] = createBaseVNode("span", { style: { "margin-left": "6px" } }, "手机号: ", -1)), customer.isAnonymous ? (openBlock(), createElementBlock("span", _hoisted_6, "匿名")) : (openBlock(), createElementBlock("span", _hoisted_7, toDisplayString(customer.mobile), 1)) ]) ]) ]), _cache[10] || (_cache[10] = createBaseVNode("div", { style: { "height": "10px" } }, null, -1)), createBaseVNode("div", _hoisted_8, [ scan_list.value.length == 0 ? (openBlock(), createElementBlock("div", _hoisted_9, [ createBaseVNode("div", _hoisted_10, [ createVNode(_component_van_icon, { name: "warning-o", size: "20" }), _cache[3] || (_cache[3] = createBaseVNode("span", { style: { "margin-left": "6px" } }, "暂无扫码结果", -1)) ]) ])) : (openBlock(), createElementBlock("div", _hoisted_11, [ (openBlock(true), createElementBlock(Fragment, null, renderList(scan_list.value, (item) => { return openBlock(), createBlock(_component_van_swipe_cell, { name: item.id, "right-width": "65" }, { right: withCtx(() => [ createBaseVNode("div", { style: { "background-color": "red", "height": "100%", "width": "65px", "color": "#ffffff", "display": "flex", "align-items": "center", "justify-content": "center" }, onClick: ($event) => deleteCell(item) }, _cache[4] || (_cache[4] = [ createBaseVNode("div", null, "删除", -1) ]), 8, _hoisted_21) ]), default: withCtx(() => [ createVNode(_component_van_cell_group, { border: false }, { default: withCtx(() => [ createVNode(_component_van_cell, { onClick: ($event) => clickCell(item) }, { default: withCtx(() => [ createBaseVNode("div", _hoisted_12, [ createBaseVNode("div", _hoisted_13, [ createBaseVNode("div", _hoisted_14, [ createBaseVNode("div", _hoisted_15, [ createBaseVNode("div", _hoisted_16, toDisplayString(item.name), 1), createBaseVNode("div", _hoisted_17, toDisplayString(item.typeName), 1) ]), createBaseVNode("div", null, toDisplayString(item.register), 1) ]), createBaseVNode("div", _hoisted_18, [ createBaseVNode("div", null, toDisplayString(item.registCode), 1), createBaseVNode("div", _hoisted_19, [ createVNode(_component_van_icon, { name: "cross", size: "10" }), createBaseVNode("span", _hoisted_20, toDisplayString(item.amount), 1) ]) ]) ]) ]) ]), _: 2 }, 1032, ["onClick"]) ]), _: 2 }, 1024) ]), _: 2 }, 1032, ["name"]); }), 256)) ])) ]), _cache[11] || (_cache[11] = createBaseVNode("div", { style: { "height": "0px" } }, null, -1)), scan_list.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_22, [ createBaseVNode("div", _hoisted_23, [ _cache[5] || (_cache[5] = createBaseVNode("div", null, [ createBaseVNode("span", { style: { "margin-left": "3px" } }, "总计:") ], -1)), createBaseVNode("span", _hoisted_24, toDisplayString(total.value), 1) ]) ])) : createCommentVNode("", true), _cache[12] || (_cache[12] = createBaseVNode("div", { style: { "height": "0px" } }, null, -1)), createBaseVNode("div", _hoisted_25, [ createVNode(_component_van_button, { color: "#4fc08d", type: "primary", round: "", block: "", size: "large", icon: "scan", onClick: clickScan }, { default: withCtx(() => _cache[6] || (_cache[6] = [ createTextVNode("扫描二维码") ])), _: 1 }), _cache[8] || (_cache[8] = createBaseVNode("div", { style: { "height": "10px" } }, null, -1)), createVNode(_component_van_button, { type: "primary", round: "", block: "", size: "large", icon: "guide-o", onClick: submit }, { default: withCtx(() => _cache[7] || (_cache[7] = [ createTextVNode("提交结果") ])), _: 1 }), _cache[9] || (_cache[9] = createBaseVNode("div", { style: { "height": "10px" } }, null, -1)) ]) ]), withDirectives(createBaseVNode("div", _hoisted_26, [ createVNode(QRScreen, { ref_key: "scanQR", ref: scanQR, onSuccess: scanSuccess }, null, 512) ], 512), [ [vShow, show.value] ]), createVNode(_component_van_overlay, { "lock-scroll": false, show: scan_result_show.value }, { default: withCtx(() => [ createBaseVNode("div", _hoisted_27, [ createBaseVNode("div", _hoisted_28, [ _cache[28] || (_cache[28] = createBaseVNode("div", { style: { "height": "16px" } }, null, -1)), createBaseVNode("div", _hoisted_29, [ createBaseVNode("div", _hoisted_30, [ createBaseVNode("div", null, [ _cache[13] || (_cache[13] = createBaseVNode("span", { style: { "font-weight": "bold" } }, "扫描结果: ", -1)), createBaseVNode("span", null, toDisplayString(scan_content.scan_result), 1) ]), isLoading.value ? (openBlock(), createElementBlock("div", _hoisted_31, [ _cache[14] || (_cache[14] = createBaseVNode("div", { style: { "margin-right": "6px" } }, [ createBaseVNode("span", { style: {} }, "农药信息加载中") ], -1)), createBaseVNode("div", null, [ createVNode(_component_van_loading, { type: "spinner", color: "#1989fa" }) ]) ])) : (openBlock(), createElementBlock("div", _hoisted_32, [ createBaseVNode("div", _hoisted_33, [ _cache[15] || (_cache[15] = createBaseVNode("span", { style: { "font-weight": "bold" } }, "单元识别码: ", -1)), createBaseVNode("span", null, toDisplayString(scan_content.id), 1) ]), createBaseVNode("div", _hoisted_34, [ _cache[16] || (_cache[16] = createBaseVNode("span", { style: { "font-weight": "bold" } }, "登记证号: ", -1)), createBaseVNode("span", null, toDisplayString(scan_content.registCode), 1) ]), createBaseVNode("div", _hoisted_35, [ _cache[17] || (_cache[17] = createBaseVNode("span", { style: { "font-weight": "bold" } }, "农药名称: ", -1)), createBaseVNode("span", null, toDisplayString(scan_content.name), 1) ]), createBaseVNode("div", _hoisted_36, [ _cache[18] || (_cache[18] = createBaseVNode("span", { style: { "font-weight": "bold" } }, "农药类别: ", -1)), createBaseVNode("span", null, toDisplayString(scan_content.typeName), 1) ]), createBaseVNode("div", _hoisted_37, [ _cache[19] || (_cache[19] = createBaseVNode("span", { style: { "font-weight": "bold" } }, "剂型: ", -1)), createBaseVNode("span", null, toDisplayString(scan_content.physicType), 1) ]), createBaseVNode("div", _hoisted_38, [ _cache[20] || (_cache[20] = createBaseVNode("span", { style: { "font-weight": "bold" } }, "总含量: ", -1)), createBaseVNode("span", null, toDisplayString(scan_content.concent), 1) ]), createBaseVNode("div", _hoisted_39, [ _cache[21] || (_cache[21] = createBaseVNode("span", { style: { "font-weight": "bold" } }, "有效期至: ", -1)), createBaseVNode("span", null, toDisplayString(scan_content.validDate), 1) ]), createBaseVNode("div", _hoisted_40, [ _cache[22] || (_cache[22] = createBaseVNode("span", { style: { "font-weight": "bold" } }, "登记证持有人: ", -1)), createBaseVNode("span", null, toDisplayString(scan_content.register), 1) ]) ])) ]) ]), _cache[29] || (_cache[29] = createBaseVNode("div", { style: { "height": "10px" } }, null, -1)), createBaseVNode("div", _hoisted_41, [ createBaseVNode("div", _hoisted_42, [ _cache[23] || (_cache[23] = createBaseVNode("div", { style: { "margin": "0px 10px 0px 16px" } }, [ createBaseVNode("span", { style: { "color": "red" } }, "*"), createBaseVNode("span", null, "  数量:") ], -1)), createBaseVNode("div", _hoisted_43, [ createVNode(_component_van_stepper, { integer: "", modelValue: scan_content.amount, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => scan_content.amount = $event), "input-width": "60px", theme: "round", disabled: customer.isAnonymous }, null, 8, ["modelValue", "disabled"]) ]) ]) ]), _cache[30] || (_cache[30] = createBaseVNode("div", { style: { "height": "20px" } }, null, -1)), createBaseVNode("div", _hoisted_44, [ createVNode(_component_van_button, { color: "#e87f5e", type: "danger", round: "", block: "", size: "normal", icon: "close", onClick: cancel }, { default: withCtx(() => _cache[24] || (_cache[24] = [ createTextVNode("取消") ])), _: 1 }), _cache[26] || (_cache[26] = createBaseVNode("div", { style: { "height": "10px" } }, null, -1)), createVNode(_component_van_button, { color: "#4fc08d", type: "primary", round: "", block: "", size: "normal", icon: "passed", onClick: confirm }, { default: withCtx(() => _cache[25] || (_cache[25] = [ createTextVNode("添加") ])), _: 1 }), _cache[27] || (_cache[27] = createBaseVNode("div", { style: { "height": "10px" } }, null, -1)) ]) ]) ]) ]), _: 1 }, 8, ["show"]) ], 64); }; } }); const Index_vue_vue_type_style_index_0_scoped_1d96855a_lang = ""; const Index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1d96855a"]]); export { Index as default };