index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. <!-- -->
  2. <template>
  3. <div>
  4. <div class="pending">
  5. <!-- 搜索 -->
  6. <div class="formSearch">
  7. <el-form :inline="true" :model="formInline">
  8. <el-form-item label="店铺名称">
  9. <el-input v-model="formInline.shopName" maxlength="20" placeholder="请输入店铺名称" />
  10. </el-form-item>
  11. <el-form-item label="店铺编码">
  12. <el-input v-model="formInline.shopCode" maxlength="20" placeholder="请输入店铺编码" />
  13. </el-form-item>
  14. <el-form-item label="负责人">
  15. <el-input v-model="formInline.chargePersonName" maxlength="20" placeholder="请输入负责人" />
  16. </el-form-item>
  17. <el-form-item label="合同状态">
  18. <el-select v-model="formInline.contractState" placeholder="请选择">
  19. <el-option label="有效" value="1" />
  20. <el-option label="无效" value="0" />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" plain @click="onSubmit">
  25. 查询
  26. </el-button>
  27. <el-button type="success" plain @click="addbuss">
  28. 新建商家
  29. </el-button>
  30. </el-form-item>
  31. </el-form>
  32. </div>
  33. <!-- 表格 -->
  34. <div class="tableBox">
  35. <el-table ref="multipleTable" :data="tableData" border
  36. :header-cell-style="{ background: '#EEF3FF', color: '#333333' }" tooltip-effect="dark" style="width: 100%">
  37. <el-table-column label="店铺名称" width="220">
  38. <template slot-scope="scope">{{ scope.row.shopName }}</template>
  39. </el-table-column>
  40. <el-table-column prop="shopCode" label="店铺编码" />
  41. <el-table-column prop="chargePersonName" label="负责人" />
  42. <el-table-column prop="chargePersonPhone" label="联系电话" />
  43. <el-table-column label="合同状态">
  44. <template slot-scope="scope">
  45. <span v-if="scope.row.contractState === 0">无效</span>
  46. <span v-if="scope.row.contractState === 1">有效</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column prop="createTime" label="创建时间" />
  50. <el-table-column label="操作" show-overflow-tooltip>
  51. <template slot-scope="scope">
  52. <div class="btnList">
  53. <el-button type="text" @click="seeMore(scope.row)">
  54. 查看
  55. </el-button>
  56. <el-button type="text" @click="edit(scope.row)">
  57. 编辑
  58. </el-button>
  59. <el-button v-if="scope.row.state == 1" type="text" @click="del(scope.row)">
  60. 禁用
  61. </el-button>
  62. <el-button v-else type="text" @click="del(scope.row)">
  63. 启用
  64. </el-button>
  65. <el-button type="text" @click="delBusiness(scope.row)">
  66. 删除
  67. </el-button>
  68. </div>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <div class="fenye">
  73. <el-pagination :current-page="currentPage" :page-sizes="[10, 20, 50, 100]" :page-size="10"
  74. layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
  75. @current-change="handleCurrentChange" />
  76. </div>
  77. </div>
  78. <!-- ******************************************************弹框开始****************************************************** -->
  79. <!-- 新建商家弹框 -->
  80. <el-dialog :title="userState === 0
  81. ? '新增商家'
  82. : userState === 1
  83. ? '修改商家'
  84. : '查看商家'
  85. " :visible.sync="dialogVisible" width="30%" center :before-close="closeFn" :close-on-click-modal="false">
  86. <div>
  87. <el-tabs v-model="activeName" @tab-click="handleClick">
  88. <el-tab-pane label="授权信息" name="first">
  89. <el-form ref="ruleFormInfo" :model="ruleForm" :rules="rulesInfo" label-width="120px">
  90. <el-form-item label="店铺名称" prop="shopName">
  91. <el-input v-model="ruleForm.shopName" maxlength="20" :disabled="disabled" />
  92. </el-form-item>
  93. <el-form-item label="店铺负责人" prop="chargePersonName">
  94. <el-input v-model="ruleForm.chargePersonName" maxlength="20" :disabled="disabled" />
  95. </el-form-item>
  96. <el-form-item label="负责人电话" prop="chargePersonPhone">
  97. <el-input v-if="cpPhoneShow" :value="hidden(ruleForm.chargePersonPhone, 3, 4)" maxlength="11"
  98. :disabled="disabled" @focus="focuscpPhoneInput" />
  99. <el-input v-else ref="cpPhoneCls" v-model="ruleForm.chargePersonPhone" maxlength="11" clearable
  100. :disabled="disabled" @change="changecpPhoneInput" />
  101. </el-form-item>
  102. <el-form-item label="请选择区域" prop="areaId">
  103. <el-cascader v-if="!isEdit" :disabled="disabled" :props="areaData" ref="cascaderRef"
  104. @change="handleCascaderChange"></el-cascader>
  105. <div v-else>
  106. {{ ruleForm.areaId }}
  107. <el-button :disabled="disabled" size="mini" type="primary" style="margin-left: 15px;"
  108. @click="isEdit = !isEdit">{{ isEdit ? '修改' : '取消' }}</el-button>
  109. </div>
  110. </el-form-item>
  111. <el-form-item label="请选择门店分类" prop="classificationId">
  112. <el-cascader :disabled="disabled" v-model="ruleForm.classificationId" :options="allShopCategoryList"
  113. :props="{ label: 'storeName', value: 'id', children: 'childs' }"></el-cascader>
  114. </el-form-item>
  115. <el-form-item label="店铺地址" prop="shopAdress">
  116. <el-input ref="addressCls" v-model="ruleForm.shopAdress" maxlength="60" :disabled="disabled" />
  117. <!-- <div v-else @click="inputAddress">
  118. <el-input :value="hidden(ruleForm.shopAdress, 1, 1)" :disabled="disabled" />
  119. </div> -->
  120. </el-form-item>
  121. <el-form-item label="店铺经纬度" prop="longitude">
  122. <div>
  123. <span v-if="ruleForm.longitude">
  124. {{ ruleForm.longitude }} - {{ ruleForm.latitude }}
  125. </span>
  126. <el-button size="mini" type="primary" style="margin-left: 20px;"
  127. @click="$refs.selectAddressMapRef && $refs.selectAddressMapRef.show()">{{ ruleForm.longitude ? '修改'
  128. :
  129. '选择' }}</el-button>
  130. </div>
  131. </el-form-item>
  132. <el-form-item label="生效日期" prop="effectiveDate">
  133. <el-date-picker v-model="ruleForm.effectiveDate" :disabled="disabled" value-format="yyyy-MM-dd"
  134. type="date" placeholder="选择日期" />
  135. </el-form-item>
  136. <el-form-item label="生效年限" prop="effectiveYear">
  137. <el-input v-model="ruleForm.effectiveYear" type="text" :disabled="disabled" placeholder="请输入内容"
  138. maxlength="4" class="elipt" style="width: 50%" show-word-limit />
  139. <span class="elspan">年</span>
  140. </el-form-item>
  141. <el-form-item label="合同状态" prop="contractState">
  142. <el-radio-group v-model="ruleForm.contractState">
  143. <el-radio :disabled="disabled" :label="1">
  144. 有效
  145. </el-radio>
  146. <el-radio :disabled="disabled" :label="0">
  147. 无效
  148. </el-radio>
  149. </el-radio-group>
  150. </el-form-item>
  151. <el-form-item label="店铺类型" prop="shopType">
  152. <el-radio-group v-model="ruleForm.shopType">
  153. <el-radio :disabled="disabled" :label="1">
  154. 商家
  155. </el-radio>
  156. <el-radio :disabled="disabled" :label="2">
  157. 本地
  158. </el-radio>
  159. </el-radio-group>
  160. </el-form-item>
  161. <el-form-item v-if="ruleForm.shopType === 2" prop="startTime" label="营业开始时间" :rules="[
  162. { required: true, message: '请选择营业开始时间', trigger: 'blur' }]">
  163. <el-time-select :disabled="disabled" placeholder="起始时间" v-model="ruleForm.startTime" :picker-options="{
  164. start: '08:30',
  165. step: '00:05',
  166. }">
  167. </el-time-select>
  168. </el-form-item>
  169. <el-form-item v-if="ruleForm.shopType === 2" prop="endTime" label="营业结束时间" :rules="[
  170. { required: true, message: '请选择营业开始时间', trigger: 'blur' }]">
  171. <el-time-select :disabled="disabled" placeholder="营业结束时间" v-model="ruleForm.endTime" :picker-options="{
  172. step: '00:05',
  173. end: '18:30',
  174. minTime: ruleForm.endTime
  175. }">
  176. </el-time-select>
  177. </el-form-item>
  178. <el-form-item label="是否支持代金卷" prop="isVoucher">
  179. <el-radio-group v-model="ruleForm.isVoucher">
  180. <el-radio :disabled="disabled" :label="1">
  181. 允许
  182. </el-radio>
  183. <el-radio :disabled="disabled" :label="2">
  184. 拒绝
  185. </el-radio>
  186. </el-radio-group>
  187. </el-form-item>
  188. <el-form-item v-if="ruleForm.isVoucher === 1" :rules="[
  189. { required: true, message: '请输入代金券返还比例', trigger: 'blur' },
  190. { type: 'number', max: 100, min: 0, message: '请输入正确的代金券返还比例,0 ~ 100', trigger: ['blur', 'change'] }
  191. ]" label="代金券返还比例" prop="voucherReturn">
  192. <el-input :disabled="disabled" placeholder="请填写代金券返还比例,范围0 ~ 100"
  193. v-model.number="ruleForm.voucherReturn">
  194. <template slot="append">%</template>
  195. </el-input>
  196. </el-form-item>
  197. <el-form-item label="直播间审核" prop="auditLive">
  198. <el-radio-group v-model="ruleForm.auditLive">
  199. <el-radio :disabled="disabled" :label="1">
  200. 开启
  201. </el-radio>
  202. <el-radio :disabled="disabled" :label="0">
  203. 关闭
  204. </el-radio>
  205. </el-radio-group>
  206. </el-form-item>
  207. <el-form-item label="直播间商品审核" prop="auditLiveProduct">
  208. <el-radio-group v-model="ruleForm.auditLiveProduct">
  209. <el-radio :disabled="disabled" :label="1">
  210. 开启
  211. </el-radio>
  212. <el-radio :disabled="disabled" :label="0">
  213. 关闭
  214. </el-radio>
  215. </el-radio-group>
  216. </el-form-item>
  217. <el-form-item class="b-shop-rate" prop="score" label="评分">
  218. <el-rate :disabled="disabled" v-model="ruleForm.score"></el-rate>
  219. </el-form-item>
  220. <el-form-item prop="monthlySales" label="月售">
  221. <el-input :disabled="disabled" placeholder="请输入商家月售额" v-model.number="ruleForm.monthlySales"
  222. type="number"></el-input>
  223. </el-form-item>
  224. <el-form-item prop="perCapita" label="人均">
  225. <el-input :disabled="disabled" type="number" placeholder="请输入人均消费额" v-model.number="ruleForm.perCapita"
  226. closeable></el-input>
  227. </el-form-item>
  228. <el-form-item prop="advertisement" label="广告图">
  229. <el-upload :disabled="disabled" class="avatar-uploader" list-type="picture-card"
  230. :file-list="advertisementList" :action="action" :on-success="handleAvatarSuccess"
  231. :on-remove="handleRemovePic">
  232. <i class="el-icon-plus avatar-uploader-icon" />
  233. </el-upload>
  234. </el-form-item>
  235. </el-form>
  236. </el-tab-pane>
  237. <el-tab-pane label="客户信息" name="second">
  238. <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px">
  239. <el-form-item label="账号" prop="shopPhone">
  240. <el-input v-if="shopPhoneShow" :value="hidden(ruleForm.shopPhone, 3, 4)" :disabled="disabled"
  241. maxlength="20" @focus="focusShopPhoneInput" />
  242. <el-input v-else ref="shopPhoneCls" v-model="ruleForm.shopPhone" :disabled="disabled" maxlength="20" />
  243. </el-form-item>
  244. <el-form-item label="密码" prop="shopPassword">
  245. <el-input v-model="ruleForm.shopPassword" type="password" :disabled="disabled" maxlength="16" />
  246. </el-form-item>
  247. </el-form>
  248. </el-tab-pane>
  249. </el-tabs>
  250. </div>
  251. <span slot="footer" class="dialog-footer">
  252. <el-button @click="closeFn">取 消</el-button>
  253. <el-button v-if="activeName == 'first'" type="primary" @click="next">下一步</el-button>
  254. <el-button v-else type="primary" @click="addCheck('ruleForm')">确 定</el-button>
  255. </span>
  256. </el-dialog>
  257. </div>
  258. <!-- 选择经纬度 -->
  259. <SelectAddressMap ref="selectAddressMapRef" @select="handleSelectLngAndLat"></SelectAddressMap>
  260. </div>
  261. </template>
  262. <script>
  263. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  264. // 例如:import 《组件名称》 from '《组件路径》';
  265. import {
  266. businessListGetAll,
  267. businessListSave,
  268. businessListGetById,
  269. businessListUpdate,
  270. businessListStart,
  271. delBusinessById
  272. } from '@/api/business'
  273. import { uploadUrl } from '@/utils/request'
  274. import { getProvinceList, getChildAreaList } from '@/api/address'
  275. import { businessClassList } from '@/api/business'
  276. import SelectAddressMap from './components/SelectAddressMap'
  277. export default {
  278. // eslint-disable-next-line vue/match-component-file-name
  279. name: 'BusinessList',
  280. components: { SelectAddressMap },
  281. data() {
  282. // 这里存放数据
  283. return {
  284. action: uploadUrl,
  285. advertisementList: [],
  286. allShopCategoryList: [],
  287. areaData: {
  288. lazy: true,
  289. label: 'name',
  290. value: 'id',
  291. lazyLoad(node, resolve) {
  292. const { level, value } = node;
  293. if (level === 0) {
  294. getProvinceList().then(res => {
  295. resolve(res.data)
  296. })
  297. } else if (level != 0) {
  298. getChildAreaList(value).then(res => {
  299. resolve(res.data.map(item => {
  300. item.leaf = level === 3
  301. return item
  302. }))
  303. })
  304. }
  305. }
  306. },
  307. // 新建商家弹框
  308. dialogVisible: false,
  309. isEdit: false, // 是否是编辑
  310. originShopDetailInfo: null, // 点击编辑上架2详情原始数据
  311. activeName: 'first',
  312. formInline: {
  313. shopName: '', // 店铺名称
  314. shopCode: '', // 店铺编码
  315. chargePersonName: '', // 店铺负责人
  316. contractState: '', // 合同状态 1-有效 0-无效
  317. page: '1', // 当前页
  318. pageSize: '10' // 每页记录数
  319. },
  320. disabled: false,
  321. ruleForm: {
  322. shopName: '', // 店铺名称
  323. chargePersonName: '', // 店铺负责人
  324. chargePersonPhone: '', // 负责人电话
  325. shopType: 1, // 店铺类型 1商家 2本地
  326. isVoucher: 1, // 是否支持代金卷 1 true 2 false
  327. shopAdress: '', // 地址
  328. effectiveDate: '', // 生效日期
  329. effectiveYear: '', // 生效年限
  330. contractState: 1, // 合同状态 1-有效 0-无效
  331. auditLive: 1,
  332. auditLiveProduct: 1,
  333. shopPhone: '', // 账号
  334. shopPassword: '', // 密码
  335. perCapita: "", //人均
  336. score: 5, // 评分
  337. advertisement: '',
  338. classificationId: null, // 商家分类id
  339. startTime: "",
  340. endTime: ""
  341. },
  342. showPhone: false,
  343. showAddress: false,
  344. userPhone: '',
  345. showUserPhone: false,
  346. newAddress: '',
  347. personPhone: '',
  348. rulesInfo: {
  349. effectiveYear: [
  350. { required: true, message: '请输入生效时限', trigger: 'blur' }
  351. ],
  352. shopName: [
  353. { required: true, message: '请输入店铺名称', trigger: 'blur' }
  354. ],
  355. chargePersonName: [
  356. { required: true, message: '请输入店铺负责人', trigger: 'blur' }
  357. ],
  358. chargePersonPhone: [
  359. { required: true, message: '请输入负责人电话', trigger: 'blur' },
  360. {
  361. pattern: /^1[3456789]\d{9}$/,
  362. message: '目前只支持中国大陆的手机号码'
  363. }
  364. ],
  365. shopAdress: [
  366. { required: true, message: '请输入地址', trigger: 'blur' }
  367. ],
  368. contractState: [
  369. {
  370. required: true,
  371. message: '请选择合同状态',
  372. trigger: 'change'
  373. }
  374. ],
  375. shopType: [
  376. {
  377. required: true,
  378. message: '请选择店铺类型',
  379. trigger: 'change'
  380. }
  381. ],
  382. perCapita: [
  383. { required: true, message: "请输入人均消费额", trigger: "blur" }
  384. ],
  385. isVoucher: [
  386. {
  387. required: true,
  388. message: '请选择是否允许使用代金卷',
  389. trigger: 'change'
  390. }
  391. ], // 是否支持代金卷 1 true 2 false
  392. auditLive: [
  393. {
  394. required: true,
  395. message: '请选择状态',
  396. trigger: 'change'
  397. }
  398. ],
  399. auditLiveProduct: [
  400. {
  401. required: true,
  402. message: '请选择状态',
  403. trigger: 'change'
  404. }
  405. ],
  406. effectiveDate: [
  407. {
  408. required: true,
  409. message: '请选择日期',
  410. trigger: 'change'
  411. }
  412. ],
  413. score: [
  414. {
  415. required: true,
  416. message: '请选择商家评分',
  417. trigger: 'change'
  418. }
  419. ],
  420. monthlySales: [
  421. {
  422. required: true,
  423. message: '请输入商家月售额',
  424. trigger: 'trigger'
  425. }
  426. ],
  427. // advertisement: [
  428. // {
  429. // required: true,
  430. // message: '请上传广告图',
  431. // trigger: 'trigger'
  432. // }
  433. // ],
  434. areaId: [
  435. {
  436. required: true,
  437. message: "请选择地址",
  438. trigger: 'blur'
  439. }
  440. ],
  441. longitude: [
  442. {
  443. required: true,
  444. message: "请选择商家经纬度",
  445. trigger: 'blur'
  446. }
  447. ]
  448. },
  449. rules: {
  450. shopPhone: [
  451. { required: true, message: '请输入账号', trigger: 'blur' },
  452. {
  453. pattern: /^1[3456789]\d{9}$/,
  454. message: '目前只支持中国大陆的手机号码'
  455. }
  456. ],
  457. shopPassword: [
  458. { required: true, message: '请输入密码', trigger: 'blur' },
  459. {
  460. pattern: /^[~!@#$%^&*\-+=_.0-9a-zA-Z]{8,16}$/,
  461. message: '8-16密码数字英文混合'
  462. }
  463. ]
  464. },
  465. total: 1,
  466. tableData: [],
  467. currentPage: 1,
  468. userState: 1,
  469. privacyTime: 0,
  470. cpPhoneShow: true, // 是否显示脱敏负责人手机号
  471. shopPhoneShow: true // 是否显示脱敏账号
  472. }
  473. },
  474. // 监听属性 类似于data概念
  475. computed: {},
  476. // 监控data中的数据变化
  477. watch: {},
  478. // 生命周期 - 创建完成(可以访问当前this实例)
  479. created() {
  480. },
  481. // 生命周期 - 挂载完成(可以访问DOM元素)
  482. mounted() {
  483. this.getAll(this.formInline)
  484. this.getCategoryList()
  485. this.privacyTime = localStorage.getItem('privacyTime')
  486. console.log(this.privacyTime)
  487. },
  488. // 方法集合
  489. methods: {
  490. focusShopPhoneInput() {
  491. this.shopPhoneShow = false
  492. this.ruleForm.shopPhone = ''
  493. // 自动获取焦点
  494. this.$nextTick(() => {
  495. this.$refs.shopPhoneCls.focus()
  496. })
  497. },
  498. focuscpPhoneInput() {
  499. this.cpPhoneShow = false
  500. this.ruleForm.chargePersonPhone = ''
  501. // 自动获取焦点
  502. this.$nextTick(() => {
  503. this.$refs.cpPhoneCls.focus()
  504. })
  505. },
  506. changecpPhoneInput() {
  507. },
  508. handleSizeChange(val) {
  509. this.formInline.pageSize = val
  510. this.getAll(this.formInline)
  511. },
  512. handleCurrentChange(val) {
  513. this.formInline.page = val
  514. this.getAll(this.formInline)
  515. },
  516. handleClick(tab, event) {
  517. console.log(tab, event)
  518. },
  519. onSubmit() {
  520. this.getAll(this.formInline)
  521. },
  522. // 新建商家
  523. addbuss() {
  524. this.userState = 0
  525. this.disabled = false
  526. this.newAddress = ''
  527. this.personPhone = ''
  528. this.ruleForm = {
  529. shopName: '', // 店铺名称
  530. chargePersonName: '', // 店铺负责人
  531. chargePersonPhone: '', // 负责人电话
  532. shopAdress: '', // 地址
  533. effectiveDate: '', // 生效日期
  534. effectiveYear: '', // 生效年限
  535. shopType: 1, // 商家类型 1 商家 2 本地
  536. isVoucher: 1, // 是否支持代金卷 1 true 2 false
  537. contractState: 1, // 合同状态 1-有效 0-无效
  538. auditLive: 1,
  539. auditLiveProduct: 1,
  540. shopPhone: '', // 账号
  541. shopPassword: '', // 密码
  542. advertisement: '', // 广告图
  543. areaId: '', // 区域id
  544. longitude: '', // 经纬度
  545. latitude: '', // 经纬度
  546. }
  547. this.dialogVisible = true
  548. this.advertisementList = []
  549. },
  550. next() {
  551. this.activeName = 'second'
  552. },
  553. closeFn() {
  554. this.$nextTick(() => {
  555. this.$refs.ruleForm.resetFields()
  556. this.$refs.ruleForm.clearValidate()
  557. this.$refs.ruleFormInfo.clearValidate()
  558. this.dialogVisible = false
  559. })
  560. },
  561. // 新建商家确定
  562. addCheck() {
  563. const submitData = JSON.parse(JSON.stringify(this.ruleForm))
  564. submitData.advertisement = this.advertisementList.map(item => item.url).join(',')
  565. console.log(submitData)
  566. this.$refs['ruleFormInfo'].validate((valid) => {
  567. if (valid) {
  568. console.log(this.userState)
  569. if (this.personPhone !== '') {
  570. submitData.chargePersonPhone = this.personPhone
  571. }
  572. if (this.newAddress !== '') {
  573. submitData.shopAdress = this.newAddress
  574. }
  575. if (this.userPhone !== '') {
  576. submitData.shopPhone = this.userPhone
  577. }
  578. if (submitData.shopName === '') {
  579. this.$message.error('请输入店铺名称')
  580. return
  581. }
  582. if (submitData.effectiveDate === '') {
  583. this.$message.error('请输入生效日期')
  584. return
  585. }
  586. if (submitData.effectiveYear === '') {
  587. this.$message.error('请输入生效年限')
  588. return
  589. }
  590. submitData.classificationId = submitData.classificationId[2]
  591. if (!this.userState) {
  592. businessListSave(submitData).then((res) => {
  593. console.log(res)
  594. if (res.code === '') {
  595. this.$message({
  596. message: '新增成功',
  597. type: 'success'
  598. })
  599. }
  600. this.getAll(this.formInline)
  601. this.dialogVisible = false
  602. this.$refs.ruleForm.clearValidate()
  603. })
  604. } else {
  605. businessListUpdate(submitData).then((res) => {
  606. console.log(res)
  607. if (res.code === '') {
  608. this.$message({
  609. message: '修改成功',
  610. type: 'success'
  611. })
  612. this.$refs.ruleForm.clearValidate()
  613. }
  614. this.getAll(this.formInline)
  615. this.dialogVisible = false
  616. })
  617. }
  618. } else {
  619. console.log('error submit!!')
  620. this.$message.error('请输入完整信息')
  621. return false
  622. }
  623. })
  624. },
  625. // 查看
  626. async seeMore(row) {
  627. this.showPhone = false
  628. this.cpPhoneShow = true
  629. this.shopPhoneShow = true
  630. const res = await businessListGetById({ shopId: row.shopId })
  631. if (res.code === '') {
  632. this.userState = 3
  633. this.disabled = true
  634. this.ruleForm = res.data
  635. this.dialogVisible = true
  636. this.initShopClassPath(this.ruleForm.classificationId)
  637. this.ruleForm.voucherReturn *= 1
  638. const advertisementStr = this.ruleForm.advertisement
  639. if (advertisementStr && typeof advertisementStr === 'string') {
  640. this.advertisementList = advertisementStr.split(',').map(item => {
  641. return {
  642. url: item,
  643. uid: item + Math.random() + new Date()
  644. }
  645. })
  646. }
  647. }
  648. },
  649. // 编辑
  650. async edit(row) {
  651. this.showPhone = false
  652. this.personPhone = ''
  653. this.userState = 1
  654. this.disabled = false
  655. this.cpPhoneShow = true
  656. const res = await businessListGetById({ shopId: row.shopId })
  657. this.ruleForm = res.data
  658. this.dialogVisible = true
  659. this.isEdit = true
  660. this.originShopDetailInfo = JSON.parse(JSON.stringify(res.data))
  661. this.initShopClassPath(this.ruleForm.classificationId)
  662. this.ruleForm.voucherReturn *= 1
  663. const advertisementStr = this.ruleForm.advertisement
  664. if (advertisementStr && typeof advertisementStr === 'string') {
  665. this.advertisementList = advertisementStr.split(',').map(item => {
  666. return {
  667. url: item,
  668. uid: item + Math.random() + new Date()
  669. }
  670. })
  671. }
  672. },
  673. // 删除
  674. async del(row) {
  675. console.log(row)
  676. if (row.state === 1) {
  677. const res = await businessListStart({
  678. shopName: row.shopName,
  679. state: 0,
  680. shopId: row.shopId
  681. })
  682. if (res.code === '') {
  683. this.$message({
  684. message: '停用成功',
  685. type: 'success'
  686. })
  687. this.getAll(this.formInline)
  688. }
  689. } else {
  690. const res = await businessListStart({
  691. shopName: row.shopName,
  692. state: 1,
  693. shopId: row.shopId
  694. })
  695. if (res.code === '') {
  696. this.$message({
  697. message: '启用成功',
  698. type: 'success'
  699. })
  700. this.getAll(this.formInline)
  701. }
  702. }
  703. },
  704. delBusiness(row) {
  705. // todo 判断商家状态
  706. this.$confirm('此操作将永久删除该商家, 是否继续?', '提示', {
  707. confirmButtonText: '确定',
  708. cancelButtonText: '取消',
  709. type: 'warning'
  710. }).then(async () => {
  711. const res = await delBusinessById({
  712. shopId: row.shopId
  713. })
  714. if (res.code === '') {
  715. this.$message({
  716. message: '操作成功',
  717. type: 'success'
  718. })
  719. this.getAll(this.formInline)
  720. }
  721. })
  722. .catch(() => {
  723. })
  724. },
  725. // businessListGetAll
  726. // 初始化查询所有数据
  727. async getAll(formInline) {
  728. const res = await businessListGetAll(formInline)
  729. this.total = res.data.total
  730. this.tableData = res.data.list
  731. },
  732. // 编辑号码
  733. inputPhone() {
  734. this.showPhone = true
  735. this.personPhone = ''
  736. this.$nextTick(() => {
  737. this.$refs.phoneCls.focus()
  738. })
  739. },
  740. // 编辑地址
  741. inputAddress() {
  742. this.showAddress = true
  743. this.newAddress = ''
  744. this.$nextTick(() => {
  745. this.$refs.addressCls.focus()
  746. })
  747. },
  748. // 编辑客户信息
  749. inputUserPhone() {
  750. this.showUserPhone = true
  751. this.userPhone = ''
  752. this.$nextTick(() => {
  753. this.$refs.userPhoneCls.focus()
  754. })
  755. },
  756. // 中间部分
  757. hidden(str, frontLen, endLen) {
  758. let endLenData = 0
  759. if (str.length !== 2) {
  760. endLenData = endLen
  761. }
  762. const len = str.length - frontLen - endLenData
  763. let xing = ''
  764. for (let i = 0; i < len; i++) {
  765. xing += '*'
  766. }
  767. return (
  768. str.substring(0, frontLen) + xing + str.substring(str.length - endLenData)
  769. )
  770. },
  771. handleAvatarSuccess(response) {
  772. const { url } = response.data
  773. this.advertisementList.push({
  774. url, uid: url + Math.random() + Date.now()
  775. })
  776. },
  777. handleRemovePic(e) {
  778. const { uid } = e
  779. this.advertisementList = this.advertisementList.filter(item => item.uid !== uid)
  780. },
  781. // 获取省数据
  782. handleCascaderChange() {
  783. const checkedNode = this.$refs.cascaderRef.getCheckedNodes()
  784. const nodeData = checkedNode[0].data
  785. this.ruleForm.areaId = nodeData.id
  786. },
  787. // 获取所有商家分类
  788. async getCategoryList() {
  789. const res = await businessClassList({
  790. page: 1,
  791. pageSize: 100
  792. })
  793. this.allShopCategoryList = res.data.records.map(item => {
  794. item.childs.map(item2 => {
  795. item2.childs.map(item3 => {
  796. delete item3.childs
  797. return item3
  798. })
  799. return item2
  800. })
  801. return item
  802. })
  803. },
  804. // 获取路径信息
  805. initShopClassPath(classId) {
  806. const allLevelThereList = []
  807. this.allShopCategoryList.forEach(item => {
  808. item.childs.forEach(item1 => {
  809. allLevelThereList.push(...item1.childs)
  810. })
  811. })
  812. const currentClassInfo = allLevelThereList.find(item => {
  813. return item.levelId.includes(classId)
  814. })
  815. if (currentClassInfo) {
  816. this.ruleForm.classificationId = currentClassInfo.levelId.slice(1).split('/').map(item => item * 1)
  817. }
  818. },
  819. // 选择经纬
  820. handleSelectLngAndLat(address) {
  821. this.ruleForm.longitude = address[0]
  822. this.ruleForm.latitude = address[1]
  823. }
  824. }
  825. }
  826. </script>
  827. <style
  828. lang="scss"
  829. scoped
  830. >
  831. @import url("../../../styles/elDialog.scss");
  832. .pending {
  833. padding: 30px;
  834. }
  835. .fenye {
  836. margin-top: 20px;
  837. }
  838. .elipt {
  839. width: 50%;
  840. }
  841. .elspan {
  842. margin-left: 10px;
  843. }
  844. </style>