ExpressEdit.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. channelOrderShipUpdate,
  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. },
  71. data() {
  72. return {
  73. loading: false,
  74. shipForm: {
  75. deliveryId: "",
  76. deliveryFlowId: "",
  77. },
  78. // 快递下拉列表
  79. companyData: [],
  80. rules: {
  81. deliveryId: [
  82. { required: true, message: "请选择快递公司", trigger: "change" },
  83. ],
  84. deliveryFlowId: [
  85. { required: true, message: "请输入快递单号", trigger: "blur" },
  86. ],
  87. },
  88. };
  89. },
  90. created() {
  91. this.getCompanyList();
  92. this.getFormData()
  93. },
  94. methods: {
  95. getFormData(){
  96. this.shipForm.deliveryId = this.goodsInfo.deliveryId
  97. this.shipForm.deliveryFlowId = this.goodsInfo.deliveryFlowId
  98. },
  99. // 关闭发货弹框
  100. close() {
  101. this.$emit("close");
  102. this.loading = false;
  103. this.$refs["shipForm"].resetFields();
  104. },
  105. // 快递下拉列表
  106. getCompanyList() {
  107. companyList({}).then((res) => {
  108. this.companyData = res.data;
  109. });
  110. },
  111. // 确认
  112. saveClick() {
  113. this.loading = true;
  114. const subForm = this.$refs["shipForm"];
  115. subForm.validate((valid) => {
  116. if (valid) {
  117. this.submitForm(this.shipForm);
  118. } else {
  119. this.loading = false;
  120. // 提示第一个error
  121. this.getFormErrorMessage(subForm);
  122. return false;
  123. }
  124. });
  125. },
  126. // 提交
  127. submitForm(form) {
  128. let data = {
  129. ...form,
  130. orderId: this.goodsInfo.orderId,
  131. };
  132. channelOrderShipUpdate(data)
  133. .then((res) => {
  134. if (res.code == 0) {
  135. this.msgSuccess("修改成功");
  136. this.close();
  137. }
  138. })
  139. .catch(() => {
  140. this.loading = false;
  141. });
  142. },
  143. },
  144. };
  145. </script>
  146. <style scoped>
  147. </style>