leave.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="mind">
  3. <picker range-key="dictLabel" v-if="roles!='parents'" :disabled="daflag" :range="classlist" :value="classidx" @change="bindDateChangeb">
  4. <view class="flexc mibox mb20">
  5. <view class="tit" style="margin-bottom: 0;">班级</view>
  6. <view class="f15 flex1 txr co16" v-if="className" >{{className}}</view>
  7. <view class="f15 flex1 txr coa" v-else >请选择班级</view>
  8. <image :src="rimg" class="rimg"></image>
  9. </view>
  10. </picker>
  11. <picker range-key="dictLabel" :disabled="daflag||studentlist.length<1" :range="studentlist" :value="nameidx" @change="bindDateChangea">
  12. <view class="flexc mibox mb20">
  13. <view class="tit" style="margin-bottom: 0;">人员</view>
  14. <view class="f15 flex1 txr co16" v-if="name" >{{name}}</view>
  15. <view class="f15 flex1 txr coa" v-else >请选择人员</view>
  16. <image :src="rimg" class="rimg"></image>
  17. </view>
  18. </picker>
  19. <picker range-key="dictLabel" :disabled="daflag" :range="qjlxrange" :value="qjlbidx" @change="bindDateChanged">
  20. <view class="flexc mibox mb20">
  21. <view class="tit" style="margin-bottom: 0;">请假类别</view>
  22. <view class="f15 flex1 txr co16" v-if="category" >{{category}}</view>
  23. <view class="f15 flex1 txr coa" v-else >请选择请假类别</view>
  24. <image :src="rimg" class="rimg"></image>
  25. </view>
  26. </picker>
  27. <!-- <picker mode="time" @change="bindDateChanged"> -->
  28. <view class="flexc mibox mb20">
  29. <view class="tit" style="margin-bottom: 0;">开始时间</view>
  30. <uni-datetime-picker :border="false" :hide-second='true' type="datetime" v-model="startTime" @change="changeLog" />
  31. <!-- <view class="f15 flex1 txr co16" v-if="starttime" >{{starttime}}</view>
  32. <view class="f15 flex1 txr coa" v-else >请选择开始时间</view> -->
  33. <image :src="rimg" class="rimg"></image>
  34. </view>
  35. <view class="flexc mibox mb20">
  36. <view class="tit" style="margin-bottom: 0;">结束时间</view>
  37. <uni-datetime-picker :border="false" :hide-second='true' type="datetime" v-model="endTime" @change="changeLog" />
  38. <!-- <view class="f15 flex1 txr co16" v-if="starttime" >{{starttime}}</view>
  39. <view class="f15 flex1 txr coa" v-else >请选择开始时间</view> -->
  40. <image :src="rimg" class="rimg"></image>
  41. </view>
  42. <!-- </picker> -->
  43. <view class='mibox'>
  44. <view class="tit">详情描述</view>
  45. <textarea placeholder="请输入详情描述内容……" v-model="reason" :auto-height="autoHeight"></textarea>
  46. </view>
  47. <view class="rebtn mt30" @click="getSubmit">确认</view>
  48. </view>
  49. </template>
  50. <script>
  51. // import tabSearch from "@/components/toptab/search.vue"
  52. import {getDictionaryFn} from '@/api/mine/register.js'
  53. import {getDeptList} from "@/api/mine/mine.js"
  54. import {getleaveAddFn,getstunoListFn} from "@/api/mine/files.js"
  55. export default {
  56. data(){
  57. return{
  58. rimg:require("@/mine/static/score/rimg.png"),
  59. autoHeight:true,
  60. qjlx:[],
  61. startTime:'',
  62. endTime:'',
  63. absenteeName:'',
  64. qjlbidx:0,
  65. category:'',//请假类别
  66. categoryval:'',//请假类别
  67. datainfo:{
  68. },
  69. roles:'',
  70. studentlist:[],
  71. name:'',
  72. nameidx:0,
  73. classidx:0,
  74. studentId:'',
  75. classId:'',
  76. className:'',
  77. psychologicalDescription:'',
  78. daflag:false,
  79. qjlxrange:[],
  80. reason:'',
  81. classlist:[],//班级
  82. }
  83. },
  84. onLoad: function(e) {
  85. this.init();
  86. if(e.type&&e.type=='daup'){
  87. this.name=e.name;
  88. this.studentId=e.id;
  89. this.daflag=true;
  90. }else{
  91. var roles=this.$store.state.user.choseroles;
  92. this.roles=roles;
  93. if(roles=='parents'){
  94. var newArr=this.$store.state.user.student;
  95. if(newArr&&newArr.length){
  96. if(newArr.length>1){
  97. this.studentlist = newArr.map(v => {
  98. return {
  99. dictLabel:v.studentName,
  100. dictValue: v.id,
  101. classId:v.classId
  102. }
  103. })
  104. }else{
  105. // 一个娃
  106. this.name=newArr[0].studentName
  107. this.studentId=newArr[0].id
  108. this.classId=newArr[0].classId
  109. }
  110. }
  111. }else if(roles=='teacher'){
  112. var newArr=this.$store.state.user.teacherClass;
  113. if(newArr&&newArr.length){
  114. this.classlist = newArr.map(v => {
  115. return {
  116. dictLabel:v.className,
  117. dictValue: v.classId,
  118. }
  119. })
  120. }
  121. }else{
  122. var id=this.$store.state.user.deptId;
  123. this.getclassListFn(id)
  124. }
  125. }
  126. },
  127. methods:{
  128. init(){
  129. //心理健康状态
  130. getDictionaryFn('qjlx').then(res=>{
  131. if(res.code==200){
  132. this.qjlxrange = res.data.map(v => {
  133. return {
  134. dictLabel: v.dictLabel,
  135. dictValue: v.dictValue
  136. }
  137. })
  138. }
  139. })
  140. },
  141. changeLog(){
  142. },
  143. getclassListFn(id){
  144. getDeptList(id).then(res=>{
  145. if(res.code==200){
  146. var newArr=res.data;
  147. if(newArr&&newArr.length){
  148. this.classlist = newArr.map(v => {
  149. return {
  150. dictLabel: v.deptName,
  151. dictValue: v.deptId,
  152. }
  153. })
  154. }
  155. }else{
  156. this.$toast(res.msg)
  157. }
  158. })
  159. },
  160. bindDateChangea(e){
  161. var idx=e.detail.value
  162. this.name=this.studentlist[idx].dictLabel
  163. this.studentId=this.studentlist[idx].dictValue
  164. this.classId=this.studentlist[idx].classId
  165. },
  166. bindDateChangeb(e){
  167. var idx=e.detail.value
  168. this.className=this.classlist[idx].dictLabel
  169. this.classId=this.classlist[idx].dictValue
  170. this.name='';
  171. this.studentId='';
  172. // 获取班级信息
  173. this.getstunoListFn()
  174. },
  175. bindDateChanged(e){
  176. var idx=e.detail.value
  177. this.category=this.qjlxrange[idx].dictLabel
  178. this.categoryval=this.qjlxrange[idx].dictValue
  179. },
  180. getstunoListFn(){
  181. var params={
  182. classId:this.classId
  183. }
  184. params['params[role]']=this.$store.state.user.choseroles
  185. getstunoListFn(params).then(res=>{
  186. if(res.code==200){
  187. this.studentlist = res.rows.map(v => {
  188. return {
  189. dictLabel: v.studentName,
  190. dictValue: v.id,
  191. classId:v.classId
  192. }
  193. })
  194. }
  195. })
  196. },
  197. getSubmit(){
  198. // 学生 id
  199. var roles=this.$store.state.user.choseroles;
  200. var that=this;
  201. if(roles!="parents"){
  202. if(!this.className){
  203. this.$toast('请选择班级')
  204. return
  205. }
  206. }
  207. if(!this.studentId){
  208. this.$toast('请选择人员')
  209. return
  210. }
  211. if(!this.category){
  212. this.$toast('请选择请假类别')
  213. return
  214. }
  215. if(!this.startTime){
  216. this.$toast('请选择开始时间')
  217. return
  218. }
  219. if(!this.endTime){
  220. this.$toast('请选择结束时间')
  221. return
  222. }
  223. var params={
  224. absenteeId:this.studentId,
  225. category:this.categoryval,
  226. reason:this.reason,
  227. startTime:this.startTime+':00',
  228. endTime:this.endTime+':00',
  229. classId:this.classId,
  230. absenteeName:this.name,
  231. }
  232. params['params[role]']=this.$store.state.user.choseroles
  233. // if(roles=='teacher'){
  234. // params.createType='2'
  235. // }else if(roles=='parents'){
  236. // params.createType='1'
  237. // }
  238. getleaveAddFn(params).then(res => {
  239. if (res.code == 200) {
  240. that.$toast('新增成功')
  241. setTimeout(function() {
  242. if(that.daflag){
  243. uni.$emit('refreshleavelist');
  244. uni.redirectTo({
  245. url:'/mine/pages/files/leavelist?type=da&id='+that.studentId+'&name='+that.name
  246. })
  247. }else{
  248. uni.$emit('refreshleavelist');
  249. uni.navigateBack({
  250. delta:1
  251. })
  252. }
  253. }, 1500)
  254. } else {
  255. this.$toast(res.msg)
  256. }
  257. })
  258. },
  259. },
  260. }
  261. </script>
  262. <style lang="scss" scoped>
  263. .mind{
  264. min-height: 100vh;background: #ffffff;padding: 80rpx 60rpx;
  265. .mibox{
  266. .tit{font-size: 32rpx;font-weight: 500;color: #161616;margin-bottom: 40rpx;}
  267. textarea{border: 2rpx solid #FFB132;border-radius: 20rpx;width: 100%;min-height: 230rpx;padding:32rpx;box-sizing: border-box;}
  268. .rimg{width: 14rpx;height: 24rpx;flex: 0 0 auto;margin-left: 12rpx;}
  269. }
  270. }
  271. .mind /deep/ .uni-input-wrapper{text-align: right;font-size: 30rpx;}
  272. .mind /deep/ .uni-date__x-input{padding: 0;text-align: right;font-size: 30rpx;}
  273. .mind /deep/ .uni-date-x{padding: 0;}
  274. .mind /deep/ .uniui-calendar::before{display: none;}
  275. .mind /deep/ .uni-input-placeholder{color:#AAAAAA;font-size: 30rpx;}
  276. </style>