ExpressEdit.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="修改快递信息"
  5. :visible.sync="editShow"
  6. width="500px"
  7. :before-close="close"
  8. >
  9. <el-form
  10. :model="shipForm"
  11. ref="shipForm"
  12. :rules="rules"
  13. label-width="100px"
  14. >
  15. <el-form-item label="快递公司:" prop="deliveryId">
  16. <el-select
  17. v-model="shipForm.deliveryId"
  18. placeholder="请选择快递公司"
  19. clearable
  20. size="small"
  21. style="width: 300px"
  22. >
  23. <el-option
  24. v-for="item in companyData"
  25. :key="item.areaId"
  26. :label="item.companyName"
  27. :value="item.deliveryId"
  28. />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="快递单号:" prop="deliveryFlowId">
  32. <el-input
  33. v-model="shipForm.deliveryFlowId"
  34. placeholder="输入快递单号"
  35. clearable
  36. size="small"
  37. style="width: 300px"
  38. />
  39. </el-form-item>
  40. </el-form>
  41. <!-- 按钮 -->
  42. <div slot="footer" class="dialog-footer">
  43. <el-button @click="close">取 消</el-button>
  44. <el-button type="primary" :disabled="loading" @click="saveClick"
  45. >确 定</el-button
  46. >
  47. </div>
  48. </el-dialog>
  49. </div>
  50. </template>
  51. <script>
  52. import CustomFieldsMixin from "@/mixins/CustomFields";
  53. import {
  54. companyList,
  55. deliverOrderShipUpdate,
  56. } from "@/api/business/order";
  57. export default {
  58. mixins: [CustomFieldsMixin],
  59. props: {
  60. // 发货弹框显示
  61. editShow: {
  62. type: Boolean,
  63. default: false,
  64. },
  65. // 订单详情
  66. goodsInfo: {
  67. type: Object,
  68. default: {},
  69. },
  70. // 订单ID
  71. orderId: {
  72. type: String,
  73. default: ''
  74. }
  75. },
  76. data() {
  77. return {
  78. loading: false,
  79. shipForm: {
  80. deliveryId: "",
  81. deliveryFlowId: "",
  82. },
  83. // 快递下拉列表
  84. companyData: [],
  85. rules: {
  86. deliveryId: [
  87. { required: true, message: "请选择快递公司", trigger: "change" },
  88. ],
  89. deliveryFlowId: [
  90. { required: true, message: "请输入快递单号", trigger: "blur" },
  91. ],
  92. },
  93. };
  94. },
  95. created() {
  96. this.getCompanyList();
  97. this.getFormData()
  98. },
  99. methods: {
  100. getFormData(){
  101. this.shipForm.deliveryId = this.goodsInfo.deliveryId
  102. this.shipForm.deliveryFlowId = this.goodsInfo.deliveryFlowId
  103. },
  104. // 关闭发货弹框
  105. close() {
  106. this.$emit("close");
  107. this.loading = false;
  108. this.$refs["shipForm"].resetFields();
  109. },
  110. // 快递下拉列表
  111. getCompanyList() {
  112. companyList({}).then((res) => {
  113. this.companyData = res.data;
  114. });
  115. },
  116. // 确认
  117. saveClick() {
  118. this.loading = true;
  119. const subForm = this.$refs["shipForm"];
  120. subForm.validate((valid) => {
  121. if (valid) {
  122. this.submitForm(this.shipForm);
  123. } else {
  124. this.loading = false;
  125. // 提示第一个error
  126. this.getFormErrorMessage(subForm);
  127. return false;
  128. }
  129. });
  130. },
  131. // 提交
  132. submitForm(form) {
  133. let data = {
  134. ...form,
  135. orderId: this.orderId,
  136. itemIds: this.goodsInfo.items.map( item => item.itemId)
  137. };
  138. deliverOrderShipUpdate(data)
  139. .then((res) => {
  140. if (res.code == 0) {
  141. this.msgSuccess("修改成功");
  142. this.close();
  143. }
  144. })
  145. .catch(() => {
  146. this.loading = false;
  147. });
  148. },
  149. },
  150. };
  151. </script>
  152. <style scoped>
  153. </style>