Files
t-admin/unpackage/dist/dev/mp-weixin/pages/cms-temp/edit.js
T
2025-06-13 21:16:12 +08:00

254 lines
7.9 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const js_sdk_validator_cmsTemp = require("../../js_sdk/validator/cms-temp.js");
const db = common_vendor.er.database();
db.command;
const dbCollectionName = "cms-temp";
function getValidator(fields) {
let result = {};
for (let key in js_sdk_validator_cmsTemp.validator) {
if (fields.includes(key)) {
result[key] = js_sdk_validator_cmsTemp.validator[key];
}
}
return result;
}
const _sfc_main = {
data() {
let formData = {
"font_color": "",
"backgrond_color": "",
"select_src": "",
"temptele_src": "",
"temptele_name": "",
"select_icon_color": "",
"icon_color": "",
"user_name_color": "",
"btn_color": ""
};
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
};
},
onLoad(e) {
if (e.id) {
const id = e.id;
this.formDataId = id;
this.getDetail(id);
}
},
onReady() {
this.$refs.form.setRules(this.rules);
},
methods: {
async setFormData_src(uploadRes, type) {
if (uploadRes && uploadRes.fileID) {
if (type === "temptele_src") {
this.formData.temptele_src = uploadRes.fileID;
} else if (type === "select_src") {
this.formData.select_src = uploadRes.fileID;
}
common_vendor.index.__f__("log", "at pages/cms-temp/edit.vue:146", "上传成功", uploadRes);
}
},
/**
* 验证表单并提交
*/
submit() {
common_vendor.index.showLoading({
mask: true
});
this.$refs.form.validate().then((res) => {
return this.submitForm(res);
}).catch(() => {
}).finally(() => {
common_vendor.index.hideLoading();
});
},
/**
* 提交表单
*/
submitForm(value) {
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
common_vendor.index.showToast({
title: "修改成功"
});
this.getOpenerEventChannel().emit("refreshData");
setTimeout(() => common_vendor.index.navigateBack(), 500);
}).catch((err) => {
common_vendor.index.showModal({
content: err.message || "请求服务失败",
showCancel: false
});
});
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
common_vendor.index.showLoading({
mask: true
});
db.collection(dbCollectionName).doc(id).field(
"font_color,backgrond_color,select_src,temptele_src,temptele_name,select_icon_color,icon_color,user_name_color,btn_color"
).get().then((res) => {
const data = res.result.data[0];
if (data) {
this.formData = data;
}
}).catch((err) => {
common_vendor.index.showModal({
content: err.message || "请求服务失败",
showCancel: false
});
}).finally(() => {
common_vendor.index.hideLoading();
});
}
}
};
if (!Array) {
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
const _easycom_cloud_image2 = common_vendor.resolveComponent("cloud-image");
const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
(_easycom_uni_easyinput2 + _easycom_uni_forms_item2 + _easycom_cloud_image2 + _easycom_uni_forms2)();
}
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
const _easycom_cloud_image = () => "../../uni_modules/uni-id-pages/components/cloud-image/cloud-image.js";
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
if (!Math) {
(_easycom_uni_easyinput + _easycom_uni_forms_item + _easycom_cloud_image + _easycom_uni_forms)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.o(($event) => $data.formData.font_color = $event),
b: common_vendor.p({
placeholder: "文字颜色代码",
modelValue: $data.formData.font_color
}),
c: common_vendor.p({
name: "font_color",
label: "",
required: true
}),
d: common_vendor.o(($event) => $data.formData.backgrond_color = $event),
e: common_vendor.p({
placeholder: "背景颜色代码",
modelValue: $data.formData.backgrond_color
}),
f: common_vendor.p({
name: "backgrond_color",
label: "",
required: true
}),
g: common_vendor.o(($event) => $data.formData.select_src = $event),
h: common_vendor.p({
placeholder: "素材选择(选择模板的样例图)地址",
disabled: "false",
modelValue: $data.formData.select_src
}),
i: !$data.formData.select_src
}, !$data.formData.select_src ? {} : {
j: common_vendor.p({
width: "400rpx",
height: "400rpx",
mode: "scaleToFill",
src: $data.formData.select_src
})
}, {
k: common_vendor.o(($event) => _ctx.updateImage("select_src")),
l: common_vendor.p({
name: "select_src",
label: "",
required: true
}),
m: common_vendor.o(($event) => $data.formData.temptele_src = $event),
n: common_vendor.p({
placeholder: "模板图片(实际使用)地址",
disabled: "false",
modelValue: $data.formData.temptele_src
}),
o: !$data.formData.temptele_src
}, !$data.formData.temptele_src ? {} : {
p: common_vendor.p({
width: "400rpx",
height: "400rpx",
mode: "scaleToFill",
src: $data.formData.temptele_src
})
}, {
q: common_vendor.o(($event) => _ctx.updateImage("temptele_src")),
r: common_vendor.p({
name: "temptele_src",
label: "",
required: true
}),
s: common_vendor.o(($event) => $data.formData.temptele_name = $event),
t: common_vendor.p({
placeholder: "模板名称",
modelValue: $data.formData.temptele_name
}),
v: common_vendor.p({
name: "temptele_name",
label: "",
required: true
}),
w: common_vendor.o(($event) => $data.formData.select_icon_color = $event),
x: common_vendor.p({
placeholder: "图标选中颜色的代码",
modelValue: $data.formData.select_icon_color
}),
y: common_vendor.p({
name: "select_icon_color",
label: "",
required: true
}),
z: common_vendor.o(($event) => $data.formData.icon_color = $event),
A: common_vendor.p({
placeholder: "图标未选中颜色的代码",
modelValue: $data.formData.icon_color
}),
B: common_vendor.p({
name: "icon_color",
label: "",
required: true
}),
C: common_vendor.o(($event) => $data.formData.user_name_color = $event),
D: common_vendor.p({
placeholder: "默认用户名字颜色的代码",
modelValue: $data.formData.user_name_color
}),
E: common_vendor.p({
name: "user_name_color",
label: "",
required: true
}),
F: common_vendor.o(($event) => $data.formData.btn_color = $event),
G: common_vendor.p({
placeholder: "按钮(回复和删除评论)默认颜色的代码",
modelValue: $data.formData.btn_color
}),
H: common_vendor.p({
name: "btn_color",
label: "",
required: true
}),
I: common_vendor.o((...args) => $options.submit && $options.submit(...args)),
J: common_vendor.sr("form", "0e5cea11-0"),
K: common_vendor.p({
model: $data.formData,
validateTrigger: "bind"
})
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-0e5cea11"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/cms-temp/edit.js.map