roleList.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="roleList app-container">
  3. <div class="search">
  4. <div>
  5. <el-input
  6. v-model="query.name"
  7. size="small"
  8. clearable
  9. placeholder="请输入名称"
  10. class="item-width-200 "
  11. ></el-input>
  12. <el-input
  13. v-model="query.name"
  14. size="small"
  15. clearable
  16. placeholder="请输入登录账号"
  17. class="item-width-200 ml10"
  18. ></el-input>
  19. <el-select
  20. v-model="query.activityType"
  21. size="small"
  22. class="item-width-200 ml10"
  23. placeholder="请选择角色"
  24. clearable
  25. >
  26. <el-option
  27. v-for="item in options"
  28. :key="item.value"
  29. :label="item.label"
  30. :value="item.value"
  31. >
  32. </el-option>
  33. </el-select>
  34. <el-date-picker
  35. v-model="date"
  36. size="small"
  37. value-format="timestamp"
  38. class="item-width-350 ml10"
  39. type="datetimerange"
  40. range-separator="至"
  41. start-placeholder="开始日期"
  42. end-placeholder="结束日期">
  43. </el-date-picker>
  44. <el-button
  45. class="ml10"
  46. type="primary"
  47. size="small"
  48. icon="el-icon-search"
  49. @click="handleSearch"
  50. >
  51. 搜索
  52. </el-button>
  53. </div>
  54. <el-button
  55. type="primary"
  56. size="small"
  57. @click="handleAdd"
  58. >
  59. 添加
  60. </el-button>
  61. </div>
  62. <el-table
  63. :data="tableData"
  64. tooltip-effect="dark"
  65. border
  66. v-loading="loading"
  67. style="width: 100%"
  68. >
  69. <el-table-column
  70. align="center"
  71. label="角色名称"
  72. prop="activityName"
  73. show-overflow-tooltip
  74. >
  75. </el-table-column>
  76. <el-table-column
  77. align="center"
  78. label="备注"
  79. prop="status"
  80. show-overflow-tooltip
  81. >
  82. </el-table-column>
  83. <el-table-column
  84. align="center"
  85. label="状态"
  86. prop="status"
  87. show-overflow-tooltip
  88. >
  89. </el-table-column>
  90. <el-table-column
  91. align="center"
  92. label="创建时间"
  93. prop="status"
  94. show-overflow-tooltip
  95. >
  96. </el-table-column>
  97. <el-table-column prop="address" align="center" label="操作">
  98. <template slot-scope="scope">
  99. <el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
  100. <el-button type="text" size="small" @click="handleEdit(scope.row)">权限分配</el-button>
  101. <el-button type="text" size="small" @click="handleDel(scope.row.id)">删除</el-button>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. <div class="page-box">
  106. <el-pagination
  107. @size-change="handleSizeChange"
  108. @current-change="handleCurrentChange"
  109. background
  110. :current-page="query.currentPage"
  111. :page-sizes="[10, 20, 30, 40]"
  112. :page-size="query.pageSize"
  113. layout="total, sizes, prev, pager, next, jumper"
  114. :total="total"
  115. >
  116. </el-pagination>
  117. </div>
  118. <el-dialog :title="title" width="550px" :visible.sync="dialogFormVisible">
  119. <el-form label-width="130px" :model="setQuery"
  120. ref="setQuery"
  121. :rules="rules">
  122. <el-form-item label="角色名称:" prop="paperName">
  123. <el-input
  124. v-model="setQuery.paperName"
  125. class="item-width-300"
  126. ></el-input>
  127. </el-form-item>
  128. <el-form-item label="备注:" prop="paperName">
  129. <el-input
  130. v-model="setQuery.paperName"
  131. class="item-width-300"
  132. ></el-input>
  133. </el-form-item>
  134. <el-form-item label="权限分配:" prop="questionsNum">
  135. <el-tree
  136. style="margin-top: 10px;"
  137. :data="data"
  138. show-checkbox
  139. default-expand-all
  140. node-key="id"
  141. ref="tree"
  142. highlight-current
  143. :props="defaultProps">
  144. </el-tree>
  145. </el-form-item>
  146. </el-form>
  147. <div slot="footer" class="dialog-footer">
  148. <el-button @click="dialogFormVisible = false">取 消</el-button>
  149. <el-button type="primary" :loading="btnLoading" @click="save">确 定</el-button>
  150. </div>
  151. </el-dialog>
  152. </div>
  153. </template>
  154. <script>
  155. import {activityList,activityDel,activityStop} from '@/api/activity'
  156. export default {
  157. name: "roleList",
  158. data() {
  159. return {
  160. date:'',
  161. data: [{
  162. id: 1,
  163. label: '一级 1',
  164. children: [{
  165. id: 4,
  166. label: '二级 1-1',
  167. children: [{
  168. id: 9,
  169. label: '三级 1-1-1'
  170. }, {
  171. id: 10,
  172. label: '三级 1-1-2'
  173. }]
  174. }]
  175. }, {
  176. id: 2,
  177. label: '一级 2',
  178. children: [{
  179. id: 5,
  180. label: '二级 2-1'
  181. }, {
  182. id: 6,
  183. label: '二级 2-2'
  184. }]
  185. }, {
  186. id: 3,
  187. label: '一级 3',
  188. children: [{
  189. id: 7,
  190. label: '二级 3-1'
  191. }, {
  192. id: 8,
  193. label: '二级 3-2'
  194. }]
  195. }],
  196. defaultProps: {
  197. children: 'children',
  198. label: 'label'
  199. },
  200. options:[
  201. {
  202. value:1,
  203. label:'海报'
  204. },
  205. {
  206. value:2,
  207. label:'报名'
  208. },
  209. ],
  210. tableData: [],
  211. loading: false,
  212. btnLoading: false,
  213. dialogFormVisible: false,
  214. query: {
  215. "activityType":null,
  216. "state":'',
  217. "currentPage": 1,
  218. "pageSize": 10,
  219. shopId: 0,
  220. },
  221. setQuery: {
  222. type:1
  223. },
  224. rules:{},
  225. title: "",
  226. total: 0,
  227. };
  228. },
  229. watch: {
  230. date(val){
  231. if(val){
  232. this.query.startTime = val[0]
  233. this.query.endTime = val[1]
  234. }else{
  235. this.query.startTime = ''
  236. this.query.endTime = ''
  237. }
  238. }
  239. },
  240. methods: {
  241. handleEdit(row){
  242. this.title = "编辑"
  243. this.dialogFormVisible = true
  244. },
  245. handleAdd(){
  246. this.title = "添加"
  247. this.dialogFormVisible = true
  248. },
  249. handleSearch(){
  250. this.query.currentPage = 1
  251. this.activityList();
  252. },
  253. handleDel(id){
  254. this.$confirm(`此操作将删除该活动, 是否继续?`, "提示", {
  255. confirmButtonText: "确定",
  256. cancelButtonText: "取消",
  257. type: "warning",
  258. }).then(() => {
  259. activityDel({id}).then(res=>{
  260. if(res.state == 'Success'){
  261. this.$notify({
  262. title: "成功",
  263. message: "操作成功",
  264. type: "success",
  265. });
  266. this.handleSearch()
  267. }
  268. })
  269. })
  270. },
  271. handleSizeChange(val) {
  272. this.query.currentPage = 1;
  273. this.query.pageSize = val;
  274. this.activityList()
  275. },
  276. handleCurrentChange(val) {
  277. this.query.currentPage = val;
  278. this.activityList()
  279. },
  280. activityList(){
  281. // this.loading = true
  282. // activityList(this.query).then(res=>{
  283. // this.loading = false
  284. // if(res.state == 'Success'){
  285. // this.tableData = res.content.records
  286. // this.total = res.content.total
  287. // }
  288. // })
  289. },
  290. save(){
  291. console.log(1111);
  292. this.$refs.setQuery.validate((v) => {
  293. if (v) {
  294. // this.btnLoading = true
  295. // addOrUpdatePaper(this.setQuery).then(res=>{
  296. // this.btnLoading = false
  297. // if(res.state == 'Success'){
  298. this.dialogFormVisible = false
  299. // this.$notify({
  300. // title: '成功',
  301. // message: '操作成功',
  302. // type: 'success'
  303. // });
  304. // this.query.currentPage = 1
  305. // this.paperList();
  306. // }
  307. // })
  308. }
  309. });
  310. }
  311. },
  312. created() {
  313. this.activityList()
  314. },
  315. };
  316. </script>
  317. <style lang="scss" >
  318. .roleList {
  319. }
  320. </style>