ShopManage.vue 20 KB

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