(self["webpackChunkerp"]=self["webpackChunkerp"]||[]).push([[292],{4042:function(t,e,r){"use strict";r.r(e),r.d(e,{default:function(){return _}});var i=function(){var t=this,e=t._self._c;return e("div",{staticClass:"pageBox"},[e("div",{staticClass:"cardBox"},[e("div",{staticClass:"searchBox"},[e("div",{staticClass:"row"},[e("span",[t._v("商品名称:")]),e("el-input",{attrs:{clearable:""},model:{value:t.filter.title,callback:function(e){t.$set(t.filter,"title",e)},expression:"filter.title"}})],1),e("div",{staticClass:"row"},[e("span",[t._v("商品编码:")]),e("el-input",{attrs:{clearable:""},model:{value:t.filter.external_sku_id,callback:function(e){t.$set(t.filter,"external_sku_id",e)},expression:"filter.external_sku_id"}})],1),e("div",{staticClass:"row"},[e("span",[t._v("创建时间:")]),e("el-date-picker",{staticStyle:{width:"340px"},attrs:{type:"datetimerange","range-separator":"-","start-placeholder":"开始时间","end-placeholder":"结束时间","value-format":"yyyy-MM-dd HH:mm:ss"},model:{value:t.addTime,callback:function(e){t.addTime=e},expression:"addTime"}})],1),e("div",{staticClass:"row"},[e("span",[t._v("审核状态:")]),e("el-select",{attrs:{placeholder:"请选择",clearable:""},model:{value:t.filter.status,callback:function(e){t.$set(t.filter,"status",e)},expression:"filter.status"}},t._l(t.statusList,(function(t){return e("el-option",{key:t.id,attrs:{label:t.name,value:t.id}})})),1)],1),e("div",{staticClass:"row"},[e("el-button",{attrs:{type:"primary",icon:"el-icon-search"},on:{click:t.handleSearch}},[t._v("筛选")])],1)])]),e("el-card",[e("div",{staticClass:"opaBox"},[e("el-button",{attrs:{type:"primary",icon:"el-icon-plus"},on:{click:t.handleAdd}},[t._v("新增")]),e("el-button",{attrs:{type:"warning",icon:"el-icon-upload2"},on:{click:t.handleImport}},[t._v("导入")])],1),e("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}],staticStyle:{width:"100%"},attrs:{data:t.procureList,border:""}},[e("el-table-column",{attrs:{prop:"goods_sku.id",label:"商品id",width:"80",align:"center"}}),e("el-table-column",{attrs:{prop:"goods_sku.name",label:"商品名称"}}),e("el-table-column",{attrs:{prop:"external_sku_id",label:"商品编码"}}),e("el-table-column",{attrs:{prop:"num",label:"采购数量"}}),e("el-table-column",{attrs:{prop:"cost",label:"采购成本"}}),e("el-table-column",{attrs:{prop:"buyer_name",label:"采购人名称"}}),e("el-table-column",{attrs:{prop:"expire_time",label:"到货时间"}}),e("el-table-column",{attrs:{prop:"supplier_name",label:"供应商"},scopedSlots:t._u([{key:"default",fn:function(r){return[r.row.supplier_name?e("span",[t._v(t._s(r.row.supplier_name)+"("+t._s(r.row.supplier_id)+")")]):t._e()]}}])}),e("el-table-column",{attrs:{prop:"date",label:"采购时间",align:"center"}}),e("el-table-column",{attrs:{label:"状态"},scopedSlots:t._u([{key:"default",fn:function(r){return[0==r.row.status?e("span",[t._v("待审核")]):1==r.row.status?e("span",{staticStyle:{color:"#6DD230"}},[t._v("审核通过")]):2==r.row.status?e("span",{staticStyle:{color:"#f00"}},[t._v("审核不通过")]):t._e()]}}])}),e("el-table-column",{attrs:{label:"操作",width:"120",align:"center"},scopedSlots:t._u([{key:"default",fn:function(r){return[e("el-button",{attrs:{type:"primary",icon:"el-icon-edit",size:"mini"},on:{click:function(e){return t.handleEdit(r.row)}}},[t._v("编辑")])]}}])})],1),e("div",{staticClass:"page-pagination"},[e("el-pagination",{attrs:{"current-page":t.page,"page-sizes":[15,30,50,100],"page-size":t.pageSize,layout:"prev, pager, next, jumper, sizes, total",total:t.total},on:{"size-change":t.handleSizeChange,"current-change":t.handleCurrentChange}})],1)],1),e("el-dialog",{attrs:{title:"新增",visible:t.dialogVisible,width:"900px"},on:{"update:visible":function(e){t.dialogVisible=e}}},[e("el-form",{attrs:{"label-width":"90px",inline:!0}},[e("el-form-item",{attrs:{label:"采购人:"}},[e("el-select",{ref:"userBatchRef",attrs:{clearable:"",filterable:""},model:{value:t.curInfo.buyer_user_id,callback:function(e){t.$set(t.curInfo,"buyer_user_id",e)},expression:"curInfo.buyer_user_id"}},t._l(t.usersList,(function(t){return e("el-option",{key:t.id,attrs:{label:t.name,value:t.id}})})),1)],1),e("el-form-item",{attrs:{label:"供应商:"}},[e("el-select",{ref:"supplierBatchRef",attrs:{clearable:"",filterable:""},model:{value:t.curInfo.supplier_id,callback:function(e){t.$set(t.curInfo,"supplier_id",e)},expression:"curInfo.supplier_id"}},t._l(t.supplierList,(function(t){return e("el-option",{key:t.id,attrs:{label:t.supplier_name,value:t.id}})})),1)],1)],1),t._l(t.purchaseOrders,(function(r,i){return e("div",{key:i,staticClass:"bgBox"},[e("div",{staticClass:"close",on:{click:function(e){return t.delItem(i)}}},[e("i",{staticClass:"el-icon-delete-solid"})]),e("el-form",{attrs:{"label-width":"90px",inline:!0}},[e("el-form-item",{attrs:{label:"商品名称:"}},[e("el-select",{attrs:{filterable:"",remote:"","reserve-keyword":"",placeholder:"商品名称",clearable:"","remote-method":t.remoteMethod,loading:t.searchLoading},model:{value:r.external_sku_id,callback:function(e){t.$set(r,"external_sku_id",e)},expression:"item.external_sku_id"}},t._l(t.goodsList,(function(t){return e("el-option",{key:t.external_sku_id,attrs:{label:t.title,value:t.external_sku_id}})})),1)],1),e("el-form-item",{attrs:{label:"数量:"}},[e("el-input",{attrs:{clearable:""},on:{input:function(e){return t.changeInput(i,r)}},model:{value:r.num,callback:function(e){t.$set(r,"num",e)},expression:"item.num"}})],1),e("el-form-item",{attrs:{label:"成本:"}},[e("el-input",{staticStyle:{width:"215px"},attrs:{clearable:""},on:{input:function(e){return t.changeInput(i,r)}},model:{value:r.cost,callback:function(e){t.$set(r,"cost",e)},expression:"item.cost"}},[e("template",{slot:"append"},[t._v("元")])],2)],1),e("el-form-item",{attrs:{label:"商品总价:"}},[e("el-input",{staticStyle:{width:"215px"},model:{value:r.total_price,callback:function(e){t.$set(r,"total_price",e)},expression:"item.total_price"}},[e("template",{slot:"append"},[t._v("元")])],2)],1),e("el-form-item",{attrs:{label:"采购日期:"}},[e("el-date-picker",{attrs:{type:"date",placeholder:"选择日期",format:"yyyy-MM-dd","value-format":"yyyy-MM-dd"},model:{value:r.date,callback:function(e){t.$set(r,"date",e)},expression:"item.date"}})],1),e("el-form-item",{attrs:{label:"到货时间:"}},[e("el-date-picker",{attrs:{type:"datetime",placeholder:"选择日期",format:"yyyy-MM-dd hh:mm:ss","value-format":"yyyy-MM-dd hh:mm:ss"},model:{value:r.arrived_time,callback:function(e){t.$set(r,"arrived_time",e)},expression:"item.arrived_time"}})],1)],1)],1)})),e("div",{staticClass:"btn",on:{click:function(e){return t.addItem()}}},[e("i",{staticClass:"el-icon-plus"}),t._v("添加采购商品")]),e("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[e("el-button",{on:{click:function(e){t.dialogVisible=!1}}},[t._v("取 消")]),e("el-button",{attrs:{type:"primary",loading:t.commitloading},on:{click:t.commitAddPurchase}},[t._v("确 定")])],1)],2),e("el-dialog",{attrs:{title:"编辑",visible:t.editDialog,width:"600px"},on:{"update:visible":function(e){t.editDialog=e}}},[e("el-form",{attrs:{"label-width":"90px"}},[e("el-form-item",{attrs:{label:"采购人"}},[e("el-select",{ref:"userRef",attrs:{clearable:"",filterable:"",disabled:""},model:{value:t.curInfo.buyer_user_id,callback:function(e){t.$set(t.curInfo,"buyer_user_id",e)},expression:"curInfo.buyer_user_id"}},t._l(t.usersList,(function(t){return e("el-option",{key:t.id,attrs:{label:t.name,value:t.id}})})),1)],1),e("el-form-item",{attrs:{label:"供应商"}},[e("el-select",{ref:"supplierRef",attrs:{clearable:"",filterable:""},model:{value:t.curInfo.supplier_id,callback:function(e){t.$set(t.curInfo,"supplier_id",e)},expression:"curInfo.supplier_id"}},t._l(t.supplierList,(function(t){return e("el-option",{key:t.id,attrs:{label:t.supplier_name,value:t.id}})})),1)],1),e("el-form-item",{attrs:{label:"商品名称"}},[e("el-select",{attrs:{filterable:"",remote:"","reserve-keyword":"",placeholder:"商品名称",clearable:"","remote-method":t.editRemoteMethod,loading:t.searchLoading},model:{value:t.curInfo.external_sku_id,callback:function(e){t.$set(t.curInfo,"external_sku_id",e)},expression:"curInfo.external_sku_id"}},t._l(t.editGoodsList,(function(t){return e("el-option",{key:t.external_sku_id,attrs:{label:t.title,value:t.external_sku_id}})})),1)],1),e("el-form-item",{attrs:{label:"数量"}},[e("el-input",{attrs:{disabled:""},model:{value:t.curInfo.num,callback:function(e){t.$set(t.curInfo,"num",e)},expression:"curInfo.num"}})],1),e("el-form-item",{attrs:{label:"成本"}},[e("el-input",{attrs:{disabled:""},model:{value:t.curInfo.cost,callback:function(e){t.$set(t.curInfo,"cost",e)},expression:"curInfo.cost"}})],1),e("el-form-item",{attrs:{label:"商品总价"}},[e("el-input",{attrs:{disabled:""},model:{value:t.curInfo.total_price,callback:function(e){t.$set(t.curInfo,"total_price",e)},expression:"curInfo.total_price"}},[e("template",{slot:"append"},[t._v("元")])],2)],1),e("el-form-item",{attrs:{label:"采购时间"}},[e("el-date-picker",{attrs:{type:"date",placeholder:"选择日期",format:"yyyy-MM-dd","value-format":"yyyy-MM-dd"},model:{value:t.curInfo.date,callback:function(e){t.$set(t.curInfo,"date",e)},expression:"curInfo.date"}})],1),e("el-form-item",{attrs:{label:"到期时间"}},[e("el-date-picker",{attrs:{type:"datetime",placeholder:"到货时间",format:"yyyy-MM-dd hh:mm:ss","value-format":"yyyy-MM-dd hh:mm:ss"},model:{value:t.curInfo.arrived_time,callback:function(e){t.$set(t.curInfo,"arrived_time",e)},expression:"curInfo.arrived_time"}})],1)],1),e("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[e("el-button",{on:{click:function(e){t.editDialog=!1}}},[t._v("取 消")]),e("el-button",{attrs:{type:"primary",loading:t.commitloading},on:{click:t.commitEdit}},[t._v("确 定")])],1)],1),e("el-dialog",{attrs:{title:"导入",visible:t.showImport,width:"500px"},on:{"update:visible":function(e){t.showImport=e}}},[e("div",{staticStyle:{"text-align":"center"}},[e("el-upload",{staticClass:"upload-demo",attrs:{drag:"",action:"",limit:1,multiple:!1,accept:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel","file-list":t.fileList,"auto-upload":!1,"on-change":t.importFileChange,"on-remove":t.fileRemove}},[e("i",{staticClass:"el-icon-upload"}),e("div",{staticClass:"el-upload__text"},[t._v("将文件拖到此处,或"),e("em",[t._v("点击上传")])])])],1),e("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[e("el-button",{on:{click:function(e){t.showImport=!1}}},[t._v("取 消")]),e("el-button",{attrs:{type:"primary",loading:t.commitloading},on:{click:t.commitUpload}},[t._v("上 传")])],1)])],1)},a=[],n=(r(560),r(3550)),s=r(9669),o=r.n(s),l=r(2900),u=r(9036),c=r(7484),d=r.n(c),p={data(){return{loading:!1,page:1,pageSize:15,total:0,procureList:[],filter:{title:"",external_sku_id:"",status:""},addTime:[],commitloading:!1,dialogVisible:!1,curInfo:{},showImport:!1,fileList:[],usersList:[],supplierList:[],purchaseOrders:[],editDialog:!1,goodsList:[],searchLoading:!1,statusList:[{id:0,name:"待审核"},{id:1,name:"审核通过"},{id:2,name:"审核不通过"}],editGoodsList:[]}},methods:{fetchList(){this.loading=!0;let t={page:this.page,per_page:this.pageSize,...this.filter,start_time:this.addTime?this.addTime[0]:"",end_time:this.addTime?this.addTime[1]:""};(0,n.Js)(t).then((t=>{this.procureList=t.data.data,this.total=t.data.meta.total,this.loading=!1})).catch((()=>{this.loading=!1}))},handleSizeChange(t){this.page=1,this.pageSize=t,this.fetchList()},handleCurrentChange(t){this.page=t,this.fetchList()},handleSearch(){this.page=1,this.fetchList()},handleAdd(){this.curInfo={buyer_user_id:localStorage.getItem("userId"),supplier_id:""},this.purchaseOrders=[{external_sku_id:"",num:"",cost:"",total_price:"",date:d()().format("YYYY-MM-DD"),arrived_time:""}],this.dialogVisible=!0},delItem(t){this.purchaseOrders.splice(t,1)},addItem(){this.purchaseOrders.push({external_sku_id:"",num:"",cost:"",total_price:"",date:d()().format("YYYY-MM-DD"),arrived_time:""})},handleEdit(t){this.curInfo=JSON.parse(JSON.stringify(t)),this.editGoodsList=[{external_sku_id:t.external_sku_id,title:t.goods_sku&&t.goods_sku.name}],this.curInfo.total_price=1*t.cost*(1*t.num),this.editDialog=!0},commitAddPurchase(){this.commitloading=!0;let t=[],e={...this.curInfo};e.buyer_name="",e.supplier_name="",e.buyer_user_id&&(e.buyer_name=this.$refs.userBatchRef.selectedLabel),e.supplier_id&&(e.supplier_name=this.$refs.supplierBatchRef.selectedLabel),this.purchaseOrders.forEach((r=>{t.push({...r,buyer_name:e.buyer_name,buyer_user_id:e.buyer_user_id,supplier_id:e.supplier_id,supplier_name:e.supplier_name})})),(0,n.iY)({purchaseOrders:t}).then((t=>{this.page=1,this.fetchList(),this.$message({type:"success",message:"新增成功!"}),this.dialogVisible=!1,this.commitloading=!1})).catch((()=>{this.commitloading=!1}))},commitEdit(){this.commitloading=!0;let t={...this.curInfo};t.buyer_name="",t.supplier_name="",t.buyer_user_id&&(t.buyer_name=this.$refs.userRef.selectedLabel),t.supplier_id&&(t.supplier_name=this.$refs.supplierRef.selectedLabel),(0,n.JI)(this.curInfo.id,t).then((t=>{this.fetchList(),this.$message({type:"success",message:"更新成功!"}),this.editDialog=!1,this.commitloading=!1})).catch((()=>{this.commitloading=!1}))},handleImport(){this.fileList=[],this.showImport=!0},importFileChange(t,e){console.log(e),this.fileList=e},fileRemove(){this.fileList=[]},commitUpload(){if(this.fileList.length){this.commitloading=!0;const t=new FormData;t.append("purchaseFile",this.fileList[0].raw);let e=localStorage.getItem("token");o().post("/api/purchase_record/purchase_import",t,{headers:{Authorization:`Bearer ${e}`}}).then((t=>{200===t.status?(this.$message.success("导入成功"),this.page=1,this.fetchList(),this.commitloading=!1,this.showImport=!1):this.commitloading=!1})).catch((()=>{this.commitloading=!1}))}else this.$message.error("请先上传文件")},getUserList(){let t={page:1,per_page:9999};(0,l.Lh)(t).then((t=>{this.usersList=t.data.data}))},getSupplierList(){let t={page:1,per_page:9999};(0,n.Fb)(t).then((t=>{this.supplierList=t.data.data}))},remoteMethod(t){""!==t?(this.searchLoading=!0,setTimeout((()=>{this.searchLoading=!1,(0,u.NR)(t).then((e=>{this.goodsList=e.data.filter((e=>e.title.toLowerCase().indexOf(t.toLowerCase())>-1))}))}),200)):this.goodsList=[]},changeInput(t,e){this.$set(this.purchaseOrders[t],"total_price",1*e.num*(1*e.cost))},editRemoteMethod(t){""!==t?(this.searchLoading=!0,setTimeout((()=>{this.searchLoading=!1,(0,u.NR)(t).then((e=>{this.editGoodsList=e.data.filter((e=>e.title.toLowerCase().indexOf(t.toLowerCase())>-1))}))}),200)):this.editGoodsList=[]}},mounted(){this.fetchList(),this.getSupplierList(),this.getUserList()}},f=p,h=r(1001),m=(0,h.Z)(f,i,a,!1,null,"b907944a",null),_=m.exports},7484:function(t){!function(e,r){t.exports=r()}(0,(function(){"use strict";var t=1e3,e=6e4,r=36e5,i="millisecond",a="second",n="minute",s="hour",o="day",l="week",u="month",c="quarter",d="year",p="date",f="Invalid Date",h=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,_={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],r=t%100;return"["+t+(e[(r-20)%10]||e[r]||e[0])+"]"}},g=function(t,e,r){var i=String(t);return!i||i.length>=e?t:""+Array(e+1-i.length).join(r)+t},b={s:g,z:function(t){var e=-t.utcOffset(),r=Math.abs(e),i=Math.floor(r/60),a=r%60;return(e<=0?"+":"-")+g(i,2,"0")+":"+g(a,2,"0")},m:function t(e,r){if(e.date()1)return t(s[0])}else{var o=e.name;y[o]=e,a=o}return!i&&a&&(v=a),a||!i&&v},w=function(t,e){if(k(t))return t.clone();var r="object"==typeof e?e:{};return r.date=t,r.args=arguments,new L(r)},M=b;M.l=x,M.i=k,M.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var L=function(){function _(t){this.$L=x(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[$]=!0}var g=_.prototype;return g.parse=function(t){this.$d=function(t){var e=t.date,r=t.utc;if(null===e)return new Date(NaN);if(M.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var i=e.match(h);if(i){var a=i[2]-1||0,n=(i[7]||"0").substring(0,3);return r?new Date(Date.UTC(i[1],a,i[3]||1,i[4]||0,i[5]||0,i[6]||0,n)):new Date(i[1],a,i[3]||1,i[4]||0,i[5]||0,i[6]||0,n)}}return new Date(e)}(t),this.init()},g.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},g.$utils=function(){return M},g.isValid=function(){return!(this.$d.toString()===f)},g.isSame=function(t,e){var r=w(t);return this.startOf(e)<=r&&r<=this.endOf(e)},g.isAfter=function(t,e){return w(t)