Market_Discount.vue 35 KB

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