ticketingCollection.vue 22 KB

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