Browse Source

Signed-off-by: 1004749546@qq.com <1004749546@qq.com>
考评方案提交

1004749546@qq.com 4 years ago
parent
commit
acea9173e5
1 changed files with 77 additions and 73 deletions
  1. 77 73
      src/views/evaluationPlan/SetEvaModal.vue

+ 77 - 73
src/views/evaluationPlan/SetEvaModal.vue

@@ -4,7 +4,7 @@
       <a-row :gutter="24">
       <a-row :gutter="24">
         <a-col class="title" :span="20">
         <a-col class="title" :span="20">
           <!-- 考评方案名称 -->
           <!-- 考评方案名称 -->
-          <span >考评方案名称:</span>
+          <span>考评方案名称:</span>
         </a-col>
         </a-col>
       </a-row>
       </a-row>
       <a-row :gutter="24">
       <a-row :gutter="24">
@@ -13,12 +13,13 @@
             <a-col :span="15">
             <a-col :span="15">
               <p>已选考评项目:</p>
               <p>已选考评项目:</p>
               <!-- 已选考评项列表 -->
               <!-- 已选考评项列表 -->
-              <s-table
+              <a-table
                 ref="table"
                 ref="table"
                 size="default"
                 size="default"
+                :pagination="false"
                 :rowKey="(record) => record.id"
                 :rowKey="(record) => record.id"
                 :columns="columns"
                 :columns="columns"
-                :data="loadData"
+                :dataSource="checkedList"
                 bordered>
                 bordered>
                 <!-- 操作 -->
                 <!-- 操作 -->
                 <template slot="action" slot-scope="text, record, index">
                 <template slot="action" slot-scope="text, record, index">
@@ -55,7 +56,7 @@
                     v-if="index < checkedList.length-1"
                     v-if="index < checkedList.length-1"
                     icon="down">置底</a-button>
                     icon="down">置底</a-button>
                 </template>
                 </template>
-              </s-table>
+              </a-table>
 
 
             </a-col>
             </a-col>
             <a-col span="1" class="divider">
             <a-col span="1" class="divider">
@@ -67,8 +68,6 @@
               <s-table
               <s-table
                 ref="tableItem"
                 ref="tableItem"
                 size="default"
                 size="default"
-                columnTitle="选择"
-                hideDefaultSelections
                 :row-selection="rowSelection"
                 :row-selection="rowSelection"
                 :rowKey="(record) => record.id"
                 :rowKey="(record) => record.id"
                 :columns="itemColumns"
                 :columns="itemColumns"
@@ -128,25 +127,49 @@ export default {
     },
     },
     isshow (newValue, oldValue) {
     isshow (newValue, oldValue) {
       if (newValue) {
       if (newValue) {
-
+        // 获取已选列表数据
+        this.getCheckedList()
+        // 刷新考评项列表数据
+        this.$refs.tableItem.refresh()
       } else {
       } else {
         this.cancel()
         this.cancel()
       }
       }
     }
     }
   },
   },
   computed: {
   computed: {
+    // 已选择的复选框
+    selectedRowKeys () {
+      const arr = []
+      this.checkedList.map(item => {
+        arr.push(item.id)
+      })
+      return arr
+    },
+    // 列表项是否可选择的配置
     rowSelection () {
     rowSelection () {
       return {
       return {
+        columnTitle: '选择', // 选择框标题
+        columnWidth: 80, // 选择框宽度
+        selectedRowKeys: this.selectedRowKeys, // 指定选中项的 key 数组
+        // 选中项发生变化时的回调 selectedRowKeys:指定选中项的 key 数组 selectedRows:已选中的数组数据
         onChange: (selectedRowKeys, selectedRows) => {
         onChange: (selectedRowKeys, selectedRows) => {
-          // if (this.checkedList.length) {
-          //   return this.checkedList
-          // }
-          console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
+          const arr = []
+          let index = 0
+		  // 根据选择项的顺序展示已选列表
+          selectedRowKeys.map(item => {
+            index++
+            const p = selectedRows.find(row => row.id == item)
+            if (p) {
+              p.no = index
+              arr.push(p)
+            }
+          })
+          this.checkedList = arr
+          // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
         },
         },
         getCheckboxProps: record => ({
         getCheckboxProps: record => ({
           props: {
           props: {
-            disabled: record.status == '0', // 禁用状态不可选
-            checked: this.checkedList.find(item => item.id == record.id) // 默认是否选中
+            disabled: record.status == '0' // 禁用状态不可选
           }
           }
         })
         })
       }
       }
@@ -186,37 +209,21 @@ export default {
         }
         }
       }
       }
       ],
       ],
