ShopManage.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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="请输入手机号"></el-input>
  19. </el-col>
  20. <el-col :span="4">
  21. <el-button size="" type="primary" @click="query" plain>查询</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">删除店面</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. }
  171. },
  172. mounted() {
  173. this.getTableQuery();
  174. },
  175. methods: {
  176. clickChange (item) {
  177. this.tableRadio = item
  178. },
  179. // 新增 确认提交
  180. confirmAdmin() {
  181. let that = this;
  182. // checkNum
  183. if (!that.form.shopName) {
  184. this.$message.error('错了哦,店面名称不能为空');
  185. return false
  186. }
  187. if (that.form.shopName.length > 18) {
  188. this.$message.error('错了哦,姓名字数超过18个字');
  189. return false
  190. }
  191. if (!that.form.addr) {
  192. this.$message.error('错了哦,位置不能为空');
  193. return false
  194. }
  195. if (that.form.addr.length > 38) {
  196. this.$message.error('错了哦,位置字数超过38个字');
  197. return false
  198. }
  199. if (!that.form.contacts) {
  200. this.$message.error('错了哦,负责人不能为空');
  201. return false
  202. }
  203. if (that.form.contacts.length > 8) {
  204. this.$message.error('错了哦,负责人字数超过8个字');
  205. return false
  206. }
  207. if (!that.form.phone) {
  208. this.$message.error('错了哦,手机号不能为空');
  209. return false
  210. }
  211. if (!globalCheckPhone(that.form.phone)) {
  212. this.$message.error('错了哦,手机号格式不正确');
  213. return false
  214. }
  215. let param = {
  216. token: localStorage.token,
  217. shopName: that.form.shopName,
  218. addr: that.form.addr,
  219. contacts: that.form.contacts,
  220. phone: that.form.phone,
  221. shopid: that.form.shopid,
  222. };
  223. let postdata = qs.stringify(param);
  224. ShopAdd(postdata).then(res => {
  225. let json = res;
  226. if (json.Code == 0) {
  227. // 关闭弹窗
  228. that.dialogVisible = false;
  229. // 重载列表
  230. that.getTableQuery();
  231. that.$message({
  232. showClose: true,
  233. message: '店面添加成功!',
  234. type: 'success'
  235. });
  236. } else {
  237. that.$message.error(json.Memo);
  238. }
  239. })
  240. },
  241. // 修改
  242. confirmEdite() {
  243. let that = this;
  244. // checkNum
  245. if (!that.form.shopName) {
  246. this.$message.error('错了哦,店面名称不能为空');
  247. return false
  248. }
  249. if (that.form.shopName.length > 18) {
  250. this.$message.error('错了哦,姓名字数超过18个字');
  251. return false
  252. }
  253. if (!that.form.addr) {
  254. this.$message.error('错了哦,位置不能为空');
  255. return false
  256. }
  257. if (that.form.addr.length > 38) {
  258. this.$message.error('错了哦,位置字数超过38个字');
  259. return false
  260. }
  261. if (!that.form.contacts) {
  262. this.$message.error('错了哦,负责人不能为空');
  263. return false
  264. }
  265. if (that.form.contacts.length > 8) {
  266. this.$message.error('错了哦,负责人字数超过8个字');
  267. return false
  268. }
  269. if (!that.form.phone) {
  270. this.$message.error('错了哦,手机号不能为空');
  271. return false
  272. }
  273. if (!globalCheckPhone(that.form.phone)) {
  274. this.$message.error('错了哦,手机号格式不正确');
  275. return false
  276. }
  277. let param = {
  278. token: localStorage.token,
  279. shopName: that.form.shopName,
  280. addr: that.form.addr,
  281. contacts: that.form.contacts,
  282. phone: that.form.phone,
  283. shopId: that.form.shopId,
  284. };
  285. let postdata = qs.stringify(param);
  286. ShopEdit(postdata).then(res => {
  287. let json = res;
  288. if (json.Code == 0) {
  289. // 关闭弹窗
  290. that.dialogVisible = false;
  291. // 重载列表
  292. that.getTableQuery();
  293. that.$message({
  294. showClose: true,
  295. message: '店面编辑成功!',
  296. type: 'success'
  297. });
  298. } else {
  299. that.$message.error(json.Memo);
  300. }
  301. })
  302. },
  303. // 删除
  304. delList() {
  305. let that = this;
  306. if(this.tableRadio.length == 0){
  307. this.$message.error("请先选中一条记录");
  308. return false
  309. }
  310. let ShopID = this.tableRadio.ShopID;
  311. let param = {
  312. token: localStorage.token,
  313. shopId: ShopID,
  314. status: 9,//0禁用1启用9删除
  315. };
  316. let postdata = qs.stringify(param);
  317. this.$confirm('此操作将永久删除该店面, 是否继续?', '提示', {
  318. confirmButtonText: '确定',
  319. cancelButtonText: '取消',
  320. type: 'warning'
  321. }).then(() => {
  322. ShopStatusEdit(postdata).then(res => {
  323. let json = res;
  324. if (json.Code == 0) {
  325. that.$message({
  326. showClose: true,
  327. message: '选中的店面已删除!',
  328. type: 'success'
  329. });
  330. // 重载列表
  331. that.getTableQuery();
  332. } else {
  333. that.$message.error(json.Memo);
  334. }
  335. });
  336. }).catch(() => {
  337. this.$message({
  338. type: 'info',
  339. message: '已取消删除'
  340. });
  341. });
  342. },
  343. clearForm() {
  344. // clear
  345. this.form.shopName = '';
  346. this.form.addr = '';
  347. this.form.name = '';
  348. this.form.userCode = '';
  349. this.form.shopId = '';
  350. this.form.phone = '';
  351. this.form.contacts = '';
  352. },
  353. // 新增店面
  354. addAdmin() {
  355. this.clearForm();
  356. this.dialogVisible = true
  357. this.dialogTitle = '新增店面'
  358. this.form.btnState = 0; //新增
  359. },
  360. // 编辑店面
  361. editList() {
  362. let that = this;
  363. // checkNum
  364. this.clearForm();
  365. this.form.btnState = 1; //编辑
  366. if(this.tableRadio.length == 0){
  367. this.$message.error("请先选中一条记录");
  368. return false
  369. }
  370. let row = this.tableRadio;
  371. this.form.shopId = row.ShopID;
  372. this.form.shopName = row.ShopName;
  373. this.form.addr = row.Addr;
  374. this.form.contacts = row.Contacts;
  375. this.form.phone = row.Phone;
  376. this.dialogVisible = true;
  377. this.dialogTitle = '编辑店面'
  378. },
  379. handleSelectionChange(val) {
  380. this.multipleSelection = val;
  381. },
  382. // 查询按钮
  383. query() {
  384. this.getTableQuery();
  385. this.$message.success('查询完毕');
  386. },
  387. // 页面数据查询
  388. getTableQuery() {
  389. let that = this;
  390. that.loading = true;
  391. // 查询检测设备。上级区域id,区域id必传。regionid传0,查询supregionid对应所有子区域的检测设备。 如果supregionid,regionid都传0,默认查询企业ID下所有检测设备
  392. let param = {
  393. token: localStorage.token,
  394. shopName: this.panel.shopName,//
  395. contacts: this.panel.contacts,//
  396. phone: this.panel.phone,//
  397. };
  398. let postdata = qs.stringify(param);
  399. ShopListQuery(postdata).then(res => {
  400. let json = res;
  401. if (json.Code == 0) {
  402. that.loading = false;
  403. if (json.Rs) {
  404. that.allTableData = json.Rs;
  405. that.recordsTotal = json.Rs.length;
  406. } else {
  407. that.allTableData = [];
  408. that.recordsTotal = 0;
  409. }
  410. // 设置分页数据
  411. that.setPaginations();
  412. } else {
  413. that.$message.error(json.Memo);
  414. }
  415. })
  416. },
  417. // 设置分页数据
  418. setPaginations() {
  419. // 分页属性
  420. let that = this;
  421. that.pageination.total = that.recordsTotal;
  422. // 默认分页
  423. that.tableData = that.allTableData.filter((item, index) => {
  424. return index < that.pageination.pageItem;
  425. });
  426. },
  427. // 每页显示数量
  428. handleSizeChange() {
  429. let that = this;
  430. that.tableData = that.allTableData.filter((item, index) => {
  431. return index < that.pageination.pageItem;
  432. });
  433. that.draw = that.pageination.pageItem;
  434. that.getTableQuery();
  435. },
  436. // 翻页
  437. pageChange(pageIndex) {
  438. let that = this;
  439. // 获取当前页
  440. let index = that.pageination.pageItem * (pageIndex - 1);
  441. // 数据总数
  442. let nums = that.pageination.pageItem * pageIndex;
  443. // 容器
  444. let tables = [];
  445. for (var i = index; i < nums; i++) {
  446. if (that.allTableData[i]) {
  447. tables.push(that.allTableData[i])
  448. }
  449. this.tableData = tables;
  450. }
  451. that.start = index * that.draw;
  452. that.getTableQuery();
  453. },
  454. // 自动排序
  455. sortChange(params) {
  456. console.log(params)
  457. },
  458. // 过滤时间
  459. filterFmtDate(value, row, column) {
  460. let that = this;
  461. return nonTfmtDate(column, 11);
  462. },
  463. // 过滤金额
  464. filterMoney(value, row, column) {
  465. let that = this;
  466. return parseFloat(column).toFixed(2);
  467. },
  468. },
  469. }
  470. </script>
  471. <style scoped>
  472. @import "../assets/css/panel.css";
  473. .context {
  474. height: 770px;
  475. overflow-y: scroll;
  476. display: block;
  477. margin: 0 auto;
  478. background-color: #fff !important;
  479. padding: 30px;
  480. padding-bottom: 60px;
  481. }
  482. .panel-body {
  483. padding: 20px;
  484. background: #F0F2F5;
  485. }
  486. .change {
  487. width: 100%;
  488. overflow: hidden;
  489. display: block;
  490. margin: 0 auto;
  491. padding-top: 10px;
  492. padding-bottom: 10px;
  493. }
  494. .change button {
  495. float: left;
  496. }
  497. .change button.pull-right {
  498. float: right;
  499. }
  500. .dialogTitle {
  501. width: 100%;
  502. overflow: hidden;
  503. display: block;
  504. margin: 0 auto;
  505. color: #000000;
  506. font-size: 18px;
  507. text-align: center;
  508. }
  509. .dialogTitle em {
  510. float: none;
  511. font-style: normal;
  512. color: #3799FF;
  513. margin: 0;
  514. }
  515. /deep/ .el-transfer-panel__item .el-checkbox__input {
  516. left: 40px;
  517. }
  518. .dialogFooter {
  519. width: 90%;
  520. overflow: hidden;
  521. display: block;
  522. margin: 0 auto;
  523. margin-top: 10px;
  524. }
  525. .dialogFooter button {
  526. float: right;
  527. margin-left: 10px;
  528. }
  529. </style>