limengbo hace 5 años
padre
commit
cce54e0f33

+ 0 - 5
src/store/getters.js

@@ -9,15 +9,10 @@ const getters = {
   getScheduleData: state => state.schoolTimetable.getScheduleData,
   getScheduleDataLength: state => state.schoolTimetable.getScheduleDataLength,
   getScheduleWareData: state => state.schoolTimetable.getScheduleWareData,
-  getScheduleWareDataLength: state => state.schoolTimetable.getScheduleWareDataLength,
   getBlockData: state => state.dashboard.getBlockData,
-  getBlockDataLength: state => state.dashboard.getBlockDataLength,
   getBlockRowData: state => state.dashboard.getBlockRowData,
-  getBlockRowDataLength: state => state.dashboard.getBlockRowDataLength,
   getRowItemData: state => state.dashboard.getRowItemData,
-  getRowItemDataLength: state => state.dashboard.getRowItemDataLength,
   getTempateData: state => state.dashboard.getTempateData,
-  getTempateDataLength: state => state.dashboard.getTempateDataLength,
   getCategoryData: state => state.categoryList.getCategoryData,
   getCategoryDataLength: state => state.categoryList.getCategoryDataLength,
   getMemberData: state => state.memberList.getMemberData,

+ 4 - 28
src/store/modules/dashboard.js

@@ -2,51 +2,33 @@ import { getBlock, getBlockRow, getRowItem, setBlockRow, addBlockRow, setRowItem
 
 const state = {
   getBlockData: [],
-  getBlockDataLength: 0,
   getBlockRowData: [],
-  getBlockRowDataLength: 0,
   getRowItemData: [],
-  getRowItemDataLength: 0,
   getTempateData: [],
-  getTempateDataLength: 0
 }
 
 const mutations = {
   GET_BLOCK: (state, data) => {
     state.getBlockData = data
   },
-  GET_BLOCK_LENGTH: (state, length) => {
-    state.getBlockDataLength = length
-  },
   GET_BLOCK_ROW: (state, data) => {
     state.getBlockRowData = data
   },
-  BLOCK_ROW_LENGTH: (state, length) => {
-    state.getBlockRowDataLength = length
-  },
   GET_ROW_ITEM: (state, data) => {
     state.getRowItemData = data
   },
-  ROW_ITEM__LENGTH: (state, length) => {
-    state.getRowItemDataLength = length
-  },
   GET_TEMPATE: (state, data) => {
     state.getTempateData = data
-  },
-  TEMPATE__LENGTH: (state, length) => {
-    state.getTempateDataLength = length
   }
 }
 
 const actions = {
   // 获取课程表列表
   getBlockList({ commit, state }, obj) {
-    const page = (obj.page - 1) * 10
     return new Promise((resolve, reject) => {
       getBlock().then((res) => {
         const list = res.data
-        commit('GET_BLOCK_LENGTH', list.length)
-        commit('GET_BLOCK', list.splice(page, 10))
+        commit('GET_BLOCK', list)
         resolve()
       }).catch(error => {
         reject(error)
@@ -56,13 +38,11 @@ const actions = {
   // 获取课程表行列表
   getBlockRowList({ commit, state }, obj) {
     const id = obj.id
-    const page = (obj.page - 1) * 10
     return new Promise((resolve, reject) => {
       getBlockRow(id).then((res) => {
         console.log(res)
         const list = res.data
-        commit('BLOCK_ROW_LENGTH', list.length)
-        commit('GET_BLOCK_ROW', list.splice(page, 10))
+        commit('GET_BLOCK_ROW', list)
         resolve()
       }).catch(error => {
         reject(error)
@@ -72,13 +52,11 @@ const actions = {
   // 获取首页项列表
   getRowItemList({ commit, state }, obj) {
     const id = obj.id
-    const page = (obj.page - 1) * 10
     return new Promise((resolve, reject) => {
       getRowItem(id).then((res) => {
         console.log(res)
         const list = res.data
-        commit('ROW_ITEM__LENGTH', list.length)
-        commit('GET_ROW_ITEM', list.splice(page, 10))
+        commit('GET_ROW_ITEM', list)
         resolve()
       }).catch(error => {
         reject(error)
@@ -139,12 +117,10 @@ const actions = {
   },
   // 获取课程表模板
   getTempateList({ commit, state }, obj) {
-    const page = (obj.page - 1) * 10
     return new Promise((resolve, reject) => {
       getTempate().then((res) => {
         const list = res.data
-        commit('TEMPATE__LENGTH', list.length)
-        commit('GET_TEMPATE', list.splice(page, 10))
+        commit('GET_TEMPATE', list)
         resolve()
       }).catch(error => {
         reject(error)

+ 2 - 8
src/store/modules/schoolTimetable.js

@@ -3,8 +3,7 @@ import { getSchedule, getScheduleWare, setSchedule, setScheduleWare } from '@/ap
 const state = {
   getScheduleData: [],
   getScheduleDataLength: 0,
-  getScheduleWareData: [],
-  getScheduleWareDataLength: 0
+  getScheduleWareData: []
 }
 
 const mutations = {
@@ -17,9 +16,6 @@ const mutations = {
   GET_SCHEDULE_WARE: (state, data) => {
     console.log(data)
     state.getScheduleWareData = data
-  },
-  SCHEDULE_WARE_LENGTH: (state, length) => {
-    state.getScheduleWareDataLength = length
   }
 }
 
@@ -46,14 +42,12 @@ const actions = {
   },
   // 获取课程表详情
   getScheduleWare({ commit, state }, obj) {
-    const page = (obj.page - 1) * 10
     return new Promise((resolve, reject) => {
       getScheduleWare({
         scheduleId: obj.id
       }).then((res) => {
         const data = res.data
-        commit('SCHEDULE_WARE_LENGTH', data.length)
-        commit('GET_SCHEDULE_WARE', data.splice(page, 10))
+        commit('GET_SCHEDULE_WARE', data)
         resolve()
       }).catch(error => {
         reject(error)

+ 2 - 23
src/views/dashboard/index.vue

@@ -48,12 +48,6 @@
           </template>
         </el-table-column>
       </el-table>
-      <el-pagination
-        background
-        layout="prev, pager, next"
-        :total="getBlockDataLength"
-        @current-change="handleCurrentChange"
-      />
     </div>
   </div>
 </template>
@@ -63,21 +57,13 @@ import { mapGetters } from 'vuex'
 
 export default {
   name: 'Dashboard',
-  data() {
-    return {
-      page: 1
-    }
-  },
   created() {
-    this.$store.dispatch('dashboard/getBlockList', {
-      page: this.page
-    })
+    this.$store.dispatch('dashboard/getBlockList')
   },
   // eslint-disable-next-line vue/order-in-components
   computed: {
     ...mapGetters([
-      'getBlockData',
-      'getBlockDataLength'
+      'getBlockData'
     ])
   },
   methods: {
@@ -92,13 +78,6 @@ export default {
           id: row.id
         }
       })
-    },
-    handleCurrentChange(val) {
-      console.log(val)
-      this.page = val
-      this.$store.dispatch('dashboard/getBlockList', {
-        page: this.page
-      })
     }
   }
 }

+ 6 - 26
src/views/dashboardBlockRow/index.vue

@@ -103,12 +103,6 @@
           <el-button type="primary" @click="handOk('ruleForm')">确 定</el-button>
         </div>
       </el-dialog>
-      <el-pagination
-        background
-        layout="prev, pager, next"
-        :total="getBlockRowDataLength"
-        @current-change="handleCurrentChange"
-      />
     </div>
   </div>
 </template>
@@ -134,21 +128,18 @@ export default {
         sort: [
           { required: true, message: '请输入排序', trigger: 'blur' }
         ]
-      },
-      page: 1
+      }
     }
   },
   created() {
     this.$store.dispatch('dashboard/getBlockRowList', {
-      id: this.$route.query.id,
-      page: this.page
+      id: this.$route.query.id
     })
   },
   // eslint-disable-next-line vue/order-in-components
   computed: {
     ...mapGetters([
-      'getBlockRowData',
-      'getBlockRowDataLength'
+      'getBlockRowData'
     ])
   },
   methods: {
@@ -226,8 +217,7 @@ export default {
       this.form.status = row.status === 'NOT_ON_STOCK' ? 'HAS_ON_STOCK' : 'NOT_ON_STOCK'
       this.$store.dispatch('dashboard/setBlockRowList', this.form).then(() => {
         this.$store.dispatch('dashboard/getBlockRowList', {
-          id: this.$route.query.id,
-          page: this.page
+          id: this.$route.query.id
         })
       })
     },
@@ -248,16 +238,14 @@ export default {
             this.$store.dispatch('dashboard/setBlockRowList', this.form).then(() => {
               this.dialogFormVisible = false
               this.$store.dispatch('dashboard/getBlockRowList', {
-                id: this.$route.query.id,
-                page: this.page
+                id: this.$route.query.id
               })
             })
           } else {
             this.$store.dispatch('dashboard/addBlockRowList', this.form).then(() => {
               this.dialogFormVisible = false
               this.$store.dispatch('dashboard/getBlockRowList', {
-                id: this.$route.query.id,
-                page: this.page
+                id: this.$route.query.id
               })
             })
           }
@@ -277,14 +265,6 @@ export default {
         sort: ''
       }
     },
-    handleCurrentChange(val) {
-      console.log(val)
-      this.page = val
-      this.$store.dispatch('dashboard/getBlockRowList', {
-        id: this.$route.query.id,
-        page: this.page
-      })
-    },
     setForm(data) {
       this.form.id = data.id
       this.form.blockId = data.blockId

+ 1 - 17
src/views/dashboardRowItem/index.vue

@@ -109,12 +109,6 @@
           <el-button type="primary" @click="handOk('ruleForm')">确 定</el-button>
         </div>
       </el-dialog>
-      <el-pagination
-        background
-        layout="prev, pager, next"
-        :total="getRowItemDataLength"
-        @current-change="handleCurrentChange"
-      />
     </div>
   </div>
 </template>
@@ -130,7 +124,6 @@ export default {
       dialogFormVisible: false,
       type: '',
       formLabelWidth: '120px',
-      page: 1,
       rules: {
         content: [
           { required: true, message: '请输入项目名称', trigger: 'blur' }
@@ -155,8 +148,7 @@ export default {
   // eslint-disable-next-line vue/order-in-components
   computed: {
     ...mapGetters([
-      'getRowItemData',
-      'getRowItemDataLength'
+      'getRowItemData'
     ])
   },
   methods: {
@@ -300,14 +292,6 @@ export default {
         }
       })
     },
-    handleCurrentChange(val) {
-      console.log(val)
-      this.page = val
-      this.$store.dispatch('dashboard/getRowItemList', {
-        id: this.$route.query.id,
-        page: this.page
-      })
-    },
     setForm(data) {
       this.form = {
         'id': data.id,

+ 5 - 24
src/views/schoolDetail/index.vue

@@ -101,12 +101,6 @@
           <el-button type="primary" @click="handOk">确 定</el-button>
         </div>
       </el-dialog>
-      <el-pagination
-        background
-        layout="prev, pager, next"
-        :total="getScheduleWareDataLength"
-        @current-change="handleCurrentChange"
-      />
     </div>
   </div>
 </template>
@@ -126,23 +120,20 @@ export default {
         free: ''
       },
       formLabelWidth: '120px',
-      sheduleId: '',
-      page: 1
+      sheduleId: ''
     }
   },
   created() {
     console.log(this.$route.query.id)
     this.sheduleId = this.$route.query.id
     this.$store.dispatch('schoolTimetable/getScheduleWare', {
-      id: this.$route.query.id,
-      page: this.page
+      id: this.$route.query.id
     })
   },
   // eslint-disable-next-line vue/order-in-components
   computed: {
     ...mapGetters([
-      'getScheduleWareData',
-      'getScheduleWareDataLength'
+      'getScheduleWareData'
     ])
   },
   methods: {
@@ -222,8 +213,7 @@ export default {
       if (this.form.title !== '' || this.form.subTitle !== '' || this.form.url !== '' || this.form.free !== '') {
         this.$store.dispatch('schoolTimetable/setScheduleWare', this.form).then(() => {
           this.$store.dispatch('schoolTimetable/getScheduleWare', {
-            id: this.sheduleId,
-            page: this.page
+            id: this.sheduleId
           })
         })
       }
@@ -233,20 +223,11 @@ export default {
         this.$store.dispatch('schoolTimetable/setScheduleWare', this.form).then(() => {
           this.dialogFormVisible = false
           this.$store.dispatch('schoolTimetable/getScheduleWare', {
-            id: this.sheduleId,
-            page: this.page
+            id: this.sheduleId
           })
         })
       }
     },
-    handleCurrentChange(val) {
-      console.log(val)
-      this.page = val
-      this.$store.dispatch('schoolTimetable/getScheduleWare', {
-        id: this.sheduleId,
-        page: this.page
-      })
-    },
     setForm(data) {
       this.form.id = data.id
       this.form.url = data.url

+ 4 - 22
src/views/tempateList/index.vue

@@ -83,12 +83,6 @@
           <el-button type="primary" @click="handOk">确 定</el-button>
         </div>
       </el-dialog>
-      <el-pagination
-        background
-        layout="prev, pager, next"
-        :total="getTempateDataLength"
-        @current-change="handleCurrentChange"
-      />
     </div>
   </div>
 </template>
@@ -103,20 +97,16 @@ export default {
       form: {},
       dialogFormVisible: false,
       type: '',
-      formLabelWidth: '120px',
-      page: 1
+      formLabelWidth: '120px'
     }
   },
   created() {
-    this.$store.dispatch('dashboard/getTempateList', {
-      page: this.page
-    })
+    this.$store.dispatch('dashboard/getTempateList')
   },
   // eslint-disable-next-line vue/order-in-components
   computed: {
     ...mapGetters([
-      'getTempateData',
-      'getTempateDataLength'
+      'getTempateData'
     ])
   },
   methods: {
@@ -152,9 +142,7 @@ export default {
         console.log(this.form)
         this.$store.dispatch('dashboard/setTempateList', this.form).then(() => {
           this.dialogFormVisible = false
-          this.$store.dispatch('dashboard/getTempateList', {
-            page: this.page
-          })
+          this.$store.dispatch('dashboard/getTempateList')
         })
       } else if (this.form.templateCode !== '' && this.form.status !== '' && this.form.sort !== '') {
         // this.$store.dispatch('dashboard/addBlockRowList', this.form).then(() => {
@@ -165,12 +153,6 @@ export default {
         // })
       }
     },
-    handleCurrentChange(val) {
-      this.page = val
-      this.$store.dispatch('dashboard/getTempateList', {
-        page: this.page
-      })
-    },
     setForm(data) {
       this.form = {
         'id': data.id,

+ 33 - 25
src/views/uploadTab/index.vue

@@ -15,23 +15,24 @@
         <el-input v-model="ruleForm.title" clearable />
       </el-form-item>
       <el-form-item label="周" prop="weekSeq">
-        <el-input v-model="ruleForm.weekSeq" clearable />
+        <el-input v-model="ruleForm.weekSeq" placeholder="202001" clearable />
+      </el-form-item>
+      <el-form-item label="导入课程表">
+        <el-upload
+          ref="upload"
+          class="image-uploader"
+          :multiple="false"
+          action="http://ott80test-api.efunbox.cn:81/cms/schedule/import"
+          :limit="1"
+          :on-exceed="handleExceed"
+          :data="ruleForm"
+          :auto-upload="false"
+          :on-success="handleAvatarSuccess"
+        >
+          <el-button size="small" type="primary">点击上传</el-button>
+          <div slot="tip" class="el-upload__tip">只能上传xls/xlsx文件</div>
+        </el-upload>
       </el-form-item>
-      <el-upload
-        ref="upload"
-        class="image-uploader"
-        :multiple="false"
-        :drag="true"
-        action="http://ott80test-api.efunbox.cn:81/cms/schedule/import"
-        :limit="1"
-        :on-exceed="handleExceed"
-        :data="ruleForm"
-        :auto-upload="false"
-        :on-success="handleAvatarSuccess"
-      >
-        <i class="el-icon-upload" />
-        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
-      </el-upload>
       <el-form-item>
         <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
         <el-button @click="resetForm('ruleForm')">重置</el-button>
@@ -91,23 +92,30 @@ export default {
       }
       return grade
     },
-    // 上传文件之前的钩子
-    beforeUpload(file) {
-      console.log('beforeUpload')
-      console.log(file.type)
-      const isText = file.type === 'application/vnd.ms-excel'
-      const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
-      return (isText | isTextComputer)
-    },
     // 上传文件个数超过定义的数量
     handleExceed(files, fileList) {
       this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`)
     },
     submitForm(formName) {
+      console.log(this.$refs[formName])
       this.$refs[formName].validate((valid) => {
         if (valid) {
           console.log(this.ruleForm)
-          this.$refs.upload.submit()
+          console.log(this.$refs.upload.uploadFiles)
+          const regx = new RegExp('(.xlsx)$|(.xls)$')
+          if (!this.$refs.upload.uploadFiles.length) {
+            this.$message({
+              message: '请选择要上传的文件',
+              type: 'error'
+            })
+          } else if (!regx.test(this.$refs.upload.uploadFiles[this.$refs.upload.uploadFiles.length - 1].name)) {
+            this.$message({
+              message: '文件格式只支持xlsx、xls',
+              type: 'error'
+            })
+          } else {
+            this.$refs.upload.submit()
+          }
         } else {
           console.log('error submit!!')
           return false