index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <PermissionContainer
  3. :jiBieArr="[1, 2]"
  4. :type="3"
  5. :tipArr="[
  6. ,
  7. '优惠券功能只对集团和站点级别开放',
  8. '因为集团上关于优惠券的共享配置,此级没有配置权限',
  9. ,
  10. '您暂未启动优惠券功能',
  11. ]"
  12. >
  13. <div>
  14. <el-tabs v-model="activeName">
  15. <el-tab-pane label="实时发放" name="realTime" :key="'info'">
  16. <child1></child1>
  17. </el-tab-pane>
  18. <el-tab-pane label="按发放方式" name="issue" :key="'issue'">
  19. <child2></child2>
  20. </el-tab-pane>
  21. <el-tab-pane label="按优惠券类" name="model" :key="'pay'">
  22. <child3></child3>
  23. </el-tab-pane>
  24. </el-tabs>
  25. </div>
  26. </PermissionContainer>
  27. </template>
  28. <script>
  29. import {
  30. listManage,
  31. getManage,
  32. delManage,
  33. addManage,
  34. updateManage,
  35. exportManage,
  36. changeManageStatus,
  37. } from "@/api/station/manage";
  38. import { listPrice } from "@/api/station/price";
  39. import tabZujianChild1 from "./realTime.vue";
  40. import tabZujianChild2 from "./issue.vue";
  41. import tabZujianChild3 from "./model.vue";
  42. import Vue from "vue";
  43. import VueClipboard from "vue-clipboard2";
  44. import Qr from "@/components/QrCode";
  45. import Base64 from "@/utils/base64";
  46. Vue.use(VueClipboard);
  47. import {
  48. addInfo,
  49. listInfo,
  50. updateInfo,
  51. changeCouponStatus,
  52. addIssue,
  53. listIssue,
  54. upIssueStatus,
  55. } from "@/api/coupon";
  56. import SelectDay from "@/components/SelectDay";
  57. import settings from "@/settings";
  58. export default {
  59. name: "Coupon_CreateIssue",
  60. data() {
  61. let validateGunNo = (rule, value, callback) => {
  62. callback();
  63. };
  64. let validateAvailableControl = (rule, value, callback) => {
  65. if (
  66. this.createForm.availableControl == 1 ||
  67. this.createForm.availableControl == 2
  68. ) {
  69. if (this.createForm.cycleDaysList.length == 0) {
  70. callback(new Error("请选择时间"));
  71. return;
  72. }
  73. }
  74. if (this.createForm.availableControl == 3) {
  75. if (this.createForm.appointedDaysList.length == 0) {
  76. callback(new Error("请选择日期"));
  77. return;
  78. }
  79. }
  80. callback();
  81. };
  82. let validateCouponIssueRelationList = (rule, value, callback) => {
  83. if (this.createForm.couponIssueRelationList.length == 0) {
  84. callback(new Error("请选择优惠券"));
  85. }
  86. callback();
  87. };
  88. return {
  89. activeName: "realTime",
  90. couponEnabledFlag: "1",
  91. exportQrDialog: false,
  92. pageStatus: 4,
  93. createForm: {
  94. issueRemark: "",
  95. issueName: "",
  96. showIdList: [],
  97. availableControl: "0",
  98. appointedDaysList: [],
  99. cycleDaysList: [],
  100. issueType: "",
  101. discountThresholdAmt: "0",
  102. couponIssueRelationList: [],
  103. giveLimit: 9,
  104. giveCount: 999999,
  105. },
  106. currentExport: {
  107. text: "error",
  108. type: "你好",
  109. name: "二维码",
  110. },
  111. couponList: [],
  112. oilNameList: [],
  113. allVerificationList: [],
  114. equipmentList: [],
  115. // 油枪复选
  116. allGunList: [],
  117. // 已选的油枪
  118. checkedGunList: [],
  119. //设备状态
  120. deviceStatusOptions: [],
  121. //设备类型
  122. deviceTypeOptions: [],
  123. stationOptions: [],
  124. // 弹出层标题
  125. title: "",
  126. // 是否显示弹出层
  127. open: false,
  128. // 总条数
  129. total: 100,
  130. leftQuery: {},
  131. rightQuery: {},
  132. leftData: [],
  133. rightData: [],
  134. moveRightData: [],
  135. moveLeftData: [],
  136. // 查询参数
  137. queryForm: {
  138. pageNum: 1,
  139. pageSize: 10, // 初始值只能比10大
  140. },
  141. // 表单校验
  142. rules: {
  143. availableControl: [
  144. {
  145. required: true,
  146. message: "请选择有效期内时间控制",
  147. trigger: "change",
  148. },
  149. { validator: validateAvailableControl, trigger: "change" },
  150. ],
  151. couponIssueRelationList: [
  152. {
  153. required: true,
  154. message: "请选择优惠券",
  155. trigger: "change",
  156. },
  157. { validator: validateCouponIssueRelationList, trigger: "change" },
  158. ],
  159. },
  160. day: [],
  161. cycle: [],
  162. issueList: [],
  163. timeSelect: [
  164. ,
  165. ["周天", "周一", "周二", "周三", "周四", "周五", "周六"],
  166. [
  167. "1号",
  168. "2号",
  169. "3号",
  170. "4号",
  171. "5号",
  172. "6号",
  173. "7号",
  174. "8号",
  175. "9号",
  176. "10号",
  177. "11号",
  178. "12号",
  179. "13号",
  180. "14号",
  181. "15号",
  182. "16号",
  183. "17号",
  184. "18号",
  185. "19号",
  186. "20号",
  187. "21号",
  188. "22号",
  189. "23号",
  190. "24号",
  191. "25号",
  192. "26号",
  193. "27号",
  194. "28号",
  195. "29号",
  196. "30号",
  197. "31号",
  198. ],
  199. ],
  200. };
  201. },
  202. components: {
  203. SelectDay: SelectDay,
  204. Qr: Qr,
  205. VueClipboard: VueClipboard,
  206. child1: tabZujianChild1,
  207. child2: tabZujianChild2,
  208. child3: tabZujianChild3,
  209. },
  210. created() {
  211. console.log("哈哈");
  212. console.log("settings", settings);
  213. // this.init();
  214. this.getCoupon();
  215. // this.setPageStatus();
  216. this.getIssueList();
  217. },
  218. computed: {
  219. toggleable() {
  220. if (this.moveRightData.length === 0 && this.moveLeftData.length === 0) {
  221. return true;
  222. }
  223. return false;
  224. },
  225. selectedCouponList() {
  226. return this.couponList.filter((ele) => {
  227. if (this.createForm.couponIssueRelationList == null) {
  228. this.createForm.couponIssueRelationList = [];
  229. }
  230. return this.createForm.couponIssueRelationList.includes(ele.id);
  231. });
  232. },
  233. unselectedCouponList() {
  234. return this.couponList.filter((ele) => {
  235. if (this.createForm.couponIssueRelationList == null) {
  236. this.createForm.couponIssueRelationList = [];
  237. }
  238. return !!!this.createForm.couponIssueRelationList.includes(ele.id);
  239. });
  240. },
  241. getTodayDateString() {
  242. const date = new Date();
  243. let y = date.getFullYear();
  244. let m = date.getMonth().toString();
  245. let s = date.getDate().toString();
  246. m = "" + (m.length == 1 ? "0" : "") + m;
  247. s = "" + (s.length == 1 ? "0" : "") + s;
  248. console.log("" + h + ":" + m + ":" + s);
  249. return "" + y + ":" + m + ":" + s;
  250. },
  251. },
  252. methods: {
  253. onCopySuccess() {
  254. this.msgSuccess("网址已经拷贝到剪切板");
  255. },
  256. onCopyError() {
  257. this.msgError("网址拷贝失败,请手动复制");
  258. },
  259. // exportUrl(url){
  260. // this.currentExport.name = emp.personnelName;
  261. // this.currentExport.type = 1;
  262. // const encodeStr = "e" + emp.personnelId + "/l" + this.currentExport.labelId + "/";
  263. // const encodedStr = this.base.encode(encodeStr);
  264. // const trimEqualStr = encodedStr.replace(/={1,}$/g, "");
  265. // this.currentExport.text = "https://goto.huijy.net/" + this.deptId + "/" + trimEqualStr;
  266. // this.exportQrDialog = true;
  267. // },
  268. handleExport(row) {
  269. this.currentExport.name = row.issueName;
  270. const base64 = Base64.getInstance();
  271. const encodeStr = "i" + row.id;
  272. const encodedStr = base64.encode(encodeStr);
  273. const trimEqualStr = encodedStr.replace(/={1,}$/g, "");
  274. this.exportQrDialog = true;
  275. this.currentExport.text =
  276. settings.baseURL + this.deptId + "/" + trimEqualStr;
  277. },
  278. downloadImg() {
  279. console.log("");
  280. },
  281. translateTime(row) {
  282. let timeString = "";
  283. const availableControleType = row.availableControl;
  284. if (availableControleType == 0) {
  285. return "用户一直都可以领取";
  286. }
  287. timeString = "用户只能在";
  288. if (availableControleType == 1) {
  289. timeString += "每周的";
  290. }
  291. if (availableControleType == 2) {
  292. timeString += "每月的";
  293. }
  294. if (availableControleType == 3) {
  295. timeString += "指定的日期 ";
  296. }
  297. if (availableControleType == 1 || availableControleType == 2) {
  298. row.cycleDaysList.forEach((ele) => {
  299. timeString += this.timeSelect[availableControleType][ele] + "、";
  300. });
  301. } else if (availableControleType == 3) {
  302. timeString += row.appointedDaysList.toString();
  303. }
  304. timeString = timeString.replace(/(、)$/g, "") + "可以领取劵";
  305. return timeString;
  306. },
  307. getIssueList() {
  308. listIssue(this.queryForm)
  309. .then((res) => {
  310. if (res.code == 200) {
  311. if (res.rows == null) {
  312. this.total = 0;
  313. this.issueList = [];
  314. } else {
  315. this.total = res.total;
  316. this.issueList = res.rows;
  317. }
  318. } else {
  319. throw new Error("");
  320. }
  321. })
  322. .catch((err) => {
  323. this.msgError("亲,拉取领取方式列表失败~");
  324. });
  325. },
  326. getCoupon() {
  327. listInfo({
  328. pageNum: 1,
  329. pageSize: 1000,
  330. status: 1,
  331. })
  332. .then((res) => {
  333. if (res.code == 200) {
  334. if (res.rows == null) {
  335. this.couponList = [];
  336. } else {
  337. this.couponList = res.rows;
  338. }
  339. } else {
  340. throw new Error("");
  341. }
  342. })
  343. .catch((err) => {
  344. this.msgError("亲,拉取优惠券列表失败~");
  345. });
  346. },
  347. availableControlChange() {
  348. this.createForm.appointedDaysList = [];
  349. this.createForm.cycleDaysList = [];
  350. this.createForm = { ...this.createForm };
  351. },
  352. handleMoveLabel(direction, row) {
  353. console.log(row);
  354. if (this.createForm.couponIssueRelationList == null) {
  355. this.createForm.couponIssueRelationList = [];
  356. }
  357. if (direction == "right") {
  358. this.createForm.couponIssueRelationList.push(row.id);
  359. } else {
  360. this.createForm.couponIssueRelationList =
  361. this.createForm.couponIssueRelationList.filter((ele) => {
  362. return ele != row.id;
  363. });
  364. }
  365. },
  366. handleFlagChange() {
  367. const that = this;
  368. let text = this.couponEnabledFlag === "1" ? "启用" : "停用";
  369. this.$confirm('确认要"' + text + '"优惠券功能吗?', "警告", {
  370. confirmButtonText: "确定",
  371. cancelButtonText: "取消",
  372. type: "warning",
  373. })
  374. .then(function () {
  375. return changeCouponStatus({
  376. deptId: that.deptId,
  377. couponEnabledFlag: that.couponEnabledFlag,
  378. });
  379. })
  380. .then(() => {
  381. that.msgSuccess(text + "成功");
  382. })
  383. .catch(function () {
  384. that.couponEnabledFlag = that.couponEnabledFlag === "0" ? "1" : "0";
  385. });
  386. },
  387. handleStatusChange(row) {
  388. let text = row.status === "1" ? "启用" : "停用";
  389. this.$confirm(
  390. '确认要"' + text + '""' + row.issueName + '"发放方式吗?',
  391. "警告",
  392. {
  393. confirmButtonText: "确定",
  394. cancelButtonText: "取消",
  395. type: "warning",
  396. }
  397. )
  398. .then(function () {
  399. return upIssueStatus({
  400. id: row.id,
  401. status: row.status,
  402. });
  403. })
  404. .then(() => {
  405. this.msgSuccess(text + "成功");
  406. })
  407. .catch(function () {
  408. row.status = row.status === "0" ? "1" : "0";
  409. });
  410. },
  411. toggleLabel() {
  412. if (this.moveLeftData.length !== 0) {
  413. this.createForm.couponIssueRelationList =
  414. this.createForm.couponIssueRelationList.filter((ele) => {
  415. return ele != this.moveLeftData;
  416. });
  417. this.createForm = { ...this.createForm };
  418. return;
  419. }
  420. if (this.moveRightData.length !== 0) {
  421. this.createForm.couponIssueRelationList = [
  422. ...new Set(
  423. this.createForm.couponIssueRelationList.concat(this.moveRightData)
  424. ),
  425. ].filter((ele) => {
  426. return !!ele;
  427. });
  428. this.createForm = { ...this.createForm };
  429. return;
  430. }
  431. return;
  432. },
  433. handleLeftChange(val) {
  434. let changeArr = [];
  435. val.map((ele) => {
  436. changeArr.push(ele.id);
  437. });
  438. console.log(changeArr);
  439. this.moveLeftData = [];
  440. this.moveRightData = changeArr;
  441. // console.log(this.moveRightData);
  442. this.$refs.rightTable.clearSelection();
  443. },
  444. handleRightChange(val) {
  445. let changeArr = [];
  446. val.map((ele) => {
  447. changeArr.push(ele.id);
  448. });
  449. this.moveLeftData = changeArr;
  450. this.moveRightData = [];
  451. this.$refs.leftTable.clearSelection();
  452. },
  453. init() {
  454. this.getOilList();
  455. this.getCoupon();
  456. this.getVerificationList();
  457. },
  458. setPageStatus() {
  459. this.queryPageStatus([2]).then((res) => {
  460. this.pageStatus = res;
  461. });
  462. },
  463. // 取消按钮
  464. cancel() {
  465. this.open = false;
  466. },
  467. /** 搜索按钮操作 */
  468. handleQuery() {
  469. this.createForm.pageNum = 1;
  470. this.getList();
  471. },
  472. deviceNoInput(value) {
  473. this.dialogForm.posQueue = value;
  474. },
  475. /** 重置按钮操作 */
  476. resetQuery() {
  477. this.resetForm("createForm");
  478. this.handleQuery();
  479. },
  480. /** 新增按钮操作 */
  481. handleAdd() {
  482. this.createForm = {
  483. issueRemark: "",
  484. issueName: "",
  485. showIdList: [],
  486. availableControl: "0",
  487. appointedDaysList: [],
  488. cycleDaysList: [],
  489. issueType: "",
  490. discountThresholdAmt: "0",
  491. couponIssueRelationList: [],
  492. giveLimit: 9,
  493. giveCount: 999999,
  494. };
  495. this.title = "添加优惠券";
  496. // this.createForm = {
  497. // couponName: "",
  498. // couponDetails: "",
  499. // couponThresholdAmt: 0,
  500. // couponType: "1",
  501. // couponAmt: 0,
  502. // oilNameList: [],
  503. // effectiveTimeType: "",
  504. // effectiveTime: [],
  505. // effectiveDayNum: 30,
  506. // couponHoldNum: 1,
  507. // couponReceiveNum: 100,
  508. // couponNum: 100,
  509. // status: "1",
  510. // couponIssueRelationList: [],
  511. // isCardFlag: "1",
  512. // isGradeFlag: "1",
  513. // isMarketFlag: "1",
  514. // };
  515. this.open = true;
  516. },
  517. /** 修改按钮操作 */
  518. handleUpdate(row) {
  519. // // 查找自己已经选中的枪号
  520. this.createForm = JSON.parse(JSON.stringify(row));
  521. this.title = "修改油站设备管理";
  522. this.open = true;
  523. },
  524. /** 提交按钮 */
  525. submitForm() {
  526. console.log(123);
  527. this.$refs["dialogForm"].validate((valid) => {
  528. if (valid) {
  529. if (!!this.createForm.id) {
  530. updateIssue(this.createForm)
  531. .then((res) => {
  532. if (res.code == 200) {
  533. this.msgSuccess("亲,修改成功了~");
  534. this.getIssueList();
  535. this.open = false;
  536. } else {
  537. throw new Error("");
  538. }
  539. })
  540. .catch((err) => {
  541. this.msgError("修改失败了呀~");
  542. });
  543. } else {
  544. addIssue(this.createForm)
  545. .then((res) => {
  546. if (res.code == 200) {
  547. this.msgSuccess("亲,新增成功了~");
  548. this.getIssueList();
  549. this.open = false;
  550. } else {
  551. throw new Error("");
  552. }
  553. })
  554. .catch((err) => {
  555. this.msgError("创建失败了~");
  556. });
  557. }
  558. }
  559. });
  560. },
  561. /** 删除按钮操作 */
  562. handleDelete(row) {
  563. const deviceIds = row.deviceId;
  564. this.$confirm("是否确认删除油站设备管理", "警告", {
  565. confirmButtonText: "确定",
  566. cancelButtonText: "取消",
  567. type: "warning",
  568. })
  569. .then(function () {
  570. return delManage(deviceIds);
  571. })
  572. .then(() => {
  573. this.getList();
  574. this.msgSuccess("删除成功");
  575. });
  576. },
  577. },
  578. };
  579. </script>
  580. <style lang="scss">
  581. .el-transfer__buttons {
  582. }
  583. </style>