Dev_Test copy.vue 28 KB

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