yangfeng
2024-04-01 2aa506566031eae9a53006119db0cea8c876e6c3
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
<template>
  <div class="add-sales-details">
    <el-dialog
      :close-on-click-modal="false"
      :visible.sync="editRow.visible"
      width="64rem"
      :before-close="handleClose"
      append-to-body
      custom-class="delivery-dalog"
    >
      <div slot="title" class="tac drawerHeader">
        {{ editCommonConfig.title }}
      </div>
      <div class="dialog-body">
        <el-form :model="ruleForm" :rules="rules" ref="form" label-width="90px" class="demo-ruleForm">
          <el-row>
            <el-col :span="6">
              <el-form-item label="发货单号:" prop="number">
                <el-input v-model="ruleForm.number" size="mini"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="承运商:" prop="carrier">
                <el-input v-model="ruleForm.carrier" size="mini"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="运单号:" prop="waybillNumber">
                <el-input v-model="ruleForm.waybillNumber" size="mini"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6"></el-col>
          </el-row>
        </el-form>
        <el-table
          ref="multipleTable"
          :data="tableData"
          tooltip-effect="dark"
          style="width: 100%"
          height="500"
          border
          :header-cell-style="{
            background: '#f1f3f8',
            color: '#000009',
            'font-size': '12px',
            'font-family': 'PingFangSC'
          }"
          size="mini"
        >
          <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
          <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
          <el-table-column prop="productName" label="产品名称" show-overflow-tooltip></el-table-column>
          <el-table-column prop="productId" label="产品编号" show-overflow-tooltip> </el-table-column>
          <el-table-column prop="amount" label="订单数量"> </el-table-column>
          <el-table-column prop="sendAmount" label="已发货数量"> </el-table-column>
          <el-table-column prop="specs" label="产品规格"> </el-table-column>
          <el-table-column prop="type" label="产品型号"> </el-table-column>
          <el-table-column prop="unit" label="单位"> </el-table-column>
          <el-table-column prop="deliveryAmount" label="发货数量">
            <template slot-scope="scope">
              <el-input
                v-model.number="scope.row.deliveryAmount"
                placeholder=""
                :min="0"
                size="mini"
                @change="
                  (val) => {
                    inputContent(val, scope)
                  }
                "
              ></el-input>
            </template>
          </el-table-column>
          <div slot="empty">
            <el-empty description="暂无数据"></el-empty>
          </div>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer">
        <template v-if="isView">
          <el-button @click="editRow.visible = false">关闭</el-button>
        </template>
        <template v-else>
          <!-- <el-button type="primary" :loading="isAddloading" @click="deliveryCompleteClick()">全部发货完成</el-button> -->
          <el-button @click="editRow.visible = false">取消</el-button>
          <el-button type="primary" :loading="isAddloading" @click="saveClick('form')">确认发货</el-button>
        </template>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import { getDeliveryPrepare, saveDelivery, changeOutsourceOrderStatus } from "@/api/orderManageModule/orderManage"
export default {
  name: "DeliveryDialog",
  props: {
    editCommonConfig: {
      type: Object,
      default: () => {
        return {
          visible: false,
          title: "发货",
          infomation: {}
        }
      }
    }
  },
  components: {},
  data() {
    return {
      editRow: this.editCommonConfig,
      isView: this.editCommonConfig.title === "发货信息",
      editSelCommonConfig: {
        editVisible: false,
        isSelectBox: false,
        title: "",
        infomation: {}
      },
      isAddloading: false,
      tableData: [],
      ruleForm: {
        number: "",
        carrier: "",
        waybillNumber: ""
      },
      rules: {
        number: [{ required: true, message: "请输入发货单号", trigger: "blur" }]
      }
    }
  },
  created() {
    // this.setTableForm()
    this.getDeliveryPrepare()
  },
  watch: {
    "editCommonConfig.visible"(val) {
      if (val) {
        // this.setTableForm()
      }
    }
  },
  methods: {
    handleClose() {
      this.editRow.visible = false
    },
    // 获取发货产品列表
    getDeliveryPrepare() {
      getDeliveryPrepare({
        outsourcingOrderID: this.editRow.infomation.id
      }).then((res) => {
        console.log(res)
        if (res.code == 200) {
          let list = res.data.map((item) => {
            return {
              ...item,
              deliveryAmount: 0
            }
          })
          this.tableData = list
        }
      })
    },
    // 多选回调
    getSelectArray(arr) {
      console.log(arr)
    },
    // 数量输入回调
    inputContent(val, scope) {
      console.log(val, scope)
    },
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(this.ruleForm, "保存内容处理", this.tableData)
          let isDeliveryCount = false
          this.tableData.map((item) => {
            if (item.deliveryAmount == 0) {
              isDeliveryCount = true
              return
            }
          })
          if (isDeliveryCount) {
            this.$message.error("发货数量必须大于0")
          } else {
            let deliveryList = this.tableData.map((item) => {
              return {
                outsourcingOrderProductID: item.id,
                sendAmount: item.deliveryAmount
              }
            })
            let params = {
              carrier: this.ruleForm.carrier,
              deliveryList: deliveryList,
              number: this.ruleForm.number,
              outsourcingOrderID: this.editRow.infomation.id,
              waybillNumber: this.ruleForm.waybillNumber
            }
            saveDelivery(params).then((res) => {
              if (res.code == 200) {
                this.handleClose()
                this.$message.success("发货成功")
                this.$emit("reRreshData")
              }
            })
          }
        }
      })
    },
    // 全部发货完成
    deliveryCompleteClick() {
      this.$confirm("是否确认全部发货完成?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        changeOutsourceOrderStatus({
          outsourcingOrderNumber: this.editRow.infomation.number,
          status: 7
        })
          .then((reply) => {
            if (reply.code == 200) {
              this.handleClose()
              this.$message.success("全部发货完成成功")
              this.$emit("reRreshData")
            }
          })
          .catch(() => {})
      })
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
::v-deep {
  .delivery-dalog .el-dialog__header {
    background: #fff;
  }
  .delivery-dalog .el-dialog__body {
    padding: 20px !important;
  }
  .el-dialog__footer {
    width: 100%;
    height: 65px;
    // line-height: 55px;
    background-color: #fff;
    padding: 0px 20px 0;
    text-align: right;
    box-sizing: border-box;
    border-top: 0px solid #dadee5;
    position: relative;
    .footer-left {
      position: absolute;
      top: 0px;
      left: 20px;
    }
  }
}
</style>