create_account.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <div class="app-container">
  3. <div v-show="step == 1">
  4. <div class="setting_title">开通账号</div>
  5. <el-divider></el-divider>
  6. <div class="tips">
  7. 说明:开通商户账号是指开通商城后台管理系统的总登录账号。
  8. </div>
  9. <el-card shadow="never" class="my-card">
  10. <el-form
  11. class="my-form"
  12. ref="mainForm"
  13. :model="mainForm"
  14. :rules="mainFormRules"
  15. label-width="120px"
  16. label-position="right"
  17. >
  18. <el-form-item label="商户账号" prop="account">
  19. <el-input
  20. v-model="mainForm.account"
  21. autocomplete="off"
  22. placeholder="请输入商户账号"
  23. ></el-input>
  24. <el-popover
  25. class="question"
  26. placement="right-start"
  27. title="账号设置"
  28. width="260"
  29. trigger="hover"
  30. content="账号设置需按数字、字母组合设置至少12位账号"
  31. >
  32. <svg-icon icon-class="question" slot="reference" />
  33. </el-popover>
  34. </el-form-item>
  35. <el-form-item label="账户昵称" prop="nickName">
  36. <el-input
  37. v-model="mainForm.nickName"
  38. autocomplete="off"
  39. placeholder="请输入账户昵称"
  40. ></el-input>
  41. </el-form-item>
  42. <el-form-item label="负责人" prop="chargePerson">
  43. <el-input
  44. v-model="mainForm.chargePerson"
  45. autocomplete="off"
  46. placeholder="请输入负责人"
  47. ></el-input>
  48. </el-form-item>
  49. <el-form-item label="联系电话" prop="phone">
  50. <el-input
  51. v-model="mainForm.phone"
  52. autocomplete="off"
  53. placeholder="请输入联系电话"
  54. ></el-input>
  55. </el-form-item>
  56. <el-form-item label="金蝶主体账号" prop="kingdeeId">
  57. <el-input
  58. v-model="mainForm.kingdeeId"
  59. autocomplete="off"
  60. placeholder="请输入金蝶主体账号"
  61. ></el-input>
  62. </el-form-item>
  63. <el-form-item label="金蝶主体名称" prop="kingdeeName">
  64. <el-input
  65. v-model="mainForm.kingdeeName"
  66. autocomplete="off"
  67. placeholder="请输入金蝶主体名称"
  68. ></el-input>
  69. </el-form-item>
  70. <el-form-item label="电子邮箱" prop="email">
  71. <el-input
  72. v-model="mainForm.email"
  73. autocomplete="off"
  74. placeholder="请输入电子邮箱"
  75. ></el-input>
  76. </el-form-item>
  77. <el-form-item label="地址" prop="address">
  78. <el-input
  79. v-model="mainForm.address"
  80. placeholder="请输入地址"
  81. ></el-input>
  82. </el-form-item>
  83. <el-form-item label="登录密码" prop="newPassword">
  84. <el-input
  85. v-model="mainForm.newPassword"
  86. ref="password1"
  87. auto-complete="new-password"
  88. placeholder="请输入登录密码"
  89. :type="passwordType1"
  90. ></el-input>
  91. <span class="show-pwd" @click="showPwd(1)">
  92. <svg-icon
  93. :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'"
  94. />
  95. </span>
  96. <el-popover
  97. class="question"
  98. placement="right-start"
  99. title="密码设置"
  100. width="260"
  101. trigger="hover"
  102. content="密码设置需按数字、字母组合设置至少12位密码"
  103. >
  104. <svg-icon icon-class="question" slot="reference" />
  105. </el-popover>
  106. </el-form-item>
  107. <el-form-item label="确认密码" prop="confirmPassword">
  108. <el-input
  109. v-model="mainForm.confirmPassword"
  110. ref="password2"
  111. auto-complete="confirm-password"
  112. placeholder="请再次输入密码"
  113. :type="passwordType2"
  114. ></el-input>
  115. <span class="show-pwd" @click="showPwd(2)">
  116. <svg-icon
  117. :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'"
  118. />
  119. </span>
  120. <el-popover
  121. class="question"
  122. placement="right-start"
  123. title="密码设置"
  124. width="260"
  125. trigger="hover"
  126. content="确认密码需要和登录密码保持一致"
  127. >
  128. <svg-icon icon-class="question" slot="reference" />
  129. </el-popover>
  130. </el-form-item>
  131. </el-form>
  132. </el-card>
  133. </div>
  134. <div class="page-footer">
  135. <div class="footer" :class="classObj">
  136. <el-button
  137. type="primary"
  138. @click="clickSubmitForm"
  139. :loading="formLoading"
  140. >{{ formLoading ? "提交中 ..." : "提 交" }}</el-button
  141. >
  142. <el-popconfirm
  143. title="确定关闭吗?"
  144. @onConfirm="goBack"
  145. style="margin-left: 10px"
  146. >
  147. <el-button slot="reference">关 闭</el-button>
  148. </el-popconfirm>
  149. </div>
  150. </div>
  151. </div>
  152. </template>
  153. <script>
  154. import { getToken } from "@/utils/auth";
  155. import { addAccount } from "@/api/merchant";
  156. export default {
  157. data() {
  158. var validateAccount = (rule, value, callback) => {
  159. if (value === "") {
  160. callback(new Error("请输入商户账号"));
  161. } else if (value.length < 12) {
  162. callback(new Error("账号长度至少12位"));
  163. } else if (/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/.test(value) == false) {
  164. callback(new Error("账号必须包含数字和字母"));
  165. } else {
  166. callback();
  167. }
  168. };
  169. var validatePass3 = (rule, value, callback) => {
  170. if (value === "") {
  171. callback(new Error("请输入登录密码"));
  172. } else if (value.length < 12) {
  173. callback(new Error("密码长度至少12位"));
  174. } else if (/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/.test(value) == false) {
  175. callback(new Error("密码必须包含数字和字母"));
  176. } else {
  177. if (this.mainForm.confirmPassword !== "") {
  178. this.$refs.mainForm.validateField("confirmPassword");
  179. }
  180. callback();
  181. }
  182. };
  183. var validatePass4 = (rule, value, callback) => {
  184. if (value === "") {
  185. callback(new Error("请再次输入密码"));
  186. } else if (value !== this.mainForm.newPassword) {
  187. callback(new Error("两次输入密码不一致"));
  188. } else {
  189. callback();
  190. }
  191. };
  192. return {
  193. baseURL: process.env.VUE_APP_BASE_API,
  194. myHeaders: { "x-token": getToken() },
  195. step: 1,
  196. mainForm: {
  197. account: "", // 账号
  198. nickName: "", // 用户名
  199. appName: "", // 小程序名称
  200. chargePerson: "", // 负责人
  201. phone: "", // 联系电话
  202. kingdeeId: "",
  203. kingdeeName: "",
  204. email: "", // 电子邮箱
  205. address: "", // 地址
  206. newPassword: "", // 登录密码
  207. confirmPassword: "", // 确认密码
  208. },
  209. mainFormRules: {
  210. account: [
  211. { required: true, validator: validateAccount, trigger: "blur" },
  212. ],
  213. nickName: [
  214. { required: true, message: "请输入用户名", trigger: "blur" },
  215. ],
  216. appName: [{ required: true, message: "请输入用户名", trigger: "blur" }],
  217. chargePerson: [
  218. { required: true, message: "请输入负责人", trigger: "blur" },
  219. ],
  220. phone: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
  221. kingdeeId: [
  222. { required: true, message: "请输入金蝶主体账号", trigger: "blur" },
  223. ],
  224. kingdeeName: [
  225. { required: true, message: "请输入金蝶主体密码", trigger: "blur" },
  226. ],
  227. newPassword: [
  228. { required: true, validator: validatePass3, trigger: "blur" },
  229. ],
  230. confirmPassword: [
  231. { required: true, validator: validatePass4, trigger: "blur" },
  232. ],
  233. },
  234. passwordType1: "password",
  235. passwordType2: "password",
  236. formLoading: false,
  237. };
  238. },
  239. computed: {
  240. sidebar() {
  241. return this.$store.state.app.sidebar;
  242. },
  243. classObj() {
  244. return {
  245. hideSidebar: !this.sidebar.opened,
  246. openSidebar: this.sidebar.opened,
  247. };
  248. },
  249. },
  250. methods: {
  251. goBack() {
  252. this.$router.go(-1);
  253. },
  254. // 显示隐藏密码
  255. showPwd(num) {
  256. if (num == 1) {
  257. if (this.passwordType1 === "password") {
  258. this.passwordType1 = "";
  259. } else {
  260. this.passwordType1 = "password";
  261. }
  262. this.$nextTick(() => {
  263. this.$refs.password1.focus();
  264. });
  265. }
  266. if (num == 2) {
  267. if (this.passwordType2 === "password") {
  268. this.passwordType2 = "";
  269. } else {
  270. this.passwordType2 = "password";
  271. }
  272. this.$nextTick(() => {
  273. this.$refs.password2.focus();
  274. });
  275. }
  276. },
  277. // 点击 提交表单
  278. clickSubmitForm() {
  279. this.$refs.mainForm.validate((valid) => {
  280. if (valid) {
  281. this.submitForm();
  282. }
  283. });
  284. },
  285. // 提交表单
  286. submitForm() {
  287. this.formLoading = true;
  288. let params = {
  289. adminCompanyName: this.mainForm.nickName,
  290. useOrgNumber: this.mainForm.kingdeeId,
  291. useOrgName: this.mainForm.kingdeeName,
  292. adminUser: {
  293. userName: this.mainForm.account,
  294. adminCompanyName: this.mainForm.nickName,
  295. linkName: this.mainForm.chargePerson,
  296. linkPhone: this.mainForm.phone,
  297. email: this.mainForm.email,
  298. address: this.mainForm.address,
  299. password: this.mainForm.confirmPassword,
  300. },
  301. };
  302. addAccount(params)
  303. .then((res) => {
  304. this.$successMsg("开通成功");
  305. setTimeout(() => {
  306. this.$router.push({
  307. path: "/merchant/merchant_list",
  308. query: {},
  309. });
  310. }, 1500);
  311. })
  312. .finally((res) => {
  313. this.formLoading = false;
  314. });
  315. },
  316. },
  317. };
  318. </script>
  319. <style lang="scss" scoped>
  320. .setting_title {
  321. padding-left: 0;
  322. }
  323. .tips {
  324. font-size: 14px;
  325. }
  326. .my-card {
  327. margin-top: 20px;
  328. .box {
  329. background: rgb(235, 240, 249);
  330. padding: 10px;
  331. font-size: 14px;
  332. margin: 20px 0;
  333. line-height: 18px;
  334. ::v-deep .el-link {
  335. vertical-align: unset;
  336. }
  337. }
  338. }
  339. .my-form {
  340. width: 450px;
  341. margin: 0 auto;
  342. }
  343. .show-pwd {
  344. position: absolute;
  345. right: 15px;
  346. top: 0;
  347. font-size: 16px;
  348. cursor: pointer;
  349. user-select: none;
  350. }
  351. .question {
  352. position: absolute;
  353. right: -30px;
  354. top: 0;
  355. font-size: 20px;
  356. cursor: pointer;
  357. user-select: none;
  358. }
  359. </style>