index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  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 v-model="queryParams.orderId" placeholder="请输入订单号" clearable style="width: 240px;"
  6. @keyup.enter.native="handleQuery" />
  7. </el-form-item>
  8. <el-form-item label="订单状态">
  9. <el-select v-model="queryParams.orderStatus" placeholder="订单状态" clearable style="width: 100%">
  10. <el-option v-for="dict in dict.type.order_status_type" :key="dict.value" :label="dict.label"
  11. :value="dict.value" />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="座位类型">
  15. <el-select v-model="queryParams.seatTypeId" placeholder="座位类型" clearable style="width: 100%">
  16. <el-option v-for="(item, index) in seatTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="购票渠道">
  20. <el-select v-model="queryParams.source" placeholder="购票渠道" clearable style="width: 100%">
  21. <el-option v-for="dict in dict.type.order_form_type" :key="dict.value" :label="dict.label"
  22. :value="dict.value" />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="支付时间">
  26. <el-date-picker style="width: 230px;" v-model="queryParams.payTime" type="date" value-format="yyyy-MM-dd"
  27. placeholder="支付时间">
  28. </el-date-picker>
  29. </el-form-item>
  30. <el-form-item label="演出时间">
  31. <el-date-picker style="width: 230px;" v-model="queryParams.performDate" @change="pagePerformTimeListFun"
  32. type="date" value-format="yyyy-MM-dd" placeholder="选择日期">
  33. </el-date-picker>
  34. </el-form-item>
  35. <el-form-item label="场次">
  36. <el-select v-model="queryParams.performTimeId" placeholder="场次" clearable style="width: 100%">
  37. <el-option v-for="dict in pagePerformTimeList" :key="dict.id" :label="dict.timeSnapshot" :value="dict.id" />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  42. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <el-row :gutter="10" class="mb8">
  46. <el-button type="primary" size="mini" icon="el-icon-download" v-hasPermi="['order:viewers:excel']"
  47. @click="handleExport" v-loading.fullscreen.lock="handleExportLoading" element-loading-text="正在拼命生成数据中..."
  48. element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.5)">导出excel</el-button>
  49. <el-button
  50. type="primary"
  51. size="mini"
  52. v-hasPermi="['order:viewers:tuikuai']"
  53. :disabled="multipleSelection.length==0"
  54. @click="openRefundSubmitModel(multipleSelection)">批量退款</el-button>
  55. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  56. </el-row>
  57. <el-table ref="tables" @selection-change="handleSelectionChange" v-loading="loading" :data="dataList" border>
  58. <el-table-column
  59. :selectable="isSelectableFun"
  60. type="selection"
  61. width="55"></el-table-column>
  62. <el-table-column label="订单号" align="center" prop="orderId" />
  63. <el-table-column label="观影人名称" align="center" prop="name" />
  64. <el-table-column label="身份证号" align="center" prop="idcard" />
  65. <el-table-column label="票务名称" align="center" prop="goodsName" />
  66. <el-table-column label="座位类型" align="center" prop="seatTypeName" />
  67. <el-table-column label="购买渠道" align="center" prop="source">
  68. <template slot-scope="scope">
  69. <dict-tag :options="dict.type.order_form_type" :value="scope.row.source" />
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="演出日期" align="center" prop="performDate" />
  73. <el-table-column label="场次" width="120" align="center">
  74. <template slot-scope="scope">
  75. <span>{{ scope.row.performTimeStart + '-' + scope.row.performTimeEnd }}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="购票人" align="center" prop="memberName" />
  79. <el-table-column label="购票人手机号" align="center" prop="memberMobile" />
  80. <el-table-column label="订单总额" align="center" prop="realPriceTotal">
  81. <template slot-scope="scope">
  82. <span>{{ scope.row.realPriceTotal ? '¥' + scope.row.realPriceTotal : '-' }}</span>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="观影实付金额" align="center" prop="realPrice">
  86. <template slot-scope="scope">
  87. <span>{{ scope.row.realPrice ? '¥' + scope.row.realPrice : '-' }}</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="支付方式" align="center" prop="payWay">
  91. <template slot-scope="scope">
  92. <dict-tag :options="dict.type.pay_way_type" :value="scope.row.payWay" />
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="支付时间" align="center" prop="createTime" />
  96. <el-table-column label="支付时间" align="center" prop="payTime" width="160">
  97. <template slot-scope="scope">
  98. <span>{{ parseTime(scope.row.payTime) }}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="订单状态" align="center">
  102. <template slot-scope="scope">
  103. <dict-tag :options="dict.type.order_status_type" :value="scope.row.status" />
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="核销渠道" align="center" prop="deviceName" />
  107. <el-table-column label="人员类别" align="center">
  108. <template slot-scope="scope">
  109. <dict-tag :options="dict.type.personnel_type" :value="scope.row.identity" />
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="备注" align="center" prop="remark" />
  113. <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width">
  114. <template slot-scope="scope">
  115. <el-button size="mini" type="text" @click="openDetails(scope.row)"
  116. v-hasPermi="['order:viewers:details']">详情</el-button>
  117. <el-button v-if="scope.row.status == 3 || scope.row.status == 7" size="mini" type="text"
  118. @click="handleOpen([scope.row])"
  119. v-hasPermi="['order:viewers:print']">打印</el-button>
  120. <el-button v-if="scope.row.status == 3 || scope.row.status == 6" size="mini" type="text"
  121. @click="openRefundSubmitModel([scope.row])"
  122. v-hasPermi="['order:viewers:tuikuai']">退款</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  127. @pagination="getList" />
  128. <!-- 详情 -->
  129. <details-dia ref="detailsDia" @getList="getList"></details-dia>
  130. <!-- 打印 -->
  131. <el-dialog title="选择小票机" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
  132. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  133. <el-form-item label="小票机" prop="region">
  134. <el-select v-model="ruleForm.region" placeholder="选择小票机">
  135. <el-option :label="item.deviceName" :key="item.id" :value="item.id"
  136. v-for="(item, index) in printList"></el-option>
  137. </el-select>
  138. </el-form-item>
  139. </el-form>
  140. <span slot="footer" class="dialog-footer">
  141. <el-button @click="dialogVisible = false">取 消</el-button>
  142. <el-button type="primary" :loading="dialogVisibleLoading" @click="print(viewerList)">{{
  143. dialogVisibleLoading ? '打印中...' : '打印' }}</el-button>
  144. </span>
  145. </el-dialog>
  146. <!-- 退款 -->
  147. <el-dialog
  148. title="退款提示"
  149. :visible.sync="tkDialogVisible"
  150. width="80%"
  151. :before-close="handleCloseTk"
  152. :modal-append-to-body="false"
  153. :show-close="!tkDialogVisibleLoading"
  154. >
  155. <div style="display: flex;width: 100%;height: calc( 100vh - 30vh );overflow: hidden;overflow-y: auto;">
  156. <div style="display: 200px;box-sizing: border-box;">
  157. <el-form :disabled="tkDialogVisibleLoading" :model="tkRuleForm" :rules="tkRules" ref="tkRuleForm" label-width="100px" class="demo-ruleForm">
  158. <el-form-item label="退款总金额">
  159. <span>{{ tkRuleForm.refundAmountAll }}</span>
  160. </el-form-item>
  161. <el-form-item label="退款原因" prop="refundReason">
  162. <el-input
  163. type="textarea"
  164. :rows="3"
  165. v-model="tkRuleForm.refundReason"></el-input>
  166. </el-form-item>
  167. <el-form-item label="备注" prop="remark">
  168. <el-input
  169. type="textarea"
  170. :rows="3"
  171. v-model="tkRuleForm.remark"></el-input>
  172. </el-form-item>
  173. </el-form>
  174. </div>
  175. <div style=" width: calc( 100% - 200px );box-sizing: border-box;padding-left: 40px;">
  176. <el-table
  177. :data="tkSelectList"
  178. style="width: 100%">
  179. <el-table-column
  180. prop="orderId"
  181. label="订单号"
  182. >
  183. </el-table-column>
  184. <el-table-column
  185. label="观影人数"
  186. >
  187. <template slot-scope="scope">
  188. <span>{{ scope.row.viewerList.length }}</span>
  189. </template>
  190. </el-table-column>
  191. <el-table-column
  192. prop="refundAmount"
  193. label="退款金额"
  194. >
  195. </el-table-column>
  196. <el-table-column
  197. prop="address"
  198. label="状态">
  199. <template slot-scope="scope">
  200. <span
  201. :style="{
  202. color: refundSubmitAction == scope.row.orderId?'#409eff':
  203. refundSubmitSuccess.includes(scope.row.orderId)?'#67c23a':
  204. refundSubmitError.includes(scope.row.orderId)?'#f56c6c':
  205. '#000'
  206. }"
  207. >
  208. {{
  209. refundSubmitAction == scope.row.orderId?'退款提交中...':
  210. refundSubmitSuccess.includes(scope.row.orderId)?'退款提交成功':
  211. refundSubmitError.includes(scope.row.orderId)?'退款提交失败':
  212. '等待退款提交...' }}
  213. </span>
  214. </template>
  215. </el-table-column>
  216. </el-table>
  217. </div>
  218. </div>
  219. <span slot="footer" class="dialog-footer">
  220. <el-button :loading="tkDialogVisibleLoading" @click="handleCloseTk('tkRuleForm')">取 消</el-button>
  221. <el-button
  222. :loading="tkDialogVisibleLoading"
  223. type="primary"
  224. @click="tkSubmitForm('tkRuleForm')"
  225. v-if="refundSubmitSuccess.length != tkSelectList.length"
  226. >{{
  227. tkDialogVisibleLoading ? '退款中...':
  228. refundSubmitError.length > 0? '继续提交失败订单':
  229. '确定退款'
  230. }}</el-button>
  231. </span>
  232. </el-dialog>
  233. </div>
  234. </template>
  235. <script>
  236. import { pageList, downOrderListXls, printApi, refundSubmitApi } from '@/api/order/viewers'
  237. import detailsDia from "./dialog/details";
  238. import { pagePerformTimeList } from "@/api/schedulingMr/schedulingMr"
  239. import { exportExcel } from '@/utils/exportexcel'
  240. import { pageList as getPrintListApi } from "@/api/device/pda";
  241. import { pageList as getSeatTypeList } from '@/api/seatTypeMr/seatTypeMr'
  242. const https = require('https');
  243. const axios = require('axios');
  244. const mathM = require('mathjs')
  245. export default {
  246. name: "agreement",
  247. dicts: ['order_form_type', 'order_status_type', 'pay_way_type', 'personnel_type'],
  248. components: { detailsDia },
  249. data() {
  250. return {
  251. // 遮罩层
  252. loading: true,
  253. // 选中数组
  254. ids: [],
  255. // 非单个禁用
  256. single: true,
  257. // 非多个禁用
  258. multiple: true,
  259. // 显示搜索条件
  260. showSearch: true,
  261. // 总条数
  262. total: 0,
  263. // 用户表格数据
  264. dataList: null,
  265. // 弹出层标题
  266. title: "",
  267. // 是否显示弹出层
  268. open: false,
  269. // 查询参数
  270. queryParams: {
  271. pageNum: 1,
  272. pageSize: 10,
  273. },
  274. visibleStatus: false,
  275. newObj: {},
  276. visibleType: '',
  277. pagePerformTimeList: [], // 场次列表
  278. handleExportLoading: false,
  279. viewerList: [],
  280. printList: [],
  281. dialogVisible: false,
  282. ruleForm: {},
  283. rules: {
  284. region: [
  285. { required: true, message: '请选择备注', trigger: ['change', 'blur'] }
  286. ],
  287. },
  288. dialogVisibleLoading: false,
  289. seatTypeList: [],
  290. multipleSelection: [],
  291. tkDialogVisible: false,
  292. tkDialogVisibleLoading: false,
  293. tkSelectList: [],
  294. tkRuleForm: {
  295. "orderId": null,
  296. "refundReason": null,
  297. "remark": null,
  298. "refundAmount": 0.01,
  299. "viewerList": [
  300. {
  301. "viewerId": "1111",
  302. "salePrice": 0.01
  303. }
  304. ]
  305. },
  306. tkRules: {
  307. refundReason: [{ required: true, message: '请输入退款原因', trigger: ['blur', 'change'] }],
  308. remark: [{ required: true, message: '请输入备注', trigger: ['blur', 'change'] }],
  309. },
  310. refundSubmitAction: null,
  311. refundSubmitSuccess:[], // 成功条数
  312. refundSubmitError: [], // 失败条数
  313. refundSubmitErrorList: [], //
  314. };
  315. },
  316. created() {
  317. this.getSeatTypeListFun()
  318. this.getList();
  319. },
  320. methods: {
  321. /** 查询列表 */
  322. getList() {
  323. this.loading = true;
  324. pageList(this.addDateRange(this.queryParams))
  325. .then(response => {
  326. this.dataList = response.data.rows;
  327. this.total = response.data.total;
  328. this.loading = false;
  329. });
  330. },
  331. // 取消按钮
  332. cancel() {
  333. this.open = false;
  334. },
  335. /** 搜索按钮操作 */
  336. handleQuery() {
  337. this.queryParams.pageNum = 1;
  338. if (this.queryParams.time) {
  339. this.queryParams.payBeginTime = this.queryParams.time[0];
  340. this.queryParams.payEndTime = this.queryParams.time[1];
  341. }else {
  342. this.queryParams.payBeginTime = null
  343. this.queryParams.payEndTime = null
  344. }
  345. if (this.queryParams.createTime && this.queryParams.createTime.length > 0) {
  346. this.queryParams.createBeginTime = this.queryParams.createTime[0];
  347. this.queryParams.createEndTime = this.queryParams.createTime[1];
  348. }else {
  349. this.queryParams.createBeginTime = null
  350. this.queryParams.createEndTime = null
  351. }
  352. this.getList();
  353. },
  354. /** 重置按钮操作 */
  355. resetQuery() {
  356. this.queryParams = {
  357. pageNum: 1,
  358. pageSize: 10,
  359. }
  360. // this.$set(this.queryParams, 'orderId', '');
  361. // this.$set(this.queryParams, 'status', '');
  362. // this.$set(this.queryParams, 'memberMobile', '');
  363. // this.$set(this.queryParams, 'source', '');
  364. // this.$set(this.queryParams, 'performName', '');
  365. // this.$set(this.queryParams, 'payBeginTime', '');
  366. // this.$set(this.queryParams, 'payEndTime', '');
  367. // this.$set(this.queryParams, 'time', '');
  368. // this.$set(this.queryParams, 'createTime', '');
  369. // this.$set(this.queryParams, 'createBeginTime', '');
  370. // this.$set(this.queryParams, 'createEndTime', '');
  371. // this.$set(this.queryParams, 'goodsName', '');
  372. // this.$set(this.queryParams, 'performDate', '');
  373. // this.$set(this.queryParams, 'timeSnapshot', '');
  374. // this.$set(this.queryParams, 'performTimeId', '');
  375. // this.queryParams.pageNum = 1;
  376. this.handleQuery();
  377. },
  378. /** 详情按钮操作 */
  379. openDetails(row, type) {
  380. this.$refs["detailsDia"].openDialog("详情", row, type);
  381. },
  382. async pagePerformTimeListFun(value) {
  383. try {
  384. this.pagePerformTimeList = []
  385. this.$set(this.queryParams, 'performTimeId', null)
  386. if (!value) {
  387. return
  388. }
  389. let { data, code } = await pagePerformTimeList({
  390. performDate: value,
  391. pageNum: 1,
  392. pageSize: 999
  393. })
  394. this.pagePerformTimeList = [].concat(data.rows)
  395. } catch (error) {
  396. }
  397. },
  398. /**
  399. * 导出报表
  400. * @date 2022-10-24
  401. * @returns {any}
  402. */
  403. handleExport() {
  404. this.$confirm('您确定要导出当前查询的数据吗?', '提示', {
  405. confirmButtonText: '确定 ',
  406. cancelButtonText: '取消 ',
  407. type: 'warning'
  408. })
  409. .then(() => {
  410. this.handleExportLoading = true;
  411. // const { pageNum, pageSize} = this.params;
  412. let postMap = {}
  413. for (let key in this.queryParams) {
  414. if (key != 'pageNum' && key != 'pageSize') {
  415. postMap[key] = this.queryParams[key]
  416. }
  417. }
  418. downOrderListXls(postMap)
  419. .then((res) => {
  420. exportExcel(res, '订单管理', '.xlsx');
  421. this.handleExportLoading = false;
  422. })
  423. .catch((error) => {
  424. console.log("error===", error)
  425. this.handleExportLoading = false;
  426. });
  427. })
  428. .catch(() => {
  429. this.$message.info('您已取消导出!');
  430. });
  431. },
  432. handleOpen(list = []) {
  433. if (!list || list.length == 0) return
  434. let idList = []
  435. list.forEach((item, index) => {
  436. idList.push(item.id)
  437. })
  438. this.viewerList = idList
  439. this.getPrintListApi()
  440. this.$set(this.ruleForm, 'region', '');
  441. this.$nextTick(() => {
  442. this.$refs.ruleForm.clearValidate('region')
  443. })
  444. this.dialogVisible = true
  445. },
  446. handleClose() {
  447. this.dialogVisible = false
  448. },
  449. /** 查询打印机列表 */
  450. getPrintListApi() {
  451. getPrintListApi({
  452. deviceType: 5, pageNum: 1,
  453. pageSize: 999,
  454. })
  455. .then(response => {
  456. this.printList = response.data.rows;
  457. }
  458. );
  459. },
  460. /** 选择打印机 */
  461. selectPrint() {
  462. },
  463. // 打印
  464. async print(list = []) {
  465. this.$refs.ruleForm.validate(async (valid) => {
  466. if (valid) {
  467. this.dialogVisibleLoading = true
  468. try {
  469. let res = await printApi({
  470. viewerList: list,
  471. source: 2,
  472. deviceId: this.ruleForm.region
  473. })
  474. if (res.code == 200) {
  475. let url = res.data.linkIp
  476. let printInfo = res.data.printInfo
  477. this.connectPrint(url, printInfo)
  478. } else {
  479. throw new Error(res)
  480. }
  481. } catch (error) {
  482. this.dialogVisible = false
  483. this.dialogVisibleLoading = false
  484. console.error("error=====", error)
  485. }
  486. } else {
  487. console.log('error submit!!');
  488. return false;
  489. }
  490. });
  491. },
  492. /** 连接打印机 */
  493. connectPrint(url, data) {
  494. // 创建忽略 SSL 的 axios 实例
  495. const ignoreSSL = axios.create({
  496. httpsAgent: new https.Agent({
  497. rejectUnauthorized: false
  498. }),
  499. withCredentials: true, // 跨域请求时发送Cookie
  500. timeout: 60000, // 请求超时
  501. headers: {
  502. "Content-Type": "application/json; charset=UTF-8;"
  503. }
  504. });
  505. ignoreSSL.post(url,
  506. { ...data }
  507. ).then(() => {
  508. this.dialogVisible = false
  509. this.dialogVisibleLoading = false
  510. }).catch(() => {
  511. this.dialogVisible = false
  512. this.dialogVisibleLoading = false
  513. })
  514. },
  515. /** 获取座位类型 */
  516. async getSeatTypeListFun() {
  517. try {
  518. let res = await getSeatTypeList({
  519. pageNum: 1, pageSize: 999
  520. })
  521. this.seatTypeList = res.data.rows
  522. } catch (error) {
  523. }
  524. },
  525. /** 打开弹窗 */
  526. openRefundSubmitModel(data, type) {
  527. this.refundSubmitSuccess = []
  528. this.refundSubmitError = []
  529. let list = []
  530. data.forEach((item,index)=>{
  531. let flog = false
  532. let indexNew = null
  533. list.forEach((item1,index1)=>{
  534. if(item.orderId == item1.orderId) {
  535. flog = true
  536. indexNew = index1
  537. }
  538. })
  539. if(!flog){
  540. list.push({
  541. "orderId": item.orderId,
  542. "refundReason": null,
  543. "remark": null,
  544. "refundAmount": 0,
  545. "viewerList": [
  546. {
  547. "viewerId": item.id,
  548. "salePrice": item.realPrice?item.realPrice:0
  549. }
  550. ]
  551. })
  552. }else {
  553. list[indexNew].viewerList.push({
  554. "viewerId": item.id,
  555. "salePrice": item.realPrice?item.realPrice:0
  556. })
  557. }
  558. })
  559. let refundAmountAll = 0
  560. list.forEach((item,index)=>{
  561. if(item.viewerList && item.viewerList.length > 0){
  562. let refundAmount = 0
  563. item.viewerList.forEach((item1,index1)=>{
  564. refundAmount = mathM.format(Number(refundAmount) + Number(item1.salePrice),10)
  565. refundAmountAll = mathM.format(Number(refundAmountAll) + Number(item1.salePrice),10)
  566. })
  567. list[index].refundAmount = refundAmount
  568. }
  569. })
  570. this.tkRuleForm['refundAmountAll'] = refundAmountAll
  571. this.tkSelectList = JSON.parse(JSON.stringify(list))
  572. console.log("dfsfdsfsdfds====",this.tkSelectList)
  573. this.tkDialogVisible = true
  574. },
  575. tkSubmitForm(formName) {
  576. this.$refs[formName].validate((valid) => {
  577. if (valid) {
  578. let listCopy = JSON.parse(JSON.stringify(this.tkSelectList))
  579. this.tkSelectList.forEach((item,index)=>{
  580. listCopy[index] = {
  581. ...item,
  582. refundReason: this.tkRuleForm.refundReason?this.tkRuleForm.refundReason:'',
  583. remark: this.tkRuleForm.remark?this.tkRuleForm.remark:''
  584. }
  585. })
  586. this.tkSelectList = listCopy
  587. //this.refundSubmitFun(0)
  588. if(this.refundSubmitError && this.refundSubmitError.length>0) {
  589. let list = []
  590. this.refundSubmitError.forEach((item,index)=>{
  591. this.tkSelectList.forEach((item1,index1)=>{
  592. if(item == item1.orderId){
  593. list.push(item1)
  594. }
  595. })
  596. })
  597. this.refundSubmitErrorList = list
  598. this.moreRefundSubmitFun(0)
  599. }else {
  600. this.refundSubmitFun(0)
  601. }
  602. } else {
  603. console.log('error submit!!');
  604. return false;
  605. }
  606. });
  607. },
  608. /** 批量退票 */
  609. async refundSubmitFun(index) {
  610. try {
  611. this.tkDialogVisibleLoading = true
  612. this.refundSubmitAction = this.tkSelectList[index].orderId
  613. let res = await refundSubmitApi({
  614. ...this.tkSelectList[index]
  615. })
  616. this.refundSubmitAction = null
  617. if(res.code == 200) {
  618. this.refundSubmitSuccess.push(this.tkSelectList[index].orderId)
  619. }else {
  620. this.refundSubmitError.push(this.tkSelectList[index].orderId)
  621. this.$message.error(`订单号:${this.tkSelectList[index].orderId},退款提交失败`);
  622. }
  623. if((index+1) < this.tkSelectList.length) {
  624. this.refundSubmitAction = this.tkSelectList[index+1].orderId
  625. setTimeout(() => {
  626. this.refundSubmitFun(index+1)
  627. }, 3000);
  628. }else {
  629. this.tkDialogVisibleLoading = false
  630. if(this.refundSubmitError.length == 0) {
  631. this.$message({
  632. message: '全部退款提交成功!!!',
  633. type: 'success'
  634. });
  635. // this.handleCloseTk()
  636. }
  637. }
  638. } catch (error) {
  639. console.error(index+"===error====",error)
  640. this.refundSubmitAction = null
  641. this.refundSubmitError.push(this.tkSelectList[index].orderId)
  642. this.$message.error(`订单号:${this.tkSelectList[index].orderId},退款提交失败`);
  643. if((index+1) < this.tkSelectList.length) {
  644. this.refundSubmitAction = this.tkSelectList[index+1].orderId
  645. setTimeout(() => {
  646. this.refundSubmitFun(index+1)
  647. }, 3000);
  648. }else {
  649. this.tkDialogVisibleLoading = false
  650. }
  651. }
  652. },
  653. /** 再次 批量退票 */
  654. async moreRefundSubmitFun(index) {
  655. try {
  656. this.refundSubmitError = []
  657. this.tkDialogVisibleLoading = true
  658. this.refundSubmitAction = this.refundSubmitErrorList[index].orderId
  659. let res = await refundSubmitApi({
  660. ...this.refundSubmitErrorList[index]
  661. })
  662. this.refundSubmitAction = null
  663. if(res.code == 200) {
  664. this.refundSubmitSuccess.push(this.refundSubmitErrorList[index].orderId)
  665. }else {
  666. this.refundSubmitError.push(this.refundSubmitErrorList[index].orderId)
  667. this.$message.error(`订单号:${this.refundSubmitErrorList[index].orderId},退款提交失败`);
  668. }
  669. if((index+1) < this.refundSubmitErrorList.length) {
  670. this.refundSubmitAction = this.refundSubmitErrorList[index+1].orderId
  671. setTimeout(() => {
  672. this.refundSubmitFun(index+1)
  673. }, 3000);
  674. }else {
  675. this.tkDialogVisibleLoading = false
  676. if(this.refundSubmitErrorList.length == 0) {
  677. this.$message({
  678. message: '全部退款成功!!!',
  679. type: 'success'
  680. });
  681. // this.handleCloseTk()
  682. }
  683. }
  684. } catch (error) {
  685. console.error(index+"===error====",error)
  686. this.refundSubmitAction = null
  687. this.refundSubmitError.push(this.refundSubmitErrorList[index].orderId)
  688. this.$message.error(`订单号:${this.refundSubmitErrorList[index].orderId},退款提交失败`);
  689. if((index+1) < this.refundSubmitErrorList.length) {
  690. this.refundSubmitAction = this.refundSubmitErrorList[index+1].orderId
  691. setTimeout(() => {
  692. this.refundSubmitFun(index+1)
  693. }, 3000);
  694. }else {
  695. this.tkDialogVisibleLoading = false
  696. }
  697. }
  698. },
  699. /** 退款状态 */
  700. refundSubmitStatus(row){
  701. },
  702. /** 选择 */
  703. handleSelectionChange(val) {
  704. this.multipleSelection = val;
  705. },
  706. /** 是否可用 */
  707. isSelectableFun(row, index){
  708. return row.status == 3 || row.status == 6
  709. },
  710. handleCloseTk(formName){
  711. console.log('dsfsdfsdf')
  712. this.tkDialogVisible = false
  713. if(this.$refs.tkRuleForm) {
  714. this.$refs.tkRuleForm.resetFields()
  715. }
  716. this.getList();
  717. }
  718. }
  719. };
  720. </script>