292 lines
11 KiB
JavaScript
292 lines
11 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: "goodsAdd",
|
|
setup(__props) {
|
|
const onScan = () => {
|
|
common_vendor.index.scanCode({
|
|
onlyFromCamera: true,
|
|
success: (res) => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsAdd.vue:174", res);
|
|
form.goods_no = res.result;
|
|
},
|
|
fail: () => {
|
|
common_vendor.index.showToast({
|
|
icon: "none",
|
|
title: "扫码失败"
|
|
});
|
|
}
|
|
});
|
|
};
|
|
const filter_params = common_vendor.reactive({});
|
|
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 form = common_vendor.reactive({
|
|
// goods_id: 0,
|
|
goods_name: "",
|
|
goods_no: "",
|
|
goods_price: "",
|
|
goods_stock: "",
|
|
content: "",
|
|
details_content: "",
|
|
status: "10",
|
|
images: [],
|
|
add_person: "",
|
|
// disk: '未选择',
|
|
degree_id: 0,
|
|
degree_name: "未选择",
|
|
type_id: 0,
|
|
type_name: "未选择",
|
|
brand_id: 0,
|
|
brand_name: "未选择",
|
|
product_id: 0,
|
|
product_name: "未选择"
|
|
// video_url: ''
|
|
// goods_no: '',
|
|
// goods_status: '10',
|
|
// goods_sort: 0,
|
|
});
|
|
const onProductChange = (...args) => {
|
|
};
|
|
const onSubmit = () => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsAdd.vue:271", "form====>", form);
|
|
api_goods.fetchGoodsAdd(form).then((res) => {
|
|
common_vendor.index.showToast({
|
|
icon: "none",
|
|
title: "新增商品成功"
|
|
});
|
|
setTimeout(() => {
|
|
common_vendor.index.navigateBack({
|
|
delta: 1
|
|
// 返回上一页
|
|
});
|
|
}, 500);
|
|
});
|
|
};
|
|
const onProcutPathChange = (args) => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsAdd.vue:299", 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;
|
|
};
|
|
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/goodsAdd.vue:348", "filter_params", filter_params);
|
|
});
|
|
});
|
|
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 {
|
|
a: common_vendor.o(($event) => form.goods_name = $event),
|
|
b: common_vendor.p({
|
|
placeholder: "请输入名称",
|
|
type: "text",
|
|
modelValue: form.goods_name
|
|
}),
|
|
c: common_vendor.p({
|
|
label: "名称"
|
|
}),
|
|
d: common_vendor.o(onScan),
|
|
e: common_vendor.p({
|
|
name: "scan2",
|
|
size: "30",
|
|
["custom-color"]: "#000000"
|
|
}),
|
|
f: common_vendor.o(($event) => form.goods_no = $event),
|
|
g: common_vendor.p({
|
|
placeholder: "请输入串号",
|
|
type: "text",
|
|
modelValue: form.goods_no
|
|
}),
|
|
h: common_vendor.p({
|
|
label: "串号"
|
|
}),
|
|
i: common_vendor.o(($event) => form.goods_price = $event),
|
|
j: common_vendor.p({
|
|
placeholder: "请输入售价",
|
|
type: "nubmer",
|
|
modelValue: form.goods_price
|
|
}),
|
|
k: common_vendor.p({
|
|
label: "售价"
|
|
}),
|
|
l: common_vendor.o(($event) => form.content = $event),
|
|
m: common_vendor.p({
|
|
autosize: true,
|
|
placeholder: "请输入说明",
|
|
type: "text",
|
|
modelValue: form.content
|
|
}),
|
|
n: common_vendor.p({
|
|
label: "说明"
|
|
}),
|
|
o: common_vendor.o(($event) => form.details_content = $event),
|
|
p: common_vendor.p({
|
|
autosize: true,
|
|
placeholder: "请输入介绍",
|
|
type: "text",
|
|
modelValue: form.details_content
|
|
}),
|
|
q: common_vendor.p({
|
|
label: "介绍"
|
|
}),
|
|
r: common_vendor.p({
|
|
label: "10"
|
|
}),
|
|
s: common_vendor.p({
|
|
label: "20"
|
|
}),
|
|
t: common_vendor.o(($event) => form.status = $event),
|
|
v: common_vendor.p({
|
|
direction: "horizontal",
|
|
modelValue: form.status
|
|
}),
|
|
w: common_vendor.p({
|
|
label: "状态"
|
|
}),
|
|
x: common_vendor.t(form.degree_name),
|
|
y: common_vendor.o(($event) => show_degree_popup.value = true),
|
|
z: common_vendor.t(form.type_name),
|
|
A: common_vendor.t(form.brand_name),
|
|
B: common_vendor.t(form.product_name),
|
|
C: common_vendor.o(($event) => show_product_cascader.value = true),
|
|
D: common_vendor.o(($event) => form.images = $event),
|
|
E: common_vendor.p({
|
|
number: 9,
|
|
["add-image"]: addGoodsImg,
|
|
keyName: "file_path",
|
|
modelValue: form.images
|
|
}),
|
|
F: common_vendor.o(onSubmit),
|
|
G: common_vendor.p({
|
|
type: "primary",
|
|
block: true
|
|
}),
|
|
H: common_vendor.o(onConfirmDegree),
|
|
I: common_vendor.o(($event) => show_degree_popup.value = false),
|
|
J: common_vendor.o(($event) => popup_degree_val.value = $event),
|
|
K: common_vendor.p({
|
|
columns: filter_params.degree_list,
|
|
["field-names"]: {
|
|
text: "degree_name",
|
|
value: "degree_id"
|
|
},
|
|
title: "选择成色",
|
|
modelValue: popup_degree_val.value
|
|
}),
|
|
L: common_vendor.o(($event) => show_degree_popup.value = $event),
|
|
M: common_vendor.p({
|
|
position: "bottom",
|
|
["safe-area-inset-bottom"]: true,
|
|
visible: show_degree_popup.value
|
|
}),
|
|
N: common_vendor.o(onProductChange),
|
|
O: common_vendor.o(onProcutPathChange),
|
|
P: common_vendor.o(($event) => show_product_cascader.value = $event),
|
|
Q: common_vendor.o(($event) => cascader_product_val.value = $event),
|
|
R: 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-262d0393"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/config/goodsAdd.js.map
|