index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <div class="app-container" style="padding-top: 5px;">
  3. <!--固态等级-->
  4. <p style="margin: 5px"><span class="textlineHeader">固定等级</span>
  5. <el-button class="settingButton" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['customer:setting:add']" >添加固定等级</el-button>
  6. </p>
  7. <div class="cutLine firstLine"></div>
  8. <el-table v-loading="loading" :data="settingList" >
  9. <el-table-column label="id" align="center" prop="id" v-if="false"/>
  10. <el-table-column label="等级名称" align="center" prop="grade" />
  11. <el-table-column label="优惠方式" align="center" prop="discountWay" />
  12. <el-table-column label="会员条件" align="center" prop="memberCondit" />
  13. <el-table-column label="汽油优惠/L" align="center" prop="gasoilDiscountLitre" />
  14. <el-table-column label="柴油优惠/L" align="center" prop="dieseloilDiscountLitre" />
  15. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  16. <template slot-scope="scope">
  17. <el-button
  18. size="mini"
  19. type="text"
  20. icon="el-icon-edit"
  21. @click="handleUpdate(scope.row)"
  22. v-hasPermi="['customer:setting:edit']"
  23. >修改</el-button>
  24. <el-button
  25. size="mini"
  26. type="text"
  27. icon="el-icon-delete"
  28. @click="handleDelete(scope.row)"
  29. v-hasPermi="['customer:setting:remove']"
  30. >删除</el-button>
  31. </template>
  32. </el-table-column>
  33. </el-table>
  34. <!-- 添加或修改客户优惠等级设置对话框 -->
  35. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  36. <el-form ref="form" :model="form" :rules="rules" label-width="90px">
  37. <el-form-item label="等级" prop="grade">
  38. <el-input v-model="form.grade" placeholder="请输入等级" />
  39. </el-form-item>
  40. <el-form-item label="优惠方式" prop="discountWay">
  41. <el-input v-model="form.discountWay" placeholder="请输入优惠方式" />
  42. </el-form-item>
  43. <el-form-item label="会员条件" prop="discountWay">
  44. <el-input v-model="form.memberCondit" placeholder="请输入优惠方式" />
  45. </el-form-item>
  46. <el-form-item label="汽油优惠/L" prop="gasoilDiscountLitre">
  47. <el-input v-model="form.gasoilDiscountLitre" placeholder="请输入汽油优惠/L" />
  48. </el-form-item>
  49. <el-form-item label="柴油优惠/L" prop="dieseloilDiscountLitre">
  50. <el-input v-model="form.dieseloilDiscountLitre" placeholder="请输入柴油优惠/L" />
  51. </el-form-item>
  52. <el-form-item label="类型" v-show="false" prop="growthValue">
  53. <el-input v-model="form.gradeType" value="1" />
  54. </el-form-item>
  55. </el-form>
  56. <div slot="footer" class="dialog-footer">
  57. <el-button type="primary" @click="submitForm">确 定</el-button>
  58. <el-button @click="cancel">取 消</el-button>
  59. </div>
  60. </el-dialog>
  61. <!--成长规则-->
  62. <!-- <p style="margin-left: 5px; margin-top: 25px; margin-bottom: 5px;">
  63. <span class="textlineHeader">成长规则</span>
  64. <el-button icon="el-icon-plus" size="mini" @click="handleAddGrouthRules" class="settingButton">添加成长规则</el-button>
  65. </p>
  66. <div class="cutLine secLine"></div>
  67. <el-table v-loading="loading" :data="grouthRuleList" >
  68. <el-table-column label="id" align="center" prop="id" v-if="false" />
  69. <el-table-column label="成长规则名称" align="center" prop="grouthValueName" />
  70. <el-table-column label="消费值" align="center" prop="grouthValueConsume" />
  71. <el-table-column label="成长值" align="center" prop="grouthValue" />
  72. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  73. <template slot-scope="scope2">
  74. <el-button
  75. size="mini"
  76. type="text"
  77. icon="el-icon-edit"
  78. @click="grouthRuleUpdate(scope2.row)"
  79. >修改</el-button>
  80. <el-button
  81. size="mini"
  82. type="text"
  83. icon="el-icon-delete"
  84. @click="grouthRuleDelete(scope2.row)"
  85. >删除</el-button>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. &lt;!&ndash;添加或修改成长规则&ndash;&gt;
  90. <el-dialog :title="title" :visible.sync="openGrouthRule" width="500px" append-to-body>
  91. <el-form ref="formGrouthRule" :model="formGrouthRule" :rules="grouthRules" label-width="100px">
  92. <el-form-item label="成长规则名称" prop="grouthValueName">
  93. <el-input v-model="formGrouthRule.grouthValueName" placeholder="请输入成长规则名称" />
  94. </el-form-item>
  95. <el-form-item label="消费值" prop="grouthValueConsume">
  96. <el-input v-model="formGrouthRule.grouthValueConsume" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入消费值" />
  97. </el-form-item>
  98. <el-form-item label="成长值" prop="grouthValue">
  99. <el-input v-model="formGrouthRule.grouthValue" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入成长值" />
  100. </el-form-item>
  101. </el-form>
  102. <div slot="footer" class="dialog-footer">
  103. <el-button type="primary" @click="submitFormGrouthRule">确 定</el-button>
  104. <el-button @click="cancelGrouthRule">取 消</el-button>
  105. </div>
  106. </el-dialog>
  107. &lt;!&ndash;动态等级&ndash;&gt;
  108. <p style="margin-left: 5px; margin-top: 25px; margin-bottom: 5px;"><span class="textlineHeader">动态等级</span>
  109. <el-button class="settingButton" icon="el-icon-plus" size="mini" @click="handleAddDT" v-hasPermi="['customer:setting:add']" >添加动态等级</el-button>
  110. </p>
  111. <div class="cutLine"></div>
  112. <el-table v-loading="loading" :data="DTsettingList" >
  113. <el-table-column label="id" align="center" prop="id" v-if="false" />
  114. <el-table-column label="等级名称" align="center" prop="grade" />
  115. <el-table-column label="成长值" align="center" prop="growthValue" />
  116. <el-table-column label="有效期" align="center" prop="date" width="180">
  117. <template slot-scope="scope1">
  118. <span>{{ parseTime(scope1.row.date, '{y}-{m}-{d}') }}</span>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="到期扣除成长值" align="center" prop="deductionGrowthValue" />
  122. <el-table-column label="汽油优惠/L" align="center" prop="gasoilDiscountLitre" />
  123. <el-table-column label="柴油优惠/L" align="center" prop="dieseloilDiscountLitre" />
  124. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  125. <template slot-scope="scope1">
  126. <el-button
  127. size="mini"
  128. type="text"
  129. icon="el-icon-edit"
  130. @click="handleUpdateDT(scope1.row)"
  131. v-hasPermi="['customer:setting:edit']"
  132. >修改</el-button>
  133. <el-button
  134. size="mini"
  135. type="text"
  136. icon="el-icon-delete"
  137. @click="handleDeleteDT(scope1.row)"
  138. v-hasPermi="['customer:setting:remove']"
  139. >删除</el-button>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. &lt;!&ndash; 添加或修改动态客户优惠等级设置对话框 &ndash;&gt;
  144. <el-dialog :title="title" :visible.sync="opendt" width="500px" append-to-body>
  145. <el-form ref="dtform" :model="dtform" :rules="dtrules" label-width="110px">
  146. <el-form-item label="等级" prop="grade">
  147. <el-input v-model="dtform.grade" placeholder="请输入等级" />
  148. </el-form-item>
  149. <el-form-item label="成长值" prop="growthValue">
  150. <el-input v-model="dtform.growthValue" placeholder="请输入成长值" />
  151. </el-form-item>
  152. <el-form-item label="类型" v-show="false" prop="gradeType">
  153. <el-input v-model="dtform.gradeType"/>
  154. </el-form-item>
  155. <el-form-item label="有效期" prop="date">
  156. <el-date-picker clearable size="small" style="width: 200px"
  157. v-model="dtform.date"
  158. type="date"
  159. value-format="yyyy-MM-dd"
  160. placeholder="选择有效期">
  161. </el-date-picker>
  162. </el-form-item>
  163. <el-form-item label="到期扣除成长值" prop="deductionGrowthValue">
  164. <el-input v-model="dtform.deductionGrowthValue" placeholder="请输入到期扣除成长值" />
  165. </el-form-item>
  166. <el-form-item label="汽油优惠/L" prop="gasoilDiscountLitre">
  167. <el-input v-model="dtform.gasoilDiscountLitre" placeholder="请输入汽油优惠/L" />
  168. </el-form-item>
  169. <el-form-item label="柴油优惠/L" prop="dieseloilDiscountLitre">
  170. <el-input v-model="dtform.dieseloilDiscountLitre" placeholder="请输入柴油优惠/L" />
  171. </el-form-item>
  172. </el-form>
  173. <div slot="footer" class="dialog-footer">
  174. <el-button type="primary" @click="submitFormDT">确 定</el-button>
  175. <el-button @click="cancelDT">取 消</el-button>
  176. </div>
  177. </el-dialog>-->
  178. </div>
  179. </template>
  180. <script>
  181. import { listSetting, getGrouthRuleList, addGrouthRule, editGrouthRule, delGrouthRule, getSetting, delSetting, addSetting, updateSetting, exportSetting } from "@/api/customer/setting";
  182. export default {
  183. name: "Setting",
  184. data() {
  185. return {
  186. // 遮罩层
  187. loading: true,
  188. // 选中数组
  189. ids: [],
  190. // 非单个禁用
  191. single: true,
  192. // 非多个禁用
  193. multiple: true,
  194. // 显示搜索条件
  195. showSearch: true,
  196. // 总条数
  197. total: 0,
  198. // 客户优惠等级设置表格数据
  199. ruleList: [],
  200. grouthRuleList:[],
  201. settingList: [],
  202. DTsettingList: [],
  203. // 弹出层标题
  204. title: "",
  205. // 是否显示弹出层
  206. open: false,
  207. opendt: false,
  208. openGrouthRule: false,
  209. // 查询参数
  210. queryParams: {
  211. pageNum: 1,
  212. pageSize: 10,
  213. grade: null,
  214. discountWay: null,
  215. gasoilDiscountLitre: null,
  216. dieseloilDiscountLitre: null,
  217. gradeType: null,
  218. grouthValueName: null,
  219. grouthValueConsume: null,
  220. grouthValue: null,
  221. // gasoilConsume: null,
  222. // gasoilGrowthValue: null,
  223. // dieseloilConsume: null,
  224. // dieseloilGrowthValue: null,
  225. date: null,
  226. deductionGrowthValue: null
  227. },// 查询参数
  228. selectParams: {
  229. pageNum: 1,
  230. pageSize: 10,
  231. grade: null,
  232. discountWay: null,
  233. gasoilDiscountLitre: null,
  234. dieseloilDiscountLitre: null,
  235. gradeType: null,
  236. grouthValueName: null,
  237. grouthValueConsume: null,
  238. grouthValue: null,
  239. // gasoilConsume: null,
  240. // gasoilGrowthValue: null,
  241. // dieseloilConsume: null,
  242. // dieseloilGrowthValue: null,
  243. date: null,
  244. deductionGrowthValue: null
  245. },
  246. // 表单参数
  247. form: {},
  248. formGrouthRule:{},
  249. dtform: {},
  250. ruleForm: {},
  251. // 表单校验
  252. rules: {
  253. },
  254. grouthRules: {},
  255. dtrules: {
  256. }
  257. };
  258. },
  259. created() {
  260. this.getList();
  261. //this.getRuleList();
  262. // this.getList2();
  263. },
  264. methods: {
  265. /** 查询客户优惠等级设置列表 */
  266. getList() {
  267. this.queryParams.gradeType="1";
  268. this.loading = true;
  269. listSetting(this.queryParams).then(response => {
  270. this.settingList = response.rows;
  271. this.total = response.total;
  272. this.loading = false;
  273. });
  274. },
  275. getList2() {
  276. this.selectParams.gradeType="3";
  277. this.loading = true;
  278. listSetting(this.selectParams).then(response => {
  279. this.DTsettingList = response.rows;
  280. this.total = response.total;
  281. this.loading = false;
  282. });
  283. },
  284. // 取消按钮
  285. cancel() {
  286. this.open = false;
  287. this.reset();
  288. },
  289. // 取消按钮
  290. cancelDT() {
  291. this.opendt = false;
  292. this.reset();
  293. },
  294. // 表单重置
  295. reset() {
  296. this.form = {
  297. id: null,
  298. grade: null,
  299. discountWay: null,
  300. gasoilDiscountLitre: null,
  301. dieseloilDiscountLitre: null,
  302. gradeType: null,
  303. grouthValueName: null,
  304. grouthValueConsume: null,
  305. grouthValue: null,
  306. // gasoilConsume: null,
  307. // gasoilGrowthValue: null,
  308. // dieseloilConsume: null,
  309. // dieseloilGrowthValue: null,
  310. date: null,
  311. deductionGrowthValue: null
  312. };
  313. this.resetForm("form");
  314. //this.resetForm("formGrouthRule");
  315. },
  316. /** 新增按钮操作 */
  317. handleAdd() {
  318. this.reset();
  319. this.open = true;
  320. this.title = "添加客户优惠等级设置";
  321. },
  322. /** 修改按钮操作 */
  323. handleUpdate(row) {
  324. this.reset();
  325. const id = row.id || this.ids
  326. getSetting(id).then(response => {
  327. this.form = response.data;
  328. this.open = true;
  329. this.title = "修改客户优惠等级设置";
  330. });
  331. },
  332. //查询成长规则列表
  333. getRuleList() {
  334. this.loading = true;
  335. getGrouthRuleList().then(response => {
  336. this.grouthRuleList = response.rows;
  337. this.total = response.total;
  338. this.loading = false;
  339. });
  340. },
  341. //打开新增成长规则窗口
  342. handleAddGrouthRules(){
  343. //this.reset();
  344. this.formGrouthRule = {};
  345. this.openGrouthRule = true;
  346. this.title = "添加成长规则";
  347. },
  348. //打开修改成长规则窗口
  349. grouthRuleUpdate(row){
  350. this.reset();
  351. this.formGrouthRule = row;
  352. this.openGrouthRule = true;
  353. this.title = "修改成长规则";
  354. //const id = row.id
  355. // editGrouthRule(id).then(response => {
  356. // this.formGrouthRule = response.data;
  357. // this.openGrouthRule = true;
  358. // this.title = "修改成长规则"
  359. // });
  360. },
  361. //取消按钮
  362. cancelGrouthRule(){
  363. this.openGrouthRule = false;
  364. this.reset();
  365. },
  366. //提交新增和修改成长规则
  367. submitFormGrouthRule(){
  368. this.$refs['formGrouthRule'].validate(valid =>{
  369. if(valid){
  370. if(this.formGrouthRule.id != null){
  371. editGrouthRule(this.formGrouthRule).then(response =>{
  372. this.msgSuccess("修改成功")
  373. this.openGrouthRule = false;
  374. this.getRuleList();
  375. });
  376. }else{
  377. addGrouthRule(this.formGrouthRule).then(response =>{
  378. this.msgSuccess("新增成功");
  379. this.openGrouthRule =false;
  380. this.getRuleList();
  381. })
  382. }
  383. }
  384. });
  385. },
  386. //删除成长规则
  387. grouthRuleDelete(row){
  388. const ids = row.id || this.ids
  389. if(row.id !=null || this.ids != null){
  390. this.$confirm('是否删除该成长规则的数据项?', "警告",{
  391. confirmButtonText: "确定",
  392. cancelButtonText: "取消",
  393. type: "warning"
  394. }).then(function () {
  395. delGrouthRule(ids);
  396. }).then(() =>{
  397. this.msgSuccess("删除成功");
  398. this.getRuleList();
  399. })
  400. }
  401. },
  402. /** 新增按钮操作 */
  403. handleAddDT() {
  404. this.reset();
  405. this.opendt = true;
  406. this.title = "添加客户优惠等级设置";
  407. },
  408. /** 修改按钮操作 */
  409. handleUpdateDT(row) {
  410. this.reset();
  411. const id = row.id || this.ids
  412. getSetting(id).then(response => {
  413. this.dtform = response.data;
  414. this.opendt = true;
  415. this.title = "修改客户优惠等级设置";
  416. });
  417. },
  418. /** 提交按钮 */
  419. submitForm() {
  420. this.form.gradeType="1";
  421. this.$refs["form"].validate(valid => {
  422. if (valid) {
  423. if (this.form.id != null) {
  424. updateSetting(this.form).then(response => {
  425. this.msgSuccess("修改成功");
  426. this.open = false;
  427. this.getList();
  428. });
  429. } else {
  430. addSetting(this.form).then(response => {
  431. this.msgSuccess("新增成功");
  432. this.open = false;
  433. this.getList();
  434. });
  435. }
  436. }
  437. });
  438. },
  439. /** 提交按钮 */
  440. submitFormDT() {
  441. this.dtform.gradeType="3";
  442. this.$refs["dtform"].validate(valid => {
  443. if (valid) {
  444. if (this.dtform.id != null) {
  445. updateSetting(this.dtform).then(response => {
  446. this.msgSuccess("修改成功");
  447. this.opendt = false;
  448. this.getList2();
  449. });
  450. } else {
  451. addSetting(this.dtform).then(response => {
  452. this.msgSuccess("新增成功");
  453. this.opendt= false;
  454. this.getList2();
  455. });
  456. }
  457. }
  458. });
  459. },
  460. /** 删除按钮操作 */
  461. handleDelete(row) {
  462. const ids = row.id || this.ids;
  463. this.$confirm('是否确认删除客户优惠等级设置编号为"' + ids + '"的数据项?', "警告", {
  464. confirmButtonText: "确定",
  465. cancelButtonText: "取消",
  466. type: "warning"
  467. }).then(function() {
  468. return delSetting(ids);
  469. }).then(() => {
  470. this.getList();
  471. this.msgSuccess("删除成功");
  472. })
  473. },
  474. /** 删除按钮操作 */
  475. handleDeleteDT(row) {
  476. const ids = row.id || this.ids;
  477. this.$confirm('是否确认删除客户优惠等级设置编号为"' + ids + '"的数据项?', "警告", {
  478. confirmButtonText: "确定",
  479. cancelButtonText: "取消",
  480. type: "warning"
  481. }).then(function() {
  482. return delSetting(ids);
  483. }).then(() => {
  484. this.getList2();
  485. this.msgSuccess("删除成功");
  486. })
  487. },
  488. /** 导出按钮操作 */
  489. handleExport() {
  490. const queryParams = this.queryParams;
  491. this.$confirm('是否确认导出所有客户优惠等级设置数据项?', "警告", {
  492. confirmButtonText: "确定",
  493. cancelButtonText: "取消",
  494. type: "warning"
  495. }).then(function() {
  496. return exportSetting(queryParams);
  497. }).then(response => {
  498. this.download(response.msg);
  499. })
  500. }
  501. }
  502. };
  503. </script>
  504. <style>
  505. .two{
  506. margin-top: 30px;
  507. }
  508. .settingButton{
  509. border: 0px;
  510. float: right;
  511. }
  512. .cutLine{
  513. width: 65px;
  514. height: 2px;
  515. background: #71f332;
  516. /*margin-top: 5px;*/
  517. margin-left: 5px;
  518. margin-bottom: 20px;
  519. }
  520. .textlineHeader{
  521. /*margin-bottom: 20px;*/
  522. font-family: Bahnschrift;
  523. /*text-shadow: #32a9f3 1px 1px 1px;*/
  524. /*font-size: ;*/
  525. color: #32a9f3;
  526. }
  527. </style>