MONSTER-ygh 1 tahun lalu
induk
melakukan
9f576431c9

+ 105 - 13
src/views/order/orderMr/index.vue

@@ -196,7 +196,7 @@
           <el-button
               size="mini"
               type="text"
-              @click="print([scope.row])"
+              @click="handleOpen([scope.row])"
               v-hasPermi="['orderMr:orderMr:print']"
             >打印小票</el-button>
         </template>
@@ -214,6 +214,23 @@
     <!-- 详情 -->
     <details-dia ref="detailsDia" @getList="getList"></details-dia>
 
+    <el-dialog
+        title="选择小票机"
+        :visible.sync="dialogVisible"
+        width="30%"
+        :before-close="handleClose">
+        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
+          <el-form-item label="小票机" prop="region">
+            <el-select v-model="ruleForm.region" placeholder="选择小票机">
+              <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-form>
+        <span slot="footer" class="dialog-footer">
+          <el-button @click="dialogVisible = false">取 消</el-button>
+          <el-button type="primary" :loading="dialogVisibleLoading" @click="print(viewerList)">{{ dialogVisibleLoading?'打印中...':'打印' }}</el-button>
+        </span>
+      </el-dialog>
   </div>
 </template>
 
@@ -223,6 +240,7 @@ import { pageList,downOrderListXls, printApi } from '@/api/order/orderMr'
 import detailsDia from "./dialog/details";
 import { pagePerformTimeList } from "@/api/schedulingMr/schedulingMr"
 import { exportExcel } from '@/utils/exportexcel'
+import { pageList as getPrintListApi } from "@/api/device/pda";
 export default {
   name: "agreement",
   dicts: ['order_form_type','order_status_type','pay_way_type'],
@@ -262,6 +280,17 @@ export default {
       pagePerformTimeList: [], // 场次列表
 
       handleExportLoading: false,
+
+      viewerList: [],
+        printList: [],
+        dialogVisible: false,
+        ruleForm: {},
+        rules: {
+          region: [
+            { required: true, message: '请选择打印机', trigger: ['change','blur' ]}
+          ],
+        },
+        dialogVisibleLoading: false,
     };
   },
   created() {
@@ -372,26 +401,89 @@ export default {
           this.$message.info('您已取消导出!');
         });
     },
-    // 打印 
-    async print(list = []){
+    
+
+    handleOpen(list=[]){
           if(!list||list.length==0) return
           let idList = []
           list.forEach((item,index)=>{
             idList.push(item.id)
           }) 
-          console.log("isList===",idList)
-          return
-          try {
-            let res = await printApi({viewerList:idList})
-            if(res.code == 200) {
+          this.viewerList = idList
+          this.getPrintListApi()
+          this.$set(this.ruleForm, 'region', '');
+          this.$nextTick(()=>{
+            this.$refs.ruleForm.clearValidate('region')
+          })
+          this.dialogVisible = true
+        },
+        handleClose(){
+          this.dialogVisible = false
+        },
+        /** 查询打印机列表 */
+        getPrintListApi() {
+          getPrintListApi({deviceType:5,pageNum: 1,
+          pageSize: 999,})
+          .then(response => {
+              this.printList = response.data.rows;
+            }
+          );
+        },
+        /**  选择打印机  */
+        selectPrint(){
 
-            }else {
-              throw new Error(res)
+        },
+        // 打印 
+        async print(list = []){
+          this.$refs.ruleForm.validate(async (valid) => {
+            if (valid) {
+              this.dialogVisibleLoading = true
+              try {
+                let res = await printApi({
+                  viewerList:list,
+                  source: 2,
+                  deviceId: this.ruleForm.region
+                })
+                if(res.code == 200) {
+                  let url = res.data.linkIp
+                  let printInfo = res.data.printInfo
+                  this.connectPrint(url,printInfo)
+                }else {
+                  throw new Error(res)
+                }
+              } catch (error) {
+                this.dialogVisible = false
+                this.dialogVisibleLoading = false
+                console.error("error=====",error)
+              }
+            } else {
+              console.log('error submit!!');
+              return false;
             }
-          } catch (error) {
-            console.error("error=====",error)
-          }
+          });
+          
         },
+        /**  连接打印机  */
+        connectPrint(url,data){
+          let xhr = new XMLHttpRequest();
+          xhr.onreadystatechange = ()=>{
+          if(xhr.readyState == 4){ // 监听请求完成
+              if((xhr.status >=200 && xhr.status <300) || xhr.status == 304){
+                console.log(xhr.responseText)
+                this.dialogVisible = false
+                this.dialogVisibleLoading = false
+              }else{
+                console.log('请求失败')
+                this.dialogVisible = false
+                this.dialogVisibleLoading = false
+              }
+            }
+          }
+          xhr.open("post", url, true); // 异步请求
+          xhr.send(JSON.stringify(data));
+
+
+        }
   }
 };
 </script>

+ 3 - 0
src/views/ticket/ticketMr/dialog/FreightMgrIndexMi.js

