2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-7e987d9a"],{1726:function(t,e,o){"use strict";o.d(e,"e",(function(){return s})),o.d(e,"l",(function(){return c})),o.d(e,"f",(function(){return a})),o.d(e,"i",(function(){return n})),o.d(e,"c",(function(){return d})),o.d(e,"g",(function(){return i})),o.d(e,"a",(function(){return l})),o.d(e,"h",(function(){return u})),o.d(e,"k",(function(){return p})),o.d(e,"d",(function(){return f})),o.d(e,"b",(function(){return h})),o.d(e,"j",(function(){return m}));var r=o("b775");function s(t){return new Promise((e,o)=>{Object(r["a"])({url:"/product.queryProduct",method:"get",params:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function c(t){return new Promise((e,o)=>{Object(r["a"])({url:"/product.updateProduct",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function a(t){return new Promise((e,o)=>{Object(r["a"])({url:"/productCategory.queryProductCategory",method:"get",params:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function n(t){return new Promise((e,o)=>{Object(r["a"])({url:"/shopHouse.queryShopHouse",method:"get",params:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function d(t){return new Promise((e,o)=>{Object(r["a"])({url:"/housekeepingType.queryHousekeepingType",method:"get",params:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function i(t){return new Promise((e,o)=>{Object(r["a"])({url:"/productH5Menu.listProductH5Menu",method:"get",params:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function l(t){return new Promise((e,o)=>{Object(r["a"])({url:"/product.deleteProduct",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function u(t){return new Promise((e,o)=>{Object(r["a"])({url:"/product/queryProductSpec",method:"get",params:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function p(t){return new Promise((e,o)=>{Object(r["a"])({url:"/product/saveProductLabel",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function f(t){return new Promise((e,o)=>{Object(r["a"])({url:"/label/queryLabel",method:"get",params:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function h(t){return new Promise((e,o)=>{Object(r["a"])({url:"/export.exportData",method:"get",params:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function m(t){return new Promise((e,o)=>{Object(r["a"])({url:"/product.saveProduct",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}},"298e":function(t,e,o){"use strict";o("7663")},7663:function(t,e,o){},eecb:function(t,e,o){"use strict";o.r(e);var r=function(){var t=this,e=t._self._c;return e("div",[e("el-card",{staticClass:"ibox"},[e("div",{staticClass:"flex justify-between",attrs:{slot:"header"},slot:"header"},[e("span",[t._v("商品信息")])]),e("div",{},[e("el-form",{attrs:{model:t.editProductInfo,"label-width":"120px"}},[e("el-row",{attrs:{gutter:20}},[e("el-col",{attrs:{span:12}},[e("el-form-item",{attrs:{label:"商品名称",prop:"prodName"}},[e("el-input",{attrs:{placeholder:"必填,请填写商品名称"},model:{value:t.editProductInfo.prodName,callback:function(e){t.$set(t.editProductInfo,"prodName",e)},expression:"editProductInfo.prodName"}})],1)],1),e("el-col",{attrs:{span:12}},[e("el-form-item",{attrs:{label:"商品分组",prop:"categoryId"}},[e("el-select",{staticStyle:{width:"100%"},attrs:{placeholder:"必填,请选择商品分组"},model:{value:t.editProductInfo.categoryId,callback:function(e){t.$set(t.editProductInfo,"categoryId",e)},expression:"editProductInfo.categoryId"}},[e("el-option",{attrs:{disabled:"",value:""}},[t._v("必填,请选择商品分组")]),t._l(t.editProductInfo.productCategorys,(function(t,o){return e("el-option",{key:o,attrs:{label:t.categoryName,value:t.categoryId}})}))],2)],1)],1)],1),e("el-row",{attrs:{gutter:20}},[e("el-col",{attrs:{span:12}},[e("el-form-item",{attrs:{label:"单位",prop:"unitName"}},[e("el-input",{attrs:{placeholder:"选填,请填写单位"},model:{value:t.editProductInfo.unitName,callback:function(e){t.$set(t.editProductInfo,"unitName",e)},expression:"editProductInfo.unitName"}})],1)],1),e("el-col",{attrs:{span:12}},[e("el-form-item",{attrs:{label:"排序",prop:"sort"}},[e("el-input",{attrs:{type:"number",placeholder:"选填,请填写排序"},model:{value:t.editProductInfo.sort,callback:function(e){t.$set(t.editProductInfo,"sort",e)},expression:"editProductInfo.sort"}})],1)],1)],1),e("el-row",{attrs:{gutter:20}},[e("el-col",{attrs:{span:12}},[e("el-form-item",{attrs:{label:"关键词",prop:"keyword"}},[e("el-input",{attrs:{placeholder:"必填,请填写关键词,多个关键词用;分隔"},model:{value:t.editProductInfo.keyword,callback:function(e){t.$set(t.editProductInfo,"keyword",e)},expression:"editProductInfo.keyword"}})],1)],1),e("el-col",{staticClass:"text-left",attrs:{span:12}},[e("el-form-item",{attrs:{label:"手机菜单",prop:"hktIds"}},[e("el-checkbox-group",{model:{value:t.editProductInfo.hktIds,callback:function(e){t.$set(t.editProductInfo,"hktIds",e)},expression:"editProductInfo.hktIds"}},t._l(t.editProductInfo.housekeepingTypes,(function(o,r){return e("el-checkbox",{key:r,attrs:{label:o.hktId}},[t._v(" "+t._s(o.hktName)+" ")])})),1)],1)],1)],1),e("el-row",{attrs:{gutter:20}},[e("el-col",{attrs:{span:12}},[e("el-form-item",{attrs:{label:"仓库",prop:"shId"}},[e("el-select",{staticStyle:{width:"100%"},attrs:{placeholder:"请选择仓库"},on:{change:function(e){return t._changeShopHouse(t.editProductInfo.shId)}},model:{value:t.editProductInfo.shId,callback:function(e){t.$set(t.editProductInfo,"shId",e)},expression:"editProductInfo.shId"}},[e("el-option",{attrs:{disabled:"",value:""}},[t._v("请选择仓库")]),t._l(t.editProductInfo.shopHouses,(function(t,o){return e("el-option",{key:o,attrs:{label:t.shName,value:t.shId}})}))],2)],1)],1),e("el-col",{staticClass:"text-left",attrs:{span:12}},[e("el-form-item",{attrs:{label:"库存警告数量",prop:"warnStock"}},[e("el-input-number",{attrs:{placeholder:"必填,请填写库存警告数量"},model:{value:t.editProductInfo.warnStock,callback:function(e){t.$set(t.editProductInfo,"warnStock",e)},expression:"editProductInfo.warnStock"}})],1)],1)],1),e("el-row",[e("el-col",{attrs:{span:24}},[e("el-form-item",{attrs:{label:"商品简介",prop:"prodDesc"}},[e("el-input",{attrs:{type:"textarea",rows:3,maxlength:"250",placeholder:"必填,请填写商品简介"},model:{value:t.editProductInfo.prodDesc,callback:function(e){t.$set(t.editProductInfo,"prodDesc",e)},expression:"editProductInfo.prodDesc"}})],1)],1)],1)],1)],1)]),e("el-card",{staticClass:"ibox"},[e("div",{staticClass:"flex justify-between",attrs:{slot:"header"},slot:"header"},[e("span",[t._v("商品图片")])]),e("div",{},[e("el-form",{attrs:{model:t.editProductInfo,"label-width":"120px"}},[e("el-row",[e("el-col",{attrs:{span:24}},[e("el-form-item",{attrs:{label:"商品封面"}},[e("upload-image-url",{ref:"editProductCover",attrs:{"image-count":1},on:{notifyUploadCoverImage:t.handleCoverImageUpload}})],1)],1)],1),e("el-row",[e("el-col",{attrs:{span:24}},[e("el-form-item",{attrs:{label:"商品轮播"}},[e("upload-image-url",{ref:"editProductCarouselFigure",attrs:{"image-count":3},on:{notifyUploadCoverImage:t.handleCarouselImageUpload}})],1)],1)],1)],1)],1)]),e("el-card",{staticClass:"ibox"},[e("div",{staticClass:"flex justify-between",attrs:{slot:"header"},slot:"header"},[e("span",[t._v("商品规格")]),e("el-button",{staticStyle:{float:"right"},attrs:{type:"primary",size:"small"},on:{click:t._openEditChooseSpecModal}},[e("i",{staticClass:"el-icon-plus"}),t._v("添加 ")])],1),e("div",{},[e("el-table",{staticStyle:{width:"100%"},attrs:{data:t.editProductInfo.productSpecs,border:""}},[e("el-table-column",{attrs:{prop:"specName",label:"规格名称",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input",{attrs:{placeholder:"请输入规格名称"},model:{value:o.row.specName,callback:function(e){t.$set(o.row,"specName",e)},expression:"scope.row.specName"}})]}}])}),e("el-table-column",{attrs:{prop:"stock",label:"库存",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input-number",{model:{value:o.row.stock,callback:function(e){t.$set(o.row,"stock",e)},expression:"scope.row.stock"}})]}}])}),e("el-table-column",{attrs:{prop:"sales",label:"销量",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input-number",{model:{value:o.row.sales,callback:function(e){t.$set(o.row,"sales",e)},expression:"scope.row.sales"}})]}}])}),e("el-table-column",{attrs:{prop:"price",label:"价格/积分",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input-number",{model:{value:o.row.price,callback:function(e){t.$set(o.row,"price",e)},expression:"scope.row.price"}})]}}])}),e("el-table-column",{attrs:{prop:"costPrice",label:"成本价",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input-number",{model:{value:o.row.costPrice,callback:function(e){t.$set(o.row,"costPrice",e)},expression:"scope.row.costPrice"}})]}}])}),e("el-table-column",{attrs:{prop:"ownerPrice",label:"业主价",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input-number",{model:{value:o.row.ownerPrice,callback:function(e){t.$set(o.row,"ownerPrice",e)},expression:"scope.row.ownerPrice"}})]}}])}),e("el-table-column",{attrs:{prop:"vipPrice",label:"会员价格",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input-number",{model:{value:o.row.vipPrice,callback:function(e){t.$set(o.row,"vipPrice",e)},expression:"scope.row.vipPrice"}})]}}])}),e("el-table-column",{attrs:{prop:"otPrice",label:"市场价",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input-number",{model:{value:o.row.otPrice,callback:function(e){t.$set(o.row,"otPrice",e)},expression:"scope.row.otPrice"}})]}}])}),e("el-table-column",{attrs:{prop:"deduction",label:"抵扣金",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input-number",{model:{value:o.row.deduction,callback:function(e){t.$set(o.row,"deduction",e)},expression:"scope.row.deduction"}})]}}])}),e("el-table-column",{attrs:{prop:"barCode",label:"条形码",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input",{model:{value:o.row.barCode,callback:function(e){t.$set(o.row,"barCode",e)},expression:"scope.row.barCode"}})]}}])}),e("el-table-column",{attrs:{label:"操作",align:"center",width:"180"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-button",{attrs:{type:"danger",size:"mini"},on:{click:function(e){return t._openEditDeleteProductSpec(o.row)}}},[t._v(" 删除 ")]),"T"!=o.row.isDefault?e("el-button",{attrs:{type:"primary",size:"mini"},on:{click:function(e){return t._doEditDefaultProductSpec(t.editProductInfo,o.row)}}},[t._v(" 默认规格 ")]):t._e()]}}])})],1),e("div",{staticStyle:{"margin-top":"15px"}},[e("span",[t._v("抵扣金:商品购买时抵扣金会自动送客户用来 缴相应的物业费停车费")])])],1)]),e("el-card",{staticClass:"ibox"},[e("div",{staticClass:"flex justify-between",attrs:{slot:"header"},slot:"header"},[e("span",[t._v("商品扩展")])]),e("div",{},[e("el-form",{attrs:{model:t.editProductInfo,"label-width":"120px"}},[e("el-row",[e("el-col",{attrs:{span:24}},[e("el-form-item",{attrs:{label:"商品状态"}},[e("el-select",{staticStyle:{width:"100%"},model:{value:t.editProductInfo.state,callback:function(e){t.$set(t.editProductInfo,"state",e)},expression:"editProductInfo.state"}},[e("el-option",{attrs:{label:"选填,请选择状态",value:"",disabled:""}}),e("el-option",{attrs:{label:"未上架",value:"1001"}}),e("el-option",{attrs:{label:"上架",value:"2002"}})],1)],1)],1)],1),e("el-row",[e("el-col",{attrs:{span:24}},[e("el-form-item",{attrs:{label:"商品详情"}},[e("RichTextEditor",{ref:"richTextEditor",on:{input:t.handleContentChange},model:{value:t.editProductInfo.content,callback:function(e){t.$set(t.editProductInfo,"content",e)},expression:"editProductInfo.content"}})],1)],1)],1)],1),e("div",{staticStyle:{"margin-top":"20px","text-align":"right"}},[e("el-button",{attrs:{type:"warning"},on:{click:function(e){return t._closeEditProduct()}}},[t._v(" 取消 ")]),e("el-button",{attrs:{type:"primary"},on:{click:function(e){return t.saveProductInfo()}}},[e("i",{staticClass:"el-icon-check"}),t._v("保存 ")])],1)],1)])],1)},s=[],c=o("7323"),a=o("5e31"),n=o("e01b"),d=o("1726"),i={name:"EditProduct",components:{UploadImageUrl:a["a"],RichTextEditor:n["a"]},data(){return{editProductInfo:{shId:"",shName:"",productId:"",warnStock:"",categoryId:"",prodName:"",prodDesc:"",keyword:"",barCode:"1",unitName:"",sort:"",isPostage:"2",postage:"0.00",productCategorys:[],content:"",states:[],state:"",coverPhoto:"",carouselFigurePhotos:[],productSpecs:[],areaCode:"",distributionModes:[],housekeepingTypes:[],shopHouses:[],hktIds:[]}}},created(){this.editProductInfo.productId=this.$route.query.productId,this.editProductInfo.shopId=Object(c["f"])(),this.editProductInfo.areaCode=Object(c["b"])(),this._initEditProduct()},methods:{_initEditProduct(){this._listEditProducts({productId:this.editProductInfo.productId}),this._listProductH5Menu({productId:this.editProductInfo.productId}),this._listShopHouses(),this._listEditHousekeepingTypes(),this._listEditProductCategorys(),Object(c["e"])("product","state").then(t=>{this.editProductInfo.states=t.data}),console.log(this.editProductInfo.areaCode)},handleContentChange(t){this.editProductInfo.content=t},handleCoverImageUpload(t){t.length>0?this.editProductInfo.coverPhoto=t[0]:this.editProductInfo.coverPhoto=""},handleCarouselImageUpload(t){this.editProductInfo.carouselFigurePhotos=[],t.forEach(t=>{this.editProductInfo.carouselFigurePhotos.push(t)})},async _listEditProducts(t){try{const e=await Object(d["e"])({page:1,row:1,productId:t.productId});if(0===e.code&&e.data.length>0){const t=e.data[0];Object.assign(this.editProductInfo,t),t.coverPhoto&&this.$refs.editProductCover.setImages([t.coverPhoto]),t.carouselFigurePhotos&&this.$refs.editProductCarouselFigure.setImages(t.carouselFigurePhotos),t.productSpecValues&&(this.editProductInfo.productSpecs=t.productSpecValues.map(t=>{let e="";return t.productSpecDetails&&t.productSpecDetails.forEach(t=>{e+=t.detailValue+"/"}),{...t,specValue:e}})),t.content&&this.$refs.richTextEditor.setContent(t.content)}}catch(e){console.error("获取商品详情失败:",e),this.$message.error("获取商品详情失败")}},async _listProductH5Menu(t){try{const e=await Object(d["g"])({page:1,row:30,productId:t.productId});0===e.code&&(this.editProductInfo.hktIds=e.data.map(t=>t.hktId))}catch(e){console.error("获取商品H5菜单失败:",e)}},async _listShopHouses(){try{const t={page:1,row:100,shopId:this.editProductInfo.shopId},e=await Object(d["i"])(t);this.editProductInfo.shopHouses=e.data}catch(t){console.error("获取仓库列表失败:",t)}},async _listEditHousekeepingTypes(){try{const t=await Object(d["c"])({page:1,row:30,typeCd:"2002",shopId:"9999",skipType:"3"});0===t.code&&(this.editProductInfo.housekeepingTypes=t.data)}catch(t){console.error("获取家政类型列表失败:",t)}},async _listEditProductCategorys(){try{const t=await Object(d["f"])({page:1,row:50,shopId:this.editProductInfo.shopId});0===t.code&&(this.editProductInfo.productCategorys=t.data)}catch(t){console.error("获取商品分类列表失败:",t)}},_openEditChooseSpecModal(){const t={specCd:"0",stock:"0",sales:"0",price:"0.00",costPrice:"0.00",ownerPrice:"0.00",vipPrice:"0.00",otPrice:"0.00",deduction:"0.00",isDefault:"F",barCode:""};this.editProductInfo.productSpecs.push(t);let e=!1;this.editProductInfo.productSpecs.forEach(t=>{"T"===t.isDefault&&(e=!0)}),!e&&this.editProductInfo.productSpecs.length>0&&(this.editProductInfo.productSpecs[0].isDefault="T")},_openEditDeleteProductSpec(t){const e=this.editProductInfo.productSpecs.indexOf(t);e>-1&&this.editProductInfo.productSpecs.splice(e,1);let o=!1;this.editProductInfo.productSpecs.forEach(t=>{"T"===t.isDefault&&(o=!0)}),!o&&this.editProductInfo.productSpecs.length>0&&(this.editProductInfo.productSpecs[0].isDefault="T")},_doEditDefaultProductSpec(t,e){t.productSpecs&&t.productSpecs.forEach(t=>{t.isDefault="F"}),e.isDefault="T"},_changeShopHouse(t){this.editProductInfo.shopHouses&&this.editProductInfo.shopHouses.forEach(e=>{e.shId===t&&(this.editProductInfo.shName=e.shName)})},editProductValidate(){if(!this.editProductInfo.categoryId)return this.$message.error("商品大类不能为空"),!1;if(!this.editProductInfo.prodName)return this.$message.error("商品名称不能为空"),!1;if(this.editProductInfo.prodName.length>128)return this.$message.error("商品名称不能超过128位"),!1;if(!this.editProductInfo.prodDesc)return this.$message.error("商品简介不能为空"),!1;if(this.editProductInfo.prodDesc.length>256)return this.$message.error("商品简介不能超过256位"),!1;if(!this.editProductInfo.keyword)return this.$message.error("关键词不能为空"),!1;if(this.editProductInfo.keyword.length>256)return this.$message.error("关键词不能超过256位"),!1;if(this.editProductInfo.barCode&&this.editProductInfo.barCode.length>15)return this.$message.error("产品条码不能超过15位"),!1;if(!this.editProductInfo.shId)return this.$message.error("仓库不能为空"),!1;if(this.editProductInfo.unitName&&this.editProductInfo.unitName.length>32)return this.$message.error("单位不能超过32位"),!1;let t=!1;return this.editProductInfo.productSpecs&&this.editProductInfo.productSpecs.forEach(e=>{"T"===e.isDefault&&(t=!0)}),!!t||(this.$message.error("未选择默认规格"),!1)},async saveProductInfo(){if(this.editProductValidate())try{const t=await Object(d["l"])(this.editProductInfo);0===t.code?(this.$message.success("修改成功"),this._closeEditProduct(),this.$emit("refresh")):this.$message.error(t.msg||"修改失败")}catch(t){console.error("修改商品失败:",t),this.$message.error("修改商品失败")}},_closeEditProduct(){this.$router.go(-1)}}},l=i,u=(o("298e"),o("2877")),p=Object(u["a"])(l,r,s,!1,null,"70c5a5e9",null);e["default"]=p.exports}}]);
|
|
//# sourceMappingURL=chunk-7e987d9a.d6bd7952.js.map
|