index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. :inline="true"
  7. v-show="showSearch"
  8. label-width="68px"
  9. >
  10. <el-form-item label="开始时间" label-width="120px" prop="outTradeNo">
  11. <el-date-picker
  12. format="yyyy-MM-dd HH:mm:ss"
  13. value-format="yyyy-MM-dd HH:mm:ss"
  14. v-model="queryParams.startTime"
  15. type="datetime"
  16. placeholder="默认是当前月份第一天"
  17. >
  18. </el-date-picker>
  19. </el-form-item>
  20. <el-form-item label="结束时间" label-width="120px" prop="outTradeNo">
  21. <el-date-picker
  22. format="yyyy-MM-dd HH:mm:ss"
  23. value-format="yyyy-MM-dd HH:mm:ss"
  24. v-model="queryParams.endTime"
  25. type="datetime"
  26. placeholder="默认是当前月份最后一天"
  27. >
  28. </el-date-picker>
  29. </el-form-item>
  30. <el-form-item label="商品ID" label-width="120px" prop="goodsId">
  31. <el-input
  32. v-model="queryParams.userId"
  33. placeholder="商品ID"
  34. clearable
  35. size="small"
  36. @keyup.enter.native="handleQuery"
  37. />
  38. </el-form-item>
  39. <el-form-item label="订单号" label-width="120px" prop="outTradeNo">
  40. <el-input
  41. v-model="queryParams.outTradeNo"
  42. placeholder="订单号"
  43. clearable
  44. size="small"
  45. @keyup.enter.native="handleQuery"
  46. />
  47. </el-form-item>
  48. <el-form-item label="商品名称" label-width="120px" prop="goodsName">
  49. <el-input
  50. v-model="queryParams.goodsName"
  51. placeholder="请输入名称"
  52. clearable
  53. size="small"
  54. @keyup.enter.native="handleQuery"
  55. />
  56. </el-form-item>
  57. <el-form-item label="退款订单号" label-width="120px" prop="outTradeNo">
  58. <el-input
  59. v-model="queryParams.outRefundNo"
  60. placeholder="退款订单号"
  61. clearable
  62. size="small"
  63. @keyup.enter.native="handleQuery"
  64. />
  65. </el-form-item>
  66. <!-- <el-form-item label="是否分成" label-width="120px" prop="phoneType">
  67. <el-select v-model="queryParams.isShare" placeholder="">
  68. <el-option value="" label="全部"></el-option>
  69. <el-option :value="1" label="是"></el-option>
  70. <el-option :value="0" label="否"></el-option>
  71. </el-select>
  72. </el-form-item> -->
  73. <!-- <el-form-item label="支付状态" label-width="120px" prop="tradeType">
  74. <el-select v-model="queryParams.tradeType">
  75. <el-option value="" key="4" label="全部"></el-option>
  76. <el-option value="1" key="1" label="支付成功">支付成功</el-option>
  77. <el-option value="2" key="2" label="支付失败">支付失败</el-option>
  78. <el-option value="3" key="3" label="已退款"></el-option>
  79. </el-select>
  80. </el-form-item> -->
  81. <!-- <el-form-item label="支付类型" prop="payType">
  82. <el-select v-model="queryParams.payType" placeholder="">
  83. <el-option :value="1" label="微信"></el-option>
  84. <el-option :value="2" label="支付宝"></el-option>
  85. </el-select>
  86. </el-form-item>
  87. <el-form-item label="手机类型" prop="payType">
  88. <el-select v-model="queryParams.payType" placeholder="">
  89. <el-option :value="1" label="苹果"></el-option>
  90. <el-option :value="2" label="安卓"></el-option>
  91. </el-select>
  92. </el-form-item>
  93. <el-form-item label="驾校名称" prop="school">
  94. <el-input v-model="queryParams.school" placeholder="请输入驾校名称" clearable size="small"
  95. @keyup.enter.native="handleQuery" />
  96. </el-form-item>
  97. <el-form-item label="驾校提成" prop="questionId">
  98. <el-input v-model="queryParams.schoolCommission" placeholder="请输入驾校提成" clearable size="small"
  99. @keyup.enter.native="handleQuery" />
  100. </el-form-item>
  101. <el-form-item label="驾校名称" prop="schoolName">
  102. <el-input v-model="queryParams.schoolName" placeholder="请输入驾校名称" clearable size="small"
  103. @keyup.enter.native="handleQuery" />
  104. </el-form-item> -->
  105. <el-form-item>
  106. <el-button
  107. type="cyan"
  108. icon="el-icon-search"
  109. size="mini"
  110. @click="handleQuery"
  111. >搜索</el-button
  112. >
  113. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  114. >重置</el-button
  115. >
  116. </el-form-item>
  117. </el-form>
  118. <!-- <el-row :gutter="10" class="mb8">
  119. <el-col :span="1.5">
  120. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
  121. v-hasPermi="['question:error:add']">新增</el-button>
  122. </el-col>
  123. <el-col :span="1.5">
  124. <el-button type="success" icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
  125. v-hasPermi="['question:error:edit']">修改</el-button>
  126. </el-col>
  127. <el-col :span="1.5">
  128. <el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  129. v-hasPermi="['question:error:remove']">删除</el-button>
  130. </el-col>
  131. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  132. </el-row> -->
  133. <el-table
  134. v-loading="loading"
  135. :data="errorList"
  136. @selection-change="handleSelectionChange"
  137. >
  138. <el-table-column type="selection" width="55" align="center" />
  139. <el-table-column label="用户id" align="center" prop="userId" />
  140. <!-- <el-table-column label="姓名" align="center" prop="userName" /> -->
  141. <!-- <el-table-column label="身份证" align="center" prop="logincode" /> -->
  142. <el-table-column
  143. label="支付时间"
  144. align="center"
  145. width="180px"
  146. prop="createTime"
  147. />
  148. <el-table-column label="商品名称" align="center" prop="goodsName" />
  149. <!-- <el-table-column label="是否分成" align="center" prop="isShare">
  150. <template slot-scope="scope">
  151. <span v-if="scope.row.isShare == 1">是</span>
  152. <span v-else-if="scope.row.isShare == 0">否</span>
  153. <span v-else>其他</span>
  154. </template>
  155. </el-table-column> -->
  156. <el-table-column
  157. label="极速驾培订单ID"
  158. align="center"
  159. prop="outTradeNo"
  160. />
  161. <el-table-column label="支付方式" align="center" prop="goodsName">
  162. <template slot-scope="scope">{{
  163. scope.row.payType == 1 ? "微信" : "支付宝"
  164. }}</template>
  165. </el-table-column>
  166. <el-table-column label="手机类型" align="center" prop="goodsName">
  167. <template slot-scope="scope">
  168. <span v-if="scope.row.phoneType == 1">苹果</span>
  169. <span v-else-if="scope.row.phoneType == 2">安卓</span>
  170. <span v-else>其他</span>
  171. </template>
  172. </el-table-column>
  173. <el-table-column label="客户端类型" align="center" prop="goodsName">
  174. <template slot-scope="scope">
  175. <span v-if="scope.row.foreType == 1">app</span>
  176. <span v-if="scope.row.foreType == 2">小程序</span>
  177. <span v-if="scope.row.foreType == 3">公众号</span>
  178. </template>
  179. </el-table-column>
  180. <!-- <el-table-column label="驾校名称" align="center" prop="schoolName" /> -->
  181. <!-- <el-table-column label="驾校提成" align="center" prop="schoolName">
  182. <template slot-scope="scope">
  183. {{ scope.row.schoolCommission / 100 }}元
  184. </template>
  185. </el-table-column> -->
  186. <el-table-column label="订单价格" align="center" prop="total">
  187. <template slot-scope="scope"> {{ scope.row.total / 100 }}元 </template>
  188. </el-table-column>
  189. <el-table-column
  190. label="操作"
  191. align="center"
  192. class-name="small-padding fixed-width"
  193. >
  194. <template slot-scope="scope">
  195. <el-button
  196. v-if="!scope.row.outRefundNo"
  197. :disabled="scope.row.outRefundNo"
  198. size="mini"
  199. type="text"
  200. icon="el-icon-money"
  201. @click="handleRefund(scope.row)"
  202. >分账</el-button
  203. >
  204. <el-popover
  205. v-else
  206. placement="bottom"
  207. title="极速驾培订单退款ID"
  208. width="200"
  209. trigger="click"
  210. :content="scope.row.outRefundNo"
  211. >
  212. <el-link type="danger" slot="reference">已退款</el-link>
  213. </el-popover>
  214. </template>
  215. </el-table-column>
  216. </el-table>
  217. <pagination
  218. v-show="total > 0"
  219. :total="total"
  220. :page.sync="queryParams.pageNum"
  221. :limit.sync="queryParams.pageSize"
  222. @pagination="getList"
  223. />
  224. <!-- 添加或修改错题对话框 -->
  225. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  226. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  227. <el-form-item label="用户id" prop="userId">
  228. <el-input v-model="form.userId" placeholder="请输入用户id" />
  229. </el-form-item>
  230. <el-form-item label="题目id" prop="questionId">
  231. <el-input v-model="form.questionId" placeholder="请输入题目id" />
  232. </el-form-item>
  233. </el-form>
  234. <div slot="footer" class="dialog-footer">
  235. <el-button type="primary" @click="submitForm">确 定</el-button>
  236. <el-button @click="cancel">取 消</el-button>
  237. </div>
  238. </el-dialog>
  239. </div>
  240. </template>
  241. <script>
  242. import {
  243. getList,
  244. shareProfitOrder,
  245. refundOrder,
  246. } from "@/api/wxorder";
  247. let date = new Date();
  248. let defaultStartTime = `${date.getFullYear()}-${
  249. date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1
  250. }-01 00:00:00`;
  251. let defaultEndTime = `${date.getFullYear()}-${
  252. date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1
  253. }-${new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate()} 23:59:59`;
  254. export default {
  255. name: "Order",
  256. data() {
  257. return {
  258. // 遮罩层
  259. loading: true,
  260. // 选中数组
  261. ids: [],
  262. // 非单个禁用
  263. single: true,
  264. // 非多个禁用
  265. multiple: true,
  266. // 显示搜索条件
  267. showSearch: true,
  268. // 总条数
  269. total: 0,
  270. // 错题表格数据
  271. errorList: [],
  272. // 弹出层标题
  273. title: "",
  274. // 是否显示弹出层
  275. open: false,
  276. // 查询参数
  277. queryParams: {
  278. startTime: defaultStartTime,
  279. endTime: defaultEndTime,
  280. tradeType: "",
  281. userId: null,
  282. isShare: "",
  283. userName: "",
  284. logincode: "",
  285. outTradeNo: null,
  286. pageNum: 1,
  287. pageSize: 10,
  288. // id: null,
  289. // outRefundNo: null,
  290. // payType: 1,
  291. // phoneType: 1,
  292. // school: "",
  293. // schoolCommission: 0,
  294. // schoolName: "",
  295. // isShare: 0,
  296. },
  297. // 表单参数
  298. form: {},
  299. // 表单校验
  300. rules: {},
  301. };
  302. },
  303. created() {
  304. this.getList();
  305. },
  306. methods: {
  307. /** 查询错题列表 */
  308. getList() {
  309. this.loading = true;
  310. getList(this.queryParams).then((response) => {
  311. this.errorList = response.rows;
  312. this.total = response.total;
  313. this.loading = false;
  314. });
  315. },
  316. // 取消按钮
  317. cancel() {
  318. this.open = false;
  319. this.reset();
  320. },
  321. // 表单重置
  322. reset() {
  323. this.form = {
  324. tradeType: "",
  325. userId: null,
  326. isShare: "",
  327. userName: "",
  328. logincode: "",
  329. outTradeNo: null,
  330. pageNum: 1,
  331. pageSize: 10,
  332. // id: null,
  333. // outRefundNo: null,
  334. // payType: 1,
  335. // phoneType: 1,
  336. // school: "",
  337. // schoolCommission: 0,
  338. // schoolName: "",
  339. // ,
  340. };
  341. this.resetForm("form");
  342. },
  343. handleRefund(row) {
  344. const outTradeNo = row.outTradeNo;
  345. this.$prompt(
  346. `确认退款${row.goodsName}吗?
  347. 请附带退款理由: <div>用户ID:${row.userId}</div><div>退款金额:${
  348. row.total / 100
  349. }元</div> <div>订单号:${row.outTradeNo}</div> `,
  350. "警告",
  351. {
  352. confirmButtonText: "确定",
  353. cancelButtonText: "取消",
  354. type: "warning",
  355. inputPlaceholder: "请输入退款理由",
  356. dangerouslyUseHTMLString: true,
  357. inputPattern: /[\u4E00-\u9FA5]/,
  358. inputErrorMessage: "至少输入一个中文",
  359. }
  360. )
  361. .then(function (obj) {
  362. return refundOrder({
  363. outTradeNo,
  364. reason: obj.value,
  365. });
  366. })
  367. .then(() => {
  368. this.getList();
  369. this.msgSuccess("退款成功");
  370. });
  371. },
  372. /** 搜索按钮操作 */
  373. handleQuery() {
  374. this.queryParams.pageNum = 1;
  375. this.getList();
  376. },
  377. /** 重置按钮操作 */
  378. resetQuery() {
  379. this.resetForm("queryForm");
  380. this.handleQuery();
  381. },
  382. // 多选框选中数据
  383. handleSelectionChange(selection) {
  384. this.ids = selection.map((item) => item.id);
  385. this.single = selection.length !== 1;
  386. this.multiple = !selection.length;
  387. },
  388. /** 新增按钮操作 */
  389. handleAdd() {
  390. this.reset();
  391. this.open = true;
  392. this.title = "添加错题";
  393. },
  394. /** 修改按钮操作 */
  395. handleUpdate(row) {
  396. this.reset();
  397. const id = row.id || this.ids;
  398. getError(id).then((response) => {
  399. this.form = response.data;
  400. this.open = true;
  401. this.title = "修改错题";
  402. });
  403. },
  404. /** 提交按钮 */
  405. submitForm() {
  406. this.$refs["form"].validate((valid) => {
  407. if (valid) {
  408. if (this.form.id != null) {
  409. updateError(this.form).then((response) => {
  410. this.msgSuccess("修改成功");
  411. this.open = false;
  412. this.getList();
  413. });
  414. } else {
  415. addError(this.form).then((response) => {
  416. this.msgSuccess("新增成功");
  417. this.open = false;
  418. this.getList();
  419. });
  420. }
  421. }
  422. });
  423. },
  424. /** 删除按钮操作 */
  425. handleDelete(row) {
  426. const ids = row.id || this.ids;
  427. this.$confirm('是否确认删除错题编号为"' + ids + '"的数据项?', "警告", {
  428. confirmButtonText: "确定",
  429. cancelButtonText: "取消",
  430. type: "warning",
  431. })
  432. .then(function () {
  433. return delError(ids);
  434. })
  435. .then(() => {
  436. this.getList();
  437. this.msgSuccess("删除成功");
  438. });
  439. },
  440. /** 导出按钮操作 */
  441. handleExport() {
  442. const queryParams = this.queryParams;
  443. this.$confirm("是否确认导出所有错题数据项?", "警告", {
  444. confirmButtonText: "确定",
  445. cancelButtonText: "取消",
  446. type: "warning",
  447. })
  448. .then(function () {
  449. return exportError(queryParams);
  450. })
  451. .then((response) => {
  452. this.download(response.data);
  453. });
  454. },
  455. },
  456. };
  457. </script>