Log.vue 12 KB

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