edit.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <div class="club-device page">
  3. <div class="page-top"></div>
  4. <div class="page-content">
  5. <div class="page-title">设备认证</div>
  6. <FormClubDevice
  7. ref="formClubDevice"
  8. :formType="formType"
  9. @step="onClubDeviceFormStep"
  10. />
  11. <div class="control flex flex-col items-center">
  12. <div
  13. class="button submit flex justify-center items-center"
  14. @click="onSubmit"
  15. >
  16. 提交
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import FormClubDevice from '../../form/components/form-club-device.vue'
  24. import { mapGetters } from 'vuex'
  25. export default {
  26. layout: 'app-normal',
  27. components: {
  28. FormClubDevice,
  29. },
  30. data() {
  31. return {
  32. productInfo: {},
  33. formData: {},
  34. productId: 0,
  35. relationId: '',
  36. formType: '',
  37. }
  38. },
  39. computed: {
  40. ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix', 'authId']),
  41. },
  42. mounted() {
  43. this.formType = this.$route.query.type
  44. this.getProductDetails()
  45. },
  46. methods: {
  47. async onSubmit() {
  48. try {
  49. await this.$refs.formClubDevice.validate()
  50. if (this.formType === 'edit') {
  51. this.formData.authId = this.authId
  52. }
  53. await this.$http.api.authProducSave(this.formData)
  54. this.$toast('保存成功')
  55. this.$router.push(
  56. `${this.routePrefix}/record/device/detail?id=${this.productId}`
  57. )
  58. } catch (error) {
  59. console.log(error)
  60. }
  61. },
  62. // 获取认证机构信息
  63. async getProductDetails() {
  64. try {
  65. this.productId = this.$route.query.id
  66. this.relationId = this.$route.query.relationId
  67. const res = await this.$http.api.getProductDetails({
  68. productId: this.productId,
  69. relationId: this.relationId,
  70. })
  71. this.productInfo = res.data
  72. console.log('productInfo', this.productInfo)
  73. this.$refs.formClubDevice.init(this.productInfo)
  74. } catch (error) {}
  75. },
  76. onClubDeviceFormStep(data) {
  77. console.log(data)
  78. this.formData = data[0]
  79. },
  80. },
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. @media screen and (min-width: 768px) {
  85. .page {
  86. background: #fff;
  87. }
  88. .page-top {
  89. height: 360px;
  90. background: url(~/assets/theme-images/normal/pc/banner-record.png);
  91. background-size: auto 360px;
  92. background-position: center;
  93. .logo {
  94. display: block;
  95. width: 120px;
  96. height: 120px;
  97. border-radius: 50%;
  98. background: #fff;
  99. }
  100. .name {
  101. font-size: 30px;
  102. color: #fff;
  103. }
  104. }
  105. .page-content {
  106. width: 700px;
  107. margin: 0 auto;
  108. overflow: hidden;
  109. min-height: calc(100vh - 80px - 80px - 360px);
  110. box-sizing: border-box;
  111. padding-bottom: 40px;
  112. .page-title {
  113. font-size: 24px;
  114. font-weight: bold;
  115. text-align: center;
  116. padding: 40px 0;
  117. }
  118. .el-select {
  119. width: 100%;
  120. }
  121. .control {
  122. margin-top: 62px;
  123. .button {
  124. width: 295px;
  125. height: 50px;
  126. cursor: pointer;
  127. &.submit {
  128. background-color: #bc1724;
  129. color: #fff;
  130. }
  131. }
  132. }
  133. .device-param-list {
  134. position: relative;
  135. .add-param {
  136. position: absolute;
  137. cursor: pointer;
  138. top: -40px;
  139. right: 0;
  140. text-decoration: underline;
  141. font-size: 14px;
  142. color: #bc1724;
  143. }
  144. .param {
  145. position: relative;
  146. .remove {
  147. position: absolute;
  148. right: 0;
  149. top: 0;
  150. width: 20px;
  151. height: 20px;
  152. background: #f94b4b;
  153. border-radius: 2px;
  154. cursor: pointer;
  155. color: #fff;
  156. font-size: 14px;
  157. text-align: center;
  158. line-height: 20px;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. @media screen and (max-width: 768px) {
  165. .page {
  166. background: #fff;
  167. }
  168. .page-top {
  169. height: 46vw;
  170. background: url(~assets/theme-images/normal/pc/banner-record.png);
  171. background-size: auto 46vw;
  172. background-position: center;
  173. .logo {
  174. display: block;
  175. width: 14.8vw;
  176. height: 14.8vw;
  177. border-radius: 50%;
  178. background: #fff;
  179. }
  180. .name {
  181. font-size: 4vw;
  182. color: #fff;
  183. }
  184. }
  185. .page-content {
  186. box-sizing: border-box;
  187. padding: 8vw 7vw;
  188. .page-title {
  189. font-size: 4.2vw;
  190. font-weight: bold;
  191. text-align: center;
  192. color: #282828;
  193. margin-bottom: 4.6vw;
  194. }
  195. .el-select {
  196. width: 100%;
  197. }
  198. .control {
  199. .button {
  200. width: 100%;
  201. height: 12vw;
  202. cursor: pointer;
  203. &.submit {
  204. background-color: #bc1724;
  205. color: #fff;
  206. }
  207. }
  208. }
  209. .device-param-list {
  210. position: relative;
  211. .add-param {
  212. position: absolute;
  213. cursor: pointer;
  214. top: -40px;
  215. right: 0;
  216. font-size: 3.4vw;
  217. color: #bc1724;
  218. }
  219. .param {
  220. position: relative;
  221. .remove {
  222. position: absolute;
  223. right: 0;
  224. top: 0;
  225. width: 4.4vw;
  226. height: 4.4vw;
  227. background: #f94b4b;
  228. border-radius: 0.2vw;
  229. cursor: pointer;
  230. color: #fff;
  231. font-size: 3.4vw;
  232. text-align: center;
  233. line-height: 4.4vw;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. </style>