ShopManage.vue 15 KB

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