active.vue 6.0 KB

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