var publish_order_id = $("#publish_order_id").val(); const App = { mixins: [sharedMixin], /////共用的方法///// data() { return { // loading: true, dialog: { setGoodsDisInfo: false, }, loading: { loading: false, goodsDisInfo: true, }, review_comments: '', set_nopass_reason_title: '刊登审核', dialogVisible_reason: false, set_goods_dis_info_title: '分销详情', publish_order_id: publish_order_id, categoryList: [], /////商品分类数据////// uploadFileForm: { atta_type: 1, }, create_goods_form: { categoryid: ["29", "2901", "290101"], warehouse_mode: 1, //////商品仓库模式:自建仓 docking_way: 0, /////对接系统:无 price_method: 0, ////定价方式 sales_form: 1, ////销售形式:单品 }, publishOrderInfoForm: { istemp: 0, },////////商品信息////// goodsBrandList: [],///////商品品牌列表////// publishOrderPictureList: [],////////商品图片列表////// previewImageUrl: '',////预览图片地址////// dialogVisible_Picture: false,////预览图片弹窗////// goodsPictureCount: {},//////商品图片数量////// current_goods_distribution_area: {}, screenHeight: 0, goodsDisInfo: { goodsSpecInfo: {}, goodsAttributeInfo: {}, goodsAttributExtendList: [], goodsRetailPriceLimitList: [], goodsLabelList: [], }, disAreaList: [], disStockList: [], disReturnGoodsList: [], goods_spec_info: [], pictureStatuslist: { 0: true, 1: false, 2: false, 3: false, 4: false, 5: false, 6: false, 7: false }, picture_type: [], goodsPictureList: [], }; }, mounted() { this.loading.loading = true; Promise.all([ this.updateScreenHeight(), this.getPublishOrderInfo(), this.getCategoryList(), // this.getTinymce(), // this.getGoodsPurposeList(), // this.getGoodsAnnexList(), this.getPublishOrderPictureList(), ]).then(() => { // setTimeout(() => { // }, 500); }).catch((error) => { this.loading.loading = false; }); }, created() { }, methods: { showReviewPublishOrder() { this.review_comments = ''; this.dialogVisible_reason = true; }, reviewPublishOrder(status) { let that = this; let { id } = that.publishOrderInfoForm; if (status == 2 && that.review_comments == '') { that.$notify.error({ title: '错误', position: 'top-left', message: '请填写不通过理由' }); return false; } let url = "/admin/publishOrder/reviewPublishOrder.html" postRequest(url, { id: id, status: status, review_comments: that.review_comments }).then(res => { if (res.data.code == 200) { that.$notify({ title: '成功', message: res.data.message, position: 'top-left', type: 'success', duration: 1000, onClose: () => { if (status == 2) { that.dialogVisible_reason = false; } document.location.href = '/admin/publishOrder/index.html'; } }); if (status == 2) { that.dialogVisible_reason = false; } } else { that.$notify.error({ title: '错误', position: 'top-left', message: res.data.message }); } }); }, setPictureStatus(val) { if (val === 0) { this.pictureStatuslist = { 0: true, 1: false, 2: false, 3: false, 4: false, 5: false, 6: false, 7: false } this.picture_type = []; } else { this.pictureStatuslist[0] = false; this.pictureStatuslist[val] = !this.pictureStatuslist[val]; if (this.pictureStatuslist[val]) { this.picture_type.push(val); } else { this.picture_type = this.picture_type.filter(item => item != val); } if (this.picture_type.length === 0) { this.pictureStatuslist[0] = true; } } this.getGoodsPictureList(); }, getGoodsPictureList() { const that = this; const url = "/admin/publishOrder/getGoodsPictureList.html"; postRequest(url, { goods_id: that.goodsDisInfo.id, picture_type: that.picture_type }).then((res) => { if (res.data.code === 200) { that.goodsPictureList = res.data.list; } else { that.goodsPictureList = []; } }).catch((error) => { // 处理请求失败的情况 }); }, getGoodsPictureCount() { const that = this; const url = "/admin/publishOrder/getGoodsPictureCount.html"; postRequest(url, { goods_id: that.goodsDisInfo.id }).then((res) => { if (res.data.code === 200) { that.goodsPictureCount = res.data.goodsPictureCount; } else { that.goodsPictureCount = {}; } }).catch((error) => { // 处理请求失败的情况 }); }, updateScreenHeight() { this.screenHeight = window.innerHeight; }, // 显示商品分销详情 showGoodsDisInfo() { const that = this; if (that.publishOrderInfoForm.supplier_goods_code !== null) { this.dialog.setGoodsDisInfo = true; that.getGoodsDisInfo(that.publishOrderInfoForm.supplier_goods_code); } }, getGoodsDisInfo(supplier_goods_code) { const that = this; const url = "/admin/publishOrder/getGoodsDisInfo.html"; postRequest(url, { supplier_goods_code: supplier_goods_code }).then((res) => { this.loading.goodsDisInfo = false; if (res.data.code === 200) { that.goodsDisInfo = res.data.info; that.disAreaList = res.data.disAreaList; that.disStockList = res.data.disStockList; that.disPriceList = res.data.disPriceList; that.disReturnGoodsList = res.data.disReturnGoodsList; that.getGoodsPictureList() this.getGoodsPictureCount(); } else { return; } }).catch((error) => { this.loading.goodsDisInfo = false; // 错误处理逻辑,例如弹窗提示 });; }, savePublishOrder() { const that = this; // 使用Promise.all来并行处理tinymce内容获取 const getContentPromises = [ tinymce.get('tinymce-en-1').getContent(), tinymce.get('tinymce-cn-1').getContent(), ]; Promise.all(getContentPromises) .then((contents) => { // 更新表单数据 that.publishOrderInfoForm.goods_desc_en = contents[0] that.publishOrderInfoForm.goods_desc_cn = contents[1] // 发送请求 const url = "/admin/publishOrder/savePublishOrder.html"; postRequest(url, that.publishOrderInfoForm) .then((res) => { if (res.data.code === 200) { that.$notify({ title: "成功", message: res.data.message, position: "top-left", duration: 2000, type: "success", onClose: () => { window.location.href = res.data.url; } }); // that.$message({ // type: "success", // message: res.data.message, // duration: 2000, // onClose: () => { // window.location.href = res.data.url; // } // }); } else { that.$notify.error({ title: "错误", position: "top-left", message: res.data.message, }); } }) .catch((error) => { that.$notify.error({ title: "错误", position: "top-left", message: "请求发生错误,请稍后重试", }); }); /////////////////////// }) .catch((error) => { that.$notify.error({ title: "错误", position: "top-left", message: "获取内容时发生错误,请稍后重试", }); }); }, ///取商品基本信息数据 getGoodsInfo(supplier_goods_code) { const that = this; const url = "/admin/publishOrder/getGoodsInfo.html"; postRequest(url, { supplier_goods_code: supplier_goods_code }).then((res) => { this.loading.loading = false; if (res.data.code === 200) { that.publishOrderInfoForm.first_cate_code = res.data.info.first_cate_code; that.publishOrderInfoForm.second_cate_code = res.data.info.second_cate_code; that.publishOrderInfoForm.three_cate_code = res.data.info.three_cate_code; that.publishOrderInfoForm.cate_code = res.data.info.cate_code; that.publishOrderInfoForm.brand_code = res.data.info.brand_code; that.publishOrderInfoForm.goods_title_en = res.data.goods_desc.goods_title_en; that.publishOrderInfoForm.goods_title_cn = res.data.goods_desc.goods_title_cn; that.publishOrderInfoForm.goods_desc_en = res.data.goods_desc_content.goods_desc_en; that.publishOrderInfoForm.goods_desc_cn = res.data.goods_desc_content.goods_desc_cn; if (that.publishOrderInfoForm.goods_desc_en != null) { tinymce.get('tinymce-en-1').setContent(that.publishOrderInfoForm.goods_desc_en); } if (that.publishOrderInfoForm.goods_desc_cn != null) { tinymce.get('tinymce-cn-1').setContent(that.publishOrderInfoForm.goods_desc_cn); } } else { return; } }).catch((error) => { this.loading.loading = false; // 错误处理逻辑,例如弹窗提示 });; }, ///取商品基本信息数据 getPublishOrderInfo() { const that = this; const url = "/admin/publishOrder/getPublishOrderInfo.html"; postRequest(url, { id: that.publish_order_id }).then((res) => { this.loading.loading = false; if (res.data.code === 200) { that.publishOrderInfoForm = res.data.info; if (that.publishOrderInfoForm.supplier_goods_code != null && that.publishOrderInfoForm.goods_title_en == null) { that.getGoodsInfo(that.publishOrderInfoForm.supplier_goods_code); } // } else { return; } }).catch((error) => { this.loading.loading = false; // 错误处理逻辑,例如弹窗提示 });; }, ////////////////////////// ////获取商品信息////// removePicture(file) { const that = this; let { id } = file; that.$confirm( '确定删除吗?', '警告', { confirmButtonText: '删除', cancelButtonText: '取消', type: 'warning', center: true, } ).then(() => { let url = "/admin/publishOrder/deletePublishOrderPicture.html" postRequest(url, { id: id }).then(res => { if (res.data.code === 200) { that.$notify({ title: '成功', message: res.data.message, position: 'top-left', type: 'success' }); that.publishOrderPictureList = that.publishOrderPictureList.filter(item => item.id !== id); } else { that.$notify.error({ title: '错误', position: 'top-left', message: res.data.message }); } }).catch((error) => { that.$notify.error({ title: "错误", position: "top-left", message: "请求发生错误,请稍后重试", }); }); ///////////// }).catch(() => { //取消,不做处理 }) }, // 预览图片 previewPictureCard(file) { this.previewImageUrl = file.url this.dialogVisible_Picture = true }, imgchecked(E_width, E_height, file) { const that = this; return new Promise((resolve, reject) => { let reader = new FileReader(); reader.readAsDataURL(file); reader.onload = () => { let img = new Image(); img.src = reader.result; img.onload = () => { const width = img.width; const height = img.height; if (width < E_width || height < E_height) { that.$message.error('上传失败 图片尺寸不能低于 ' + E_width + '_' + E_height) resolve(false) } else { resolve(true) } } } }) }, //上传图片前验证大小 handleBeforeUpload(file) { return new Promise((resolve, reject) => { const suffix = file.type === 'image/jpg' || file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif' const isLt10M = file.size / 1024 / 1024 < 10 if (!suffix) { this.$message.error('上传图片只能是 JPG、JPEG、PNG、GIF 格式!') reject(false) } if (!isLt10M) { this.$message.error('上传图片大小不能超过 10MB!') reject(false) } this.imgchecked(1000, 1000, file).then((res) => { if (res) { resolve(true) } else { reject(false) } }) }); }, // 上传图片 uploadPublishOrderPicture(param) { const that = this; var fileobj = param.file; var form = new FormData(); form.append('file', fileobj); form.append('publish_order_id', that.publish_order_id); const url = "/admin/publishOrder/uploadPublishOrderPicture.html"; axios.post(url, form).then((res) => { if (res.data.code === 200) { that.publishOrderPictureList[that.publishOrderPictureList.length - 1].id = res.data.id; } param.onSuccess(res) }).catch(({ err }) => { param.onError(err) }); }, // 获取商品图片列表 getPublishOrderPictureList() { const that = this; const url = "/admin/publishOrder/getPublishOrderPictureList.html"; postRequest(url, { publish_order_id: that.publish_order_id }).then((res) => { if (res.data.code === 200) { that.publishOrderPictureList = res.data.list; } else { that.publishOrderPictureList = []; } }).catch((error) => { // 处理请求失败的情况 }); }, //选择分类 handleCategoryChange(value) { const that = this; if (typeof value == 'undefined') { that.publishOrderInfoForm.first_cate_code = '' that.publishOrderInfoForm.second_cate_code = '' that.publishOrderInfoForm.three_cate_code = '' } else { that.publishOrderInfoForm.first_cate_code = value[0] that.publishOrderInfoForm.second_cate_code = value[1] that.publishOrderInfoForm.three_cate_code = value[2] } }, // 保存关键字 //获取货运属性 getGoodsFreightAttrList() { const that = this; const url = "/admin/publishOrder/getGoodsFreightAttrList.html"; postRequest(url, {}).then((res) => { if (res.data.code === 200) { that.goodsFreightAttrList = res.data.list; } }).catch((error) => { // 处理请求失败的情况 }) }, //获取分类数据 getCategoryList() { const that = this; const url = "/admin/publishOrder/getCategoryList.html"; postRequest(url, {}).then((res) => { if (res.data.code === 200) { that.categoryList = res.data.list; } }).catch((error) => { // 处理请求失败的情况 }) }, //获取商品用途 getGoodsPurposeList() { const that = this; const url = "/admin/publishOrder/getGoodsPurposeList.html"; postRequest(url, {}).then((res) => { if (res.data.code === 200) { that.goodsPurposeList = res.data.list; } }).catch((error) => { // 处理请求失败的情况 }) }, //获取销售平台列表 getSalesPlatformList() { const that = this; const url = "/admin/publishOrder/getSalesPlatformList.html"; postRequest(url, {}).then((res) => { if (res.data.code === 200) { that.salesPlatformList = res.data.list; } }).catch((error) => { // 处理请求失败的情况 }) }, //获取商品分销平台 getDisPlatformList() { const that = this; const url = "/admin/publishOrder/getDisPlatformList.html"; postRequest(url, {}).then((res) => { if (res.data.code === 200) { that.disPlatformList = res.data.list; } }).catch((error) => { // 处理请求失败的情况 }) }, getGoodsMaterialList() { const that = this; const url = "/admin/publishOrder/getGoodsMaterialList.html"; postRequest(url, {}).then((res) => { if (res.data.code === 200) { that.goodsMaterialList = res.data.list; } }).catch((error) => { // 处理请求失败的情况 }) }, getStockCountryList() { let that = this; let url = "/admin/thirdPartyStockTemp/stockCountryList.html" postRequest(url, {}).then(res => { if (res.data.code == 200) { that.stockCountryList = res.data.list; } }); }, // 初始tinymce getTinymce() { tinymce.init({ selector: '.textarea', license_key: 'gpl', language: "zh_CN", // toolbar: "", entity_encoding: "raw", convert_urls: false, width: "100%", height: 300, fontsize_formats: "8pt 9pt 10pt 11pt 12pt 14pt 18pt 22pt 26pt 36pt", autoresize_min_height: 300, autoresize_max_height: 300, resize: false, statusbar: false, branding: false, promotion: false, }); }, }, }; const app = Vue.createApp(App); const iconList = ['Menu', 'QuestionFilled']; for (const [key, component] of Object.entries(ElementPlusIconsVue)) { if (iconList.includes(key)) { app.component('custom-' + key.toLowerCase(), component); } else { app.component(key, component); } } app.use(ElementPlus, { locale: ElementPlusLocaleZhCn, }); app.mount("#vue_item");