Coupon_CreateGetWay.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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="550px"
  110. append-to-body
  111. status-icon
  112. >
  113. <el-form
  114. ref="dialogForm"
  115. :model="dialogForm"
  116. :rules="rules"
  117. label-width="150px"
  118. >
  119. <el-form-item label="名称" prop="couponName">
  120. <input
  121. type="text"
  122. class="form-control"
  123. v-model.number="queryParams.couponName"
  124. style="width: 150px"
  125. />
  126. </el-form-item>
  127. <el-form-item label="条件" prop="couponThresholdAmt">
  128. <div>
  129. <input
  130. type="text"
  131. class="form-control d-inline"
  132. v-model.number="queryParams.couponThresholdAmt"
  133. style="width: 100px"
  134. />
  135. 元 可用
  136. </div>
  137. </el-form-item>
  138. <el-form-item label="类型" prop="couponType">
  139. <el-radio-group v-model="queryParams.couponType">
  140. <el-radio label="1">现金券</el-radio>
  141. <el-radio label="2">折扣劵</el-radio>
  142. <el-radio label="3">兑换劵</el-radio>
  143. </el-radio-group>
  144. </el-form-item>
  145. <el-form-item label="优惠" prop="couponAmt">
  146. <div>
  147. 面值金额—<input
  148. type="text"
  149. class="form-control d-inline"
  150. v-model.number="queryParams.couponAmt"
  151. style="width: 100px"
  152. />
  153. </div>
  154. <div>
  155. 折扣比例—<input
  156. type="text"
  157. class="form-control d-inline"
  158. v-model.number="queryParams.couponAmt"
  159. style="width: 100px"
  160. />
  161. %
  162. </div>
  163. </el-form-item>
  164. <el-form-item label="油品" prop="deviceName">
  165. <el-checkbox-group v-model="queryParams.oilName">
  166. <el-checkbox label="92#"></el-checkbox>
  167. <el-checkbox label="93#"></el-checkbox>
  168. <el-checkbox label="94#"></el-checkbox>
  169. </el-checkbox-group>
  170. </el-form-item>
  171. <el-form-item label="有效期类型" prop="effectiveTimeType">
  172. <el-radio-group v-model="queryParams.effectiveTimeType">
  173. <el-radio label="1">固定时间段</el-radio>
  174. <el-radio label="2">领取后设定有效时段</el-radio>
  175. </el-radio-group>
  176. </el-form-item>
  177. <el-form-item label="有效时间" prop="deviceName">
  178. <div>
  179. <el-date-picker
  180. style="margin: 0px 10px; width: 300px"
  181. v-model="queryParams.dateRangeCreatedDate"
  182. type="datetimerange"
  183. value-format="yyyy-MM-dd HH:mm:ss"
  184. size="mini"
  185. range-separator="至"
  186. start-placeholder="开始日期"
  187. end-placeholder="结束日期"
  188. >
  189. </el-date-picker>
  190. </div>
  191. <div>
  192. 自用户领取后 <input
  193. type="text"
  194. class="form-control d-inline"
  195. v-model.number="queryParams.effectiveDayNum"
  196. style="width: 100px"
  197. /> 天内有效
  198. </div>
  199. </el-form-item>
  200. <el-form-item label="生成数量" prop="couponNum">
  201. 共生成
  202. <input
  203. type="text"
  204. class="form-control d-inline"
  205. v-model.number="queryParams.couponNum"
  206. style="width: 100px"
  207. />
  208. </el-form-item>
  209. <el-form-item label="每人限领" prop="couponReceiveNum">
  210. 单个用户最多领取
  211. <input
  212. type="text"
  213. class="form-control d-inline"
  214. v-model.number="queryParams.couponReceiveNum"
  215. style="width: 100px"
  216. />
  217. </el-form-item>
  218. </el-form>
  219. <div slot="footer" class="dialog-footer">
  220. <el-button type="primary" @click="submitForm">确 定</el-button>
  221. <el-button @click="cancel">取 消</el-button>
  222. </div>
  223. </el-dialog>
  224. </div>
  225. </template>
  226. <script>
  227. import {
  228. listManage,
  229. getManage,
  230. delManage,
  231. addManage,
  232. updateManage,
  233. exportManage,
  234. changeManageStatus,
  235. } from "@/api/station/manage";
  236. import { listGun } from "@/api/station/gun";
  237. export default {
  238. name: "Station_Equipment",
  239. data() {
  240. let validateGunNo = (rule, value, callback) => {
  241. callback();
  242. };
  243. return {
  244. pageStatus: 4,
  245. // 油站设备管理表格数据
  246. queryParams: {
  247. couponName: "",
  248. couponThresholdAmt:0,
  249. couponType:"1",
  250. couponAmt:0,
  251. oilName:[],
  252. effectiveTimeType:'', //有效时间类型: 1,固定时间;2,领取后x天内有效
  253. effectiveTime:[],
  254. effectiveDayNum :3,
  255. couponReceiveNum:1,
  256. couponNum :100,
  257. status:1
  258. },
  259. equipmentList: [],
  260. // 油枪复选
  261. allGunList: [],
  262. // 已选的油枪
  263. checkedGunList: [],
  264. //设备状态
  265. deviceStatusOptions: [],
  266. //设备类型
  267. deviceTypeOptions: [],
  268. stationOptions: [],
  269. // 弹出层标题
  270. title: "",
  271. // 是否显示弹出层
  272. open: false,
  273. // 总条数
  274. total: 100,
  275. // 查询参数
  276. queryForm: {
  277. pageNum: 1,
  278. pageSize: 10, // 初始值只能比10大
  279. deviceNo: null,
  280. deviceSerialNum: null, // 设备密钥
  281. },
  282. // 弹窗表单参数
  283. dialogForm: {
  284. checkedGunList: [],
  285. deviceStatus: "1",
  286. deviceType: "1",
  287. },
  288. currentList: [],
  289. // 表单校验
  290. rules: {
  291. deviceNo: [
  292. { required: true, message: "请输入设备编号", trigger: "blur" },
  293. ],
  294. deviceName: [
  295. { required: true, message: "请输入设备名", trigger: "blur" },
  296. ],
  297. // deviceSerialNum: [
  298. // { required: true, message: "请输入设备密钥", trigger: "blur" },
  299. // ],
  300. deviceType: [
  301. { required: true, message: "请选择设备类型", trigger: "blur" },
  302. ],
  303. checkedGunList: [{ validator: validateGunNo, trigger: "change" }],
  304. deviceStatus: [
  305. { required: true, message: "请选择设备状态", trigger: "blur" },
  306. ],
  307. deviceFactory: [
  308. // { required: true, message: '请输入设备厂家', trigger: 'blur' }
  309. ],
  310. },
  311. updateAble: false,
  312. deviceTypeAble: false,
  313. };
  314. },
  315. created() {
  316. this.init();
  317. this.setPageStatus();
  318. },
  319. computed: {
  320. posList() {
  321. // 排除其他pos已经添加过的
  322. const temp = this.allGunList.filter((item) => {
  323. let flag = false;
  324. this.equipmentList.map((ele) => {
  325. if (ele.deviceType == 2) {
  326. if (ele.gunNo.split(",").includes(item.oilGunNo)) {
  327. flag = true;
  328. return;
  329. }
  330. }
  331. });
  332. return flag;
  333. });
  334. // 查找自己的
  335. const temp2 = this.allGunList.filter((item) => {
  336. let flag = true;
  337. temp.map((ele) => {
  338. if (item.oilGunNo == ele.oilGunNo) {
  339. flag = false;
  340. }
  341. });
  342. return flag;
  343. });
  344. return this.currentList.concat(temp2);
  345. },
  346. printList() {
  347. const temp = this.allGunList.filter((item) => {
  348. let flag = false;
  349. this.equipmentList.map((ele) => {
  350. if (ele.deviceType == 1) {
  351. if (ele.gunNo.split(",").includes(item.oilGunNo)) {
  352. flag = true;
  353. return;
  354. }
  355. }
  356. });
  357. return flag;
  358. });
  359. const temp2 = this.allGunList.filter((item) => {
  360. let flag = true;
  361. temp.map((ele) => {
  362. if (item.oilGunNo == ele.oilGunNo) {
  363. flag = false;
  364. }
  365. });
  366. return flag;
  367. });
  368. return this.currentList.concat(temp2);
  369. },
  370. },
  371. methods: {
  372. init() {
  373. this.getList();
  374. //字典设备状态
  375. this.getDicts("device_status").then((response) => {
  376. this.deviceStatusOptions = response.data;
  377. });
  378. //字典设备类型
  379. this.getDicts("device_type").then((response) => {
  380. this.deviceTypeOptions = response.data;
  381. });
  382. listGun({
  383. stationId: this.deptId,
  384. }).then((response) => {
  385. this.allGunList = response.rows;
  386. });
  387. },
  388. setPageStatus() {
  389. this.queryPageStatus([2]).then((res) => {
  390. this.pageStatus = res;
  391. });
  392. },
  393. /** 查询油站设备管理列表 首页表单 */
  394. getList() {
  395. listManage(this.queryForm).then((response) => {
  396. this.equipmentList = response.rows;
  397. this.total = response.total;
  398. });
  399. },
  400. // 取消按钮
  401. cancel() {
  402. this.open = false;
  403. },
  404. /** 搜索按钮操作 */
  405. handleQuery() {
  406. this.queryForm.pageNum = 1;
  407. this.getList();
  408. },
  409. deviceNoInput(value) {
  410. this.dialogForm.posQueue = value;
  411. },
  412. /** 重置按钮操作 */
  413. resetQuery() {
  414. this.resetForm("queryForm");
  415. this.handleQuery();
  416. },
  417. /** 新增按钮操作 */
  418. handleAdd() {
  419. this.updateAble = false;
  420. this.currentList = [];
  421. this.title = "添加油站设备管理";
  422. this.dialogForm = {
  423. checkedGunList: [],
  424. deviceStatus: "1",
  425. deviceType: "1",
  426. posFanoutExchange: "posFanoutExchange-" + this.deptId,
  427. };
  428. this.open = true;
  429. },
  430. /** 修改按钮操作 */
  431. handleUpdate(row) {
  432. // 查找自己已经选中的枪号
  433. this.updateAble = true;
  434. this.currentList = this.allGunList.filter((ele) => {
  435. return row.gunNo.split(",").includes(ele.oilGunNo);
  436. });
  437. let checkedGunList;
  438. // 将自己有的抢号 默认勾选
  439. if (Object.prototype.toString.call(row.gunNo) === "[object String]") {
  440. checkedGunList = [...new Set(row.gunNo.split(","))].filter((ele) => {
  441. return ele.toString().trim() !== "";
  442. });
  443. } else {
  444. checkedGunList = [];
  445. }
  446. this.dialogForm = { ...row, checkedGunList };
  447. this.title = "修改油站设备管理";
  448. this.open = true;
  449. },
  450. /** 提交按钮 */
  451. submitForm() {
  452. this.$refs["dialogForm"].validate((valid) => {
  453. if (valid) {
  454. //this.dialogForm.gunNo = this.dialogForm.checkedGunList.toString();
  455. }
  456. });
  457. },
  458. /** 删除按钮操作 */
  459. handleDelete(row) {
  460. const deviceIds = row.deviceId;
  461. this.$confirm("是否确认删除油站设备管理", "警告", {
  462. confirmButtonText: "确定",
  463. cancelButtonText: "取消",
  464. type: "warning",
  465. })
  466. .then(function () {
  467. return delManage(deviceIds);
  468. })
  469. .then(() => {
  470. this.getList();
  471. this.msgSuccess("删除成功");
  472. });
  473. },
  474. },
  475. };
  476. </script>
  477. <style scoped>
  478. </style>