"use strict"; const common_vendor = require("../../../common/vendor.js"); const api_system_complaint = require("../../../api/system/complaint.js"); const api_system_dict = require("../../../api/system/dict.js"); const api_resource_oss = require("../../../api/resource/oss.js"); const ErpNavBar = () => "../../../components/erp-nav-bar.js"; const _sfc_main = { components: { ErpNavBar }, data() { return { types: [], uploading: false, imageOssMap: [], formData: { type: "", content: "", images: [] } }; }, computed: { isFormValid() { return !this.uploading && this.formData.type && this.formData.content && this.formData.content.trim().length >= 5; } }, onLoad() { this.loadTypes(); }, methods: { async loadTypes() { try { const res = await api_system_dict.getDictByType("sys_complaint_type"); if (res && res.data) { this.types = res.data.map((d) => ({ label: d.dictLabel, value: d.dictValue })); if (this.types.length) this.formData.type = this.types[0].value; } } catch (e) { this.types = [ { label: "系统投诉", value: "complaint" }, { label: "改进建议", value: "suggestion" }, { label: "其他反馈", value: "other" } ]; this.formData.type = "complaint"; } }, goBack() { common_vendor.index.navigateBack(); }, chooseImage() { const count = 6 - this.formData.images.length; common_vendor.index.chooseImage({ count, sizeType: ["compressed"], success: async (res) => { const paths = res.tempFilePaths; this.uploading = true; try { for (const path of paths) { const preview = path; const placeholderIndex = this.formData.images.length; this.formData.images.push(preview); this.imageOssMap.push(null); try { const uploadRes = await api_resource_oss.uploadFile(path); this.formData.images.splice(placeholderIndex, 1, uploadRes.url); this.imageOssMap.splice(placeholderIndex, 1, uploadRes.ossId); } catch (err) { this.formData.images.splice(placeholderIndex, 1); this.imageOssMap.splice(placeholderIndex, 1); common_vendor.index.showToast({ title: "图片上传失败", icon: "none" }); } } } finally { this.uploading = false; } } }); }, removeImage(index) { this.formData.images.splice(index, 1); this.imageOssMap.splice(index, 1); }, previewImage(index) { common_vendor.index.previewImage({ urls: this.formData.images, current: index }); }, async handleSubmit() { if (!this.isFormValid) return; try { common_vendor.index.showLoading({ title: "提交中" }); const payload = { feedbackType: this.formData.type, content: this.formData.content, images: this.imageOssMap.filter((id) => id !== null).join(",") }; await api_system_complaint.submitComplaint(payload); common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: "反馈成功", icon: "success" }); setTimeout(() => { common_vendor.index.navigateBack(); }, 1500); } catch (e) { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: e.message || "提交失败", icon: "none" }); } } } }; if (!Array) { const _component_erp_nav_bar = common_vendor.resolveComponent("erp-nav-bar"); _component_erp_nav_bar(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.p({ title: "投诉与建议" }), b: common_vendor.f($data.types, (item, k0, i0) => { return { a: common_vendor.t(item.label), b: item.value, c: $data.formData.type === item.value ? 1 : "", d: common_vendor.o(($event) => $data.formData.type = item.value, item.value) }; }), c: $data.formData.content, d: common_vendor.o(($event) => $data.formData.content = $event.detail.value, "71"), e: common_vendor.t($data.formData.content.length), f: common_vendor.f($data.formData.images, (img, index, i0) => { return { a: img, b: common_vendor.o(($event) => $options.previewImage(index), index), c: common_vendor.o(($event) => $options.removeImage(index), index), d: index }; }), g: $data.formData.images.length < 6 }, $data.formData.images.length < 6 ? { h: common_vendor.o((...args) => $options.chooseImage && $options.chooseImage(...args), "2e") } : {}, { i: !$options.isFormValid, j: common_vendor.o((...args) => $options.handleSubmit && $options.handleSubmit(...args), "5f") }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6497fc4f"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/mine/complaint/index.js.map