SendGoods.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="订单发货"
  5. :visible.sync="sendShow"
  6. width="800px"
  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="companyName">
  24. <el-select
  25. v-model="shipForm.companyName"
  26. placeholder="请选择快递公司"
  27. clearable
  28. size="small"
  29. style="width: 500px"
  30. >
  31. <el-option
  32. v-for="item in companyData"
  33. :key="item.areaId"
  34. :label="item.companyName"
  35. :value="item.companyName"
  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: 500px"
  46. />
  47. </el-form-item>
  48. <el-form-item label="盲票组:">
  49. <el-select
  50. v-model="shipForm.boxId"
  51. placeholder="请选择盲票组"
  52. clearable
  53. size="small"
  54. style="width: 500px"
  55. >
  56. <el-option
  57. v-for="item in channelList"
  58. :key="item.areaId"
  59. :label="item.title"
  60. :value="item.boxId"
  61. >
  62. <div class="channel">
  63. <div>{{ item.boxNo }}</div>
  64. <div>{{ item.title }}</div>
  65. <div>{{ item.orderNum }}包</div>
  66. </div>
  67. </el-option>
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item label="盲票包序号:">
  71. <el-autocomplete
  72. v-model="pkgNo"
  73. :fetch-suggestions="querySearch"
  74. placeholder="输入盲票包序号"
  75. size="small"
  76. :disabled="shipForm.boxId ? false : true"
  77. style="width: 500px"
  78. @select="handleSelect"
  79. >
  80. <template slot-scope="{ item }">
  81. <div class="channel">
  82. <div>{{ item.startSn }}至{{ item.endSn }}</div>
  83. <div>{{ item.title }}</div>
  84. </div>
  85. </template>
  86. </el-autocomplete>
  87. </el-form-item>
  88. </el-form>
  89. <!-- 选中盲票组列表 -->
  90. <div class="table">
  91. <el-table ref="table" :data="list">
  92. <el-table-column label="盲票组" prop="title" />
  93. <el-table-column label="盲票包系列号范围" min-width="100">
  94. <template slot-scope="{ row }">
  95. <div>
  96. <div>{{ row.startSn }}至{{ row.endSn }}</div>
  97. </div>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="操作" width="50">
  101. <template slot-scope="scope">
  102. <div>
  103. <el-button
  104. type="text"
  105. size="small"
  106. @click="delList(scope.$index, scope.row)"
  107. >删除</el-button
  108. >
  109. </div>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. </div>
  114. <!-- 按钮 -->
  115. <div slot="footer" class="dialog-footer">
  116. <el-button @click="close">取 消</el-button>
  117. <el-button type="primary" :disabled="loading" @click="saveClick"
  118. >确 定</el-button
  119. >
  120. </div>
  121. </el-dialog>
  122. </div>
  123. </template>
  124. <script>
  125. import CustomFieldsMixin from "@/mixins/CustomFields";
  126. import {
  127. companyList,
  128. ticketPkgList,
  129. channelOrderShip,
  130. } from "@/api/business/order";
  131. export default {
  132. mixins: [CustomFieldsMixin],
  133. props: {
  134. // 发货弹框显示
  135. sendShow: {
  136. type: Boolean,
  137. default: false,
  138. },
  139. // 订单详情
  140. goodsInfo: {
  141. type: Object,
  142. default: {},
  143. },
  144. // 盲票组下拉列表
  145. channelList: {
  146. type: Array,
  147. default: [],
  148. },
  149. },
  150. created() {
  151. this.getCompanyList();
  152. },
  153. data() {
  154. return {
  155. loading: false,
  156. shipForm: {
  157. companyName: "",
  158. deliveryFlowId: "",
  159. boxId: "",
  160. },
  161. // 快递下拉列表
  162. companyData: [],
  163. // 盲票组序列号
  164. pkgNo: "",
  165. // 选中盲票组列表
  166. list: [],
  167. rules: {
  168. companyName: [
  169. { required: true, message: "请选择快递公司", trigger: "change" },
  170. ],
  171. deliveryFlowId: [
  172. { required: true, message: "请输入快递单号", trigger: "blur" },
  173. ],
  174. },
  175. };
  176. },
  177. methods: {
  178. // 关闭发货弹框
  179. close() {
  180. this.$emit("close");
  181. this.loading = false;
  182. this.list = [];
  183. this.shipForm.boxId = "";
  184. this.$refs["shipForm"].resetFields();
  185. },
  186. // 快递下拉列表
  187. getCompanyList() {
  188. companyList({}).then((res) => {
  189. this.companyData = res.data;
  190. });
  191. },
  192. // 查询盲票组序列号
  193. querySearch(queryString, cb) {
  194. ticketPkgList({
  195. orderId: this.goodsInfo.orderId,
  196. boxId: this.shipForm.boxId,
  197. pkgNo: this.pkgNo,
  198. }).then((res) => {
  199. cb(res.data);
  200. });
  201. },
  202. // 选中盲票组序列号
  203. handleSelect(item) {
  204. let index = this.list.findIndex(ele=>{
  205. return item.pkgId == ele.pkgId
  206. })
  207. if(index != -1){
  208. this.msgError("当前票包已选!");
  209. return
  210. }
  211. this.list.push(item);
  212. },
  213. // 删除选中盲票组序列号
  214. delList(index, row) {
  215. this.list.splice(index, 1);
  216. },
  217. // 确认
  218. saveClick() {
  219. this.loading = true;
  220. const subForm = this.$refs["shipForm"];
  221. subForm.validate((valid) => {
  222. if (valid) {
  223. this.submitForm(this.shipForm);
  224. } else {
  225. this.loading = false;
  226. // 提示第一个error
  227. this.getFormErrorMessage(subForm);
  228. return false;
  229. }
  230. });
  231. },
  232. // 提交
  233. submitForm(form) {
  234. let ids = this.list.map((item) => item.pkgId);
  235. if (!ids.length) {
  236. this.msgError("请选择发货的票包");
  237. this.loading = false;
  238. return;
  239. }
  240. if (this.goodsInfo.pkgNum != ids.length) {
  241. this.msgError(
  242. `应发${this.goodsInfo.pkgNum}包,实际选中${ids.length}包`
  243. );
  244. this.loading = false;
  245. return;
  246. }
  247. let data = {
  248. ...form,
  249. orderId: this.goodsInfo.orderId,
  250. pkgIds: ids,
  251. };
  252. channelOrderShip(data)
  253. .then((res) => {
  254. if (res.code == 0) {
  255. this.msgSuccess("发货成功");
  256. this.close();
  257. }
  258. })
  259. .catch(() => {
  260. this.loading = false;
  261. });
  262. },
  263. },
  264. };
  265. </script>
  266. <style scoped>
  267. .channel {
  268. display: flex;
  269. align-items: center;
  270. justify-content: space-between;
  271. }
  272. </style>