ticketingCollection.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div class="app-container app-container-me">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
  4. <el-form-item label="订单号" label-width="80px">
  5. <el-input
  6. v-model="queryParams.orderId"
  7. placeholder="请输入订单号"
  8. clearable
  9. style="width: 240px;"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="取票码" label-width="80px">
  14. <el-input
  15. v-model="queryParams.qrcodeNo"
  16. placeholder="请输入取票码"
  17. clearable
  18. style="width: 240px;"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="手机号:" prop="mobile">
  23. <el-input
  24. v-model="queryParams.mobile"
  25. placeholder="请输入手机号"
  26. clearable
  27. style="width: 240px;"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="身份证号:" label-width="120px" prop="idcard">
  32. <el-input
  33. v-model="queryParams.idcard"
  34. placeholder="请输入身份证号"
  35. clearable
  36. style="width: 240px;"
  37. @keyup.enter.native="handleQuery"
  38. >
  39. <el-button slot="append" :loading="idcardLoading" size="mini" type="primary" @click="readCert">{{ idcardLoading ? '识别中':'识别' }}</el-button>
  40. </el-input>
  41. </el-form-item>
  42. <el-form-item label="座位号" label-width="80px">
  43. <el-input
  44. v-model="queryParams.seatName"
  45. placeholder="请输入座位号"
  46. clearable
  47. style="width: 240px;"
  48. @keyup.enter.native="handleQuery"
  49. />
  50. </el-form-item>
  51. <el-form-item label="订单状态">
  52. <el-select
  53. v-model="queryParams.orderStatus"
  54. placeholder="订单状态"
  55. clearable
  56. style="width: 100%"
  57. >
  58. <el-option
  59. v-for="dict in dict.type.order_status_type"
  60. :key="dict.value"
  61. :label="dict.label"
  62. :value="dict.value"
  63. />
  64. </el-select>
  65. </el-form-item>
  66. <el-form-item>
  67. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  68. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  69. </el-form-item>
  70. </el-form>
  71. <el-row :gutter="10" class="mb8">
  72. <el-col :span="1.5">
  73. <el-button
  74. :disabled="multipleSelection.length == 0"
  75. type="primary"
  76. plain
  77. icon="el-icon-plus"
  78. size="mini"
  79. @click="openMultipleSelectionVisible"
  80. v-hasPermi="['windowTicketSales:ticketingCollection:print']"
  81. >批量打印门票</el-button>
  82. </el-col>
  83. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  84. </el-row>
  85. <el-table
  86. ref="tables"
  87. v-loading="loading"
  88. :data="dataList"
  89. @selection-change="handleSelectionChange"
  90. border>
  91. <el-table-column type="selection" width="55"></el-table-column>
  92. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  93. <el-table-column label="姓名" align="center" prop="name" />
  94. <el-table-column label="身份证号" align="center" prop="idcard" />
  95. <el-table-column label="手机号" align="center" prop="mobile" />
  96. <el-table-column label="取票码" align="center" prop="qrcodeNo" />
  97. <el-table-column label="订单号" align="center" prop="orderId" />
  98. <el-table-column label="剧目名称" align="center" prop="performName" />
  99. <el-table-column label="票务名称" align="center" prop="goodsName" />
  100. <el-table-column label="座位信息" align="center" prop="seatName" />
  101. <el-table-column label="座位类型" align="center" prop="seatTypeName" />
  102. <el-table-column label="节目播出日期" align="center" prop="performDate" />
  103. <el-table-column label="下单时间" align="center" prop="createTime" />
  104. <el-table-column label="购票渠道" align="center" prop="source">
  105. <template slot-scope="scope">
  106. <dict-tag :options="dict.type.order_form_type" :value="scope.row.source"/>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="订单状态" align="center" prop="status">
  110. <template slot-scope="scope">
  111. <dict-tag :options="dict.type.order_status_type" :value="scope.row.status"/>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="打印次数" align="center" prop="printNum" />
  115. <el-table-column label="操作" align="center" fixed="right" width="80" class-name="small-padding fixed-width">
  116. <template slot-scope="scope">
  117. <el-button
  118. size="mini"
  119. type="text"
  120. @click="handleOpen([scope.row])"
  121. v-hasPermi="['windowTicketSales:ticketingCollection:print']"
  122. >打印门票</el-button>
  123. </template>
  124. </el-table-column>
  125. <template slot="empty">
  126. <div>
  127. <span>未查询到相关订单,请重新输入!</span>
  128. </div>
  129. </template>
  130. </el-table>
  131. <pagination
  132. v-show="total>0"
  133. :total="total"
  134. :page.sync="queryParams.pageNum"
  135. :limit.sync="queryParams.pageSize"
  136. @pagination="getList"
  137. />
  138. <!-- 批量打印顺序 -->
  139. <el-dialog
  140. title="批量打印顺序"
  141. :visible.sync="multipleSelectionVisible"
  142. width="90%"
  143. :before-close="()=>{ multipleSelectionVisible = false}">
  144. <el-table
  145. ref="tabless"
  146. v-loading="loading"
  147. :data="multipleSelectionTabel"
  148. border>
  149. <el-table-column label="打印顺序" align="center" type="index" width="50"></el-table-column>
  150. <el-table-column label="姓名" align="center" prop="name" />
  151. <el-table-column label="身份证号" align="center" prop="idcard" />
  152. <el-table-column label="手机号" align="center" prop="mobile" />
  153. <el-table-column label="取票码" align="center" prop="qrcodeNo" />
  154. <el-table-column label="订单号" align="center" prop="orderId" />
  155. <el-table-column label="剧目名称" align="center" prop="performName" />
  156. <el-table-column label="票务名称" align="center" prop="goodsName" />
  157. <el-table-column label="座位信息" align="center" prop="seatName" />
  158. <el-table-column label="座位类型" align="center" prop="seatTypeName" />
  159. <el-table-column label="节目播出日期" align="center" prop="performDate" />
  160. <el-table-column label="下单时间" align="center" prop="createTime" />
  161. <el-table-column label="购票渠道" align="center" prop="source">
  162. <template slot-scope="scope">
  163. <dict-tag :options="dict.type.order_form_type" :value="scope.row.source"/>
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="订单状态" align="center" prop="status">
  167. <template slot-scope="scope">
  168. <dict-tag :options="dict.type.order_status_type" :value="scope.row.status"/>
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. <span slot="footer" class="dialog-footer">
  173. <el-button @click="multipleSelectionVisible = false">取 消</el-button>
  174. <el-button type="primary" :loading="loading" @click="handleOpen(multipleSelection)">{{ dialogVisibleLoading?'打印中...':'打印' }}</el-button>
  175. </span>
  176. </el-dialog>
  177. <!-- 选择打印机 -->
  178. <el-dialog
  179. title="选择打印机"
  180. :visible.sync="dialogVisible"
  181. width="30%"
  182. :before-close="handleClose">
  183. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  184. <el-form-item label="打印机" prop="region">
  185. <el-select v-model="ruleForm.region" placeholder="选择打印机">
  186. <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
  187. </el-select>
  188. </el-form-item>
  189. </el-form>
  190. <span slot="footer" class="dialog-footer">
  191. <el-button @click="dialogVisible = false">取 消</el-button>
  192. <el-button type="primary" :loading="dialogVisibleLoading" @click="print(viewerList)">{{ dialogVisibleLoading?'打印中...':'打印' }}</el-button>
  193. </span>
  194. </el-dialog>
  195. </div>
  196. </template>
  197. <script>
  198. import { pageList,printApi } from '@/api/windowTicketSales/ticketingCollection'
  199. import { pageList as getPrintListApi } from "@/api/device/pda";
  200. const https = require('https');
  201. const axios = require('axios');
  202. export default {
  203. name: "TicketingCollectionfsd",
  204. dicts: ['order_form_type','order_status_type'],
  205. data() {
  206. return {
  207. // 遮罩层
  208. loading: false,
  209. // 选中数组
  210. multipleSelection: [],
  211. multipleSelectionTabel: [],
  212. multipleSelectionVisible: false,
  213. // 显示搜索条件
  214. showSearch: true,
  215. // 总条数
  216. total: 0,
  217. // 用户表格数据
  218. dataList: null,
  219. // 查询参数
  220. queryParams: {
  221. pageNum: 1,
  222. pageSize: 10,
  223. // type: undefined
  224. //orderStatus: "3"
  225. },
  226. visibleStatus: false,
  227. visibleStatusLoading: false,
  228. ruleForm: {},
  229. rules: {
  230. remark: [
  231. { required: true, message: '请输入备注', trigger: ['blur','change'] },
  232. { min: 0, max: 50, message: '长度在 0 到 50 个字符', trigger: ['blur','change'] }
  233. ]
  234. },
  235. viewerList: [],
  236. printList: [],
  237. dialogVisible: false,
  238. ruleForm: {},
  239. rules: {
  240. region: [
  241. { required: true, message: '请选择打印机', trigger: ['change','blur' ]}
  242. ],
  243. },
  244. dialogVisibleLoading: false,
  245. idcardLoading: false,
  246. };
  247. },
  248. created() {
  249. console.log("params====",this.$route)
  250. if(this.$route.query&&this.$route.query.orderId) {
  251. this.$set(this.queryParams,'orderId',this.$route.query.orderId)
  252. this.getList()
  253. }
  254. //this.getList();
  255. //this.getPrintListApi()
  256. },
  257. methods: {
  258. /** 查询列表 */
  259. getList() {
  260. this.loading = true;
  261. pageList(this.queryParams)
  262. .then(response => {
  263. this.dataList = response.data.rows;
  264. this.total = response.data.total;
  265. this.loading = false;
  266. console.log("this.multipleSelection=====",this.multipleSelection)
  267. }
  268. ).catch(()=>{
  269. this.dataList = []
  270. this.total = 0
  271. this.loading = false
  272. })
  273. },
  274. // 取消按钮
  275. cancel() {
  276. this.open = false;
  277. },
  278. /** 搜索按钮操作 */
  279. handleQuery() {
  280. this.getList();
  281. },
  282. /** 重置按钮操作 */
  283. resetQuery() {
  284. this.dateRange = [];
  285. this.$set(this.queryParams, 'orderId', '');
  286. this.$set(this.queryParams, 'qrcodeNo', '');
  287. this.$set(this.queryParams, 'idcard', '');
  288. this.$set(this.queryParams, 'mobile', '');
  289. this.$set(this.queryParams, 'orderStatus', '');
  290. this.$set(this.queryParams, 'seatName', '');
  291. this.handleQuery();
  292. },
  293. setRemark(data) {
  294. this.visibleStatus = true
  295. this.resetForm.id = data.id
  296. },
  297. submitForm(formName) {
  298. this.$refs[formName].validate(async (valid) => {
  299. if (valid) {
  300. try {
  301. this.visibleStatusLoading = true
  302. let res = await setRemark({
  303. id: this.resetForm.id,
  304. "remark": this.ruleForm.remark
  305. })
  306. this.visibleStatus = false
  307. this.visibleStatusLoading = false
  308. this.resetForm('ruleForm')
  309. this.queryParams.pageNum = 1;
  310. this.getList()
  311. } catch (error) {
  312. this.visibleStatusLoading = false
  313. }
  314. } else {
  315. this.visibleStatusLoading = false
  316. return false;
  317. }
  318. });
  319. },
  320. resetForm(formName) {
  321. this.$refs[formName].resetFields();
  322. },
  323. handleSelectionChange(val,row) {
  324. console.log("val====",val,row)
  325. this.multipleSelection = val;
  326. },
  327. openMultipleSelectionVisible(){
  328. console.log("sdfasgadfgadfgadfgadfg")
  329. this.multipleSelectionTabel = JSON.parse(JSON.stringify(this.multipleSelection))
  330. this.multipleSelectionVisible = true
  331. },
  332. handleOpen(list=[]){
  333. if(!list||list.length==0) return
  334. let idList = []
  335. list.forEach((item,index)=>{
  336. idList.push({
  337. viewerId: item.id,
  338. index: index
  339. })
  340. })
  341. this.viewerList = idList
  342. this.getPrintListApi()
  343. this.$set(this.ruleForm, 'region', '');
  344. this.$nextTick(()=>{
  345. this.$refs.ruleForm.clearValidate('region')
  346. })
  347. this.dialogVisible = true
  348. },
  349. handleClose(){
  350. this.dialogVisible = false
  351. },
  352. /** 查询打印机列表 */
  353. getPrintListApi() {
  354. getPrintListApi({deviceType:5,pageNum: 1,
  355. pageSize: 999,})
  356. .then(response => {
  357. this.printList = response.data.rows;
  358. }).catch((error)=>{
  359. console.log("error===",error)
  360. }
  361. );
  362. },
  363. /** 选择打印机 */
  364. selectPrint(){
  365. },
  366. // 打印
  367. async print(list = []){
  368. this.$refs.ruleForm.validate(async (valid) => {
  369. if (valid) {
  370. this.dialogVisibleLoading = true
  371. try {
  372. let res = await printApi({
  373. viewerList2:list,
  374. source: 2,
  375. deviceId: this.ruleForm.region
  376. })
  377. if(res.code == 200) {
  378. let url = res.data.linkIp
  379. let printInfo = res.data.printInfo
  380. this.connectPrint(url,printInfo)
  381. }else {
  382. throw new Error(res)
  383. }
  384. } catch (error) {
  385. this.dialogVisible = false
  386. this.dialogVisibleLoading = false
  387. console.error("error=====",error)
  388. }
  389. } else {
  390. console.log('error submit!!');
  391. return false;
  392. }
  393. });
  394. },
  395. /** 连接打印机 */
  396. connectPrint(url,data){
  397. // let xhr = new XMLHttpRequest();
  398. // xhr.withCredentials = true
  399. // xhr.onreadystatechange = ()=>{
  400. // if(xhr.readyState == 4){ // 监听请求完成
  401. // if((xhr.status >=200 && xhr.status <300) || xhr.status == 304){
  402. // console.log(xhr.responseText)
  403. // this.dialogVisible = false
  404. // this.dialogVisibleLoading = false
  405. // }else{
  406. // console.log('请求失败')
  407. // this.dialogVisible = false
  408. // this.dialogVisibleLoading = false
  409. // }
  410. // }
  411. // }
  412. // xhr.open("post", url, true); // 异步请求
  413. // xhr.setRequestHeader('Content-Type', 'application/json')
  414. // xhr.send(JSON.stringify(data));
  415. // 创建忽略 SSL 的 axios 实例
  416. const ignoreSSL = axios.create({
  417. httpsAgent: new https.Agent({
  418. rejectUnauthorized: false
  419. }),
  420. withCredentials: true, // 跨域请求时发送Cookie
  421. timeout: 60000, // 请求超时
  422. headers: {
  423. "Content-Type": "application/json; charset=UTF-8;"
  424. }
  425. });
  426. ignoreSSL.post(url,
  427. { ...data }
  428. ).then(()=>{
  429. this.dialogVisible = false
  430. this.dialogVisibleLoading = false
  431. }).catch(()=>{
  432. this.dialogVisible = false
  433. this.dialogVisibleLoading = false
  434. })
  435. // 在 axios 请求时,选择性忽略 SSL
  436. // const agent = new https.Agent({
  437. // rejectUnauthorized: false
  438. // });
  439. // axios.post(
  440. // url,
  441. // { httpsAgent: agent,...data }
  442. // ).then(()=>{
  443. // this.dialogVisible = false
  444. // this.dialogVisibleLoading = false
  445. // })
  446. // .catch(()=>{
  447. // this.dialogVisible = false
  448. // this.dialogVisibleLoading = false
  449. // })
  450. },
  451. /** 读取身份证 */
  452. readCert(){
  453. this.idcardLoading = true
  454. var result = "";
  455. try {
  456. let xmlHttp = new XMLHttpRequest();
  457. let Protocol = window.location.protocol.split(':')[0];
  458. //获取当前协议,并且分割字符串,得到http或者https
  459. if (Protocol === 'https'){
  460. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  461. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  462. }else {
  463. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  464. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  465. }
  466. //发送请求
  467. xmlHttp.send();
  468. if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  469. result = xmlHttp.responseText;
  470. xmlHttp.readyState = 1;
  471. }
  472. } catch (e) {
  473. console.error("e====",e)
  474. }
  475. let obj = JSON.parse(result)
  476. if(obj.resultContent && obj.resultContent.certNumber){
  477. this.$set(this.queryParams,"idcard",obj.resultContent.certNumber)
  478. }else {
  479. this.$message.error('读取失败!!!');
  480. }
  481. this.idcardLoading = false
  482. //return result;
  483. console.log(result,obj)
  484. }
  485. }
  486. };
  487. </script>