Browse Source

Merge remote-tracking branch 'origin/master'

liuyang 5 years ago
parent
commit
111a0883c9
2 changed files with 115 additions and 95 deletions
  1. 111 89
      frontend_web/src/views/duty/detail/index.vue
  2. 4 6
      frontend_web/src/views/duty/index.vue

+ 111 - 89
frontend_web/src/views/duty/detail/index.vue

@@ -2,45 +2,30 @@
   <d2-container>
     <template slot="header"
               style="padding: 5px;">
-      <el-form size="mini"
-               :model="dutyDetail"
+      <el-form :model="dutyDetail"
                label-width="100px">
         <el-row :gutter="20">
           <el-col :span="8">
             <el-form-item label="学年"
                           label-width="120px">
-              <el-select placeholder="请选择学年"
-                         style="width:100%"
-                         v-model="year">
-                <el-option v-for="item in years"
-                           :key="item.value"
-                           :label="item.label"
-                           :value="item.value">
-                </el-option>
-              </el-select>
+              {{dutyDetail.Year}}年
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="学期"
                           label-width="120px">
-              <el-input placeholder="请输入"
-                        style="width:100%"></el-input>
+              {{this.termName}}
             </el-form-item>
           </el-col>
           <el-col :span="8">
-            <el-form-item label="地点"
-                          prop="Local"
+            <el-form-item label="标题"
                           label-width="120px">
-              <el-checkbox-group v-model="dutyDetail.Local">
-                <el-checkbox v-for="item in LocalList"
-                             :label="item.ItemValue"
-                             :key="item.ItemValue">{{item.ItemName}}</el-checkbox>
-              </el-checkbox-group>
+              {{dutyDetail.Title}}
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="值班人员"
-                          prop="People"
+                          size="mini"
                           label-width="120px">
               <el-tag @click="personClick(item.ItemValue)"
                       v-for="item in PeopleList"
@@ -50,10 +35,22 @@
 
           </el-col>
           <el-col :span="8">
-            <el-form-item label="课程时间"
-                          prop="Time"
+            <el-form-item label="地点"
+                          size="mini"
+                          label-width="120px">
+              <el-checkbox-group v-model="selectLocal">
+                <el-checkbox v-for="item in LocalList"
+                             :label="item.ItemValue"
+                             :key="item.ItemValue">{{item.ItemName}}</el-checkbox>
+              </el-checkbox-group>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="8">
+            <el-form-item label="值班时间"
+                          size="mini"
                           label-width="120px">
-              <el-checkbox-group v-model="dutyDetail.Time">
+              <el-checkbox-group v-model="selectTime">
                 <el-checkbox v-for="item in TimeList"
                              :label="item.ItemValue"
                              :key="item.ItemValue">{{item.ItemName}}</el-checkbox>
@@ -61,15 +58,19 @@
             </el-form-item>
           </el-col>
         </el-row>
+        <el-button size="mini"
+                   @click="addList()"
+                   type="success"
+                   style="margin-right:6px">生成表格</el-button>
+        <!-- <el-button icon="el-icon-delete"
+                   size="mini"
+                   >删除</el-button> -->
         <el-button size="mini"
                    type="primary"
                    style="margin-left:10px"
                    @click="addDuytDetail()">保存</el-button>
         <el-button size="mini"
                    style="margin-right:6px">返回</el-button>
-        <el-button size="mini"
-                   @click="addList()"
-                   style="margin-right:6px">生成表格</el-button>
       </el-form>
     </template>
     <el-table :data="list"
@@ -83,55 +84,55 @@
               :cell-class-name="cellBg"
               :key="refresh">
       <el-table-column fit
-                       prop="position"
+                       prop="Local"
                        min-width="160px"
                        label="地点"
                        align="center"
                        show-overflow-tooltip
                        :formatter="formatLocal"></el-table-column>
-      <el-table-column prop="time"
+      <el-table-column prop="Time"
                        label="时间段"
                        align="center"
                        min-width="120px"
                        show-overflow-tooltip
                        :formatter="formatTime"></el-table-column>
-      <el-table-column prop="mo"
+      <el-table-column prop="Monday"
                        label="周一"
                        align="center"
                        min-width="120px"
                        show-overflow-tooltip
                        :formatter="formatPerson"></el-table-column>
-      <el-table-column prop="tu"
+      <el-table-column prop="Tuesday"
                        label="周二"
                        align="center"
                        min-width="120px"
                        show-overflow-tooltip
                        :formatter="formatPerson"></el-table-column>
-      <el-table-column prop="we"
+      <el-table-column prop="Wednesday"
                        label="周三"
                        align="center"
                        min-width="120px"
                        show-overflow-tooltip
                        :formatter="formatPerson"></el-table-column>
-      <el-table-column prop="th"
+      <el-table-column prop="Thursday"
                        label="周四"
                        align="center"
                        min-width="120px"
                        show-overflow-tooltip
                        :formatter="formatPerson"></el-table-column>
