Log.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <div class="context">
  3. <div class="panel">
  4. <h5>操作日志</h5>
  5. <div class="panel-body">
  6. <div class="panel_control">
  7. <el-row :gutter="20">
  8. <el-col :span="5">
  9. <el-date-picker
  10. v-model="times"
  11. type="daterange"
  12. range-separator="至"
  13. start-placeholder="开始日期"
  14. end-placeholder="结束日期">
  15. </el-date-picker>
  16. </el-col>
  17. <el-col :span="4">
  18. <em>管理员:</em>
  19. <el-select v-model="panel.shopList">
  20. <el-option
  21. v-for="item in panel.options"
  22. :key="item.value"
  23. :label="item.label"
  24. :value="item.value">
  25. </el-option>
  26. </el-select>
  27. </el-col>
  28. <el-col :span="4">
  29. <el-button size="" type="primary" @click="query" plain>查询</el-button>
  30. </el-col>
  31. </el-row>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="table">
  36. <el-table
  37. :data="tableData"
  38. border
  39. is-horizontal-resize
  40. :default-sort="{prop: 'date', order: 'descending'}"
  41. element-loading-background="rgba(0, 0, 0, 0.8)"
  42. class=""
  43. @selection-change="handleSelectionChange"
  44. >
  45. <el-table-column
  46. type="index"
  47. label="序号"
  48. width="50">
  49. </el-table-column>
  50. <el-table-column
  51. prop="userCode"
  52. label="日期"
  53. sortable
  54. >
  55. </el-table-column>
  56. <el-table-column
  57. prop="name"
  58. label="姓名"
  59. sortable
  60. >
  61. </el-table-column>
  62. <el-table-column
  63. prop="tel"
  64. label="手机号"
  65. >
  66. </el-table-column>
  67. <el-table-column
  68. prop="shop"
  69. label="所属门店"
  70. sortable
  71. >
  72. </el-table-column>
  73. <el-table-column
  74. prop="name"
  75. label="操作内容"
  76. sortable
  77. >
  78. </el-table-column>
  79. </el-table>
  80. <br>
  81. <el-pagination
  82. background
  83. :total="pageination.total"
  84. :page-size="pageination.pageItem"
  85. @current-change="pageChange"
  86. ></el-pagination>
  87. </div>
  88. <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="360px">
  89. <div>
  90. <el-form ref="form" :model="form" label-width="80px">
  91. <el-form-item label="手机号">
  92. <el-input v-model="form.userCode"></el-input>
  93. </el-form-item>
  94. <el-form-item label="姓名">
  95. <el-input v-model="form.name"></el-input>
  96. </el-form-item>
  97. <el-form-item label="所属门店">
  98. <el-select v-model="form.shopId" placeholder="请选择所属门店">
  99. <el-option
  100. v-for="item in shops"
  101. :key="item.value"
  102. :label="item.label"
  103. :value="item.value"
  104. ></el-option>
  105. </el-select>
  106. </el-form-item>
  107. </el-form>
  108. </div>
  109. <div class="dialogFooter">
  110. <el-button type="primary" size="small" @click="confirmAdmin">确定</el-button>
  111. <el-button @click="dialogVisible = false" size="small">取消</el-button>
  112. </div>
  113. </el-dialog>
  114. </div>
  115. </template>
  116. <script>
  117. import Global from '../Global.js'
  118. import {
  119. testTable,
  120. testSelect
  121. } from "../api/getApiRes";
  122. let qs = require('qs');
  123. export default {
  124. data() {
  125. return {
  126. dialogVisible: false,
  127. dialogTitle: '新增管理员',
  128. times: globalBt2(7),
  129. // panel 配置项目
  130. panel: {
  131. userCode: '',
  132. tel: '',
  133. shopList: 0,
  134. options: [],
  135. draw: 1,
  136. start: 0,
  137. recordsTotal: 0,
  138. tableData: [],
  139. allTableData: [],
  140. limit: '10',
  141. multipleSort: false,
  142. loading: false,
  143. fileList: [],
  144. multipleSelection: [],
  145. detectedmac: '',
  146. time1: globalBt(),
  147. },
  148. multipleSelection: [],
  149. pageination: {
  150. pageItem: 100,
  151. pageoptions: pageOptions(),
  152. total: 100,
  153. pageIndex: 1,
  154. },
  155. form: {
  156. name: '',
  157. userCode: '',
  158. shopId: '',
  159. },
  160. shops: [],
  161. tableData: []
  162. }
  163. },
  164. mounted() {
  165. this.panelSelect();
  166. this.getTableQuery();
  167. },
  168. methods: {
  169. // 新增 确认提交
  170. confirmAdmin() {
  171. let that = this;
  172. // checkNum
  173. if (!that.form.userCode) {
  174. this.$message.error('错了哦,手机号不能为空');
  175. return false
  176. }
  177. if (!globalCheckPhone(that.form.userCode)) {
  178. this.$message.error('错了哦,手机号格式不正确');
  179. return false
  180. }
  181. if (!that.form.name) {
  182. this.$message.error('错了哦,姓名不能为空');
  183. return false
  184. }
  185. if (that.form.name.length > 8) {
  186. this.$message.error('错了哦,姓名字数超过8个字');
  187. return false
  188. }
  189. let param = {
  190. token: localStorage.token,
  191. userCode: that.form.userCode,
  192. name: that.form.name,
  193. shopid: that.form.shopid,
  194. };
  195. let postdata = qs.stringify(param);
  196. testSelect(postdata).then(res => {
  197. let json = res;
  198. if (json.Code == 0) {
  199. // 关闭弹窗
  200. that.dialogVisible = false;
  201. // 重载列表
  202. that.getTableQuery();
  203. that.$message({
  204. showClose: true,
  205. message: '管理员添加成功!',
  206. type: 'success'
  207. });
  208. } else {
  209. that.$message.error(json.Memo);
  210. }
  211. })
  212. },
  213. // 加载选项
  214. panelSelect() {
  215. let that = this;
  216. let param = {
  217. token: localStorage.token,
  218. };
  219. let postdata = qs.stringify(param);
  220. testSelect(postdata).then(res => {
  221. let json = res;
  222. if (json.Code == 0) {
  223. that.shops = json.Rs;
  224. that.form.shopId = json.Rs[0].value;
  225. console.log(that.form.shopId);
  226. that.panel.options = json.Rs;
  227. that.panel.options.unshift({value: 0, label: "全部"});
  228. } else {
  229. that.$message.error(json.Memo);
  230. }
  231. })
  232. },
  233. // 删除
  234. delList() {
  235. let that = this;
  236. // checkNum
  237. if (!this.multipleSelection.length) {
  238. that.$message({
  239. showClose: true,
  240. message: '错了哦,需要先选中至少一条记录',
  241. type: 'error'
  242. });
  243. return false
  244. }
  245. if (this.multipleSelection.length != 1) {
  246. that.$message({
  247. showClose: true,
  248. message: '错了哦,只能选中一条记录',
  249. type: 'error'
  250. });
  251. return false
  252. }
  253. let detectorid = that.multipleSelection[0].Id;
  254. let param = {
  255. token: localStorage.token,
  256. detectorid: detectorid,
  257. status: 9,//0禁用1启用9删除
  258. };
  259. let postdata = qs.stringify(param);
  260. this.$confirm('此操作将永久删除该管理员, 是否继续?', '提示', {
  261. confirmButtonText: '确定',
  262. cancelButtonText: '取消',
  263. type: 'warning'
  264. }).then(() => {
  265. testSelect(postdata).then(res => {
  266. let json = res;
  267. if (json.Code == 0) {
  268. that.$message({
  269. showClose: true,
  270. message: '选中的管理员已删除!',
  271. type: 'success'
  272. });
  273. // 重载列表
  274. that.getTableQuery();
  275. } else {
  276. that.$message.error(json.Memo);
  277. }
  278. });
  279. }).catch(() => {
  280. this.$message({
  281. type: 'info',
  282. message: '已取消删除'
  283. });
  284. });
  285. },
  286. clearForm() {
  287. // clear
  288. this.form.name = '';
  289. this.form.userCode = '';
  290. this.form.shopId = '';
  291. },
  292. // 新增管理员
  293. addAdmin() {
  294. this.clearForm();
  295. this.dialogVisible = true
  296. this.dialogTitle = '新增管理员'
  297. },
  298. // 编辑管理员
  299. editList(row){
  300. this.clearForm();
  301. this.form.name =row.name;
  302. this.form.userCode = row.userCode;
  303. this.form.shopId = row.Id;
  304. this.dialogVisible = true
  305. this.dialogTitle = '编辑管理员'
  306. },
  307. handleSelectionChange(val) {
  308. this.multipleSelection = val;
  309. },
  310. // 查询按钮
  311. query() {
  312. this.getTableQuery();
  313. this.$message.success('查询完毕');
  314. },
  315. // 页面数据查询
  316. getTableQuery() {
  317. let that = this;
  318. // this.getGetChildRegionSelect(0, 1);
  319. that.loading = true;
  320. // 查询检测设备。上级区域id,区域id必传。regionid传0,查询supregionid对应所有子区域的检测设备。 如果supregionid,regionid都传0,默认查询企业ID下所有检测设备
  321. let param = {
  322. token: localStorage.token,
  323. supregionid: 0,//
  324. regionid: this.panel.regionid,//
  325. comid: 1,//
  326. tagname: that.panel.tagname,//标签名
  327. start: 1,//
  328. tableMax: 9999,//
  329. };
  330. let postdata = qs.stringify(param);
  331. testTable(postdata).then(res => {
  332. let json = res;
  333. if (json.Code == 0) {
  334. that.loading = false;
  335. if (json.Rs) {
  336. that.allTableData = json.Rs;
  337. that.recordsTotal = json.Rs.length;
  338. } else {
  339. that.allTableData = [];
  340. that.recordsTotal = 0;
  341. }
  342. // 设置分页数据
  343. that.setPaginations();
  344. } else {
  345. that.$message.error(json.Memo);
  346. }
  347. })
  348. },
  349. // 设置分页数据
  350. setPaginations() {
  351. // 分页属性
  352. let that = this;
  353. that.pageination.total = that.recordsTotal;
  354. // 默认分页
  355. that.tableData = that.allTableData.filter((item, index) => {
  356. return index < that.pageination.pageItem;
  357. });
  358. },
  359. // 每页显示数量
  360. handleSizeChange() {
  361. let that = this;
  362. that.tableData = that.allTableData.filter((item, index) => {
  363. return index < that.pageination.pageItem;
  364. });
  365. that.draw = that.pageination.pageItem;
  366. that.getTableQuery();
  367. },
  368. // 翻页
  369. pageChange(pageIndex) {
  370. let that = this;
  371. // 获取当前页
  372. let index = that.pageination.pageItem * (pageIndex - 1);
  373. // 数据总数
  374. let nums = that.pageination.pageItem * pageIndex;
  375. // 容器
  376. let tables = [];
  377. for (var i = index; i < nums; i++) {
  378. if (that.allTableData[i]) {
  379. tables.push(that.allTableData[i])
  380. }
  381. this.tableData = tables;
  382. }
  383. that.start = index * that.draw;
  384. that.getTableQuery();
  385. },
  386. // 自动排序
  387. sortChange(params) {
  388. console.log(params)
  389. },
  390. // 过滤时间
  391. filterFmtDate(value, row, column) {
  392. let that = this;
  393. return nonTfmtDate(column, 11);
  394. },
  395. // 过滤金额
  396. filterMoney(value, row, column) {
  397. let that = this;
  398. return parseFloat(column).toFixed(2);
  399. },
  400. },
  401. }
  402. </script>
  403. <style scoped>
  404. @import "../assets/css/panel.css";
  405. .context {
  406. overflow: hidden;
  407. display: block;
  408. margin: 0 auto;
  409. background-color: #fff !important;
  410. padding: 30px;
  411. padding-bottom: 60px;
  412. }
  413. .panel-body {
  414. padding: 20px;
  415. background: #F0F2F5;
  416. }
  417. .change {
  418. width: 100%;
  419. overflow: hidden;
  420. display: block;
  421. margin: 0 auto;
  422. padding-top: 10px;
  423. padding-bottom: 10px;
  424. }
  425. .change button {
  426. float: left;
  427. }
  428. .change button.pull-right {
  429. float: right;
  430. }
  431. .dialogTitle {
  432. width: 100%;
  433. overflow: hidden;
  434. display: block;
  435. margin: 0 auto;
  436. color: #000000;
  437. font-size: 18px;
  438. text-align: center;
  439. }
  440. .dialogTitle em {
  441. float: none;
  442. font-style: normal;
  443. color: #3799FF;
  444. margin: 0;
  445. }
  446. /deep/ .el-transfer-panel__item .el-checkbox__input {
  447. left: 40px;
  448. }
  449. .dialogFooter {
  450. width: 90%;
  451. overflow: hidden;
  452. display: block;
  453. margin: 0 auto;
  454. margin-top: 10px;
  455. }
  456. .dialogFooter button {
  457. float: right;
  458. margin-left: 10px;
  459. }
  460. /deep/ .el-date-editor .el-range__icon {
  461. line-height: 22px;
  462. }
  463. .panel /deep/ .el-date-editor .el-range-separator {
  464. line-height: 22px;
  465. }
  466. </style>