applyclass.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view class="regbox flexdc">
  3. <uni-forms ref="form" :rules="rules" :modelValue="datainfo">
  4. <!-- 家长 -->
  5. <picker mode="date" :value="date" @change="bindDateChange">
  6. <uni-forms-item name="schoolName" required label="申请时间">
  7. <view class="f15 co16 flex1 txr">{{datainfo.applyTime}}</view>
  8. <view class="rimg"><image :src="rimg" class="rimgs"></image></view>
  9. </uni-forms-item>
  10. </picker>
  11. <picker range-key="dictLabel" :value="bjindex" :range="classval" @change="bindDateChangea">
  12. <uni-forms-item label="调课班级" required name="subjectClass">
  13. <view class="f16 flex1 txr" :class="datainfo.subjectClass ? 'co16' : 'coa'">{{ datainfo.subjectClass || '请选择调课班级' }}</view>
  14. <view class="rimg"><image :src="rimg" class="rimgs"></image></view>
  15. </uni-forms-item>
  16. </picker>
  17. <picker range-key="dictLabel" :value="tkindex" :range="subject" @change="bindDateChangeb">
  18. <uni-forms-item label="调课科目" required name="subject">
  19. <view class="f16 flex1 txr" :class="datainfo.subject ? 'co16' : 'coa'">{{ datainfo.subject || '请选择调课科目' }}</view>
  20. <view class="rimg"><image :src="rimg" class="rimgs"></image></view>
  21. </uni-forms-item>
  22. </picker>
  23. <picker range-key="dictLabel" :value="btindex" :range="subject" @change="bindDateChangec">
  24. <uni-forms-item label="被调科目" required name="beSubject">
  25. <view class="f16 flex1 txr" :class="datainfo.beSubject ? 'co16' : 'coa'">{{ datainfo.beSubject || '请选择被调科目' }}</view>
  26. <view class="rimg"><image :src="rimg" class="rimgs"></image></view>
  27. </uni-forms-item>
  28. </picker>
  29. <picker range-key="dictLabel" :value="xqindex" :range="week" @change="bindDateChanged">
  30. <uni-forms-item label="时间(星期)" required name="week">
  31. <view class="f16 flex1 txr" :class="datainfo.week ? 'co16' : 'coa'">{{ kaType(datainfo.week,week) || '请选择时间(星期)' }}</view>
  32. <view class="rimg"><image :src="rimg" class="rimgs"></image></view>
  33. </uni-forms-item>
  34. </picker>
  35. <view class="text">
  36. <uni-forms-item label="调课内容" name="content">
  37. <uni-easyinput class='inp_textarea' v-model="datainfo.content" :inputBorder="false" type="textarea" placeholder="请输入调课内容,例:5月16日星期二的英语课与 5月18日周四的语文课调换…"></uni-easyinput>
  38. </uni-forms-item>
  39. </view>
  40. </uni-forms>
  41. <view class="mt26">
  42. <view class="rbtn" @click="getSubmit">提交</view>
  43. <!-- <view class="apllytxt f15" @click="gethome">稍后完善</view> -->
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import {getChangeAddFn,getChangeDetFn,getChangePutFn} from "@/api/work/index.js"
  49. import {getDictionaryFn} from "@/api/mine/register.js"
  50. import { selectDictValue } from '@/utils/common.js';
  51. import {getDeptList} from "@/api/mine/mine.js"
  52. import config from '@/config'
  53. const baseUrl = config.baseUrl
  54. import { getToken } from '@/utils/auth'
  55. export default {
  56. data(){
  57. return{
  58. rimg:require("@/static/images/rimg.png"),
  59. wimg:require('@/static/images/read.png'),
  60. delimg:require('@/static/images/del.png'),
  61. addimg:require('@/static/images/add.png'),
  62. date:'',
  63. rules: {
  64. applyTime: {rules: [{required: true,errorMessage: '请选择时间'}]},
  65. subjectClass: {rules: [{required: true,errorMessage: '请选择调课班级'}]},
  66. subject: {rules: [{required: true,errorMessage: '请选择调课科目'}]},
  67. beSubject: {rules: [{required: true,errorMessage: '请选择被调科目'}]},
  68. week: {rules: [{required: true,errorMessage: '请选择时间(星期)'}]},
  69. },
  70. datainfo:{
  71. "applyTime": "",
  72. "subjectClassId": "",
  73. "subjectClass": "",
  74. "subject": "",
  75. "beSubject": "",
  76. "week": "",
  77. "content": ""
  78. },
  79. subject:[],
  80. week:[],
  81. classval:[],
  82. bjindex:[0],
  83. tkindex:[0],
  84. btindex:[0],
  85. xqindex:[0],
  86. pagetype:'add',
  87. id:''
  88. }
  89. },
  90. onLoad: function(e) {
  91. this.getclassListFn()
  92. this.datainfo.applyTime=this.getNowFormatDate()
  93. this.init()
  94. if(e.pagetype){
  95. var that=this;
  96. this.pagetype=e.pagetype||'add';
  97. this.id=e.id;
  98. setTimeout(function(){
  99. that.getDataFn()
  100. },500)
  101. }
  102. },
  103. methods:{
  104. getNowFormatDate(){
  105. let date = new Date();
  106. let y = date.getFullYear();
  107. let m = date.getMonth() + 1;
  108. m = m < 10 ? "0" + m : m;
  109. let d = date.getDate();
  110. d = d < 10 ? "0" + d : d;
  111. // let h = date.getHours();
  112. // h = h < 10 ? "0" + h : h;
  113. // let ms = date.getMinutes();
  114. // ms = ms < 10 ? "0" + ms : ms;
  115. // let s = date.getSeconds();
  116. // s = s < 10 ? "0" + s : s;
  117. // const time = y + "-" + m + "-" + d + " " + h + ":" + ms + ":" + s;
  118. const timeday = y + "-" + m + "-" + d;
  119. return timeday;
  120. },
  121. kaType(data, list) {
  122. return selectDictValue(list, data);
  123. },
  124. getDataFn(){
  125. // 详情
  126. getChangeDetFn(this.id).then(res=>{
  127. if(res.code==200){
  128. this.datainfo=res.data;
  129. if(res.data.subjectClass){
  130. var newa=[]
  131. Object.keys(this.classval).some((key) => {
  132. if (this.classval[key].dictLabel == ('' + res.data.subjectClass)) {
  133. newa[0]=Number(key)
  134. this.bjindex=newa
  135. return true;
  136. }
  137. })
  138. }
  139. if(res.data.subject){
  140. var newb=[]
  141. Object.keys(this.subject).some((key) => {
  142. if (this.subject[key].dictValue == ('' + res.data.subject)) {
  143. newb[0]=Number(key)
  144. this.tkindex=newb
  145. return true;
  146. }
  147. })
  148. }
  149. if(res.data.beSubject){
  150. var newc=[];
  151. Object.keys(this.subject).some((key) => {
  152. if (this.subject[key].dictValue == ('' + res.data.beSubject)) {
  153. newc[0]=Number(key)
  154. this.btindex=newc
  155. return true;
  156. }
  157. })
  158. }
  159. if(res.data.week){
  160. var newd=[];
  161. Object.keys(this.week).some((key) => {
  162. if (this.week[key].dictValue == ('' + res.data.week)) {
  163. newd[0]=Number(key)
  164. this.xqindex=newd
  165. return true;
  166. }
  167. })
  168. }
  169. }else{
  170. this.$toast(res.msg)
  171. }
  172. })
  173. },
  174. // 班级
  175. getclassListFn(){
  176. // 老师 获取学校id
  177. var id=this.$store.state.user.schoolId||this.$store.state.user.deptId;
  178. getDeptList(id).then(res=>{
  179. if(res.code==200){
  180. this.classval = res.data.map(v => {
  181. return {
  182. dictLabel: v.deptName,
  183. dictValue:v.deptId
  184. }
  185. })
  186. }else{
  187. this.$toast(res.msg)
  188. }
  189. })
  190. },
  191. init(){
  192. // 学科
  193. getDictionaryFn('sys_subject').then(res=>{
  194. if(res.code==200){
  195. this.subject = res.data.map(v => {
  196. return {
  197. dictLabel: v.dictLabel,
  198. dictValue: v.dictValue
  199. }
  200. })
  201. }
  202. })
  203. // 星期
  204. getDictionaryFn('sys_week').then(res=>{
  205. if(res.code==200){
  206. this.week = res.data.map(v => {
  207. return {
  208. dictLabel: v.dictLabel,
  209. dictValue: v.dictValue
  210. }
  211. })
  212. }
  213. })
  214. },
  215. bindDateChange(e){
  216. var val = e.detail.value;
  217. this.datainfo.applyTime=val;
  218. },
  219. bindDateChangea(e) {
  220. var val = e.detail.value;
  221. this.datainfo.subjectClass = this.classval[val].dictLabel;
  222. this.datainfo.subjectClassId = this.classval[val].dictValue;
  223. },
  224. bindDateChangeb(e) {
  225. var val = e.detail.value;
  226. this.datainfo.subject = this.subject[val].dictLabel;
  227. },
  228. bindDateChangec(e) {
  229. var val = e.detail.value;
  230. this.datainfo.beSubject = this.subject[val].dictLabel;
  231. },
  232. bindDateChanged(e) {
  233. var val = e.detail.value;
  234. this.datainfo.week = this.week[val].dictValue;
  235. },
  236. getSubmit(){
  237. var that=this;
  238. this.$refs.form.validate().then(res => {
  239. var params=JSON.parse(JSON.stringify(this.datainfo))
  240. if(that.pagetype=='add'){
  241. getChangeAddFn(params).then(res=>{
  242. if(res.code==200){
  243. that.$toast("新增成功")
  244. setTimeout(function(){
  245. uni.$emit('refreshdatalis');
  246. that.$tab.reLaunch('/pages/work/index')
  247. },1500)
  248. }else{
  249. that.$toast(res.msg)
  250. }
  251. })
  252. }else{
  253. getChangePutFn(params).then(res=>{
  254. if(res.code==200){
  255. that.$toast("修改成功")
  256. setTimeout(function(){
  257. uni.$emit('refreshdatalis');
  258. uni.navigateBack({
  259. delta:1
  260. })
  261. },1500)
  262. }else{
  263. that.$toast(res.msg)
  264. }
  265. })
  266. }
  267. })
  268. // this.$tab.navigateTo(`/mine/pages/mine/success`)
  269. },
  270. gethome(){
  271. this.$tab.reLaunch(`/pages/index/index`)
  272. },
  273. },
  274. }
  275. </script>
  276. <style lang="scss" scoped>
  277. .regbox{padding: 50rpx 36rpx 80rpx;
  278. .apllytxt{font-size:30rpx ;}
  279. .line{width: 40rpx;height: 6rpx;background: #FFB132;margin: 60rpx auto 0;}
  280. .addbox{font-weight: 500;
  281. image{width: 44rpx;height: 44rpx;margin-right: 24rpx;}
  282. }
  283. }
  284. .inp_textarea{text-align: left !important;border: 1px solid #FFB132;margin-top: 30rpx;border-radius: 14rpx;padding:0rpx 30rpx;box-sizing: border-box;}
  285. .regbox /deep/ .uni-easyinput__content-textarea{height: 260rpx;min-height: 260rpx;max-height: 260rpx;font-size: 30rpx;}
  286. /* #ifndef H5 */
  287. .regbox /deep/ .uni-easyinput__content-textarea{height: 260rpx;min-height: 260rpx;max-height: 260rpx;font-size: 30rpx;text-align: left !important;border: 1px solid #FFB132;margin-top: 30rpx;border-radius: 14rpx;padding:12rpx 30rpx;box-sizing: border-box;}
  288. /* #endif */
  289. .regbox /deep/ .uni-forms{flex: 1;}
  290. .regbox /deep/ .uni-forms-item__label{flex: 0 0 auto;width: auto !important;font-size: 32rpx;font-weight: bold;
  291. color: #161616;}
  292. .regbox /deep/ .uni-forms .uni-forms-item{padding: 28rpx 24rpx 20rpx;border-bottom: 2rpx #C1C1C1 solid;margin-bottom: 0;
  293. // &:last-child{margin-bottom: 0;border-bottom: 0;flex-direction: column;text-align: left;}
  294. }
  295. .regbox /deep/ .uni-forms .text .uni-forms-item{margin-bottom: 0;border-bottom: 0;flex-direction: column;text-align: left;}
  296. .regbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  297. .regbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
  298. .regbox /deep/ .uni-easyinput__placeholder-class{font-size: 30rpx;}
  299. .regbox /deep/ .uni-easyinput__content-input{font-size: 30rpx;}
  300. .regbox /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  301. // .regbox .inp_textarea /deep/ .uni-easyinput__content-textarea{text-align: left !important;border: 1px solid #FFB132;margin-top: 30rpx;border-radius: 14rpx;padding:0rpx 30rpx;box-sizing: border-box;}
  302. </style>