You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

2 lines
18 KiB

"use strict";(self["webpackChunkabcdf"]=self["webpackChunkabcdf"]||[]).push([[95],{1734:function(e,t,i){i.d(t,{A:function(){return d}});var s=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{title:("add"===e.type?"新增":"编辑")+"收货地址",visible:e.visible,width:"700px"},on:{close:e.handleClose}},[t("el-form",{ref:"addressForm",attrs:{model:e.form,rules:e.rules,"label-width":"100px",size:"small"}},[t("el-form-item",{attrs:{label:"收货人",prop:"username"}},[t("el-input",{attrs:{placeholder:"请填写收货人姓名,限制10个字符",maxlength:"10"},model:{value:e.form.username,callback:function(t){e.$set(e.form,"username",t)},expression:"form.username"}})],1),t("el-form-item",{attrs:{label:"所在地区",prop:"region"}},[t("div",{staticClass:"region-selector"},[t("el-select",{staticClass:"region-select",attrs:{placeholder:"选择省份/直辖市"},on:{change:e.handleProvinceChange},model:{value:e.form.province_id,callback:function(t){e.$set(e.form,"province_id",t)},expression:"form.province_id"}},e._l(e.provinces,function(e){return t("el-option",{key:e.id,attrs:{label:e.name,value:e.id}})}),1),t("el-select",{staticClass:"region-select",attrs:{placeholder:"选择城市",disabled:!e.form.province_id},on:{change:e.handleCityChange},model:{value:e.form.city_id,callback:function(t){e.$set(e.form,"city_id",t)},expression:"form.city_id"}},e._l(e.cities,function(e){return t("el-option",{key:e.id,attrs:{label:e.name,value:e.id}})}),1),t("el-select",{staticClass:"region-select",attrs:{placeholder:"选择县区",disabled:!e.form.city_id},model:{value:e.form.district_id,callback:function(t){e.$set(e.form,"district_id",t)},expression:"form.district_id"}},e._l(e.districts,function(e){return t("el-option",{key:e.id,attrs:{label:e.name,value:e.id}})}),1)],1)]),t("el-form-item",{attrs:{label:"详细地址",prop:"detail_addr"}},[t("el-input",{attrs:{placeholder:"请填写详细地址,限制500个字符",maxlength:"500"},model:{value:e.form.detail_addr,callback:function(t){e.$set(e.form,"detail_addr",t)},expression:"form.detail_addr"}})],1),t("el-form-item",{attrs:{label:"手机号码",prop:"mobile"}},[t("el-input",{attrs:{placeholder:"请填写手机号码,限制11位数字",maxlength:"11",oninput:"value=value.replace(/[^\\d]/g,'')"},model:{value:e.form.mobile,callback:function(t){e.$set(e.form,"mobile",t)},expression:"form.mobile"}})],1)],1),t("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{attrs:{size:"small"},on:{click:e.handleClose}},[e._v("取消")]),t("el-button",{attrs:{size:"small",type:"primary"},on:{click:e.saveAddress}},[e._v("保存")])],1)],1)},a=[],r=(i(8111),i(2489),i(116),{name:"AddressFormDialog",props:{visible:{type:Boolean,default:!1},type:{type:String,required:!0,validator:e=>["add","edit"].includes(e)},initialData:{type:Object,default:()=>({})}},data(){const e=(e,t,i)=>t?/^1[3-9]\d{9}$/.test(t)?void i():i(new Error("请输入正确的11位手机号码")):i(new Error("请输入手机号码")),t=(e,t,i)=>{if(!this.form.province_id||!this.form.city_id||!this.form.district_id)return i(new Error("请完整选择省市区"));i()};return{form:{id:null,username:"",detail_addr:"",mobile:"",province_id:null,city_id:null,district_id:null,region:""},rules:{username:[{required:!0,message:"请输入收货人姓名",trigger:"blur"},{max:10,message:"姓名不能超过10个字符",trigger:"blur"}],region:[{required:!0,validator:t,trigger:"change"}],detail_addr:[{required:!0,message:"请输入详细地址",trigger:"blur"},{max:500,message:"详细地址不能超过500个字符",trigger:"blur"}],mobile:[{required:!0,validator:e,trigger:"blur"}]},regionData:[]}},computed:{provinces(){return this.regionData.filter(e=>1===e.level)},cities(){return this.form.province_id?this.regionData.filter(e=>2===e.level&&e.pid===this.form.province_id):[]},districts(){return this.form.city_id?this.regionData.filter(e=>3===e.level&&e.pid===this.form.city_id):[]}},watch:{visible(e){e&&this.initForm()},initialData:{handler(){this.visible&&this.initForm()},deep:!0}},mounted(){this.getRegionData()},methods:{async getRegionData(){try{const e=await this.post({},"/api/uservice/user/getAreas");e&&e.data?this.regionData=e.data:this.$message.error("获取地区数据失败")}catch(e){console.error("获取地区数据出错:",e),this.$message.error("获取地区数据时发生错误")}},initForm(){this.$nextTick(()=>{this.$refs.addressForm&&this.$refs.addressForm.resetFields(),this.form={id:"edit"===this.type?this.initialData.id:null,username:this.initialData.username||"",detail_addr:this.initialData.detail_addr||"",mobile:this.initialData.mobile||"",province_id:this.initialData.province_id||null,city_id:this.initialData.city_id||null,district_id:this.initialData.district_id||null,region:this.initialData.region||""},"edit"===this.type&&this.initialData.region&&!this.form.province_id&&this.echoRegionSelection(this.initialData.region)})},echoRegionSelection(e){const t=e.split(" ");if(t.length<3)return;const i=this.provinces.find(e=>e.name===t[0]);i&&(this.form.province_id=i.id,this.$nextTick(()=>{const e=this.cities.find(e=>e.name===t[1]);e&&(this.form.city_id=e.id,this.$nextTick(()=>{const e=this.districts.find(e=>e.name===t[2]);e&&(this.form.district_id=e.id)}))}))},handleProvinceChange(){this.form.city_id=null,this.form.district_id=null},handleCityChange(){this.form.district_id=null},saveAddress(){this.$refs.addressForm.validate(async e=>{if(!e)return;const t=this.provinces.find(e=>e.id===this.form.province_id),i=this.cities.find(e=>e.id===this.form.city_id),s=this.districts.find(e=>e.id===this.form.district_id);if(!(t&&i&&s))return void this.$message.warning("地区信息不完整");const a={...this.form,region:`${t.name} ${i.name} ${s.name}`};this.$emit("save",a),this.handleClose()})},handleClose(){this.$emit("update:visible",!1)}}}),o=r,l=i(1656),n=(0,l.A)(o,s,a,!1,null,"7d3ebefd",null),d=n.exports},5095:function(e,t,i){i.r(t),i.d(t,{default:function(){return u}});var s=function(){var e=this,t=e._self._c;return t("div",{staticClass:"order-page"},[t("div",{staticClass:"page-header"},[t("h2",[e._v("填写收货人信息")]),t("el-button",{staticClass:"address-book-btn",attrs:{type:"text"},on:{click:function(t){return e.openDialog("add",{})}}},[e._v(" 新增/修改地址 ")])],1),t("div",{staticClass:"info-section"},[t("h3",[e._v("收货人信息")]),t("div",{staticClass:"address-item"},[t("span",{staticClass:"label"},[e._v("收货地址:")]),t("div",{staticClass:"address-content"},e._l(e.addresses,function(i,s){return t("div",{key:s,staticClass:"saved-address",class:{selected:e.selectedAddressIndex===s},on:{click:function(t){return e.selectAddress(s)}}},[t("span",{staticClass:"name-tag"},[e._v(e._s(i.name)+" "+e._s(i.province))]),t("span",{staticClass:"detail"},[e._v(e._s(i.address)+" "+e._s(i.phone))]),t("el-button",{staticClass:"edit-btn",attrs:{type:"text"},on:{click:function(t){return t.stopPropagation(),e.handleEdit(i)}}},[e._v("编辑")]),t("el-button",{staticClass:"delete-btn",attrs:{type:"text"},on:{click:function(t){return t.stopPropagation(),e.handleDelete()}}},[e._v("删除")])],1)}),0)]),t("h3",[e._v("发票信息")]),t("div",{staticClass:"invoice-type-item"},[t("span",{staticClass:"label"},[e._v("是否开票:")]),t("el-radio-group",{model:{value:e.needInvoice,callback:function(t){e.needInvoice=t},expression:"needInvoice"}},[t("el-radio",{attrs:{label:!0}},[e._v("是")]),t("el-radio",{attrs:{label:!1}},[e._v("否")])],1)],1),e.needInvoice?t("div",{staticClass:"invoice-type-item"},[t("span",{staticClass:"label"},[e._v("发票类型:")]),t("el-radio-group",{model:{value:e.invoice_type,callback:function(t){e.invoice_type=t},expression:"invoice_type"}},[t("el-radio",{attrs:{label:1}},[e._v("增值税普通发票")]),t("el-radio",{attrs:{label:2}},[e._v("普通电子发票")])],1)],1):e._e(),e.needInvoice?t("div",{staticClass:"invoice-title-item"},[t("span",{staticClass:"label"},[e._v("发票抬头:")]),t("el-select",{staticClass:"invoice-title-select",attrs:{placeholder:"请选择发票抬头"},model:{value:e.selectedInvoiceTitle,callback:function(t){e.selectedInvoiceTitle=t},expression:"selectedInvoiceTitle"}},e._l(e.invoiceTitles,function(e,i){return t("el-option",{key:i,attrs:{label:e.invoice_head,value:e.id}})}),1),t("el-button",{staticClass:"add-title-btn",attrs:{type:"text"},on:{click:e.openTitleDialog}},[e._v("+ 添加")])],1):e._e()]),e._m(0),t("div",{staticClass:"goods-section"},[t("h3",[e._v("商品清单")]),e._l(e.orderGroups,function(i,s){return t("div",{key:s,staticClass:"order-group"},[t("div",{staticClass:"supplier-info"},[t("span",[e._v("供货名称:"+e._s(i.supplier))])]),t("table",{staticClass:"goods-table"},[e._m(1,!0),t("tbody",e._l(i.items,function(i,s){return t("tr",{key:s},[t("td",[t("img",{staticClass:"goods-img",attrs:{src:i.image,alt:"商品图片"}}),t("span",{staticClass:"goods-name"},[e._v(e._s(i.name))])]),t("td",[e._v(e._s(i.spec))]),t("td",[e._v(e._s(i.price))]),t("td",[e._v(e._s(i.quantity))]),t("td",[e._v(e._s(i.freight))]),t("td",[e._v(e._s(i.deliveryType))]),t("td",{staticClass:"subtotal"},[e._v(e._s(i.subtotal))])])}),0)]),t("div",{staticClass:"order-remark"},[t("span",{staticClass:"remark-label"},[e._v("订单备注:")]),t("div",{staticClass:"rich-text-editor"},[t("el-input",{staticClass:"remark-editor",attrs:{type:"textarea",rows:"4",placeholder:"请输入订单备注信息"},model:{value:i.remark,callback:function(t){e.$set(i,"remark",t)},expression:"group.remark"}}),e._e()],1)])])}),t("div",{staticClass:"total-info"},[t("p",[e._v(" 共 "+e._s(e.totalGoodsCount)+" 件商品,总商品金额 ¥"+e._s(e.totalGoodsAmount)+" ")]),t("p",[e._v("总运费 ¥"+e._s(e.totalFreight))]),t("p",{staticClass:"pay-amount"},[e._v("实付总金额 ¥"+e._s(e.totalPayAmount))]),t("p",{staticClass:"address-info"},[e._v(" 配送地:"+e._s(e.selectedAddress.address)),t("br"),e._v(" 交货地:"+e._s(e.selectedAddress.address)+" "+e._s(e.selectedAddress.phone)+" ")]),t("el-button",{staticClass:"submit-btn",attrs:{type:"primary"},on:{click:e.submitOrder}},[e._v(" 提交订单 ")])],1)],2),t("AddressFormDialog",{attrs:{visible:e.dialogVisible,type:e.dialogType,"initial-data":e.dialogData},on:{"update:visible":function(t){e.dialogVisible=t},save:e.handleSaveAddress}}),t("el-dialog",{attrs:{title:"新增发票抬头",visible:e.invoiceTitleDialogVisible,width:"700px","before-close":e.handleTitleDialogClose},on:{"update:visible":function(t){e.invoiceTitleDialogVisible=t}}},[t("el-form",{ref:"titleForm",staticClass:"invoice-title-form",attrs:{model:e.titleForm,rules:e.titleRules,"label-width":"120px"}},[t("el-form-item",{attrs:{label:"发票抬头",prop:"invoice_head"}},[t("el-input",{attrs:{placeholder:"请输入发票抬头",maxlength:"100"},model:{value:e.titleForm.invoice_head,callback:function(t){e.$set(e.titleForm,"invoice_head",t)},expression:"titleForm.invoice_head"}})],1),t("el-form-item",{attrs:{label:"纳税人识别号",prop:"tax_number"}},[t("el-input",{attrs:{placeholder:"请输入纳税人识别号",maxlength:"20"},model:{value:e.titleForm.tax_number,callback:function(t){e.$set(e.titleForm,"tax_number",t)},expression:"titleForm.tax_number"}})],1),t("el-form-item",{attrs:{label:"开户银行",prop:"opening_bank"}},[t("el-input",{attrs:{placeholder:"请输入开户银行",maxlength:"100"},model:{value:e.titleForm.opening_bank,callback:function(t){e.$set(e.titleForm,"opening_bank",t)},expression:"titleForm.opening_bank"}})],1),t("el-form-item",{attrs:{label:"银行账号",prop:"bank_account"}},[t("el-input",{attrs:{placeholder:"请输入银行账号",maxlength:"30"},model:{value:e.titleForm.bank_account,callback:function(t){e.$set(e.titleForm,"bank_account",t)},expression:"titleForm.bank_account"}})],1)],1),t("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:e.handleTitleDialogClose}},[e._v("取消")]),t("el-button",{attrs:{type:"primary"},on:{click:e.saveInvoiceTitle}},[e._v("确定")])],1)],1)],1)},a=[function(){var e=this,t=e._self._c;return t("div",{staticClass:"contract-section"},[t("h3",[e._v("签署合同")]),t("p",[e._v("如需签署合同,提交订单后,请至采购中心>合同中心签署")])])},function(){var e=this,t=e._self._c;return t("thead",[t("tr",[t("th",[e._v("商品")]),t("th",[e._v("规格")]),t("th",[e._v("单价(元)")]),t("th",[e._v("数量")]),t("th",[e._v("运费")]),t("th",[e._v("收货方式")]),t("th",[e._v("小计(元)")])])])}],r=(i(4114),i(8111),i(7588),i(1701),i(3518)),o=i(1734),l={name:"OrderPage",components:{AddressFormDialog:o.A},data(){return{addresses:[],selectedAddressIndex:-1,selectedTradeType:1,needInvoice:!1,invoice_type:1,invoiceTitles:[],selectedInvoiceTitle:null,orderGroups:[],totalGoodsCount:3,totalGoodsAmount:973,totalFreight:0,totalPayAmount:0,dialogVisible:!1,dialogType:"add",dialogData:{},invoiceTitleDialogVisible:!1,titleForm:{invoice_head:"",tax_number:"",opening_bank:"",bank_account:""},titleRules:{invoice_head:[{required:!0,message:"请输入发票抬头",trigger:"blur"}],tax_number:[{required:!0,message:"请输入纳税人识别号",trigger:"blur"},{pattern:/^[A-Z0-9]{15,20}$/,message:"纳税人识别号格式不正确",trigger:"blur"}],opening_bank:[{required:!0,message:"请输入开户银行",trigger:"blur"}],bank_account:[{required:!0,message:"请输入银行账号",trigger:"blur"}]}}},computed:{...(0,r.L8)(["getOrderData"]),selectedAddress(){return this.addresses[this.selectedAddressIndex]||{}}},mounted(){this.getOrderData?(this.initOrderData(this.getOrderData),console.log(this.getOrderData)):(this.$message.error("未获取到商品信息,请重新操作"),this.$router.go(-1)),this.getAddress(),this.getInvoiceList()},methods:{...(0,r.PY)(["clearOrderData"]),openTitleDialog(){this.invoiceTitleDialogVisible=!0,this.$nextTick(()=>{this.$refs.titleForm.resetFields()})},handleTitleDialogClose(){this.invoiceTitleDialogVisible=!1,this.$refs.titleForm.resetFields()},saveInvoiceTitle(){this.$refs.titleForm.validate(e=>{e&&this.post(this.titleForm,"/api/enterprise_invoice/create").then(e=>{1==e.code&&(this.getInvoiceList(),this.$message.success("发票抬头添加成功"),this.invoiceTitleDialogVisible=!1)})})},getInvoiceList(){this.post({offset:0,limit:100},"/api/enterprise_invoice/index").then(e=>{this.invoiceTitles=e.data})},openDialog(e,t){this.dialogType=e,this.dialogData={...t},this.dialogVisible=!0},handleEdit(e){console.log(e),e.username=e.name,e.mobile=e.tel,this.openDialog("edit",e)},handleDelete(e){this.$confirm("此操作将永久删除该地址, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{this.post({id:e.id},"/api/uservice/user/delConsignee").then(e=>{1==e.code&&(this.getAddress(),this.$message.success("删除成功!"))})}).catch(()=>{this.$message.info("已取消删除")})},initOrderData(e){if("product"===e.from){const t=e.items[0];this.orderGroups=[{supplier:t.product.supplier_name,items:this.formatItems([t])}]}else"cart"===e.from&&(this.orderGroups=Object.entries(e.groups).map(([e,t])=>({supplier:e,items:this.formatItems(t)})));this.calculateTotal()},formatItems(e){return console.log(e,13213),e.map(e=>({id:e.sku.id,productId:e.product.id,name:e.product.title,image:e.product.headimg,spec:e.sku.sku_name,price:(e.sku.price/100).toFixed(2),quantity:e.quantity,freight:"0.00",deliveryType:"邮寄",type:e.product.type,subtotal:(e.sku.price/100*e.quantity+parseFloat("0.00")).toFixed(2)}))},getPost(){if(!this.selectedAddress.id)return void this.$message.warning("请先选择收货地址");this.totalFreight=0;const e=[];this.orderGroups.forEach((t,i)=>{t.items.forEach((t,i)=>{const s={consignee_id:this.selectedAddress.id,sku_id:t.id,num:t.quantity},a=this.post(s,"/api/order/get_post_price").then(e=>{if(1===e.code){const i=(e.data.price/100).toFixed(2);t.freight=i,t.subtotal=(parseFloat(t.price)*t.quantity+parseFloat(i)).toFixed(2),this.totalFreight=(parseFloat(this.totalFreight)+parseFloat(i)).toFixed(2)}}).catch(e=>{console.error(`获取商品 ${t.id} 邮费失败`,e),this.$message.error(`获取商品 ${t.name} 邮费失败,请重试`)});e.push(a)})}),Promise.all(e).then(()=>{this.calculateTotal()})},calculateTotalFreight(){let e=0;this.orderGroups.forEach(t=>{t.items.forEach(t=>{console.log(t),e+=parseFloat(t.freight)})}),this.totalFreight=e.toFixed(2)},calculateTotal(){let e=0,t=0;this.orderGroups.forEach(i=>{i.items.forEach(i=>{e+=i.quantity,t+=parseFloat(i.subtotal)})}),this.totalGoodsCount=e,this.totalGoodsAmount=t.toFixed(2),this.totalPayAmount=t.toFixed(2)},handleSaveAddress(e){e.is_default=0,"add"===this.dialogType?this.post(e,"/api/uservice/user/addNewConsignee").then(e=>{1==e.code&&(this.$message.success("保存成功"),this.getAddress(),this.dialogVisible=!1)}):this.post(e,"/api/uservice/user/editConsignee").then(e=>{1==e.code&&(this.$message.success("保存成功"),this.getAddress(),this.dialogVisible=!1)})},getAddress(){this.post({contactType:"CONSIGNEE",offset:"0",limit:"100"},"/api/uservice/user/getContactOrConsignee").then(e=>{e&&(this.addresses=e.data||[])})},selectAddress(e){this.selectedAddressIndex=e,this.getPost()},submitOrder(){if(!this.selectedAddress.id)return void this.$message.warning("请先选择收货地址");if(this.needInvoice&&null===this.selectedInvoiceTitle)return void this.$message.warning("请选择发票抬头");let e=[];this.orderGroups.forEach((t,i)=>{t.items.forEach((i,s)=>{console.log(i),e.push({type:i.type,product_id:i.productId,sku_id:i.id,product_num:i.quantity,post:this.selectedAddress.id,remark:t.remark||""})})});let t={product_list:e,invoice_id:this.selectedInvoiceTitle,invoice_type:this.invoice_type};this.post({data:JSON.stringify(t)},"/api/order/create").then(e=>{1==e.code&&(this.$message.success("订单提交成功!"),this.$router.push("/User/OrderList"))})}}},n=l,d=i(1656),c=(0,d.A)(n,s,a,!1,null,"71e54fa2",null),u=c.exports}}]);
//# sourceMappingURL=95.41c718be.js.map