merge-print-scan-delivery.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <el-dialog title="扫码集货"
  3. :close-on-click-modal="false"
  4. :visible.sync="mergeScanVisible"
  5. v-if="mergeScanVisible"
  6. @close="closeMergeScanDialog"
  7. width="80%">
  8. <div style="margin: 20px">
  9. <h1 align="center">扫码集货打单</h1>
  10. <el-row>
  11. <el-col :span="3">
  12. <el-select v-model="logistics" placeholder="请选择快递">
  13. <el-option v-for="(item,index) in logisticsList"
  14. :key="index"
  15. :label="item.logisticsName"
  16. :value="item.logisticsValue">
  17. </el-option>
  18. </el-select>
  19. </el-col>
  20. <el-col :span="3">
  21. <el-select v-model="deviceNo" placeholder="请选择打印设备" >
  22. <el-option
  23. v-for="(item,index) in deviceList"
  24. :key="index"
  25. :label="item.deviceNo"
  26. :value="item.deviceNo">
  27. </el-option>
  28. </el-select>
  29. </el-col>
  30. <el-col :span="18">
  31. <el-input id="scanInput" @change="scanMatchPrintOrder" type="text" v-model="scanOrderNo" placeholder="请扫码二维码"></el-input>
  32. </el-col>
  33. </el-row>
  34. <div v-if="infoVisible">
  35. <div style="margin-top: 30px">
  36. <span style="font-weight: bold; font-size: 26px">集货单</span>
  37. <el-row>
  38. <el-col class="col" :span="6">订单编号</el-col>
  39. <el-col class="col" :span="3">数量</el-col>
  40. <el-col class="col" :span="6">扫码状态</el-col>
  41. <el-col class="col" :span="6">商品名称</el-col>
  42. <el-col class="col" :span="3">货架</el-col>
  43. </el-row>
  44. <el-row v-for="item in mergeRecordList">
  45. <el-col class="col" :span="6" :class="item.orderNumber === scanOrderNo? 'heightLine':''">{{item.orderNumber}}</el-col>
  46. <el-col class="col" :span="3">{{item.prodNums}}</el-col>
  47. <el-col class="col" :span="6" v-if="item.scanStatus === 0">未扫码</el-col>
  48. <el-col class="col" :span="6" v-if="item.scanStatus === 1" style="color: #2da641;font-weight: bold">已扫码</el-col>
  49. <el-col class="col" :span="6">{{item.prodName}}</el-col>
  50. <el-col class="col" :span="3">{{item.storeNo}}</el-col>
  51. </el-row>
  52. </div>
  53. <div style="margin-top: 6px">
  54. <span style="font-weight: bold; font-size: 26px;">配送信息</span>
  55. <el-row>
  56. <el-col class="col" :span="6">配送方式</el-col>
  57. <el-col class="col" :span="18" style="color: red">{{printOrder.orderLogistics.logisticsName}}</el-col>
  58. </el-row>
  59. <el-row>
  60. <el-col class="col" :span="6">收货地址</el-col>
  61. <el-col class="col" :span="18">{{printOrder.orderLogistics.receiverAddr}}</el-col>
  62. </el-row>
  63. <el-row>
  64. <el-col class="col" :span="6">收货人</el-col>
  65. <el-col class="col" :span="18">{{printOrder.orderLogistics.receiverName}}</el-col>
  66. </el-row>
  67. <el-row>
  68. <el-col class="col" :span="6">联系电话</el-col>
  69. <el-col class="col" :span="18">{{printOrder.orderLogistics.receiverMobile}}</el-col>
  70. </el-row>
  71. </div>
  72. <div style="margin-top: 6px">
  73. <span style="font-weight: bold; font-size: 26px">打单记录</span>
  74. <el-row>
  75. <el-col class="col" :span="4">编号</el-col>
  76. <el-col class="col" :span="6">运单号</el-col>
  77. <el-col class="col" :span="4">打印次数</el-col>
  78. <el-col class="col" :span="6">打单时间</el-col>
  79. <el-col class="col" :span="4">操作</el-col>
  80. </el-row>
  81. <el-row>
  82. <el-col class="col" :span="4">{{printOrder.orderLogistics.logisticsName}}</el-col>
  83. <el-col class="col" :span="6">{{printOrder.orderLogistics.deliveryNo}}</el-col>
  84. <el-col class="col" :span="4">{{printOrder.orderLogistics.printTimes}}</el-col>
  85. <el-col class="col" :span="6">{{printOrder.orderLogistics.updateTime}}</el-col>
  86. <el-col class="col" :span="4">
  87. <el-button type="info" @click="handlePrintOrder">打印</el-button>
  88. </el-col>
  89. </el-row>
  90. </div>
  91. </div>
  92. </div>
  93. </el-dialog>
  94. </template>
  95. <script>
  96. // import AddOrUpdate from './orderLogistics-add-or-update'
  97. import {autoConnect, disAutoConnect, hiprint, defaultElementTypeProvider} from 'vue-plugin-hiprint'
  98. import template from './yunda-template-data'
  99. import printData from './yunda-print-data'
  100. autoConnect();
  101. hiprint.init();
  102. export default {
  103. data () {
  104. return {
  105. logistics: "YUNDA",
  106. logisticsList:[{logisticsName: "韵达速递", logisticsValue: "YUNDA"},{logisticsName: "申通快递", logisticsValue: "STO"}],
  107. dataList: [],
  108. page: {
  109. total: 0, // 总页数
  110. currentPage: 1, // 当前页数
  111. pageSize: 10 // 每页显示多少条
  112. },
  113. printOrder:{
  114. orderLogistics:{}
  115. },
  116. deviceList: [],
  117. deviceNo: null,
  118. infoVisible:false,
  119. lastInputStr: null,
  120. scanOrderNo: null,
  121. searchForm: {}, // 搜索
  122. dataListLoading: false,
  123. addOrUpdateVisible: false,
  124. mergeRecordList:[],
  125. mergeScanVisible: false,
  126. }
  127. },
  128. components: {
  129. // AddOrUpdate
  130. },
  131. created () {
  132. this.getDeviceList();
  133. },
  134. mounted () {
  135. this.buildDesigner();
  136. },
  137. methods: {
  138. init(){
  139. this.mergeScanVisible = true;
  140. },
  141. printWallbill(logistics){
  142. this.hiprintTemplate.print2(printData.value(logistics));
  143. },
  144. buildDesigner(){
  145. $("#hiprint-printTemplate").empty(); // 先清空, 避免重复构建
  146. this.hiprintTemplate = new hiprint.PrintTemplate({
  147. // 如果使用 vue ref 创建的模板json, 需要使用 .value 获取 (确保内部能够使用 object.key 拿到对应数据就行)
  148. template: template, // 模板json(object)
  149. settingContainer: "#PrintElementOptionSetting", // 元素参数容器
  150. });
  151. // 构建 并填充到 容器中
  152. this.hiprintTemplate.design("#hiprint-printTemplate");
  153. },
  154. closeMergeScanDialog(){
  155. this.mergeScanVisible = false;
  156. this.mergeRecordList = [];
  157. this.scanOrderNo = null;
  158. this.lastInputStr = null;
  159. this.$emit('refreshDataList')
  160. },
  161. getDeviceList(){
  162. this.$http({
  163. url: this.$http.adornUrl('/print/printDevice/getDeviceList'),
  164. method: 'GET',
  165. params: this.$http.adornParams(),
  166. }).then(({data}) => {
  167. if(data){
  168. this.deviceList = data;
  169. }
  170. }).catch((error) => {
  171. })
  172. },
  173. scanMatchPrintOrder(value){
  174. let substr;
  175. if(this.lastInputStr != null){
  176. substr = value.replace(new RegExp(this.lastInputStr), "");
  177. }else{
  178. substr = value;
  179. }
  180. if(!this.deviceNo){
  181. this.$message.error("请选择打印设备");
  182. }
  183. if(substr){
  184. this.scanOrderNo = substr;
  185. let dataBody = {orderNumber: substr};
  186. this.$http({
  187. url: this.$http.adornUrl('/mergeOrderRecord/scanMergeOrder'),
  188. method: 'POST',
  189. data: this.$http.adornData(dataBody),
  190. }).then(({data}) => {
  191. if(data){
  192. this.$message.success("扫码集货成功");
  193. this.getMergeOrderList(data.batchNo);
  194. }
  195. this.lastInputStr = substr;
  196. }).catch((error) =>{
  197. this.lastInputStr = substr;
  198. })
  199. }
  200. },
  201. getMergeOrderList(batchNo){
  202. this.$http({
  203. url: this.$http.adornUrl('/mergeOrderRecord/getMergeOrderList'),
  204. method: 'GET',
  205. params: this.$http.adornParams({batchNo:batchNo}),
  206. }).then(({data}) => {
  207. if(data){
  208. this.mergeRecordList = data;
  209. }
  210. this.infoVisible = true;
  211. })
  212. },
  213. handlePrintOrder(){
  214. if(!this.deviceNo){
  215. this.$message.error("请选择打印设备");
  216. }
  217. this.$confirm('确定打印面单吗?', '提示', {
  218. confirmButtonText: '确定',
  219. cancelButtonText: '取消',
  220. type: 'warning'
  221. }).then(() => {
  222. this.$http({
  223. url: this.$http.adornUrl('/logistics/mergePrintAndDelivery'),
  224. method: 'POST',
  225. data: this.$http.adornData({orderNumber: this.scanOrderNo, logistics: this.printOrder.orderLogistics.logistics, deviceNo: this.deviceNo}),
  226. }).then(({data}) => {
  227. if(data){
  228. this.$message.success("打印成功")
  229. this.getLogisticsInfo(this.scanOrderNo);
  230. if(this.logistics === 'YUNDA'){
  231. //打印韵达面单
  232. this.printWallbill(this.printOrder.orderLogistics)
  233. }
  234. }
  235. }).catch((error) => {
  236. this.$message.error("打印失败")
  237. })
  238. })
  239. },
  240. getLogisticsInfo(orderNumber){
  241. this.$http({
  242. url: this.$http.adornUrl('/logistics/getLogisticsInfo'),
  243. method: 'GET',
  244. params: this.$http.adornParams({orderNumber:orderNumber}),
  245. }).then(({data}) => {
  246. if(data){
  247. this.printOrder = data;
  248. }
  249. })
  250. },
  251. }
  252. }
  253. </script>
  254. <style lang="scss">
  255. .col{
  256. height: 40px;
  257. border: gainsboro 1px solid;
  258. font-size: 20px;
  259. line-height: 40px;
  260. text-align: center;
  261. }
  262. .heightLine{
  263. background-color: #2d8cf0;
  264. color: white;
  265. }
  266. </style>