Dev_Test copy 2.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  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. <div class="card mx-auto shadow" style="width: 310px;">
  10. <div class="card-body">
  11. <el-form
  12. ref="ruleForm"
  13. :model="ruleForm"
  14. :rules="rules"
  15. label-width="80px"
  16. >
  17. <el-form-item label="当前方案">
  18. {{ currentDiscountName }}
  19. </el-form-item>
  20. <el-form-item label="变改方案">
  21. <el-select
  22. v-model="ruleForm.discountSetting"
  23. placeholder="请选择优惠方案"
  24. clearable
  25. size="small"
  26. style="width:100px"
  27. @change="discountSettingChang"
  28. >
  29. <el-option label="无" value="0"></el-option>
  30. <el-option label="满减" value="1"></el-option>
  31. <el-option label="立减" value="2"></el-option>
  32. <el-option label="直降" value="3"></el-option>
  33. <el-option label="阶梯直降" value="4"></el-option>
  34. </el-select>
  35. <button href="#" type="button" @click="save" class="btn btn-primary btn-sm ml-3 mb-1">变更</button>
  36. </el-form-item>
  37. </el-form>
  38. </div>
  39. </div>
  40. <hr />
  41. <el-dialog
  42. :visible.sync="openDialog"
  43. width="520px"
  44. append-to-body
  45. :title="
  46. ['', '满减方案', '立减方案', '直降方案', '阶梯直降'][discountSetting]
  47. "
  48. >
  49. <el-form
  50. ref="updateForm"
  51. :model="updateForm"
  52. :rules="rules"
  53. label-width="150px"
  54. >
  55. <el-form-item label="方案名称" prop="grade" class="input-group-sm">
  56. <!-- <el-input v-model="updateForm.grade" placeholder="请输入方案名称" /> -->
  57. <input
  58. v-model="updateForm.grade"
  59. placeholder="请输入方案名称"
  60. class="form-control form-control-sm w-50"
  61. />
  62. </el-form-item>
  63. <el-form-item label="油品名称" prop="oilName">
  64. <select
  65. v-model="updateForm.oilName"
  66. class="form-control form-control-sm w-50"
  67. >
  68. <option
  69. v-for="dict in filterOilNameOptions"
  70. :key="dict.oilName"
  71. :value="dict.oilName"
  72. >
  73. {{ dict.oilName }}
  74. </option>
  75. </select>
  76. </el-form-item>
  77. <!-- 阶梯直降没有此规则 -->
  78. <el-form-item
  79. label="优惠条件"
  80. prop="gasoilDiscountAmt"
  81. :rules="{
  82. required: discountSetting != 4,
  83. message: '请填写优惠条件',
  84. trigger: 'change',
  85. }"
  86. v-if="discountSetting != 4"
  87. >
  88. <el-radio-group
  89. v-model="updateForm.discountTerm"
  90. v-if="discountSetting == 3"
  91. >
  92. <el-radio :label="2">按加油金额</el-radio>
  93. <el-radio :label="1">按加油升数</el-radio>
  94. </el-radio-group>
  95. <div
  96. v-show="
  97. updateForm.discountTerm == 2 ||
  98. updateForm.discountTerm == 1 ||
  99. discountSetting == 1 ||
  100. discountSetting == 2
  101. "
  102. >
  103. {{ ["", "每满", "满", "满"][discountSetting] }}
  104. <!-- <el-input-number
  105. v-model="updateForm.discountAmt"
  106. size="mini"
  107. :min="0"
  108. /> -->
  109. <input
  110. v-model="updateForm.discountAmt"
  111. class="form-control form-control-sm"
  112. style="width: 50px; display: inline-block"
  113. />
  114. <span>{{
  115. updateForm.discountTerm == 1 && discountSetting == 3 ? "L" : "元"
  116. }}</span>
  117. ,{{ ["", "减", "减", "每升优惠"][discountSetting] }}
  118. <!-- <el-input-number
  119. v-model="updateForm.gasoilDiscountAmt"
  120. size="mini"
  121. :min="0"
  122. /> -->
  123. <input
  124. v-model="updateForm.gasoilDiscountAmt"
  125. class="form-control form-control-sm"
  126. style="width: 50px; display: inline-block"
  127. />
  128. </div>
  129. </el-form-item>
  130. <!-- 阶梯直降没有此规则 -->
  131. <el-form-item
  132. label="会员日"
  133. prop="discountSettingFlag"
  134. :rules="{
  135. required: discountSetting != 4,
  136. message: '请选择是否开启会员日',
  137. trigger: 'change',
  138. }"
  139. v-if="discountSetting != 4"
  140. >
  141. <el-radio-group v-model="updateForm.discountSettingFlag">
  142. <el-radio label="0">关闭</el-radio>
  143. <el-radio label="1">开启</el-radio>
  144. </el-radio-group>
  145. </el-form-item>
  146. <el-form-item
  147. label="会员日周期类型"
  148. prop="discountType"
  149. v-show="updateForm.discountSettingFlag == 1"
  150. :rules="{
  151. required: updateForm.discountSettingFlag == 1,
  152. message: '请选择会员日的周期类型',
  153. trigger: 'change',
  154. }"
  155. >
  156. <el-select
  157. v-model="updateForm.discountType"
  158. clearable
  159. size="small"
  160. @change="timeClear"
  161. >
  162. <el-option label="每周指定日" value="1"></el-option>
  163. <el-option label="每月指定日" value="2"></el-option>
  164. <el-option label="固定活动日" value="3"></el-option>
  165. </el-select>
  166. <div
  167. v-show="updateForm.discountType != 3"
  168. style="
  169. display: flex;
  170. flex-wrap: wrap;
  171. border-style: solid;
  172. border-color: #f5f7fa;
  173. "
  174. >
  175. <div
  176. v-for="(item, index) in timeSelect[updateForm.discountType]"
  177. :key="index"
  178. style="margin: 3px"
  179. >
  180. <div
  181. class="hover-style"
  182. style="
  183. border-radius: 5px;
  184. font-weight: bold;
  185. font-size: 12px;
  186. cursor: pointer;
  187. "
  188. @click="clickCalendar(index)"
  189. >
  190. <div>{{ item }}</div>
  191. <div
  192. v-if="updateForm.collectClickCalendar.indexOf(index) > -1"
  193. style="
  194. width: 4px;
  195. height: 4px;
  196. border-radius: 50%;
  197. background-color: red;
  198. position: relative;
  199. left: calc(50% - 2px);
  200. "
  201. ></div>
  202. <div v-else style="width: 4px; height: 4px"></div>
  203. </div>
  204. </div>
  205. </div>
  206. <div v-show="updateForm.discountType == 3">
  207. <el-date-picker
  208. clearable
  209. size="small"
  210. style="margin-left: 10px; width: 200px"
  211. v-model="updateForm.collectClickDay"
  212. type="dates"
  213. value-format="yyyy-MM-dd"
  214. placeholder="选择提醒时间设置"
  215. >
  216. </el-date-picker>
  217. </div>
  218. </el-form-item>
  219. <el-form-item
  220. label="会员日优惠条件"
  221. prop="discountActivityAmt"
  222. v-show="updateForm.discountSettingFlag == 1"
  223. :rules="{
  224. required: updateForm.discountSettingFlag == 1,
  225. message: '请填写会员日的优惠金额',
  226. trigger: 'change',
  227. }"
  228. >
  229. <div>
  230. {{ ["", "每满", "满", "满"][discountSetting] }}
  231. <el-input-number
  232. v-model="updateForm.discountAmt"
  233. size="mini"
  234. :min="0"
  235. disabled
  236. />
  237. <span>{{
  238. updateForm.discountTerm == 1 && discountSetting == 3 ? "L" : "元"
  239. }}</span>
  240. ,{{ ["", "减", "减", "每升优惠"][discountSetting] }}
  241. <el-input-number
  242. v-model="updateForm.discountActivityAmt"
  243. size="mini"
  244. :min="0"
  245. />元
  246. </div>
  247. </el-form-item>
  248. <el-form-item label="叠加等级优惠" prop="vipDiscountyPlus">
  249. <el-radio-group v-model="updateForm.vipDiscountyPlus">
  250. <el-radio label="1">是</el-radio>
  251. <el-radio label="0">否</el-radio>
  252. </el-radio-group>
  253. <div style="margin-left: 20px; color: red; font-size: 12px">
  254. 注:"否" 客户只享受 {{ discountName }} 优惠
  255. </div>
  256. </el-form-item>
  257. <el-form-item label="可否叠加劵" prop="couponPlus">
  258. <el-radio-group v-model="updateForm.couponPlus">
  259. <el-radio label="1">是</el-radio>
  260. <el-radio label="0">否</el-radio>
  261. </el-radio-group>
  262. <div style="margin-left: 20px; color: red; font-size: 12px">
  263. 注:"否" 客户只享受 {{ discountName }} 优惠
  264. </div>
  265. </el-form-item>
  266. <!-- 只有阶梯直降有此规则 -->
  267. <el-form-item
  268. label="优惠条件"
  269. prop="discountTerm"
  270. :rules="{
  271. required: discountSetting == 4,
  272. message: '请填写优惠条件',
  273. trigger: 'change',
  274. }"
  275. v-if="discountSetting == 4"
  276. >
  277. <el-radio-group v-model="updateForm.discountTerm">
  278. <el-radio :label="2">按加油金额</el-radio>
  279. <el-radio :label="1">按加油升数</el-radio>
  280. </el-radio-group>
  281. </el-form-item>
  282. <!-- 只有阶梯直降有此规则 -->
  283. <el-form-item
  284. label="阶梯设置"
  285. prop="list"
  286. :rules="{
  287. required: discountSetting == 4,
  288. message: '请设置优惠的阶梯定价',
  289. trigger: 'change',
  290. }"
  291. v-if="discountSetting == 4"
  292. >
  293. <el-button
  294. icon="el-icon-plus"
  295. size="mini"
  296. class="mb-3 mr-4"
  297. @click="addLadder"
  298. type="secondary"
  299. >
  300. 添加规则
  301. </el-button>
  302. </el-form-item>
  303. <div
  304. class="mx-auto mb-4 bg-light pt-4 pb-2 px-1 rounded"
  305. style="width: 450px"
  306. v-if="discountSetting==4"
  307. >
  308. <div
  309. class="input-group input-group-sm mb-4 mt-1"
  310. v-for="(item, index) in updateForm.list"
  311. :key="index"
  312. >
  313. <input
  314. type="text"
  315. class="form-control"
  316. v-model="item.discountAmt"
  317. />
  318. <div class="input-group-append">
  319. <span class="input-group-text"> {{updateForm.discountTerm==1 ? '升&lt;= 加油升数 &lt;': "元&lt;= 加油金额 &lt;"}} </span>
  320. </div>
  321. <input
  322. type="text"
  323. class="form-control"
  324. v-model="item.discountAmtEnd"
  325. />
  326. <div class="input-group-append">
  327. <span class="input-group-text">{{updateForm.discountTerm==1 ? '升':'元'}},每升优惠</span>
  328. </div>
  329. <input
  330. type="text"
  331. class="form-control"
  332. v-model="item.gasoilDiscountAmt"
  333. />
  334. <div class="input-group-append">
  335. <span class="input-group-text">元</span>
  336. </div>
  337. <div class="input-group-append" id="button-addon4">
  338. <button
  339. class="btn btn-danger"
  340. type="button"
  341. @click="delLadder(index)"
  342. >
  343. 删除
  344. </button>
  345. </div>
  346. </div>
  347. </div>
  348. </el-form>
  349. <div slot="footer" class="dialog-footer">
  350. <el-button type="primary" @click="handleSubmit">确 定</el-button>
  351. <el-button @click="cancelSubmit">取 消</el-button>
  352. </div>
  353. </el-dialog>
  354. <el-form
  355. :model="queryParams"
  356. ref="queryForm"
  357. :inline="true"
  358. label-width="68px"
  359. v-show="discountSetting != 0"
  360. class="mx-auto"
  361. >
  362. <div>
  363. <el-button
  364. icon="el-icon-plus"
  365. size="mini"
  366. class="mb-3 mr-4"
  367. @click="handleUpdateClick"
  368. style="float: right"
  369. type="warning"
  370. >
  371. {{
  372. this.discountSetting == 1
  373. ? "添加满减方案规则"
  374. : this.discountSetting == 2
  375. ? "添加立减方案规则"
  376. : this.discountSetting == 3
  377. ? "添加直降方案规则"
  378. : this.discountSetting == 4
  379. ? "添加阶梯直降规则"
  380. : "无"
  381. }}
  382. </el-button>
  383. </div>
  384. </el-form>
  385. <el-table
  386. :data="discountList"
  387. v-show="discountSetting != 0 && discountSetting != 4"
  388. class="shadow"
  389. >
  390. <af-table-column label="id" align="center" prop="id" v-if="false" />
  391. <af-table-column label="方案名称" align="center" prop="grade" />
  392. <af-table-column label="油品名称" align="center" prop="oilName" />
  393. <af-table-column
  394. label="优惠条件"
  395. align="center"
  396. v-if="discountSetting == 3"
  397. >
  398. <template slot-scope="scope">
  399. 满 {{ scope.row.discountAmt }}
  400. {{ scope.row.discountTerm == 2 ? "元" : "L" }},每升优惠
  401. {{ scope.row.gasoilDiscountAmt }} 元
  402. </template>
  403. </af-table-column>
  404. <af-table-column
  405. label="优惠条件"
  406. align="center"
  407. v-if="discountSetting == 1"
  408. >
  409. <template slot-scope="scope">
  410. 每满 {{ scope.row.discountAmt }} 元,减
  411. {{ scope.row.gasoilDiscountAmt }} 元
  412. </template>
  413. </af-table-column>
  414. <af-table-column
  415. label="优惠条件"
  416. align="center"
  417. v-if="discountSetting == 2"
  418. >
  419. <template slot-scope="scope">
  420. 满 {{ scope.row.discountAmt }} 元,减
  421. {{ scope.row.gasoilDiscountAmt }} 元
  422. </template>
  423. </af-table-column>
  424. <af-table-column
  425. label="会员日"
  426. align="center"
  427. v-if="discountSetting != 4"
  428. >
  429. <template slot-scope="scope">
  430. <span v-if="scope.row.discountSettingFlag == 0"> 无活动 </span>
  431. <span v-else-if="scope.row.discountSettingFlag == 1">
  432. {{ discountSettingTranslate(scope.row) }}
  433. </span>
  434. </template>
  435. </af-table-column>
  436. <af-table-column
  437. label="叠加等级优惠"
  438. align="center"
  439. prop="vipDiscountyPlus"
  440. :formatter="vipDiscountyPlusFotmat"
  441. />
  442. <af-table-column
  443. label="叠加劵"
  444. align="center"
  445. prop="couponPlus"
  446. :formatter="couponPlusFotmat"
  447. />
  448. <af-table-column
  449. label="优惠方案类型"
  450. v-if="false"
  451. align="center"
  452. prop="discountPlanType"
  453. />
  454. <af-table-column
  455. label="操作"
  456. align="center"
  457. class-name="small-padding fixed-width"
  458. >
  459. <template slot-scope="scope">
  460. <el-button
  461. size="mini"
  462. type="text"
  463. icon="el-icon-delete"
  464. @click="handleDelete(scope.row)"
  465. >删除</el-button
  466. >
  467. </template>
  468. </af-table-column>
  469. </el-table>
  470. <el-table
  471. :data="discountListTep"
  472. v-show="discountSetting == 4"
  473. type="expand"
  474. class="shadow"
  475. >
  476. <af-table-column type="expand">
  477. <template slot-scope="props">
  478. <div
  479. class="input-group input-group-sm mb-4 mt-1"
  480. v-for="(item, index) in props.row.list"
  481. :key="index"
  482. style="width:600px;"
  483. >
  484. <div class="input-group-append">
  485. <span class="input-group-text"> 规则 {{index + 1}}: </span>
  486. </div>
  487. <input
  488. type="text"
  489. class="form-control"
  490. v-model="item.discountAmt"
  491. disabled
  492. />
  493. <div class="input-group-append">
  494. <span class="input-group-text"> {{updateForm.discountTerm==1 ? '升&lt;= 加油升数 &lt;': "元&lt;= 加油金额 &lt;"}} </span>
  495. </div>
  496. <input
  497. type="text"
  498. class="form-control"
  499. v-model="item.discountAmtEnd"
  500. disabled
  501. />
  502. <div class="input-group-append">
  503. <span class="input-group-text">{{updateForm.discountTerm==1 ? '升,':'元,'}}</span>
  504. </div>
  505. <div class="input-group-append">
  506. <span class="input-group-text">每升优惠</span>
  507. </div>
  508. <input
  509. type="text"
  510. class="form-control"
  511. v-model="item.gasoilDiscountAmt"
  512. disabled
  513. />
  514. <div class="input-group-append">
  515. <span class="input-group-text">元</span>
  516. </div>
  517. <div class="input-group-append" id="button-addon4">
  518. </div>
  519. </div>
  520. </template>
  521. </af-table-column>
  522. <af-table-column label="方案名称" align="center" prop="grade" />
  523. <af-table-column label="油品名称" align="center" prop="oilName" />
  524. <af-table-column
  525. label="叠加等级优惠"
  526. align="center"
  527. prop="vipDiscountyPlus"
  528. :formatter="vipDiscountyPlusFotmat"
  529. />
  530. <af-table-column
  531. label="叠加劵"
  532. align="center"
  533. prop="couponPlus"
  534. :formatter="couponPlusFotmat"
  535. />
  536. <af-table-column
  537. label="优惠方案类型"
  538. v-if="false"
  539. align="center"
  540. prop="discountPlanType"
  541. />
  542. <af-table-column
  543. label="操作"
  544. align="center"
  545. class-name="small-padding fixed-width"
  546. width="200px"
  547. >
  548. <template slot-scope="scope">
  549. <el-button
  550. size="mini"
  551. type="text"
  552. icon="el-icon-edit"
  553. @click="handleDelete(scope.row)"
  554. >修改规则</el-button
  555. >
  556. <el-button
  557. size="mini"
  558. type="text"
  559. icon="el-icon-delete"
  560. @click="handleDelete(scope.row)"
  561. >删除</el-button
  562. >
  563. </template>
  564. </af-table-column>
  565. </el-table>
  566. </div>
  567. </template>
  568. <script>
  569. import {
  570. listPlan,
  571. getPlan,
  572. delPlan,
  573. addPlan,
  574. updatePlan,
  575. exportPlan,
  576. addMarketPlanInfo
  577. } from "@/api/market/plan";
  578. import { getStationPay, updatePay } from "@/api/station/pay";
  579. import { getDept } from "@/api/system/dept";
  580. import { listPrice } from "@/api/station/price";
  581. export default {
  582. name: "Market_Discount",
  583. data() {
  584. const validatorGasoilDiscountAmt = (rule, value, callback) => {
  585. if (this.discountSetting == 3) {
  586. if (
  587. this.updateForm.discountTerm === undefined ||
  588. this.updateForm.discountTerm === ""
  589. ) {
  590. callback(new Error("请选择优惠方式"));
  591. return;
  592. }
  593. }
  594. const start = +this.updateForm.discountAmt;
  595. const end = +this.updateForm.gasoilDiscountAmt;
  596. if (isNaN(start) || isNaN(end)) {
  597. callback(new Error("检查优惠方式完整性"));
  598. return;
  599. }
  600. callback();
  601. };
  602. return {
  603. testd: 1,
  604. pageStatus: 0,
  605. discountList: [],
  606. total: 0,
  607. oilNameOptions: [],
  608. title: "",
  609. openDialog: false,
  610. // 查询参数
  611. queryParams: {
  612. pageNum: 1,
  613. pageSize: 10,
  614. grade: null,
  615. discountWay: null,
  616. gasoilDiscountLitre: null,
  617. dieseloilDiscountLitre: null,
  618. gradeType: null,
  619. gasoilConsume: null,
  620. gasoilGrowthValue: null,
  621. dieseloilConsume: null,
  622. dieseloilGrowthValue: null,
  623. growthValue: null,
  624. date: null,
  625. deductionGrowthValue: null,
  626. },
  627. updateFormDynamic1: ["", "满", "每满", "满"],
  628. updateFormDynamic2: ["", "减", "减", "每升优惠"],
  629. ruleForm: {},
  630. // 表单校验
  631. rules: {
  632. grade: [{ required: true, message: "请输入方案名称", trigger: "blur" }],
  633. oilName: [
  634. { required: true, message: "请选择油品名称", trigger: "change" },
  635. ],
  636. discountTerm: [
  637. { required: true, message: "选择油品名称", trigger: "change" },
  638. ],
  639. gasoilDiscountAmt: [
  640. { validator: validatorGasoilDiscountAmt, trigger: "change" },
  641. ],
  642. discountAmt: [
  643. { required: true, message: "请填写优惠金额", trigger: "blur" },
  644. ],
  645. vipDiscountyPlus: [
  646. {
  647. required: true,
  648. message: "选择等级优惠是否叠加",
  649. trigger: "change",
  650. },
  651. ],
  652. couponPlus: [
  653. { required: true, message: "选择可否叠加券", trigger: "change" },
  654. ],
  655. },
  656. dtrules: {},
  657. discountSetting: 0,
  658. updateForm: {
  659. collectClickCalendar: [],
  660. collectClickDay: "",
  661. },
  662. currentDiscountName: "",
  663. timeSelect: [
  664. ,
  665. ["周天", "周一", "周二", "周三", "周四", "周五", "周六"],
  666. [
  667. "01",
  668. "02",
  669. "03",
  670. "04",
  671. "05",
  672. "06",
  673. "07",
  674. "08",
  675. "09",
  676. "10",
  677. "11",
  678. "12",
  679. "13",
  680. "14",
  681. "15",
  682. "16",
  683. "17",
  684. "18",
  685. "19",
  686. "20",
  687. "21",
  688. "22",
  689. "23",
  690. "24",
  691. "25",
  692. "26",
  693. "27",
  694. "28",
  695. "29",
  696. "30",
  697. "31",
  698. ],
  699. ],
  700. discountListTep: [
  701. {
  702. list: [],
  703. },
  704. {},
  705. ],
  706. };
  707. },
  708. computed: {
  709. discountName() {
  710. return this.discountSetting == 1
  711. ? "满减"
  712. : this.discountSetting == 2
  713. ? "立减"
  714. : this.discountSetting == 3
  715. ? "直降"
  716. : this.discountSetting == 4
  717. ? "阶梯直降"
  718. : "无";
  719. },
  720. filterOilNameOptions() {
  721. return this.oilNameOptions.filter((ele) => {
  722. let flag = true;
  723. this.discountList.forEach((item) => {
  724. if (ele.oilName == item.oilName) {
  725. flag = false;
  726. }
  727. });
  728. return flag;
  729. });
  730. },
  731. },
  732. created() {
  733. this.setPageStatus();
  734. this.init();
  735. },
  736. methods: {
  737. delLadder(index) {
  738. this.updateForm.list.splice(index, 1);
  739. if (this.updateForm.list < 1) {
  740. this.updateForm.list.push({
  741. discountAmtEnd: null,
  742. discountAmt: null,
  743. gasoilDiscountAmt: null,
  744. });
  745. this.updateForm = { ...this.updateForm };
  746. }
  747. },
  748. addLadder(e) {
  749. this.updateForm.list.push({
  750. discountAmtEnd: null,
  751. discountAmt: null,
  752. gasoilDiscountAmt: null,
  753. });
  754. this.updateForm = { ...this.updateForm };
  755. },
  756. test(e) {
  757. console.log("---");
  758. console.log(e);
  759. console.log(123);
  760. console.log(this.testd);
  761. },
  762. init() {
  763. listPrice().then((response) => {
  764. this.oilNameOptions = response.rows;
  765. });
  766. this.getPay().then(() => {
  767. this.getList();
  768. });
  769. },
  770. setPageStatus() {
  771. this.queryPageStatus([2]).then((res) => {
  772. this.pageStatus = res;
  773. });
  774. },
  775. timeClear() {
  776. this.updateForm.collectClickCalendar = [];
  777. this.updateForm.collectClickDay = [];
  778. },
  779. getPay() {
  780. return getStationPay().then((response) => {
  781. this.ruleForm = response.data;
  782. this.discountSetting = response.data.discountSetting;
  783. this.currentDiscountName = this.discountName;
  784. });
  785. },
  786. save() {
  787. this.$refs["ruleForm"].validate((valid) => {
  788. if (valid) {
  789. if (this.ruleForm.deptId != null) {
  790. let upPromise = null;
  791. let e = this.ruleForm.discountSetting;
  792. if (e == "0") {
  793. upPromise = updatePay(this.ruleForm).then((response) => {
  794. this.msgSuccess("优惠方案设置成功");
  795. });
  796. } else if (e == "1") {
  797. if (this.discountList.length > 0) {
  798. upPromise = updatePay(this.ruleForm).then((response) => {
  799. this.msgSuccess("优惠方案设置成功");
  800. });
  801. } else {
  802. this.msgError("满减规则下无方案");
  803. return;
  804. }
  805. } else if (e == "2") {
  806. if (this.discountList.length > 0) {
  807. upPromise = updatePay(this.ruleForm).then((response) => {
  808. this.msgSuccess("优惠方案设置成功");
  809. });
  810. } else {
  811. this.msgError("立减规则下无方案");
  812. return;
  813. }
  814. } else if (e == "3") {
  815. if (this.discountList.length > 0) {
  816. upPromise = updatePay(this.ruleForm).then((response) => {
  817. this.msgSuccess("优惠方案设置成功");
  818. });
  819. } else {
  820. this.msgError("直降规则下无方案");
  821. return;
  822. }
  823. } else if (e == "4") {
  824. if (this.discountList.length > 0) {
  825. upPromise = updatePay(this.ruleForm).then((response) => {
  826. this.msgSuccess("优惠方案设置成功");
  827. });
  828. } else {
  829. this.msgError("直降规则下无方案");
  830. return;
  831. }
  832. }
  833. upPromise
  834. .catch((err) => {
  835. this.msgError("设置时出错,请刷新后重试~");
  836. })
  837. .then((res) => {
  838. this.getPay();
  839. });
  840. } else {
  841. this.getPay();
  842. }
  843. }
  844. });
  845. },
  846. discountSettingChang(e) {
  847. console.log(e);
  848. this.discountSetting = e;
  849. this.getList();
  850. },
  851. getList() {
  852. const query = {
  853. pageNum: 1,
  854. pageSize: 100,
  855. discountPlanType: this.discountSetting,
  856. };
  857. listPlan(query).then((response) => {
  858. if(this.discountSetting == 4){
  859. this.discountListTep = response.rows;
  860. return;
  861. }
  862. this.discountList = response.rows;
  863. this.total = response.total;
  864. });
  865. },
  866. vipDiscountyPlusFotmat(row, column) {
  867. if (row.vipDiscountyPlus === "1") {
  868. return "是";
  869. } else if (row.vipDiscountyPlus === "0") {
  870. return "否";
  871. }
  872. },
  873. couponPlusFotmat(row, column) {
  874. if (row.couponPlus === "1") {
  875. return "是";
  876. } else if (row.couponPlus === "0") {
  877. return "否";
  878. }
  879. },
  880. handleUpdateClick() {
  881. this.openDialog = true;
  882. this.updateForm = {
  883. discountPlanType: this.discountSetting,
  884. };
  885. if (this.discountSetting == 4) {
  886. this.updateForm.list = [
  887. {
  888. discountAmtEnd: null,
  889. discountAmt: null,
  890. gasoilDiscountAmt: null,
  891. },
  892. ];
  893. }
  894. },
  895. handleSubmit() {
  896. this.$refs["updateForm"].validate((valid) => {
  897. if (valid) {
  898. // 会员日特殊处理
  899. if (this.updateForm.discountSettingFlag == "1" && this.discountSetting != "4") {
  900. if (
  901. this.updateForm.discountType == "1" ||
  902. this.updateForm.discountType == "2"
  903. ) {
  904. this.updateForm.discountDate =
  905. this.updateForm.collectClickCalendar.toString();
  906. } else {
  907. this.updateForm.discountDate =
  908. this.updateForm.collectClickDay.toString();
  909. }
  910. }
  911. // 阶梯直降
  912. if(this.discountSetting == "4"){
  913. addMarketPlanInfo(this.updateForm).then((res) => {
  914. console.log("哈哈112",res);
  915. }).then((res) => {
  916. this.msgSuccess("新增成功");
  917. this.openDialog = false;
  918. this.getList();
  919. })
  920. }
  921. if (this.updateForm.id != null) {
  922. updatePlan(this.updateForm).then((response) => {
  923. this.msgSuccess("修改成功");
  924. this.openDialog = false;
  925. this.getList();
  926. });
  927. } else {
  928. addPlan(this.updateForm).then((response) => {
  929. this.msgSuccess("新增成功");
  930. this.openDialog = false;
  931. this.getList();
  932. });
  933. }
  934. }
  935. });
  936. },
  937. clickCalendar(index) {
  938. if (this.updateForm.collectClickCalendar.indexOf(index) === -1) {
  939. this.updateForm.collectClickCalendar.push(index);
  940. } else if (this.updateForm.collectClickCalendar.indexOf(index) > -1) {
  941. const temp = this.updateForm.collectClickCalendar.findIndex((ele) => {
  942. return ele == index;
  943. });
  944. this.updateForm.collectClickCalendar.splice(temp, 1);
  945. }
  946. this.$refs.updateForm.validateField("discountType");
  947. this.updateForm = { ...this.updateForm };
  948. },
  949. cancelSubmit() {
  950. this.openDialog = false;
  951. },
  952. /** 修改按钮操作 */
  953. handleUpdate(row) {
  954. const id = row.id;
  955. this.title = "修改满减优惠";
  956. this.openDialog = true;
  957. this.updateForm = row;
  958. },
  959. /** 删除按钮操作 */
  960. handleDelete(row) {
  961. const ids = row.id;
  962. this.$confirm("是否确认删除满减优惠方案?", "警告", {
  963. confirmButtonText: "确定",
  964. cancelButtonText: "取消",
  965. type: "warning",
  966. })
  967. .then(function () {
  968. return delPlan(ids);
  969. })
  970. .then(() => {
  971. this.getList();
  972. this.msgSuccess("删除成功");
  973. });
  974. },
  975. // /** 导出按钮操作 */
  976. // handleExport() {
  977. // const queryParams = this.queryParams;
  978. // this.$confirm("是否确认导出所有优惠设置数据项?", "警告", {
  979. // confirmButtonText: "确定",
  980. // cancelButtonText: "取消",
  981. // type: "warning",
  982. // })
  983. // .then(function () {
  984. // return exportPlan(queryParams);
  985. // })
  986. // .then((response) => {
  987. // this.download(response.msg);
  988. // });
  989. // },
  990. discountSettingTranslate(row) {
  991. if (row.discountSettingFlag == 0) {
  992. return "未设置";
  993. }
  994. // if (this.discountList.integralActivity == 0) {
  995. // return "";
  996. // }
  997. let timeString = "";
  998. const discountType = row.discountType;
  999. if (discountType == 1) {
  1000. timeString += "每周的";
  1001. }
  1002. if (discountType == 2) {
  1003. timeString += "每月的";
  1004. }
  1005. if (discountType == 3) {
  1006. timeString += "指定的日期 ";
  1007. }
  1008. if (discountType == 1 || discountType == 2) {
  1009. (row.discountDate || "")
  1010. .split(",")
  1011. .filter((ele) => {
  1012. return ele !== "";
  1013. })
  1014. .forEach((ele) => {
  1015. timeString += this.timeSelect[discountType][ele] + "、";
  1016. });
  1017. } else if (discountType == 3) {
  1018. timeString += row.discountDate.toString();
  1019. }
  1020. timeString = timeString.replace(/(、)$/g, "") + " 优惠:";
  1021. if (this.discountSetting == 3) {
  1022. timeString +=
  1023. "满" +
  1024. row.discountAmt +
  1025. (row.discountTerm == 2 ? "元" : "L") +
  1026. ",每升优惠" +
  1027. row.discountActivityAmt +
  1028. "元";
  1029. } else if (this.discountSetting == 1) {
  1030. timeString +=
  1031. "每满" + row.discountAmt + "元,减" + row.discountActivityAmt + "元";
  1032. } else if (this.discountSetting == 2) {
  1033. timeString +=
  1034. "满" + row.discountAmt + "元,减" + row.discountActivityAmt + "元";
  1035. }
  1036. return timeString;
  1037. },
  1038. },
  1039. };
  1040. </script>
  1041. <style>
  1042. </style>