zhuanghaoguanli.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :span="24" class="first-row">
  5. <div class="tag">账号管理</div>
  6. </el-col>
  7. </el-row>
  8. <el-row>
  9. <el-col :span="24" class="second-row">
  10. <el-form :inline="true" class="demo-form-inline">
  11. <el-form-item label="账号:" class="shuibiaoId">
  12. <el-input v-model="account" placeholder="请输入账号" clearable maxlength="16"></el-input>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" @click="onSearch">查找</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <div class="btn-add">
  19. <el-button type="primary" icon="el-icon-add" @click="handleAdd">添加</el-button>
  20. </div>
  21. </el-col>
  22. </el-row>
  23. <hr style="background-color: #CCCCCC;height: 1px;border: 0;">
  24. <el-row>
  25. <el-col :span="24" class="third-row">
  26. <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
  27. highlight-current-row>
  28. <el-table-column label="昵称" align="center">
  29. <template slot-scope="scope">{{ scope.row.name }}</template>
  30. </el-table-column>
  31. <el-table-column prop="number" label="账号" align="center"></el-table-column>
  32. <el-table-column prop="password" label="密码" show-overflow-tooltip></el-table-column>
  33. <el-table-column label="操作" align="center" width="80">
  34. <el-button type="text" class="del-btn" slot-scope="scope"
  35. @click="handleDelete(scope.$index, scope.row)">删除
  36. </el-button>
  37. </el-table-column>
  38. <el-table-column width="130">
  39. <el-button type="text" slot-scope="scope" @click="handleEdit(scope.$index, scope.row)">编辑
  40. </el-button>
  41. </el-table-column>
  42. </el-table>
  43. <div style="margin-top: 20px" class="table-footer">
  44. <div class="pages">
  45. <el-pagination layout="prev, pager, next" :total="total_rows" :current-page.sync="current_page"
  46. :hide-on-single-page="true" :page-size="page_rows" @current-change="handleCurrentChange">
  47. </el-pagination>
  48. </div>
  49. </div>
  50. </el-col>
  51. </el-row>
  52. <el-row>
  53. <el-col :span="24" class="forth-row">
  54. <!-- 添加对话框 -->
  55. <el-dialog title="添加账号" :visible.sync="adddialogFormVisible" width="500px" top="0vh" class="my-dialog"
  56. :close-on-click-modal="false" :close-on-press-escape="false">
  57. <hr
  58. style="width: 100%; position: absolute; top: 60px; left: 0px;background-color: #CCCCCC;height: 1px;border: 0;">
  59. <el-form :model="addform">
  60. <el-form-item label="昵称:" :label-width="formLabelWidth">
  61. <el-input v-model="addform.name" autocomplete="off" maxlength="16"></el-input>
  62. </el-form-item>
  63. <el-form-item label="账号:" :label-width="formLabelWidth">
  64. <el-input v-model="addform.number" autocomplete="off" maxlength="16"></el-input>
  65. </el-form-item>
  66. <el-form-item label="密码:" :label-width="formLabelWidth">
  67. <el-input v-model="addform.password" type="password" autocomplete="off" maxlength="16">
  68. </el-input>
  69. </el-form-item>
  70. <el-form-item label="确认密码:" :label-width="formLabelWidth">
  71. <el-input v-model="addform.comfirmPass" type="password" autocomplete="off" maxlength="16">
  72. </el-input>
  73. </el-form-item>
  74. </el-form>
  75. <div slot="footer" class="dialog-footer">
  76. <el-button @click="adddialogFormVisible = false">取 消</el-button>
  77. <el-button type="primary" @click="handleAddRow">确 定</el-button>
  78. </div>
  79. </el-dialog>
  80. <!-- 编辑对话框 -->
  81. <el-dialog title="编辑" :visible.sync="editdialogFormVisible" width="500px" top="0vh" class="my-dialog"
  82. :close-on-click-modal="false" :close-on-press-escape="false">
  83. <hr
  84. style="width: 100%; position: absolute; top: 60px; left: 0px;background-color: #CCCCCC;height: 1px;border: 0;">
  85. <el-form>
  86. <el-form-item label="昵称:" :label-width="formLabelWidth">
  87. <el-input v-model="form.name" autocomplete="off" maxlength="16"></el-input>
  88. </el-form-item>
  89. <el-form-item label="账号:" :label-width="formLabelWidth">
  90. <el-input v-model="form.number" autocomplete="off" maxlength="16"></el-input>
  91. </el-form-item>
  92. <el-form-item label="密码:" :label-width="formLabelWidth">
  93. <el-input v-model="form.password" autocomplete="off" type="password" maxlength="16">
  94. </el-input>
  95. </el-form-item>
  96. <el-form-item label="确认密码:" :label-width="formLabelWidth">
  97. <el-input v-model="form.comfirmPass" autocomplete="off" type="password" maxlength="16">
  98. </el-input>
  99. </el-form-item>
  100. </el-form>
  101. <div slot="footer" class="dialog-footer">
  102. <el-button @click="editdialogFormVisible = false">取 消</el-button>
  103. <el-button type="primary" @click="handleEditRow">确 定</el-button>
  104. </div>
  105. </el-dialog>
  106. <!-- 删除对话框 -->
  107. <el-dialog :visible.sync="delDialogVisible" width="500px" center top="0vh" class="my-dialog"
  108. :close-on-click-modal="false" :close-on-press-escape="false">
  109. <div class="box-icon"></div>
  110. <span class="del-msg">确定删除【{{del_account}}】账号吗?</span>
  111. <span slot="footer" class="dialog-footer">
  112. <el-button @click="delDialogVisible = false">取 消</el-button>
  113. <el-button type="primary" @click="handleDelRow">确 定</el-button>
  114. </span>
  115. </el-dialog>
  116. </el-col>
  117. </el-row>
  118. </div>
  119. </template>
  120. <script>
  121. export default {
  122. data() {
  123. return {
  124. account: '', // 需要查找的账号
  125. del_account: '',
  126. del_id: 0,
  127. adddialogFormVisible: false,
  128. editdialogFormVisible: false, // 控制编辑对话框显示、隐藏
  129. delDialogVisible: false, // 控制删除对话框显示、隐藏
  130. form: { // 编辑框的数据绑定
  131. id: 0,
  132. name: '',
  133. number: '',
  134. password: '',
  135. comfirmPass: ''
  136. },
  137. addform: { // 添加框的数据绑定
  138. name: '',
  139. number: '',
  140. password: '',
  141. comfirmPass: ''
  142. },
  143. formLabelWidth: '120px',
  144. // 表格数据
  145. tableData: [],
  146. current_page: 1, // 当前所在页码
  147. page_rows: 8, // 每页显示的记录数
  148. total_rows: 0 // 总记录数
  149. }
  150. },
  151. created() {
  152. // 获取账号列表
  153. this.updateTable()
  154. },
  155. methods: {
  156. /**
  157. * 改变页码
  158. * @param {Object} val
  159. */
  160. handleCurrentChange(val) {
  161. this.current_page = val
  162. // 查询账号相关信息
  163. this.updateTable()
  164. },
  165. /**
  166. * 获取账号数据,填充表格变量
  167. */
  168. updateTable() {
  169. var _this = this
  170. _this.tableData = []
  171. let params = {
  172. page: this.current_page,
  173. rows: this.page_rows
  174. }
  175. if (this.account) {
  176. params.number = this.account
  177. }
  178. // _this.rows_total = 0
  179. this.$axios.get('/api/HotWaters/waterqueryAdmin.action', {
  180. params: params
  181. })
  182. .then(res => {
  183. // console.log(res.data);
  184. if (typeof(res.data.rows) != 'undefined' && res.data.rows != '' && JSON.stringify(res.data) !=
  185. '{}') {
  186. // _this.$message.success('数据加载成功!');
  187. _this.tableData = res.data.rows
  188. _this.total_rows = res.data.total
  189. } else {
  190. _this.$message.success('【获取账号数据】暂无数据!');
  191. }
  192. })
  193. .catch(err => {
  194. // console.log(err);
  195. _this.$message.error('【获取账号数据】请求异常: ' + err);
  196. })
  197. },
  198. /**
  199. * 查找账号
  200. */
  201. onSearch() {
  202. // if (!this.account) {
  203. // this.$message.error('请输入账号')
  204. // return
  205. // }
  206. // 查询账号相关信息
  207. this.updateTable()
  208. },
  209. /**
  210. * 添加账号
  211. */
  212. handleAdd() {
  213. this.adddialogFormVisible = true
  214. },
  215. /**
  216. * 添加一条账号
  217. */
  218. handleAddRow() {
  219. // console.log(this.addform);
  220. if (!String(this.addform.name).trim()) {
  221. this.$message.error('请输入昵称')
  222. return
  223. }
  224. if (!String(this.addform.number).trim()) {
  225. this.$message.error('请输入账号')
  226. return
  227. }
  228. if (!String(this.addform.password).trim()) {
  229. this.$message.error('请输入密码')
  230. return
  231. }
  232. if (String(this.addform.password).trim() != String(this.addform.comfirmPass).trim()) {
  233. this.$message.error('密码与确认密码不一致!')
  234. return
  235. }
  236. var _this = this
  237. this.$axios.get('/api/HotWaters/wateraddAdmin.action', {
  238. params: {
  239. name: String(this.addform.name).trim(),
  240. number: String(this.addform.number).trim(),
  241. password: String(this.addform.password).trim()
  242. }
  243. })
  244. .then(res => {
  245. // console.log(res.data);
  246. if (typeof(res.data.msg) != 'undefined' && res.data.msg != '' && res.data.msg == '添加成功' && JSON
  247. .stringify(res.data) != '{}') {
  248. _this.$message.success('【账号添加】成功!');
  249. _this.addform.name = ''
  250. _this.addform.number = ''
  251. _this.addform.password = ''
  252. _this.addform.comfirmPass = ''
  253. // 更新列表
  254. this.updateTable()
  255. } else {
  256. _this.$message.error('【账号添加】失败!' + res.data.msg);
  257. }
  258. this.adddialogFormVisible = false
  259. })
  260. .catch(err => {
  261. // console.log(err);
  262. _this.$message.error('【账号添加】请求异常: ' + err);
  263. })
  264. },
  265. /**
  266. * 编辑对话框
  267. * @param {Object} index
  268. * @param {Object} row
  269. */
  270. handleEdit(index, row) {
  271. this.editdialogFormVisible = true
  272. this.form.id = row.id
  273. this.form.name = row.name
  274. this.form.number = row.number
  275. this.form.password = row.password
  276. },
  277. /**
  278. * 更新指定的id所在的行
  279. */
  280. handleEditRow() {
  281. if (!String(this.form.name).trim()) {
  282. this.$message.error('请输入昵称')
  283. return
  284. }
  285. if (!String(this.form.number).trim()) {
  286. this.$message.error('请输入账号')
  287. return
  288. }
  289. if (!String(this.form.password).trim()) {
  290. this.$message.error('请输入密码')
  291. return
  292. }
  293. if (String(this.form.password).trim() != String(this.form.comfirmPass).trim()) {
  294. this.$message.error('密码和确认密码不一致!')
  295. return
  296. }
  297. var _this = this
  298. this.$axios.get('/api/HotWaters/waterupdateAdmin.action', {
  299. params: {
  300. id: this.form.id,
  301. name: String(this.form.name).trim(),
  302. number: String(this.form.number).trim(),
  303. password: String(this.form.password).trim()
  304. }
  305. })
  306. .then(res => {
  307. // console.log(res.data);
  308. if (typeof(res.data.msg) != 'undefined' && res.data.msg != '' && res.data.msg == '更新成功' && JSON
  309. .stringify(res.data) != '{}') {
  310. _this.$message.success('【账号更新】成功!');
  311. // 更新表格
  312. this.updateTable()
  313. _this.form.id = ''
  314. _this.form.name = ''
  315. _this.form.number = ''
  316. _this.form.password = ''
  317. _this.form.comfirmPass = ''
  318. } else {
  319. _this.$message.error('【账号更新】失败!' + res.data.msg);
  320. }
  321. this.editdialogFormVisible = false
  322. })
  323. .catch(err => {
  324. // console.log(err);
  325. _this.$message.error('【账号更新】请求异常: ' + err);
  326. })
  327. },
  328. /**
  329. * 删除对话框
  330. * @param {Object} index
  331. * @param {Object} row
  332. */
  333. handleDelete(index, row) {
  334. this.delDialogVisible = true
  335. this.del_account = row.number
  336. this.del_id = row.id
  337. },
  338. /**
  339. * 删除指定的id所在的行
  340. */
  341. handleDelRow() {
  342. var _this = this
  343. this.$axios.get('/api/HotWaters/waterdelAdmin.action', {
  344. params: {
  345. id: this.del_id
  346. }
  347. })
  348. .then(res => {
  349. // console.log(res.data);
  350. if (typeof(res.data.msg) != 'undefined' && res.data.msg != '' && res.data.msg == '删除成功' && JSON
  351. .stringify(res.data) != '{}') {
  352. _this.$message.success('【账号删除】成功!');
  353. this.updateTable()
  354. } else {
  355. _this.$message.error('【账号删除】失败!');
  356. }
  357. this.delDialogVisible = false
  358. })
  359. .catch(err => {
  360. // console.log(err);
  361. _this.$message.error('【账号删除】请求异常: ' + err);
  362. })
  363. }
  364. }
  365. }
  366. </script>
  367. <style scoped>
  368. @import url("zhuanghaoguanli.css");
  369. </style>