add.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <zz-form :cols="formCols" :data="formData" :rules="formRules" labelWidth="90" ref="form">
  3. <template slot="companyOrgId">
  4. <select-tree
  5. class="new-select-tree"
  6. selectTreeTitle="请选择公司"
  7. placeholder="请选择公司"
  8. :options="params.companyArray"
  9. :props="defaultProps"
  10. v-model="formData.companyOrgId"
  11. @selectedLable="selectedLable"
  12. />
  13. </template>
  14. <template slot="payeeType">
  15. <el-select class="width65" v-model="formData.payeeType" clearable>
  16. <el-option label="微信" :value="1"></el-option>
  17. <el-option label="支付宝" :value="2"></el-option>
  18. </el-select>
  19. </template>
  20. <template slot="authFile">
  21. <el-input v-model="formData.authFile" disabled placeholder="请上传授权文件">
  22. <i slot="suffix" class="zoniot_font zoniot-icon-shangchuan1" @click="QueryClick"></i>
  23. </el-input>
  24. <el-upload
  25. style="display: none"
  26. :headers="token"
  27. ref="uploaduserlogo"
  28. limit="1"
  29. action="/sc-charge/payee/account/uploadFile"
  30. :on-success="uploadsuccess"
  31. :before-upload="beforeAvatarUpload"
  32. :auto-upload="true"
  33. name="file"
  34. >
  35. </el-upload>
  36. </template>
  37. </zz-form>
  38. </template>
  39. <script >
  40. export default {
  41. props: ['params'],
  42. data() {
  43. return {
  44. formData: {
  45. companyName: '',
  46. companyOrgId: '',
  47. payeeType: '',
  48. merchantNumber: '',
  49. paymentSecretKey: '',
  50. appId: '',
  51. appSecretKey: '',
  52. officialAccountsId: '',
  53. messageId: '',
  54. authFile: ''
  55. },
  56. formRules: {
  57. companyOrgId: [this.$valid.selectRequired('公司')],
  58. payeeType: [this.$valid.selectRequired('充值方式')],
  59. merchantNumber: [this.$valid.inputRequired('商户号')],
  60. paymentSecretKey: [this.$valid.inputRequired('支付密钥')],
  61. appId: [this.$valid.inputRequired('应用ID')],
  62. appSecretKey: [this.$valid.inputRequired('应用密钥')],
  63. authFile: [this.$valid.inputRequired('授权文件')]
  64. },
  65. formCols: [
  66. [
  67. {
  68. label: '公司',
  69. prop: 'companyOrgId',
  70. slot: 'companyOrgId'
  71. },
  72. {
  73. label: '类型',
  74. prop: 'payeeType',
  75. slot: 'payeeType'
  76. },
  77. {
  78. label: '商户号',
  79. prop: 'merchantNumber',
  80. input: true
  81. },
  82. {
  83. label: '支付密钥',
  84. prop: 'paymentSecretKey',
  85. input: true
  86. },
  87. {
  88. label: '应用ID',
  89. prop: 'appId',
  90. input: true
  91. },
  92. {
  93. label: '应用密钥',
  94. prop: 'appSecretKey',
  95. input: true
  96. },
  97. {
  98. label: '公众号ID',
  99. prop: 'officialAccountsId',
  100. input: true
  101. },
  102. {
  103. label: '消息模板ID',
  104. prop: 'messageId',
  105. input: true
  106. },
  107. {
  108. label: '授权文件',
  109. prop: 'authFile',
  110. slot: 'authFile'
  111. }
  112. ]
  113. ],
  114. token: {
  115. [localStorage.getItem('SC_token') && 'Authorization']: 'Bearer ' + localStorage.getItem('SC_token')
  116. },
  117. defaultProps: {
  118. value: 'id', // 唯一标识
  119. label: 'orgName', // 标签显示
  120. children: 'orgs' // 子级
  121. }
  122. };
  123. },
  124. methods: {
  125. selectedLable(e) {
  126. this.formData.companyName = e;
  127. },
  128. QueryClick() {
  129. this.$refs['uploaduserlogo'].$refs['upload-inner'].handleClick();
  130. },
  131. submit() {
  132. new Promise((resolve) => {
  133. this.$refs.form.validate(resolve);
  134. }).then(() => {
  135. var loading = this.$loading();
  136. let url = '/sc-charge/payee/account/add';
  137. if (this.params.todo == 'edit') {
  138. url = '/sc-charge/payee/account/update';
  139. }
  140. this.$http
  141. .post(url, this.formData)
  142. .then(({ status, msg }) => {
  143. if (status == 0) {
  144. this.$message.success(msg);
  145. this.params.callback();
  146. this.$emit('close');
  147. } else {
  148. this.$message.error(msg);
  149. }
  150. loading.close();
  151. })
  152. .catch(() => {
  153. loading.close();
  154. });
  155. });
  156. },
  157. uploadsuccess(response, file, fileList) {
  158. this.$refs.uploaduserlogo.clearFiles();
  159. if (0 === response.status) {
  160. this.formData.authFile = response.data;
  161. }
  162. },
  163. beforeAvatarUpload(file) {
  164. // const isJPG = file.type === 'image/jpeg';
  165. // const isLt2M = file.size / 1024 / 1024 < 2;
  166. // if (!isLt2M) {
  167. // this.$message.error('上传头像图片大小不能超过 2MB!');
  168. // }
  169. // return isJPG && isLt2M;
  170. }
  171. },
  172. created() {
  173. if (this.params.todo == 'edit') {
  174. this.formData = JSON.parse(JSON.stringify(this.params.data));
  175. }
  176. }
  177. };
  178. </script>