Log.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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="7">
  9. <em>时间:</em>
  10. <el-date-picker
  11. v-model="panel.timeScope"
  12. type="daterange"
  13. range-separator="至"
  14. start-placeholder="开始日期"
  15. end-placeholder="结束日期">
  16. </el-date-picker>
  17. </el-col>
  18. <el-col :span="4">
  19. <em>店面:</em>
  20. <el-select v-model="panel.shopId">
  21. <el-option
  22. v-for="item in panel.shopOptions"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value">
  26. </el-option>
  27. </el-select>
  28. </el-col>
  29. <el-col :span="4">
  30. <em>操作者:</em>
  31. <el-select v-model="panel.userId">
  32. <el-option
  33. v-for="item in panel.options"
  34. :key="item.value"
  35. :label="item.label"
  36. :value="item.value">
  37. </el-option>
  38. </el-select>
  39. </el-col>
  40. <el-col :span="4">
  41. <em>手机号:</em>
  42. <el-input v-model="panel.phone" placeholder="请输入手机号" type="number" ></el-input>
  43. </el-col>
  44. <el-col :span="4">
  45. <el-button size="" type="primary" @click="query" plain :disabled="serachBtnStatus">查询</el-button>
  46. </el-col>
  47. </el-row>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="table">
  52. <el-table
  53. :data="tableData"
  54. border
  55. is-horizontal-resize
  56. :default-sort="{prop: 'date', order: 'descending'}"
  57. element-loading-background="rgba(0, 0, 0, 0.8)"
  58. class=""
  59. >
  60. <el-table-column
  61. type="index"
  62. label="序号"
  63. align="center"
  64. width="50">
  65. </el-table-column>
  66. <el-table-column
  67. prop="CreatedAt"
  68. label="日期"
  69. :formatter="filterFmtDate"
  70. width="180"
  71. sortable
  72. >
  73. </el-table-column>
  74. <el-table-column
  75. prop="OptName"
  76. label="操作者"
  77. sortable
  78. width="120"
  79. >
  80. </el-table-column>
  81. <el-table-column
  82. prop="OptShop"
  83. label="所属店铺"
  84. sortable
  85. width="120"
  86. >
  87. </el-table-column>
  88. <el-table-column
  89. prop="OptPhone"
  90. label="手机号"
  91. width="120"
  92. >
  93. </el-table-column>
  94. <el-table-column
  95. prop="Parameter"
  96. label="执行语句"
  97. sortable
  98. >
  99. <template slot-scope="scope">
  100. <el-popover
  101. placement="top"
  102. title="具体语句"
  103. trigger="hover"
  104. :content="scope.row.Parameter">
  105. <span slot="reference"
  106. v-if="scope.row.Parameter.length > 40">{{ scope.row.Parameter.substr(0, 40) }} ....</span>
  107. </el-popover>
  108. <span v-if="scope.row.Parameter.length <= 40">{{ scope.row.Parameter }}</span>
  109. </template>
  110. </el-table-column>
  111. <el-table-column
  112. prop="OptInfo"
  113. label="操作信息"
  114. sortable
  115. >
  116. </el-table-column>
  117. <el-table-column
  118. prop="Result"
  119. label="操作结果"
  120. width="120"
  121. sortable
  122. >
  123. </el-table-column>
  124. </el-table>
  125. <br>
  126. <el-pagination
  127. background
  128. :total="pageination.total"
  129. :page-size="pageination.pageItem"
  130. @current-change="pageChange"
  131. ></el-pagination>
  132. </div>
  133. </div>
  134. </template>
  135. <script>
  136. import Global from '../Global.js'
  137. import {
  138. OptLogListQuery,
  139. testTable,
  140. testSelect, ShopManagerListQuery, ShopListQuery
  141. } from "../api/getApiRes";
  142. let qs = require('qs');
  143. export default {
  144. data() {
  145. return {
  146. dialogVisible: false,
  147. dialogTitle: '新增管理员',
  148. times: globalBt2(7),
  149. // panel 配置项目
  150. panel: {
  151. userCode: '',
  152. tel: '',
  153. userId: '',
  154. shopList: 0,
  155. shopId: '',
  156. options: [],
  157. shopOptions: [],
  158. draw: 1,
  159. start: 0,
  160. recordsTotal: 0,
  161. tableData: [],
  162. allTableData: [],
  163. limit: '10',
  164. multipleSort: false,
  165. loading: false,
  166. fileList: [],
  167. multipleSelection: [],
  168. detectedmac: '',
  169. time1: globalBt(),
  170. timeScope: globalBt2(30),
  171. },
  172. multipleSelection: [],
  173. pageination: {
  174. pageItem: 100,
  175. pageoptions: pageOptions(),
  176. total: 100,
  177. pageIndex: 1,
  178. },
  179. form: {
  180. name: '',
  181. userCode: '',
  182. shopId: '',
  183. },
  184. shops: [],
  185. tableData: [],
  186. serachBtnStatus: false,
  187. }
  188. },
  189. mounted() {
  190. this.panelSelect();
  191. this.shopPanelSelect();
  192. this.getTableQuery();
  193. },
  194. methods: {
  195. shopPanelSelect(){
  196. let that = this;
  197. let param = {
  198. token: localStorage.token,
  199. };
  200. let postdata = qs.stringify(param);
  201. ShopListQuery(postdata).then(res => {
  202. let json = res;
  203. if (json.Code == 0) {
  204. if (json.Rs == '') {
  205. that.$message.error('当前没有可选的店铺,请先在店面管理中添加店铺!');
  206. return false
  207. }
  208. that.panel.shopOptions = turnShopResToOption(json.Rs);
  209. that.panel.shopOptions.unshift({value: '', label: "全部"});
  210. } else {
  211. that.$message.error(json.Memo + '错误码:' + json.Code);
  212. }
  213. })
  214. },
  215. // 加载选项
  216. panelSelect() {
  217. let that = this;
  218. let param = {
  219. token: localStorage.token,
  220. start: 1,
  221. tableMax: 999,
  222. };
  223. let postdata = qs.stringify(param);
  224. ShopManagerListQuery(postdata).then(res => {
  225. let json = res;
  226. if (json.Code == 0) {
  227. that.panel.options = this.turnResToOptionByUsers(json.Rs);
  228. that.panel.options.unshift({value: '', label: "全部"});
  229. console.log(that.panel.options);
  230. } else {
  231. that.$message.error(json.Memo + '错误码:' + json.Code);
  232. }
  233. })
  234. },
  235. turnResToOptionByUsers(data) {
  236. if (!data) return false
  237. let ids = data.map(item => {
  238. return {
  239. label: item.Name + ' ' + item.Phone,
  240. key: parseInt(item.Id),
  241. value: parseInt(item.Id),
  242. }
  243. })
  244. return ids
  245. },
  246. clearForm() {
  247. // clear
  248. this.form.name = '';
  249. this.form.userCode = '';
  250. this.form.shopId = '';
  251. },
  252. handleSelectionChange(val) {
  253. this.multipleSelection = val;
  254. },
  255. // 查询按钮
  256. query() {
  257. // 按钮倒计时
  258. let that = this;
  259. that.serachBtnStatus = true;
  260. let totalTime = 2
  261. let clock = window.setInterval(() => {
  262. totalTime--
  263. if (totalTime < 0) {
  264. totalTime = 2;
  265. that.serachBtnStatus = false;
  266. }
  267. }, 1000)
  268. this.getTableQuery();
  269. this.$message.success('查询完毕');
  270. },
  271. // 页面数据查询
  272. getTableQuery() {
  273. let that = this;
  274. // this.getGetChildRegionSelect(0, 1);
  275. that.loading = true;
  276. // 查询检测设备。上级区域id,区域id必传。regionid传0,查询supregionid对应所有子区域的检测设备。 如果supregionid,regionid都传0,默认查询企业ID下所有检测设备
  277. let param = {
  278. token: localStorage.token,
  279. name: this.panel.name,
  280. phone: this.panel.phone,
  281. userId: this.panel.userId,
  282. bt: nonTfmtDatetoLength(that.panel.timeScope[0], 10) + " 00:00:00",
  283. et: nonTfmtDatetoLength(that.panel.timeScope[1], 10) + " 23:59:59",
  284. start: 1,//
  285. tableMax: 9999,//
  286. optShopId:this.panel.shopId,
  287. };
  288. let postdata = qs.stringify(param);
  289. OptLogListQuery(postdata).then(res => {
  290. let json = res;
  291. if (json.Code == 0) {
  292. that.loading = false;
  293. if (json.Rs) {
  294. that.allTableData = json.Rs;
  295. that.recordsTotal = json.Rs.length;
  296. } else {
  297. that.allTableData = [];
  298. that.recordsTotal = 0;
  299. }
  300. // 设置分页数据
  301. that.setPaginations();
  302. } else {
  303. that.$message.error(json.Memo + '错误码:' + json.Code);
  304. }
  305. })
  306. },
  307. // 设置分页数据
  308. setPaginations() {
  309. // 分页属性
  310. let that = this;
  311. that.pageination.total = that.recordsTotal;
  312. // 默认分页
  313. that.tableData = that.allTableData.filter((item, index) => {
  314. return index < that.pageination.pageItem;
  315. });
  316. },
  317. // 每页显示数量
  318. handleSizeChange() {
  319. let that = this;
  320. that.tableData = that.allTableData.filter((item, index) => {
  321. return index < that.pageination.pageItem;
  322. });
  323. that.draw = that.pageination.pageItem;
  324. that.getTableQuery();
  325. },
  326. // 翻页
  327. pageChange(pageIndex) {
  328. let that = this;
  329. // 获取当前页
  330. let index = that.pageination.pageItem * (pageIndex - 1);
  331. // 数据总数
  332. let nums = that.pageination.pageItem * pageIndex;
  333. // 容器
  334. let tables = [];
  335. for (var i = index; i < nums; i++) {
  336. if (that.allTableData[i]) {
  337. tables.push(that.allTableData[i])
  338. }
  339. this.tableData = tables;
  340. }
  341. that.start = index * that.draw;
  342. // that.getTableQuery();
  343. },
  344. // 自动排序
  345. sortChange(params) {
  346. console.log(params)
  347. },
  348. // 过滤时间
  349. filterFmtDate(value, row, column) {
  350. let that = this;
  351. return nonTfmtDate(column, 11);
  352. },
  353. },
  354. }
  355. </script>
  356. <style scoped>
  357. @import "../assets/css/panel.css";
  358. .context {
  359. height: 770px;
  360. overflow-y: scroll;
  361. display: block;
  362. margin: 0 auto;
  363. background-color: #fff !important;
  364. padding: 30px;
  365. padding-bottom: 60px;
  366. }
  367. .panel-body {
  368. padding: 20px;
  369. background: #F0F2F5;
  370. }
  371. .change {
  372. width: 100%;
  373. overflow: hidden;
  374. display: block;
  375. margin: 0 auto;
  376. padding-top: 10px;
  377. padding-bottom: 10px;
  378. }
  379. .change button {
  380. float: left;
  381. }
  382. .change button.pull-right {
  383. float: right;
  384. }
  385. .dialogTitle {
  386. width: 100%;
  387. overflow: hidden;
  388. display: block;
  389. margin: 0 auto;
  390. color: #000000;
  391. font-size: 18px;
  392. text-align: center;
  393. }
  394. .dialogTitle em {
  395. float: none;
  396. font-style: normal;
  397. color: #3799FF;
  398. margin: 0;
  399. }
  400. /deep/ .el-transfer-panel__item .el-checkbox__input {
  401. left: 40px;
  402. }
  403. .dialogFooter {
  404. width: 90%;
  405. overflow: hidden;
  406. display: block;
  407. margin: 0 auto;
  408. margin-top: 10px;
  409. }
  410. .dialogFooter button {
  411. float: right;
  412. margin-left: 10px;
  413. }
  414. /deep/ .el-date-editor .el-range__icon {
  415. line-height: 22px;
  416. }
  417. .panel /deep/ .el-date-editor .el-range-separator {
  418. line-height: 22px;
  419. }
  420. /*ipad only*/
  421. @media only screen and (max-width: 1366px) {
  422. .panel /deep/ .el-date-editor--daterange {
  423. width: 100%;
  424. }
  425. }
  426. </style>