UserInfoAiEdit.vue 5.0 KB

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