addstudent.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. <template>
  2. <view class="addbox">
  3. <uni-forms ref="form" :rules="rules" :modelValue="datainfo">
  4. <!-- 家长 -->
  5. <view class="ftit">基本信息</view>
  6. <view class="fbox">
  7. <!-- 选择学生 -->
  8. <picker range-key="dictLabel" v-if="roles!='parents'&&pagetype=='add'" :range="classlist" :value="classidx" @change="bindDateChangee">
  9. <uni-forms-item name="className" label="班级">
  10. <view class="f15 flex1 txr co16" v-if="datainfo.className" >{{datainfo.className}}</view>
  11. <view class="f15 flex1 txr coa" v-else >请选择班级</view>
  12. <image :src="rimg" class="ilrmgr"></image>
  13. </uni-forms-item>
  14. </picker>
  15. <picker range-key="dictLabel" :disabled="pagetype=='update'||!stuflag" :range="studentlist" :value="nameidx" @change="bindDateChangef">
  16. <uni-forms-item name="name" :disabled="pagetype=='update'||!stuflag" required label="姓名">
  17. <view class="f15 flex1 txr co16" v-if="datainfo.name" >{{datainfo.name}}</view>
  18. <view class="f15 flex1 txr coa" v-else >请选择姓名</view>
  19. <image :src="rimg" class="ilrmgr"></image>
  20. </uni-forms-item>
  21. </picker>
  22. <uni-forms-item label="身份证号" name="idCard">
  23. <uni-easyinput :inputBorder="false" v-model="datainfo.idCard" @blur="getIdcardInfo" placeholder="请输入身份证号">
  24. </uni-easyinput>
  25. </uni-forms-item>
  26. <!-- <uni-forms-item label="姓名" required name="name">
  27. <uni-easyinput :inputBorder="false" v-model="datainfo.name" placeholder="请输入姓名">
  28. </uni-easyinput>
  29. </uni-forms-item> -->
  30. <picker range-key="text" :range="sexrange" :value="sexidx" @change="bindDateChange">
  31. <uni-forms-item name="sex" required label="性别">
  32. <view class="f15 flex1 txr co16" v-if="datainfo.sex" >{{datainfo.sex==1?'男':'女'}}</view>
  33. <view class="f15 flex1 txr coa" v-else >请选择性别</view>
  34. <image :src="rimg" class="ilrmgr"></image>
  35. </uni-forms-item>
  36. </picker>
  37. <uni-forms-item label="年龄" name="age">
  38. <uni-easyinput :inputBorder="false" v-model="datainfo.age" placeholder="请输入年龄">
  39. </uni-easyinput>
  40. </uni-forms-item>
  41. <uni-forms-item label="民族" name="familyName">
  42. <uni-easyinput :inputBorder="false" v-model="datainfo.familyName" placeholder="请输入民族">
  43. </uni-easyinput>
  44. </uni-forms-item>
  45. <picker range-key="dictLabel" :range="outlook" :value="lookidx" @change="bindDateChangea">
  46. <uni-forms-item name="politicalStatus" label="政治面貌">
  47. <view class="f15 flex1 txr" :class="datainfo.politicalStatus?'co16':'coa'">{{datainfo.politicalStatus||'请选择政治面貌'}}</view>
  48. <image :src="rimg" class="ilrmgr"></image>
  49. </uni-forms-item>
  50. </picker>
  51. <picker range-key="dictLabel" :range="schoolval" :value="schoolidx" @change="bindDateChangeb">
  52. <uni-forms-item name="school" label="学校">
  53. <view class="f15 flex1 txr" :class="datainfo.school?'co16':'coa'">{{datainfo.school||'请选择学校名称'}}</view>
  54. </uni-forms-item>
  55. </picker>
  56. <uni-forms-item label="学号" name="studentNumber">
  57. <uni-easyinput :inputBorder="false" v-model="datainfo.studentNumber" placeholder="请输入学号">
  58. </uni-easyinput>
  59. </uni-forms-item>
  60. </view>
  61. <view class="ftit">照片信息</view>
  62. <view class="fbox">
  63. <uni-forms-item label="证件照" name="identificationPhoto">
  64. <view class="flex1"></view>
  65. <view class="imgs">
  66. <view class="photos" v-for="(item,index) in zjfile" :key='index' @click="getPreview(zjfile,index)">
  67. <image :src="baseUrl+item" class="addimg"></image>
  68. <image :src="delimg" class="del" @click.stop="delimgFn('zj',index)" ></image>
  69. </view>
  70. <image :src="addimg" class="photos" v-if="zjfile.length<9" @click.stop="getphotoFn('zj')"></image>
  71. </view>
  72. </uni-forms-item>
  73. <uni-forms-item label="门禁照" name="entrancePermit">
  74. <view class="flex1"></view>
  75. <view class="imgs">
  76. <view class="photos" v-for="(item,index) in mjfile" :key='index' @click="getPreview(mjfile,index)">
  77. <image :src="baseUrl+item" class="addimg"></image>
  78. <image :src="delimg" class="del" @click.stop="delimgFn('mj',index)" ></image>
  79. </view>
  80. <image :src="addimg" class="photos" v-if="mjfile.length<9" @click.stop="getphotoFn('mj')"></image>
  81. </view>
  82. </uni-forms-item>
  83. </view>
  84. <view class="ftit">其他信息</view>
  85. <view class="fbox">
  86. <uni-forms-item label="身高" name="height">
  87. <uni-easyinput :inputBorder="false" :disabled="pagetype=='update'" v-model="datainfo.height" placeholder="请输入身高">
  88. </uni-easyinput>
  89. <view class="f16 co16 ml6">cm</view>
  90. </uni-forms-item>
  91. <uni-forms-item label="体重" name="weight">
  92. <uni-easyinput :inputBorder="false" :disabled="pagetype=='update'" v-model="datainfo.weight" placeholder="请输入体重">
  93. </uni-easyinput>
  94. <view class="f16 co16 ml6">kg</view>
  95. </uni-forms-item>
  96. <!-- <uni-forms-item label="血型" name="bloodType">
  97. <uni-easyinput :inputBorder="false" v-model="datainfo.bloodType" placeholder="请输入血型">
  98. </uni-easyinput>
  99. </uni-forms-item> -->
  100. <picker range-key="dictLabel" :range="bloodrange" :value="bloodidx" @change="bindDateChangeg">
  101. <uni-forms-item name="bloodType" label="血型">
  102. <view class="f15 flex1 txr" :class="datainfo.bloodType?'co16':'coa'">{{datainfo.bloodType||'请选择血型'}}</view>
  103. <image :src="rimg" class="ilrmgr"></image>
  104. </uni-forms-item>
  105. </picker>
  106. </view>
  107. <view class="ftit">视力信息</view>
  108. <view class="fbox">
  109. <uni-forms-item label="是否近视" name="isNearsightedness">
  110. <uni-data-checkbox v-model="datainfo.isNearsightedness" :localdata="isjinshi"></uni-data-checkbox>
  111. </uni-forms-item>
  112. <uni-forms-item label="近视度数" name="degreeMyopia">
  113. <uni-easyinput :inputBorder="false" v-model="datainfo.degreeMyopia" placeholder="请输入度数,例:左300 右200">
  114. </uni-easyinput>
  115. </uni-forms-item>
  116. <uni-forms-item label="是否远视" name="isFarsightedness">
  117. <uni-data-checkbox v-model="datainfo.isFarsightedness" :localdata="isjinshi"></uni-data-checkbox>
  118. </uni-forms-item>
  119. <uni-forms-item label="远视度数" name="farsightedness">
  120. <uni-easyinput :inputBorder="false" v-model="datainfo.farsightedness" placeholder="请输入度数,例:左300 右200">
  121. </uni-easyinput>
  122. </uni-forms-item>
  123. </view>
  124. <view class="ftit">健康信息</view>
  125. <view class="fbox">
  126. <picker range-key="dictLabel" :range="healthrange" :value="healthidx" @change="bindDateChangec">
  127. <uni-forms-item name="health" label="健康状态">
  128. <view class="f15 flex1 txr co16" v-if="datainfo.health" >{{datainfo.health}}</view>
  129. <view class="f15 flex1 txr coa" v-else >请选择健康状态</view>
  130. <image :src="rimg" class="ilrmgr"></image>
  131. </uni-forms-item>
  132. </picker>
  133. <uni-forms-item label="有无过往病史" name="isMedicalHistory">
  134. <uni-data-checkbox v-model="datainfo.isMedicalHistory" :localdata="ynrange"></uni-data-checkbox>
  135. </uni-forms-item>
  136. <uni-forms-item label="病史描述" name="medicalDescription">
  137. <view class="comboxl">
  138. <textarea placeholder="请输入病史描述详情" v-model="datainfo.medicalDescription" placeholder-style="color:#aaa;" :auto-height="autoHeight" ></textarea>
  139. </view>
  140. </uni-forms-item>
  141. <picker range-key="dictLabel" :disabled="pagetype=='update'" :range="xlhealthrange" :value="mindidx" @change="bindDateChanged">
  142. <uni-forms-item name="mind" label="心理健康状态">
  143. <view :class="pagetype=='update'?'is_disabled':''" class="flexc flex1">
  144. <view class="f15 flex1 txr co16" v-if="datainfo.mind" >{{datainfo.mind}}</view>
  145. <view class="f15 flex1 txr coa" :class="pagetype=='update'?'is_disabled':''" v-else >请选择心理健康状态</view>
  146. <image :src="rimg" class="ilrmgr"></image>
  147. </view>
  148. </uni-forms-item>
  149. </picker>
  150. <!-- <uni-forms-item label="心理健康状态" name="health">
  151. <view class="health flexcc">
  152. <view class="flexc pl8 ml2" @click="heaidx=1">
  153. <image :src="mooda" v-if="heaidx==1"></image>
  154. <image :src="moodan" v-else></image>
  155. 愉悦
  156. </view>
  157. <view class="flexc pl8 ml2" @click="heaidx=2">
  158. <image :src="moodb" v-if="heaidx==2"></image>
  159. <image :src="moodbn" v-else></image>
  160. 难过
  161. </view>
  162. <view class="flexc pl8 ml2" @click="heaidx=3">
  163. <image :src="moodc" v-if="heaidx==3"></image>
  164. <image :src="moodcn" v-else></image>
  165. 生病
  166. </view>
  167. </view>
  168. </uni-forms-item> -->
  169. <uni-forms-item label="心理健康描述" name="psychologicalDescription">
  170. <view class="comboxl" :class="pagetype=='update'?'is_disabled':''">
  171. <textarea placeholder="请输入心理健康描述详情" placeholder-style="color:#aaa;" :disabled="pagetype=='update'" v-model="datainfo.psychologicalDescription" :auto-height="autoHeight" ></textarea>
  172. </view>
  173. </uni-forms-item>
  174. </view>
  175. <view class="ftit">家庭信息</view>
  176. <view class="fbox">
  177. <uni-forms-item label="是否贫困" name="isPoverty">
  178. <uni-data-checkbox v-model="datainfo.isPoverty" :localdata="ynrange"></uni-data-checkbox>
  179. </uni-forms-item>
  180. <uni-forms-item label="是否留守儿童" name="isLset">
  181. <uni-data-checkbox v-model="datainfo.isLset" :localdata="ynrange"></uni-data-checkbox>
  182. </uni-forms-item>
  183. <uni-forms-item label="居住地址" name="address" >
  184. <view @click="getMapFn" class="flexc flex1">
  185. <view class="flex1 f15 txr" :class="datainfo.address?'co16':'coa'">{{datainfo.address||'请选择居住地址'}}</view>
  186. <image :src="rimg" class="ilrmgr"></image>
  187. </view>
  188. </uni-forms-item>
  189. <!-- -->
  190. <uni-forms-item label="父亲姓名" name="fatherName">
  191. <uni-easyinput :inputBorder="false" v-model="datainfo.fatherName" placeholder="请输入父亲姓名">
  192. </uni-easyinput>
  193. </uni-forms-item>
  194. <uni-forms-item label="联系方式" name="fatherTelephone">
  195. <uni-easyinput :inputBorder="false" v-model="datainfo.fatherTelephone" placeholder="请输入联系方式">
  196. </uni-easyinput>
  197. </uni-forms-item>
  198. <uni-forms-item label="母亲姓名" name="motherName">
  199. <uni-easyinput :inputBorder="false" v-model="datainfo.motherName" placeholder="请输入母亲姓名">
  200. </uni-easyinput>
  201. </uni-forms-item>
  202. <uni-forms-item label="联系方式" name="motherTelephone">
  203. <uni-easyinput :inputBorder="false" v-model="datainfo.motherTelephone" placeholder="请输入联系方式">
  204. </uni-easyinput>
  205. </uni-forms-item>
  206. <uni-forms-item label="紧急联系人" name="emergencyContact">
  207. <uni-easyinput :inputBorder="false" v-model="datainfo.emergencyContact" placeholder="请输入紧急联系人姓名">
  208. </uni-easyinput>
  209. </uni-forms-item>
  210. <uni-forms-item label="紧急联系方式" name="emergencyContactTelephone">
  211. <uni-easyinput :inputBorder="false" v-model="datainfo.emergencyContactTelephone" placeholder="请输入紧急联系方式">
  212. </uni-easyinput>
  213. </uni-forms-item>
  214. </view>
  215. <view class="fbtns">
  216. <view class="rebtn" @click="getSubmit">确认</view>
  217. </view>
  218. </uni-forms>
  219. </view>
  220. </template>
  221. <script>
  222. // import tabSearch from "@/components/toptab/search.vue"
  223. import config from '@/config'
  224. const baseUrl = config.baseUrl
  225. import {uploadmore,selectDictLabel} from '@/utils/common.js'
  226. import {getDeptList,getselfList} from "@/api/mine/mine.js"
  227. import {getDictionaryFn} from '@/api/mine/register.js'
  228. import {getstuDetFn,getstuAddtFn,getstunoListFn,getstuPutFn} from "@/api/mine/files.js"
  229. export default {
  230. components:{},
  231. data(){
  232. return{
  233. // adddj
  234. addimg:require("@/mine/static/score/addd.png"),
  235. mooda:require("@/mine/static/score/mooda.png"),
  236. moodan:require("@/mine/static/score/moodan.png"),
  237. moodb:require("@/mine/static/score/moodb.png"),
  238. moodbn:require("@/mine/static/score/moodbn.png"),
  239. moodc:require("@/mine/static/score/moodc.png"),
  240. moodcn:require("@/mine/static/score/moodcn.png"),
  241. delimg: require("@/static/images/del.png"),
  242. rimg:require("@/mine/static/score/rimg.png"),
  243. heaidx:1,
  244. date:'',
  245. baseUrl:'',
  246. sexrange:[{"val": 1,"text":"男"},{"val":2,"text":"女"}],// 性别
  247. ynrange:[{"value": 1,"text": "是"},{"value": 2,"text": "否"}],
  248. zjfile:[],
  249. mjfile:[],
  250. autoHeight:true,
  251. bjrange: [{"value": 1,"text": "有" },{"value": 2,"text": "无"}],
  252. rules: {
  253. name: {rules: [{required: true,errorMessage: '请选择姓名'}]},
  254. sex: {rules: [{required: true,errorMessage: '请选择性别'}]},
  255. // subjectClass: {rules: [{required: true,errorMessage: '请选择调课班级'}]},
  256. // subject: {rules: [{required: true,errorMessage: '请选择调课科目'}]},
  257. // beSubject: {rules: [{required: true,errorMessage: '请选择被调科目'}]},
  258. // week: {rules: [{required: true,errorMessage: '请选择时间(星期)'}]},
  259. },
  260. datainfo:{
  261. "studentId":"",//学生id
  262. "name":"",//姓名
  263. "sex":"",//性别(1:男,2:女)
  264. "age":"",//年龄
  265. "familyName":"",//民族
  266. "school":"",//学校(汉字)
  267. "studentNumber":"",//学号
  268. "idCard":"",//身份证号
  269. "height":"",//身高
  270. "weight":"",//体重
  271. "bloodType":"",//血型
  272. "politicalStatus":"",//政治面貌(字典值:political_outlook)
  273. "identificationPhoto":"",//证件照(地址)
  274. "entrancePermit":"",//门禁照(地址)
  275. "fatherName":"",//父亲
  276. "fatherTelephone":"",//父亲联系方式
  277. "motherName":"",//母亲
  278. "motherTelephone":"",//母亲联系方式
  279. "emergencyContact":"",//紧急
  280. "emergencyContactTelephone":"",//紧急联系方式
  281. "address":"",//居住地址
  282. "isNearsightedness":'',//近视,
  283. "psychologicalDescription":'',
  284. "isFarsightedness":'',//远视,
  285. "farsightedness":'',
  286. 'health':'',
  287. "mind":'',
  288. "isMedicalHistory":'',
  289. "medicalDescription":'',
  290. "classId":'',
  291. "className":''
  292. },
  293. pagetype:'add',
  294. stulist:'',
  295. schoolval:[],
  296. outlook:[],
  297. isjinshi:[],
  298. healthrange:[],
  299. xlhealthrange:[],
  300. bloodrange:[],
  301. bloodidx:0,
  302. sexidx:0,
  303. lookidx:0,
  304. schoolidx:0,
  305. healthidx:0,
  306. mindidx:0,
  307. id:'',
  308. address:{},
  309. classlist:[],//班级
  310. roles:'',
  311. classidx:0,
  312. nameidx:0,
  313. studentlist:[],
  314. schoolId:'',
  315. stuflag:true
  316. }
  317. },
  318. onUnload(){
  319. uni.$off('refreshaddr')
  320. },
  321. onLoad: function(e) {
  322. var that=this;
  323. uni.$on('refreshaddr',(e) => {
  324. var addr=JSON.parse(JSON.stringify(e))
  325. this.datainfo.address=e.address
  326. this.datainfo.longitude=e.lng
  327. this.datainfo.latitude=e.lat
  328. })
  329. this.pagetype=e.type||'add';
  330. this.baseUrl=baseUrl;
  331. this.init()
  332. this.getDeptListFn()
  333. if(e.type=='update'){
  334. this.id=e.id
  335. this.getDataFn()
  336. }else{
  337. var roles=this.$store.state.user.choseroles;
  338. this.roles=roles;
  339. if(roles=='parents'){
  340. var newArr=this.$store.state.user.student;
  341. if(newArr&&newArr.length){
  342. if(newArr.length>1){
  343. this.studentlist = newArr.map(v => {
  344. return {
  345. dictLabel:v.studentName,
  346. dictValue: v.id,
  347. classId:v.classId,
  348. className:v.className
  349. }
  350. })
  351. }else{
  352. // 一个娃
  353. this.datainfo.name=newArr[0].studentName
  354. this.datainfo.studentId=newArr[0].id
  355. this.datainfo.classId=newArr[0].classId
  356. this.datainfo.className=newArr[0].className
  357. this.stuflag=false;
  358. }
  359. }
  360. }else if(roles=='teacher'){
  361. var id=this.$store.state.user.schoolId;
  362. this.schoolId=id;
  363. this.getselfList(id)
  364. }else{
  365. this.schoolId=this.$store.state.user.deptId;
  366. this.getselfList(0)
  367. }
  368. }
  369. },
  370. methods:{
  371. getselfList(id){
  372. var params={
  373. parentId:id,
  374. }
  375. params['params[role]']=this.$store.state.user.choseroles
  376. getselfList(params).then(res=>{
  377. if(res.code==200){
  378. var newArr=res.data;
  379. if(newArr&&newArr.length){
  380. this.classlist = newArr.map(v => {
  381. return {
  382. dictLabel: v.deptName,
  383. dictValue: v.deptId,
  384. }
  385. })
  386. }
  387. }else{
  388. this.$toast(res.msg)
  389. }
  390. })
  391. },
  392. getMapFn(){
  393. // #ifdef APP-PLUS
  394. if(this.datainfo.address){
  395. this.$tab.navigateTo('/mine/pages/files/maps?type=update&lng='+this.datainfo.longitude+'&lat='+this.datainfo.latitude+'&address='+this.datainfo.address)
  396. }else{
  397. this.$tab.navigateTo('/mine/pages/files/maps')
  398. }
  399. // #endif
  400. // #ifndef APP-PLUS
  401. if(this.datainfo.address){
  402. this.$tab.navigateTo('/mine/pages/files/map?type=update&lng='+this.datainfo.longitude+'&lat='+this.datainfo.latitude+'&address='+this.datainfo.address)
  403. }else{
  404. this.$tab.navigateTo('/mine/pages/files/map')
  405. }
  406. // #endif
  407. },
  408. getDataFn() {
  409. getstuDetFn(this.id).then(res => {
  410. if (res.code == 200) {
  411. this.datainfo = res.data;
  412. if(res.data.isNearsightedness){
  413. this.datainfo.isNearsightedness=Number(res.data.isNearsightedness)
  414. }
  415. if(res.data.isLset){
  416. this.datainfo.isLset=Number(res.data.isLset)
  417. }
  418. if(res.data.isPoverty){
  419. this.datainfo.isPoverty=Number(res.data.isPoverty)
  420. }
  421. if(res.data.isMedicalHistory){
  422. this.datainfo.isMedicalHistory=Number(res.data.isMedicalHistory)
  423. }
  424. if(res.data.identificationPhoto){
  425. this.zjfile=res.data.identificationPhoto.split(',')
  426. }else{
  427. this.zjfile=[];
  428. }
  429. if(res.data.entrancePermit){
  430. this.mjfile=res.data.entrancePermit.split(',')
  431. }else{
  432. this.mjfile=[];
  433. }
  434. if(res.data.sex){
  435. this.sexidx=res.data.sex==1?0:1
  436. }
  437. // 政治面貌
  438. if(res.data.politicalStatus){
  439. for(var i=0;i<this.outlook.length;i++){
  440. if(this.outlook[i].dictLabel==res.data.politicalStatus){
  441. this.lookidx=Number(i)
  442. break;
  443. }
  444. }
  445. }
  446. if(res.data.school){
  447. for(var i=0;i<this.schoolval.length;i++){
  448. if(this.schoolval[i].dictLabel==res.data.school){
  449. this.schoolidx=Number(i)
  450. break;
  451. }
  452. }
  453. }
  454. if(res.data.health){
  455. for(var i=0;i<this.healthrange.length;i++){
  456. if(this.healthrange[i].dictLabel==res.data.health){
  457. this.healthidx=Number(i)
  458. break;
  459. }
  460. }
  461. }
  462. if(res.data.mind){
  463. for(var i=0;i<this.xlhealthrange.length;i++){
  464. if(this.xlhealthrange[i].dictLabel==res.data.mind){
  465. this.mindidx=Number(i)
  466. break;
  467. }
  468. }
  469. }
  470. } else {
  471. this.$toast(res.msg)
  472. }
  473. })
  474. },
  475. go(idCard) {
  476. let sex = null;
  477. let birth = null;
  478. let myDate = new Date();
  479. let month = myDate.getMonth() + 1;
  480. let day = myDate.getDate();
  481. let age = 0;
  482. if (idCard.length === 18) {
  483. age = myDate.getFullYear() - idCard.substring(6, 10) - 1;
  484. sex = idCard.substring(16, 17);
  485. birth = idCard.substring(6, 10) + "-" + idCard.substring(10, 12) + "-" + idCard.substring(12, 14);
  486. if (idCard.substring(10, 12) < month || idCard.substring(10, 12) === month && idCard.substring(12, 14) <= day)
  487. age++;
  488. }
  489. if (idCard.length === 15) {
  490. age = myDate.getFullYear() - idCard.substring(6, 8) - 1901;
  491. sex = idCard.substring(13, 14);
  492. birth = "19" + idCard.substring(6, 8) + "-" + idCard.substring(8, 10) + "-" + idCard.substring(10, 12);
  493. if (idCard.substring(8, 10) < month || idCard.substring(8, 10) === month && idCard.substring(10, 12) <= day)
  494. age++;
  495. }
  496. if (sex % 2 === 0) sex = '2';
  497. else sex = '1';
  498. this.datainfo.sex = sex
  499. this.datainfo.age = age
  500. return {
  501. age,
  502. sex,
  503. birth
  504. }
  505. },
  506. /* 上传后端获取身份证信息 */
  507. getIdcardInfo(val) {
  508. var idCard=this.datainfo.idCard;
  509. if(!idCard){
  510. return
  511. }
  512. // 身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X
  513. let _IDRe18 =/^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
  514. let _IDre15 = /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
  515. // 校验身份证:
  516. if (_IDRe18.test(idCard) || _IDre15.test(idCard)) {
  517. this.go(idCard)
  518. } else {
  519. }
  520. },
  521. getClassFn(){
  522. var that=this;
  523. var roles=that.$store.state.user.choseroles;
  524. that.roles=roles;
  525. if(roles=='parents'){
  526. this.$store.dispatch('GetInforoles').then(resd => {
  527. if(resd.code==200){
  528. var res=resd.data;
  529. if(res.user&&res.user.parentsStudent&&res.user.parentsStudent.length){
  530. that.stulist = res.user.parentsStudent
  531. }
  532. }
  533. })
  534. }
  535. },
  536. init(){
  537. // 政治面貌
  538. getDictionaryFn('political_outlook').then(res=>{
  539. if(res.code==200){
  540. this.outlook = res.data.map(v => {
  541. return {
  542. dictLabel: v.dictLabel,
  543. dictValue: v.dictValue
  544. }
  545. })
  546. }
  547. })
  548. //近视
  549. getDictionaryFn('isjinshi').then(res=>{
  550. if(res.code==200){
  551. this.isjinshi = res.data.map(v => {
  552. return {
  553. text: v.dictLabel,
  554. value: v.dictValue
  555. }
  556. })
  557. }
  558. })
  559. //健康状态
  560. getDictionaryFn('health_status').then(res=>{
  561. if(res.code==200){
  562. this.healthrange = res.data.map(v => {
  563. return {
  564. dictLabel: v.dictLabel,
  565. dictValue:v.dictValue
  566. }
  567. })
  568. }
  569. })
  570. //心理健康状态
  571. getDictionaryFn('psychology').then(res=>{
  572. if(res.code==200){
  573. this.xlhealthrange = res.data.map(v => {
  574. return {
  575. dictLabel: v.dictLabel,
  576. dictValue: v.dictValue
  577. }
  578. })
  579. }
  580. })
  581. // 血型
  582. getDictionaryFn('blood_type').then(res=>{
  583. if(res.code==200){
  584. this.bloodrange = res.data.map(v => {
  585. return {
  586. dictLabel: v.dictLabel,
  587. dictValue: v.dictValue
  588. }
  589. })
  590. }
  591. })
  592. },
  593. // 学校列表
  594. getDeptListFn(){
  595. var params={
  596. parentId:0
  597. }
  598. getDeptList(0).then(res=>{
  599. if(res.code==200){
  600. this.schoolval = res.data.map(v => {
  601. return {
  602. dictLabel: v.deptName,
  603. dictValue:v.deptId
  604. }
  605. })
  606. }else{
  607. this.$toast(res.msg)
  608. }
  609. })
  610. },
  611. getstunoListFn(){
  612. var params={
  613. classId:this.datainfo.classId
  614. }
  615. params['params[role]']=this.$store.state.user.choseroles
  616. getstunoListFn(params).then(res=>{
  617. if(res.code==200){
  618. this.studentlist = res.rows.map(v => {
  619. return {
  620. dictLabel: v.studentName,
  621. dictValue: v.id,
  622. classId:v.classId
  623. }
  624. })
  625. }
  626. })
  627. },
  628. getSubmit(){
  629. var that = this;
  630. this.$refs.form.validate().then(res => {
  631. var params = JSON.parse(JSON.stringify(this.datainfo))
  632. if (this.pagetype == 'add') {
  633. if(params.idCard){
  634. let _IDRe18 =
  635. /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
  636. let _IDre15 = /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
  637. // 校验身份证:
  638. if (_IDRe18.test(params.idCard) || _IDre15.test(params.idCard)) {
  639. }else{
  640. this.$toast('请输入正确身份证号')
  641. return
  642. }
  643. }
  644. // 验证手机号
  645. let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
  646. if(params.fatherTelephone&&!regphone.test(params.fatherTelephone)){
  647. this.$toast('请输入正确的父亲联系方式')
  648. return
  649. }
  650. if(params.motherTelephone&&!regphone.test(params.motherTelephone)){
  651. this.$toast('请输入正确的母亲联系方式')
  652. return
  653. }
  654. if(params.emergencyContactTelephone&&!regphone.test(params.emergencyContactTelephone)){
  655. this.$toast('请输入正确的紧急联系方式')
  656. return
  657. }
  658. getstuAddtFn(params).then(res => {
  659. if (res.code == 200) {
  660. that.$toast('新增成功')
  661. setTimeout(function() {
  662. uni.$emit('refreshdalist');
  663. uni.navigateBack({
  664. delta:1
  665. })
  666. }, 1500)
  667. } else {
  668. this.$toast(res.msg)
  669. }
  670. })
  671. } else {
  672. if(params.idCard){
  673. let _IDRe18 =
  674. /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
  675. let _IDre15 = /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
  676. // 校验身份证:
  677. if (_IDRe18.test(params.idCard) || _IDre15.test(params.idCard)) {
  678. }else{
  679. this.$toast('请输入正确身份证号')
  680. return
  681. }
  682. }
  683. // 验证手机号
  684. let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
  685. if(params.fatherTelephone&&!regphone.test(params.fatherTelephone)){
  686. this.$toast('请输入正确的父亲联系方式')
  687. return
  688. }
  689. if(params.motherTelephone&&!regphone.test(params.motherTelephone)){
  690. this.$toast('请输入正确的母亲联系方式')
  691. return
  692. }
  693. getstuPutFn(params).then(res => {
  694. if (res.code == 200) {
  695. that.$toast('修改成功')
  696. setTimeout(function() {
  697. uni.$emit('refreshdadetail');
  698. uni.$emit('refreshdalist');
  699. uni.navigateBack({
  700. delta:1
  701. })
  702. }, 1500)
  703. } else {
  704. this.$toast(res.msg)
  705. }
  706. })
  707. }
  708. })
  709. },
  710. bindDateChange(e){
  711. var idx=e.detail.value
  712. this.datainfo.sex=this.sexrange[idx].val
  713. },
  714. bindDateChangea(e){
  715. var idx=e.detail.value
  716. this.datainfo.politicalStatus=this.outlook[idx].dictLabel
  717. },
  718. bindDateChangeb(e){
  719. var idx=e.detail.value
  720. this.datainfo.school=this.schoolval[idx].dictLabel
  721. },
  722. bindDateChangec(e){
  723. var idx=e.detail.value
  724. this.datainfo.health=this.healthrange[idx].dictLabel
  725. },
  726. bindDateChanged(e){
  727. var idx=e.detail.value
  728. this.datainfo.mind=this.xlhealthrange[idx].dictLabel
  729. },
  730. bindDateChangee(e){
  731. var idx=e.detail.value
  732. this.datainfo.className=this.classlist[idx].dictLabel;
  733. this.datainfo.classId=this.classlist[idx].dictValue;
  734. this.datainfo.name='';
  735. this.datainfo.studentId='';
  736. this.getstunoListFn()
  737. },
  738. bindDateChangef(e){
  739. var idx=e.detail.value
  740. this.datainfo.name=this.studentlist[idx].dictLabel
  741. this.datainfo.studentId=this.studentlist[idx].dictValue
  742. },
  743. bindDateChangeg(e){
  744. var idx=e.detail.value
  745. this.datainfo.bloodType=this.bloodrange[idx].dictLabel
  746. // this.datainfo.studentId=this.studentlist[idx].dictValue
  747. },
  748. // 查看照片
  749. getPreview(iurl,idx) {
  750. var newArr=[];
  751. iurl.forEach(ite=>{
  752. var ds=this.baseUrl+ite
  753. newArr.push(ds)
  754. })
  755. uni.previewImage({
  756. urls: newArr,
  757. current:idx,
  758. success: function(data) {
  759. },
  760. fail: function(err) {
  761. console.log(err.errMsg);
  762. }
  763. });
  764. },
  765. delimgFn(e,idx){
  766. var that = this;
  767. if(e=='zj'){
  768. that.zjfile.splice(idx,1);
  769. this.datainfo.identificationPhoto=that.zjfile.join(',')
  770. }else{
  771. that.mjfile.splice(idx,1);
  772. this.datainfo.entrancePermit=that.mjfile.join(',')
  773. }
  774. },
  775. getphotoFn(e){
  776. let that = this;
  777. let file =[],count=9
  778. if(e=='zj'){
  779. file = that.zjfile;
  780. count=9
  781. }else{
  782. file = that.mjfile;
  783. count=9
  784. }
  785. if(file.length < count){
  786. uni.chooseImage({
  787. count: count - parseInt(file.length),
  788. success:function(res){
  789. let img= res.tempFilePaths;
  790. if(img.length + file.length > count){
  791. uni.showToast({
  792. title: '最多上传'+count+'张图片',
  793. icon: 'none',
  794. duration: 2000
  795. })
  796. }else{
  797. let imglen = res.tempFilePaths.length;
  798. var fuwufile = [];
  799. uploadmore('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  800. if(e=='zj'){
  801. that.zjfile = that.zjfile.concat(rs);
  802. that.datainfo.identificationPhoto=that.zjfile.join(',')
  803. }else{
  804. that.mjfile = that.mjfile.concat(rs);
  805. that.datainfo.entrancePermit=that.mjfile.join(',')
  806. }
  807. // console.log(that.datainfo.image,85)
  808. })
  809. }
  810. }
  811. });
  812. }
  813. },
  814. },
  815. }
  816. </script>
  817. <style lang="scss" scoped>
  818. .addbox{padding: 24rpx 36rpx 180rpx;}
  819. .ftit{font-size: 30rpx;font-weight: 500;color: #666666;padding: 8rpx;margin-bottom: 16rpx;}
  820. .fbox{background: #FFFFFF;border-radius: 18rpx;padding: 12rpx 0;margin-bottom: 32rpx;
  821. .addimg{width: 120rpx;height: 120rpx;}
  822. }
  823. .ilrmgr{width: 14rpx;height: 24rpx;margin-left: 20rpx;flex: 0 0 auto;}
  824. .addbtn{height: 98rpx;width: 100%;
  825. background: #1f57e6;
  826. border-radius: 48rpx;display: flex;align-items: center;justify-content: center;font-size: 34rpx;font-weight: 500;
  827. color: #FFFFFF;}
  828. .comboxl{min-height: 70rpx;padding:15rpx 0rpx;box-sizing: border-box;line-height: 40rpx;flex: 1;
  829. textarea{width: 100%;font-size: 30rpx;color: #161616;text-align: right;}
  830. }
  831. .imgs{display: flex;align-items: center;flex-wrap: wrap;justify-content: flex-end;
  832. .photos{width: 120rpx;height: 120rpx;position: relative;margin: 0 0rpx 16rpx 16rpx;
  833. // &:nth-child(3n){margin-left: 0;}
  834. .rimg{width: 100%;height: 100%;}
  835. .del{width: 36rpx;height: 36rpx;position: absolute;right: 0rpx;top: 0rpx;}
  836. }
  837. }
  838. .is_disabled{background-color: #f7f6f6;min-height:70rpx;display: flex;align-items: center;justify-content: flex-end;color: #d5d5d5;
  839. textarea{color: #d5d5d5;}
  840. }
  841. // 心理
  842. .health{display: flex;align-items: center;justify-content: flex-end;flex-wrap: wrap;flex: 1;
  843. image{width: 36rpx;height: 36rpx;margin-right: 12rpx;font-size: 32rpx;color: #161616;flex:0 0 auto;}
  844. }
  845. .addbox /deep/ .uni-forms{flex: 1;}
  846. .addbox /deep/ .uni-forms-item__label{flex: 0 0 auto;width: auto !important;font-size: 30rpx;font-weight: bold;
  847. color: #161616;}
  848. .addbox /deep/ .uni-forms .uni-forms-item{margin-bottom: 0;padding: 4rpx 32rpx;
  849. // &:nth-of-type(3){margin-bottom: 0;border-bottom: 0;}
  850. }
  851. .addbox /deep/ .uni-easyinput{height: 70rpx;}
  852. // .addbox /deep/ .uni-textarea-textarea{height: auto;}
  853. .addbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  854. .addbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
  855. .addbox /deep/ .uni-easyinput__placeholder-class{font-size: 30rpx;}
  856. .addbox /deep/ .uni-easyinput__content-input{font-size: 30rpx;}
  857. .addbox /deep/ .uni-forms-item__error{margin-top:-12rpx;left: auto;right: 0;}
  858. .addbox /deep/ .uni-data-checklist .checklist-group .checklist-box{margin-right: 30rpx;}
  859. .addbox /deep/ .uni-data-checklist .checklist-group{justify-content: flex-end;}
  860. </style>