import { n as e, r as t } from "./component-AqiMonitor-DoGm_NCt.mjs";
import { Fragment as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, getCurrentInstance as s, onMounted as c, openBlock as l, ref as u, renderList as d, toDisplayString as f, withModifiers as p } from "vue";
//#region src/components/ServiceMaterial/ServiceMaterial.vue?vue&type=script&setup=true&lang.ts
var m = { class: "ServiceMaterial" }, h = { class: "ServiceMaterial__head" }, g = { class: "ServiceMaterial__head-top" }, _ = { class: "ServiceMaterial__body" }, v = { class: "ServiceMaterial__list" }, y = { class: "ServiceMaterial__list-container" }, b = { class: "ServiceMaterial__list-content" }, x = { class: "ServiceMaterial__list-col ServiceMaterial__list-col--name" }, S = ["title"], C = { class: "ServiceMaterial__list-col ServiceMaterial__list-col--time" }, w = { class: "ServiceMaterial__list-col ServiceMaterial__list-col--action" }, T = ["onClick"], E = ["onClick"], D = {
	key: 0,
	class: "ServiceMaterial__empty"
}, O = { class: "ServiceMaterial__list-footer" }, k = { class: "ServiceMaterial__total" }, A = /* @__PURE__ */ e(/* @__PURE__ */ o({
	__name: "ServiceMaterial",
	props: {
		appKey: {
			type: String,
			default: ""
		},
		appSalt: {
			type: String,
			default: ""
		},
		baseHttp: {
			type: String,
			default: ""
		},
		ids: {
			type: Object,
			default: () => ({})
		},
		title: {
			type: String,
			default: "服务材料制作"
		}
	},
	emits: [
		"close",
		"preview",
		"download"
	],
	setup(e, { emit: o }) {
		let A = s()?.appContext.config.globalProperties.$bus, j = e, M = o, N = u(!1), P = u([]);
		c(() => {
			A?.on("toComponent", (e) => {
				e.componentName === "ServiceMaterial" && F();
			}), F();
		});
		let F = async () => {
			await I();
		}, I = async () => {
			if (j.ids.data?.id) {
				N.value = !0;
				try {
					let e = await t({
						appKey: j.appKey,
						appSalt: j.appSalt,
						id: j.ids.data.id,
						variables: {},
						baseHttp: j.baseHttp,
						reqType: j.ids.data.reqType,
						isFormData: j.ids.data.isFormData
					});
					console.log(e, "服务材料数据");
					let n = e.data?.result?.output || [];
					Array.isArray(n) && n.length > 0 && (P.value = n.map((e) => ({
						id: e.id || e.file_id,
						name: e.name || e.file_name || e.title || "",
						createTime: e.createTime || e.create_time || e.created_at || "",
						fileUrl: e.fileUrl || e.file_url || e.url || "#",
						previewUrl: e.previewUrl || e.preview_url || e.url || "#"
					})));
				} catch (e) {
					console.error("获取服务材料失败:", e);
				} finally {
					N.value = !1;
				}
			}
		}, L = (e) => {
			M("preview", e), window.open(e.previewUrl, "_blank");
		}, R = (e) => {
			M("download", e), window.location.href = e.fileUrl;
		}, z = () => {
			window.open("http://58.213.50.38:9192/AICloud-user/#/chatAssistant?account=admin&password=123456", "_blank");
		}, B = () => {
			M("close", "ServiceMaterial");
		};
		return (t, o) => (l(), i("div", m, [a("div", h, [a("div", g, [a("div", null, f(e.title), 1), a("div", {
			class: "closeBtn",
			onClick: B,
			title: "关闭"
		})]), o[0] ||= a("img", {
			class: "ServiceMaterial__head-line",
			src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbsAAAASBAMAAAAwI22/AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAwUExURQAAAAem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/5bu5GYAAAAPdFJOUwAFwAwc2M8ULQYDn/hGXGnV2UoAAAGZSURBVEjH7ZM/S8NAGId/JYGmmeLspptThurk0CHWRXGo0Nk/S50y6CYSHMRF7Efo4uQXEIpbwUnM6OhnEIeChXjv5ZLLXdLtLCX68vDCe0eGJ7/3AJN1VcL+UImB/SruVJwYTqSAW5V3LLyaPR1c+IIdH12OPZiLcyTAjccZEdccZ0Nn4bXpC3KpCuFu5tkdziX3FJxBSBZZdFk9HempCduMk4xSitJTpOgJSSIPrx10YAUB0tYOwrQ1g12k7ZyODIYXZmQpppLV26rtbDFOXVhua2Fn7WTWwUEyAe5Zc2hiLWTTC3jjk8Hw+jrSM9/Z8raKOAtZVmyr9jbpee4lU9hvSUStw6YvOpqwiXlK9d8IL0Oq5tuqvc3KLMs7q9uyCC0y22aKvDVp4u2SjnJ1c+Wecg7h9gV4CFV8NHpEaw7yF2wVGcIa6OBx/Ax3PI6pRWx6Am98alBbpSODNVTxgAbQUpF3KeVv0s80xMUow8N//YVaqWEV9BJDdby2PBUZ1/te0uU0YzeLa623jjrrvaLOep/+str9ACyAtv25BhHcAAAAAElFTkSuQmCC",
			alt: ""
		}, null, -1)]), a("div", _, [a("div", v, [a("div", y, [
			o[1] ||= a("div", { class: "ServiceMaterial__list-header" }, [
				a("div", { class: "ServiceMaterial__list-col ServiceMaterial__list-col--name" }, "材料名称"),
				a("div", { class: "ServiceMaterial__list-col ServiceMaterial__list-col--time" }, "制作时间"),
				a("div", { class: "ServiceMaterial__list-col ServiceMaterial__list-col--action" }, "操作")
			], -1),
			a("div", b, [(l(!0), i(n, null, d(P.value, (e) => (l(), i("div", {
				key: e.id,
				class: "ServiceMaterial__list-row"
			}, [
				a("div", x, [a("span", {
					class: "ServiceMaterial__file-name",
					title: e.name
				}, f(e.name), 9, S)]),
				a("div", C, f(e.createTime), 1),
				a("div", w, [a("span", {
					class: "ServiceMaterial__link",
					onClick: p((t) => L(e), ["stop"])
				}, "预览", 8, T), a("span", {
					class: "ServiceMaterial__link",
					onClick: p((t) => R(e), ["stop"])
				}, "下载", 8, E)])
			]))), 128)), !P.value || !P.value.length ? (l(), i("div", D, "暂无数据")) : r("", !0)]),
			a("div", O, [a("span", k, "共 " + f(P.value.length) + " 份服务材料", 1), a("span", {
				class: "ServiceMaterial__create-btn",
				onClick: z
			}, "去制作")])
		])])])]));
	}
}), [["__scopeId", "data-v-9798930e"]]);
//#endregion
export { A as t };
