2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-a5f868fc"],{"1d48":function(t,e,a){"use strict";a.r(e);var o=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.addChainProductInfo,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.addChainProductInfo.prodName,callback:function(e){t.$set(t.addChainProductInfo,"prodName",e)},expression:"addChainProductInfo.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.addChainProductInfo.catalogId,callback:function(e){t.$set(t.addChainProductInfo,"catalogId",e)},expression:"addChainProductInfo.catalogId"}},[e("el-option",{attrs:{label:"必填,请选择商品分组",value:"",disabled:""}}),t._l(t.addChainProductInfo.catalogs,(function(t,a){return e("el-option",{key:a,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.addChainProductInfo.unitName,callback:function(e){t.$set(t.addChainProductInfo,"unitName",e)},expression:"addChainProductInfo.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.addChainProductInfo.sort,callback:function(e){t.$set(t.addChainProductInfo,"sort",e)},expression:"addChainProductInfo.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.addChainProductInfo.prodDesc,callback:function(e){t.$set(t.addChainProductInfo,"prodDesc",e)},expression:"addChainProductInfo.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._addChainProductSpec()}}},[e("i",{staticClass:"el-icon-plus"}),t._v("添加 ")])],1),e("div",{},[e("el-table",{staticStyle:{width:"100%"},attrs:{data:t.addChainProductInfo.productSpecs,border:""}},[e("el-table-column",{attrs:{prop:"specName",label:"规格名称",align:"center"},scopedSlots:t._u([{key:"default",fn:function(a){return[e("el-input",{attrs:{placeholder:"请输入规格名称"},model:{value:a.row.specName,callback:function(e){t.$set(a.row,"specName",e)},expression:"scope.row.specName"}})]}}])}),e("el-table-column",{attrs:{prop:"specValue",label:"规格值",align:"center"},scopedSlots:t._u([{key:"default",fn:function(a){return[e("el-input",{attrs:{placeholder:"请输入规格值"},model:{value:a.row.specValue,callback:function(e){t.$set(a.row,"specValue",e)},expression:"scope.row.specValue"}})]}}])}),e("el-table-column",{attrs:{prop:"price",label:"价格",align:"center"},scopedSlots:t._u([{key:"default",fn:function(a){return[e("el-input-number",{attrs:{precision:2,min:0},model:{value:a.row.price,callback:function(e){t.$set(a.row,"price",e)},expression:"scope.row.price"}})]}}])}),e("el-table-column",{attrs:{prop:"barCode",label:"条形码",align:"center"},scopedSlots:t._u([{key:"default",fn:function(a){return[e("el-input",{attrs:{placeholder:"请输入条形码"},model:{value:a.row.barCode,callback:function(e){t.$set(a.row,"barCode",e)},expression:"scope.row.barCode"}})]}}])}),e("el-table-column",{attrs:{label:"操作",align:"center",width:"180"},scopedSlots:t._u([{key:"default",fn:function(a){return[e("el-button",{attrs:{type:"danger",size:"mini"},on:{click:function(e){return t._openAddDeleteProductSpec(a.row)}}},[t._v(" 删除 ")]),"T"!=a.row.isDefault?e("el-button",{attrs:{type:"primary",size:"mini"},on:{click:function(e){return t._doAddDefaultProductSpec(t.addChainProductInfo,a.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.addChainProductInfo.state,callback:function(e){t.$set(t.addChainProductInfo,"state",e)},expression:"addChainProductInfo.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",{on:{input:t.handleContentChange},model:{value:t.addChainProductInfo.content,callback:function(e){t.$set(t.addChainProductInfo,"content",e)},expression:"addChainProductInfo.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.saveProductInfo()}}},[e("i",{staticClass:"el-icon-check"}),t._v("保存 ")])],1)],1)])],1)},r=[],n=a("5e31"),c=a("e01b"),d=a("7323"),s=a("9d32"),l=a("5be6"),i={name:"AddChainProduct",components:{UploadImageUrl:n["a"],RichTextEditor:c["a"]},data(){return{addChainProductInfo:{productId:"",catalogId:"",prodName:"",prodDesc:"",unitName:"",sort:"",catalogs:[],content:"",states:[],state:"",coverPhoto:"",carouselFigurePhoto:[],productSpecs:[],areaCode:"",csId:""},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.addChainProductInfo.csId=this.$route.query.csId||"",this.initData()},methods:{async initData(){try{const{data:t}=await Object(d["e"])("product","state");this.addChainProductInfo.states=t,this._listAddCatalogs()}catch(t){console.error("初始化数据失败:",t)}},handleCoverImageUpload(t){t.length>0?this.addChainProductInfo.coverPhoto=t[0]:this.addChainProductInfo.coverPhoto=""},handleCarouselImageUpload(t){this.addChainProductInfo.carouselFigurePhoto=[],t.forEach(t=>{this.addChainProductInfo.carouselFigurePhoto.push(t)})},handleContentChange(t){this.addChainProductInfo.content=t},addProductValidate(){return new Promise(t=>{this.$refs.form.validate(e=>{t(e)})})},async saveProductInfo(){try{const t=this.addChainProductInfo.productSpecs.some(t=>"T"===t.isDefault);if(!t&&this.addChainProductInfo.productSpecs.length>0)return void this.$message.warning("未选择默认规格");const e=await this.addProductValidate();if(!e)return;const a=await Object(l["e"])(this.addChainProductInfo);0==a.code?(this.$message.success("添加成功"),this.clearAddProductInfo(),this.$router.go(-1)):this.$message.error(a.msg)}catch(t){console.error("保存商品失败:",t),this.$message.error("保存商品失败")}},clearAddProductInfo(){const t=this.addChainProductInfo.catalogs,e=this.addChainProductInfo.csId;this.addChainProductInfo={productId:"",catalogId:"",prodName:"",prodDesc:"",unitName:"",sort:"",catalogs:t,content:"",states:[],state:"",coverPhoto:"",carouselFigurePhoto:[],productSpecs:[],areaCode:"",csId:e},this.$refs.form&&this.$refs.form.resetFields(),this.$refs.coverImageUpload&&this.$refs.coverImageUpload.clearImages(),this.$refs.carouselImageUpload&&this.$refs.carouselImageUpload.clearImages()},_closeAddProduct(){this.$router.go(-1)},async _listAddCatalogs(){try{const t={page:1,row:50,csId:this.addChainProductInfo.csId},e=await Object(s["b"])(t);this.addChainProductInfo.catalogs=e.data||[]}catch(t){console.error("获取商品分类失败:",t)}},_addChainProductSpec(){const t={specName:"",specValue:"",price:0,barCode:"",isDefault:"F"};this.addChainProductInfo.productSpecs.push(t),!this.addChainProductInfo.productSpecs.some(t=>"T"===t.isDefault)&&this.addChainProductInfo.productSpecs.length>0&&(this.addChainProductInfo.productSpecs[0].isDefault="T")},_openAddDeleteProductSpec(t){const e=this.addChainProductInfo.productSpecs.indexOf(t);e>-1&&this.addChainProductInfo.productSpecs.splice(e,1),!this.addChainProductInfo.productSpecs.some(t=>"T"===t.isDefault)&&this.addChainProductInfo.productSpecs.length>0&&(this.addChainProductInfo.productSpecs[0].isDefault="T")},_doAddDefaultProductSpec(t,e){t.productSpecs.forEach(t=>{t.isDefault="F"}),e.isDefault="T",this.addChainProductInfo.productSpecs=JSON.parse(JSON.stringify(t.productSpecs))}}},u=i,p=(a("bc1c"),a("2877")),h=Object(p["a"])(u,o,r,!1,null,"5231f31f",null);e["default"]=h.exports},"5be6":function(t,e,a){"use strict";a.d(e,"b",(function(){return r})),a.d(e,"a",(function(){return n})),a.d(e,"d",(function(){return c})),a.d(e,"e",(function(){return d})),a.d(e,"f",(function(){return s}));var o=a("b775");function r(t){return new Promise((e,a)=>{Object(o["a"])({url:"/chainProduct.listChainProduct",method:"get",params:t}).then(t=>{const a=t.data;e(a)}).catch(t=>{a(t)})})}function n(t){return new Promise((e,a)=>{Object(o["a"])({url:"/chainProduct.deleteChainProduct",method:"post",data:t}).then(t=>{const a=t.data;e(a)}).catch(t=>{a(t)})})}function c(t){return new Promise((e,a)=>{Object(o["a"])({url:"/chainInoutOrder.saveChainInoutOrder",method:"post",data:t}).then(t=>{const a=t.data;e(a)}).catch(t=>{a(t)})})}function d(t){return new Promise((e,a)=>{Object(o["a"])({url:"/chainProduct.saveChainProduct",method:"post",data:t}).then(t=>{const a=t.data;e(a)}).catch(t=>{a(t)})})}function s(t){return new Promise((e,a)=>{Object(o["a"])({url:"/chainProduct.updateChainProduct",method:"post",data:t}).then(t=>{const a=t.data;e(a)}).catch(t=>{a(t)})})}},"91b9":function(t,e,a){},"9d32":function(t,e,a){"use strict";a.d(e,"b",(function(){return r})),a.d(e,"c",(function(){return n})),a.d(e,"d",(function(){return c})),a.d(e,"a",(function(){return d}));var o=a("b775");function r(t){return new Promise((e,a)=>{Object(o["a"])({url:"/chainSupplierCatalog.listChainSupplierCatalog",method:"get",params:t}).then(t=>{const a=t.data;e(a)}).catch(t=>{a(t)})})}function n(t){return new Promise((e,a)=>{Object(o["a"])({url:"/chainSupplierCatalog.saveChainSupplierCatalog",method:"post",data:t}).then(t=>{const a=t.data;e(a)}).catch(t=>{a(t)})})}function c(t){return new Promise((e,a)=>{Object(o["a"])({url:"/chainSupplierCatalog.updateChainSupplierCatalog",method:"post",data:t}).then(t=>{const a=t.data;e(a)}).catch(t=>{a(t)})})}function d(t){return new Promise((e,a)=>{Object(o["a"])({url:"/chainSupplierCatalog.deleteChainSupplierCatalog",method:"post",data:t}).then(t=>{const a=t.data;e(a)}).catch(t=>{a(t)})})}},bc1c:function(t,e,a){"use strict";a("91b9")}}]);
|
|
//# sourceMappingURL=chunk-a5f868fc.6bf55cca.js.map
|