index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <div class="shopManage app-container">
  3. <div class="search">
  4. <div>
  5. <el-input
  6. v-model="query.shopNameOrPhoneNum"
  7. size="small"
  8. placeholder="请输入门店名称或账号"
  9. class="item-width-200"
  10. ></el-input>
  11. <el-select
  12. v-model="platformType"
  13. multiple
  14. size="small"
  15. clearable
  16. class="item-width-200 ml10"
  17. placeholder="请选择所属平台"
  18. >
  19. <el-option
  20. v-for="item in masterShopOptions"
  21. :key="item.value"
  22. :label="item.label"
  23. :value="item.value"
  24. >
  25. </el-option>
  26. </el-select>
  27. <el-select
  28. v-model="query.shopMenuId"
  29. size="small"
  30. clearable
  31. class="item-width-200 ml10"
  32. placeholder="请选择栏目"
  33. >
  34. <el-option
  35. v-for="item in options"
  36. :key="item.value"
  37. :label="item.label"
  38. :value="item.value"
  39. >
  40. </el-option>
  41. </el-select>
  42. <el-select
  43. v-model="query.state"
  44. size="small"
  45. class="item-width-200 ml10"
  46. placeholder="请选择状态"
  47. >
  48. <el-option
  49. v-for="item in options1"
  50. :key="item.value"
  51. :label="item.label"
  52. :value="item.value"
  53. >
  54. </el-option>
  55. </el-select>
  56. <el-button
  57. class="ml10"
  58. type="primary"
  59. size="small"
  60. icon="el-icon-search"
  61. @click="handleSearch"
  62. >
  63. 搜索
  64. </el-button>
  65. </div>
  66. <el-button
  67. class="add-btn"
  68. type="primary"
  69. size="small"
  70. @click="handleAdd(0)"
  71. >
  72. 添加
  73. </el-button>
  74. <!-- <el-dropdown @command="handleAdd">
  75. <el-button class="add-btn" type="primary" size="small">
  76. 添加<i class="el-icon-arrow-down el-icon--right"></i>
  77. </el-button>
  78. <el-dropdown-menu slot="dropdown">
  79. <el-dropdown-item :command="0">小微商户</el-dropdown-item>
  80. <el-dropdown-item :command="1">个体工商户</el-dropdown-item>
  81. <el-dropdown-item :command="2">企业</el-dropdown-item>
  82. <el-dropdown-item :command="3">机关事业单位</el-dropdown-item>
  83. </el-dropdown-menu>
  84. </el-dropdown> -->
  85. </div>
  86. <el-table
  87. :data="tableData"
  88. tooltip-effect="dark"
  89. border
  90. v-loading="loading"
  91. style="width: 100%"
  92. >
  93. <el-table-column
  94. align="center"
  95. label="店铺名称"
  96. prop="shopName"
  97. show-overflow-tooltip
  98. >
  99. </el-table-column>
  100. <el-table-column
  101. prop="shopMenuId"
  102. align="center"
  103. label="店铺经营类型"
  104. show-overflow-tooltip
  105. >
  106. <template slot-scope="scope">
  107. {{ scope.row.shopMenuId | filterType(that) }}
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. prop="shopMainName"
  112. align="center"
  113. label="所属主体"
  114. show-overflow-tooltip
  115. >
  116. </el-table-column>
  117. <el-table-column
  118. prop="shopMenuId"
  119. align="center"
  120. label="所属平台"
  121. show-overflow-tooltip
  122. >
  123. <template slot-scope="scope">
  124. <div class="flex">
  125. {{ filterMasterName(scope.row.platformType) }}
  126. </div>
  127. </template>
  128. </el-table-column>
  129. <el-table-column
  130. prop="shopId"
  131. align="center"
  132. label="店铺账号"
  133. show-overflow-tooltip
  134. >
  135. </el-table-column>
  136. <el-table-column
  137. prop="applyTime"
  138. align="center"
  139. label="申请时间"
  140. show-overflow-tooltip
  141. >
  142. </el-table-column>
  143. <el-table-column
  144. align="center"
  145. prop="state"
  146. label="店铺状态"
  147. show-overflow-tooltip
  148. >
  149. <template slot-scope="scope">
  150. <span :class="[scope.row.state == 1?'green':'red']">{{ scope.row.state == 1 ? "正常" : "禁用" }}</span>
  151. </template>
  152. </el-table-column>
  153. <!-- <el-table-column
  154. align="center"
  155. prop="authStatus"
  156. label="银联状态"
  157. show-overflow-tooltip
  158. >
  159. <template slot-scope="scope">
  160. <span :class="[filterColor(scope.row.authStatus)]">{{ scope.row.authStatus | filterAuth }}</span>
  161. </template>
  162. </el-table-column> -->
  163. <el-table-column prop="address" width="180px" fixed="right" align="center" label="操作">
  164. <template slot-scope="scope">
  165. <el-button
  166. type="text"
  167. size="small"
  168. @click="handleDetail(scope.row.shopId)"
  169. >店铺资料</el-button
  170. >
  171. <!-- <el-button
  172. type="text"
  173. size="small"
  174. @click="jump(scope.row.shopId,scope.row.shopType)"
  175. >银联</el-button
  176. > -->
  177. <el-button
  178. type="text"
  179. size="small"
  180. @click="checkCode(scope.row.shopId,scope.row.shopName)"
  181. >收款码</el-button
  182. >
  183. <el-button type="text" size="small" @click="handle(scope.row)">{{
  184. scope.row.state == 1 ? "禁用" : "启用"
  185. }}</el-button>
  186. <el-button type="text" size="small" @click="handleDel(scope.row.shopId)"
  187. >删除</el-button
  188. >
  189. </template>
  190. </el-table-column>
  191. </el-table>
  192. <div class="page-box">
  193. <el-pagination
  194. @size-change="handleSizeChange"
  195. @current-change="handleCurrentChange"
  196. background
  197. :current-page="query.currentPage"
  198. :page-sizes="[10, 20, 30, 40]"
  199. :page-size="query.pageSize"
  200. layout="total, sizes, prev, pager, next, jumper"
  201. :total="total"
  202. >
  203. </el-pagination>
  204. </div>
  205. <el-dialog
  206. :visible.sync="showCode"
  207. width="400px"
  208. center>
  209. <div v-loading="codeLoading">
  210. <img style="width:300px;height:300px;margin:0 auto;display:block" :src="codeImg" alt="">
  211. </div>
  212. <span slot="footer" class="dialog-footer">
  213. <a id="downBtn" v-show="false" :download="downName" :href="codeImg" >下载</a>
  214. <el-button @click="download">下载</el-button>
  215. </span>
  216. </el-dialog>
  217. </div>
  218. </template>
  219. <script>
  220. import { debounce } from "@/utils/index";
  221. import { getList, updateState } from "@/api/shop";
  222. import {getMenuName} from '@/api/appConfig';
  223. import axios from 'axios'
  224. const BASE_URL = require('@/utils/config')
  225. export default {
  226. name: "shopManage",
  227. data() {
  228. return {
  229. that:this,
  230. codeImg:'',//收款码
  231. downName:'',//下载名称
  232. showCode:false,
  233. codeLoading:false,
  234. tableData: [],
  235. options: [],
  236. options1: [
  237. {
  238. value: null,
  239. label: "全部状态",
  240. },
  241. {
  242. value: "1",
  243. label: "启用",
  244. },
  245. {
  246. value: "4",
  247. label: "禁用",
  248. },
  249. ],
  250. loading: false,
  251. platformType:'',
  252. query: {
  253. platformType:null,
  254. state: null,
  255. province: "",
  256. city: "",
  257. district: "",
  258. checkStartTime: "",
  259. checkEndTime: "",
  260. shopMainId: "",
  261. shopMenuId:"",
  262. shopNameOrPhoneNum: "",
  263. currentPage: 1,
  264. pageSize: 10,
  265. },
  266. total: 0,
  267. };
  268. },
  269. watch: {
  270. platformType(val) {
  271. if(val.length){
  272. this.query.platformType = val.join(',')
  273. }else{
  274. this.query.platformType = null
  275. }
  276. }
  277. },
  278. filters: {
  279. filterType: function(value,that) {
  280. let msg = ''
  281. let arr = value.split(',')
  282. that.options.map(item=>{
  283. arr.map(i=>{
  284. if(item.value == i){
  285. msg+=item.label + '/'
  286. }
  287. })
  288. })
  289. return msg.substring(0,msg.length-1);
  290. },
  291. filterAuth: function(val) {
  292. if(val == 0){
  293. return '未认证'
  294. }else if(val == 1){
  295. return '审核中'
  296. }else if(val == 2){
  297. return '审核通过'
  298. }else if(val == 3){
  299. return '被驳回'
  300. }
  301. },
  302. filterShopType(val){
  303. if(val == 1){
  304. return '小微商户'
  305. }else if(val == 2){
  306. return '个体工商户'
  307. }else if(val == 3){
  308. return '企业'
  309. }else if(val == 4){
  310. return '机关事业单位或社会团体'
  311. }
  312. },
  313. },
  314. methods: {
  315. handleSearch(){
  316. this.query.currentPage = 1
  317. this.getList();
  318. },
  319. filterColor(val) {
  320. if(val == 0){
  321. return 'gray'
  322. }else if(val == 1){
  323. return 'gray'
  324. }else if(val == 2){
  325. return 'green'
  326. }else if(val == 3){
  327. return 'red'
  328. }
  329. },
  330. handleAdd(val) {
  331. this.$router.push({
  332. path: "/operationManage/shopManage/shopAdd" + (val || ""),
  333. });
  334. },
  335. handle(row) {
  336. let msg;
  337. if (row.state == 1) {
  338. msg = "禁用";
  339. } else {
  340. msg = "启用";
  341. }
  342. this.$confirm(`此操作将${msg}该商铺, 是否继续?`, "提示", {
  343. confirmButtonText: "确定",
  344. cancelButtonText: "取消",
  345. type: "warning",
  346. }).then(() => {
  347. updateState({
  348. shopId: row.shopId,
  349. state: row.state == 1 ? 4 : 1,
  350. }).then((res) => {
  351. if (res.state == "Success") {
  352. this.$notify({
  353. title: "成功",
  354. message: "操作成功",
  355. type: "success",
  356. });
  357. this.getList();
  358. }
  359. });
  360. });
  361. },
  362. handleEdit(id) {
  363. this.$router.push({
  364. path: "/operationManage/shopManage/shopAdd",
  365. query: {
  366. title: "店铺编辑",
  367. id,
  368. },
  369. });
  370. },
  371. handleDetail(id,title) {
  372. this.$router.push({
  373. path: "/operationManage/shopManage/shopAdd",
  374. query: {
  375. title: "店铺详情",
  376. id,
  377. },
  378. });
  379. },
  380. // 转化base64
  381. getBase64(data) {
  382. return new Promise((resolve, reject) => {
  383. const blob = new Blob([data], { type: 'image/jpeg' }) // 必须指定type类型
  384. const reader = new FileReader()
  385. reader.readAsDataURL(blob)
  386. reader.onload = () => resolve(reader.result)
  387. reader.onerror = (error) => reject(error)
  388. })
  389. },
  390. checkCode(shopId,shopName){
  391. this.showCode = true
  392. this.codeLoading = true
  393. this.downName = shopName + "收款码"
  394. axios(
  395. {
  396. url: BASE_URL.BASE_URL+'zswl-cloud-bdb/promotion/qrcode',
  397. method: 'post',
  398. responseType: "arraybuffer",
  399. data:{
  400. "page": "pay/offlinePayment",
  401. "scene": shopId
  402. }
  403. }).then(res=>{
  404. this.codeLoading = false
  405. let blob = new Blob([res.data], { type: "image/png" });
  406. this.codeImg = (window.URL || window.webkitURL).createObjectURL(blob);
  407. })
  408. },
  409. // 下载
  410. download(){
  411. document.getElementById('downBtn').click()
  412. },
  413. handleDel(shopId){
  414. this.$confirm(`此操作将删除该商铺, 是否继续?`, "提示", {
  415. confirmButtonText: "确定",
  416. cancelButtonText: "取消",
  417. type: "warning",
  418. }).then(() => {
  419. updateState({
  420. shopId,
  421. state: 3,
  422. }).then((res) => {
  423. if (res.state == "Success") {
  424. this.$notify({
  425. title: "成功",
  426. message: "操作成功",
  427. type: "success",
  428. });
  429. this.getList();
  430. }
  431. });
  432. });
  433. },
  434. jump(id,type){
  435. this.$router.push({
  436. path: "/operationManage/shopManage/shopAdd"+type,
  437. query: {
  438. id,
  439. mode:'detail'
  440. },
  441. });
  442. },
  443. handleSizeChange(val) {
  444. this.query.currentPage = 1;
  445. this.query.pageSize = val;
  446. this.getList();
  447. },
  448. handleCurrentChange(val) {
  449. this.query.currentPage = val;
  450. this.getList();
  451. },
  452. getList() {
  453. this.loading = true;
  454. getList(this.query).then((res) => {
  455. this.loading = false;
  456. if (res.state == "Success") {
  457. this.tableData = res.content.records;
  458. this.total = res.content.total;
  459. }
  460. });
  461. },
  462. getMenuName(){
  463. getMenuName().then(res=>{
  464. if(res.state == 'Success'){
  465. for (const key in res.content) {
  466. if (res.content.hasOwnProperty.call(res.content, key)) {
  467. this.options.push({
  468. label:res.content[key],
  469. value:Number(key)
  470. })
  471. }
  472. }
  473. }
  474. })
  475. },
  476. },
  477. created() {
  478. this.getList();
  479. this.getMenuName();
  480. },
  481. };
  482. </script>
  483. <style lang="scss" scoped>
  484. .shopManage {
  485. .search {
  486. justify-content: space-between;
  487. .flex{
  488. display: flex;
  489. }
  490. .add-btn {
  491. // margin-right: 20px;
  492. }
  493. }
  494. }
  495. </style>