active.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="container main">
  3. <view class="one">
  4. <uni-forms ref="baseForm" :rules="rules" :modelValue="form" label-width="80px">
  5. <uni-forms-item label="姓名" required name="name">
  6. <uni-easyinput v-model="form.name" placeholder="请输入姓名" />
  7. </uni-forms-item>
  8. <uni-forms-item label="手机号" required name="phone">
  9. <uni-easyinput v-model="form.phone" placeholder="请输入手机号" />
  10. </uni-forms-item>
  11. <uni-forms-item label="报名类型" required name="type">
  12. <uni-data-checkbox v-model="form.type" :localdata="signList" :map="{text:'label',value:'value'}" />
  13. </uni-forms-item>
  14. <uni-forms-item label="公司名称" required name="company">
  15. <uni-easyinput v-model="form.company" placeholder="请输入公司名称" />
  16. </uni-forms-item>
  17. <uni-forms-item label="路演名称" required name="project_name" v-if="form.type=='1'">
  18. <uni-easyinput v-model="form.project_name" placeholder="请输入路演名称" />
  19. </uni-forms-item>
  20. <uni-forms-item label="路演简介" required name="project_brief" v-if="form.type=='1'">
  21. <uni-easyinput v-model="form.project_brief" placeholder="请输入路演简介" />
  22. </uni-forms-item>
  23. <uni-forms-item label="路演附件" required name="project_file" v-if="form.type=='1'">
  24. <upload class='upload' :list="form.project_file" name="project_file" :count="1" @uplSuc="uplSuc"
  25. @uplDel="uplDel">
  26. </upload>
  27. </uni-forms-item>
  28. </uni-forms>
  29. <view class="button">
  30. <view class="button_remark">*修改报名信息将会重新进行审核</view>
  31. <button type="primary" @click="submit('baseForm')">保存</button>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import upload from '../../components/upload/index.vue';
  38. import moment from 'moment';
  39. export default {
  40. components: {
  41. upload
  42. },
  43. data() {
  44. return {
  45. id: "",
  46. user: {},
  47. form: {
  48. name: "",
  49. type: "",
  50. company: "",
  51. phone: "",
  52. project_name: "",
  53. project_brief: "",
  54. project_file: [],
  55. },
  56. typeList: [],
  57. signList: [],
  58. // 校验规则
  59. rules: {
  60. name: {
  61. rules: [{
  62. required: true,
  63. errorMessage: '姓名不能为空'
  64. }]
  65. },
  66. phone: {
  67. rules: [{
  68. required: true,
  69. errorMessage: '联系方式不能为空'
  70. }]
  71. },
  72. },
  73. }
  74. },
  75. onLoad: async function(e) {
  76. const that = this;
  77. that.$set(that, `id`, e && e.id || '');
  78. await that.searchToken();
  79. await that.searchOther();
  80. await that.search();
  81. },
  82. methods: {
  83. // 用户信息
  84. searchToken() {
  85. const that = this;
  86. try {
  87. const res = uni.getStorageSync('token');
  88. if (res) {
  89. const user = that.$jwt(res);
  90. that.$set(that, `user`, user);
  91. }
  92. } catch (e) {}
  93. },
  94. async searchOther() {
  95. const that = this;
  96. let res;
  97. // 查询证件类型
  98. res = await that.$api(`/dictData`, 'GET', {
  99. code: 'cardType',
  100. is_use: '0',
  101. })
  102. if (res.errcode == '0') that.$set(that, `typeList`, res.data);
  103. // 查询证件类型
  104. res = await that.$api(`/dictData`, 'GET', {
  105. code: 'signType',
  106. is_use: '0',
  107. })
  108. if (res.errcode == '0') that.$set(that, `signList`, res.data);
  109. },
  110. // 查询
  111. async search() {
  112. const that = this;
  113. if (that.id) {
  114. let res;
  115. res = await that.$api(`/sign/${that.id}`, 'GET', {})
  116. if (res.errcode == '0') {
  117. that.$set(that, `form`, res.data)
  118. } else {
  119. uni.showToast({
  120. title: res.errmsg,
  121. });
  122. }
  123. }
  124. },
  125. // 图片上传
  126. uplSuc(e) {
  127. const that = this;
  128. that.$set(that.form, `${e.name}`, [...that.form[e.name], e.data]);
  129. },
  130. // 图片删除
  131. uplDel(e) {
  132. const that = this;
  133. let data = that.form[e.name];
  134. let arr = data.filter((i, index) => index != e.data.index);
  135. that.$set(that.form, `${e.name}`, arr)
  136. },
  137. // 保存
  138. submit(ref) {
  139. const that = this;
  140. that.$refs[ref].validate().then(async res => {
  141. let arr;
  142. const data = {
  143. id: that.id,
  144. project_file: that.form.project_file,
  145. time: moment().format('YYYY-MM-DD HH:mm:ss'),
  146. status: '0'
  147. }
  148. if (res.type == '1') {
  149. delete res.project_name
  150. delete res.project_brief
  151. delete res.project_file
  152. }
  153. arr = await that.$api(`/sign/${that.id}`, 'POST', {
  154. ...res,
  155. ...data
  156. })
  157. if (arr.errcode == '0') {
  158. uni.showModal({
  159. content: "修改报名信息成功!",
  160. showCancel: false
  161. });
  162. uni.navigateBack({
  163. delta: 1
  164. })
  165. } else {
  166. uni.showToast({
  167. title: arr.errmsg,
  168. });
  169. }
  170. }).catch(err => {
  171. console.log('err', err);
  172. })
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .main {
  179. padding: 0 3vw;
  180. .one {
  181. .button_remark {
  182. margin: 2vw 0;
  183. text-indent: 10px;
  184. color: var(--fF0Color);
  185. font-size: var(--font12Size);
  186. }
  187. .button {
  188. margin: 2vw 0 0 0;
  189. button {
  190. background-color: var(--f3CColor);
  191. font-size: var(--font14Size);
  192. border-radius: 2vw;
  193. }
  194. }
  195. }
  196. }
  197. </style>