merchant_list.vue 17 KB

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