index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="订单号">
  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="100px">
  14. <el-input
  15. v-model="queryParams.memberMobile"
  16. placeholder="请输入购票人手机号"
  17. clearable
  18. style="width: 240px;"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="剧目名称">
  23. <el-input
  24. v-model="queryParams.performName"
  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-input
  33. v-model="queryParams.goodsName"
  34. placeholder="请输入票务名称"
  35. clearable
  36. style="width: 240px;"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="订单状态">
  41. <el-select
  42. v-model="queryParams.status"
  43. placeholder="订单状态"
  44. clearable
  45. style="width: 100%"
  46. >
  47. <el-option
  48. v-for="dict in dict.type.order_status_type"
  49. :key="dict.value"
  50. :label="dict.label"
  51. :value="dict.value"
  52. />
  53. </el-select>
  54. </el-form-item>
  55. <el-form-item label="购票渠道">
  56. <el-select
  57. v-model="queryParams.source"
  58. placeholder="购票渠道"
  59. clearable
  60. style="width: 100%"
  61. >
  62. <!-- <el-option
  63. v-for="dict in sourceMapList"
  64. :key="dict.value"
  65. :label="dict.name"
  66. :value="dict.value"
  67. /> -->
  68. <el-option
  69. v-for="dict in dict.type.order_form_type"
  70. :key="dict.value"
  71. :label="dict.label"
  72. :value="dict.value"
  73. />
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item label="支付时间">
  77. <el-date-picker
  78. style="width: 230px;"
  79. v-model="queryParams.time"
  80. type="daterange"
  81. value-format="yyyy-MM-dd"
  82. range-separator="至"
  83. start-placeholder="开始日期"
  84. end-placeholder="结束日期">
  85. </el-date-picker>
  86. </el-form-item>
  87. <el-form-item label="下单时间">
  88. <el-date-picker
  89. style="width: 230px;"
  90. v-model="queryParams.createTime"
  91. type="daterange"
  92. value-format="yyyy-MM-dd"
  93. range-separator="至"
  94. start-placeholder="开始日期"
  95. end-placeholder="结束日期">
  96. </el-date-picker>
  97. </el-form-item>
  98. <el-form-item label="场次时间">
  99. <el-date-picker
  100. style="width: 230px;"
  101. v-model="queryParams.performDate"
  102. @change="pagePerformTimeListFun"
  103. type="date"
  104. value-format="yyyy-MM-dd"
  105. placeholder="选择日期">
  106. </el-date-picker>
  107. </el-form-item>
  108. <el-form-item label="场次">
  109. <el-select
  110. v-model="queryParams.performTimeId"
  111. placeholder="场次"
  112. clearable
  113. style="width: 100%"
  114. >
  115. <el-option
  116. v-for="dict in pagePerformTimeList"
  117. :key="dict.id"
  118. :label="dict.timeSnapshot"
  119. :value="dict.id"
  120. />
  121. </el-select>
  122. </el-form-item>
  123. <el-form-item>
  124. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  125. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  126. </el-form-item>
  127. </el-form>
  128. <el-row :gutter="10" class="mb8">
  129. <el-button
  130. type="primary"
  131. size="mini"
  132. icon="el-icon-download"
  133. v-hasPermi="['order:orderMr:downloadExcel']"
  134. @click="handleExport"
  135. v-loading.fullscreen.lock="handleExportLoading"
  136. element-loading-text="正在拼命生成数据中..."
  137. element-loading-spinner="el-icon-loading"
  138. element-loading-background="rgba(0, 0, 0, 0.5)"
  139. >导出excel</el-button>
  140. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  141. </el-row>
  142. <el-table ref="tables" v-loading="loading" :data="dataList" border>
  143. <el-table-column label="序号" align="center" type="index" width="60"></el-table-column>
  144. <el-table-column label="订单号" align="center" prop="id" />
  145. <el-table-column label="购票人手机号" align="center" prop="memberMobile" />
  146. <el-table-column label="剧目名称" align="center" prop="performName" />
  147. <el-table-column label="票务名称" align="center" prop="goodsName" />
  148. <el-table-column label="票务类型" align="center" prop="seatTypeName" />
  149. <el-table-column label="购票渠道" align="center" prop="source">
  150. <template slot-scope="scope">
  151. <!-- <span>{{ sourceList[scope.row.source] }}</span> -->
  152. <dict-tag :options="dict.type.order_form_type" :value="scope.row.source"/>
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="场次时间" align="center" prop="performDate" />
  156. <el-table-column label="场次" align="center" prop="timeSnapshot" />
  157. <el-table-column label="下单时间" align="center" prop="createTime" />
  158. <el-table-column label="购票数量" align="center" prop="quantity" />
  159. <el-table-column label="支付总额" align="center" prop="orderPrice">
  160. <template slot-scope="scope">
  161. <span>¥{{ scope.row.orderPrice }}</span>
  162. </template>
  163. </el-table-column>
  164. <!-- <el-table-column label="优惠信息" align="center" prop="refundReason" />-->
  165. <el-table-column label="支付方式" align="center" prop="payWay">
  166. <template slot-scope="scope">
  167. <dict-tag :options="dict.type.pay_way_type" :value="scope.row.payWay"/>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="支付时间" align="center" prop="payTime" width="160" >
  171. <template slot-scope="scope">
  172. <span>{{ parseTime(scope.row.payTime) }}</span>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="订单状态" align="center" prop="status">
  176. <template slot-scope="scope">
  177. <dict-tag :options="dict.type.order_status_type" :value="scope.row.status"/>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="已核销票数" align="center" prop="usedTotal">
  181. <template slot-scope="scope">
  182. <span>{{ scope.row.usedTotal }}</span>
  183. </template>
  184. </el-table-column>
  185. <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width">
  186. <template slot-scope="scope">
  187. <el-button
  188. size="mini"
  189. type="text"
  190. @click="openDetails(scope.row)"
  191. v-hasPermi="['orderMr:orderMr:details']"
  192. >详情</el-button>
  193. <el-button
  194. size="mini"
  195. type="text"
  196. @click="handleOpen([scope.row])"
  197. v-hasPermi="['orderMr:orderMr:print']"
  198. >打印小票</el-button>
  199. </template>
  200. </el-table-column>
  201. </el-table>
  202. <pagination
  203. v-show="total>0"
  204. :total="total"
  205. :page.sync="queryParams.pageNum"
  206. :limit.sync="queryParams.pageSize"
  207. @pagination="getList"
  208. />
  209. <!-- 详情 -->
  210. <details-dia ref="detailsDia" @getList="getList"></details-dia>
  211. <el-dialog
  212. title="选择小票机"
  213. :visible.sync="dialogVisible"
  214. width="30%"
  215. :before-close="handleClose">
  216. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  217. <el-form-item label="小票机" prop="region">
  218. <el-select v-model="ruleForm.region" placeholder="选择小票机">
  219. <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
  220. </el-select>
  221. </el-form-item>
  222. </el-form>
  223. <span slot="footer" class="dialog-footer">
  224. <el-button @click="dialogVisible = false">取 消</el-button>
  225. <el-button type="primary" :loading="dialogVisibleLoading" @click="print(viewerList)">{{ dialogVisibleLoading?'打印中...':'打印' }}</el-button>
  226. </span>
  227. </el-dialog>
  228. </div>
  229. </template>
  230. <script>
  231. import { pageList,downOrderListXls, printApi } from '@/api/order/orderMr'
  232. import detailsDia from "./dialog/details";
  233. import { pagePerformTimeList } from "@/api/schedulingMr/schedulingMr"
  234. import { exportExcel } from '@/utils/exportexcel'
  235. import { pageList as getPrintListApi } from "@/api/device/pda";
  236. const https = require('https');
  237. const axios = require('axios');
  238. export default {
  239. name: "agreement",
  240. dicts: ['order_form_type','order_status_type','pay_way_type'],
  241. components: { detailsDia },
  242. data() {
  243. return {
  244. // 遮罩层
  245. loading: true,
  246. // 选中数组
  247. ids: [],
  248. // 非单个禁用
  249. single: true,
  250. // 非多个禁用
  251. multiple: true,
  252. // 显示搜索条件
  253. showSearch: true,
  254. // 总条数
  255. total: 0,
  256. // 用户表格数据
  257. dataList: null,
  258. // 弹出层标题
  259. title: "",
  260. // 是否显示弹出层
  261. open: false,
  262. // 日期范围
  263. dateRange: [],
  264. // 查询参数
  265. queryParams: {
  266. pageNum: 1,
  267. pageSize: 10,
  268. },
  269. visibleStatus: false,
  270. newObj: {},
  271. visibleType: '',
  272. pagePerformTimeList: [], // 场次列表
  273. handleExportLoading: false,
  274. viewerList: [],
  275. printList: [],
  276. dialogVisible: false,
  277. ruleForm: {},
  278. rules: {
  279. region: [
  280. { required: true, message: '请选择打印机', trigger: ['change','blur' ]}
  281. ],
  282. },
  283. dialogVisibleLoading: false,
  284. };
  285. },
  286. created() {
  287. this.getList();
  288. },
  289. methods: {
  290. /** 查询列表 */
  291. getList() {
  292. this.loading = true;
  293. pageList(this.addDateRange(this.queryParams, this.dateRange))
  294. .then(response => {
  295. this.dataList = response.data.rows;
  296. this.total = response.data.total;
  297. this.loading = false;
  298. });
  299. },
  300. // 取消按钮
  301. cancel() {
  302. this.open = false;
  303. },
  304. /** 搜索按钮操作 */
  305. handleQuery() {
  306. this.queryParams.pageNum = 1;
  307. if(this.queryParams.time){
  308. this.queryParams.payBeginTime = this.queryParams.time[0];
  309. this.queryParams.payEndTime = this.queryParams.time[1];
  310. }
  311. if(this.queryParams.createTime&&this.queryParams.createTime.length>0){
  312. this.queryParams.createBeginTime = this.queryParams.createTime[0];
  313. this.queryParams.createEndTime = this.queryParams.createTime[1];
  314. }
  315. this.getList();
  316. },
  317. /** 重置按钮操作 */
  318. resetQuery() {
  319. this.dateRange = [];
  320. this.$set(this.queryParams, 'orderId', '');
  321. this.$set(this.queryParams, 'status', '');
  322. this.$set(this.queryParams, 'memberMobile', '');
  323. this.$set(this.queryParams, 'source', '');
  324. this.$set(this.queryParams, 'performName', '');
  325. this.$set(this.queryParams, 'payBeginTime', '');
  326. this.$set(this.queryParams, 'payEndTime', '');
  327. this.$set(this.queryParams, 'time', '');
  328. this.$set(this.queryParams, 'createTime', '');
  329. this.$set(this.queryParams, 'createBeginTime', '');
  330. this.$set(this.queryParams, 'createEndTime', '');
  331. this.$set(this.queryParams, 'goodsName', '');
  332. this.$set(this.queryParams, 'performDate', '');
  333. this.$set(this.queryParams, 'timeSnapshot', '');
  334. this.$set(this.queryParams, 'performTimeId', '');
  335. this.queryParams.pageNum = 1;
  336. this.handleQuery();
  337. },
  338. /** 详情按钮操作 */
  339. openDetails(row, type) {
  340. this.$refs["detailsDia"].openDialog("详情", row, type);
  341. },
  342. async pagePerformTimeListFun(value) {
  343. try {
  344. this.pagePerformTimeList = []
  345. this.$set(this.queryParams,'timeSnapshot',null)
  346. if(!value){
  347. return
  348. }
  349. let { data,code } = await pagePerformTimeList({
  350. performDate: value,
  351. pageNum: 1,
  352. pageSize: 999
  353. })
  354. this.pagePerformTimeList = [].concat(data.rows)
  355. } catch (error) {
  356. }
  357. },
  358. /**
  359. * 导出报表
  360. * @date 2022-10-24
  361. * @returns {any}
  362. */
  363. handleExport() {
  364. this.$confirm('您确定要导出当前查询的数据吗?', '提示', {
  365. confirmButtonText: '确定 ',
  366. cancelButtonText: '取消 ',
  367. type: 'warning'
  368. })
  369. .then(() => {
  370. this.handleExportLoading = true;
  371. // const { pageNum, pageSize} = this.params;
  372. let postMap = {}
  373. for (let key in this.queryParams) {
  374. if(key != 'pageNum' && key != 'pageSize'){
  375. postMap[key] = this.queryParams[key]
  376. }
  377. }
  378. downOrderListXls(postMap)
  379. .then((res) => {
  380. exportExcel(res, '订单管理', '.xlsx');
  381. this.handleExportLoading = false;
  382. })
  383. .catch((error) => {
  384. console.log("error===",error)
  385. this.handleExportLoading = false;
  386. });
  387. })
  388. .catch(() => {
  389. this.$message.info('您已取消导出!');
  390. });
  391. },
  392. handleOpen(list=[]){
  393. if(!list||list.length==0) return
  394. let idList = []
  395. list.forEach((item,index)=>{
  396. idList.push(item.id)
  397. })
  398. this.viewerList = idList
  399. this.getPrintListApi()
  400. this.$set(this.ruleForm, 'region', '');
  401. this.$nextTick(()=>{
  402. this.$refs.ruleForm.clearValidate('region')
  403. })
  404. this.dialogVisible = true
  405. },
  406. handleClose(){
  407. this.dialogVisible = false
  408. },
  409. /** 查询打印机列表 */
  410. getPrintListApi() {
  411. getPrintListApi({deviceType:5,pageNum: 1,
  412. pageSize: 999,})
  413. .then(response => {
  414. this.printList = response.data.rows;
  415. }
  416. );
  417. },
  418. /** 选择打印机 */
  419. selectPrint(){
  420. },
  421. // 打印
  422. async print(list = []){
  423. this.$refs.ruleForm.validate(async (valid) => {
  424. if (valid) {
  425. this.dialogVisibleLoading = true
  426. try {
  427. let res = await printApi({
  428. //viewerList:list,
  429. orderId: list[0],
  430. source: 2,
  431. deviceId: this.ruleForm.region
  432. })
  433. if(res.code == 200) {
  434. let url = res.data.linkIp
  435. let printInfo = res.data.printInfo
  436. this.connectPrint(url,printInfo)
  437. }else {
  438. throw new Error(res)
  439. }
  440. } catch (error) {
  441. this.dialogVisible = false
  442. this.dialogVisibleLoading = false
  443. console.error("error=====",error)
  444. }
  445. } else {
  446. console.log('error submit!!');
  447. return false;
  448. }
  449. });
  450. },
  451. /** 连接打印机 */
  452. connectPrint(url,data){
  453. // let xhr = new XMLHttpRequest();
  454. // xhr.onreadystatechange = ()=>{
  455. // if(xhr.readyState == 4){ // 监听请求完成
  456. // if((xhr.status >=200 && xhr.status <300) || xhr.status == 304){
  457. // console.log(xhr.responseText)
  458. // this.dialogVisible = false
  459. // this.dialogVisibleLoading = false
  460. // }else{
  461. // console.log('请求失败')
  462. // this.dialogVisible = false
  463. // this.dialogVisibleLoading = false
  464. // }
  465. // }
  466. // }
  467. // xhr.open("post", url, true); // 异步请求
  468. // xhr.send(JSON.stringify(data));
  469. // 创建忽略 SSL 的 axios 实例
  470. const ignoreSSL = axios.create({
  471. httpsAgent: new https.Agent({
  472. rejectUnauthorized: false
  473. }),
  474. withCredentials: true, // 跨域请求时发送Cookie
  475. timeout: 60000, // 请求超时
  476. headers: {
  477. "Content-Type": "application/json; charset=UTF-8;"
  478. }
  479. });
  480. ignoreSSL.post(url,
  481. { ...data }
  482. ).then(()=>{
  483. this.dialogVisible = false
  484. this.dialogVisibleLoading = false
  485. }).catch(()=>{
  486. this.dialogVisible = false
  487. this.dialogVisibleLoading = false
  488. })
  489. }
  490. }
  491. };
  492. </script>