ticketingCollection.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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="handleOpen(multipleSelection)"
  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. <el-dialog
  139. title="选择打印机"
  140. :visible.sync="dialogVisible"
  141. width="30%"
  142. :before-close="handleClose">
  143. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  144. <el-form-item label="打印机" prop="region">
  145. <el-select v-model="ruleForm.region" placeholder="选择打印机">
  146. <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
  147. </el-select>
  148. </el-form-item>
  149. </el-form>
  150. <span slot="footer" class="dialog-footer">
  151. <el-button @click="dialogVisible = false">取 消</el-button>
  152. <el-button type="primary" :loading="dialogVisibleLoading" @click="print(viewerList)">{{ dialogVisibleLoading?'打印中...':'打印' }}</el-button>
  153. </span>
  154. </el-dialog>
  155. </div>
  156. </template>
  157. <script>
  158. import { pageList,printApi } from '@/api/windowTicketSales/ticketingCollection'
  159. import { pageList as getPrintListApi } from "@/api/device/pda";
  160. const https = require('https');
  161. const axios = require('axios');
  162. export default {
  163. name: "distributionapplication",
  164. dicts: ['order_form_type','order_status_type'],
  165. data() {
  166. return {
  167. // 遮罩层
  168. loading: false,
  169. // 选中数组
  170. multipleSelection: [],
  171. // 显示搜索条件
  172. showSearch: true,
  173. // 总条数
  174. total: 0,
  175. // 用户表格数据
  176. dataList: null,
  177. // 查询参数
  178. queryParams: {
  179. pageNum: 1,
  180. pageSize: 10,
  181. // type: undefined
  182. //orderStatus: "3"
  183. },
  184. visibleStatus: false,
  185. visibleStatusLoading: false,
  186. ruleForm: {},
  187. rules: {
  188. remark: [
  189. { required: true, message: '请输入备注', trigger: ['blur','change'] },
  190. { min: 0, max: 50, message: '长度在 0 到 50 个字符', trigger: ['blur','change'] }
  191. ]
  192. },
  193. viewerList: [],
  194. printList: [],
  195. dialogVisible: false,
  196. ruleForm: {},
  197. rules: {
  198. region: [
  199. { required: true, message: '请选择打印机', trigger: ['change','blur' ]}
  200. ],
  201. },
  202. dialogVisibleLoading: false,
  203. idcardLoading: false,
  204. };
  205. },
  206. created() {
  207. //this.getList();
  208. //this.getPrintListApi()
  209. },
  210. methods: {
  211. /** 查询列表 */
  212. getList() {
  213. this.loading = true;
  214. pageList(this.queryParams)
  215. .then(response => {
  216. this.dataList = response.data.rows;
  217. this.total = response.data.total;
  218. this.loading = false;
  219. console.log("this.multipleSelection=====",this.multipleSelection)
  220. }
  221. ).catch(()=>{
  222. this.dataList = []
  223. this.total = 0
  224. this.loading = false
  225. })
  226. },
  227. // 取消按钮
  228. cancel() {
  229. this.open = false;
  230. },
  231. /** 搜索按钮操作 */
  232. handleQuery() {
  233. this.getList();
  234. },
  235. /** 重置按钮操作 */
  236. resetQuery() {
  237. this.dateRange = [];
  238. this.$set(this.queryParams, 'orderId', '');
  239. this.$set(this.queryParams, 'qrcodeNo', '');
  240. this.$set(this.queryParams, 'idcard', '');
  241. this.$set(this.queryParams, 'mobile', '');
  242. this.$set(this.queryParams, 'orderStatus', '');
  243. this.$set(this.queryParams, 'seatName', '');
  244. this.handleQuery();
  245. },
  246. setRemark(data) {
  247. this.visibleStatus = true
  248. this.resetForm.id = data.id
  249. },
  250. submitForm(formName) {
  251. this.$refs[formName].validate(async (valid) => {
  252. if (valid) {
  253. try {
  254. this.visibleStatusLoading = true
  255. let res = await setRemark({
  256. id: this.resetForm.id,
  257. "remark": this.ruleForm.remark
  258. })
  259. this.visibleStatus = false
  260. this.visibleStatusLoading = false
  261. this.resetForm('ruleForm')
  262. this.queryParams.pageNum = 1;
  263. this.getList()
  264. } catch (error) {
  265. this.visibleStatusLoading = false
  266. }
  267. } else {
  268. this.visibleStatusLoading = false
  269. return false;
  270. }
  271. });
  272. },
  273. resetForm(formName) {
  274. this.$refs[formName].resetFields();
  275. },
  276. handleSelectionChange(val) {
  277. console.log("val====",val)
  278. this.multipleSelection = val;
  279. },
  280. handleOpen(list=[]){
  281. if(!list||list.length==0) return
  282. let idList = []
  283. list.forEach((item,index)=>{
  284. idList.push(item.id)
  285. })
  286. this.viewerList = idList
  287. this.getPrintListApi()
  288. this.$set(this.ruleForm, 'region', '');
  289. this.$nextTick(()=>{
  290. this.$refs.ruleForm.clearValidate('region')
  291. })
  292. this.dialogVisible = true
  293. },
  294. handleClose(){
  295. this.dialogVisible = false
  296. },
  297. /** 查询打印机列表 */
  298. getPrintListApi() {
  299. getPrintListApi({deviceType:5,pageNum: 1,
  300. pageSize: 999,})
  301. .then(response => {
  302. this.printList = response.data.rows;
  303. }).catch((error)=>{
  304. console.log("error===",error)
  305. }
  306. );
  307. },
  308. /** 选择打印机 */
  309. selectPrint(){
  310. },
  311. // 打印
  312. async print(list = []){
  313. this.$refs.ruleForm.validate(async (valid) => {
  314. if (valid) {
  315. this.dialogVisibleLoading = true
  316. try {
  317. let res = await printApi({
  318. viewerList:list,
  319. source: 2,
  320. deviceId: this.ruleForm.region
  321. })
  322. if(res.code == 200) {
  323. let url = res.data.linkIp
  324. let printInfo = res.data.printInfo
  325. this.connectPrint(url,printInfo)
  326. }else {
  327. throw new Error(res)
  328. }
  329. } catch (error) {
  330. this.dialogVisible = false
  331. this.dialogVisibleLoading = false
  332. console.error("error=====",error)
  333. }
  334. } else {
  335. console.log('error submit!!');
  336. return false;
  337. }
  338. });
  339. },
  340. /** 连接打印机 */
  341. connectPrint(url,data){
  342. // let xhr = new XMLHttpRequest();
  343. // xhr.withCredentials = true
  344. // xhr.onreadystatechange = ()=>{
  345. // if(xhr.readyState == 4){ // 监听请求完成
  346. // if((xhr.status >=200 && xhr.status <300) || xhr.status == 304){
  347. // console.log(xhr.responseText)
  348. // this.dialogVisible = false
  349. // this.dialogVisibleLoading = false
  350. // }else{
  351. // console.log('请求失败')
  352. // this.dialogVisible = false
  353. // this.dialogVisibleLoading = false
  354. // }
  355. // }
  356. // }
  357. // xhr.open("post", url, true); // 异步请求
  358. // xhr.setRequestHeader('Content-Type', 'application/json')
  359. // xhr.send(JSON.stringify(data));
  360. // 创建忽略 SSL 的 axios 实例
  361. const ignoreSSL = axios.create({
  362. httpsAgent: new https.Agent({
  363. rejectUnauthorized: false
  364. }),
  365. withCredentials: true, // 跨域请求时发送Cookie
  366. timeout: 60000, // 请求超时
  367. headers: {
  368. "Content-Type": "application/json; charset=UTF-8;"
  369. }
  370. });
  371. ignoreSSL.post(url,
  372. { ...data }
  373. ).then(()=>{
  374. this.dialogVisible = false
  375. this.dialogVisibleLoading = false
  376. }).catch(()=>{
  377. this.dialogVisible = false
  378. this.dialogVisibleLoading = false
  379. })
  380. // 在 axios 请求时,选择性忽略 SSL
  381. // const agent = new https.Agent({
  382. // rejectUnauthorized: false
  383. // });
  384. // axios.post(
  385. // url,
  386. // { httpsAgent: agent,...data }
  387. // ).then(()=>{
  388. // this.dialogVisible = false
  389. // this.dialogVisibleLoading = false
  390. // })
  391. // .catch(()=>{
  392. // this.dialogVisible = false
  393. // this.dialogVisibleLoading = false
  394. // })
  395. },
  396. /** 读取身份证 */
  397. readCert(){
  398. this.idcardLoading = true
  399. var result = "";
  400. try {
  401. let xmlHttp = new XMLHttpRequest();
  402. let Protocol = window.location.protocol.split(':')[0];
  403. //获取当前协议,并且分割字符串,得到http或者https
  404. if (Protocol === 'https'){
  405. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  406. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  407. }else {
  408. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  409. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  410. }
  411. //发送请求
  412. xmlHttp.send();
  413. if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  414. result = xmlHttp.responseText;
  415. xmlHttp.readyState = 1;
  416. }
  417. } catch (e) {
  418. console.error("e====",e)
  419. }
  420. let obj = JSON.parse(result)
  421. if(obj.resultContent && obj.resultContent.certNumber){
  422. this.$set(this.queryParams,"idcard",obj.resultContent.certNumber)
  423. }else {
  424. this.$message.error('读取失败!!!');
  425. }
  426. this.idcardLoading = false
  427. //return result;
  428. console.log(result,obj)
  429. }
  430. }
  431. };
  432. </script>