Customer_Grade.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div class="app-container" style="padding-top: 5px">
  3. <!--固态等级-->
  4. <p style="margin: 5px">
  5. <el-button
  6. class="settingButton"
  7. type="primary"
  8. icon="el-icon-plus"
  9. size="mini"
  10. @click="handleAdd"
  11. >添加等级</el-button
  12. >
  13. </p>
  14. <el-table :data="settingList">
  15. <af-table-column label="油品名称" align="center" prop="oilName" />
  16. <af-table-column label="等级名称" align="center" prop="grade" />
  17. <af-table-column label="会员条件(元)" align="center">
  18. <template slot-scope="scope">
  19. {{ scope.row.memberConditStart }} ≤累计历史消费金额&lt;{{
  20. scope.row.memberConditEnd
  21. }}
  22. </template>
  23. </af-table-column>
  24. <af-table-column label="优惠 (元/L)" align="center" prop="discountAmt" />
  25. <af-table-column
  26. label="操作"
  27. align="center"
  28. class-name="small-padding fixed-width "
  29. width="120px"
  30. >
  31. <template slot-scope="scope">
  32. <!-- <el-button
  33. size="mini"
  34. type="text"
  35. icon="el-icon-edit"
  36. @click="handleUpdate(scope.row)"
  37. >修改</el-button
  38. > -->
  39. <el-button
  40. size="mini"
  41. type="text"
  42. icon="el-icon-delete"
  43. @click="handleDelete(scope.row)"
  44. >删除</el-button
  45. >
  46. </template>
  47. </af-table-column>
  48. </el-table>
  49. <!-- 添加或修改客户优惠等级设置对话框 -->
  50. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  51. <el-form ref="form" :model="form" :rules="rules" label-width="90px">
  52. <el-form-item label="油品名称" prop="oilName">
  53. <el-select
  54. v-model="form.oilName"
  55. placeholder="油品名称"
  56. clearable
  57. size="small"
  58. >
  59. <el-option
  60. v-for="dict in oilNameOptions"
  61. :key="dict.oilName"
  62. :label="dict.oilName"
  63. :value="dict.oilName"
  64. />
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="等级名称" prop="grade">
  68. <el-input v-model="form.grade" placeholder="请输入等级名称" />
  69. </el-form-item>
  70. <el-form-item label="会员条件" prop="memberConditEnd" required>
  71. <div>
  72. <el-input-number
  73. v-model="form.memberConditStart"
  74. style="width: 110px"
  75. size="mini"
  76. :min="0"
  77. />
  78. ≤累计消费金额(元)&lt;
  79. <el-input-number
  80. v-model="form.memberConditEnd"
  81. style="width: 110px"
  82. size="mini"
  83. :min="0"
  84. />
  85. </div>
  86. <span
  87. ><font style="color: red; size: 10px"
  88. >注:优惠条件按照累计历史消费金额计算</font
  89. ></span
  90. >
  91. </el-form-item>
  92. <el-form-item label="优惠金额" prop="discountAmt">
  93. <el-input-number
  94. v-model="form.discountAmt"
  95. size="mini"
  96. :min="0"
  97. placeholder="请输入优惠金额"
  98. />
  99. 元/L
  100. </el-form-item>
  101. <el-form-item label="类型" v-show="false" prop="growthValue">
  102. <el-input v-model="form.gradeType" value="1" />
  103. </el-form-item>
  104. </el-form>
  105. <div slot="footer" class="dialog-footer">
  106. <el-button type="primary" @click="submitForm">确 定</el-button>
  107. <el-button @click="cancel">取 消</el-button>
  108. </div>
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. import {
  114. listSetting,
  115. getSetting,
  116. delSetting,
  117. addSetting,
  118. updateSetting,
  119. } from "@/api/customer/setting";
  120. import { listPrice } from "@/api/station/price";
  121. export default {
  122. name: "Customer_Grade",
  123. data() {
  124. const validatorMemberConditEnd = (rule, value, callback) => {
  125. if (!value) {
  126. callback(new Error("请填入会员条件"));
  127. return;
  128. }
  129. const start = +this.form.memberConditStart;
  130. const end = +value;
  131. if (isNaN(start) || isNaN(end)) {
  132. callback(new Error("请填入数字"));
  133. return;
  134. }
  135. if (start >= end) {
  136. console.log(start, end);
  137. callback(new Error("请检查数字逻辑有效性"));
  138. return;
  139. }
  140. callback();
  141. };
  142. return {
  143. // 总条数
  144. total: 0,
  145. settingList: [],
  146. //下拉油品名称
  147. oilNameOptions: [],
  148. // 弹出层标题
  149. title: "",
  150. // 是否显示弹出层
  151. open: false,
  152. // 查询参数
  153. queryParams: {
  154. pageNum: 1,
  155. pageSize: 100,
  156. },
  157. // 表单参数
  158. form: {},
  159. // 表单校验
  160. rules: {
  161. oilName: [{ required: true, message: "请填写联系人", trigger: "blur" }],
  162. grade: [{ required: true, message: "请填写等级名称", trigger: "blur" }],
  163. memberConditEnd: [
  164. { validator: validatorMemberConditEnd, trigger: "change" },
  165. ],
  166. discountAmt: [
  167. { required: true, message: "请填写优惠金额", trigger: "blur" },
  168. ],
  169. },
  170. };
  171. },
  172. created() {
  173. this.getList();
  174. listPrice().then((response) => {
  175. this.oilNameOptions = response.rows;
  176. });
  177. },
  178. methods: {
  179. /** 查询客户优惠等级设置列表 */
  180. getList() {
  181. listSetting(this.queryParams).then((response) => {
  182. this.settingList = response.rows;
  183. this.total = response.total;
  184. });
  185. },
  186. // 取消按钮
  187. cancel() {
  188. this.open = false;
  189. },
  190. /** 新增按钮操作 */
  191. handleAdd() {
  192. this.open = true;
  193. this.title = "添加客户优惠等级";
  194. this.form = {};
  195. },
  196. /** 修改按钮操作 */
  197. handleUpdate(row) {
  198. const id = row.id;
  199. this.form = row;
  200. this.open = true;
  201. this.title = "修改客户优惠等级";
  202. },
  203. /** 提交按钮 */
  204. submitForm() {
  205. this.$refs["form"].validate((valid) => {
  206. if (valid) {
  207. if (this.form.id != null) {
  208. updateSetting(this.form).then((response) => {
  209. this.msgSuccess("修改成功");
  210. this.open = false;
  211. this.getList();
  212. });
  213. } else {
  214. addSetting(this.form).then((response) => {
  215. this.msgSuccess("新增成功");
  216. this.open = false;
  217. this.getList();
  218. });
  219. }
  220. }
  221. });
  222. },
  223. /** 删除按钮操作 */
  224. handleDelete(row) {
  225. const ids = row.id;
  226. this.$confirm("确认删除该条等级优惠信息?", "警告", {
  227. confirmButtonText: "确定",
  228. cancelButtonText: "取消",
  229. type: "warning",
  230. })
  231. .then(function () {
  232. return delSetting(ids);
  233. })
  234. .then(() => {
  235. this.getList();
  236. this.msgSuccess("删除成功");
  237. });
  238. },
  239. },
  240. };
  241. </script>
  242. <style>
  243. .two {
  244. margin-top: 30px;
  245. }
  246. .settingButton {
  247. border: 0px;
  248. float: right;
  249. }
  250. .cutLine {
  251. width: 65px;
  252. height: 2px;
  253. background: #71f332;
  254. /*margin-top: 5px;*/
  255. margin-left: 5px;
  256. margin-bottom: 20px;
  257. }
  258. .textlineHeader {
  259. /*margin-bottom: 20px;*/
  260. font-family: Bahnschrift;
  261. /*text-shadow: #32a9f3 1px 1px 1px;*/
  262. /*font-size: ;*/
  263. color: #32a9f3;
  264. }
  265. </style>