Coupon_CreateCoupon.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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. :model="queryForm"
  11. ref="queryForm"
  12. :inline="true"
  13. label-width="88px"
  14. >
  15. <el-form-item label="设备类型" prop="deviceType">
  16. <el-select
  17. v-model="queryForm.deviceType"
  18. clearable
  19. placeholder="请选择"
  20. >
  21. <el-option label="小票打印机" value="1"></el-option>
  22. <el-option label="POS" value="2"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="密钥" prop="deviceSerialNum">
  26. <el-input
  27. v-model="queryForm.deviceSerialNum"
  28. placeholder="请输入设备密钥"
  29. clearable
  30. size="small"
  31. @keyup.enter.native="handleQuery"
  32. />
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button
  36. type="cyan"
  37. icon="el-icon-search"
  38. size="mini"
  39. @click="handleQuery"
  40. >搜索</el-button
  41. >
  42. <el-button
  43. type="info"
  44. icon="el-icon-refresh"
  45. size="mini"
  46. @click="resetQuery"
  47. >重置</el-button
  48. >
  49. <el-button
  50. type="primary"
  51. icon="el-icon-plus"
  52. size="mini"
  53. @click="handleAdd"
  54. >新增</el-button
  55. >
  56. </el-form-item>
  57. </el-form>
  58. <el-table :data="equipmentList">
  59. <af-table-column label="优惠" align="center" prop="deviceType">
  60. <template slot-scope="scope">
  61. {{
  62. scope.row.deviceType == "1"
  63. ? "小票打印机"
  64. : scope.row.deviceType == "2"
  65. ? "POS"
  66. : "不明设备"
  67. }}
  68. </template>
  69. </af-table-column>
  70. <af-table-column label="优惠券名称" align="center" prop="deviceNo" />
  71. <af-table-column label="面值" align="center" prop="gunNo" />
  72. <af-table-column label="有效期" align="center" prop="deviceFactory" />
  73. <af-table-column
  74. label="操作"
  75. align="center"
  76. class-name="small-padding fixed-width"
  77. width="120px"
  78. >
  79. <template slot-scope="scope">
  80. <el-button
  81. size="mini"
  82. type="text"
  83. icon="el-icon-edit"
  84. @click="handleUpdate(scope.row)"
  85. >修改</el-button
  86. >
  87. <el-button
  88. size="mini"
  89. type="text"
  90. icon="el-icon-delete"
  91. @click="handleDelete(scope.row)"
  92. >删除</el-button
  93. >
  94. </template>
  95. </af-table-column>
  96. </el-table>
  97. <pagination
  98. :hidden="total > 0 ? false : true"
  99. :total="total"
  100. :page.sync="queryForm.pageNum"
  101. :limit.sync="queryForm.pageSize"
  102. @pagination="getList"
  103. :autoScroll="true"
  104. />
  105. <!-- 添加或修改油站设备管理对话框 -->
  106. <el-dialog
  107. :title="title"
  108. :visible.sync="open"
  109. width="600px"
  110. append-to-body
  111. status-icon
  112. >
  113. <el-form
  114. ref="dialogForm"
  115. :model="dialogForm"
  116. :rules="rules"
  117. label-width="180px"
  118. >
  119. <el-form-item label="优惠劵名称(油站备注)" prop="couponName">
  120. <input
  121. type="text"
  122. class="form-control"
  123. v-model="queryParams.couponName"
  124. style="width: 180px"
  125. />
  126. </el-form-item>
  127. <el-form-item label="优惠劵内容(用户展示)" prop="couponDetails">
  128. <input
  129. type="text"
  130. class="form-control"
  131. v-model="queryParams.couponDetails"
  132. style="width: 180px"
  133. />
  134. </el-form-item>
  135. <el-form-item label="优惠劵使用条件" prop="couponThresholdAmt">
  136. <div>
  137. <input
  138. type="text"
  139. class="form-control d-inline"
  140. v-model.number="queryParams.couponThresholdAmt"
  141. style="width: 100px"
  142. />
  143. 元 可用
  144. </div>
  145. </el-form-item>
  146. <el-form-item label="优惠券类型" prop="couponType">
  147. <el-radio-group v-model="queryParams.couponType">
  148. <el-radio label="1">现金券</el-radio>
  149. <el-radio label="2">折扣劵</el-radio>
  150. <el-radio label="3">兑换劵</el-radio>
  151. </el-radio-group>
  152. </el-form-item>
  153. <el-form-item label="优惠金额"
  154. prop="couponAmt"
  155. v-if="queryParams.couponType == 1 ||queryParams.couponType == 2"
  156. >
  157. <div v-if="queryParams.couponType == 1">
  158. 固定面值—<input
  159. type="text"
  160. class="form-control d-inline"
  161. v-model.number="queryParams.couponAmt"
  162. style="width: 100px"
  163. />
  164. </div>
  165. <div v-if="queryParams.couponType == 2">
  166. 折扣比例—<input
  167. type="text"
  168. class="form-control d-inline"
  169. v-model.number="queryParams.couponAmt"
  170. style="width: 100px"
  171. />
  172. %
  173. </div>
  174. </el-form-item>
  175. <el-form-item label="优惠券适用油品" prop="oilNameList">
  176. <el-checkbox-group v-model="queryParams.oilNameList">
  177. <el-checkbox label="92#"></el-checkbox>
  178. <el-checkbox label="93#"></el-checkbox>
  179. <el-checkbox label="94#"></el-checkbox>
  180. </el-checkbox-group>
  181. </el-form-item>
  182. <el-form-item label="优惠券有效期" prop="effectiveTimeType">
  183. <div>
  184. <div>
  185. <el-radio-group v-model="queryParams.effectiveTimeType">
  186. <el-radio label="1">固定时间段</el-radio>
  187. <el-radio label="2">固定天数</el-radio>
  188. </el-radio-group>
  189. </div>
  190. <div style="margin-top: 10px; ">
  191. <div v-if="queryParams.effectiveTimeType == 1">
  192. <el-date-picker
  193. style="margin: 0px 10px; width: 300px"
  194. v-model="queryParams.dateRangeCreatedDate"
  195. type="datetimerange"
  196. value-format="yyyy-MM-dd HH:mm:ss"
  197. size="mini"
  198. range-separator="至"
  199. start-placeholder="开始日期"
  200. end-placeholder="结束日期"
  201. >
  202. </el-date-picker>
  203. </div>
  204. <div v-if="queryParams.effectiveTimeType == 2" style="margin-left: 20px">
  205. 自用户领取后
  206. <input
  207. type="text"
  208. class="form-control d-inline"
  209. v-model.number="queryParams.effectiveDayNum"
  210. style="width: 80px"
  211. />
  212. 天内有效
  213. </div>
  214. </div>
  215. </div>
  216. </el-form-item>
  217. <el-form-item label="生成优惠券的数量" prop="couponNum">
  218. 共生成
  219. <input
  220. type="text"
  221. class="form-control d-inline"
  222. v-model.number="queryParams.couponNum"
  223. style="width: 100px"
  224. />
  225. </el-form-item>
  226. <el-form-item label="单人可持有数量" prop="couponHoldNum">
  227. 单个用户最多拥有
  228. <input
  229. type="text"
  230. class="form-control d-inline"
  231. v-model.number="queryParams.couponHoldNum"
  232. style="width: 100px"
  233. />
  234. 张优惠券
  235. </el-form-item>
  236. <el-form-item label="累计可拥有数量" prop="couponReceiveNum">
  237. 单个用户累计可以拥有
  238. <input
  239. type="text"
  240. class="form-control d-inline"
  241. v-model.number="queryParams.couponReceiveNum"
  242. style="width: 100px"
  243. />
  244. 张优惠券
  245. </el-form-item>
  246. <el-form-item label="优惠券的核销方" prop="couponType" v-if="queryParams.couponType == 3">
  247. (自己的站点也是核销商)
  248. </el-form-item>
  249. <div v-if="queryParams.couponType == 3">
  250. <el-col :span="11">
  251. <el-table
  252. :data="unselectedCouponList"
  253. border
  254. size="mini"
  255. :resizable="false"
  256. highlight-current-row
  257. height="500"
  258. @selection-change="handleLeftChange"
  259. disabled
  260. ref="leftTable"
  261. >
  262. >
  263. <el-table-column label="可选">
  264. <el-table-column
  265. prop="phone"
  266. label="姓名"
  267. type="selection"
  268. ></el-table-column>
  269. <el-table-column
  270. prop="deptName"
  271. label="机构"
  272. ></el-table-column>
  273. <el-table-column label="添加" width="60px" align="center">
  274. <template slot-scope="scope">
  275. <el-button
  276. type="text"
  277. icon="el-icon-circle-plus-outline"
  278. class="underline btn24"
  279. size="mini"
  280. @click="handleMoveLabel('right', 1, scope.row)"
  281. >添加</el-button>
  282. </template>
  283. </el-table-column>
  284. </el-table-column>
  285. </el-table>
  286. </el-col>
  287. <el-col :span="2" style="text-align: center;">
  288. <el-button type="primary" size="mini" @click="toggleLabel" style="margin-top:200px;text-align:center;width:30px;padding-right:0;padding-left:0;" :disabled="toggleable">切换</el-button>
  289. </el-col>
  290. <el-col :span="11">
  291. <el-table
  292. :data="selectedCouponList"
  293. border
  294. size="mini"
  295. highlight-current-row
  296. :resizable="false"
  297. height="500"
  298. @selection-change="handleRightChange"
  299. :loading="true"
  300. ref="rightTable"
  301. >
  302. <el-table-column label="已选" :resizable="false">
  303. <el-table-column
  304. prop="phone"
  305. type="selection"
  306. ></el-table-column>
  307. <el-table-column
  308. prop="deptName"
  309. label="姓名"
  310. ></el-table-column>
  311. <el-table-column label="移除" width="60px" align="center">
  312. <template slot-scope="scope">
  313. <el-button
  314. type="text"
  315. icon="el-icon-remove-outline"
  316. class="underline btn24"
  317. size="mini"
  318. @click="handleMoveLabel('left', 1, scope.row)"
  319. >移除</el-button
  320. >
  321. </template>
  322. </el-table-column>
  323. </el-table-column>
  324. </el-table>
  325. </el-col>
  326. </div>
  327. </el-form>
  328. <div slot="footer" class="dialog-footer">
  329. <el-button type="primary" @click="submitForm">确 定</el-button>
  330. <el-button @click="cancel">取 消</el-button>
  331. </div>
  332. </el-dialog>
  333. </div>
  334. </template>
  335. <script>
  336. import {
  337. listManage,
  338. getManage,
  339. delManage,
  340. addManage,
  341. updateManage,
  342. exportManage,
  343. changeManageStatus,
  344. } from "@/api/station/manage";
  345. import { listGun } from "@/api/station/gun";
  346. import { addInfo,verificationList } from "@/api/coupon";
  347. export default {
  348. name: "Station_Equipment",
  349. data() {
  350. let validateGunNo = (rule, value, callback) => {
  351. callback();
  352. };
  353. return {
  354. pageStatus: 4,
  355. // 油站设备管理表格数据
  356. queryParams: {
  357. couponName: "",
  358. couponDetails:'',
  359. couponThresholdAmt: 0,
  360. couponType: "1",
  361. couponAmt: 0,
  362. oilNameList: [],
  363. effectiveTimeType: "", //有效时间类型: 1,固定时间;2,领取后x天内有效
  364. effectiveDayNum: 3,
  365. couponHoldNum: 2,
  366. couponReceiveNum: 1,
  367. couponNum: 100,
  368. status: 1,
  369. verificationList: [2,5,7],
  370. },
  371. couponList: [{
  372. deptId: 1,
  373. deptName:'固定1'
  374. },{
  375. deptId: 2,
  376. deptName:'油站2'
  377. },{
  378. deptId: 3,
  379. deptName:'固定3'
  380. },{
  381. deptId: 4,
  382. deptName:'油站4'
  383. },{
  384. deptId: 5,
  385. deptName:'固定5'
  386. },{
  387. deptId: 6,
  388. deptName:'油站6'
  389. },{
  390. deptId: 7,
  391. deptName:'油站7'
  392. }],
  393. equipmentList: [],
  394. // 油枪复选
  395. allGunList: [],
  396. // 已选的油枪
  397. checkedGunList: [],
  398. //设备状态
  399. deviceStatusOptions: [],
  400. //设备类型
  401. deviceTypeOptions: [],
  402. stationOptions: [],
  403. // 弹出层标题
  404. title: "",
  405. // 是否显示弹出层
  406. open: false,
  407. // 总条数
  408. total: 100,
  409. leftQuery:{},
  410. rightQuery:{},
  411. leftData:[],
  412. rightData:[],
  413. moveRightData: [],
  414. moveLeftData:[],
  415. // 查询参数
  416. queryForm: {
  417. pageNum: 1,
  418. pageSize: 10, // 初始值只能比10大
  419. deviceNo: null,
  420. deviceSerialNum: null, // 设备密钥
  421. },
  422. // 表单校验
  423. rules: {
  424. },
  425. };
  426. },
  427. created() {
  428. console.log("111111111111111111111")
  429. this.init();
  430. this.setPageStatus();
  431. },
  432. computed: {
  433. toggleable(){
  434. if(this.moveRightData.length === 0 && this.moveLeftData.length === 0){
  435. return true;
  436. }
  437. return false;
  438. },
  439. selectedCouponList(){
  440. return this.couponList.filter((ele)=>{
  441. return this.queryParams.verificationList.includes(ele.deptId)
  442. })
  443. },
  444. unselectedCouponList(){
  445. return this.couponList.filter((ele)=>{
  446. return !!!this.queryParams.verificationList.includes(ele.deptId)
  447. })
  448. },
  449. getTodayDateString(){
  450. const today = new Date()
  451. // const day = today.getD()
  452. return
  453. },
  454. posList() {
  455. // 排除其他pos已经添加过的
  456. const temp = this.allGunList.filter((item) => {
  457. let flag = false;
  458. this.equipmentList.map((ele) => {
  459. if (ele.deviceType == 2) {
  460. if (ele.gunNo.split(",").includes(item.oilGunNo)) {
  461. flag = true;
  462. return;
  463. }
  464. }
  465. });
  466. return flag;
  467. });
  468. // 查找自己的
  469. const temp2 = this.allGunList.filter((item) => {
  470. let flag = true;
  471. temp.map((ele) => {
  472. if (item.oilGunNo == ele.oilGunNo) {
  473. flag = false;
  474. }
  475. });
  476. return flag;
  477. });
  478. return this.currentList.concat(temp2);
  479. },
  480. printList() {
  481. const temp = this.allGunList.filter((item) => {
  482. let flag = false;
  483. this.equipmentList.map((ele) => {
  484. if (ele.deviceType == 1) {
  485. if (ele.gunNo.split(",").includes(item.oilGunNo)) {
  486. flag = true;
  487. return;
  488. }
  489. }
  490. });
  491. return flag;
  492. });
  493. const temp2 = this.allGunList.filter((item) => {
  494. let flag = true;
  495. temp.map((ele) => {
  496. if (item.oilGunNo == ele.oilGunNo) {
  497. flag = false;
  498. }
  499. });
  500. return flag;
  501. });
  502. return this.currentList.concat(temp2);
  503. },
  504. },
  505. methods: {
  506. getVerificationList(){
  507. verificationList({
  508. pageNum: 1,
  509. pageSize: 1000
  510. }).then((res)=>{
  511. if(res.code == 200){
  512. if(res.rows == null){
  513. this.couponList = [];
  514. }else{
  515. this.couponList = res.rows;
  516. }
  517. }else{
  518. throw new Error('');
  519. }
  520. }).catch((err)=>{
  521. this.msgError("亲,拉取核销机构失败~")
  522. })
  523. },
  524. toggleLabel(){
  525. if(this.moveLeftData.length !== 0){
  526. this.queryParams.verificationList = this.queryParams.verificationList.filter((ele)=>{
  527. return ele != this.moveLeftData
  528. })
  529. this.queryParams = {...this.queryParams}
  530. return;
  531. }
  532. if(this.moveRightData.length !== 0){
  533. this.queryParams.verificationList = [...new Set(this.queryParams.verificationList.concat(this.moveRightData))].filter((ele)=>{
  534. return !!ele
  535. })
  536. this.queryParams = {...this.queryParams}
  537. return;
  538. }
  539. return;
  540. },
  541. handleLeftChange(val) {
  542. let changeArr = [];
  543. val.map((ele) => {
  544. changeArr.push(ele.deptId);
  545. });
  546. console.log(changeArr)
  547. this.moveLeftData = []
  548. this.moveRightData = changeArr
  549. // console.log(this.moveRightData);
  550. this.$refs.rightTable.clearSelection()
  551. },
  552. handleRightChange(val){
  553. let changeArr = [];
  554. val.map((ele) => {
  555. changeArr.push(ele.deptId);
  556. });
  557. this.moveLeftData = changeArr
  558. this.moveRightData = []
  559. this.$refs.leftTable.clearSelection()
  560. },
  561. init() {
  562. this.getList();
  563. this.getVerificationList();
  564. //字典设备状态
  565. this.getDicts("device_status").then((response) => {
  566. this.deviceStatusOptions = response.data;
  567. });
  568. //字典设备类型
  569. this.getDicts("device_type").then((response) => {
  570. this.deviceTypeOptions = response.data;
  571. });
  572. listGun({
  573. stationId: this.deptId,
  574. }).then((response) => {
  575. this.allGunList = response.rows;
  576. });
  577. },
  578. setPageStatus() {
  579. this.queryPageStatus([2]).then((res) => {
  580. this.pageStatus = res;
  581. });
  582. },
  583. /** 查询油站设备管理列表 首页表单 */
  584. getList() {
  585. listManage(this.queryForm).then((response) => {
  586. this.equipmentList = response.rows;
  587. this.total = response.total;
  588. });
  589. },
  590. // 取消按钮
  591. cancel() {
  592. this.open = false;
  593. },
  594. /** 搜索按钮操作 */
  595. handleQuery() {
  596. this.queryForm.pageNum = 1;
  597. this.getList();
  598. },
  599. deviceNoInput(value) {
  600. this.dialogForm.posQueue = value;
  601. },
  602. /** 重置按钮操作 */
  603. resetQuery() {
  604. this.resetForm("queryForm");
  605. this.handleQuery();
  606. },
  607. /** 新增按钮操作 */
  608. handleAdd() {
  609. this.updateAble = false;
  610. this.currentList = [];
  611. this.title = "添加油站设备管理";
  612. this.dialogForm = {
  613. checkedGunList: [],
  614. deviceStatus: "1",
  615. deviceType: "1",
  616. posFanoutExchange: "posFanoutExchange-" + this.deptId,
  617. };
  618. this.open = true;
  619. },
  620. /** 修改按钮操作 */
  621. handleUpdate(row) {
  622. // 查找自己已经选中的枪号
  623. this.updateAble = true;
  624. this.currentList = this.allGunList.filter((ele) => {
  625. return row.gunNo.split(",").includes(ele.oilGunNo);
  626. });
  627. let checkedGunList;
  628. // 将自己有的抢号 默认勾选
  629. if (Object.prototype.toString.call(row.gunNo) === "[object String]") {
  630. checkedGunList = [...new Set(row.gunNo.split(","))].filter((ele) => {
  631. return ele.toString().trim() !== "";
  632. });
  633. } else {
  634. checkedGunList = [];
  635. }
  636. this.dialogForm = { ...row, checkedGunList };
  637. this.title = "修改油站设备管理";
  638. this.open = true;
  639. },
  640. /** 提交按钮 */
  641. submitForm() {
  642. this.$refs["dialogForm"].validate((valid) => {
  643. if (valid) {
  644. //this.dialogForm.gunNo = this.dialogForm.checkedGunList.toString();
  645. addInfo(this.queryParams).then((res) => {
  646. console.log(res)
  647. })
  648. }
  649. });
  650. },
  651. /** 删除按钮操作 */
  652. handleDelete(row) {
  653. const deviceIds = row.deviceId;
  654. this.$confirm("是否确认删除油站设备管理", "警告", {
  655. confirmButtonText: "确定",
  656. cancelButtonText: "取消",
  657. type: "warning",
  658. })
  659. .then(function () {
  660. return delManage(deviceIds);
  661. })
  662. .then(() => {
  663. this.getList();
  664. this.msgSuccess("删除成功");
  665. });
  666. },
  667. },
  668. };
  669. </script>
  670. <style lang="scss">
  671. .el-transfer__buttons {
  672. }
  673. </style>