shopAdd.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <!--
  2. * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
  3. * @Date: 2023-05-26 16:37:34
  4. * @LastEditors: wenjie 1454560336@qq.com
  5. * @LastEditTime: 2024-04-15 16:07:14
  6. * @FilePath: \admin-manage\src\views\operationManage\shopManage\shopAdd.vue
  7. * @Description:
  8. *
  9. * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
  10. -->
  11. <template>
  12. <div class="shopAdd app-container" v-loading="loading">
  13. <el-form
  14. :model="setQuery"
  15. ref="setQuery"
  16. :rules="rules"
  17. v-loading="pageLoading"
  18. :disabled="disabled"
  19. label-width="130px"
  20. >
  21. <el-tabs v-model="activeName">
  22. <el-tab-pane label="基本信息" name="1">
  23. <el-form-item label="商铺主体:" prop="shopMainId">
  24. <el-select v-model="setQuery.shopMainId" size="small" filterable class="item-width-300" placeholder="请搜索选择店铺主体">
  25. <el-option
  26. v-for="item in shopMainOptions"
  27. :key="item.value"
  28. :label="item.label"
  29. :value="item.value">
  30. </el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="店铺经营类型:" prop="shopMenuId">
  34. <!-- <el-select v-model="setQuery.shopMenuId" size="small" class="item-width-300" placeholder="请选择店铺经营类型">
  35. <el-option
  36. v-for="item in options"
  37. :key="item.value"
  38. :label="item.label"
  39. :value="item.value">
  40. </el-option>
  41. </el-select> -->
  42. <el-cascader
  43. size="small"
  44. class="item-width-300"
  45. placeholder="请选择店铺经营类型"
  46. v-model="setQuery.shopMenuId"
  47. :options="options"
  48. :props="{
  49. value:'id',
  50. label:'menuName',
  51. children:'child',
  52. }"
  53. ></el-cascader>
  54. </el-form-item>
  55. <el-form-item label="店铺名称:" prop="shopName">
  56. <el-input
  57. v-model.number="setQuery.shopName"
  58. size="small"
  59. :maxlength="18"
  60. class="item-width-300"
  61. ></el-input>
  62. </el-form-item>
  63. <!-- <el-form-item label="店铺类型:" prop="shopType">
  64. <el-select v-model="setQuery.shopType" size="small" class="item-width-300" placeholder="请选择店铺经营类型">
  65. <el-option
  66. v-for="item in options1"
  67. :key="item.value"
  68. :label="item.label"
  69. :value="item.value">
  70. </el-option>
  71. </el-select>
  72. </el-form-item> -->
  73. <el-form-item label="店铺地址:" prop="address">
  74. <el-input
  75. disabled
  76. v-model="setQuery.address"
  77. class="item-width-500"
  78. size="small"
  79. placeholder="请点击右侧定位图标选择店铺地址"
  80. ></el-input>
  81. <i class="el-icon-location ml10 position red" @click="chooseAddress"></i>
  82. </el-form-item>
  83. <el-form-item label="店铺简介:">
  84. <el-input
  85. type="textarea"
  86. placeholder="请输入店铺简介"
  87. v-model="setQuery.detailContent"
  88. maxlength="400"
  89. class="item-width-500"
  90. show-word-limit
  91. >
  92. </el-input>
  93. </el-form-item>
  94. <el-form-item label="店铺头像:" prop="logoPath">
  95. <Upload
  96. type="logoPath"
  97. id="logoPath"
  98. width="250px"
  99. height="150px"
  100. :disabled="mode == 'detail'"
  101. uploadType="SHOP_INFO"
  102. :imgUrl="setQuery.logoPath"
  103. @uploadEnd="uploadEnd"
  104. ></Upload>
  105. </el-form-item>
  106. <el-form-item label="店铺图片:" prop="detailImg">
  107. <Upload
  108. type="detailImg"
  109. id="detailImg"
  110. width="250px"
  111. height="150px"
  112. :disabled="mode == 'detail'"
  113. uploadType="SHOP_INFO"
  114. :imgUrl="setQuery.detailImg"
  115. @uploadEnd="uploadEnd"
  116. ></Upload>
  117. </el-form-item>
  118. <!-- <el-form-item label="店铺状态:">
  119. <el-radio-group v-model="setQuery.doorImg">
  120. <el-radio :label="1">关闭</el-radio>
  121. <el-radio :label="2">运营中</el-radio>
  122. </el-radio-group>
  123. </el-form-item> -->
  124. </el-tab-pane>
  125. <el-tab-pane label="其他信息" name="2">
  126. <el-form-item label="经营商品类型:" prop="serviceCode">
  127. <el-checkbox-group v-model="setQuery.serviceCode">
  128. <el-checkbox label="801">研学商品</el-checkbox>
  129. <el-checkbox label="802">虚拟商品充值</el-checkbox>
  130. <el-checkbox label="803">餐饮商品</el-checkbox>
  131. <el-checkbox label="809">贵大商品</el-checkbox>
  132. </el-checkbox-group>
  133. </el-form-item>
  134. <el-form-item label="经营商品分类:" prop="serviceCate">
  135. <el-cascader
  136. v-model="setQuery.serviceCate"
  137. :options="typeOptions"
  138. :props="{
  139. multiple: true ,
  140. value:'id',
  141. label:'cateName',
  142. children:'child'
  143. }"
  144. @change=""></el-cascader>
  145. </el-form-item>
  146. <el-form-item label="银联分账帐户:">
  147. <el-select v-model="setQuery.authAccount" size="small" filterable class="item-width-300" placeholder="请搜索选择店铺主体">
  148. <el-option
  149. v-for="item in authOptions"
  150. :key="item.value"
  151. :label="item.label"
  152. :value="item.value">
  153. </el-option>
  154. </el-select>
  155. </el-form-item>
  156. <el-form-item label="分账规则:" prop="shareId">
  157. <el-select
  158. v-model="setQuery.shareId"
  159. class="item-width-300"
  160. placeholder="请选择分账规则"
  161. >
  162. <el-option
  163. v-for="item in ruleOptions"
  164. :key="item.value"
  165. :label="item.label"
  166. :value="item.value"
  167. >
  168. </el-option>
  169. </el-select>
  170. </el-form-item>
  171. <el-form-item label="店铺搜索:">
  172. <el-radio-group v-model="setQuery.searchEnable">
  173. <el-radio :label="1">可搜索</el-radio>
  174. <el-radio :label="2">不可搜索</el-radio>
  175. </el-radio-group>
  176. </el-form-item>
  177. <el-form-item label="店铺状态:" >
  178. <el-radio-group :disabled="!setQuery.authAccount" v-model="setQuery.state">
  179. <el-radio :label="1">运营中</el-radio>
  180. <el-radio :label="2">关闭</el-radio>
  181. </el-radio-group>
  182. </el-form-item>
  183. </el-tab-pane>
  184. </el-tabs>
  185. </el-form>
  186. <el-dialog title="选择地址" close="chose-model" :close-on-press-escape="false" :show-close="false" :close-on-click-modal="false" width="60vw" :visible.sync="showMap">
  187. <div id="container"></div>
  188. <div class="address-input-box">
  189. <el-input
  190. v-model="setQuery.address"
  191. size="small"
  192. class="address-input"
  193. placeholder="请先点击地图定位,再修改详细地址"
  194. ></el-input>
  195. <el-button type="primary" size="small" class="address-btn" @click="saveAddress">提 交</el-button>
  196. </div>
  197. </el-dialog>
  198. <!-- 新增和编辑模式 -->
  199. <div class="btn-group" v-if="mode == 'add'|| mode == 'edit'">
  200. <el-button>取 消</el-button>
  201. <el-button type="primary" :loading="loading" @click="save"
  202. >提交</el-button >
  203. </div>
  204. <!-- 详情时的按钮 -->
  205. <div class="btn-group" v-else>
  206. <el-button>取 消</el-button>
  207. <el-button type="primary" :loading="loading" @click="edit"
  208. >编辑</el-button >
  209. </div>
  210. </div>
  211. </template>
  212. <script>
  213. import Upload from "@/components/Upload";
  214. import { add, detail, update,getMainName } from "@/api/shop";
  215. import {getMenuData} from '@/api/appConfig';
  216. import {getRuleList} from '@/api/rule'
  217. import {getData} from '@/api/goods'
  218. import {finishComplexList} from '@/api/payment'
  219. import { debounce } from "@/utils/index";
  220. export default {
  221. components: {
  222. Upload,
  223. },
  224. data() {
  225. return {
  226. checkList:[],
  227. activeName:"1",
  228. map:null,
  229. mode:'detail',//编辑模式
  230. showMap:false,
  231. setQuery: {
  232. address: "",
  233. businessImg: "",
  234. city: "",
  235. detailImg: "",
  236. district: "",
  237. doorImg: "",
  238. idCardNo: "",
  239. logoPath: "",
  240. mapLat: "",
  241. mapLon: "",
  242. province: "",
  243. serviceName: "",
  244. serviceTel: "",
  245. shopLabel: "",
  246. shopMainId: "",
  247. shopName: "",
  248. shopType: '',
  249. source:'2',
  250. shareId:'',
  251. shareChannelId:'',
  252. serviceCode:[],//经营类型
  253. serviceCate:[],//商品分类
  254. authAccount:"",
  255. searchEnable:1,
  256. state:2,
  257. },
  258. authOptions:[],//银联账号
  259. typeOptions:[],//商品分类
  260. ruleOptions:[],
  261. options:[],
  262. options1:[
  263. {
  264. value: 1,
  265. label: "小微商户",
  266. },
  267. {
  268. value: 2,
  269. label: "个体工商户",
  270. },
  271. {
  272. value: 3,
  273. label: "企业",
  274. },
  275. {
  276. value: 4,
  277. label: "机关事业单位或社会团体",
  278. },
  279. ],
  280. shopMainOptions:[],//主体选择
  281. disabled: false,
  282. pageLoading: false, //页面loading
  283. loading: false,
  284. rules: {
  285. shopMainId: [
  286. { required: true, message: "请选择商铺主体", trigger: "change" },
  287. ],
  288. shopMenuId: [
  289. { required: true, message: "请选择商铺经营类型", trigger: "change" },
  290. ],
  291. shopType: [
  292. { required: true, message: "请选择商铺类型", trigger: "change" },
  293. ],
  294. shopName: [
  295. { required: true, message: "请输入商铺名称", trigger: "blur" },
  296. ],
  297. address: [
  298. { required: true, message: "请输入商铺地址", trigger: "blur" },
  299. ],
  300. shareChannelId: [
  301. { required: true, message: "请选择商家佣金", trigger: "change" },
  302. ],
  303. logoPath: [
  304. { required: true, message: "请上传店铺头像", trigger: "change" },
  305. ],
  306. shareId: [
  307. { required: true, message: "请选择分账规则", trigger: "change" },
  308. ],
  309. detailImg: [
  310. { required: true, message: "请上传店铺详情图", trigger: "change" },
  311. ],
  312. businessImg: [
  313. { required: true, message: "请上传营业执照", trigger: "change" },
  314. ],
  315. serviceCate: [
  316. { required: true, message: "请选择经营商品分类", trigger: "change" },
  317. ],
  318. serviceCode: [
  319. { required: true, message: "请选择经营商品类型", trigger: "change" },
  320. ],
  321. },
  322. };
  323. },
  324. watch: {
  325. 'setQuery.address':debounce(function(val){
  326. if(this.map){
  327. let that = this
  328. //创建地址解析器实例
  329. var myGeo = new BMapGL.Geocoder();
  330. that.marker? that.map.removeOverlay(that.marker):''
  331. // 将地址解析结果显示在地图上,并调整地图视野
  332. myGeo.getPoint(val, function(point){
  333. if(point ){
  334. console.log(point);
  335. that.setQuery.mapLat = point.lat
  336. that.setQuery.mapLon = point.lng
  337. that.marker = new BMapGL.Marker(point, {title: val})
  338. if(that.map){
  339. that.map.centerAndZoom(point, 16);
  340. that.map.addOverlay(that.marker)
  341. myGeo.getLocation(new BMapGL.Point(point.lng, point.lat), function(result){
  342. if (result){
  343. console.log(result);
  344. // 选择营业地址时保存省市区
  345. that.setQuery.province = result.addressComponents.province;
  346. that.setQuery.city = result.addressComponents.city;
  347. that.setQuery.district = result.addressComponents.district;
  348. }
  349. });
  350. }
  351. }
  352. }, that.setQuery.city)
  353. }
  354. }),
  355. "setQuery.shopMainId":function(val){
  356. if(val){
  357. this.finishComplexList()
  358. }else{
  359. this.authOptions = []
  360. }
  361. },
  362. 'setQuery.authAccount'(val){
  363. if(!val){
  364. this.setQuery.state = 2
  365. }
  366. }
  367. },
  368. methods: {
  369. edit(){
  370. this.$router.push({
  371. path: "/operationManage/shopManage/shopAdd",
  372. query: {
  373. title: "店铺编辑",
  374. id:this.$route.query.id,
  375. },
  376. });
  377. },
  378. save() {
  379. this.$refs.setQuery.validate((v) => {
  380. if (v) {
  381. if(this.loading) return
  382. if (this.setQuery.shopId) {
  383. this.update();
  384. } else {
  385. this.add();
  386. }
  387. }else{
  388. this.$message.error('请检查是否有必填项未填');
  389. }
  390. });
  391. },
  392. add() {
  393. this.loading = true;
  394. let obj = JSON.parse(JSON.stringify(this.setQuery))
  395. obj.serviceCode = obj.serviceCode.toString()
  396. obj.serviceCate = obj.serviceCate.toString()
  397. obj.shopMenuId = obj.shopMenuId.toString()
  398. add(obj).then((res) => {
  399. this.loading = false;
  400. if (res.state == "Success") {
  401. this.$notify({
  402. title: "成功",
  403. message: "操作成功",
  404. type: "success",
  405. });
  406. this.$router.push("/operationManage/shopManage/index");
  407. }
  408. });
  409. },
  410. update() {
  411. this.loading = true;
  412. let obj = JSON.parse(JSON.stringify(this.setQuery))
  413. obj.serviceCode = obj.serviceCode.toString()
  414. obj.serviceCate = obj.serviceCate.toString()
  415. obj.shopMenuId = obj.shopMenuId.toString()
  416. update(obj).then((res) => {
  417. this.loading = false;
  418. if (res.state == "Success") {
  419. this.$notify({
  420. title: "成功",
  421. message: "操作成功",
  422. type: "success",
  423. });
  424. this.$router.push("/operationManage/shopManage/index");
  425. }
  426. });
  427. },
  428. // 图片统一上传
  429. uploadEnd(val) {
  430. this.setQuery[val.type] = val.url;
  431. },
  432. detail() {
  433. this.pageLoading = true;
  434. detail({ shopId: this.$route.query.id }).then((res) => {
  435. this.pageLoading = false;
  436. if (res.state == "Success") {
  437. this.setQuery = res.content;
  438. this.setQuery.serviceCode = this.setQuery.serviceCode.split(',')
  439. this.setQuery.serviceCate = this.setQuery.serviceCate.split(',').map(item=> Number(item))
  440. this.setQuery.shopMenuId = this.setQuery.shopMenuId.split(',').map(item=> Number(item))
  441. }
  442. });
  443. },
  444. // 获取经营类型
  445. getMenuName(){
  446. getMenuData().then(res=>{
  447. if(res.state == 'Success'){
  448. this.options = res.content
  449. }
  450. })
  451. },
  452. // 获取主体类型
  453. getMainName(){
  454. getMainName().then(res=>{
  455. if(res.state == 'Success'){
  456. for (const key in res.content) {
  457. if (Object.hasOwnProperty.call(res.content, key)) {
  458. this.shopMainOptions.push({
  459. label:res.content[key],
  460. value:key
  461. })
  462. }
  463. }
  464. }
  465. })
  466. },
  467. // 选择经营地址
  468. chooseAddress() {
  469. if(this.mode == 'detail') return
  470. this.showMap = true;
  471. let that = this
  472. this.$nextTick(() => {
  473. this.map = new BMapGL.Map("container");
  474. var geoc = new BMapGL.Geocoder();
  475. that.map.enableScrollWheelZoom(); // 启用滚轮放大缩小
  476. var myCity = new BMapGL.LocalCity();
  477. myCity.get((result)=> {
  478. console.log(result);
  479. var cityName = result.name;
  480. that.map.setCenter(cityName);
  481. var point = new BMapGL.Point(result.center.lat, result.center.lng);
  482. that.map.centerAndZoom(point, 15);
  483. let cache = this.setQuery.address
  484. this.setQuery.address = '切换地址触发标记点'
  485. setTimeout(() => {
  486. this.setQuery.address = cache
  487. }, 100);
  488. });
  489. that.map.addEventListener("click", function (e) {
  490. console.log(1111111,e.latlng);
  491. var pt = e.latlng;
  492. that.map.removeOverlay(that.marker); //移除点标记
  493. geoc.getLocation(pt, function (rs) {
  494. var addComp = rs.addressComponents;
  495. let point1 = new BMapGL.Point(rs.point.lng, rs.point.lat);
  496. that.marker = new BMapGL.Marker(point1); // 创建标注
  497. that.map.addOverlay(that.marker); // 将标注添加到地图中
  498. that.setQuery.address = rs.address +rs.content.poi_desc
  499. // 选择营业地址时保存省市区
  500. that.setQuery.province = addComp.province
  501. that.setQuery.city = addComp.city
  502. that.setQuery.district = addComp.district
  503. that.setQuery.mapLat = rs.point.lat
  504. that.setQuery.mapLon = rs.point.lng
  505. console.log(rs);
  506. });
  507. });
  508. });
  509. },
  510. // 保存地址
  511. saveAddress(){
  512. this.$confirm('请确认地址信息准确无误,并精确到门牌号?', '提示', {
  513. confirmButtonText: '确定',
  514. cancelButtonText: '取消',
  515. type: 'warning'
  516. }).then(() => {
  517. this.showMap = false
  518. })
  519. },
  520. // 规则
  521. getRuleList() {
  522. getRuleList({currentPage:1,pageSize:999}).then((res) => {
  523. if (res.state == "Success") {
  524. res.content.records.map(item=>{
  525. this.ruleOptions.push({
  526. label:item.shareRule,
  527. value:item.id
  528. })
  529. })
  530. }
  531. });
  532. },
  533. // 获取商品分类
  534. getData(){
  535. getData().then(res=>{
  536. if(res.state == 'Success'){
  537. this.typeOptions = res.content
  538. }
  539. })
  540. },
  541. // 获取当前主体下面的已签约银联账号
  542. finishComplexList(){
  543. finishComplexList({
  544. "accesseId": "",
  545. "epId": this.setQuery.shopMainId
  546. }).then(res=>{
  547. if(res.state == 'Success'){
  548. let list = []
  549. res.content.map(item=>{
  550. list.push({
  551. value:item.accesser_user_id,
  552. label:item.externalName
  553. })
  554. })
  555. this.authOptions = list
  556. }
  557. })
  558. }
  559. },
  560. created() {
  561. // this.finishComplexList()
  562. this.getData()
  563. this.getRuleList()
  564. this.getMenuName()
  565. this.getMainName()
  566. if (this.$route.query.title == "店铺编辑") {
  567. this.disabled = false;
  568. this.mode = 'edit'
  569. this.detail();
  570. } else if (this.$route.query.title == "店铺详情") {
  571. this.disabled = true;
  572. this.mode = 'detail'
  573. this.detail();
  574. } else {
  575. this.disabled = false;
  576. this.mode = 'add'
  577. }
  578. },
  579. };
  580. </script>
  581. <style lang="scss" scoped>
  582. .shopAdd {
  583. padding-bottom: 40px;
  584. .position{
  585. cursor: pointer;
  586. font-size: 20px;
  587. }
  588. .btn-group {
  589. display: flex;
  590. align-items: center;
  591. justify-content: center;
  592. }
  593. #container {
  594. width: 100%;
  595. height: 600px;
  596. }
  597. }
  598. </style>