index.vue 16 KB

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