ticketingCollection.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
  4. <el-form-item label="取票码" label-width="100px">
  5. <el-input
  6. v-model="queryParams.qrcodeNo"
  7. placeholder="请输入取票码"
  8. clearable
  9. style="width: 240px;"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="手机号:" prop="mobile">
  14. <el-input
  15. v-model="queryParams.mobile"
  16. placeholder="请输入手机号"
  17. clearable
  18. style="width: 240px;"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="身份证号:" label-width="120px" prop="idcard">
  23. <el-input
  24. v-model="queryParams.idcard"
  25. placeholder="请输入身份证号"
  26. clearable
  27. style="width: 240px;"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="订单状态">
  32. <el-select
  33. v-model="queryParams.orderStatus"
  34. placeholder="订单状态"
  35. clearable
  36. style="width: 100%"
  37. >
  38. <el-option
  39. v-for="dict in dict.type.order_status_type"
  40. :key="dict.value"
  41. :label="dict.label"
  42. :value="dict.value"
  43. />
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item>
  47. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  48. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  49. </el-form-item>
  50. </el-form>
  51. <el-row :gutter="10" class="mb8">
  52. <el-col :span="1.5">
  53. <el-button
  54. :disabled="multipleSelection.length == 0"
  55. type="primary"
  56. plain
  57. icon="el-icon-plus"
  58. size="mini"
  59. @click="handleOpen(multipleSelection)"
  60. v-hasPermi="['windowTicketSales:ticketingCollection:print']"
  61. >批量打印名票</el-button>
  62. </el-col>
  63. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  64. </el-row>
  65. <el-table
  66. ref="tables"
  67. v-loading="loading"
  68. :data="dataList"
  69. @selection-change="handleSelectionChange"
  70. border>
  71. <el-table-column type="selection" width="55"></el-table-column>
  72. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  73. <el-table-column label="姓名" align="center" prop="name" />
  74. <el-table-column label="身份证号" align="center" prop="qrcodeNo" />
  75. <el-table-column label="取票码" align="center" prop="qrcodeNo" />
  76. <el-table-column label="订单号" align="center" prop="orderId" />
  77. <el-table-column label="剧目名称" align="center" prop="performName" />
  78. <el-table-column label="票务名称" align="center" prop="goodsName" />
  79. <el-table-column label="座位信息" align="center" prop="seatName" />
  80. <el-table-column label="座位类型" align="center" prop="seatTypeName" />
  81. <el-table-column label="节目播出日期" align="center" prop="performDate" />
  82. <el-table-column label="下单时间" align="center" prop="createTime" />
  83. <el-table-column label="购票渠道" align="center" prop="source">
  84. <template slot-scope="scope">
  85. <dict-tag :options="dict.type.order_form_type" :value="scope.row.source"/>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="订单状态" align="center" prop="status">
  89. <template slot-scope="scope">
  90. <dict-tag :options="dict.type.order_status_type" :value="scope.row.status"/>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="操作" align="center" fixed="right" width="80" class-name="small-padding fixed-width">
  94. <template slot-scope="scope">
  95. <el-button
  96. size="mini"
  97. type="text"
  98. @click="handleOpen([scope.row])"
  99. v-hasPermi="['windowTicketSales:ticketingCollection:print']"
  100. >打印门票</el-button>
  101. </template>
  102. </el-table-column>
  103. <template slot="empty">
  104. <div>
  105. <span>未查询到相关订单,请重新输入!</span>
  106. </div>
  107. </template>
  108. </el-table>
  109. <el-dialog
  110. title="选择打印机"
  111. :visible.sync="dialogVisible"
  112. width="30%"
  113. :before-close="handleClose">
  114. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  115. <el-form-item label="打印机" prop="region">
  116. <el-select v-model="ruleForm.region" placeholder="选择打印机">
  117. <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
  118. </el-select>
  119. </el-form-item>
  120. </el-form>
  121. <span slot="footer" class="dialog-footer">
  122. <el-button @click="dialogVisible = false">取 消</el-button>
  123. <el-button type="primary" :loading="dialogVisibleLoading" @click="print(viewerList)">{{ dialogVisibleLoading?'打印中...':'打印' }}</el-button>
  124. </span>
  125. </el-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import { pageList,printApi } from '@/api/windowTicketSales/ticketingCollection'
  130. import { pageList as getPrintListApi } from "@/api/device/pda";
  131. const https = require('https');
  132. const axios = require('axios');
  133. export default {
  134. name: "distributionapplication",
  135. dicts: ['order_form_type','order_status_type'],
  136. data() {
  137. return {
  138. // 遮罩层
  139. loading: false,
  140. // 选中数组
  141. multipleSelection: [],
  142. // 显示搜索条件
  143. showSearch: true,
  144. // 总条数
  145. total: 0,
  146. // 用户表格数据
  147. dataList: null,
  148. // 查询参数
  149. queryParams: {
  150. // pageNum: 1,
  151. // pageSize: 10,
  152. // type: undefined
  153. orderStatus: "3"
  154. },
  155. visibleStatus: false,
  156. visibleStatusLoading: false,
  157. ruleForm: {},
  158. rules: {
  159. remark: [
  160. { required: true, message: '请输入备注', trigger: ['blur','change'] },
  161. { min: 0, max: 50, message: '长度在 0 到 50 个字符', trigger: ['blur','change'] }
  162. ]
  163. },
  164. viewerList: [],
  165. printList: [],
  166. dialogVisible: false,
  167. ruleForm: {},
  168. rules: {
  169. region: [
  170. { required: true, message: '请选择打印机', trigger: ['change','blur' ]}
  171. ],
  172. },
  173. dialogVisibleLoading: false,
  174. };
  175. },
  176. created() {
  177. //this.getList();
  178. //this.getPrintListApi()
  179. },
  180. methods: {
  181. /** 查询列表 */
  182. getList() {
  183. this.loading = true;
  184. pageList(this.queryParams,)
  185. .then(response => {
  186. this.dataList = response.data.list;
  187. //this.total = response.data.total;
  188. this.loading = false;
  189. }
  190. );
  191. },
  192. // 取消按钮
  193. cancel() {
  194. this.open = false;
  195. },
  196. /** 搜索按钮操作 */
  197. handleQuery() {
  198. this.getList();
  199. },
  200. /** 重置按钮操作 */
  201. resetQuery() {
  202. this.dateRange = [];
  203. this.$set(this.queryParams, 'qrcodeNo', '');
  204. this.$set(this.queryParams, 'idcard', '');
  205. this.$set(this.queryParams, 'mobile', '');
  206. this.$set(this.queryParams, 'orderStatus', '');
  207. this.handleQuery();
  208. },
  209. setRemark(data) {
  210. this.visibleStatus = true
  211. this.resetForm.id = data.id
  212. },
  213. submitForm(formName) {
  214. this.$refs[formName].validate(async (valid) => {
  215. if (valid) {
  216. try {
  217. this.visibleStatusLoading = true
  218. let res = await setRemark({
  219. id: this.resetForm.id,
  220. "remark": this.ruleForm.remark
  221. })
  222. this.visibleStatus = false
  223. this.visibleStatusLoading = false
  224. this.resetForm('ruleForm')
  225. this.queryParams.pageNum = 1;
  226. this.getList()
  227. } catch (error) {
  228. this.visibleStatusLoading = false
  229. }
  230. } else {
  231. this.visibleStatusLoading = false
  232. return false;
  233. }
  234. });
  235. },
  236. resetForm(formName) {
  237. this.$refs[formName].resetFields();
  238. },
  239. handleSelectionChange(val) {
  240. console.log("val====",val)
  241. this.multipleSelection = val;
  242. },
  243. handleOpen(list=[]){
  244. if(!list||list.length==0) return
  245. let idList = []
  246. list.forEach((item,index)=>{
  247. idList.push(item.id)
  248. })
  249. this.viewerList = idList
  250. this.getPrintListApi()
  251. this.$set(this.ruleForm, 'region', '');
  252. this.$nextTick(()=>{
  253. this.$refs.ruleForm.clearValidate('region')
  254. })
  255. this.dialogVisible = true
  256. },
  257. handleClose(){
  258. this.dialogVisible = false
  259. },
  260. /** 查询打印机列表 */
  261. getPrintListApi() {
  262. getPrintListApi({deviceType:5,pageNum: 1,
  263. pageSize: 999,})
  264. .then(response => {
  265. this.printList = response.data.rows;
  266. }).catch((error)=>{
  267. console.log("error===",error)
  268. }
  269. );
  270. },
  271. /** 选择打印机 */
  272. selectPrint(){
  273. },
  274. // 打印
  275. async print(list = []){
  276. this.$refs.ruleForm.validate(async (valid) => {
  277. if (valid) {
  278. this.dialogVisibleLoading = true
  279. try {
  280. let res = await printApi({
  281. viewerList:list,
  282. source: 2,
  283. deviceId: this.ruleForm.region
  284. })
  285. if(res.code == 200) {
  286. let url = res.data.linkIp
  287. let printInfo = res.data.printInfo
  288. this.connectPrint(url,printInfo)
  289. }else {
  290. throw new Error(res)
  291. }
  292. } catch (error) {
  293. this.dialogVisible = false
  294. this.dialogVisibleLoading = false
  295. console.error("error=====",error)
  296. }
  297. } else {
  298. console.log('error submit!!');
  299. return false;
  300. }
  301. });
  302. },
  303. /** 连接打印机 */
  304. connectPrint(url,data){
  305. // let xhr = new XMLHttpRequest();
  306. // xhr.withCredentials = true
  307. // xhr.onreadystatechange = ()=>{
  308. // if(xhr.readyState == 4){ // 监听请求完成
  309. // if((xhr.status >=200 && xhr.status <300) || xhr.status == 304){
  310. // console.log(xhr.responseText)
  311. // this.dialogVisible = false
  312. // this.dialogVisibleLoading = false
  313. // }else{
  314. // console.log('请求失败')
  315. // this.dialogVisible = false
  316. // this.dialogVisibleLoading = false
  317. // }
  318. // }
  319. // }
  320. // xhr.open("post", url, true); // 异步请求
  321. // xhr.setRequestHeader('Content-Type', 'application/json')
  322. // xhr.send(JSON.stringify(data));
  323. // 创建忽略 SSL 的 axios 实例
  324. const ignoreSSL = axios.create({
  325. httpsAgent: new https.Agent({
  326. rejectUnauthorized: false
  327. }),
  328. withCredentials: true, // 跨域请求时发送Cookie
  329. timeout: 60000, // 请求超时
  330. headers: {
  331. "Content-Type": "application/json; charset=UTF-8;"
  332. }
  333. });
  334. ignoreSSL.post(url,
  335. { ...data }
  336. ).then(()=>{
  337. this.dialogVisible = false
  338. this.dialogVisibleLoading = false
  339. }).catch(()=>{
  340. this.dialogVisible = false
  341. this.dialogVisibleLoading = false
  342. })
  343. // 在 axios 请求时,选择性忽略 SSL
  344. // const agent = new https.Agent({
  345. // rejectUnauthorized: false
  346. // });
  347. // axios.post(
  348. // url,
  349. // { httpsAgent: agent,...data }
  350. // ).then(()=>{
  351. // this.dialogVisible = false
  352. // this.dialogVisibleLoading = false
  353. // })
  354. // .catch(()=>{
  355. // this.dialogVisible = false
  356. // this.dialogVisibleLoading = false
  357. // })
  358. }
  359. }
  360. };
  361. </script>