|
@@ -0,0 +1,363 @@
|
|
|
+<template>
|
|
|
+ <div class="form-submit">
|
|
|
+ <div class="i-layout-page-header">
|
|
|
+ <PageHeader class="product_tabs" hidden-breadcrumb>
|
|
|
+ <div slot="title">
|
|
|
+ <router-link :to="{ path: `${roterPre}/erp/in_list` }">
|
|
|
+ <!-- <Button icon="ios-arrow-back" size="small" class="mr20"
|
|
|
+ >返回</Button
|
|
|
+ > -->
|
|
|
+ <div class="font-sm after-line">
|
|
|
+ <span class="iconfont iconfanhui"></span>
|
|
|
+ <span class="pl10">返回</span>
|
|
|
+ </div>
|
|
|
+ </router-link>
|
|
|
+ <span v-text="
|
|
|
+ $route.params.id !== '0' ? '添加入库单' : '添加入库单'
|
|
|
+ " class="mr20 ml16"></span>
|
|
|
+ </div>
|
|
|
+ </PageHeader>
|
|
|
+ </div>
|
|
|
+ <Card :bordered="false" dis-hover class="ivu-mt">
|
|
|
+ <Form class="formValidate mt20" ref="formValidate" :model="formValidate"
|
|
|
+ :label-width="labelWidth" :label-position="labelPosition" @submit.native.prevent>
|
|
|
+ <Row :gutter="24" type="flex">
|
|
|
+ <Col span="24">
|
|
|
+ <FormItem label="采购单号:" prop="orderNumber">
|
|
|
+ <Input v-model="formValidate.orderNumber" placeholder="请输入采购单号" v-width="'400'" @keyup.enter.native="getGoods" @submit.native.prevent />
|
|
|
+ </FormItem>
|
|
|
+ </Col>
|
|
|
+ <Col span="24">
|
|
|
+ <FormItem label="运费:" prop="freight">
|
|
|
+ <Input v-model="formValidate.freight" placeholder="请输入运费" v-width="'400'" />
|
|
|
+ </FormItem>
|
|
|
+ </Col>
|
|
|
+ <Col span="24" v-if="goodsList.length > 0">
|
|
|
+ <FormItem label="商品:">
|
|
|
+ <Table :columns="columns" :data="goodsList" ref="table" :loading="loading"
|
|
|
+ no-userFrom-text="暂无数据" no-filtered-userFrom-text="暂无筛选结果">
|
|
|
+ <template slot-scope="{ row,index }" slot="product_name">{{row.product_name}}</template>
|
|
|
+ <template slot-scope="{ row,index }" slot="unit_name">{{row.unit_name}}</template>
|
|
|
+ <template slot-scope="{ row,index }" slot="price">{{row.price}}</template>
|
|
|
+ <template slot-scope="{ row,index }" slot="pur_num">
|
|
|
+ <Input v-model="goodsList[index].pur_num" placeholder="请输入数量" v-width="'150'" type="number"/>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="{ row,index }" slot="tare_weight">
|
|
|
+ <Input v-if="row.is_weigh == 1" v-model="goodsList[index].tare_weight" :placeholder="'请输入商品毛重('+row.p_unit_name+')'" v-width="'150'" type="number"/>
|
|
|
+ <div v-else>/</div>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="{ row,index }" slot="net_weight">
|
|
|
+ <Input v-if="row.is_weigh == 1" v-model="goodsList[index].net_weight" :placeholder="'请输入商品净重('+row.p_unit_name+')'" v-width="'150'" type="number"/>
|
|
|
+ <div v-else>/</div>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="{ row,index }" slot="timeValue">
|
|
|
+ <el-date-picker v-model="row.timeValue" type="date" size="mini" style="width: 150px;"
|
|
|
+ placeholder="选择日期" @change="changeTime($event,row,index)" ></el-date-picker>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="{ row,index }" slot="bin_number">
|
|
|
+ <div v-if="row.bin_number">{{goodsList[index].bin_number}}</div>
|
|
|
+ <div v-else>
|
|
|
+ <Select v-model="goodsList[index].bin_number_value" style="width:150px">
|
|
|
+ <Option v-for="item in binList" :value="item.bin_number" :key="item.bin_number">
|
|
|
+ {{ item.bin_number }}</Option>
|
|
|
+ </Select>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </Table>
|
|
|
+ </FormItem>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ </Form>
|
|
|
+ </Card>
|
|
|
+ <Card :bordered="false" dis-hover class="fixed-card"
|
|
|
+ :style="{ left: `${!menuCollapse ? '200px' : isMobile ? '0' : '80px'}` }">
|
|
|
+ <Form>
|
|
|
+ <FormItem>
|
|
|
+ <Button type="primary" class="submission" @click="handleSubmit('formValidate')">保存</Button>
|
|
|
+ </FormItem>
|
|
|
+ </Form>
|
|
|
+ </Card>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import { mapState,mapMutations } from "vuex";
|
|
|
+ import Setting from "@/setting";
|
|
|
+ import { getPurchaseId,batch_save,position,createRuku } from "@/api/erp";
|
|
|
+ import { formatDate } from "@/utils/validate";
|
|
|
+ export default {
|
|
|
+ name: "addInList",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ roterPre: Setting.roterPre,
|
|
|
+ columns: [{
|
|
|
+ title: '商品名称',
|
|
|
+ key: 'product_name',
|
|
|
+ minWidth: 180
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '单位',
|
|
|
+ slot: 'unit_name',
|
|
|
+ minWidth: 90
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '单价',
|
|
|
+ slot: 'price',
|
|
|
+ minWidth: 90
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '数量',
|
|
|
+ slot: 'pur_num',
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ title: '毛重',
|
|
|
+ slot: 'tare_weight',
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '净重',
|
|
|
+ slot: 'net_weight',
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '批次',
|
|
|
+ slot: 'timeValue',
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '仓位',
|
|
|
+ slot: 'bin_number',
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ formValidate: {
|
|
|
+ id: 0,
|
|
|
+ orderNumber:'',
|
|
|
+ freight:'',
|
|
|
+ goods: [],
|
|
|
+ },
|
|
|
+ info:'',//采购单信息
|
|
|
+ goodsList:[],//采购单商品
|
|
|
+ binList:[],//仓位列表
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState("admin/layout", ["isMobile", "menuCollapse"]),
|
|
|
+ labelWidth() {
|
|
|
+ return this.isMobile ? undefined : 120;
|
|
|
+ },
|
|
|
+ labelPosition() {
|
|
|
+ return this.isMobile ? "top" : "right";
|
|
|
+ },
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getGodownList()
|
|
|
+ let data = {
|
|
|
+ pid: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ if (this.$route.query.id != 0) {
|
|
|
+ // this.getWantInfo(this.$route.query.id)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //提交数据
|
|
|
+ handleSubmit(name) {
|
|
|
+ if(this.formValidate.id == 0) {
|
|
|
+ if(!this.formValidate.freight){
|
|
|
+ this.$Message.error("请输入运费");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (var i = 0; i < this.goodsList.length; i ++) {
|
|
|
+ if(this.goodsList[i].is_weigh == 1){
|
|
|
+ if(this.goodsList[i].tare_weight == '' || this.goodsList[i].tare_weight == null){
|
|
|
+ this.$Message.error("请输入商品毛重");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(this.goodsList[i].net_weight == ''|| this.goodsList[i].net_weight == null){
|
|
|
+ this.$Message.error("请输入商品净重");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+
|
|
|
+ }
|
|
|
+ let list = []
|
|
|
+ let total_num = 0
|
|
|
+ let total_price = 0
|
|
|
+ this.goodsList.forEach(item => {
|
|
|
+ total_num += Number(item.net_weight)
|
|
|
+ total_price += Number(item.total_price)
|
|
|
+ list.push({
|
|
|
+ batch_code:item.batch_code,
|
|
|
+ bin_number:item.bin_number,
|
|
|
+ bar_code:item.bar_code,
|
|
|
+ net_weight:item.net_weight,
|
|
|
+ product_code:item.product_code,
|
|
|
+ product_id:item.product_id,
|
|
|
+ product_name:item.product_name,
|
|
|
+ product_num:item.pur_num,
|
|
|
+ tare_weight:item.tare_weight,
|
|
|
+ unit_name:item.unit_name,
|
|
|
+ unit_type:item.unit_type,
|
|
|
+ wid:item.wid,
|
|
|
+ price:item.price,
|
|
|
+ total_price:item.total_price,
|
|
|
+ is_weigh:item.is_weigh,
|
|
|
+ rate:item.unit_type == 1?item.p_unit_rate_1:item.unit_type == 2?item.p_unit_rate_2:1,
|
|
|
+ shelf_life:item.shelf_life,
|
|
|
+ })
|
|
|
+ })
|
|
|
+ createRuku({
|
|
|
+ info:list,
|
|
|
+ total_num:total_num,
|
|
|
+ total_price:total_price,
|
|
|
+ freight:this.formValidate.freight,
|
|
|
+ purchase_order_id:this.formValidate.orderNumber,
|
|
|
+ wid:this.info.wid
|
|
|
+ },0).then(res => {
|
|
|
+ if(res.status == 200){
|
|
|
+ this.$Message.success(res.msg);
|
|
|
+ this.$router.push({
|
|
|
+ path: this.roterPre + "/erp/in_list"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.$Message.error(err.msg);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //根据采购单号获取商品
|
|
|
+ getGoods() {
|
|
|
+ getPurchaseId(this.formValidate.orderNumber).then(res => {
|
|
|
+ if(res.status == 200){
|
|
|
+ this.info = res.data
|
|
|
+ this.info.info.forEach(item => {
|
|
|
+ item.batch_code = ''
|
|
|
+ item.tare_weight = ''
|
|
|
+ item.net_weight = ''
|
|
|
+ item.timeValue = ''
|
|
|
+ item.bin_number_value = ''
|
|
|
+ })
|
|
|
+ this.goodsList = this.info.info
|
|
|
+ this.getBin()
|
|
|
+ console.log(this.goodsList,'this.goodsList')
|
|
|
+ }else{
|
|
|
+ this.$Message.error(res.msg);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //选择批次的时间
|
|
|
+ changeTime(value,row,index){
|
|
|
+ console.log(value,row,index,'value,row,index')
|
|
|
+ let time = formatDate(value, "yyyy-MM-dd")
|
|
|
+ this.goodsList[index].timeValue = time
|
|
|
+ console.log(this.goodsList[index].timeValue,'this.goodsList[index].timeValue')
|
|
|
+ batch_save({
|
|
|
+ product_id:row.product_id,
|
|
|
+ bar_code:row.bar_code,
|
|
|
+ production_date:time
|
|
|
+ }).then(res => {
|
|
|
+ if(res.status == 200){
|
|
|
+ this.goodsList[index].batch_code = res.data.batch_code
|
|
|
+ }else{
|
|
|
+ this.$Message.error(res.msg);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //获取仓位列表
|
|
|
+ getBin(){
|
|
|
+ position({
|
|
|
+ page:1,
|
|
|
+ limit:10000,
|
|
|
+ wid:this.info.wid,
|
|
|
+ not_used:1
|
|
|
+ }).then(res => {
|
|
|
+ if(res.status == 200){
|
|
|
+ this.binList = res.data.data
|
|
|
+ }else{
|
|
|
+ this.$Message.error(res.msg);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="stylus">
|
|
|
+ .table {
|
|
|
+ /deep/.ivu-table-header table {
|
|
|
+ border: 0 !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table-header thead tr th:nth-of-type(1) {
|
|
|
+ padding-left: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table td:nth-of-type(1) {
|
|
|
+ padding-left: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table-cell {
|
|
|
+ padding: 0 !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table-border th,
|
|
|
+ /deep/.ivu-table-border td {
|
|
|
+ border-right: unset;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table td {
|
|
|
+ height: 59px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .form-submit {
|
|
|
+ /deep/.ivu-card {
|
|
|
+ border-radius: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ margin-bottom: 79px;
|
|
|
+
|
|
|
+ .fixed-card {
|
|
|
+ position: fixed;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ left: 200px;
|
|
|
+ z-index: 99;
|
|
|
+ box-shadow: 0 -1px 2px rgb(240, 240, 240);
|
|
|
+
|
|
|
+ /deep/ .ivu-card-body {
|
|
|
+ padding: 15px 16px 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ivu-form-item {
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/ .ivu-form-item-content {
|
|
|
+ margin-right: 124px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ivu-btn {
|
|
|
+ height: 36px;
|
|
|
+ padding: 0 20px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .after-line {
|
|
|
+ display: inline-block;
|
|
|
+ position: relative;
|
|
|
+ margin-right: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ml16 {
|
|
|
+ margin-left: 16px;
|
|
|
+ }
|
|
|
+</style>
|