index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <view class="addfb">
  3. <!-- :reservatType="yktypes" -->
  4. <step-bar :steps="steps" :fixeda="fixedflag" ></step-bar>
  5. <view class="card">
  6. <view class="tit">接收班级<text class="fwn f14 co6">(单选)</text></view>
  7. <view class="bjlist" v-for="(ite,idx) in classval" :key="idx" @click="getCheck(idx)">
  8. <image :src="checkimg" v-if="classidx==idx"></image>
  9. <image :src="ncheckimg" v-else></image>
  10. <view class="f16 c16 flex1">{{ite.dictLabel}}</view>
  11. </view>
  12. </view>
  13. <view class="card">
  14. <view class="flexc mb20">
  15. <view class="cttit">成绩标题</view>
  16. <input type="text" v-model="datainfo.scoreTitle" placeholder-style="color:#aaa;" placeholder="请输入成绩标题" class="ctinp">
  17. </view>
  18. <picker range-key='dictLabel' :value="ksindex" :range="kaoshilist" @change='bindDateChangea'>
  19. <view class="flexc mb20">
  20. <view class="cttit">考试类型</view>
  21. <view class="f16 flex1 txr" :class="datainfo.scoreType?'co16':'coa'">{{scoreType||"请选择考试分类"}}</view>
  22. </view>
  23. </picker>
  24. <picker mode="date" class="mb20" :value="datainfo.scoreTime" @change="bindDateChange">
  25. <view class="flexc">
  26. <view class="cttit">本次考试时间</view>
  27. <view class="f16 flex1 txr" :class="datainfo.scoreTime ? 'co16' : 'coa'">{{ datainfo.scoreTime || '请选择本次考试时间' }}</view>
  28. </view>
  29. </picker>
  30. <view class="addbtn flexcc" @click="getImport">
  31. <image :src="addimg" class="addimg"></image>
  32. 导入或录入成绩
  33. </view>
  34. </view>
  35. <view class="card" @click="getPrivacy">
  36. <view class="tit" style="margin-bottom: 32rpx;">隐私设置</view>
  37. <view class="flexc mb8">
  38. <view class="f15 co6 fw flex1">学生只能查看自己的成绩</view>
  39. <image :src="openimg" class="openimg"></image>
  40. </view>
  41. </view>
  42. <!-- 底部按钮 -->
  43. <view class="fbtn">
  44. <!-- <view class="flexcdc fbtnl">
  45. <image :src="draftimg"></image>
  46. <view>存草稿</view>
  47. </view> -->
  48. <view class="fbtnr flexcc" @click="getSubmit">发布</view>
  49. </view>
  50. <!-- 弹窗 -->
  51. <pop-up :type="type" @getClose="getClose" @getDel="getDel" @getLook="getLook" @getEnter="getEnter" @getConfirm="getConfirm"></pop-up>
  52. <!-- 上传 -->
  53. <view >
  54. <lsj-upload
  55. ref="lsjUpload"
  56. childId="upload1"
  57. :width="width"
  58. :height="height"
  59. :option="option"
  60. :size="size"
  61. :count="count"
  62. :formats="formats"
  63. :debug="debug"
  64. :instantly="instantly"
  65. :files="files"
  66. @change="change"
  67. @uploadEnd="onuploadEnd"
  68. >
  69. </lsj-upload>
  70. <view class="rebtn" :style="{width: width,height: height}"></view>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import popUp from "@/mine/components/popup/popup.vue"
  76. import stepBar from "@/mine/components/popup/stepbar.vue"
  77. import {getscoreAddFn,getscoreAddimpFn} from "@/api/mine/score.js"
  78. import {getDeptList,getDeptListparent,getselfList} from "@/api/mine/mine.js"
  79. import {getDictionaryFn} from '@/api/mine/register.js'
  80. import config from '@/config'
  81. const baseUrl = config.baseUrl
  82. const clientid = config.Clientid
  83. import { getToken } from '@/utils/auth'
  84. export default {
  85. components:{popUp,stepBar},
  86. data() {
  87. return {
  88. checkimg: require("@/mine/static/score/check.png"),
  89. ncheckimg: require("@/mine/static/score/ncheck.png"),
  90. addimg: require("@/mine/static/score/add.png"),
  91. draftimg:require("@/mine/static/score/draft.png"),
  92. openimg:require("@/mine/static/mine/check.png"),
  93. date: '',
  94. type:0,
  95. kaoshilist:[],
  96. ksindex:0,
  97. classval:[],
  98. classidx:0,
  99. importtype:1,//1 导入 2 录入
  100. scoreType:'',
  101. datainfo:{
  102. scoreTitle:'',//考试名称
  103. scoreTime:'',//考试时间
  104. scoreClassId:'',//接收班级id
  105. scoreClassName:'',//接收班级名称
  106. scoreType:'',
  107. privacyType:3,//隐私设置 1:仅自己 2:仅本班 3:全部
  108. },
  109. scoreDataDetailsList:[],//成绩子表
  110. file:[],//文件
  111. option: {
  112. // 上传服务器地址,需要替换为你的接口地址
  113. url: baseUrl+'/score/data/importData', // 该地址非真实路径,需替换为你项目自己的接口地址
  114. // 上传附件的key
  115. name: 'file',
  116. // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
  117. header: {
  118. // 示例参数可删除
  119. 'Authorization': 'Bearer ' + getToken(),
  120. "Clientid":clientid
  121. },
  122. // 根据你接口需求自定义body参数
  123. formData: {
  124. scoreClassName:'',
  125. scoreClassId:'',
  126. scoreTime:'',
  127. scoreTitle:'',
  128. scoreType:''
  129. }
  130. },
  131. // 选择文件后是否立即自动上传,true=选择后立即上传
  132. instantly: false,
  133. // 必传宽高且宽高应与slot宽高保持一致
  134. width: '0',
  135. height: '0',
  136. // 限制允许上传的格式,空串=不限制,默认为空
  137. formats: 'xls,xlsx',
  138. // 文件上传大小限制
  139. size: 100,
  140. // 文件数量限制 默认10
  141. count: 1,
  142. // 文件回显列表
  143. files: new Map(),
  144. // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道
  145. wxFiles: [],
  146. // 是否打印日志
  147. debug: false,
  148. column1:[],
  149. subList:[],
  150. mfboList:[],//满分的数据
  151. steps:[{tit:'选择班级',status:0,val:0},{tit:'上传或录入',status:0,val:1},{tit:'隐私设置',status:0,val:2},{tit:'发布成绩',status:0,val:3}],
  152. fixedflag:true,
  153. }
  154. },
  155. watch:{
  156. scoreDataDetailsList:{
  157. handler(newVal) {
  158. var data=newVal;
  159. var info=this.datainfo;
  160. if(data&&data.length&&info.scoreTitle&&info.scoreTime&&info.scoreType){
  161. this.steps[1].status=2;
  162. }else{
  163. this.steps[1].status=0;
  164. }
  165. },
  166. deep: true
  167. },
  168. file:{
  169. handler(newVal) {
  170. var data=newVal;
  171. var info=this.datainfo;
  172. if(data&&data.length&&info.scoreTitle&&info.scoreTime&&info.scoreType){
  173. this.steps[1].status=2;
  174. }else{
  175. this.steps[1].status=0;
  176. }
  177. },
  178. deep: true
  179. },
  180. datainfo: {
  181. handler(newVal) {
  182. var data=newVal;
  183. var score=this.scoreDataDetailsList;
  184. var file=this.file;
  185. if(data.scoreClassId){
  186. this.steps[0].status=2;
  187. }
  188. if(data.scoreTitle&&data.scoreTime&&data.scoreType&&(score&&score.length||file&&file.length)){
  189. this.steps[1].status=2;
  190. }else{
  191. this.steps[1].status=0;
  192. }
  193. if(data.privacyType){
  194. this.steps[2].status=2;
  195. }
  196. // scoreTitle:'',//考试名称
  197. // scoreTime:'',//考试时间
  198. // scoreClassId:'',//接收班级id
  199. // scoreClassName:'',//接收班级名称
  200. // scoreType:'',
  201. // privacyType:3,//隐私设置 1:仅自己 2:仅本班 3:全部
  202. },
  203. deep: true
  204. },
  205. // datainfo(val){
  206. // var data=this.datainfo;
  207. // if(val!=0){
  208. // if(data.visitDate&&data.visitTime) this.steps[0].status=2;
  209. // else if(!data.visitDate||!data.visitTime) this.steps[0].status=0;
  210. // }
  211. // if(val!=1){
  212. // if(this.yktypes==1){
  213. // if(this.inputValue&&data.visitPhone&&data.visitName&&data.visitUnitName) this.steps[1].status=2;
  214. // else if(!this.inputValue||!data.visitPhone||!data.visitName||!data.visitUnitName) this.steps[1].status=0;
  215. // }else{
  216. // if(this.inputValue&&data.visitPhone&&data.visitName) this.steps[1].status=2;
  217. // else if(!this.inputValue||!data.visitPhone) this.steps[1].status=0;
  218. // }
  219. // }
  220. // }
  221. },
  222. onUnload(){
  223. uni.$off('refreshscorelist')
  224. uni.$off('refreshscorefile')
  225. },
  226. onLoad: function() {
  227. uni.$on('refreshscorelist', (e) => {
  228. var nobj=JSON.parse(JSON.stringify(e))
  229. this.scoreDataDetailsList=e.scoreDataDetailsList
  230. this.column1=e.column1
  231. this.subList=e.subList
  232. this.mfboList=e.mfboList
  233. })
  234. uni.$on('refreshscorefile', (e) => {
  235. console.log(e,1)
  236. this.file=JSON.parse(JSON.stringify(e.file))
  237. this.files=e.files
  238. })
  239. this.init()
  240. this.getClassFn()
  241. },
  242. methods: {
  243. init(){
  244. // 考试类型
  245. getDictionaryFn('kaoshi').then(res=>{
  246. if(res.code==200){
  247. this.kaoshilist = res.data.map(v => {
  248. return {
  249. dictLabel: v.dictLabel,
  250. dictValue:v.dictValue,
  251. }
  252. })
  253. }
  254. })
  255. },
  256. bindDateChangea(e) {
  257. var val = e.detail.value;
  258. this.scoreType=this.kaoshilist[val].dictLabel
  259. this.datainfo.scoreType=this.kaoshilist[val].dictValue
  260. },
  261. getselfList(id){
  262. var params={
  263. parentId:id,
  264. }
  265. params['params[role]']=this.$store.state.user.choseroles
  266. getselfList(params).then(res=>{
  267. if(res.code==200){
  268. var newArr=res.data;
  269. if(newArr&&newArr.length){
  270. this.classval = newArr.map(v => {
  271. return {
  272. dictLabel: v.deptName,
  273. dictValue: v.deptId
  274. }
  275. })
  276. this.datainfo.scoreClassId=newArr[0].deptId
  277. this.datainfo.scoreClassName=newArr[0].deptName
  278. }
  279. }else{
  280. this.$toast(res.msg)
  281. }
  282. })
  283. },
  284. getClassFn(){
  285. var that=this;
  286. var roles=that.$store.state.user.choseroles;
  287. that.roles=roles;
  288. if(roles=='teacher'){
  289. var id=that.$store.state.user.schoolId;
  290. that.schoolId=id;
  291. this.getselfList(id)
  292. }else{
  293. var id=that.$store.state.user.deptId;
  294. that.schoolId=id;
  295. this.getselfList(0)
  296. }
  297. },
  298. getclassListFn(id){
  299. var that=this;
  300. // var params={
  301. // parentId:id
  302. // }
  303. getDeptList(id).then(res=>{
  304. if(res.code==200){
  305. that.classval = res.data.map(v => {
  306. return {
  307. dictLabel: v.deptName,
  308. dictValue:v.deptId,
  309. }
  310. })
  311. that.datainfo.scoreClassId=res.data[0].deptId
  312. that.datainfo.scoreClassName=res.data[0].deptName
  313. }else{
  314. that.$toast(res.msg)
  315. }
  316. })
  317. },
  318. getSubmit(){
  319. var that=this;
  320. var params=JSON.parse(JSON.stringify(this.datainfo))
  321. if(!params.scoreTitle){
  322. this.$toast("请输入成绩标题")
  323. return
  324. }
  325. if(!params.scoreType){
  326. this.$toast("请选择考试类型")
  327. return
  328. }
  329. if(!params.scoreTime){
  330. this.$toast("请选择考试时间")
  331. return
  332. }
  333. params['params[role]']=this.$store.state.user.choseroles
  334. // var formData = new FormData()
  335. // Object.keys(info).some((key) => {
  336. // if (info[key] != '') {
  337. // params[key]=info[key]
  338. // return ;
  339. // }
  340. // })
  341. // formData.append( 'file',file)
  342. // 录入
  343. if(this.importtype==2){
  344. if(this.scoreDataDetailsList&&this.scoreDataDetailsList.length<1){
  345. this.$toast("请上传成绩")
  346. return
  347. }
  348. params.scoreDataStudentBoList=this.scoreDataDetailsList
  349. params.scoreDataMfBoList=this.mfboList;
  350. // return
  351. getscoreAddFn(params).then(res=>{
  352. if(res.code==200){
  353. that.$toast('发布成功')
  354. uni.removeStorageSync('scorelist')
  355. uni.removeStorageSync('filelist')
  356. setTimeout(function(){
  357. uni.navigateBack({
  358. delta:1
  359. })
  360. },1200)
  361. }else{
  362. that.$toast(res.msg)
  363. }
  364. })
  365. }else{
  366. if(this.file&&this.file.length<1){
  367. this.$toast("请上传成绩")
  368. return
  369. }
  370. this.option.formData=JSON.parse(JSON.stringify(this.datainfo))
  371. var name=this.file[0].name;
  372. var files=this.files
  373. this.$refs['lsjUpload'].setData('formData.scoreClassName',this.datainfo.scoreClassName);
  374. this.$refs['lsjUpload'].setData('formData.scoreClassId',this.datainfo.scoreClassId);
  375. this.$refs['lsjUpload'].setData('formData.scoreTime',this.datainfo.scoreTime);
  376. this.$refs['lsjUpload'].setData('formData.scoreTitle',this.datainfo.scoreTitle);
  377. this.$refs['lsjUpload'].setData('formData.scoreType',this.datainfo.scoreType);
  378. this.$refs['lsjUpload'].uploadimp(name,files);
  379. }
  380. },
  381. onuploadEnd(item){
  382. var that=this;
  383. var responseText=JSON.parse(item.responseText)
  384. if(responseText.code==200){
  385. that.$toast('发布成功')
  386. uni.removeStorageSync('scorelist')
  387. uni.removeStorageSync('filelist')
  388. setTimeout(function(){
  389. uni.navigateBack({
  390. delta:1
  391. })
  392. },1200)
  393. }else{
  394. that.$toast(responseText.msg)
  395. }
  396. },
  397. getCheck(idx){
  398. this.classidx=idx;
  399. this.datainfo.scoreClassId=this.classval[idx].dictValue;
  400. this.datainfo.scoreClassName=this.classval[idx].dictLabel;
  401. },
  402. bindDateChange(e) {
  403. var val=e.detail.value;
  404. this.datainfo.scoreTime=val;
  405. },
  406. getPrivacy(){
  407. this.type=5
  408. },
  409. getLook(){
  410. // console.log(this.scoreDataDetailsList)
  411. if(this.scoreDataDetailsList&&this.scoreDataDetailsList.length>0){//录入
  412. var obj={
  413. column1:this.column1,
  414. subList:this.subList,
  415. mfboList:this.mfboList,
  416. item:this.scoreDataDetailsList
  417. }
  418. uni.setStorageSync('scorelist',JSON.stringify(obj))
  419. this.$tab.navigateTo('/mine/pages/release/entry?type=look&scoreClassId='+this.datainfo.scoreClassId);
  420. }else if(this.file&&this.file.length>0){// 导入
  421. var obj={
  422. files:this.files,
  423. item:this.file
  424. }
  425. uni.setStorageSync('filelist',JSON.stringify(obj))
  426. this.$tab.navigateTo('/mine/pages/release/format?type=look');
  427. }
  428. this.type=0;
  429. },
  430. getDel(){
  431. var that=this
  432. uni.showModal({
  433. title: '确认删除',
  434. content: "是否确认删除",
  435. cancelText: '取消删除',
  436. confirmText: '确认删除',
  437. success: function(res) {
  438. if (res.confirm) {
  439. that.scoreDataDetailsList=[];
  440. that.file=[];
  441. uni.removeStorageSync('scorelist')
  442. uni.removeStorageSync('filelist')
  443. that.type=0;
  444. } else if (res.cancel) {
  445. }
  446. }
  447. });
  448. },
  449. getImport(){
  450. // 判断是否有值
  451. // console.log(this.scoreDataDetailsList,1)
  452. if(this.scoreDataDetailsList&&this.scoreDataDetailsList.length>0){//录入
  453. this.type=6
  454. }else if(this.file&&this.file.length>0){// 导入
  455. this.type=6
  456. }else{
  457. this.type=1;
  458. }
  459. },
  460. getEnter(e){
  461. this.type=0;
  462. this.importtype=e;
  463. if(e==1){
  464. this.$tab.navigateTo('/mine/pages/release/format');
  465. }else{
  466. this.$tab.navigateTo('/mine/pages/release/entry?scoreClassId='+this.datainfo.scoreClassId);
  467. }
  468. },
  469. getConfirm(){
  470. this.$tab.navigateTo('/mine/pages/release/entry');
  471. this.type=0;
  472. },
  473. getClose(){
  474. this.type=0;
  475. }
  476. },
  477. }
  478. </script>
  479. <style lang="scss" scoped>
  480. .addfb{min-height: 100vh;padding: 160rpx 36rpx 168rpx;box-sizing: border-box;
  481. .card{width: 100%;padding: 40rpx 24rpx 36rpx;box-sizing: border-box;background: #FFFFFF;
  482. border-radius: 18rpx;margin-bottom: 24rpx;
  483. .tit{font-size: 32rpx;font-weight: bold;color: #161616;margin-bottom: 28rpx;}
  484. }
  485. .bjlist{display: flex;align-items: center;padding: 8rpx 26rpx;
  486. image{width: 30rpx;height: 28rpx;margin-right:26rpx;flex: 0 0 auto;}
  487. }
  488. .cttit{font-size: 32rpx;font-weight: bold;color: #000016;flex: 0 0 auto;margin-right: 12rpx;line-height: 48rpx;}
  489. .ctinp{flex: 1;text-align: right;font-size: 32rpx;color: #161616;}
  490. .addbtn{width: 100%;height: 110rpx;background: #EEF3FE;border-radius: 10rpx;font-size: 30rpx;font-weight: bold;
  491. color: #4775EA;
  492. .addimg{width: 22rpx;height: 22rpx;margin-right: 20rpx;}
  493. }
  494. .openimg{width: 100rpx;height: 56rpx;flex: 0 0 auto;margin-left: 16rpx;}
  495. .fbtn{display: flex;align-items: center;position: fixed;left: 0;right: 0;bottom: 0;background-color: #f1f1f1;padding: 34rpx;
  496. .fbtnl{padding: 0 16rpx;flex: 0 0 auto;margin-right: 20rpx;
  497. image{width: 42rpx;height: 42rpx;margin-bottom: 8rpx;}
  498. }
  499. .fbtnr{height: 98rpx;background: #1f57e6;border-radius: 48rpx;font-size: 34rpx;font-weight: 500;
  500. color: #FFFFFF;flex: 1;}
  501. }
  502. // .ccgimg{}
  503. }
  504. </style>