index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. export default {
  156. name: "agreement",
  157. dicts: ['agreement_type', 'team_type'],
  158. components: { detailsDia },
  159. data() {
  160. return {
  161. // 遮罩层
  162. loading: true,
  163. // 选中数组
  164. ids: [],
  165. // 非单个禁用
  166. single: true,
  167. // 非多个禁用
  168. multiple: true,
  169. // 显示搜索条件
  170. showSearch: true,
  171. // 总条数
  172. total: 0,
  173. // 用户表格数据
  174. dataList: null,
  175. // 弹出层标题
  176. title: "",
  177. // 是否显示弹出层
  178. open: false,
  179. // 日期范围
  180. dateRange: [],
  181. // 查询参数
  182. queryParams: {
  183. pageNum: 1,
  184. pageSize: 10,
  185. },
  186. statusList: {
  187. 0: '待支付',
  188. 2: '超时取消',
  189. 3: '待使用',
  190. 4: '退款中',
  191. 5: '己退款',
  192. 6: '退款失败',
  193. 7: '己使用',
  194. 8: '己超期',
  195. 9: '关闭',
  196. },
  197. statusMapList: [
  198. {id: 1, name: '待支付', value: 0},
  199. {id: 2, name: '超时取消', value: 2},
  200. {id: 3, name: '待使用', value: 3},
  201. {id: 4, name: '退款中', value: 4},
  202. {id: 5, name: '己退款', value: 5},
  203. {id: 6, name: '退款失败', value: 6},
  204. {id: 7, name: '己使用', value: 7},
  205. {id: 8, name: '己超期', value: 8},
  206. {id: 9, name: '关闭', value: 9},
  207. ],
  208. payList: {
  209. 0: '未支付',
  210. 1: '已支付',
  211. 2: '支付中',
  212. 3: '支付失败',
  213. 4: '支付退款',
  214. },
  215. payWayList: {
  216. 'cahsh': '现金',
  217. 'wecaht.applet': '微信小程序支付',
  218. 'alipay': '支付宝OTA',
  219. 'wecaht.h5': '微信公众号支付',
  220. 'meituan': '美团支付',
  221. },
  222. sourceList: {
  223. 1: '小程序',
  224. 2: '公众号',
  225. 3: '美团',
  226. 4: '携程',
  227. 5: '团购',
  228. },
  229. sourceMapList: [
  230. {id: 1, name: '小程序', value: 1},
  231. {id: 2, name: '公众号', value: 2},
  232. {id: 3, name: '美团', value: 3},
  233. {id: 4, name: '携程', value: 4},
  234. {id: 5, name: '团购', value: 5},
  235. ],
  236. visibleStatus: false,
  237. newObj: {},
  238. visibleType: '',
  239. viewerList: [],
  240. printList: [],
  241. dialogVisible: false,
  242. ruleForm: {},
  243. rules: {
  244. region: [
  245. { required: true, message: '请选择打印机', trigger: ['change','blur' ]}
  246. ],
  247. },
  248. dialogVisibleLoading: false,
  249. };
  250. },
  251. created() {
  252. this.getList();
  253. },
  254. methods: {
  255. /** 查询列表 */
  256. getList() {
  257. this.loading = true;
  258. pageList(this.queryParams)
  259. .then(response => {
  260. this.dataList = response.data.rows;
  261. this.total = response.data.total;
  262. this.loading = false;
  263. });
  264. },
  265. // 取消按钮
  266. cancel() {
  267. this.open = false;
  268. },
  269. /** 搜索按钮操作 */
  270. handleQuery() {
  271. this.queryParams.pageNum = 1;
  272. if(this.queryParams.time){
  273. this.queryParams.payBeginTime = this.queryParams.time[0];
  274. this.queryParams.payEndTime = this.queryParams.time[1];
  275. }
  276. this.getList();
  277. },
  278. /** 重置按钮操作 */
  279. resetQuery() {
  280. this.dateRange = [];
  281. this.$set(this.queryParams, 'orderId', '');
  282. this.$set(this.queryParams, 'status', '');
  283. this.$set(this.queryParams, 'teamType', '');
  284. this.$set(this.queryParams, 'teamName', '');
  285. this.$set(this.queryParams, 'performName', '');
  286. this.$set(this.queryParams, 'payBeginTime', '');
  287. this.$set(this.queryParams, 'payEndTime', '');
  288. this.$set(this.queryParams, 'time', '');
  289. this.queryParams.pageNum = 1;
  290. this.handleQuery();
  291. },
  292. /** 详情按钮操作 */
  293. openDetails(row, type) {
  294. this.$refs["detailsDia"].openDialog("详情", row, type);
  295. },
  296. handleOpen(list=[]){
  297. if(!list||list.length==0) return
  298. let idList = []
  299. list.forEach((item,index)=>{
  300. idList.push(item.id)
  301. })
  302. this.viewerList = idList
  303. this.getPrintListApi()
  304. this.$set(this.ruleForm, 'region', '');
  305. this.$nextTick(()=>{
  306. this.$refs.ruleForm.clearValidate('region')
  307. })
  308. this.dialogVisible = true
  309. },
  310. handleClose(){
  311. this.dialogVisible = false
  312. },
  313. /** 查询打印机列表 */
  314. getPrintListApi() {
  315. getPrintListApi({deviceType:5,pageNum: 1,
  316. pageSize: 999,})
  317. .then(response => {
  318. this.printList = response.data.rows;
  319. }
  320. );
  321. },
  322. /** 选择打印机 */
  323. selectPrint(){
  324. },
  325. // 打印
  326. async print(list = []){
  327. this.$refs.ruleForm.validate(async (valid) => {
  328. if (valid) {
  329. this.dialogVisibleLoading = true
  330. try {
  331. let res = await printApi({
  332. viewerList:list,
  333. source: 2,
  334. deviceId: this.ruleForm.region
  335. })
  336. if(res.code == 200) {
  337. let url = res.data.linkIp
  338. let printInfo = res.data.printInfo
  339. this.connectPrint(url,printInfo)
  340. }else {
  341. throw new Error(res)
  342. }
  343. } catch (error) {
  344. this.dialogVisible = false
  345. this.dialogVisibleLoading = false
  346. console.error("error=====",error)
  347. }
  348. } else {
  349. console.log('error submit!!');
  350. return false;
  351. }
  352. });
  353. },
  354. /** 连接打印机 */
  355. connectPrint(url,data){
  356. let xhr = new XMLHttpRequest();
  357. xhr.onreadystatechange = ()=>{
  358. if(xhr.readyState == 4){ // 监听请求完成
  359. if((xhr.status >=200 && xhr.status <300) || xhr.status == 304){
  360. console.log(xhr.responseText)
  361. this.dialogVisible = false
  362. this.dialogVisibleLoading = false
  363. }else{
  364. console.log('请求失败')
  365. this.dialogVisible = false
  366. this.dialogVisibleLoading = false
  367. }
  368. }
  369. }
  370. xhr.open("post", url, true); // 异步请求
  371. xhr.send(JSON.stringify(data));
  372. }
  373. }
  374. };
  375. </script>