2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-32916dde"],{"1e78":function(t,e,o){"use strict";o.r(e);var a=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("el-button",{on:{click:function(e){return t._closeAddProduct()}}},[t._v("返回")])],1),e("div",{},[e("el-form",{ref:"form",attrs:{model:t.editChainProductInfo,rules:t.rules,"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.editChainProductInfo.prodName,callback:function(e){t.$set(t.editChainProductInfo,"prodName",e)},expression:"editChainProductInfo.prodName"}})],1)],1),e("el-col",{attrs:{span:12}},[e("el-form-item",{attrs:{label:"商品分组",prop:"catalogId"}},[e("el-select",{staticStyle:{width:"100%"},model:{value:t.editChainProductInfo.catalogId,callback:function(e){t.$set(t.editChainProductInfo,"catalogId",e)},expression:"editChainProductInfo.catalogId"}},[e("el-option",{attrs:{label:"必填,请选择商品分组",value:"",disabled:""}}),t._l(t.chainCatalogs,(function(t,o){return e("el-option",{key:o,attrs:{label:t.catalogName,value:t.catalogId}})}))],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.editChainProductInfo.unitName,callback:function(e){t.$set(t.editChainProductInfo,"unitName",e)},expression:"editChainProductInfo.unitName"}})],1)],1),e("el-col",{attrs:{span:12}},[e("el-form-item",{attrs:{label:"排序",prop:"sort"}},[e("el-input",{attrs:{placeholder:"选填,请填写排序"},model:{value:t.editChainProductInfo.sort,callback:function(e){t.$set(t.editChainProductInfo,"sort",e)},expression:"editChainProductInfo.sort"}})],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,placeholder:"必填,请填写商品简介",maxlength:"250"},model:{value:t.editChainProductInfo.prodDesc,callback:function(e){t.$set(t.editChainProductInfo,"prodDesc",e)},expression:"editChainProductInfo.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:{"label-width":"120px"}},[e("el-row",[e("el-col",{attrs:{span:24}},[e("el-form-item",{attrs:{label:"商品封面"}},[e("upload-image-url",{ref:"coverImageUpload",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:"carouselImageUpload",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",{attrs:{type:"primary",size:"small"},on:{click:function(e){return t._editChainProductSpec()}}},[e("i",{staticClass:"el-icon-plus"}),t._v("添加 ")])],1),e("div",{},[e("el-table",{staticStyle:{width:"100%"},attrs:{data:t.editChainProductInfo.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:"specValue",label:"规格值",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input",{attrs:{placeholder:"请输入规格值"},model:{value:o.row.specValue,callback:function(e){t.$set(o.row,"specValue",e)},expression:"scope.row.specValue"}})]}}])}),e("el-table-column",{attrs:{prop:"price",label:"价格",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input-number",{attrs:{precision:2,min:0},model:{value:o.row.price,callback:function(e){t.$set(o.row,"price",e)},expression:"scope.row.price"}})]}}])}),e("el-table-column",{attrs:{prop:"barCode",label:"条形码",align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[e("el-input",{attrs:{placeholder:"请输入条形码"},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._openAddDeleteProductSpec(o.row)}}},[t._v(" 删除 ")]),"T"!=o.row.isDefault?e("el-button",{attrs:{type:"primary",size:"mini"},on:{click:function(e){return t._doEditDefaultProductSpec(t.editChainProductInfo,o.row)}}},[t._v(" 默认规格 ")]):t._e()]}}])})],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:{"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.editChainProductInfo.state,callback:function(e){t.$set(t.editChainProductInfo,"state",e)},expression:"editChainProductInfo.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.editChainProductInfo.content,callback:function(e){t.$set(t.editChainProductInfo,"content",e)},expression:"editChainProductInfo.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._closeAddProduct()}}},[t._v(" 取消 ")]),e("el-button",{attrs:{type:"primary"},on:{click:function(e){return t.updateProductInfo()}}},[e("i",{staticClass:"el-icon-check"}),t._v("保存 ")])],1)],1)])],1)},r=[],n=o("5e31"),i=o("e01b"),c=o("7323"),s=o("9d32"),d=o("5be6"),l={name:"EditChainProduct",components:{UploadImageUrl:n["a"],RichTextEditor:i["a"]},data(){return{editChainProductInfo:{productId:"",catalogId:"",prodName:"",prodDesc:"",unitName:"",sort:"",content:"",states:[],state:"",coverPhoto:"",carouselFigurePhotos:[],productSpecs:[],areaCode:"",csId:""},chainCatalogs:[],rules:{catalogId:[{required:!0,message:"商品大类不能为空",trigger:"change"}],prodName:[{required:!0,message:"商品名称不能为空",trigger:"blur"},{max:128,message:"商品名称不能超过128位",trigger:"blur"}],prodDesc:[{required:!0,message:"商品简介不能为空",trigger:"blur"},{max:256,message:"商品简介不能超过256位",trigger:"blur"}],unitName:[{max:32,message:"单位不能超过32位",trigger:"blur"}],sort:[{pattern:/^\d+$/,message:"排序格式错误",trigger:"blur"}]}}},created(){this.editChainProductInfo.productId=this.$route.query.productId||"",this.editChainProductInfo.csId=this.$route.query.csId||"",this.initData()},methods:{async initData(){try{const{data:t}=await Object(c["e"])("product","state");this.editChainProductInfo.states=t,this._listEditCatalogs(),this._listProducts()}catch(t){console.error("初始化数据失败:",t)}},handleCoverImageUpload(t){t.length>0?this.editChainProductInfo.coverPhoto=t[0]:this.editChainProductInfo.coverPhoto=""},handleCarouselImageUpload(t){this.editChainProductInfo.carouselFigurePhotos=[],t.forEach(t=>{this.editChainProductInfo.carouselFigurePhotos.push(t)})},handleContentChange(t){this.editChainProductInfo.content=t},editProductValidate(){return new Promise(t=>{this.$refs.form.validate(e=>{t(e)})})},async updateProductInfo(){try{const t=this.editChainProductInfo.productSpecs.some(t=>"T"===t.isDefault);if(!t&&this.editChainProductInfo.productSpecs.length>0)return void this.$message.warning("未选择默认规格");const e=await this.editProductValidate();if(!e)return;const o=await Object(d["f"])(this.editChainProductInfo);0==o.code?(this.$message.success("修改成功"),this.$router.go(-1)):this.$message.error(o.msg)}catch(t){console.error("保存商品失败:",t),this.$message.error("保存商品失败")}},async _listProducts(){try{const t={page:1,row:1,productId:this.editChainProductInfo.productId,csId:this.editChainProductInfo.csId},e=await Object(d["b"])(t);if(404==e.code)return void this.$message.error("请检查供应链信息是否正确。");if(e.data&&e.data.length>0){const t=e.data[0];Object.assign(this.editChainProductInfo,{productId:t.productId||"",catalogId:t.catalogId||"",prodName:t.prodName||"",prodDesc:t.prodDesc||"",unitName:t.unitName||"",sort:t.sort||"",content:t.content||"",state:t.state||"",coverPhoto:t.coverPhoto||"",carouselFigurePhotos:t.carouselFigurePhotos||[],productSpecs:t.chainProductValueDtos||[],csId:t.csId||this.editChainProductInfo.csId}),t.coverPhoto&&this.$nextTick(()=>{this.$refs.coverImageUpload&&this.$refs.coverImageUpload.setImages([t.coverPhoto])}),t.carouselFigurePhotos&&t.carouselFigurePhotos.length>0&&this.$nextTick(()=>{this.$refs.carouselImageUpload&&this.$refs.carouselImageUpload.setImages(t.carouselFigurePhotos)}),t.content&&this.$nextTick(()=>{this.$refs.richTextEditor&&this.$refs.richTextEditor.setContent(t.content)})}}catch(t){console.error("获取商品详情失败:",t),this.$message.error("获取商品详情失败")}},_closeAddProduct(){this.$router.go(-1)},async _listEditCatalogs(){try{const t={page:1,row:50,csId:this.editChainProductInfo.csId},e=await Object(s["b"])(t);this.chainCatalogs=e.data||[]}catch(t){console.error("获取商品分类失败:",t)}},_editChainProductSpec(){const t={specName:"",specValue:"",price:0,barCode:"",isDefault:"F"};this.editChainProductInfo.productSpecs.push(t);const e=this.editChainProductInfo.productSpecs.some(t=>"T"===t.isDefault);!e&&this.editChainProductInfo.productSpecs.length>0&&(this.editChainProductInfo.productSpecs[0].isDefault="T")},_openAddDeleteProductSpec(t){const e=this.editChainProductInfo.productSpecs.indexOf(t);e>-1&&this.editChainProductInfo.productSpecs.splice(e,1);const o=this.editChainProductInfo.productSpecs.some(t=>"T"===t.isDefault);!o&&this.editChainProductInfo.productSpecs.length>0&&(this.editChainProductInfo.productSpecs[0].isDefault="T")},_doEditDefaultProductSpec(t,e){t.productSpecs.forEach(t=>{t.isDefault="F"}),e.isDefault="T",this.editChainProductInfo.productSpecs=JSON.parse(JSON.stringify(t.productSpecs))}}},u=l,p=(o("3a11"),o("2877")),h=Object(p["a"])(u,a,r,!1,null,"5906c012",null);e["default"]=h.exports},3645:function(t,e,o){},"3a11":function(t,e,o){"use strict";o("3645")},"5be6":function(t,e,o){"use strict";o.d(e,"b",(function(){return r})),o.d(e,"a",(function(){return n})),o.d(e,"d",(function(){return i})),o.d(e,"e",(function(){return c})),o.d(e,"f",(function(){return s}));var a=o("b775");function r(t){return new Promise((e,o)=>{Object(a["a"])({url:"/chainProduct.listChainProduct",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(a["a"])({url:"/chainProduct.deleteChainProduct",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function i(t){return new Promise((e,o)=>{Object(a["a"])({url:"/chainInoutOrder.saveChainInoutOrder",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function c(t){return new Promise((e,o)=>{Object(a["a"])({url:"/chainProduct.saveChainProduct",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function s(t){return new Promise((e,o)=>{Object(a["a"])({url:"/chainProduct.updateChainProduct",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}},"9d32":function(t,e,o){"use strict";o.d(e,"b",(function(){return r})),o.d(e,"c",(function(){return n})),o.d(e,"d",(function(){return i})),o.d(e,"a",(function(){return c}));var a=o("b775");function r(t){return new Promise((e,o)=>{Object(a["a"])({url:"/chainSupplierCatalog.listChainSupplierCatalog",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(a["a"])({url:"/chainSupplierCatalog.saveChainSupplierCatalog",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function i(t){return new Promise((e,o)=>{Object(a["a"])({url:"/chainSupplierCatalog.updateChainSupplierCatalog",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}function c(t){return new Promise((e,o)=>{Object(a["a"])({url:"/chainSupplierCatalog.deleteChainSupplierCatalog",method:"post",data:t}).then(t=>{const o=t.data;e(o)}).catch(t=>{o(t)})})}}}]);
|
|
//# sourceMappingURL=chunk-32916dde.7cd8406c.js.map
|