Coupon_CreateCoupon.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  1. <template>
  2. <div v-if="pageStatus == 0">配置加载中...</div>
  3. <div v-else-if="pageStatus == 1">此页面不对此账号开放</div>
  4. <div v-else-if="pageStatus == 2">
  5. 没有此页内容的配置权限,请检查集团上的配置
  6. </div>
  7. <div v-else-if="pageStatus == 3">加载发生错误</div>
  8. <div v-else-if="pageStatus == 4" class="app-container">
  9. <el-form>
  10. <el-form-item label="启动优惠劵" label-width="88px">
  11. <el-switch
  12. v-model="couponEnabledFlag"
  13. active-value="1"
  14. inactive-value="0"
  15. @change="handleFlagChange()"
  16. ></el-switch>
  17. </el-form-item>
  18. <hr />
  19. </el-form>
  20. <div v-if="couponEnabledFlag == 1">
  21. <el-form
  22. :model="createForm"
  23. ref="createForm"
  24. :inline="true"
  25. label-width="88px"
  26. >
  27. <!--
  28. <el-form-item label="设备类型" prop="deviceType">
  29. <el-select
  30. v-model="createForm.deviceType"
  31. clearable
  32. placeholder="请选择"
  33. >
  34. <el-option label="小票打印机" value="1"></el-option>
  35. <el-option label="POS" value="2"></el-option>
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="密钥" prop="deviceSerialNum">
  39. <el-input
  40. v-model="createForm.deviceSerialNum"
  41. placeholder="请输入设备密钥"
  42. clearable
  43. size="small"
  44. @keyup.enter.native="handleQuery"
  45. />
  46. </el-form-item>
  47. -->
  48. <el-form-item>
  49. <!--
  50. <el-button
  51. type="cyan"
  52. icon="el-icon-search"
  53. size="mini"
  54. @click="handleQuery"
  55. >搜索</el-button
  56. >
  57. <el-button
  58. type="info"
  59. icon="el-icon-refresh"
  60. size="mini"
  61. @click="resetQuery"
  62. >重置</el-button
  63. >
  64. -->
  65. <el-button
  66. type="primary"
  67. icon="el-icon-plus"
  68. size="mini"
  69. @click="handleAdd"
  70. >新增</el-button
  71. >
  72. </el-form-item>
  73. </el-form>
  74. <el-table :data="couponList">
  75. <af-table-column label="优惠券名称" align="center" prop="couponName" />
  76. <af-table-column label="状态" align="center">
  77. <template slot-scope="scope">
  78. <el-switch
  79. v-model="scope.row.status"
  80. active-value="1"
  81. inactive-value="0"
  82. @change="handleStatusChange(scope.row)"
  83. ></el-switch>
  84. </template>
  85. </af-table-column>
  86. <af-table-column label="卡片类型" align="center">
  87. <template slot-scope="scope">
  88. {{scope.row.couponType == 1 ? '现金劵' + '--面值:' + scope.row.couponAmt + '元' : ''}}
  89. {{scope.row.couponType == 2 ? '折扣券' + '--折扣:' + scope.row.couponAmt + '% ' : ''}}
  90. {{scope.row.couponType == 3 ? '兑换券' + '--商品:' + scope.row.couponDetails : ''}}
  91. </template>
  92. </af-table-column>
  93. <af-table-column label="使用门槛" align="center">
  94. <template slot-scope="scope">
  95. {{scope.row.couponType == 1 || scope.row.couponType == 2 ? (scope.row.couponThresholdAmt == 0 ? '无门槛':'满' + scope.row.couponThresholdAmt + '元可用') : ''}}
  96. {{scope.row.couponType == 3 ? '------------' : ''}}
  97. </template>
  98. </af-table-column>
  99. <af-table-column label="适用油品" align="center">
  100. <template slot-scope="scope">
  101. {{scope.row.couponType == 1 || scope.row.couponType == 2 ? ((scope.row.oilNameList||[]).toString()) : ''}}
  102. {{scope.row.couponType == 3 ? '------------' : ''}}
  103. </template>
  104. </af-table-column>
  105. <af-table-column label="使用状态" align="center">
  106. <template slot-scope="scope">
  107. {{"共生成了" + scope.row.couponNum + "张,已领取" + scope.row.couponCumulativeNum + '张,已使用'+ scope.row.couponUseNum +'张' }}
  108. </template>
  109. </af-table-column>
  110. <af-table-column label="有效期内使用限制" align="center">
  111. <template slot-scope="scope">
  112. {{ (scope.row.effectiveTimeType == 1 ? scope.row.effectiveTime[0] + '到' + scope.row.effectiveTime[1] : '用户领取'+ scope.row.effectiveDayNum +'天内有效' ) + '内有效'}}
  113. {{ translateTime(scope.row) }}
  114. </template>
  115. </af-table-column>
  116. <af-table-column label="领取限制" align="center">
  117. <template slot-scope="scope">
  118. {{ "单用户最多持有" + scope.row.couponHoldNum + '张,累计可拥有'+ scope.row.couponReceiveNum +'张' }}
  119. </template>
  120. </af-table-column>
  121. <af-table-column label="优惠叠加" align="center">
  122. <template slot-scope="scope">
  123. {{scope.row.couponType == 1 || scope.row.couponType == 2 ? ['不',''][scope.row.isCardFlag] + '可用电子卡,' + ['不',''][scope.row.isGradeFlag] + '可用等级优惠,' + ['不',''][scope.row.isMarketFlag] + '可用优惠方案': ''}}
  124. {{scope.row.couponType == 3 ? '------------' : ''}}
  125. </template>
  126. </af-table-column>
  127. <af-table-column
  128. label="操作"
  129. align="center"
  130. class-name="small-padding fixed-width"
  131. width="120px"
  132. >
  133. <template slot-scope="scope">
  134. <el-button
  135. size="mini"
  136. type="text"
  137. icon="el-icon-edit"
  138. @click="handleUpdate(scope.row)"
  139. v-if="scope.row.editFlag"
  140. >修改</el-button
  141. >
  142. </template>
  143. </af-table-column>
  144. </el-table>
  145. <pagination
  146. :hidden="total > 0 ? false : true"
  147. :total="total"
  148. :page.sync="queryForm.pageNum"
  149. :limit.sync="queryForm.pageSize"
  150. @pagination="getCoupon"
  151. :autoScroll="true"
  152. />
  153. </div>
  154. <div v-else style="text-align:center">
  155. 亲,您的油站暂未启动优惠券功能,呦~
  156. </div>
  157. <!-- 添加或修改油站设备管理对话框 -->
  158. <el-dialog
  159. :title="title"
  160. :visible.sync="open"
  161. width="600px"
  162. append-to-body
  163. status-icon
  164. >
  165. <el-form
  166. ref="dialogForm"
  167. :model="createForm"
  168. :rules="rules"
  169. label-width="180px"
  170. >
  171. <el-form-item label="优惠劵名称(油站备注)" prop="couponName">
  172. <input
  173. type="text"
  174. class="form-control"
  175. v-model="createForm.couponName"
  176. style="width: 180px"
  177. />
  178. </el-form-item>
  179. <el-form-item label="优惠劵内容(用户展示)" prop="couponDetails">
  180. <input
  181. type="text"
  182. class="form-control"
  183. v-model="createForm.couponDetails"
  184. style="width: 180px"
  185. />
  186. </el-form-item>
  187. <el-form-item label="优惠劵使用条件" prop="couponThresholdAmt">
  188. <div>
  189. <input
  190. type="text"
  191. class="form-control d-inline"
  192. v-model.number="createForm.couponThresholdAmt"
  193. style="width: 100px"
  194. />
  195. 元 可用
  196. </div>
  197. </el-form-item>
  198. <el-form-item label="优惠券类型" prop="couponType">
  199. <el-radio-group v-model="createForm.couponType">
  200. <el-radio label="1">现金券</el-radio>
  201. <el-radio label="2">折扣劵</el-radio>
  202. <el-radio label="3">兑换劵</el-radio>
  203. </el-radio-group>
  204. </el-form-item>
  205. <el-form-item
  206. label="优惠金额"
  207. prop="couponAmt"
  208. v-if="createForm.couponType == 1 || createForm.couponType == 2"
  209. >
  210. <div v-if="createForm.couponType == 1">
  211. 固定面值—<input
  212. type="text"
  213. class="form-control d-inline"
  214. v-model.number="createForm.couponAmt"
  215. style="width: 100px"
  216. />
  217. </div>
  218. <div v-if="createForm.couponType == 2">
  219. 折扣比例—<input
  220. type="text"
  221. class="form-control d-inline"
  222. v-model.number="createForm.couponAmt"
  223. style="width: 100px"
  224. />
  225. %
  226. </div>
  227. </el-form-item>
  228. <el-form-item
  229. label="优惠券适用油品"
  230. prop="oilNameList"
  231. v-if="createForm.couponType == 1 || createForm.couponType == 2"
  232. >
  233. <el-checkbox-group v-model="createForm.oilNameList">
  234. <el-checkbox
  235. :label="ele.oilName"
  236. v-for="ele in oilNameList"
  237. :key="ele.oilName"
  238. ></el-checkbox>
  239. </el-checkbox-group>
  240. </el-form-item>
  241. <el-form-item label="优惠券有效期" prop="effectiveTimeType">
  242. <div>
  243. <div>
  244. <el-radio-group v-model="createForm.effectiveTimeType">
  245. <el-radio label="1">固定时间段</el-radio>
  246. <el-radio label="2">固定天数</el-radio>
  247. </el-radio-group>
  248. </div>
  249. <div style="margin-top: 10px">
  250. <div v-if="createForm.effectiveTimeType == 1">
  251. <el-date-picker
  252. style="margin: 0px 10px; width: 300px"
  253. v-model="createForm.effectiveTime"
  254. type="datetimerange"
  255. value-format="yyyy-MM-dd HH:mm:ss"
  256. size="mini"
  257. range-separator="至"
  258. start-placeholder="开始日期"
  259. end-placeholder="结束日期"
  260. >
  261. </el-date-picker>
  262. </div>
  263. <div
  264. v-if="createForm.effectiveTimeType == 2"
  265. style="margin-left: 20px"
  266. >
  267. 自用户领取后
  268. <input
  269. type="text"
  270. class="form-control d-inline"
  271. v-model.number="createForm.effectiveDayNum"
  272. style="width: 80px"
  273. />
  274. 天内有效
  275. </div>
  276. </div>
  277. </div>
  278. </el-form-item>
  279. <el-form-item label="生成优惠券的数量" prop="couponNum">
  280. 共生成
  281. <input
  282. type="text"
  283. class="form-control d-inline"
  284. v-model.number="createForm.couponNum"
  285. style="width: 100px"
  286. />
  287. </el-form-item>
  288. <el-form-item label="单人可持有数量" prop="couponHoldNum">
  289. 单个用户最多持有
  290. <input
  291. type="text"
  292. class="form-control d-inline"
  293. v-model.number="createForm.couponHoldNum"
  294. style="width: 100px"
  295. />
  296. 张优惠券
  297. </el-form-item>
  298. <el-form-item label="累计可拥有数量" prop="couponReceiveNum">
  299. 单个用户累计可以拥有
  300. <input
  301. type="text"
  302. class="form-control d-inline"
  303. v-model.number="createForm.couponReceiveNum"
  304. style="width: 100px"
  305. />
  306. 张优惠券
  307. </el-form-item>
  308. <el-form-item
  309. label="用券时可用电子卡"
  310. prop="isCardFlag"
  311. v-if="createForm.couponType == 1 || createForm.couponType == 2"
  312. >
  313. <el-radio-group v-model="createForm.isCardFlag">
  314. <el-radio label="1">可以使用电子卡</el-radio>
  315. <el-radio label="0">不可用电子卡</el-radio>
  316. </el-radio-group>
  317. </el-form-item>
  318. <el-form-item
  319. label="用券时叠加等级优惠"
  320. prop="isGradeFlag"
  321. v-if="createForm.couponType == 1 || createForm.couponType == 2"
  322. >
  323. <el-radio-group v-model="createForm.isGradeFlag">
  324. <el-radio label="1">叠加等级优惠</el-radio>
  325. <el-radio label="0">不叠加等级优惠</el-radio>
  326. </el-radio-group>
  327. </el-form-item>
  328. <el-form-item
  329. label="用劵时叠加优惠方案"
  330. prop="isMarketFlag"
  331. v-if="createForm.couponType == 1 || createForm.couponType == 2"
  332. >
  333. <el-radio-group v-model="createForm.isMarketFlag">
  334. <el-radio label="1">叠加优惠方案</el-radio>
  335. <el-radio label="0">不叠加优惠方案</el-radio>
  336. </el-radio-group>
  337. </el-form-item>
  338. <el-form-item
  339. label="有效期内可用时间控制"
  340. prop="isMarketFlag2"
  341. v-if="createForm.couponType == 1 || createForm.couponType == 2"
  342. >
  343. <el-radio-group v-model="createForm.availableControl" @change="availableControlChange">
  344. <el-radio label="0">有效期内一直都可用</el-radio>
  345. <el-radio label="1">有效期内每周指定日</el-radio>
  346. <el-radio label="2">有效期内每月指定日</el-radio>
  347. <el-radio label="3">有效期内固定指定日</el-radio>
  348. </el-radio-group>
  349. </el-form-item>
  350. <el-form-item
  351. label="可用时间选择"
  352. prop="isMarketFlag1"
  353. v-if="createForm.availableControl == 1 || createForm.availableControl == 2 || createForm.availableControl == 3"
  354. >
  355. <div>
  356. <select-day :type="createForm.availableControl" :day.sync="createForm.appointedDaysList" :cycle.sync="createForm.cycleDaysList"></select-day>
  357. </div>
  358. </el-form-item>
  359. <el-form-item
  360. label="优惠券的核销方"
  361. prop="couponType"
  362. v-if="createForm.couponType == 3"
  363. >
  364. (自己的站点也是核销商)
  365. </el-form-item>
  366. <div v-if="createForm.couponType == 3">
  367. <el-col :span="11">
  368. <el-table
  369. :data="unselectedCouponList"
  370. border
  371. size="mini"
  372. :resizable="false"
  373. highlight-current-row
  374. height="500"
  375. @selection-change="handleLeftChange"
  376. disabled
  377. ref="leftTable"
  378. >
  379. >
  380. <el-table-column label="可选">
  381. <el-table-column
  382. prop="phone"
  383. label="姓名"
  384. type="selection"
  385. ></el-table-column>
  386. <el-table-column prop="deptName" label="机构"></el-table-column>
  387. <el-table-column label="添加" width="60px" align="center">
  388. <template slot-scope="scope">
  389. <el-button
  390. type="text"
  391. icon="el-icon-circle-plus-outline"
  392. class="underline btn24"
  393. size="mini"
  394. @click="handleMoveLabel('right', scope.row)"
  395. >添加</el-button
  396. >
  397. </template>
  398. </el-table-column>
  399. </el-table-column>
  400. </el-table>
  401. </el-col>
  402. <el-col :span="2" style="text-align: center">
  403. <el-button
  404. type="primary"
  405. size="mini"
  406. @click="toggleLabel"
  407. style="
  408. margin-top: 200px;
  409. text-align: center;
  410. width: 30px;
  411. padding-right: 0;
  412. padding-left: 0;
  413. "
  414. :disabled="toggleable"
  415. >切换</el-button
  416. >
  417. </el-col>
  418. <el-col :span="11">
  419. <el-table
  420. :data="selectedCouponList"
  421. border
  422. size="mini"
  423. highlight-current-row
  424. :resizable="false"
  425. height="500"
  426. @selection-change="handleRightChange"
  427. :loading="true"
  428. ref="rightTable"
  429. >
  430. <el-table-column label="已选" :resizable="false">
  431. <el-table-column
  432. prop="phone"
  433. type="selection"
  434. ></el-table-column>
  435. <el-table-column prop="deptName" label="姓名"></el-table-column>
  436. <el-table-column label="移除" width="60px" align="center">
  437. <template slot-scope="scope">
  438. <el-button
  439. type="text"
  440. icon="el-icon-remove-outline"
  441. class="underline btn24"
  442. size="mini"
  443. @click="handleMoveLabel('left', scope.row)"
  444. >移除</el-button
  445. >
  446. </template>
  447. </el-table-column>
  448. </el-table-column>
  449. </el-table>
  450. </el-col>
  451. </div>
  452. </el-form>
  453. <div slot="footer" class="dialog-footer">
  454. <el-button type="primary" @click="submitForm">确 定</el-button>
  455. <el-button @click="cancel">取 消</el-button>
  456. </div>
  457. </el-dialog>
  458. </div>
  459. </template>
  460. <script>
  461. import { listPrice } from "@/api/station/price";
  462. import SelectDay from "@/components/SelectDay";
  463. import { addInfo, verificationList, listInfo, updateInfo, changeCouponStatus } from "@/api/coupon";
  464. import { updateDept } from "@/api/system/dept";
  465. export default {
  466. name: "Station_Equipment",
  467. data() {
  468. let validateGunNo = (rule, value, callback) => {
  469. callback();
  470. };
  471. return {
  472. couponEnabledFlag: "1",
  473. pageStatus: 4,
  474. // 油站设备管理表格数据
  475. createForm: {
  476. couponName: "",
  477. couponDetails: "",
  478. couponThresholdAmt: 0,
  479. couponType: "1",
  480. couponAmt: '',
  481. oilNameList: [],
  482. effectiveTimeType: "", //有效时间类型: 1,固定时间;2,领取后x天内有效
  483. effectiveTime: [],
  484. effectiveDayNum: 30,
  485. couponHoldNum: 1,
  486. couponReceiveNum: 100,
  487. couponNum: 100,
  488. status: "1",
  489. verificationList: [],
  490. isCardFlag: "1",
  491. isGradeFlag: "1",
  492. isMarketFlag: "1",
  493. availableControl:"0",
  494. appointedDaysList:[],
  495. cycleDaysList:[],
  496. },
  497. couponList: [],
  498. oilNameList: [],
  499. allVerificationList: [
  500. ],
  501. day:[],
  502. cycle:[],
  503. deviceTypeOptions: [],
  504. stationOptions: [],
  505. // 弹出层标题
  506. title: "",
  507. // 是否显示弹出层
  508. open: false,
  509. // 总条数
  510. total: 100,
  511. leftQuery: {},
  512. rightQuery: {},
  513. leftData: [],
  514. rightData: [],
  515. moveRightData: [],
  516. moveLeftData: [],
  517. // 查询参数
  518. queryForm: {
  519. pageNum: 1,
  520. pageSize: 10, // 初始值只能比10大
  521. },
  522. // 表单校验
  523. rules: {},
  524. timeSelect: [
  525. ,
  526. ["周天", "周一", "周二", "周三", "周四", "周五", "周六"],
  527. [
  528. "1号",
  529. "2号",
  530. "3号",
  531. "4号",
  532. "5号",
  533. "6号",
  534. "7号",
  535. "8号",
  536. "9号",
  537. "10号",
  538. "11号",
  539. "12号",
  540. "13号",
  541. "14号",
  542. "15号",
  543. "16号",
  544. "17号",
  545. "18号",
  546. "19号",
  547. "20号",
  548. "21号",
  549. "22号",
  550. "23号",
  551. "24号",
  552. "25号",
  553. "26号",
  554. "27号",
  555. "28号",
  556. "29号",
  557. "30号",
  558. "31号",
  559. ],
  560. ],
  561. };
  562. },
  563. created() {
  564. this.init();
  565. this.getCoupon();
  566. this.setPageStatus();
  567. },
  568. computed: {
  569. toggleable() {
  570. if (this.moveRightData.length === 0 && this.moveLeftData.length === 0) {
  571. return true;
  572. }
  573. return false;
  574. },
  575. selectedCouponList() {
  576. return this.allVerificationList.filter((ele) => {
  577. if(this.createForm.verificationList == null) {
  578. this.createForm.verificationList = [];
  579. }
  580. return this.createForm.verificationList.includes(ele.deptId);
  581. });
  582. },
  583. unselectedCouponList() {
  584. return this.allVerificationList.filter((ele) => {
  585. if(this.createForm.verificationList == null) {
  586. this.createForm.verificationList = [];
  587. }
  588. return !!!this.createForm.verificationList.includes(ele.deptId);
  589. });
  590. },
  591. },
  592. components: {
  593. 'SelectDay': SelectDay
  594. },
  595. methods: {
  596. translateTime(row) {
  597. let timeString = "";
  598. const availableControleType = row.availableControl;
  599. if(availableControleType == 0){
  600. return ',有效期内一直都可以领取'
  601. }
  602. timeString = ',且用户只能在'
  603. if (availableControleType == 1) {
  604. timeString += "每周的";
  605. }
  606. if (availableControleType == 2) {
  607. timeString += "每月的";
  608. }
  609. if (availableControleType == 3) {
  610. timeString += "指定的日期 ";
  611. }
  612. if (availableControleType == 1 || availableControleType == 2) {
  613. row.cycleDaysList.forEach((ele) => {
  614. timeString += this.timeSelect[availableControleType][ele] + "、";
  615. });
  616. } else if (availableControleType == 3) {
  617. timeString += row.appointedDaysList.toString();
  618. }
  619. timeString = timeString.replace(/(、)$/g, "") + "可以使用劵";
  620. return timeString;
  621. },
  622. getTodayDateString(){
  623. const date = new Date()
  624. let y = date.getFullYear();
  625. let m = date.getMonth().toString();
  626. let s = date.getDate().toString();
  627. m = '' + (m.length == 1 ? '0':'') + m
  628. s = '' + (s.length == 1 ? '0':'') + s
  629. console.log('' + h + ':' + m +':' + s)
  630. return '' + y + ':' + m +':' + s
  631. },
  632. availableControlChange(){
  633. this.createForm.appointedDaysList = [];
  634. this.createForm.cycleDaysList = [];
  635. this.createForm = {...this.createForm}
  636. },
  637. handleMoveLabel(direction, row){
  638. console.log(row)
  639. if(this.createForm.verificationList == null) {
  640. this.createForm.verificationList = [];
  641. }
  642. if(direction == "right"){
  643. this.createForm.verificationList.push(row.deptId)
  644. }else{
  645. this.createForm.verificationList = this.createForm.verificationList.filter((ele)=>{
  646. return ele != row.deptId
  647. })
  648. }
  649. },
  650. handleFlagChange() {
  651. const that = this
  652. let text = this.couponEnabledFlag === "1" ? "启用" : "停用";
  653. this.$confirm('确认要"' + text + '"优惠券功能吗?', "警告", {
  654. confirmButtonText: "确定",
  655. cancelButtonText: "取消",
  656. type: "warning",
  657. })
  658. .then(function () {
  659. return changeCouponStatus({
  660. deptId: that.deptId,
  661. couponEnabledFlag: that.couponEnabledFlag,
  662. });
  663. })
  664. .then(() => {
  665. that.msgSuccess(text + "成功");
  666. })
  667. .catch(function () {
  668. that.couponEnabledFlag = that.couponEnabledFlag === "0" ? "1" : "0";
  669. });
  670. },
  671. handleStatusChange(row) {
  672. let text = row.status === "1" ? "启用" : "停用";
  673. this.$confirm(
  674. '确认要"' + text + '""' + row.couponName + '"该优惠券吗?',
  675. "警告",
  676. {
  677. confirmButtonText: "确定",
  678. cancelButtonText: "取消",
  679. type: "warning",
  680. }
  681. )
  682. .then(function () {
  683. return updateInfo({
  684. id: row.id,
  685. status: row.status,
  686. });
  687. })
  688. .then(() => {
  689. this.msgSuccess(text + "成功");
  690. })
  691. .catch(function () {
  692. row.status = row.status === "0" ? "1" : "0";
  693. });
  694. },
  695. getOilList() {
  696. listPrice()
  697. .then((res) => {
  698. if (res.code == 200) {
  699. this.oilNameList = res.rows || [];
  700. } else {
  701. throw new Error("");
  702. }
  703. })
  704. .catch((err) => {
  705. this.msgError("亲,拉取油品列表失败~");
  706. });
  707. },
  708. getCoupon() {
  709. listInfo(this.queryForm)
  710. .then((res) => {
  711. if (res.code == 200) {
  712. console.log(res);
  713. if (res.rows == null) {
  714. this.total = 0;
  715. this.couponList = [];
  716. } else {
  717. this.total = res.total;
  718. this.couponList = res.rows;
  719. }
  720. } else {
  721. throw new Error("");
  722. }
  723. })
  724. .catch((err) => {
  725. this.msgError("亲,拉取优惠券列表失败~");
  726. });
  727. },
  728. getVerificationList() {
  729. verificationList({
  730. pageNum: 1,
  731. pageSize: 1000,
  732. })
  733. .then((res) => {
  734. if (res.code == 200) {
  735. if (res.rows == null) {
  736. this.allVerificationList = [];
  737. } else {
  738. this.allVerificationList = res.rows;
  739. }
  740. } else {
  741. throw new Error("");
  742. }
  743. })
  744. .catch((err) => {
  745. this.msgError("亲,拉取核销机构失败~");
  746. });
  747. },
  748. toggleLabel() {
  749. if (this.moveLeftData.length !== 0) {
  750. this.createForm.verificationList =
  751. this.createForm.verificationList.filter((ele) => {
  752. return ele != this.moveLeftData;
  753. });
  754. this.createForm = { ...this.createForm };
  755. return;
  756. }
  757. if (this.moveRightData.length !== 0) {
  758. this.createForm.verificationList = [
  759. ...new Set(
  760. this.createForm.verificationList.concat(this.moveRightData)
  761. ),
  762. ].filter((ele) => {
  763. return !!ele;
  764. });
  765. this.createForm = { ...this.createForm };
  766. return;
  767. }
  768. return;
  769. },
  770. handleLeftChange(val) {
  771. let changeArr = [];
  772. val.map((ele) => {
  773. changeArr.push(ele.deptId);
  774. });
  775. console.log(changeArr);
  776. this.moveLeftData = [];
  777. this.moveRightData = changeArr;
  778. // console.log(this.moveRightData);
  779. this.$refs.rightTable.clearSelection();
  780. },
  781. handleRightChange(val) {
  782. let changeArr = [];
  783. val.map((ele) => {
  784. changeArr.push(ele.deptId);
  785. });
  786. this.moveLeftData = changeArr;
  787. this.moveRightData = [];
  788. this.$refs.leftTable.clearSelection();
  789. },
  790. init() {
  791. this.getOilList();
  792. this.getCoupon();
  793. this.getVerificationList();
  794. },
  795. setPageStatus() {
  796. this.queryPageStatus([2]).then((res) => {
  797. this.pageStatus = res;
  798. });
  799. },
  800. // 取消按钮
  801. cancel() {
  802. this.open = false;
  803. },
  804. /** 搜索按钮操作 */
  805. handleQuery() {
  806. this.createForm.pageNum = 1;
  807. this.getList();
  808. },
  809. deviceNoInput(value) {
  810. this.dialogForm.posQueue = value;
  811. },
  812. /** 重置按钮操作 */
  813. resetQuery() {
  814. this.resetForm("createForm");
  815. this.handleQuery();
  816. },
  817. /** 新增按钮操作 */
  818. handleAdd() {
  819. this.title = "添加优惠券";
  820. this.createForm = {
  821. couponName: "",
  822. couponDetails: "",
  823. couponThresholdAmt: 0,
  824. couponType: "1",
  825. couponAmt: '',
  826. oilNameList: [],
  827. effectiveTimeType: "", //有效时间类型: 1,固定时间;2,领取后x天内有效
  828. effectiveTime: [],
  829. effectiveDayNum: 30,
  830. couponHoldNum: 1,
  831. couponReceiveNum: 100,
  832. couponNum: 100,
  833. status: "1",
  834. verificationList: [],
  835. isCardFlag: "1",
  836. isGradeFlag: "1",
  837. isMarketFlag: "1",
  838. availableControl:"0",
  839. appointedDaysList:[],
  840. cycleDaysList:[],
  841. }
  842. this.open = true;
  843. },
  844. /** 修改按钮操作 */
  845. handleUpdate(row) {
  846. // // 查找自己已经选中的枪号
  847. this.createForm = JSON.parse(JSON.stringify(row));
  848. this.title = "修改油站设备管理";
  849. this.open = true;
  850. },
  851. /** 提交按钮 */
  852. submitForm() {
  853. this.$refs["dialogForm"].validate((valid) => {
  854. if (valid) {
  855. if(!!this.createForm.id){
  856. updateInfo(this.createForm).then((res) => {
  857. if(res.code == 200){
  858. this.msgSuccess("亲,修改成功了~")
  859. this.getCoupon()
  860. this.open = false
  861. }else{
  862. throw new Error("");
  863. }
  864. }).catch((err) => {
  865. this.msgError("修改失败了呀~")
  866. });
  867. }else{
  868. addInfo(this.createForm).then((res) => {
  869. if(res.code == 200){
  870. this.msgSuccess("亲,新增成功了~")
  871. this.getCoupon()
  872. this.open = false
  873. }else{
  874. throw new Error("");
  875. }
  876. }).catch((err)=>{
  877. this.msgError("创建优惠劵失败了~")
  878. });
  879. }
  880. }
  881. });
  882. },
  883. /** 删除按钮操作 */
  884. handleDelete(row) {
  885. // const deviceIds = row.deviceId;
  886. // this.$confirm("是否确认删除油站设备管理", "警告", {
  887. // confirmButtonText: "确定",
  888. // cancelButtonText: "取消",
  889. // type: "warning",
  890. // })
  891. // .then(function () {
  892. // return delManage(deviceIds);
  893. // })
  894. // .then(() => {
  895. // this.getList();
  896. // this.msgSuccess("删除成功");
  897. // });
  898. },
  899. },
  900. };
  901. </script>
  902. <style lang="scss">
  903. .el-transfer__buttons {
  904. }
  905. </style>