merchant_list.vue 18 KB

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