pointRulesList.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <div class="app-container calendar-list-container">
  3. <!-- 查询和其他操作 -->
  4. <div class="filter-container">
  5. <el-select v-model="listQuery.type" clearable placeholder="积分规则类型" style="top: -4px;width: 200px;">
  6. <el-option :key="item.dictValue" v-for="item in allTypeList" :label="item.dictLabel" :value="item.dictValue">
  7. </el-option>
  8. </el-select>
  9. <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">查找</el-button>
  10. <el-button class="filter-item" type="primary" @click="handleCreate" icon="el-icon-edit">添加</el-button>
  11. </div>
  12. <!-- 查询结果 -->
  13. <el-table size="small" :data="list" v-loading="listLoading" element-loading-text="正在查询中。。。" border fit
  14. highlight-current-row>
  15. <el-table-column type="index" label="序号" header-align="center" align="center">
  16. </el-table-column>
  17. <el-table-column align="center" min-width="100px" label="积分类型" prop="integralTypeName">
  18. </el-table-column>
  19. <!-- <el-table-column align="center" min-width="200px" label="积分说明" prop="integralName">
  20. </el-table-column> -->
  21. <el-table-column align="center" min-width="80px" label="积分" prop="integral">
  22. </el-table-column>
  23. <el-table-column align="center" min-width="80px" label="状态">
  24. <template slot-scope="props">
  25. <el-tag type="success" v-if="props.row.status == 1">启用</el-tag>
  26. <el-tag type="danger" v-if="props.row.status == 0">关闭</el-tag>
  27. </template>
  28. </el-table-column>
  29. <el-table-column align="center" label="操作" width="240px" class-name="small-padding fixed-width">
  30. <template slot-scope="scope">
  31. <el-button type="primary" size="small" @click="handleUpdate(scope.row, false)">编辑</el-button>
  32. <el-button v-if="scope.row.status == 0" type="success" size="small"
  33. @click="changeState(scope.row.id, 1)">开启</el-button>
  34. <el-button v-if="scope.row.status == 1" type="warning" size="small"
  35. @click="changeState(scope.row.id, 0)">关闭</el-button>
  36. <el-button type="danger" size="mini" @click="handleDelete(scope.row.id, -1)">删除</el-button>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. <!-- 分页 -->
  41. <div class="pagination-container">
  42. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  43. :current-page="listQuery.page" :page-sizes="[10, 20, 30, 50]" :page-size="listQuery.limit"
  44. layout="total, sizes, prev, pager, next, jumper" :total="total">
  45. </el-pagination>
  46. </div>
  47. <!-- 添加或修改对话框 -->
  48. <el-dialog :close-on-click-modal="false" :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="45%">
  49. <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="100px"
  50. style='width:700px; margin-left:50px;'>
  51. <el-form-item v-if="dialogStatus == 'create'" label="规则类型" prop="integralType">
  52. <el-select v-model="dataForm.integralType" clearable style="width: 350px;">
  53. <el-option :key="item.dictValue" v-for="item in allTypeList" :label="item.dictLabel" :value="item.dictValue">
  54. </el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item v-else label="规则类型">
  58. <el-input disabled v-model="dataForm.integralTypeName" style="width: 350px"></el-input>
  59. </el-form-item>
  60. <el-form-item label="积分" prop="integral">
  61. <el-input-number
  62. :precision="0"
  63. :step="1"
  64. v-model="dataForm.integral"
  65. ></el-input-number>
  66. </el-form-item>
  67. </el-form>
  68. <div slot="footer" class="dialog-footer">
  69. <el-button @click="dialogFormVisible = false">取消</el-button>
  70. <el-button v-if="dialogStatus == 'create'" type="primary" @click="createData">确定</el-button>
  71. <el-button v-else type="primary" @click="updateData">确定</el-button>
  72. </div>
  73. </el-dialog>
  74. </div>
  75. </template>
  76. <style>
  77. .demo-table-expand {
  78. font-size: 0;
  79. }
  80. .demo-table-expand label {
  81. width: 200px;
  82. color: #99a9bf;
  83. }
  84. .demo-table-expand .el-form-item {
  85. margin-right: 0;
  86. margin-bottom: 0;
  87. }
  88. </style>
  89. <script>
  90. import { getPointRulesList, pointRulesCreateItem, pointRulesUpdateItem, pointRulesState } from "@/api/pointManage";
  91. import { dataTypeList } from "@/api/public";
  92. import waves from "@/directive/waves"; // 水波纹指令
  93. import Tinymce from '@/components/Tinymce'
  94. export default {
  95. name: 'pointRulesList',
  96. components: { Tinymce },
  97. directives: { waves },
  98. data() {
  99. return {
  100. allTypeList: [
  101. ],
  102. flagList: [
  103. {
  104. type: 1,
  105. name: '启用'
  106. },
  107. {
  108. type: 0,
  109. name: '禁用'
  110. },
  111. ],
  112. list: [],
  113. total: 0,
  114. listLoading: false,
  115. listQuery: {
  116. page: 1,
  117. limit: 10,
  118. type: '',
  119. },
  120. dataForm: {
  121. integral: undefined,
  122. integralType: undefined,
  123. },
  124. dialogFormVisible: false,
  125. dialogStatus: '',
  126. textMap: {
  127. update: "编辑",
  128. create: "创建",
  129. },
  130. rules: {
  131. integral: [{ required: true, message: "积分不能为空", trigger: "blur" }],
  132. integralType: [{ required: true, message: "请选择规则类型", trigger: "blur" }],
  133. },
  134. }
  135. },
  136. created() {
  137. this.getPointRulesType();
  138. this.getList();
  139. },
  140. methods: {
  141. changeState(ruleId, index) {
  142. pointRulesState({ ruleId: ruleId, status: index }).then(response => {
  143. this.$notify({
  144. title: '成功',
  145. message: '活动状态修改成功',
  146. type: 'success',
  147. duration: 2000
  148. })
  149. this.getList()
  150. })
  151. },
  152. handleDelete(ruleId, index) {
  153. this.$confirm('确认删除吗?', '提示', {
  154. confirmButtonText: '确定',
  155. cancelButtonText: '取消',
  156. type: 'warning'
  157. }).then(() => {
  158. pointRulesState({ ruleId: ruleId, status: index }).then(response => {
  159. this.$notify({
  160. title: '成功',
  161. message: '删除成功',
  162. type: 'success',
  163. duration: 2000
  164. })
  165. this.getList();
  166. })
  167. }).catch(() => {})
  168. },
  169. resetForm() {
  170. this.dataForm = {
  171. integral: '',
  172. integralType: '',
  173. };
  174. },
  175. handleCreate() {
  176. this.resetForm();
  177. this.dialogFormVisible = true;
  178. this.dialogStatus = "create";
  179. this.$nextTick(() => {
  180. this.$refs["dataForm"].clearValidate();
  181. });
  182. },
  183. createData() {
  184. this.$refs["dataForm"].validate((valid) => {
  185. if (valid) {
  186. console.log(this.dataForm);
  187. pointRulesCreateItem(this.dataForm)
  188. .then((response) => {
  189. this.dialogFormVisible = false;
  190. this.$notify({
  191. title: "成功",
  192. message: "创建成功",
  193. type: "success",
  194. duration: 2000,
  195. });
  196. this.getList();
  197. })
  198. .catch(() => { });
  199. }
  200. });
  201. },
  202. getPointRulesType() {
  203. dataTypeList({dictType:'integral_rule_type'}).then(response => {
  204. this.allTypeList = response.data.data;
  205. }).catch(() => {
  206. });
  207. },
  208. getList() {
  209. this.listLoading = true
  210. getPointRulesList(this.listQuery).then(response => {
  211. this.list = response.data.data.items
  212. this.total = response.data.data.total
  213. this.listLoading = false
  214. }).catch(() => {
  215. })
  216. },
  217. handleFilter() {
  218. this.listQuery.page = 1
  219. this.getList()
  220. },
  221. handleSizeChange(val) {
  222. this.listQuery.limit = val
  223. this.getList()
  224. },
  225. handleCurrentChange(val) {
  226. this.listQuery.page = val
  227. this.getList()
  228. },
  229. handleUpdate(row) {
  230. this.dataForm = Object.assign({}, row);
  231. this.dialogStatus = 'update'
  232. this.dialogFormVisible = true
  233. this.$nextTick(() => {
  234. this.$refs['dataForm'].clearValidate()
  235. })
  236. },
  237. updateData() {
  238. this.$refs['dataForm'].validate((valid) => {
  239. if (valid) {
  240. pointRulesUpdateItem(this.dataForm).then(() => {
  241. this.dialogFormVisible = false
  242. this.$notify({
  243. title: '成功',
  244. message: '更新成功',
  245. type: 'success',
  246. duration: 2000
  247. })
  248. this.getList()
  249. })
  250. }
  251. })
  252. },
  253. }
  254. }
  255. </script>
  256. <style>
  257. .ad-avatar-uploader .el-upload {
  258. border: 1px dashed #d9d9d9;
  259. border-radius: 6px;
  260. cursor: pointer;
  261. position: relative;
  262. overflow: hidden;
  263. }
  264. .ad-avatar-uploader .el-upload:hover {
  265. border-color: #409EFF;
  266. }
  267. .ad-avatar-uploader-icon {
  268. font-size: 28px;
  269. color: #8c939d;
  270. width: 178px;
  271. height: 178px;
  272. line-height: 178px;
  273. text-align: center;
  274. }
  275. .ad-avatar {
  276. display: block;
  277. }
  278. </style>