pointTier.vue~ 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item :label="$t('jifen.使用积分数量')" prop="points">
  5. <el-input
  6. v-model="queryParams.points"
  7. placeholder=""
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item :label="$t('jifen.订单金额')" prop="orderCondition">
  13. <el-input
  14. v-model="queryParams.orderCondition"
  15. placeholder=""
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item :label="$t('jifen.启用状态')" prop="isEnabled">
  21. <el-select v-model="queryParams.isEnabled" placeholder="" clearable>
  22. <el-option
  23. :label="$t('jifen.开启')"
  24. :value="1"
  25. />
  26. <el-option
  27. :label="$t('jifen.关闭')"
  28. :value="0"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{$t('jifen.搜索')}}</el-button>
  34. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{$t('jifen.重置')}}</el-button>
  35. </el-form-item>
  36. </el-form>
  37. <el-row :gutter="10" class="mb8">
  38. <el-col :span="1.5">
  39. <el-button
  40. type="primary"
  41. plain
  42. icon="el-icon-plus"
  43. size="mini"
  44. @click="handleAdd"
  45. v-hasPermi="['system:tier:add']"
  46. >{{$t('jifen.新增')}}
  47. </el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="success"
  52. plain
  53. icon="el-icon-edit"
  54. size="mini"
  55. :disabled="single"
  56. @click="handleUpdate"
  57. v-hasPermi="['system:tier:edit']"
  58. >{{$t('jifen.修改')}}
  59. </el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="danger"
  64. plain
  65. icon="el-icon-delete"
  66. size="mini"
  67. :disabled="multiple"
  68. @click="handleDelete"
  69. v-hasPermi="['system:tier:remove']"
  70. >{{$t('jifen.删除')}}
  71. </el-button>
  72. </el-col>
  73. <!-- <el-col :span="1.5">-->
  74. <!-- <el-button-->
  75. <!-- type="warning"-->
  76. <!-- plain-->
  77. <!-- icon="el-icon-download"-->
  78. <!-- size="mini"-->
  79. <!-- @click="handleExport"-->
  80. <!-- v-hasPermi="['system:tier:export']"-->
  81. <!-- >导出-->
  82. <!-- </el-button>-->
  83. <!-- </el-col>-->
  84. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  85. </el-row>
  86. <el-table v-loading="loading" :data="tierList" @selection-change="handleSelectionChange">
  87. <el-table-column type="selection" width="55" align="center"/>
  88. <el-table-column label="id" align="center" prop="id"/>
  89. <el-table-column :label="$t('jifen.使用积分数量')" align="center" prop="points"/>
  90. <el-table-column :label="$t('jifen.订单金额')" align="center" prop="orderCondition"/>
  91. <el-table-column :label="$t('jifen.启用状态')" align="center" prop="isEnabled">
  92. <template slot-scope="scope">
  93. <div v-if="scope.row.isEnabled==1">{{ $t('jifen.开启') }}</div>
  94. <div v-if="scope.row.isEnabled==0">{{ $t('jifen.关闭') }}</div>
  95. </template>
  96. </el-table-column>
  97. <el-table-column :label="$t('jifen.操作')" align="center" class-name="small-padding fixed-width">
  98. <template slot-scope="scope">
  99. <el-button
  100. size="mini"
  101. type="text"
  102. icon="el-icon-edit"
  103. @click="handleUpdate(scope.row)"
  104. v-hasPermi="['system:tier:edit']"
  105. >{{ $t('jifen.修改') }}
  106. </el-button>
  107. <el-button
  108. size="mini"
  109. type="text"
  110. icon="el-icon-delete"
  111. @click="handleDelete(scope.row)"
  112. v-hasPermi="['system:tier:remove']"
  113. >{{ $t('jifen.删除') }}
  114. </el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <pagination
  119. v-show="total>0"
  120. :total="total"
  121. :page.sync="queryParams.pageNum"
  122. :limit.sync="queryParams.pageSize"
  123. @pagination="getList"
  124. />
  125. <!-- 添加或修改积分使用梯次对话框 -->
  126. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  127. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  128. <el-form-item :label=" $t('jifen.使用积分数量')" prop="points">
  129. <el-input v-model="form.points" :placeholder="$t('jifen.请输入使用积分数量')"/>
  130. </el-form-item>
  131. <el-form-item :label=" $t('jifen.订单金额')" prop="orderCondition">
  132. <el-input v-model="form.orderCondition" :placeholder="$t('jifen.订单金额达到该金额时生效')"/>
  133. </el-form-item>
  134. <el-form-item :label="$t('jifen.订单金额')启用状态" prop="isEnabled">
  135. <el-radio-group v-model="form.isEnabled">
  136. <el-radio :label="1">{{ $t('jifen.开启') }}</el-radio>
  137. <el-radio :label="0">{{ $t('jifen.关闭') }}</el-radio>
  138. </el-radio-group>
  139. </el-form-item>
  140. </el-form>
  141. <div slot="footer" class="dialog-footer">
  142. <el-button type="primary" @click="submitForm">{{ $t('jifen.确 定') }}</el-button>
  143. <el-button @click="cancel">{{ $t('jifen.取 消') }}</el-button>
  144. </div>
  145. </el-dialog>
  146. </div>
  147. </template>
  148. <script>
  149. import {listTier, getTier, delTier, addTier, updateTier} from "@/api/system/pointTier";
  150. export default {
  151. name: "Tier",
  152. data() {
  153. return {
  154. // 遮罩层
  155. loading: true,
  156. // 选中数组
  157. ids: [],
  158. // 非单个禁用
  159. single: true,
  160. // 非多个禁用
  161. multiple: true,
  162. // 显示搜索条件
  163. showSearch: true,
  164. // 总条数
  165. total: 0,
  166. // 积分使用梯次表格数据
  167. tierList: [],
  168. // 弹出层标题
  169. title: "",
  170. // 是否显示弹出层
  171. open: false,
  172. // 查询参数
  173. queryParams: {
  174. pageNum: 1,
  175. pageSize: 10,
  176. points: null,
  177. orderCondition: null,
  178. isEnabled: null,
  179. isDeleted: 0,
  180. },
  181. // 表单参数
  182. form: {},
  183. // 表单校验
  184. rules: {
  185. points: [
  186. {required: true, message:this.$t("使用积分数量不能为空"), trigger: "blur"}
  187. ],
  188. orderCondition: [
  189. {required: true, message: this.$t("订单金额不能为空"), trigger: "blur"}
  190. ],
  191. isEnabled: [
  192. {required: true, message: this.$t("启用状态不能为空"), trigger: "blur"}
  193. ],
  194. }
  195. };
  196. },
  197. created() {
  198. this.getList();
  199. },
  200. methods: {
  201. /** 查询积分使用梯次列表 */
  202. getList() {
  203. this.loading = true;
  204. listTier(this.queryParams).then(response => {
  205. this.tierList = response.rows;
  206. this.total = response.total;
  207. this.loading = false;
  208. });
  209. },
  210. // 取消按钮
  211. cancel() {
  212. this.open = false;
  213. this.reset();
  214. },
  215. // 表单重置
  216. reset() {
  217. this.form = {
  218. id: null,
  219. points: null,
  220. orderCondition: null,
  221. isEnabled: null,
  222. isDeleted: null,
  223. createTime: null,
  224. updateTime: null
  225. };
  226. this.resetForm("form");
  227. },
  228. /** 搜索按钮操作 */
  229. handleQuery() {
  230. this.queryParams.pageNum = 1;
  231. this.getList();
  232. },
  233. /** 重置按钮操作 */
  234. resetQuery() {
  235. this.resetForm("queryForm");
  236. this.handleQuery();
  237. },
  238. // 多选框选中数据
  239. handleSelectionChange(selection) {
  240. this.ids = selection.map(item => item.id)
  241. this.single = selection.length !== 1
  242. this.multiple = !selection.length
  243. },
  244. /** 新增按钮操作 */
  245. handleAdd() {
  246. this.reset();
  247. this.open = true;
  248. this.title = this.$t('jifen.新增');
  249. },
  250. /** 修改按钮操作 */
  251. handleUpdate(row) {
  252. this.reset();
  253. const id = row.id || this.ids
  254. getTier(id).then(response => {
  255. this.form = response.data;
  256. this.open = true;
  257. this.title =this.$t('jifen.修改');
  258. });
  259. },
  260. /** 提交按钮 */
  261. submitForm() {
  262. this.$refs["form"].validate(valid => {
  263. if (valid) {
  264. if (this.form.id != null) {
  265. updateTier(this.form).then(response => {
  266. this.$modal.msgSuccess(this.$t("jifen.修改成功"));
  267. this.open = false;
  268. this.getList();
  269. });
  270. } else {
  271. addTier(this.form).then(response => {
  272. this.$modal.msgSuccess(this.$t("jifen.新增成功"));
  273. this.open = false;
  274. this.getList();
  275. });
  276. }
  277. }
  278. });
  279. },
  280. /** 删除按钮操作 */
  281. handleDelete(row) {
  282. const ids = row.id || this.ids;
  283. this.$modal.confirm('是否确认删除数据项?').then(function () {
  284. return delTier(ids);
  285. }).then(() => {
  286. this.getList();
  287. this.$modal.msgSuccess("删除成功");
  288. }).catch(() => {
  289. });
  290. },
  291. /** 导出按钮操作 */
  292. handleExport() {
  293. this.download('system/tier/export', {
  294. ...this.queryParams
  295. }, `tier_${new Date().getTime()}.xlsx`)
  296. }
  297. }
  298. };
  299. </script>