Files
cmgd-mini-app/unpackage/dist/dev/mp-weixin/pages/config/goodsEdit.js
2026-01-05 12:47:14 +08:00

332 lines
13 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const api_goods = require("../../api/goods.js");
const api_request = require("../../api/request.js");
if (!Array) {
const _easycom_nut_input2 = common_vendor.resolveComponent("nut-input");
const _easycom_nut_form_item2 = common_vendor.resolveComponent("nut-form-item");
const _easycom_nut_icon2 = common_vendor.resolveComponent("nut-icon");
const _easycom_nut_textarea2 = common_vendor.resolveComponent("nut-textarea");
const _easycom_nut_radio2 = common_vendor.resolveComponent("nut-radio");
const _easycom_nut_radio_group2 = common_vendor.resolveComponent("nut-radio-group");
const _easycom_shmily_drag_image2 = common_vendor.resolveComponent("shmily-drag-image");
const _easycom_nut_button2 = common_vendor.resolveComponent("nut-button");
const _easycom_nut_form2 = common_vendor.resolveComponent("nut-form");
const _easycom_nut_picker2 = common_vendor.resolveComponent("nut-picker");
const _easycom_nut_popup2 = common_vendor.resolveComponent("nut-popup");
const _easycom_nut_cascader2 = common_vendor.resolveComponent("nut-cascader");
(_easycom_nut_input2 + _easycom_nut_form_item2 + _easycom_nut_icon2 + _easycom_nut_textarea2 + _easycom_nut_radio2 + _easycom_nut_radio_group2 + _easycom_shmily_drag_image2 + _easycom_nut_button2 + _easycom_nut_form2 + _easycom_nut_picker2 + _easycom_nut_popup2 + _easycom_nut_cascader2)();
}
const _easycom_nut_input = () => "../../uni_modules/nutui-uni/components/input/input.js";
const _easycom_nut_form_item = () => "../../uni_modules/nutui-uni/components/formitem/formitem.js";
const _easycom_nut_icon = () => "../../uni_modules/nutui-uni/components/icon/icon.js";
const _easycom_nut_textarea = () => "../../uni_modules/nutui-uni/components/textarea/textarea.js";
const _easycom_nut_radio = () => "../../uni_modules/nutui-uni/components/radio/radio.js";
const _easycom_nut_radio_group = () => "../../uni_modules/nutui-uni/components/radiogroup/radiogroup.js";
const _easycom_shmily_drag_image = () => "../../uni_modules/shmily-drag-image/components/shmily-drag-image/shmily-drag-image.js";
const _easycom_nut_button = () => "../../uni_modules/nutui-uni/components/button/button.js";
const _easycom_nut_form = () => "../../uni_modules/nutui-uni/components/form/form.js";
const _easycom_nut_picker = () => "../../uni_modules/nutui-uni/components/picker/picker.js";
const _easycom_nut_popup = () => "../../uni_modules/nutui-uni/components/popup/popup.js";
const _easycom_nut_cascader = () => "../../uni_modules/nutui-uni/components/cascader/cascader.js";
if (!Math) {
(_easycom_nut_input + _easycom_nut_form_item + _easycom_nut_icon + _easycom_nut_textarea + _easycom_nut_radio + _easycom_nut_radio_group + _easycom_shmily_drag_image + _easycom_nut_button + _easycom_nut_form + _easycom_nut_picker + _easycom_nut_popup + _easycom_nut_cascader)();
}
const _sfc_main = {
__name: "goodsEdit",
setup(__props) {
const id = common_vendor.ref(0);
const is_show_edit = common_vendor.ref(false);
const show_product_cascader = common_vendor.ref(false);
const show_degree_popup = common_vendor.ref(false);
const popup_degree_val = common_vendor.ref([]);
const cascader_product_val = common_vendor.ref([]);
const filter_params = common_vendor.reactive({});
const form = common_vendor.reactive({
goods_id: 0,
goods_name: "",
goods_no: "",
goods_price: "",
goods_stock: "",
content: "",
details_content: "",
status: "10",
images: [],
add_person: "",
degree_id: 0,
degree_name: "未选择",
type_id: 0,
type_name: "未选择",
brand_id: 0,
brand_name: "未选择",
product_id: 0,
product_name: "未选择"
});
common_vendor.onMounted(() => {
api_goods.fetchFilterParmas(1).then((res) => {
Object.assign(filter_params, res);
filter_params.degree_list.unshift({
degree_id: 0,
degree_name: "未选择"
});
common_vendor.index.__f__("log", "at pages/config/goodsEdit.vue:166", "filter_params", filter_params);
});
});
common_vendor.onLoad((options) => {
common_vendor.index.__f__("log", "at pages/config/goodsEdit.vue:171", "goods_id===>", options.id);
id.value = options.id;
is_show_edit.value = false;
api_goods.fetchGoodsDetail(id.value).then((res) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
is_show_edit.value = true;
common_vendor.index.__f__("log", "at pages/config/goodsEdit.vue:177", "====>", res);
form.goods_id = res.goods_id;
form.goods_name = res.goods_name;
form.goods_no = res.goods_no;
form.goods_price = res.goods_price;
form.content = res.content;
form.details_content = res.details_content;
form.status = res.status.value.toString();
form.degree_id = ((_a = res.degree) == null ? void 0 : _a.degree_id) ?? 0;
form.degree_name = ((_b = res.degree) == null ? void 0 : _b.degree_name) ?? "未选择";
form.type_id = ((_c = res.type) == null ? void 0 : _c.type_id) ?? 0;
form.type_name = ((_d = res.type) == null ? void 0 : _d.name) ?? "未选择";
form.brand_id = ((_e = res.brand) == null ? void 0 : _e.brand_id) ?? 0;
form.brand_name = ((_f = res.brand) == null ? void 0 : _f.name) ?? "未选择";
form.product_id = ((_g = res.product) == null ? void 0 : _g.product_id) ?? 0;
form.product_name = ((_h = res.product) == null ? void 0 : _h.name) ?? "未选择";
popup_degree_val.value = [((_i = res.degree) == null ? void 0 : _i.degree_id) ?? 0];
cascader_product_val.value = [
((_j = res.type) == null ? void 0 : _j.type_id) ?? 0,
((_k = res.brand) == null ? void 0 : _k.brand_id) ?? 0,
((_l = res.product) == null ? void 0 : _l.product_id) ?? 0
];
form.images = [];
(_m = res.image) == null ? void 0 : _m.forEach((item) => {
form.images.push({
id: item.image_id,
file_path: item.file_path
});
});
});
});
const onProductChange = (...args) => {
common_vendor.index.__f__("log", "at pages/config/goodsEdit.vue:210", 0, ...args);
common_vendor.index.__f__("log", "at pages/config/goodsEdit.vue:211", cascader_product_val);
};
const onSubmit = () => {
common_vendor.index.__f__("log", "at pages/config/goodsEdit.vue:215", "form===>", form);
api_goods.fetchGoodsEdit(form).then((res) => {
common_vendor.index.showToast({
icon: "none",
title: "编辑商品成功"
});
setTimeout(() => {
common_vendor.index.navigateBack({
delta: 1
// 返回上一页
});
}, 500);
});
};
const onScan = () => {
common_vendor.index.scanCode({
onlyFromCamera: true,
success: (res) => {
common_vendor.index.__f__("log", "at pages/config/goodsEdit.vue:237", res);
form.goods_no = res.result;
},
fail: () => {
common_vendor.index.showToast({
icon: "none",
title: "扫码失败"
});
}
});
};
const onProcutPathChange = (args) => {
common_vendor.index.__f__("log", "at pages/config/goodsEdit.vue:250", args);
form.type_id = 0;
form.type_name = "";
form.brand_id = 0;
form.brand_name = "";
form.product_id = 0;
form.product_name = "";
if (args.length >= 1 && args[0] !== null) {
form.type_id = args[0].value;
form.type_name = args[0].text;
}
if (args.length >= 2 && args[1] !== null) {
form.brand_id = args[1].value;
form.brand_name = args[1].text;
}
if (args.length >= 3 && args[2] !== null) {
form.product_id = args[2].value;
form.product_name = args[2].text;
}
};
const onConfirmDegree = () => {
form.degree_id = popup_degree_val.value[0];
filter_params.degree_list.forEach((item) => {
if (item.degree_id === form.degree_id) {
form.degree_name = item.degree_name;
}
});
show_degree_popup.value = false;
};
const addGoodsImg = () => {
var _a;
common_vendor.index.chooseImage({
count: 9 - (((_a = form.image) == null ? void 0 : _a.length) || 0),
sourceType: ["album", "camera"],
success: (res) => {
res.tempFiles.forEach((file) => {
common_vendor.index.uploadFile({
url: api_request.getUploadImageUrl(),
filePath: file.path,
name: "iFile",
formData: {
group_id: 1
},
success: (res2) => {
let data = JSON.parse(res2.data).data;
form.images.push({
id: parseInt(data.file_id),
file_path: data.file_path
});
}
});
});
}
});
};
return (_ctx, _cache) => {
return common_vendor.e({
a: is_show_edit.value
}, is_show_edit.value ? {
b: common_vendor.o(($event) => form.goods_name = $event),
c: common_vendor.p({
placeholder: "请输入名称",
type: "text",
modelValue: form.goods_name
}),
d: common_vendor.p({
label: "名称"
}),
e: common_vendor.o(onScan),
f: common_vendor.p({
name: "scan2",
size: "30",
["custom-color"]: "#000000"
}),
g: common_vendor.o(($event) => form.goods_no = $event),
h: common_vendor.p({
placeholder: "请输入串号",
type: "text",
modelValue: form.goods_no
}),
i: common_vendor.p({
label: "串号"
}),
j: common_vendor.o(($event) => form.goods_price = $event),
k: common_vendor.p({
placeholder: "请输入售价",
type: "nubmer",
modelValue: form.goods_price
}),
l: common_vendor.p({
label: "售价"
}),
m: common_vendor.o(($event) => form.content = $event),
n: common_vendor.p({
autosize: true,
placeholder: "请输入说明",
type: "text",
modelValue: form.content
}),
o: common_vendor.p({
label: "说明"
}),
p: common_vendor.o(($event) => form.details_content = $event),
q: common_vendor.p({
autosize: true,
placeholder: "请输入介绍",
type: "text",
modelValue: form.details_content
}),
r: common_vendor.p({
label: "介绍"
}),
s: common_vendor.p({
label: "10"
}),
t: common_vendor.p({
label: "20"
}),
v: common_vendor.o(($event) => form.status = $event),
w: common_vendor.p({
direction: "horizontal",
modelValue: form.status
}),
x: common_vendor.p({
label: "状态"
}),
y: common_vendor.t(form.degree_name),
z: common_vendor.o(($event) => show_degree_popup.value = true),
A: common_vendor.t(form.type_name),
B: common_vendor.t(form.brand_name),
C: common_vendor.t(form.product_name),
D: common_vendor.o(($event) => show_product_cascader.value = true),
E: common_vendor.o(($event) => form.images = $event),
F: common_vendor.p({
number: 9,
["add-image"]: addGoodsImg,
keyName: "file_path",
modelValue: form.images
}),
G: common_vendor.o(onSubmit),
H: common_vendor.p({
type: "primary",
block: true
})
} : {}, {
I: common_vendor.o(onConfirmDegree),
J: common_vendor.o(($event) => show_degree_popup.value = false),
K: common_vendor.o(($event) => popup_degree_val.value = $event),
L: common_vendor.p({
columns: filter_params.degree_list,
["field-names"]: {
text: "degree_name",
value: "degree_id"
},
title: "选择成色",
modelValue: popup_degree_val.value
}),
M: common_vendor.o(($event) => show_degree_popup.value = $event),
N: common_vendor.p({
position: "bottom",
["safe-area-inset-bottom"]: true,
visible: show_degree_popup.value
}),
O: common_vendor.o(onProductChange),
P: common_vendor.o(onProcutPathChange),
Q: common_vendor.o(($event) => show_product_cascader.value = $event),
R: common_vendor.o(($event) => cascader_product_val.value = $event),
S: common_vendor.p({
title: "机型选择",
["text-key"]: "label",
["value-key"]: "value",
["title-ellipsis"]: false,
["children-key"]: "children",
options: filter_params.drop_down_options,
visible: show_product_cascader.value,
modelValue: cascader_product_val.value
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-a30aee39"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/config/goodsEdit.js.map