-      // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        return getTenantsList(Object.assign(parameter, this.itemId)).then(res => {
-          if (res.status == 200) {
-            const no = (res.data.pageNo - 1) * res.data.pageSize
-            for (let i = 0; i < res.data.list.length; i++) {
-              const _item = res.data.list[i]
-              _item.no = no + i + 1
-              _item.status = _item.status + '' === '1'
-            }
-            this.checkedList = res.data.list
-            return res.data
-          }
-        })
+      // 考评项列表数据
+      itemColumns: [{
+        title: '考评项目名称',
+        dataIndex: 'name',
+        align: 'center'
       },
       },
-      // 考评项列表
-      itemColumns: [
-        {
-          title: '考评项目名称',
-          dataIndex: 'name',
-          align: 'center'
-        },
-        {
-          title: '状态',
-          width: '200',
-		  dataIndex: 'status',
-          align: 'center',
-          scopedSlots: {
-            customRender: 'enable'
-          }
+      {
+        title: '状态',
+        width: '200',
+        dataIndex: 'status',
+        align: 'center',
+        scopedSlots: {
+          customRender: 'enable'
         }
         }
+      }
       ],
       ],
       // 加载数据方法 必须为 Promise 对象
       // 加载数据方法 必须为 Promise 对象
       loadItemData: parameter => {
       loadItemData: parameter => {
@@ -235,6 +242,25 @@ export default {
     }
     }
   },
   },
   methods: {
   methods: {
+    // 获取已选列表数据
+    getCheckedList () {
+      console.log(111111)
+      const params = {
+        pageNo: 1,
+        pageSize: 10
+      }
+      getTenantsList(params).then(res => {
+        if (res.status == 200) {
+          this.checkedList = res.data.list
+          this.checkedList.map((item, index) => {
+            item.no = index + 1
+          })
+        } else {
+          this.checkedList = []
+          this.$message.warning(res.message)
+        }
+      })
+    },
     // 点击弹框x号触发事件
     // 点击弹框x号触发事件
     cancel (e) {
     cancel (e) {
       this.clear()
       this.clear()
@@ -266,43 +292,19 @@ export default {
       } else {
       } else {
         arr.push(row)
         arr.push(row)
       }
       }
-	  arr.map((item, index) => {
-	   item.no = index + 1
-	  })
+      arr.map((item, index) => {
+        item.no = index + 1
+      })
     },
     },
     // 移动
     // 移动
     moveArr (index1, index2) {
     moveArr (index1, index2) {
       const arr = this.checkedList
       const arr = this.checkedList
       arr[index1] = arr.splice(index2, 1, arr[index1])[0]
       arr[index1] = arr.splice(index2, 1, arr[index1])[0]
-	  arr.map((item, index) => {
-		  item.no = index + 1
-	  })
+      arr.map((item, index) => {
+        item.no = index + 1
+      })
       this.checkedList = arr
       this.checkedList = arr
     },
     },
-    // 选中检测项目,并过滤未选择的禁止项目
-    checkJcItem () {
-	    const a = this.jcfaItemList
-	    const b = this.jcItemList
-	    const d = []
-	    const c = []
-
-	    b.map((item, index) => {
-	      const has = a.findIndex(k => { return k.id == item.id })
-	      // 如果存在
-	      if (has >= 0) {
-	        item.checked = true
-	        c.push(item)
-	      } else {
-	        // 禁用去掉
-	        if (item.itemState === '1') {
-	          d.push(item)
-	        }
-	      }
-	    })
-
-	    // console.log(d)
-	    this.jcItemList = c.concat(d)
-    },
     // 保存提交
     // 保存提交
     handleSubmit () {
     handleSubmit () {
       const _this = this
       const _this = this
@@ -363,6 +365,7 @@ export default {
 		color: black;
 		color: black;
 		padding-bottom: 30px;
 		padding-bottom: 30px;
 	}
 	}
+
 	.actionBtn {
 	.actionBtn {
 		font-size: 12px;
 		font-size: 12px;
 		margin: 0 5px;
 		margin: 0 5px;
@@ -375,7 +378,8 @@ export default {
 	.grey {
 	.grey {
 		color: rgb(153, 153, 153);
 		color: rgb(153, 153, 153);
 	}
 	}
-	.footer{
+
+	.footer {
 		margin-top: 20px;
 		margin-top: 20px;
 	}
 	}
 </style>
 </style>