SendGoods.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="订单发货"
  5. :visible.sync="sendShow"
  6. width="1000px"
  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="订单号:">
  16. <span>{{ goodsInfo.orderId }}</span>
  17. </el-form-item>
  18. <el-form-item label="收货地址:">
  19. <span>{{
  20. `${goodsInfo.receiver},${goodsInfo.tel},${goodsInfo.province}${goodsInfo.city}${goodsInfo.area}${goodsInfo.address}`
  21. }}</span>
  22. </el-form-item>
  23. <el-form-item label="快递公司:" prop="deliveryId">
  24. <el-select
  25. v-model="shipForm.deliveryId"
  26. placeholder="请选择快递公司"
  27. clearable
  28. size="small"
  29. style="width: 300px"
  30. >
  31. <el-option
  32. v-for="item in companyData"
  33. :key="item.areaId"
  34. :label="item.companyName"
  35. :value="item.deliveryId"
  36. />
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="快递单号:" prop="deliveryFlowId">
  40. <el-input
  41. v-model.number="shipForm.deliveryFlowId"
  42. placeholder="输入快递单号"
  43. clearable
  44. size="small"
  45. style="width: 300px"
  46. />
  47. </el-form-item>
  48. </el-form>
  49. <!-- 商品 -->
  50. <el-table
  51. ref="table"
  52. :data="goodsInfo.items"
  53. @selection-change="handleSelectionGoods"
  54. class="ticket-table"
  55. >
  56. <el-table-column
  57. type="selection"
  58. width="55"
  59. align="center"
  60. fixed="left"
  61. />
  62. <el-table-column label="商品名称" prop="title" />
  63. <el-table-column label="规格">
  64. <template slot-scope="{ row }">
  65. <div>{{ row.properties || "--" }}</div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="数量">
  69. <template slot-scope="{ row }">
  70. <div>{{ row.goodsNum }}件</div>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="快递公司">
  74. <template slot-scope="{ row }">
  75. <div>{{ row.deliveryId || "--" }}</div>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="快递单号">
  79. <template slot-scope="{ row }">
  80. <div>{{ row.deliveryFlowId || "--" }}</div>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="发货状态">
  84. <template slot-scope="{ row }">
  85. <div>{{ row.deliveryFlowId ? "已发货" : "未发货" }}</div>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <div slot="footer" class="dialog-footer">
  90. <el-button @click="close">取 消</el-button>
  91. <el-button type="primary" :disabled="loading" @click="saveClick"
  92. >确 定</el-button
  93. >
  94. </div>
  95. </el-dialog>
  96. </div>
  97. </template>
  98. <script>
  99. import CustomFieldsMixin from "@/mixins/CustomFields";
  100. import { companyList, deliverOrderShip } from "@/api/business/order";
  101. export default {
  102. mixins: [CustomFieldsMixin],
  103. props: {
  104. // 弹框显示
  105. sendShow: {
  106. type: Boolean,
  107. default: false,
  108. },
  109. // 订单详情
  110. goodsInfo: {
  111. type: Object,
  112. default: {},
  113. },
  114. },
  115. created() {
  116. this.getCompanyList();
  117. },
  118. data() {
  119. return {
  120. loading: false,
  121. shipForm: {
  122. deliveryId: "",
  123. deliveryFlowId: "",
  124. },
  125. // 快递下拉列表
  126. companyData: [],
  127. // 选中商品ID
  128. ids: [],
  129. rules: {
  130. deliveryId: [
  131. { required: true, message: "请选择快递公司", trigger: "change" },
  132. ],
  133. deliveryFlowId: [
  134. { required: true, message: "请输入快递单号", trigger: "blur" },
  135. { type: "number", message: "快递单号为数字值", trigger: "blur" },
  136. ],
  137. },
  138. };
  139. },
  140. methods: {
  141. // 关闭发货弹框
  142. close() {
  143. this.$emit("close");
  144. this.loading = false;
  145. this.ids = [];
  146. this.$refs["shipForm"].resetFields();
  147. },
  148. // 快递下拉列表
  149. getCompanyList() {
  150. companyList({}).then((res) => {
  151. this.companyData = res.data;
  152. });
  153. },
  154. // 选中商品
  155. handleSelectionGoods(e) {
  156. this.ids = e.map((item) => item.itemId);
  157. },
  158. // 确认
  159. saveClick() {
  160. this.loading = true;
  161. const subForm = this.$refs["shipForm"];
  162. subForm.validate((valid) => {
  163. if (valid) {
  164. this.submitForm(this.shipForm);
  165. } else {
  166. this.loading = false;
  167. // 提示第一个error
  168. this.getFormErrorMessage(subForm);
  169. return false;
  170. }
  171. });
  172. },
  173. // 提交
  174. submitForm(form) {
  175. if (!this.ids.length) {
  176. this.msgError("请选择发货的商品");
  177. this.loading = false;
  178. return;
  179. }
  180. let data = {
  181. ...form,
  182. orderId: this.goodsInfo.orderId,
  183. itemIds: this.ids,
  184. };
  185. deliverOrderShip(data)
  186. .then((res) => {
  187. if (res.code == 0) {
  188. this.msgSuccess("发货成功");
  189. this.close();
  190. }
  191. })
  192. .catch(() => {
  193. this.loading = false;
  194. });
  195. },
  196. },
  197. };
  198. </script>
  199. <style>
  200. </style>