index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80px">
  4. <el-form-item label="券号" prop="couponCode">
  5. <el-input
  6. v-model="queryParams.couponCode"
  7. placeholder="请输入券号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="券标题" prop="title">
  14. <el-input
  15. v-model="queryParams.title"
  16. placeholder="请输入券标题"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="用户电话" prop="phone">
  23. <el-input
  24. v-model="queryParams.phone"
  25. placeholder="请输入用户电话"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="领取时间" prop="createTime">
  32. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  33. </el-form-item>
  34. <el-form-item label="使用时间" prop="useTime">
  35. <el-date-picker v-model="useTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="changeUse"></el-date-picker>
  36. </el-form-item>
  37. <el-form-item label="关联订单" prop="businessId">
  38. <el-input
  39. v-model="queryParams.businessId"
  40. placeholder="请输入关联订单ID"
  41. clearable
  42. size="small"
  43. @keyup.enter.native="handleQuery"
  44. />
  45. </el-form-item>
  46. <el-form-item label="订单类型" prop="businessType">
  47. <el-select v-model="queryParams.businessType" placeholder="请选择订单类型" clearable size="small">
  48. <el-option
  49. v-for="dict in businessTypeOptions"
  50. :key="dict.dictValue"
  51. :label="dict.dictLabel"
  52. :value="dict.dictValue"
  53. />
  54. </el-select>
  55. </el-form-item>
  56. <el-form-item>
  57. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  58. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  59. </el-form-item>
  60. </el-form>
  61. <el-row :gutter="10" class="mb8">
  62. <el-col :span="1.5">
  63. <el-button
  64. type="warning"
  65. plain
  66. icon="el-icon-download"
  67. size="mini"
  68. :loading="exportLoading"
  69. @click="handleExport"
  70. v-hasPermi="['his:userCoupon:export']"
  71. >导出</el-button>
  72. </el-col>
  73. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  74. </el-row>
  75. <el-tabs type="card" v-model="actName" @tab-click="handleClickX">
  76. <el-tab-pane label="全部" name="10"></el-tab-pane>
  77. <el-tab-pane v-for="(item,index) in statusOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  78. </el-tabs>
  79. <el-table v-loading="loading" border :data="userCouponList" @selection-change="handleSelectionChange">
  80. <el-table-column type="selection" width="55" align="center" />
  81. <el-table-column label="优惠劵标题" align="center" prop="title" />
  82. <el-table-column label="券号" align="center" prop="couponCode" />
  83. <el-table-column label="会员昵称" align="center" prop="nickName" />
  84. <el-table-column label="会员电话" align="center" prop="phone" />
  85. <el-table-column label="面额" align="center" prop="price" />
  86. <el-table-column label="订单类型" align="center" prop="businessType">
  87. <template slot-scope="scope">
  88. <dict-tag :options="businessTypeOptions" :value="scope.row.businessType"/>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="卷类型 " align="center" prop="couponType" width="120px">
  92. <template slot-scope="scope">
  93. <dict-tag :options="couponTypeOptions" :value="scope.row.couponType"/>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="状态" align="center" prop="status">
  97. <template slot-scope="scope">
  98. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="发送人" align="center" prop="sendUserName"/>
  102. <el-table-column label="公司" align="center" prop="companyName"/>
  103. <el-table-column label="销售" align="center" prop="companyUserName"/>
  104. <el-table-column label="领取时间" align="center" prop="createTime" width="180"/>
  105. <el-table-column label="使用时间" align="center" prop="useTime" width="180"/>
  106. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
  107. <template slot-scope="scope">
  108. <el-button v-if="scope.row.businessType!=null"
  109. size="mini"
  110. type="text"
  111. @click="handledetails(scope.row)"
  112. >订单详情</el-button>
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. <pagination
  117. v-show="total>0"
  118. :total="total"
  119. :page.sync="queryParams.pageNum"
  120. :limit.sync="queryParams.pageSize"
  121. @pagination="getList"
  122. />
  123. <!-- 添加或修改会员优惠券对话框 -->
  124. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  125. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  126. <el-form-item label="优惠劵id" prop="couponId">
  127. <el-input v-model="form.couponId" placeholder="请输入优惠劵id" />
  128. </el-form-item>
  129. <el-form-item label="券号" prop="couponCode">
  130. <el-input v-model="form.couponCode" placeholder="请输入券号" />
  131. </el-form-item>
  132. <el-form-item label="会员ID" prop="userId">
  133. <el-input v-model="form.userId" placeholder="请输入会员ID" />
  134. </el-form-item>
  135. <el-form-item label="使用时间" prop="useTime">
  136. <el-date-picker clearable size="small"
  137. v-model="form.useTime"
  138. type="date"
  139. value-format="yyyy-MM-dd"
  140. placeholder="选择使用时间">
  141. </el-date-picker>
  142. </el-form-item>
  143. <el-form-item label="关联订单ID" prop="businessId">
  144. <el-input v-model="form.businessId" placeholder="请输入关联订单ID" />
  145. </el-form-item>
  146. <el-form-item label="订单类型" prop="businessType">
  147. <el-select v-model="form.businessType" placeholder="请选择订单类型">
  148. <el-option
  149. v-for="dict in businessTypeOptions"
  150. :key="dict.dictValue"
  151. :label="dict.dictLabel"
  152. :value="parseInt(dict.dictValue)"
  153. ></el-option>
  154. </el-select>
  155. </el-form-item>
  156. <el-form-item label="状态" prop="status">
  157. <el-select v-model="form.status" placeholder="请选择状态 0未使用 1已使用 2已过期">
  158. <el-option
  159. v-for="dict in statusOptions"
  160. :key="dict.dictValue"
  161. :label="dict.dictLabel"
  162. :value="parseInt(dict.dictValue)"
  163. ></el-option>
  164. </el-select>
  165. </el-form-item>
  166. </el-form>
  167. <div slot="footer" class="dialog-footer">
  168. <el-button type="primary" @click="submitForm">确 定</el-button>
  169. <el-button @click="cancel">取 消</el-button>
  170. </div>
  171. </el-dialog>
  172. <el-drawer
  173. :with-header="false"
  174. size="75%"
  175. :title="show.title" :visible.sync="show.open">
  176. <inquiryOrderDetails ref="Details" />
  177. </el-drawer>
  178. <el-drawer
  179. :with-header="false"
  180. size="75%"
  181. :title="show.title" :visible.sync="storeOpen">
  182. <storeOrderDetails ref="storeDetails" />
  183. </el-drawer>
  184. </div>
  185. </template>
  186. <script>
  187. import { listUserCoupon, getUserCoupon, delUserCoupon, addUserCoupon, updateUserCoupon, exportUserCoupon } from "@/api/store/userCoupon";
  188. import inquiryOrderDetails from '@/views/store/components/inquiryOrderDetails.vue';
  189. import storeOrderDetails from '@/views/store/components/storeOrderDetails.vue';
  190. export default {
  191. name: "UserCoupon",
  192. components: { inquiryOrderDetails,storeOrderDetails },
  193. data() {
  194. return {
  195. show:{
  196. open:false,
  197. },
  198. storeOpen:false,
  199. // 遮罩层
  200. createTime:[],
  201. useTime:[],
  202. loading: true,
  203. // 导出遮罩层
  204. exportLoading: false,
  205. // 选中数组
  206. ids: [],
  207. // 非单个禁用
  208. single: true,
  209. // 非多个禁用
  210. multiple: true,
  211. // 显示搜索条件
  212. showSearch: true,
  213. // 总条数
  214. total: 0,
  215. // 会员优惠券表格数据
  216. userCouponList: [],
  217. // 卷类型 1代金券 字典
  218. couponTypeOptions: [],
  219. // 弹出层标题
  220. title: "",
  221. actName:"10",
  222. // 是否显示弹出层
  223. open: false,
  224. // 订单类型 1问诊 2商城字典
  225. businessTypeOptions: [],
  226. // 状态 0未使用 1已使用 2已过期字典
  227. statusOptions: [],
  228. // 查询参数
  229. queryParams: {
  230. pageNum: 1,
  231. pageSize: 10,
  232. couponId: null,
  233. couponCode: null,
  234. userId: null,
  235. createTime: null,
  236. updateTime: null,
  237. useTime: null,
  238. businessId: null,
  239. businessType: null,
  240. status: null,
  241. sUseTime:null,
  242. eUseTime:null,
  243. sTime:null,
  244. eTime:null,
  245. phone:null,
  246. title:null
  247. },
  248. // 表单参数
  249. form: {},
  250. // 表单校验
  251. rules: {
  252. }
  253. };
  254. },
  255. created() {
  256. this.getList();
  257. this.getDicts("sys_coupon_business_type").then(response => {
  258. this.businessTypeOptions = response.data;
  259. });
  260. this.getDicts("sys_coupon_status").then(response => {
  261. this.statusOptions = response.data;
  262. });
  263. this.getDicts("sys_coupon_type").then(response => {
  264. this.couponTypeOptions = response.data;
  265. });
  266. },
  267. methods: {
  268. /** 查询会员优惠券列表 */
  269. getList() {
  270. this.loading = true;
  271. listUserCoupon(this.queryParams).then(response => {
  272. this.userCouponList = response.rows;
  273. this.total = response.total;
  274. this.loading = false;
  275. });
  276. },
  277. handledetails(row){
  278. if(row.businessType==1){
  279. this.show.open=true;
  280. setTimeout(() => {
  281. this.$refs.Details.getDetails(row.businessId);
  282. }, 1);
  283. }else if(row.businessType==2){
  284. this.storeOpen=true;
  285. setTimeout(() => {
  286. this.$refs.storeDetails.getDetails(row.businessId);
  287. }, 1);
  288. }
  289. },
  290. handleClickX(tab, event) {
  291. if(tab.name=="10"){
  292. this.queryParams.status=null;
  293. }else{
  294. this.queryParams.status=tab.name;
  295. }
  296. this.handleQuery();
  297. },
  298. // 取消按钮
  299. cancel() {
  300. this.open = false;
  301. this.reset();
  302. },
  303. // 表单重置
  304. reset() {
  305. this.form = {
  306. id: null,
  307. couponId: null,
  308. couponCode: null,
  309. userId: null,
  310. createTime: null,
  311. updateTime: null,
  312. useTime: null,
  313. businessId: null,
  314. businessType: null,
  315. status: null
  316. };
  317. this.resetForm("form");
  318. },
  319. /** 搜索按钮操作 */
  320. handleQuery() {
  321. console.log(this.queryParams)
  322. this.queryParams.pageNum = 1;
  323. this.getList();
  324. },
  325. /** 重置按钮操作 */
  326. resetQuery() {
  327. this.resetForm("queryForm");
  328. this.createTime=null;
  329. this.queryParams.sTime=null;
  330. this.queryParams.eTime=null;
  331. this.useTime=null;
  332. this.queryParams.sUseTime=null;
  333. this.queryParams.eUseTime=null;
  334. this.handleQuery();
  335. },
  336. // 多选框选中数据
  337. handleSelectionChange(selection) {
  338. this.ids = selection.map(item => item.id)
  339. this.single = selection.length!==1
  340. this.multiple = !selection.length
  341. },
  342. /** 新增按钮操作 */
  343. handleAdd() {
  344. this.reset();
  345. this.open = true;
  346. this.title = "添加会员优惠券";
  347. },
  348. change(){
  349. if(this.createTime!=null){
  350. this.queryParams.sTime=this.createTime[0];
  351. this.queryParams.eTime=this.createTime[1];
  352. }else{
  353. this.queryParams.sTime=null;
  354. this.queryParams.eTime=null;
  355. }
  356. },
  357. changeUse(){
  358. if(this.useTime!=null){
  359. this.queryParams.sUseTime=this.useTime[0];
  360. this.queryParams.eUseTime=this.useTime[1];
  361. }else{
  362. this.queryParams.sUseTime=null;
  363. this.queryParams.eUseTime=null;
  364. }
  365. },
  366. /** 修改按钮操作 */
  367. handleUpdate(row) {
  368. this.reset();
  369. const id = row.id || this.ids
  370. getUserCoupon(id).then(response => {
  371. this.form = response.data;
  372. this.open = true;
  373. this.title = "修改会员优惠券";
  374. });
  375. },
  376. /** 提交按钮 */
  377. submitForm() {
  378. this.$refs["form"].validate(valid => {
  379. if (valid) {
  380. if (this.form.id != null) {
  381. updateUserCoupon(this.form).then(response => {
  382. this.msgSuccess("修改成功");
  383. this.open = false;
  384. this.getList();
  385. });
  386. } else {
  387. addUserCoupon(this.form).then(response => {
  388. this.msgSuccess("新增成功");
  389. this.open = false;
  390. this.getList();
  391. });
  392. }
  393. }
  394. });
  395. },
  396. /** 删除按钮操作 */
  397. handleDelete(row) {
  398. const ids = row.id || this.ids;
  399. this.$confirm('是否确认删除会员优惠券编号为"' + ids + '"的数据项?', "警告", {
  400. confirmButtonText: "确定",
  401. cancelButtonText: "取消",
  402. type: "warning"
  403. }).then(function() {
  404. return delUserCoupon(ids);
  405. }).then(() => {
  406. this.getList();
  407. this.msgSuccess("删除成功");
  408. }).catch(() => {});
  409. },
  410. /** 导出按钮操作 */
  411. handleExport() {
  412. const queryParams = this.queryParams;
  413. this.$confirm('是否确认导出所有会员优惠券数据项?', "警告", {
  414. confirmButtonText: "确定",
  415. cancelButtonText: "取消",
  416. type: "warning"
  417. }).then(() => {
  418. this.exportLoading = true;
  419. return exportUserCoupon(queryParams);
  420. }).then(response => {
  421. this.download(response.msg);
  422. this.exportLoading = false;
  423. }).catch(() => {});
  424. }
  425. }
  426. };
  427. </script>