ticketingCollection.vue 22 KB

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