index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <template>
  2. <div class="app-container">
  3. <el-form ref="settingform" :model="settingform" :rules="rules" label-width="130px">
  4. <el-row>
  5. <el-col :span="6" style="">
  6. <el-form-item label="是否启用充值规则">
  7. <el-checkbox-group v-model="cardOilsTypeList">
  8. <el-checkbox v-for = "item in checkList" :key="item.id" :label="item.id" :value="item.value">{{item.value}}</el-checkbox>
  9. </el-checkbox-group>
  10. </el-form-item>
  11. </el-col>
  12. <el-col :span="8" style="">
  13. <el-button type="primary" style="" @click="handleAdd">新增充值规则</el-button>
  14. </el-col>
  15. </el-row>
  16. <div>
  17. <el-table :data="settingform.detailList" >
  18. <el-table-column label="id" align="center" prop="id" v-if="false" />
  19. <el-table-column label="所对应电子会员卡ID" align="center" prop="parentId" v-if="false" />
  20. <el-table-column label="油品" align="center" prop="oilName" :formatter="oilNameFormatter"/>
  21. <el-table-column label="优惠条件金额" align="center" prop="discountAmtTerm" >
  22. <template slot-scope="scope1">
  23. {{scope1.row.discountAmtStart}}≤充值金额(元)&lt;{{scope1.row.discountAmtEnd}}
  24. </template>
  25. </el-table-column>
  26. <el-table-column label="赠送方式" align="center" prop="settingRuleType" :formatter="settingRuleTypeFotmat"/>
  27. <el-table-column label="赠送金额值或比例" align="center" prop="presentAmt">
  28. <template slot-scope="scope2">
  29. {{scope2.row.presentAmt}}
  30. <span v-show="scope2.row.settingRuleType=='1'">元</span>
  31. <span v-show="scope2.row.settingRuleType=='2'">%</span>
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  35. <template slot-scope="scope">
  36. <el-button
  37. size="mini"
  38. type="text"
  39. icon="el-icon-edit"
  40. @click="handleUpdate(scope.$index,scope.row)"
  41. >修改</el-button>
  42. <el-button
  43. size="mini"
  44. type="text"
  45. icon="el-icon-delete"
  46. @click="handleDelete(scope.$index,scope.row)"
  47. >删除</el-button>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. </div>
  52. <el-form-item label="充值活动设置">
  53. </el-form-item>
  54. <el-form-item >
  55. <el-radio-group v-model="settingform.discountTimeSetting">
  56. <el-radio
  57. v-for="dict in discountTimeSettingOptions"
  58. :key="dict.dictValue"
  59. :label="dict.dictValue"
  60. >{{dict.dictLabel}}</el-radio>
  61. </el-radio-group>
  62. </el-form-item>
  63. <el-row>
  64. <el-col :span="8" style="">
  65. <el-form-item label="周期选择" >
  66. <el-select v-model="settingform.discountTimeType" clearable size="mini" @change="datePickerChang" >
  67. <el-option
  68. v-for="item in discountTimeTypeOptions"
  69. :key="item.dictValue"
  70. :label="item.dictLabel"
  71. :value="item.dictValue"
  72. ></el-option>
  73. </el-select>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="8">
  77. <el-form-item v-show="workDaytrue">
  78. <div style="display: flex;flex-wrap: wrap;border-style: solid;border-color:#F5F7FA">
  79. <div v-for="(item, index) in workDay" :key="index" style="margin:3px;">
  80. <div class="hover-style" style="border-radius:5px;font-weight:bold;font-size:12px;cursor: pointer;" @click="clickWorkDayCalendar(item, index)">
  81. <div>{{ item }}</div>
  82. <div v-if="collectClickWorkDay.indexOf(index) > -1" style="width:4px;height:4px;border-radius:50%;background-color:red;position: relative;left:calc(50% - 2px);"></div>
  83. <div v-else style="width:4px;height:4px;"></div>
  84. </div>
  85. </div>
  86. </div>
  87. </el-form-item>
  88. <el-form-item v-show="moonDaytrue" >
  89. <div style="display: flex;flex-wrap: wrap;border-style: solid;border-color:#F5F7FA">
  90. <div v-for="(item, index) in moonEverDay" :key="index" style="margin:3px;">
  91. <div class="hover-style" style="border-radius:5px;font-weight:bold;font-size:12px;cursor: pointer;" @click="clickCalendar(item, index)">
  92. <div>{{ item }}</div>
  93. <div v-if="collectClickCalendar.indexOf(index) > -1" style="width:4px;height:4px;border-radius:50%;background-color:red;position: relative;left:calc(50% - 2px);"></div>
  94. <div v-else style="width:4px;height:4px;"></div>
  95. </div>
  96. </div>
  97. </div>
  98. </el-form-item>
  99. <el-form-item v-show="datetrue">
  100. <el-date-picker clearable size="small" style="margin-left: 10px;width: 200px"
  101. v-model="pickerTime"
  102. type="dates"
  103. value-format="yyyy-MM-dd"
  104. placeholder="选择提醒时间设置">
  105. </el-date-picker>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="8">
  109. <el-form-item label="赠送比例" prop="presentScale">
  110. <el-input v-model="settingform.presentScale" placeholder="请输入赠送比例" style="width:70px;"/>%
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. <el-form-item label="叠加优惠设置" ></el-form-item>
  115. <el-row style="margin-left:80px;">
  116. <el-col :span="8" >
  117. <el-form-item prop="isDiscountCoupon" label="是否叠加优惠券">
  118. <el-radio-group v-model="settingform.isDiscountCoupon">
  119. <el-radio
  120. v-for="dict in isDiscountCouponOptions"
  121. :key="dict.dictValue"
  122. :label="dict.dictValue"
  123. >{{dict.dictLabel}}</el-radio>
  124. </el-radio-group>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="8" >
  128. <el-form-item prop="isMarket" label="是否叠加营销方案">
  129. <el-radio-group v-model="settingform.isMarket">
  130. <el-radio
  131. v-for="dict in isDiscountCouponOptions"
  132. :key="dict.dictValue"
  133. :label="dict.dictValue"
  134. >{{dict.dictLabel}}</el-radio>
  135. </el-radio-group>
  136. </el-form-item>
  137. </el-col>
  138. <el-col :span="8" >
  139. <el-form-item prop="isGradeSetting" label="是否叠加等级优惠">
  140. <el-radio-group v-model="settingform.isGradeSetting">
  141. <el-radio
  142. v-for="dict in isDiscountCouponOptions"
  143. :key="dict.dictValue"
  144. :label="dict.dictValue"
  145. >{{dict.dictLabel}}</el-radio>
  146. </el-radio-group>
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. <el-row>
  151. <el-col :span="8" style="margin-left:80px;">
  152. <el-form-item prop="isDiscountCoupon" label="电子卡支付产生积分可享受倍数" label-width="225px">
  153. <el-input v-model="settingform.enjoyIntegralMultiple" placeholder="请输入积分可享受倍数" style="width:100px;"/>倍
  154. </el-form-item>
  155. </el-col>
  156. </el-row>
  157. </el-form>
  158. <div slot="footer" class="dialog-footer">
  159. <el-button type="primary" @click="submitForm">确 定</el-button>
  160. </div>
  161. <!-- 添加或修改客户电子会员卡充值优惠设置明细对话框 -->
  162. <el-dialog :title="title" :visible.sync="open" append-to-body>
  163. <el-form ref="infoform" :model="infoform" :rules="rules" label-width="110px">
  164. <el-form-item label="选择油品" >
  165. <el-select
  166. v-model="infoform.oilName"
  167. placeholder="请选择油品"
  168. clearable
  169. size="small"
  170. >
  171. <el-option
  172. v-for="item in oilOptions"
  173. :key="item.dictLabel"
  174. :label="item.dictLabel"
  175. :value="item.dictValue"
  176. ></el-option>
  177. </el-select>
  178. </el-form-item>
  179. <el-form-item label="充值条件金额" prop="discountAmtTerm">
  180. <el-input-number v-model="infoform.discountAmtStart" placeholder="请输入充值条件开始金额" style="width:200px;" />
  181. <span>≤充值金额(元)&lt;</span>
  182. <el-input-number v-model="infoform.discountAmtEnd" placeholder="请输入充值条件结束金额" style="width:200px;"/>
  183. </el-form-item>
  184. <el-form-item label="赠送方式"></el-form-item>
  185. <el-row>
  186. <el-col :span="12">
  187. <el-form-item >
  188. <el-select v-model="infoform.settingRuleType" placeholder="请选择赠送方式" @change="settingRuleTypeChange">
  189. <el-option
  190. v-for="item in settingRuleTypeOptions"
  191. :key="item.dictLabel"
  192. :label="item.dictLabel"
  193. :value="item.dictValue"
  194. ></el-option>
  195. </el-select>
  196. </el-form-item>
  197. </el-col>
  198. <el-col :span="12" >
  199. <el-form-item>
  200. <el-input v-model="infoform.presentAmt" style="width:100px;"/>
  201. <span v-show="jine">元</span>
  202. <span v-show="bili">%</span>
  203. </el-form-item>
  204. </el-col>
  205. </el-row>
  206. <el-row>
  207. <span style="color:red;margin-left:90px;">例:按赠送金额:充100赠送10元;按赠送比例:充100赠送10%</span>
  208. </el-row>
  209. </el-form>
  210. <div slot="footer" class="dialog-footer">
  211. <el-button type="primary" @click="save">设置</el-button>
  212. </div>
  213. </el-dialog>
  214. </div>
  215. </template>
  216. <script>
  217. import { addSetting, updateSetting,selectCustomerCardSetting} from "@/api/customer/cardSetting";
  218. export default {
  219. name: "Setting",
  220. data() {
  221. return {
  222. // 总条数
  223. total: 0,
  224. oilOptions:[],
  225. isDiscountCouponOptions:[],
  226. discountTimeSettingOptions:[],
  227. collectClickCalendar: [], // 收集固定日期选择的日子
  228. collectClickWorkDay:[],
  229. discountTimeTypeOptions :[],
  230. settingRuleTypeOptions:[],
  231. checkList:[
  232. {id:"1",value:"汽油"},
  233. {id:"2",value:"柴油"}
  234. ],
  235. cardOilsTypeList:[],
  236. pickerTime:"",
  237. moonEverDay: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10',
  238. '11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
  239. '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
  240. workDay:["周天","周一","周二","周三","周四","周五","周六"],
  241. workDaytrue:false,
  242. moonDaytrue:false,
  243. datetrue:false,
  244. jine:false,
  245. bili:false,
  246. // 弹出层标题
  247. title: "",
  248. // 表单参数
  249. settingform: {
  250. detailList:[]
  251. },
  252. //判断保存次数
  253. num:0,
  254. queryParams:{
  255. stationId: null
  256. },
  257. index1:null,
  258. open:false,
  259. infoform:{},
  260. // 表单校验
  261. rules: {
  262. }
  263. };
  264. },
  265. created() {
  266. this.getDicts("integral_manage").then(response => {
  267. this.discountTimeSettingOptions = response.data;
  268. });
  269. this.getDicts("date_picker").then(response => {
  270. this.discountTimeTypeOptions = response.data;
  271. });
  272. this.getDicts("is_flag").then(response => {
  273. this.isDiscountCouponOptions = response.data;
  274. });
  275. this.getDicts("oil").then(response => {
  276. this.oilOptions = response.data;
  277. });
  278. this.getDicts("setting_rule_type").then(response => {
  279. this.settingRuleTypeOptions = response.data;
  280. });
  281. selectCustomerCardSetting(this.queryParams).then(response => {
  282. if(response.hasOwnProperty('data')){
  283. this.settingform = response.data;
  284. if(this.settingform.cardOilsType!=null &&this.settingform.cardOilsType!="" ){
  285. this.cardOilsTypeList=this.settingform.cardOilsType.split(",");
  286. }
  287. if(this.settingform.discountTimeType == "1"){
  288. this.workDaytrue=true;
  289. this.moonDaytrue=false;
  290. this.datetrue=false;
  291. this.collectClickWorkDay =this.settingform.discountTime.split(",").map(parseFloat);
  292. }else if(this.settingform.discountTimeType == "2"){
  293. this.workDaytrue=false;
  294. this.moonDaytrue=true;
  295. this.datetrue=false;
  296. this.collectClickCalendar= this.settingform.discountTime.split(',').map(parseFloat);
  297. }else if(this.settingform.discountTimeType == "3"){
  298. this.workDaytrue=false;
  299. this.moonDaytrue=false;
  300. this.datetrue=true;
  301. if(this.settingform.discountTime!=""){
  302. this.pickerTime =this.settingform.discountTime.split(",");
  303. }else{
  304. this.pickerTime =null;
  305. }
  306. }
  307. }
  308. });
  309. },
  310. methods: {
  311. oilNameFormatter(row, column){
  312. if(row.oilName === '1'){
  313. return '汽油'
  314. }else if(row.oilName === '2'){
  315. return '柴油'
  316. }
  317. },
  318. settingRuleTypeFotmat(row, column){
  319. if(row.settingRuleType === '1'){
  320. return '按赠送金额'
  321. }else if(row.settingRuleType === '2'){
  322. return '按赠送比例'
  323. }
  324. },
  325. settingRuleTypeChange(){
  326. if(this.infoform.settingRuleType == "1"){
  327. this.jine=true;
  328. this.bili=false;
  329. }else if(this.infoform.settingRuleType == "2"){
  330. this.jine=false;
  331. this.bili=true;
  332. }
  333. },
  334. datePickerChang(){
  335. if(this.settingform.discountTimeType == "1"){
  336. this.workDaytrue=true;
  337. this.moonDaytrue=false;
  338. this.datetrue=false;
  339. }else if(this.settingform.discountTimeType == "2"){
  340. this.workDaytrue=false;
  341. this.moonDaytrue=true;
  342. this.datetrue=false;
  343. }else if(this.settingform.discountTimeType == "3"){
  344. this.workDaytrue=false;
  345. this.moonDaytrue=false;
  346. this.datetrue=true;
  347. }
  348. },
  349. resetInfo() {
  350. this.infoform = {
  351. id: null,
  352. parentId:null,
  353. oilName: null,
  354. discountAmtStart: null,
  355. discountAmtEnd: null,
  356. settingRuleType: null,
  357. presentAmt: null
  358. };
  359. this.resetForm("infoform");
  360. },
  361. /** 新增按钮操作 */
  362. handleAdd() {
  363. this.resetInfo();
  364. this.index1=null;
  365. this.open = true;
  366. this.title = "添加客户电子会员卡充值优惠设置";
  367. },
  368. /** 修改按钮操作 */
  369. handleUpdate(index,row) {
  370. this.index1=index;
  371. this.infoform = row;
  372. this.open = true;
  373. this.title = "修改客户电子会员卡充值优惠设置";
  374. this.settingRuleTypeChange();
  375. },
  376. /** 提交按钮 */
  377. submitForm() {
  378. this.$refs["settingform"].validate(valid => {
  379. if (valid) {
  380. let flag=true;
  381. if(this.cardOilsTypeList !=null && this.cardOilsTypeList.length>0){
  382. this.settingform.cardOilsType=this.cardOilsTypeList.toString();
  383. }else{
  384. this.settingform.cardOilsType="";
  385. flag=false;
  386. }
  387. if (this.settingform.id != null) {
  388. let datepicker = this.settingform.discountTimeType;
  389. if(datepicker=="1"){
  390. if(this.collectClickWorkDay!=null&&this.collectClickWorkDay.length>0){
  391. let discountTime=null;
  392. for(let i =0;i<this.collectClickWorkDay.length;i++){
  393. if(!isNaN(this.collectClickWorkDay[i]) && this.collectClickWorkDay[i]!="NaN"){
  394. if( discountTime!=null){
  395. discountTime =discountTime+","+this.collectClickWorkDay[i];
  396. }else{
  397. discountTime =this.collectClickWorkDay[i];
  398. }
  399. }else{
  400. discountTime =discountTime;
  401. }
  402. }
  403. this.settingform.discountTime=discountTime;
  404. discountTime=null;
  405. } else{
  406. this.settingform.discountTime="";
  407. }
  408. }else if(datepicker=="2"){
  409. if(this.collectClickCalendar!=null&&this.collectClickCalendar.length>0){
  410. let discountTime=null;
  411. for(let i =0;i<this.collectClickCalendar.length;i++){
  412. if(!isNaN(this.collectClickCalendar[i]) && this.collectClickCalendar[i]!="NaN"){
  413. if( discountTime!=null){
  414. discountTime =discountTime+","+this.collectClickCalendar[i];
  415. }else{
  416. discountTime =this.collectClickCalendar[i];
  417. }
  418. }else{
  419. discountTime =discountTime;
  420. }
  421. }
  422. this.settingform.discountTime=discountTime;
  423. discountTime=null;
  424. } else{
  425. this.settingform.discountTime="";
  426. }
  427. }else{
  428. if(this.pickerTime!=null){
  429. this.settingform.discountTime = this.pickerTime.toString();
  430. }else{
  431. this.settingform.discountTime = "";
  432. }
  433. }
  434. updateSetting(this.settingform).then(response => {
  435. this.msgSuccess("修改成功");
  436. this.jine=false;
  437. this.bili=false;
  438. });
  439. } else {
  440. if(this.num==0){
  441. if(datepicker=="1"){
  442. if(this.collectClickWorkDay!=null&&this.collectClickWorkDay.length>0){
  443. let discountTime=null;
  444. for(let i =0;i<this.collectClickWorkDay.length;i++){
  445. if(!isNaN(this.collectClickWorkDay[i]) && this.collectClickWorkDay[i]!="NaN"){
  446. if( discountTime!=null){
  447. discountTime =discountTime+","+this.collectClickWorkDay[i];
  448. }else{
  449. discountTime =this.collectClickWorkDay[i];
  450. }
  451. }else{
  452. discountTime =discountTime;
  453. }
  454. }
  455. this.settingform.discountTime=discountTime;
  456. discountTime=null;
  457. } else{
  458. this.settingform.discountTime="";
  459. }
  460. }else if(datepicker=="2"){
  461. if(this.collectClickCalendar!=null&&this.collectClickCalendar.length>0){
  462. let discountTime=null;
  463. for(let i =0;i<this.collectClickCalendar.length;i++){
  464. if(!isNaN(this.collectClickCalendar[i]) && this.collectClickCalendar[i]!="NaN"){
  465. if( discountTime!=null){
  466. discountTime =discountTime+","+this.collectClickCalendar[i];
  467. }else{
  468. discountTime =this.collectClickCalendar[i];
  469. }
  470. }else{
  471. discountTime =discountTime;
  472. }
  473. }
  474. this.settingform.discountTime=discountTime;
  475. discountTime=null;
  476. } else{
  477. this.settingform.discountTime="";
  478. }
  479. }else{
  480. if(this.pickerTime!=null){
  481. this.settingform.discountTime = this.pickerTime.toString();
  482. }else{
  483. this.settingform.discountTime = "";
  484. }
  485. }
  486. addSetting(this.settingform).then(response => {
  487. this.msgSuccess("新增成功");
  488. this.num=this.num+1;
  489. this.jine=false;
  490. this.bili=false;
  491. });
  492. }else{
  493. this.msgSuccess("已新增成功,如需修改请刷新页面");
  494. }
  495. }
  496. }
  497. });
  498. },
  499. /** 删除按钮操作 */
  500. handleDelete(index) {
  501. this.settingform.detailList.splice(index, 1)
  502. },
  503. deleteItemFromArr(item) {
  504. Array.prototype.indexOf = function(val) {
  505. for (var i = 0; i < this.length; i++) {
  506. if (this[i] === val) {
  507. return i
  508. }
  509. }
  510. return -1
  511. }
  512. // 通过索引删除数组元素
  513. Array.prototype.remove = function(val) {
  514. var index = this.indexOf(val)
  515. if (index > -1) {
  516. this.splice(index, 1)
  517. }
  518. }
  519. // 删除数组元素
  520. this.collectClickCalendar.remove(item)
  521. },
  522. clickCalendar(item, index) {
  523. if (this.collectClickCalendar.indexOf(index) === -1) {
  524. this.collectClickCalendar.push(index)
  525. } else if (this.collectClickCalendar.indexOf(index) > -1) {
  526. this.deleteItemFromArr(index)
  527. }
  528. },
  529. deleteWorkDayFromArr(item) {
  530. Array.prototype.indexOf = function(val) {
  531. for (var i = 0; i < this.length; i++) {
  532. if (this[i] === val) {
  533. return i
  534. }
  535. }
  536. return -1
  537. }
  538. // 通过索引删除数组元素
  539. Array.prototype.remove = function(val) {
  540. var index = this.indexOf(val)
  541. if (index > -1) {
  542. this.splice(index, 1)
  543. }
  544. }
  545. // 删除数组元素
  546. this.collectClickWorkDay.remove(item);
  547. },
  548. clickWorkDayCalendar(item, index) {
  549. if (this.collectClickWorkDay.indexOf(index) === -1) {
  550. this.collectClickWorkDay.push(index)
  551. } else if (this.collectClickWorkDay.indexOf(index) > -1) {
  552. this.deleteWorkDayFromArr(index)
  553. }
  554. },
  555. cancelOpen(){
  556. this.infoform = {
  557. oilName: null,
  558. discountAmtStart: null,
  559. discountAmtEnd: null,
  560. settingRuleType: null,
  561. presentAmt: null
  562. };
  563. this.index1=null;
  564. this.resetForm("infoform");
  565. this.open = false;
  566. this.jine=false;
  567. this.bili=false;
  568. },
  569. save(){
  570. const that = this;
  571. this.$refs["infoform"].validate(valid => {
  572. if (valid) {
  573. if(that.index1!=null){
  574. that.handleDelete(that.index1);
  575. }
  576. that.settingform.detailList.push(that.infoform);
  577. }
  578. });
  579. this.cancelOpen();
  580. }
  581. }
  582. };
  583. </script>