chunk-45e1e6d7.691dc409.js 8.5 KB

1
  1. (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-45e1e6d7"],{"4a8f":function(t,e,s){"use strict";s.r(e);var a=function(){var t=this,e=t._self._c;return e("div",{staticClass:"body"},[e("a-page-header",{staticStyle:{background:"#fff"},attrs:{title:"生成采购单"},on:{back:function(e){return t.$router.back()}}}),e("div",{staticClass:"pad20"},[e("h4",[t._v("商品设置")]),e("a-alert",{staticStyle:{"margin-bottom":"10px"},attrs:{message:"切换供货商则重置商品",type:"info"}}),e("a-form-model",{ref:"form",attrs:{rules:t.rules,model:t.form,labelCol:{span:3},wrapperCol:{span:21}}},[e("a-form-model-item",{attrs:{label:"选择供货商",prop:"supplier_id",help:"修改供货商会同步更新商品"}},[e("a-select",{staticClass:"inp",attrs:{allowClear:"",placeholder:"请选择"},on:{change:function(e){return t.handle("changeSupplier")}},model:{value:t.form.supplier_id,callback:function(e){t.$set(t.form,"supplier_id",e)},expression:"form.supplier_id"}},t._l(t.supplierList,(function(s){return e("a-select-option",{key:s.id,attrs:{value:s.id}},[t._v(t._s(s.name))])})),1)],1),e("a-form-model-item",{attrs:{label:"选择商品",required:""}},[e("a-button",{staticStyle:{"margin-bottom":"20px"},attrs:{type:"primary"},on:{click:function(e){return t.handle("add")}}},[t._v("添加商品")]),e("a-button",{staticStyle:{"margin-left":"10px","margin-bottom":"20px"},attrs:{type:"primary"},on:{click:function(e){return t.handle("allRemove")}}},[t._v("全部删除")]),e("a-table",{staticStyle:{width:"100%","overflow-x":"auto"},attrs:{size:"default",columns:t.columns2,"data-source":t.form.purchase,"row-key":t=>t.id,scroll:{x:1500,y:400},pagination:!1},scopedSlots:t._u([{key:"content",fn:function(s,a){return e("span",{},[e("div",{staticClass:"content"},[e("div",{staticClass:"img"},[e("a-avatar",{attrs:{shape:"square",size:48,icon:"user",src:a.cover_pic}})],1),e("div",{staticClass:"txt"},[e("h3",[t._v(t._s(a.goods_name))]),e("p",[t._v(t._s(a.attr_names))])])])])}},{key:"num",fn:function(s,a){return e("span",{},[e("a-input-number",{attrs:{min:0,precision:0},model:{value:a.num,callback:function(e){t.$set(a,"num",e)},expression:"item.num"}})],1)}},{key:"price",fn:function(s){return e("span",{},[t._v(" ¥"+t._s(s||"0.00")+" ")])}},{key:"action",fn:function(s,a,i){return e("span",{},[e("a-popconfirm",{attrs:{title:"是否删除?","ok-text":"确定"},on:{confirm:function(e){return t.handle("remove",i)}}},[e("a-button",{attrs:{type:"link",size:"small"}},[t._v("删除")])],1)],1)}}])},[e("div",{staticStyle:{padding:"8px"},attrs:{slot:"numDropdown"},slot:"numDropdown"},[e("a-input-search",{attrs:{size:"small",placeholder:"批量设置"},on:{search:e=>t.settingDayAll(e,"num")}},[e("a-icon",{attrs:{slot:"enterButton",type:"plus"},slot:"enterButton"})],1)],1)])],1)],1),e("div",{staticClass:"tc"},[e("a-button",{staticStyle:{"margin-right":"20px"},on:{click:function(e){return t.$router.back()}}},[t._v(" 取消 ")]),e("a-button",{attrs:{loading:t.btnLoading,type:"primary"},on:{click:t.submitForm}},[t._v(" 保存 ")])],1)],1),e("ContentDetails",{ref:"pop",attrs:{title:"选择商品"},on:{ok:function(e){return t.handle("ok")}}},[t.selectGoodsList.length>0?e("a-row",{staticClass:"img-list",attrs:{type:"flex",align:"middle"}},t._l(t.selectGoodsList,(function(s,a){return e("img",{key:a,staticClass:"selectImg",staticStyle:{width:"30px",height:"30px","margin-right":"10px"},attrs:{src:s.cover_pic,alt:""},on:{click:function(e){return t.delSelect(a)}}})})),0):t._e(),e("div",{staticClass:"table-page-search-box",staticStyle:{"margin-bottom":"10px"}},[e("a-form",{attrs:{layout:"inline"}},[e("a-row",{attrs:{gutter:24}},[e("a-col",{attrs:{md:8,sm:24}},[e("a-form-item",{attrs:{label:"商品名称"}},[e("div",{staticClass:"flex"},[e("a-input",{attrs:{"allow-clear":"",placeholder:"请输入商品名称"},model:{value:t.goods_name,callback:function(e){t.goods_name=e},expression:"goods_name"}}),e("a-button",{attrs:{type:"primary"},on:{click:function(e){return t.getList()}}},[t._v("查询")])],1)])],1),e("a-col",{attrs:{md:8,sm:24}},[e("a-form-item",{attrs:{label:""}},[e("a-button",{attrs:{type:"primary"},on:{click:function(e){return t.handle("allSelect")}}},[t._v("批量选择")])],1)],1)],1)],1)],1),e("a-table",{staticStyle:{width:"100%","overflow-x":"auto"},attrs:{size:"default",columns:t.columns,"data-source":t.list,"row-key":t=>t.id,scroll:{x:1500,y:400},pagination:{current:t.pageNo,total:t.total,pageSize:t.pageSize,onShowSizeChange:t.onShowSizeChange,showSizeChanger:!1,onChange:t.tablePageChange},rowSelection:{selectedRowKeys:t.selectedRowKeys,onChange:t.onSelectChange}},scopedSlots:t._u([{key:"content",fn:function(s,a){return e("span",{},[e("div",{staticClass:"content"},[e("div",{staticClass:"img"},[e("a-avatar",{attrs:{shape:"square",size:48,icon:"user",src:a.cover_pic}})],1),e("div",{staticClass:"txt"},[e("h3",[t._v(t._s(a.goods_name))]),e("p",[t._v(t._s(a.attr_names))])])])])}},{key:"action",fn:function(s,a){return e("span",{},[e("a-button",{attrs:{type:"link",size:"small"},on:{click:function(e){return t.handle("selectGoods",a)}}},[t._v("选择")])],1)}}])})],1)],1)},i=[],o=(s("14d9"),s("0fc4"));const n=[{title:"ID",dataIndex:"id",width:80},{title:"商品信息",dataIndex:"content",scopedSlots:{customRender:"content"}},{title:"当前库存",dataIndex:"num"},{title:"价格",dataIndex:"price"},{title:"操作",scopedSlots:{customRender:"action"},width:180,fixed:"right"}],r=[{title:"ID",dataIndex:"id",width:80},{title:"商品信息",dataIndex:"content",scopedSlots:{customRender:"content"}},{title:"价格",dataIndex:"price"},{title:"采购数量",scopedSlots:{filterDropdown:"numDropdown",filterIcon:"numIcon",customRender:"num"}},{title:"操作",scopedSlots:{customRender:"action"},width:180,fixed:"right"}];var c={components:{ContentDetails:()=>s.e("chunk-2d222176").then(s.bind(null,"ccaa"))},data(){return{total:0,pageNo:1,pageSize:10,columns:n,columns2:r,goods_name:"",btnLoading:!1,list:[],selectGoodsList:[],rules:{supplier_id:[{required:!0,message:"请选择",trigger:"change"}]},form:{supplier_id:"",purchase:[]},supplierList:[],selectedRowKeys:[]}},created(){Object(o["I"])({warning:1}).then(t=>{0==t.code&&(this.supplierList=t.data)})},methods:{onSelectChange(t){this.selectedRowKeys=t},onShowSizeChange(t,e){this.pageSize=e,this.getList(t)},settingDayAll(t,e){this.form.purchase.forEach(s=>{s[e]=t})},delSelect(t){this.selectGoodsList.splice(t,1)},async warningList(){const t=await Object(o["Q"])({supplier_id:this.form.supplier_id});if(!t.code&&t.data.list)try{t.data.list.forEach(t=>{this.form.purchase.push({id:t.id,price:t.price,cover_pic:t.cover_pic,goods_name:t.goods_name,attr_names:t.attr_names,num:0})})}catch(e){}},handle(t,e){switch(t){case"add":if(!this.form.supplier_id)return this.$message.error("请先选择供货商~");this.$refs.pop.visible=!0;break;case"changeSupplier":this.form.purchase=[],this.getList(),this.warningList();break;case"selectGoods":if(this.selectGoodsList.find(t=>t.id===e.id))return;this.selectGoodsList.push({id:e.id,price:e.price,cover_pic:e.cover_pic,goods_name:e.goods_name,attr_names:e.attr_names,num:0});break;case"ok":this.form.purchase=[...this.selectGoodsList],this.selectGoodsList=[],this.$refs.pop.visible=!1;break;case"allRemove":this.form.purchase=[];break;case"allSelect":if(!this.selectedRowKeys.length)return this.$message.error("请至少选择一项");const t=this.selectGoodsList.map(t=>t.id),s=this.selectedRowKeys.filter(e=>-1===t.indexOf(e));s.length&&this.list.forEach(t=>{-1!==s.indexOf(t.id)&&this.selectGoodsList.push({id:t.id,price:t.price,cover_pic:t.cover_pic,goods_name:t.goods_name,attr_names:t.attr_names,num:0})}),this.selectedRowKeys=[];break;case"remove":this.form.purchase.splice(e,1);break;default:break}},async getList(t=1){const{form:e,pageSize:s,goods_name:a}=this,i=await Object(o["o"])({supplier_id:e.supplier_id,pageSize:s,pageNo:t,goods_name:a});if(0==i.code){this.pageNo=t,this.selectedRowKeys=[];const{totalCount:e,list:s}=i.data;this.total=e,this.list=s}},tablePageChange(t){this.getList(t)},submitForm(){this.$refs.form.validate(async t=>{if(t)try{const t=JSON.parse(JSON.stringify(this.form));if(!t.purchase.every(t=>t.num))return this.$message.error("请完善采购数量");t.purchase.forEach(t=>{delete t.cover_pic,delete t.goods_name,delete t.attr_names,delete t.price}),this.btnLoading=!0;const e=await Object(o["x"])(t);this.btnLoading=!1,e.code||(this.$message.success("保存成功!"),this.$router.back())}catch(e){this.btnLoading=!1,this.$message.error(e)}})}}},l=c,d=(s("af57"),s("2877")),p=Object(d["a"])(l,a,i,!1,null,"466aa23d",null);e["default"]=p.exports},af57:function(t,e,s){"use strict";s("d796")},d796:function(t,e,s){}}]);