UserInfoAiEdit.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <!-- 用户信息的新增/编辑 -->
  2. <template>
  3. <s-layout :title="state.model.id ? '编辑地址' : '新增用户信息'">
  4. <uni-forms
  5. ref="userinfoaiFormRef"
  6. v-model="state.model"
  7. :labelStyle="{ fontWeight: 'bold' }"
  8. :rules="rules"
  9. border
  10. labelAlign="left"
  11. labelWidth="160"
  12. validateTrigger="bind"
  13. >
  14. <view class="bg-white form-box ss-p-x-30">
  15. <uni-forms-item class="form-item" label="用户编号" name="userId">
  16. <uni-easyinput
  17. v-model="state.model.userId"
  18. :inputBorder="false"
  19. placeholder="请填写用户编号"
  20. placeholderStyle="color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"
  21. />
  22. </uni-forms-item>
  23. <uni-forms-item
  24. :formItemStyle="{ alignItems: 'flex-start' }"
  25. :labelStyle="{ lineHeight: '5em' }"
  26. class="textarea-item"
  27. label="提取有效信息"
  28. name="textInformation"
  29. >
  30. <uni-easyinput
  31. v-model="state.model.textInformation"
  32. :inputBorder="false"
  33. clearable
  34. placeholder="请输入提取有效信息"
  35. placeholderStyle="color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"
  36. type="textarea"
  37. />
  38. </uni-forms-item>
  39. <uni-forms-item
  40. :formItemStyle="{ alignItems: 'flex-start' }"
  41. :labelStyle="{ lineHeight: '5em' }"
  42. class="textarea-item"
  43. label="补充信息"
  44. name="additionalInfo"
  45. >
  46. <uni-easyinput
  47. v-model="state.model.additionalInfo"
  48. :inputBorder="false"
  49. clearable
  50. placeholder="请输入补充信息"
  51. placeholderStyle="color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"
  52. type="textarea"
  53. />
  54. </uni-forms-item>
  55. </view>
  56. </uni-forms>
  57. <su-fixed :index="10" :noFixed="false" :opacity="false" bg="" bottom placeholder>
  58. <view class="footer-box ss-flex-col ss-row-between ss-p-20">
  59. <view class="ss-m-b-20">
  60. <button class="ss-reset-button save-btn ui-Shadow-Main" @tap="onSave">保存</button>
  61. </view>
  62. <button v-if="state.model.id" class="ss-reset-button cancel-btn" @tap="onDelete">
  63. 删除
  64. </button>
  65. </view>
  66. </su-fixed>
  67. </s-layout>
  68. </template>
  69. <script setup>
  70. import { reactive, ref, unref } from 'vue';
  71. import sheep from '@/sheep';
  72. import { onLoad } from '@dcloudio/uni-app';
  73. import UserInfoAiApi from '@/sheep/api/member/UserInfoAi';
  74. const userinfoaiFormRef = ref(null);
  75. const state = reactive({
  76. showRegion: false,
  77. model: {
  78. name: '',
  79. mobile: '',
  80. detailUserInfoAi: '',
  81. defaultStatus: false,
  82. areaName: '',
  83. },
  84. rules: {},
  85. });
  86. const rules = {
  87. userId: {
  88. rules: [
  89. {
  90. required: true,
  91. errorMessage: '请输入用户编号',
  92. },
  93. ],
  94. },
  95. };
  96. // 保存用户信息
  97. const onSave = async () => {
  98. // 参数校验
  99. const validate = await unref(userinfoaiFormRef)
  100. .validate()
  101. .catch((error) => {
  102. console.log('error: ', error);
  103. });
  104. if (!validate) {
  105. return;
  106. }
  107. // 提交请求
  108. const formData = {
  109. ...state.model,
  110. };
  111. const { code } =
  112. state.model.id > 0
  113. ? await UserInfoAiApi.updateUserInfoAi(formData)
  114. : await UserInfoAiApi.createUserInfoAi(formData);
  115. if (code === 0) {
  116. sheep.$router.back();
  117. }
  118. };
  119. // 删除用户信息
  120. const onDelete = () => {
  121. uni.showModal({
  122. title: '提示',
  123. content: '确认删除此用户信息吗?',
  124. success: async function (res) {
  125. if (!res.confirm) {
  126. return;
  127. }
  128. const { code } = await UserInfoAiApi.deleteUserInfoAi(state.model.id);
  129. if (code === 0) {
  130. sheep.$router.back();
  131. }
  132. },
  133. });
  134. };
  135. onLoad(async (options) => {});
  136. </script>
  137. <style lang="scss" scoped>
  138. :deep() {
  139. .uni-forms-item__label .label-text {
  140. font-size: 28rpx !important;
  141. color: #333333 !important;
  142. line-height: normal !important;
  143. }
  144. .uni-easyinput__content-input {
  145. font-size: 28rpx !important;
  146. color: #333333 !important;
  147. line-height: normal !important;
  148. padding-left: 0 !important;
  149. }
  150. .uni-easyinput__content-textarea {
  151. font-size: 28rpx !important;
  152. color: #333333 !important;
  153. line-height: normal !important;
  154. margin-top: 8rpx !important;
  155. }
  156. .uni-icons {
  157. font-size: 40rpx !important;
  158. }
  159. .is-textarea-icon {
  160. margin-top: 22rpx;
  161. }
  162. .is-disabled {
  163. color: #333333;
  164. }
  165. }
  166. .default-box {
  167. width: 100%;
  168. box-sizing: border-box;
  169. height: 100rpx;
  170. .default-box-title {
  171. font-size: 28rpx;
  172. color: #333333;
  173. line-height: normal;
  174. }
  175. }
  176. .footer-box {
  177. .save-btn {
  178. width: 710rpx;
  179. height: 80rpx;
  180. border-radius: 40rpx;
  181. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  182. color: $white;
  183. }
  184. .cancel-btn {
  185. width: 710rpx;
  186. height: 80rpx;
  187. border-radius: 40rpx;
  188. background: var(--ui-BG);
  189. }
  190. }
  191. </style>