accountManagement.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div>
  3. <search-layout :needBox="true">
  4. <template slot="searchItem1">
  5. <span class="label">账户名称</span>
  6. <el-input
  7. v-model="searchParams.username"
  8. size="small"
  9. clearable
  10. placeholder="请输入"
  11. >
  12. </el-input>
  13. </template>
  14. <template slot="searchItem3">
  15. <span class="label">账户类型</span>
  16. <el-select v-model="searchParams.roleCode">
  17. <el-option
  18. v-for="item in roleCodeList"
  19. :label="item.caption"
  20. :value="item.code"
  21. :key="item.code"
  22. ></el-option>
  23. </el-select>
  24. </template>
  25. <template slot="searchItem2">
  26. <span class="label">所属公司</span>
  27. <el-input
  28. v-model="searchParams.company"
  29. size="small"
  30. clearable
  31. placeholder="请输入"
  32. >
  33. </el-input>
  34. </template>
  35. <template slot="searchItem4">
  36. <span class="label">状态</span>
  37. <el-select v-model="searchParams.visible">
  38. <el-option
  39. v-for="item in list"
  40. :label="item.caption"
  41. :value="item.code"
  42. :key="item.code"
  43. ></el-option>
  44. </el-select>
  45. </template>
  46. <template slot="searchBtn1">
  47. <el-button type="primary" @click="search">查询</el-button>
  48. </template>
  49. <template slot="searchBtn2">
  50. <el-button type="primary" @click="reset">重置</el-button>
  51. </template>
  52. </search-layout>
  53. <div class="btnsPanel">
  54. <!--<el-button type="primary" plain icon="el-icon-video-pause"
  55. >批量停用</el-button
  56. >
  57. <el-button type="primary" plain icon="el-icon-video-play"
  58. >批量启用</el-button
  59. >-->
  60. <el-button
  61. type="primary"
  62. icon="el-icon-circle-plus-outline"
  63. @click="addAccount"
  64. >创建账户</el-button
  65. >
  66. </div>
  67. <tableList
  68. ref="table"
  69. style="border-top: none; margin: 0 30px"
  70. :columns="columns"
  71. :getDataWay="getDataWay"
  72. :pagination="pagination"
  73. index
  74. >
  75. <el-table-column label="停/启用" slot="visible" align="center">
  76. <template v-slot="scope">
  77. <el-switch
  78. v-model="scope.row.visible"
  79. active-value="1"
  80. inactive-value="0"
  81. active-color="#3397ff"
  82. inactive-color="#ff4949"
  83. @change="$event=>{switchVisible($event, scope.row)}"
  84. ></el-switch>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="操作" slot="cgInfos" align="center">
  88. <template v-slot="scope">
  89. <i
  90. @click="editAccount(scope.row)"
  91. class="el-icon-edit-outline elIcon"
  92. title="编辑"
  93. ></i>
  94. </template>
  95. </el-table-column>
  96. </tableList>
  97. </div>
  98. </template>
  99. <script>
  100. import searchLayout from "@/components/grid/searchLayout";
  101. import tableList from "@/components/grid/TableList";
  102. export default {
  103. name: "accountManagement", // 账户管理
  104. components: { searchLayout, tableList },
  105. data() {
  106. return {
  107. searchParams: {
  108. //搜索参数
  109. username: "", //账户名
  110. company:"", //所属公司
  111. roleCode:"", //账户类型
  112. visible:"" //启用状态
  113. },
  114. roleCodeList:[],
  115. list: [
  116. {
  117. code:'1',
  118. caption:'启用'
  119. },
  120. {
  121. code:'0',
  122. caption:'停用'
  123. }
  124. ],
  125. columns: [
  126. //表格列
  127. {
  128. label: "账户名称",
  129. prop: "username",
  130. },
  131. {
  132. label: "账户类型",
  133. prop: "roleCode",
  134. },
  135. {
  136. label: "所属公司",
  137. prop: "company",
  138. },
  139. {
  140. label: "联系人",
  141. prop: "nickname",
  142. },
  143. {
  144. label: "联系方式",
  145. prop: "phone",
  146. },
  147. {
  148. label: "停/启用",
  149. prop: "visible",
  150. template: true
  151. },
  152. {
  153. label: "创建人",
  154. prop: "createUserName",
  155. },
  156. {
  157. label: "创建时间",
  158. prop: "createTime",
  159. formatter: (data) => {
  160. return this.$timeFormatter(data.createTime)
  161. }
  162. },
  163. {
  164. label: "操作",
  165. prop: "cgInfos",
  166. template: true,
  167. },
  168. ],
  169. pagination: {
  170. //分页使用
  171. currentPage: 1,
  172. pageSize: 10,
  173. position: "right",
  174. pageSizes: [10, 30, 50, 100, 200],
  175. layout: "sizes, total, prev, pager, next, jumper",
  176. },
  177. getDataWay: {
  178. //加载表格数据
  179. dataType: "url",
  180. type: "post",
  181. // firstRequest: false,
  182. data: this.$api.systemManagement.getUserPageList,
  183. param: {},
  184. },
  185. };
  186. },
  187. async mounted() {
  188. await this.$dicsListsInit({
  189. roleCodeList: "roleCode",
  190. });
  191. },
  192. methods: {
  193. addAccount() {
  194. this.$router.push({ path: "/addAccount" });
  195. },
  196. editAccount(row) {
  197. let query = {...row}
  198. console.log(row)
  199. this.$router.push({
  200. path: "/editAccount",
  201. query
  202. })
  203. },
  204. search(){
  205. let searchParam = {
  206. username: this.searchParams.username,
  207. company: this.searchParams.company,
  208. roleCode: this.searchParams.roleCode,
  209. visible: this.searchParams.visible
  210. }
  211. this.refreshList(searchParam)
  212. },
  213. reset(){
  214. this.searchParams={
  215. username: '',
  216. company: '',
  217. roleCode: '',
  218. visible: ''
  219. }
  220. this.search()
  221. },
  222. refreshList(param) {
  223. param
  224. ? this.$refs["table"].loadData(param)
  225. : this.$refs["table"].loadData();
  226. },
  227. switchVisible(value, row){ //停用启用账户
  228. if(value == '0'){
  229. row.visible = '1'
  230. this.$confirm("确认停用该账户?", "提示", {
  231. confirmButtonText: "确定",
  232. cancelButtonText: "取消",
  233. type: "warning",
  234. }).then(()=>{
  235. this.$axios({
  236. method:'POST',
  237. url: this.$api.systemManagement.saveVisible,
  238. data:{
  239. id: row.id,
  240. visible: '0'
  241. }
  242. }).then(res=>{
  243. if(res.code == '200'){
  244. row.visible = '0'
  245. }else{
  246. this.$message.error(res.message || "停用失败");
  247. }
  248. })
  249. }).catch(()=>{})
  250. }else{
  251. row.visible = '0'
  252. this.$confirm("确认启用该账户?", "提示", {
  253. confirmButtonText: "确定",
  254. cancelButtonText: "取消",
  255. type: "warning",
  256. }).then(()=>{this.$axios({
  257. method:'POST',
  258. url: this.$api.systemManagement.saveVisible,
  259. data:{
  260. id: row.id,
  261. visible: '1'
  262. }
  263. }).then(res=>{
  264. if(res.code == '200'){
  265. row.visible = '1'
  266. }else{
  267. this.$message.error(res.message || "启用失败");
  268. }
  269. })
  270. }).catch(()=>{})
  271. }
  272. }
  273. },
  274. };
  275. </script>
  276. <style scoped lang="less">
  277. .btnsPanel {
  278. margin: 45px 40px 15px;
  279. text-align: right;
  280. }
  281. </style>