@@ -23,6 +23,9 @@ export default {
         
     },
     methods: {
+        handleChangeProvince(){
+            
+        },
         /**
          * 取消查看可配送区域对话框
          */

+ 2 - 2
src/views/ticket/ticketMr/dialog/addAndEdit.vue

@@ -113,9 +113,9 @@
               <el-checkbox v-model="form.channelWindow">窗口</el-checkbox>
               <el-checkbox v-model="form.channelAutoSale">自助售/取票机</el-checkbox>
             </el-form-item>
-            <!-- <el-form-item label="可售区域:" required label-width="100px">
+            <el-form-item label="可售区域:" required label-width="100px">
               <span @click="deliverableAreaDialogCancel">请选择</span>
-            </el-form-item> -->
+            </el-form-item>
           </el-tab-pane>
 
           <!--    退票信息     -->

+ 115 - 16
src/views/windowTicketSales/ticketingCollection.vue

@@ -57,7 +57,7 @@
                 plain
                 icon="el-icon-plus"
                 size="mini"
-                @click="print(multipleSelection)"
+                @click="handleOpen(multipleSelection)"
                 v-hasPermi="['windowTicketSales:ticketingCollection:print']"
               >批量打印名票</el-button>
         </el-col>
@@ -98,7 +98,7 @@
             <el-button
               size="mini"
               type="text"
-              @click="print([scope.row])"
+              @click="handleOpen([scope.row])"
               v-hasPermi="['windowTicketSales:ticketingCollection:print']"
             >打印门票</el-button>
           </template>
@@ -109,12 +109,32 @@
             </div>
         </template>
       </el-table>
+
+      <el-dialog
+        title="选择打印机"
+        :visible.sync="dialogVisible"
+        width="30%"
+        :before-close="handleClose">
+        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
+          <el-form-item label="打印机" prop="region">
+            <el-select v-model="ruleForm.region" placeholder="选择打印机">
+              <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-form>
+        <span slot="footer" class="dialog-footer">
+          <el-button @click="dialogVisible = false">取 消</el-button>
+          <el-button type="primary" :loading="dialogVisibleLoading" @click="print(viewerList)">{{ dialogVisibleLoading?'打印中...':'打印' }}</el-button>
+        </span>
+      </el-dialog>
+
     </div>
   </template>
   
   <script>
   
   import { pageList,printApi } from '@/api/windowTicketSales/ticketingCollection'
+  import { pageList as getPrintListApi } from "@/api/device/pda";
   export default {
     name: "distributionapplication",
     dicts: ['order_form_type','order_status_type'],
@@ -135,7 +155,7 @@
           // pageNum: 1,
           // pageSize: 10,
           // type: undefined
-          orderStatus: 3
+          orderStatus: "3"
         },
         visibleStatus: false,
         visibleStatusLoading: false,
@@ -145,11 +165,23 @@
             { required: true, message: '请输入备注', trigger: ['blur','change'] },
             { min: 0, max: 50, message: '长度在 0 到 50 个字符', trigger: ['blur','change'] }
           ]
-        }
+        },
+        
+        viewerList: [],
+        printList: [],
+        dialogVisible: false,
+        ruleForm: {},
+        rules: {
+          region: [
+            { required: true, message: '请选择打印机', trigger: ['change','blur' ]}
+          ],
+        },
+        dialogVisibleLoading: false,
       };
     },
     created() {
       //this.getList();
+      //this.getPrintListApi()
     },
     methods: {
       /** 查询列表 */
@@ -216,26 +248,93 @@
           console.log("val====",val)
           this.multipleSelection = val;
         },
-        // 打印 
-        async print(list = []){
+        handleOpen(list=[]){
           if(!list||list.length==0) return
           let idList = []
           list.forEach((item,index)=>{
             idList.push(item.id)
           }) 
-          console.log("isList===",idList)
-          return
-          try {
-            let res = await printApi({viewerList:idList})
-            if(res.code == 200) {
+          this.viewerList = idList
+          this.getPrintListApi()
+          this.$set(this.ruleForm, 'region', '');
+          this.$nextTick(()=>{
+            this.$refs.ruleForm.clearValidate('region')
+          })
+          this.dialogVisible = true
+        },
+        handleClose(){
+          this.dialogVisible = false
+        },
+        /** 查询打印机列表 */
+        getPrintListApi() {
+          getPrintListApi({deviceType:5,pageNum: 1,
+          pageSize: 999,})
+          .then(response => {
+              this.printList = response.data.rows;
+          }).catch((error)=>{
+            console.log("error===",error)
+          }
+          );
+        },
+        /**  选择打印机  */
+        selectPrint(){
 
-            }else {
-              throw new Error(res)
+        },
+        // 打印 
+        async print(list = []){
+          this.$refs.ruleForm.validate(async (valid) => {
+            if (valid) {
+              this.dialogVisibleLoading = true
+              try {
+                let res = await printApi({
+                  viewerList:list,
+                  source: 2,
+                  deviceId: this.ruleForm.region
+                })
+                if(res.code == 200) {
+                  let url = res.data.linkIp
+                  let printInfo = res.data.printInfo
+                  this.connectPrint(url,printInfo)
+                }else {
+                  throw new Error(res)
+                }
+              } catch (error) {
+                this.dialogVisible = false
+                this.dialogVisibleLoading = false
+                console.error("error=====",error)
+              }
+            } else {
+              console.log('error submit!!');
+              return false;
             }
-          } catch (error) {
-            console.error("error=====",error)
-          }
+          });
+          
         },
+        /**  连接打印机  */
+        connectPrint(url,data){
+          let xhr = new XMLHttpRequest();
+          xhr.withCredentials = true
+          
+          xhr.onreadystatechange = ()=>{
+          if(xhr.readyState == 4){ // 监听请求完成
+              if((xhr.status >=200 && xhr.status <300) || xhr.status == 304){
+                console.log(xhr.responseText)
+                this.dialogVisible = false
+                this.dialogVisibleLoading = false
+              }else{
+                console.log('请求失败')
+                this.dialogVisible = false
+                this.dialogVisibleLoading = false
+              }
+            }
+          }
+         
+          xhr.open("post", url, true); // 异步请求
+          xhr.setRequestHeader('Content-Type', 'application/json')
+          xhr.send(JSON.stringify(data));
+
+
+        }
     }
   };
   </script>