index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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.teamName"
  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-select
  24. v-model="queryParams.teamType"
  25. placeholder="团队类型"
  26. clearable
  27. style="width: 240px"
  28. >
  29. <el-option
  30. v-for="dict in dict.type.team_type"
  31. :key="dict.value"
  32. :label="dict.label"
  33. :value="dict.value"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="订单状态">
  38. <el-select
  39. v-model="queryParams.status"
  40. placeholder="订单状态"
  41. clearable
  42. style="width: 100%"
  43. >
  44. <el-option
  45. v-for="dict in statusMapList"
  46. :key="dict.value"
  47. :label="dict.name"
  48. :value="dict.value"
  49. />
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item label="支付时间">
  53. <el-date-picker
  54. v-model="queryParams.time"
  55. type="daterange"
  56. value-format="yyyy-MM-dd"
  57. range-separator="至"
  58. start-placeholder="开始日期"
  59. end-placeholder="结束日期">
  60. </el-date-picker>
  61. </el-form-item>
  62. <el-form-item>
  63. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  64. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  65. </el-form-item>
  66. </el-form>
  67. <el-row :gutter="10" class="mb8">
  68. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  69. </el-row>
  70. <el-table ref="tables" v-loading="loading" :data="dataList" border>
  71. <el-table-column label="序号" align="center" type="index" width="60"></el-table-column>
  72. <el-table-column label="订单号" align="center" prop="id" />
  73. <el-table-column label="团队名称" align="center" prop="teamName" />
  74. <el-table-column label="团队类型" align="center" prop="type">
  75. <template slot-scope="scope">
  76. <dict-tag :options="dict.type.team_type" :value="scope.row.teamType"/>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="联系电话" align="center" prop="teamMobile" />
  80. <el-table-column label="负责人" align="center" prop="teamContact" />
  81. <el-table-column label="剧目名称" align="center" prop="performName" />
  82. <el-table-column label="票务名称" align="center" prop="goodsName" />
  83. <el-table-column label="座位类型" align="center" prop="seatTypeName" />
  84. <el-table-column label="团购数量" align="center" prop="quantity" />
  85. <el-table-column label="支付总额" align="center" prop="orderPrice">
  86. <template slot-scope="scope">
  87. <span>¥{{ scope.row.orderPrice }}</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="支付方式" align="center" prop="type">
  91. <template slot-scope="scope">
  92. <span>{{ payWayList[scope.row.payWay] }}</span>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="支付时间" align="center" prop="payTime" width="160" >
  96. <template slot-scope="scope">
  97. <span>{{ parseTime(scope.row.payTime) }}</span>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="订单状态" align="center" prop="type">
  101. <template slot-scope="scope">
  102. <span>{{statusList[scope.row.status]}}</span>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width">
  106. <template slot-scope="scope">
  107. <el-button
  108. size="mini"
  109. type="text"
  110. @click="openDetails(scope.row)"
  111. v-hasPermi="['groupBuyingMr:groupBuyingMr:details']"
  112. >详情</el-button>
  113. <el-button
  114. size="mini"
  115. type="text"
  116. @click="handleOpen([scope.row])"
  117. v-hasPermi="['orderMr:orderMr:print']"
  118. >打印小票</el-button>
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. <pagination
  123. v-show="total>0"
  124. :total="total"
  125. :page.sync="queryParams.pageNum"
  126. :limit.sync="queryParams.pageSize"
  127. @pagination="getList"
  128. />
  129. <!-- 详情 -->
  130. <details-dia ref="detailsDia" :dict="dict" @getList="getList"></details-dia>
  131. <el-dialog
  132. title="选择小票机"
  133. :visible.sync="dialogVisible"
  134. width="30%"
  135. :before-close="handleClose">
  136. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  137. <el-form-item label="小票机" prop="region">
  138. <el-select v-model="ruleForm.region" placeholder="选择小票机">
  139. <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
  140. </el-select>
  141. </el-form-item>
  142. </el-form>
  143. <span slot="footer" class="dialog-footer">
  144. <el-button @click="dialogVisible = false">取 消</el-button>
  145. <el-button type="primary" :loading="dialogVisibleLoading" @click="print(viewerList)">{{ dialogVisibleLoading?'打印中...':'打印' }}</el-button>
  146. </span>
  147. </el-dialog>
  148. </div>
  149. </template>
  150. <script>
  151. import { pageList } from '@/api/order/groupBuyingMr'
  152. import detailsDia from "./dialog/details.vue";
  153. import { printApi } from '@/api/order/orderMr'
  154. import { pageList as getPrintListApi } from "@/api/device/pda";
  155. const https = require('https');
  156. const axios = require('axios');
  157. export default {
  158. name: "agreement",
  159. dicts: ['agreement_type', 'team_type'],
  160. components: { detailsDia },
  161. data() {
  162. return {
  163. // 遮罩层
  164. loading: true,
  165. // 选中数组
  166. ids: [],
  167. // 非单个禁用
  168. single: true,
  169. // 非多个禁用
  170. multiple: true,
  171. // 显示搜索条件
  172. showSearch: true,
  173. // 总条数
  174. total: 0,
  175. // 用户表格数据
  176. dataList: null,
  177. // 弹出层标题
  178. title: "",
  179. // 是否显示弹出层
  180. open: false,
  181. // 日期范围
  182. dateRange: [],
  183. // 查询参数
  184. queryParams: {
  185. pageNum: 1,
  186. pageSize: 10,
  187. },
  188. statusList: {
  189. 0: '待支付',
  190. 2: '超时取消',
  191. 3: '待使用',
  192. 4: '退款中',
  193. 5: '己退款',
  194. 6: '退款失败',
  195. 7: '己使用',
  196. 8: '己超期',
  197. 9: '关闭',
  198. },
  199. statusMapList: [
  200. {id: 1, name: '待支付', value: 0},
  201. {id: 2, name: '超时取消', value: 2},
  202. {id: 3, name: '待使用', value: 3},
  203. {id: 4, name: '退款中', value: 4},
  204. {id: 5, name: '己退款', value: 5},
  205. {id: 6, name: '退款失败', value: 6},
  206. {id: 7, name: '己使用', value: 7},
  207. {id: 8, name: '己超期', value: 8},
  208. {id: 9, name: '关闭', value: 9},
  209. ],
  210. payList: {
  211. 0: '未支付',
  212. 1: '已支付',
  213. 2: '支付中',
  214. 3: '支付失败',
  215. 4: '支付退款',
  216. },
  217. payWayList: {
  218. 'cahsh': '现金',
  219. 'wecaht.applet': '微信小程序支付',
  220. 'alipay': '支付宝OTA',
  221. 'wecaht.h5': '微信公众号支付',
  222. 'meituan': '美团支付',
  223. },
  224. sourceList: {
  225. 1: '小程序',
  226. 2: '公众号',
  227. 3: '美团',
  228. 4: '携程',
  229. 5: '团购',
  230. },
  231. sourceMapList: [
  232. {id: 1, name: '小程序', value: 1},
  233. {id: 2, name: '公众号', value: 2},
  234. {id: 3, name: '美团', value: 3},
  235. {id: 4, name: '携程', value: 4},
  236. {id: 5, name: '团购', value: 5},
  237. ],
  238. visibleStatus: false,
  239. newObj: {},
  240. visibleType: '',
  241. viewerList: [],
  242. printList: [],
  243. dialogVisible: false,
  244. ruleForm: {},
  245. rules: {
  246. region: [
  247. { required: true, message: '请选择打印机', trigger: ['change','blur' ]}
  248. ],
  249. },
  250. dialogVisibleLoading: false,
  251. };
  252. },
  253. created() {
  254. this.getList();
  255. },
  256. methods: {
  257. /** 查询列表 */
  258. getList() {
  259. this.loading = true;
  260. pageList(this.queryParams)
  261. .then(response => {
  262. this.dataList = response.data.rows;
  263. this.total = response.data.total;
  264. this.loading = false;
  265. });
  266. },
  267. // 取消按钮
  268. cancel() {
  269. this.open = false;
  270. },
  271. /** 搜索按钮操作 */
  272. handleQuery() {
  273. this.queryParams.pageNum = 1;
  274. if(this.queryParams.time){
  275. this.queryParams.payBeginTime = this.queryParams.time[0];
  276. this.queryParams.payEndTime = this.queryParams.time[1];
  277. }
  278. this.getList();
  279. },
  280. /** 重置按钮操作 */
  281. resetQuery() {
  282. this.dateRange = [];
  283. this.$set(this.queryParams, 'orderId', '');
  284. this.$set(this.queryParams, 'status', '');
  285. this.$set(this.queryParams, 'teamType', '');
  286. this.$set(this.queryParams, 'teamName', '');
  287. this.$set(this.queryParams, 'performName', '');
  288. this.$set(this.queryParams, 'payBeginTime', '');
  289. this.$set(this.queryParams, 'payEndTime', '');
  290. this.$set(this.queryParams, 'time', '');
  291. this.queryParams.pageNum = 1;
  292. this.handleQuery();
  293. },
  294. /** 详情按钮操作 */
  295. openDetails(row, type) {
  296. this.$refs["detailsDia"].openDialog("详情", row, type);
  297. },
  298. handleOpen(list=[]){
  299. if(!list||list.length==0) return
  300. let idList = []
  301. list.forEach((item,index)=>{
  302. idList.push(item.id)
  303. })
  304. this.viewerList = idList
  305. this.getPrintListApi()
  306. this.$set(this.ruleForm, 'region', '');
  307. this.$nextTick(()=>{
  308. this.$refs.ruleForm.clearValidate('region')
  309. })
  310. this.dialogVisible = true
  311. },
  312. handleClose(){
  313. this.dialogVisible = false
  314. },
  315. /** 查询打印机列表 */
  316. getPrintListApi() {
  317. getPrintListApi({deviceType:5,pageNum: 1,
  318. pageSize: 999,})
  319. .then(response => {
  320. this.printList = response.data.rows;
  321. }
  322. );
  323. },
  324. /** 选择打印机 */
  325. selectPrint(){
  326. },
  327. // 打印
  328. async print(list = []){
  329. this.$refs.ruleForm.validate(async (valid) => {
  330. if (valid) {
  331. this.dialogVisibleLoading = true
  332. try {
  333. let res = await printApi({
  334. //viewerList:list,
  335. orderId: list[0],
  336. source: 2,
  337. deviceId: this.ruleForm.region
  338. })
  339. if(res.code == 200) {
  340. let url = res.data.linkIp
  341. let printInfo = res.data.printInfo
  342. this.connectPrint(url,printInfo)
  343. }else {
  344. throw new Error(res)
  345. }
  346. } catch (error) {
  347. this.dialogVisible = false
  348. this.dialogVisibleLoading = false
  349. console.error("error=====",error)
  350. }
  351. } else {
  352. console.log('error submit!!');
  353. return false;
  354. }
  355. });
  356. },
  357. /** 连接打印机 */
  358. connectPrint(url,data){
  359. // let xhr = new XMLHttpRequest();
  360. // xhr.onreadystatechange = ()=>{
  361. // if(xhr.readyState == 4){ // 监听请求完成
  362. // if((xhr.status >=200 && xhr.status <300) || xhr.status == 304){
  363. // console.log(xhr.responseText)
  364. // this.dialogVisible = false
  365. // this.dialogVisibleLoading = false
  366. // }else{
  367. // console.log('请求失败')
  368. // this.dialogVisible = false
  369. // this.dialogVisibleLoading = false
  370. // }
  371. // }
  372. // }
  373. // xhr.open("post", url, true); // 异步请求
  374. // xhr.send(JSON.stringify(data));
  375. const ignoreSSL = axios.create({
  376. httpsAgent: new https.Agent({
  377. rejectUnauthorized: false
  378. }),
  379. withCredentials: true, // 跨域请求时发送Cookie
  380. timeout: 60000, // 请求超时
  381. headers: {
  382. "Content-Type": "application/json; charset=UTF-8;"
  383. }
  384. });
  385. ignoreSSL.post(url,
  386. { ...data }
  387. ).then(()=>{
  388. this.dialogVisible = false
  389. this.dialogVisibleLoading = false
  390. }).catch(()=>{
  391. this.dialogVisible = false
  392. this.dialogVisibleLoading = false
  393. })
  394. }
  395. }
  396. };
  397. </script>