index.vue 21 KB

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