-      <el-table-column prop="fr"
+      <el-table-column prop="Friday"
                        label="周五"
                        align="center"
                        min-width="120px"
                        show-overflow-tooltip
                        :formatter="formatPerson"></el-table-column>
-      <el-table-column prop="sa"
+      <el-table-column prop="Saturday"
                        label="周六"
                        align="center"
                        min-width="120px"
                        show-overflow-tooltip
                        :formatter="formatPerson"></el-table-column>
-      <el-table-column prop="su"
+      <el-table-column prop="Sunday"
                        label="周日"
                        align="center"
                        min-width="120px"
@@ -147,15 +148,15 @@ const columnNum = 9
 const fixRowHeadNum = 2
 // todo 欠优化 列属性对应
 const columnProperty = [
-  'position',
-  'time',
-  'mo',
-  'tu',
-  'we',
-  'th',
-  'fr',
-  'sa',
-  'su'
+  'Local',
+  'Time',
+  'Monday',
+  'Tuesday',
+  'Wednesday',
+  'Thursday',
+  'Friday',
+  'Saturday',
+  'Sunday'
 ]
 import DutyApi from '@/api/duty'
 import itemDetailApi from '@/api/sysadmin/itemdetail'
@@ -167,24 +168,16 @@ export default {
       LocalList: [],
       PeopleList: [],
       TimeList: [],
+      termList: [],
+      termName: '',
+      selectLocal: [],
+      selectTime: [],
       dutyDetail: {
-        Id: '',
-        DutyId: '',
-        Local: [],
-        Time: [],
-        Status: '',
-        People: [],
-        Monday: '',
-        Tuesday: '',
-        Wednesday: '',
-        Thursday: '',
-        Friday: '',
-        Saturday: '',
-        Sunday: ''
+        Id: -1,
+        Year: -1,
+        Term: -1,
       },
       year: '',
-      edit: { year: 1 },
-      persons: [],
       years: [],
       dialogvisible: false,
       // 刷新标志 刷新表格样式
@@ -202,36 +195,44 @@ export default {
     this.getLocal()
     this.getPeople()
     this.getDutyTime()
+    let _this = this
+    _this.dutyDetail = _this.$route.query.duty
+    _this.termList = _this.$route.query.term
+    this.getTerm()
   },
   methods: {
     // 新增表格
     addList () {
-      if (this.dutyDetail.Local.length > 0 && this.dutyDetail.Local.Time) {
+      if (this.selectLocal == 0 && this.selectTime.length == 0) {
         return
       }
       this.list = []
+      this.selectcell = new Map()
       let _this = this
-      this.dutyDetail.Local.forEach(function (value, key) {
-        _this.dutyDetail.Time.forEach(function (valuee, keyy) {
+      this.selectLocal.forEach(function (value, key) {
+        _this.selectTime.forEach(function (valuee, keyy) {
           _this.list.push({
-            position: value,
-            time: valuee,
-            mo: 0,
-            tu: 0,
-            we: 0,
-            th: 0,
-            fr: 0,
-            sa: 0,
-            su: 0
+            DutyId: _this.dutyDetail.Id,
+            Local: value,
+            Time: valuee,
+            Monday: 0,
+            Tuesday: 0,
+            Wednesday: 0,
+            Thursday: 0,
+            Friday: 0,
+            Saturday: 0,
+            Sunday: 0
           })
         })
       })
     },
     // 保存值班子表信息
     addDuytDetail () {
-      if (valid) {
-        DutyApi.addDetail(this.dutyDetail, {})
+      let _this = this
+      if (this.dutyDetail.Id) {
+        DutyApi.addDetail(this.list)
           .then(res => {
+
           })
           .catch(err => {
             // handle error
@@ -244,10 +245,10 @@ export default {
     },
     // 获取字典表地点
     getLocal () {
+      let _this = this
       itemDetailApi.getItemDetailByItemCode({ ItemCode: 'Local' })
         .then(res => {
-          this.LocalList = res
-
+          _this.LocalList = res
         })
         .catch(err => {
           console.error(err)
@@ -255,9 +256,10 @@ export default {
     },
     // 获取字典表值班人员
     getPeople () {
+      let _this = this
       itemDetailApi.getItemDetailByItemCode({ ItemCode: 'People' })
         .then(res => {
-          this.PeopleList = res
+          _this.PeopleList = res
         })
         .catch(err => {
           console.error(err)
@@ -265,9 +267,10 @@ export default {
     },
     // 获取字典表课程时间段
     getDutyTime () {
+      let _this = this
       itemDetailApi.getItemDetailByItemCode({ ItemCode: 'DutyTime' })
         .then(res => {
-          this.TimeList = res
+          _this.TimeList = res
         })
         .catch(err => {
           console.error(err)
@@ -291,10 +294,10 @@ export default {
       // 第3列开始可以选中
       // 单击单元格选中
       if (cell.cellIndex >= fixRowHeadNum) {
-        if (this.selectcell.get(row.index + '_' + column.property)) {
-          this.selectcell.set(row.index + '_' + column.property, false)
+        if (this.selectcell.get(row.Local + '_' + row.Time + '_' + column.property)) {
+          this.selectcell.set(row.Local + '_' + row.Time + '_' + column.property, false)
         } else {
-          this.selectcell.set(row.index + '_' + column.property, this.list[row.index])
+          this.selectcell.set(row.Local + '_' + row.Time + '_' + column.property, this.list[row.index])
         }
       }
       // 第三列之前选中整行
@@ -306,10 +309,10 @@ export default {
           var nextSibling = cell.nextSibling
           cell = nextSibling
           if (i >= fixRowHeadNum - 1) {
-            if (this.selectcell.get(row.index + '_' + columnProperty[currentcolumnindex])) {
-              this.selectcell.set(row.index + '_' + columnProperty[currentcolumnindex], false)
+            if (this.selectcell.get(row.Local + '_' + row.Time + '_' + columnProperty[currentcolumnindex])) {
+              this.selectcell.set(row.Local + '_' + row.Time + '_' + columnProperty[currentcolumnindex], false)
             } else {
-              this.selectcell.set(row.index + '_' + columnProperty[currentcolumnindex], this.list[row.index])
+              this.selectcell.set(row.Local + '_' + row.Time + '_' + columnProperty[currentcolumnindex], this.list[row.index])
             }
           }
         }
@@ -321,10 +324,10 @@ export default {
       // 判断是否为可选列
       if (column.index > fixRowHeadNum - 1) {
         for (var i = 0; i < this.list.length; i++) {
-          if (this.selectcell.get(i + '_' + column.property)) {
-            this.selectcell.set(i + '_' + column.property, false)
+          if (this.selectcell.get(this.list[i].Local + '_' + this.list[i].Time + '_' + column.property)) {
+            this.selectcell.set(this.list[i].Local + '_' + this.list[i].Time + '_' + column.property, false)
           } else {
-            this.selectcell.set(i + '_' + column.property, this.list[i])
+            this.selectcell.set(this.list[i].Local + '_' + this.list[i].Time + '_' + column.property, this.list[i])
           }
         }
       }
@@ -335,7 +338,7 @@ export default {
       this.selectcell.forEach(function (value, key) {
         if (value) {
           var property = key.split('_')
-          value[property[1]] = person
+          value[property[2]] = person
         }
       })
       this.selectcell = new Map()
@@ -348,10 +351,29 @@ export default {
       // 注意这里是解构
       // 利用单元格的 className 的回调方法,给行列索引赋值
 
-      if (_this.selectcell.get(row.index + '_' + column.property)) {
+      if (_this.selectcell.get(row.Local + '_' + row.Time + '_' + column.property)) {
         return 'selectedCell'
       }
     },
+    // 匹配学期
+    formatTerm (row, column) {
+      for (var i = 0; i < this.termList.length; i++) {
+        if (parseInt(this.termList[i].ItemValue) === parseInt(row.Term)) {
+          return this.termList[i].ItemName
+        }
+      }
+    },
+    // 获取学期名称
+    getTerm () {
+      let termName = ''
+      let _this = this
+      _this.termList.forEach(function (value, key) {
+        if (_this.dutyDetail.Term == value.ItemValue) {
+          _this.termName = value.ItemName
+
+        }
+      })
+    },
     formatPerson (row, column, cellValue, index) {
       let label = '休息'
       for (var i = 0; i < this.PeopleList.length; i++) {

+ 4 - 6
frontend_web/src/views/duty/index.vue

@@ -91,8 +91,7 @@
                        align="center"
                        min-width="80px"
                        show-overflow-tooltip
-                       :formatter="formatTerm"
-      ></el-table-column>
+                       :formatter="formatTerm"></el-table-column>
       <el-table-column prop="Title"
                        label="标题"
                        align="center"
@@ -103,8 +102,7 @@
                        align="center"
                        min-width="80px"
                        show-overflow-tooltip
-                       :formatter="formatStatus"
-      ></el-table-column>
+                       :formatter="formatStatus"></el-table-column>
       <el-table-column prop="CreatedTime"
                        label="创建日期"
                        align="center"
@@ -149,6 +147,7 @@ export default {
       dutyId: -1,
       details: false,
       statusList: [],
+      activities: [],
       totalsize: 0,
       currpage: 1,
       size: 10,
@@ -233,8 +232,7 @@ export default {
     },
     // 打开二级页面
     handleDetail (duty) {
-      let Id = parseInt(duty.Id)
-      this.$router.push({ path: '/duty/detail', query: { duty: duty } })
+      this.$router.push({ path: '/duty/detail', query: { duty: duty, term: this.term } })
     },
     // 添加 返回页面
     handleCloseAdd () {