SendGoods.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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="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.companyName || "--" }}</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. // 选中sp
  128. goodsList: [],
  129. // 选中商品ID
  130. ids: [],
  131. rules: {
  132. deliveryId: [
  133. { required: true, message: "请选择快递公司", trigger: "change" },
  134. ],
  135. deliveryFlowId: [
  136. { required: true, message: "请输入快递单号", trigger: "blur" },
  137. ],
  138. },
  139. };
  140. },
  141. methods: {
  142. // 关闭发货弹框
  143. close() {
  144. this.$emit("close");
  145. this.loading = false;
  146. this.ids = [];
  147. this.$refs["shipForm"].resetFields();
  148. },
  149. // 快递下拉列表
  150. getCompanyList() {
  151. companyList({}).then((res) => {
  152. this.companyData = res.data;
  153. });
  154. },
  155. // 选中商品
  156. handleSelectionGoods(e) {
  157. this.goodsList = e
  158. },
  159. // 确认
  160. saveClick() {
  161. this.loading = true;
  162. const subForm = this.$refs["shipForm"];
  163. subForm.validate((valid) => {
  164. if (valid) {
  165. this.submitForm(this.shipForm);
  166. } else {
  167. this.loading = false;
  168. // 提示第一个error
  169. this.getFormErrorMessage(subForm);
  170. return false;
  171. }
  172. });
  173. },
  174. // 提交
  175. submitForm(form) {
  176. if (!this.goodsList.length) {
  177. this.msgError("请选择发货的商品");
  178. this.loading = false;
  179. return;
  180. }
  181. let index = this.goodsList.findIndex(item=>{
  182. return item.deliveryFlowId
  183. })
  184. if(index != -1){
  185. this.msgError(`${ this.goodsList[index].title }已发货!`);
  186. this.loading = false;
  187. return
  188. }
  189. this.ids = this.goodsList.map((item) => item.itemId);
  190. let data = {
  191. ...form,
  192. orderId: this.goodsInfo.orderId,
  193. itemIds: this.ids,
  194. };
  195. deliverOrderShip(data)
  196. .then((res) => {
  197. if (res.code == 0) {
  198. this.msgSuccess("发货成功");
  199. this.close();
  200. }
  201. })
  202. .catch(() => {
  203. this.loading = false;
  204. });
  205. },
  206. },
  207. };
  208. </script>
  209. <style>
  210. </style>