merchant_list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div class="screen-container">
  5. <Collapse :screen-form="screenForm">
  6. <template #right_btn>
  7. <el-button size="mini" @click="resetScreenForm">清空</el-button>
  8. <el-button size="mini" type="primary" @click="submitScreenForm">搜索</el-button>
  9. </template>
  10. <template #search>
  11. <el-form ref="screenForm" :model="screenForm" label-width="70px" size="mini" label-position="left">
  12. <el-row :gutter="20">
  13. <el-col :xs="24" :sm="12" :lg="6">
  14. <el-form-item label="商户账号" prop="account">
  15. <el-input v-model="screenForm.account" placeholder="请输入商户账号"></el-input>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :xs="24" :sm="12" :lg="6">
  19. <el-form-item label="商户昵称" prop="nickname">
  20. <el-input v-model="screenForm.nickname" placeholder="请输入商户昵称"></el-input>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :xs="24" :sm="12" :lg="6">
  24. <el-form-item label="联系电话" prop="phone">
  25. <el-input v-model="screenForm.phone" placeholder="请输入联系电话"></el-input>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :xs="24" :sm="12" :lg="6">
  29. <el-form-item label="电子邮箱" prop="email">
  30. <el-input v-model="screenForm.email" placeholder="请输入电子邮箱"></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :lg="6">
  34. <el-form-item label="状态" prop="state">
  35. <el-select v-model="screenForm.status" placeholder="全部">
  36. <el-option label="全部" value=""></el-option>
  37. <el-option
  38. :label="item.label"
  39. :value="item.value"
  40. v-for="(item, index) in select_status"
  41. :key="index"
  42. ></el-option>
  43. </el-select>
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. </el-form>
  48. </template>
  49. </Collapse>
  50. </div>
  51. <div class="mymain-container">
  52. <div class="btn-group clearfix">
  53. <div class="fl">
  54. <el-button size="mini" type="primary" @click="toCreate()">开通账号</el-button>
  55. </div>
  56. <div class="fr">
  57. <ExportButton :exUrl="'admin/user/mch/export'" :exParams="exParams" />
  58. </div>
  59. </div>
  60. <div class="table">
  61. <el-table
  62. v-loading="listLoading"
  63. :data="dataList"
  64. element-loading-text="Loading"
  65. border
  66. fit
  67. highlight-current-row
  68. stripe
  69. >
  70. <el-table-column align="center" label="操作" width="120" fixed="right">
  71. <template slot-scope="scope">
  72. <el-button type="text" @click="toDetail(scope.row.adminUserId)">详情</el-button>
  73. <template v-if="checkBtnRole('status')">
  74. <el-popconfirm
  75. v-if="scope.row.status"
  76. style="margin-left: 10px"
  77. title="确定冻结吗?"
  78. @confirm="changeStatus(scope.row.adminUserId, 0)"
  79. >
  80. <el-button slot="reference" type="text">冻结</el-button>
  81. </el-popconfirm>
  82. <el-popconfirm
  83. v-else
  84. style="margin-left: 10px"
  85. title="确定恢复吗?"
  86. @confirm="changeStatus(scope.row.adminUserId, 1)"
  87. >
  88. <el-button slot="reference" type="text">恢复</el-button>
  89. </el-popconfirm>
  90. </template>
  91. </template>
  92. </el-table-column>
  93. <el-table-column align="center" label="商户账号" prop="userName" min-width="100" show-overflow-tooltip>
  94. <template slot-scope="scope">
  95. <el-button type="text" @click="toAccountList(scope.row)">查看</el-button>
  96. </template>
  97. </el-table-column>
  98. <el-table-column
  99. align="center"
  100. label="商户昵称"
  101. prop="adminCompanyName"
  102. min-width="160"
  103. show-overflow-tooltip
  104. ></el-table-column>
  105. <el-table-column
  106. align="center"
  107. label="负责人"
  108. prop="linkName"
  109. min-width="100"
  110. show-overflow-tooltip
  111. ></el-table-column>
  112. <el-table-column
  113. align="center"
  114. label="角色"
  115. prop="roleName"
  116. min-width="160"
  117. show-overflow-tooltip
  118. ></el-table-column>
  119. <el-table-column
  120. align="center"
  121. label="联系电话"
  122. prop="linkPhone"
  123. min-width="160"
  124. show-overflow-tooltip
  125. ></el-table-column>
  126. <el-table-column
  127. align="center"
  128. label="金蝶主体账号"
  129. prop="useOrgNumber"
  130. min-width="160"
  131. show-overflow-tooltip
  132. ></el-table-column>
  133. <el-table-column
  134. align="center"
  135. label="金蝶主体名称"
  136. prop="useOrgName"
  137. min-width="160"
  138. show-overflow-tooltip
  139. ></el-table-column>
  140. <el-table-column
  141. align="center"
  142. label="电子邮箱"
  143. prop="email"
  144. min-width="160"
  145. show-overflow-tooltip
  146. ></el-table-column>
  147. <el-table-column
  148. align="center"
  149. label="地址"
  150. prop="address"
  151. min-width="200"
  152. show-overflow-tooltip
  153. ></el-table-column>
  154. <el-table-column align="center" label="状态" class-name="status-col">
  155. <template slot-scope="scope">
  156. <el-tag :type="scope.row.status ? 'success' : 'danger'">{{ scope.row.status ? '正常' : '冻结' }}</el-tag>
  157. </template>
  158. </el-table-column>
  159. </el-table>
  160. </div>
  161. </div>
  162. <div class="pagination clearfix">
  163. <div class="fr">
  164. <el-pagination
  165. @size-change="handleSizeChange"
  166. @current-change="handleCurrentChange"
  167. :current-page="currentPage"
  168. :page-sizes="[10, 20, 30, 50]"
  169. :page-size="10"
  170. layout="total, sizes, prev, pager, next, jumper"
  171. :total="listTotal"
  172. >
  173. </el-pagination>
  174. </div>
  175. </div>
  176. <!-- 详情弹窗 -->
  177. <el-dialog
  178. title="详情"
  179. :visible.sync="detailDiaLog"
  180. width="600px"
  181. :show-close="false"
  182. :close-on-click-modal="false"
  183. >
  184. <div>
  185. <el-form class="my-form" ref="mainForm" :model="mainForm" label-width="100px" label-position="right">
  186. <el-form-item label="商户账号" prop="account">
  187. <el-input v-model="mainForm.account" disabled class="formWidth"></el-input>
  188. </el-form-item>
  189. <el-form-item label="账户昵称" prop="nickName">
  190. <el-input v-model="mainForm.nickName" disabled class="formWidth"></el-input>
  191. </el-form-item>
  192. <el-form-item label="负责人" prop="chargePerson">
  193. <el-input v-model="mainForm.chargePerson" disabled class="formWidth"></el-input>
  194. </el-form-item>
  195. <el-form-item label="联系电话" prop="phone">
  196. <el-input v-model="mainForm.phone" disabled class="formWidth"></el-input>
  197. </el-form-item>
  198. <el-form-item label="金蝶主体账号" prop="kingdeeId">
  199. <el-input v-model="mainForm.kingdeeId" disabled class="formWidth"></el-input>
  200. </el-form-item>
  201. <el-form-item label="金蝶主体名称" prop="kingdeeName">
  202. <el-input v-model="mainForm.kingdeeName" disabled class="formWidth"></el-input>
  203. </el-form-item>
  204. <el-form-item label="电子邮箱" prop="email">
  205. <el-input v-model="mainForm.email" disabled class="formWidth"></el-input>
  206. </el-form-item>
  207. <el-form-item label="地址" prop="address">
  208. <el-input v-model="mainForm.address" disabled class="formWidth"></el-input>
  209. </el-form-item>
  210. <el-form-item label="登录密码" prop="password">
  211. <el-input v-model="mainForm.password" type="password" disabled class="formWidth"></el-input>
  212. <el-button class="reset" @click="handleReset()">重置密码</el-button>
  213. </el-form-item>
  214. <!-- <el-form-item class="tr">
  215. <el-button type="primary" @click="submitmainForm">保存</el-button>
  216. </el-form-item> -->
  217. </el-form>
  218. <!-- 重置密码 -->
  219. <el-dialog
  220. append-to-body
  221. title="重置密码"
  222. :visible.sync="resetFormVisible"
  223. :show-close="false"
  224. width="500px"
  225. :close-on-click-modal="false"
  226. >
  227. <el-form ref="resetForm" :model="resetForm" :rules="resetFormRules" label-position="left" label-width="100px">
  228. <el-form-item label="输入新密码" prop="newPassword">
  229. <el-input
  230. v-model="resetForm.newPassword"
  231. ref="password1"
  232. autocomplete="off"
  233. class="formWidth"
  234. placeholder="请输入新密码"
  235. :type="passwordType1"
  236. ></el-input>
  237. <span class="show-pwd" @click="showPwd(1)">
  238. <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
  239. </span>
  240. </el-form-item>
  241. <el-form-item label="确认密码" prop="confirmPassword">
  242. <el-input
  243. v-model="resetForm.confirmPassword"
  244. ref="password2"
  245. autocomplete="off"
  246. class="formWidth"
  247. placeholder="请再次输入新密码"
  248. :type="passwordType2"
  249. ></el-input>
  250. <span class="show-pwd" @click="showPwd(2)">
  251. <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
  252. </span>
  253. </el-form-item>
  254. </el-form>
  255. <div slot="footer" class="dialog-footer">
  256. <el-button @click="cancelResetForm">取 消</el-button>
  257. <el-button type="primary" @click="submitResetForm">确 定</el-button>
  258. </div>
  259. </el-dialog>
  260. </div>
  261. <span slot="footer" class="dialog-footer">
  262. <el-button @click="detailDiaLog = false">关 闭</el-button>
  263. </span>
  264. </el-dialog>
  265. </div>
  266. </template>
  267. <script>
  268. import { COMMON_SELECT } from '@/utils/select_data'
  269. import { getList, changeAccountStatus, getDetail, resetPassword, editAccount } from '@/api/merchant'
  270. import { downloadFiles } from '@/utils/util'
  271. import { getToken } from '@/utils/auth'
  272. export default {
  273. // components:{MERCHANT_DETAIL},
  274. data() {
  275. var validatePass = (rule, value, callback) => {
  276. if (value === '') {
  277. callback(new Error('请输入登录密码'))
  278. } else if (value.length < 12) {
  279. callback(new Error('密码长度至少12位'))
  280. } else if (/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/.test(value) == false) {
  281. callback(new Error('密码必须包含数字和字母'))
  282. } else {
  283. if (this.resetForm.confirmPassword !== '') {
  284. this.$refs.resetForm.validateField('confirmPassword')
  285. }
  286. callback()
  287. }
  288. }
  289. var validatePass2 = (rule, value, callback) => {
  290. if (value === '') {
  291. callback(new Error('请再次输入密码'))
  292. } else if (value !== this.resetForm.newPassword) {
  293. callback(new Error('两次输入密码不一致'))
  294. } else {
  295. callback()
  296. }
  297. }
  298. return {
  299. baseURL: process.env.VUE_APP_BASE_API,
  300. myHeaders: { 'x-token': getToken() },
  301. id: null,
  302. isCollapse: true,
  303. companyWechatId: null,
  304. step: 'first',
  305. mainForm: {
  306. account: '', // 账号
  307. nickName: '', // 用户名
  308. chargePerson: '', // 负责人
  309. phone: '', // 联系电话
  310. kingdeeId: '',
  311. kingdeeName: '',
  312. email: '', // 电子邮箱
  313. address: '', // 地址
  314. newPassword: '', // 新密码
  315. confirmPassword: '' // 确认密码
  316. },
  317. passwordType1: 'password',
  318. passwordType2: 'password',
  319. resetFormVisible: false,
  320. resetForm: {
  321. newPassword: '', // 新密码
  322. confirmPassword: '' // 确认密码
  323. },
  324. resetFormRules: {
  325. newPassword: [{ required: true, validator: validatePass, trigger: 'blur' }],
  326. confirmPassword: [{ required: true, validator: validatePass2, trigger: 'blur' }]
  327. },
  328. formLoading: false,
  329. detailDiaLog: false, //详情弹窗
  330. isOpen: false, // 是否展开条件筛选
  331. currentPage: 1, // 当前页码
  332. pageSize: 10, // 每页数量
  333. listTotal: 0, // 列表总数
  334. dataList: null, // 列表数据
  335. listLoading: false, // 列表加载loading
  336. screenForm: {
  337. // 筛选表单数据
  338. account: '',
  339. nickname: '',
  340. phone: '',
  341. email: '',
  342. status: ''
  343. },
  344. select_status: [
  345. // 筛选字段 - 状态
  346. { label: '正常', value: true },
  347. { label: '冻结', value: false }
  348. ]
  349. }
  350. },
  351. created() {
  352. this.getList()
  353. },
  354. computed: {
  355. sidebar() {
  356. return this.$store.state.app.sidebar
  357. },
  358. classObj() {
  359. return {
  360. hideSidebar: !this.sidebar.opened,
  361. openSidebar: this.sidebar.opened
  362. }
  363. },
  364. exParams() {
  365. return {
  366. userName: this.screenForm.account,
  367. nickName: this.screenForm.nickname,
  368. linkPhone: this.screenForm.phone,
  369. email: this.screenForm.email,
  370. status: this.screenForm.status
  371. }
  372. }
  373. },
  374. methods: {
  375. goBack() {
  376. this.$router.go(-1)
  377. },
  378. // 重置密码
  379. handleReset(id) {
  380. this.resetId = id
  381. this.resetFormVisible = true
  382. },
  383. // 取消重置密码
  384. cancelResetForm() {
  385. this.resetFormVisible = false
  386. this.passwordType1 = 'password'
  387. this.passwordType2 = 'password'
  388. this.$refs.resetForm.resetFields()
  389. },
  390. // 提交重置密码
  391. submitResetForm() {
  392. this.$refs.resetForm.validate(valid => {
  393. if (valid) {
  394. let params = {
  395. password: this.resetForm.newPassword,
  396. adminUserId: this.id
  397. }
  398. resetPassword(params).then(res => {
  399. this.cancelResetForm()
  400. this.getDetail()
  401. this.$successMsg()
  402. })
  403. }
  404. })
  405. },
  406. // 显示隐藏密码
  407. showPwd(num) {
  408. if (num == 1) {
  409. if (this.passwordType1 === 'password') {
  410. this.passwordType1 = ''
  411. } else {
  412. this.passwordType1 = 'password'
  413. }
  414. this.$nextTick(() => {
  415. this.$refs.password1.focus()
  416. })
  417. }
  418. if (num == 2) {
  419. if (this.passwordType2 === 'password') {
  420. this.passwordType2 = ''
  421. } else {
  422. this.passwordType2 = 'password'
  423. }
  424. this.$nextTick(() => {
  425. this.$refs.password2.focus()
  426. })
  427. }
  428. },
  429. submitMainForm() {
  430. this.$refs.mainForm.validate(valid => {
  431. if (valid) {
  432. this.formLoading = true
  433. let params = {
  434. adminUserId: this.id,
  435. corpId: this.mainForm.enterpriseId,
  436. secret2: this.mainForm.listSecret,
  437. secret3: this.mainForm.listSyncSecret,
  438. agentId1: this.mainForm.appAgentId,
  439. secret1: this.mainForm.appSecret,
  440. appId: this.mainForm.appId,
  441. mchId: this.mainForm.merchantId,
  442. mchKey: this.mainForm.merchantKey,
  443. subAppId: this.mainForm.childAppId,
  444. subSecret: this.mainForm.childKey,
  445. subMchId: this.mainForm.childMerchantId,
  446. template: this.mainForm.templateId,
  447. companyWechatId: this.companyWechatId
  448. }
  449. editAccount(params)
  450. .then(res => {
  451. this.$successMsg('保存成功')
  452. setTimeout(() => {
  453. this.goBack()
  454. }, 1500)
  455. })
  456. .finally(res => {
  457. this.formLoading = false
  458. })
  459. }
  460. })
  461. },
  462. // 查询按钮权限
  463. checkBtnRole(value) {
  464. // let btnRole = this.$route.meta.roles;
  465. // if(!btnRole) {return true}
  466. // let index = btnRole.indexOf(value);
  467. // return index >= 0;
  468. return true
  469. },
  470. // 查询列表
  471. getList() {
  472. this.listLoading = true
  473. let params = {
  474. pageNum: this.currentPage,
  475. pageSize: this.pageSize,
  476. userName: this.screenForm.account,
  477. nickName: this.screenForm.nickname,
  478. linkPhone: this.screenForm.phone,
  479. email: this.screenForm.email,
  480. status: this.screenForm.status
  481. }
  482. getList(params).then(res => {
  483. this.dataList = res.data.records
  484. this.listTotal = res.data.total
  485. this.listLoading = false
  486. })
  487. },
  488. // 提交筛选表单
  489. submitScreenForm() {
  490. this.currentPage = 1
  491. this.getList()
  492. },
  493. // 重置筛选表单
  494. resetScreenForm() {
  495. this.$refs.screenForm.resetFields()
  496. this.currentPage = 1
  497. this.getList()
  498. },
  499. // 更改每页数量
  500. handleSizeChange(val) {
  501. this.pageSize = val
  502. this.currentPage = 1
  503. this.getList()
  504. },
  505. // 更改当前页
  506. handleCurrentChange(val) {
  507. this.currentPage = val
  508. this.getList()
  509. },
  510. // 去开通账号
  511. toCreate() {
  512. this.$router.push({
  513. path: '/merchant/create_account',
  514. query: {}
  515. })
  516. },
  517. toAccountList() {
  518. this.$router.push({
  519. path: '/setting/account',
  520. query: {
  521. type: 1
  522. }
  523. })
  524. },
  525. async toDetail(id) {
  526. getDetail({ adminUserId: id }).then(res => {
  527. this.mainForm.account = res.data.userName
  528. this.mainForm.nickName = res.data.nickName
  529. this.mainForm.chargePerson = res.data.linkName
  530. this.mainForm.phone = res.data.linkPhone
  531. this.mainForm.kingdeeId = res.data.useOrgNumber
  532. this.mainForm.kingdeeName = res.data.useOrgName
  533. this.mainForm.email = res.data.email
  534. this.mainForm.address = res.data.address
  535. this.mainForm.password = '************'
  536. this.detailDiaLog = true
  537. })
  538. },
  539. // 操作 - 更改状态(type: 禁用0,启用1)
  540. changeStatus(id, type) {
  541. type = type ? true : false
  542. changeAccountStatus({ adminUserId: id, status: type }).then(res => {
  543. this.getList()
  544. this.$successMsg()
  545. })
  546. },
  547. // 导出
  548. handleExport() {
  549. let screenData = {
  550. userName: this.screenForm.account,
  551. nickName: this.screenForm.nickName,
  552. linkPhone: this.screenForm.phone,
  553. email: this.screenForm.email,
  554. status: this.screenForm.status
  555. }
  556. downloadFiles('admin/user/mch/export', screenData)
  557. }
  558. }
  559. }
  560. </script>
  561. <style lang="scss" scoped>
  562. .formWidth {
  563. width: 70%;
  564. margin-right: 20px;
  565. }
  566. </style>