zuozhengqing
2024-03-28 ecba7c3d82e2114ef6c01480d7c6add5f20904d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<template>
  <div class="add-quotation">
    <el-dialog title="到货确认" :visible.sync="editConfig.visible" width="50%" :before-close="handleClose" append-to-body
      custom-class="iframe-dialog">
      <el-form ref="form" :model="editConfig.infomation" label-position="right" label-width="130px" size="mini"
        style="height: 60vh; overflow-x: hidden">
        <!-- 信息 -->
        <div class="basic-info">
          <div class="product-view">
            <CommonFormTableView :isBoder="true" :detailEnter="true" :recalculateShow="false" :addTypeIdMultiple="true"
              :product-table-list="productTableList" sign="purchase" @rowClick="rowClick" />
          </div>
          <!-- <div class="btn-box">
          </div> -->
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" v-if="this.editConfig.title != '查看'" @click="editConfig.visible = false">取消</el-button>
        <el-button type="primary"  size="small"
          @click="saveClick('form')">确认收货</el-button>
        <el-button type="primary"  size="small"
          @click="saveOkClickAll('form')">全部合格入库</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import {
  getPurchaseProductConfirmInfo,
  savePurchaseProductConfirm,
  allProductInWarehouse
} from "@/api/purchaseManage/purchase"
import CommonFormTableView from "@/components/makepager/CommonFormTableView"
export default {
  name: "ArrivalConfirmation",
  components: { CommonFormTableView },
  props: {
    editCommonConfig: {
      type: Object,
      default: () => {
        return {
          visible: false,
          infomation: {}
        }
      }
    }
  },
  data() {
    return {
      editConfig: this.editCommonConfig,
      productTableList: {},
      editSelectSupplierConfig: {
        editVisible: false,
        title: "",
        infomation: {}
      },
      tableData: [],
      productIndex: 0,
      productId: "",
      isNoProduct: true,
      clientList: [],
      plcBrandList: [],
      editRow: {
        isDefault: "pin"
      },
      total: 0,
      totalTwo: 0,
      productListIdx: 0,
      lacks: [],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7
        }
      },
      pickerOptionsBefore: {
        disabledDate(time) {
          return time.getTime() > Date.now()
        }
      },
      receiveWhouseList: [] // 收货仓库列表
    }
  },
  created() {
    this.setTableForm()
    this.getPurchaseProductConfirmInfo(this.editConfig.infomation.number)
  },
  computed: {
    // calculateDifference() {
    //   return this.productTableList.tableData.map(row => ({
    //             ...row,
    //             surplusReceiveAmount: row.notReceiveAmount - row.nowReceiveAmount
    //          }));
    // }
  },
  watch: {
    "editCommonConfig.visible": {
      immediate: true,
      handler: function () {
      }
    }
  },
  methods: {
    // 确认收货
    async saveClick() {
      let pipeline=false // 是否有大于0的收货数量
      // let rule1=false    // 本次收货是否大于未收货数量
      let arr=[]
      this.productTableList.tableData.map((item)=>{
        if(item.nowReceiveAmount>0&&item.nowReceiveAmount<=item.notReceiveAmount){
          pipeline=true
          arr.push(item)
        }
      })
      if(pipeline){
        await savePurchaseProductConfirm(this.productTableList.tableData).then((res)=>{
          if(res.code===200){
            this.editConfig.visible=false
            this.$parent.getData()
            this.$message.success("确认收货成功!")
          }
        })
      }else{
        this.$message.warning("本次收货数量不能为0且不能超出未收货数量 ")
      }
    },
    // 全部合格入库
    async saveOkClickAll(){
      let pipeline=false // 是否有大于0的收货数量
      // let rule1=false    // 本次收货是否大于未收货数量
      // let arr=[]
      this.productTableList.tableData.map((item)=>{
        if(item.nowReceiveAmount>0&&item.nowReceiveAmount<=item.notReceiveAmount){
          pipeline=true
          // arr.push(item)
        }
      })
      if(pipeline){
        await allProductInWarehouse(this.productTableList.tableData).then((res)=>{
          if(res.code===200){
            this.editConfig.visible=false
            this.$parent.getData()
            this.$message.success("确认入库质检成功!")
          }
        })
      }else{
        this.$message.warning("本次收货数量不能为0且不能超出未收货数量 ")
      }
 
    },
    saveParams() {
      let data = JSON.parse(JSON.stringify(this.editConfig.infomation))
 
      let params = {
        productList: this.tableData,
        purchase: {
        }
      }
      if (data.id) {
        params.purchase.id = data.id
      }
      return params
    },
    handleClose() {
      this.editConfig.visible = false
    },
    setTableForm() {
      this.productTableList = {
        tableProductList: [],
        tableData: this.tableData,
        disabled: this.editConfig.isDisabled,
        isReturn: true,
        tableColumn: [
          { label: "产品名称", prop: "productName" },
          { label: "产品编号", prop: "productId" },
          { label: "采购数量", prop: "amount" },
          { label: "已收货数量", prop: "overReceiveAmount" },
          { label: "未收货数量", prop: "notReceiveAmount" },
          {
            label: "本次收货数量",
            prop: "nowReceiveAmount",
            inputFloat: true,
            isRequird: true,
          },
          { label: "剩余收货数量", prop: "surplusReceiveAmount",compute:true}
        ]
      }
      this.toal = this.editConfig.infomation.realTotalPrice
    },
    //选择行
    rowClick(row) {
      console.log(row, "xuanze")
      this.productListIdx = row.productIndex
    },
    // 到货确认列表
    getPurchaseProductConfirmInfo(params){
      getPurchaseProductConfirmInfo(params).then((res)=>{
        console.log(res,"res9")
        this.productTableList.tableData=res.data
      })
    },
    // 剩余收货计算
    calculateDifference(row) {  
      if (row.col1 !== null && row.col2 !== null) {  
        return row.col1 - row.col2;  
      } else {  
        return 0; // 或者返回你想要的默认值  
      }  
    }  
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.table-bottom {
  width: 500px;
  float: right;
  margin-right: 20px;
  margin-top: 10px;
  height: auto;
  line-height: 30px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #333;
 
  .table-bottom-item {
    width: 100%;
    text-align: right;
 
    .table-bottom-l {
      width: 250px;
      float: left;
    }
 
    .table-bottom-r {
      width: calc(100% - 250px);
      float: right;
    }
  }
}
 
::v-deep {
  .iframe-dialog .el-dialog__body {
    .basic-info {
      overflow: hidden;
      margin-top: 20px;
    }
  }
  .el-dialog__header,.el-dialog__body,.el-dialog__footer{
    padding: 0 20px;
  }
  .el-dialog__header{
    height: 50px;
    line-height: 50px;
  }
  .dialog-footer {
    text-align: right !important;
  }
  .el-table tr {
    background-color: #fff;
  }
  .el-table th.el-table__cell.is-leaf{
    background-color: #F1F3F8 !important;
  }
}
</style>