Admin
2022-08-02 d592747d5eaa2cfbe698f8ac61222eb3aa75d1fc
src/views/basicRightsManagement/personnelShiftManagement/teamManagement/index.vue
@@ -1,6 +1,6 @@
<template>
   <div class="home-container">
      <el-scrollbar height="100%">
      <div style="height: 100%">
      <el-row class="homeCard">
         <el-col :span="8">
            <div class="grid-content topInfo">
@@ -24,6 +24,7 @@
                  ref="multipleTableRef"
                  :data="tableData"
                  style="width: 100%"
                  height="calc(100% - 100px)"
                  :header-cell-style="{background: '#fafafa'}"
                  @selection-change="handleSelectionChange"
            >
@@ -38,22 +39,22 @@
                  </template>
               </el-table-column>
            </el-table>
         </div>
         <div class="pageBtn">
            <el-pagination
                  v-model:currentPage="currentPage"
                  v-model:page-size="pageSize"
                  :page-sizes="[10, 15]"
                  small=false
                  background
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="100"
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
            />
            <div class="pageBtn">
               <el-pagination
                     v-model:currentPage="currentPage"
                     v-model:page-size="pageSize"
                     :page-sizes="[10, 15]"
                     small=false
                     background
                     layout="total, sizes, prev, pager, next, jumper"
                     :total="100"
                     @size-change="handleSizeChange"
                     @current-change="handleCurrentChange"
               />
            </div>
         </div>
      </div>
      </el-scrollbar>
      </div>
      <el-dialog v-model="dialogDetails" title="班组信息">
         <el-form :model="details" label-width="120px">
            <el-form-item label="班组名称">
@@ -127,194 +128,198 @@
   interface type {
   }
   // export default defineComponent({
   //    name: 'workCheckinRecord',
   //    setup() {
         const userInfo = useUserInfo()
         const { userInfos } = storeToRefs(userInfo);
         const state  = reactive<stateType>({});
         const currentPage = ref(1)
         const pageSize = ref(10)
         const chosenIndex = ref(-1)
         const casProps = {
            expandTrigger: 'hover',
            multiple: true,
            emitPath: false,
            checkStrictly: false
         }
         const handleSizeChange = (val: number) => {
            console.log(`${val} items per page`)
         }
         const handleCurrentChange = (val: number) => {
            console.log(`current page: ${val}`)
         }
         const workerList =reactive([
   const userInfo = useUserInfo()
   const { userInfos } = storeToRefs(userInfo);
   const state  = reactive<stateType>({});
   const currentPage = ref(1)
   const pageSize = ref(10)
   const chosenIndex = ref(-1)
   const casProps = {
      expandTrigger: 'hover',
      multiple: true,
      emitPath: false,
      checkStrictly: false
   }
   const handleSizeChange = (val: number) => {
      console.log(`${val} items per page`)
   }
   const handleCurrentChange = (val: number) => {
      console.log(`current page: ${val}`)
   }
   const workerList =reactive([
      {
         value: 'A部门车间',
         label: 'A部门车间',
         children: [
            {
               value: 'A部门车间',
               label: 'A部门车间',
               children: [
                  {
                     value: '刘能',
                     label: '刘能',
                  },
                  {
                     value: '赵四',
                     label: '赵四',
                  },
                  {
                     value: '谢广坤',
                     label: '谢广坤',
                  },
                  {
                     value: '王大拿',
                     label: '王大拿',
                  },
                  {
                     value: '刘能',
                     label: '刘能',
                  },
                  {
                     value: '赵四',
                     label: '赵四',
                  }
               ]
               value: '刘能',
               label: '刘能',
            },
            {
               value: 'B部门车间',
               label: 'B部门车间',
               children: [
                  {
                     value: '刘备',
                     label: '刘备',
                  },
                  {
                     value: '关羽',
                     label: '关羽',
                  },
                  {
                     value: '张飞',
                     label: '张飞',
                  },
                  {
                     value: '赵云',
                     label: '赵云',
                  },
                  {
                     value: '黄忠',
                     label: '黄忠',
                  },
                  {
                     value: '马超',
                     label: '马超',
                  }
               ]
               value: '赵四',
               label: '赵四',
            },
            {
               value: '谢广坤',
               label: '谢广坤',
            },
            {
               value: '王大拿',
               label: '王大拿',
            },
            {
               value: '刘能',
               label: '刘能',
            },
            {
               value: '赵四',
               label: '赵四',
            }
         ])
         const tableData = reactive(
               [
               {
                  teamName: 'A车间班组',
                  teamMember: ['张三','李四','李羽飞']
               },
               {
                  teamName: 'B车间班组',
                  teamMember: ['刘能','赵四','谢广坤']
               },
            ]
         )
         const addRef = ref<FormInstance>()
         const addRules = reactive<FormRules>({
            teamName:[{required: true, message: '该内容不能为空',trigger:'blur'}],
            teamMember:[{required: true, message: '该内容不能为空',trigger:'blur'}]
         })
         const dialogDetails = ref(false)
         const dialogAddRecord = ref(false)
         const deleteDialog = ref(false)
         const addRecord = ref({})
         const details = ref({})
         const viewRecord = (row) =>{
            details.value = JSON.parse(JSON.stringify(row))
            dialogDetails.value = true
         ]
      },
      {
         value: 'B部门车间',
         label: 'B部门车间',
         children: [
            {
               value: '刘备',
               label: '刘备',
            },
            {
               value: '关羽',
               label: '关羽',
            },
            {
               value: '张飞',
               label: '张飞',
            },
            {
               value: '赵云',
               label: '赵云',
            },
            {
               value: '黄忠',
               label: '黄忠',
            },
            {
               value: '马超',
               label: '马超',
            }
         ]
      }
   ])
   const tableData = reactive(
         [
         {
            teamName: 'A车间班组',
            teamMember: ['张三','李四','李羽飞']
         },
         {
            teamName: 'B车间班组',
            teamMember: ['刘能','赵四','谢广坤']
         },
      ]
   )
   const addRef = ref<FormInstance>()
   const addRules = reactive<FormRules>({
      teamName:[{required: true, message: '该内容不能为空',trigger:'blur'}],
      teamMember:[{required: true, message: '该内容不能为空',trigger:'blur'}]
   })
   const dialogDetails = ref(false)
   const dialogAddRecord = ref(false)
   const deleteDialog = ref(false)
   const addRecord = ref({})
   const details = ref({})
   const viewRecord = (row) =>{
      details.value = JSON.parse(JSON.stringify(row))
      dialogDetails.value = true
   }
   const deleteRecord = (index) =>{
      chosenIndex.value = index
      deleteDialog.value = true
   }
   const conFirmDelete = ()=> {
      tableData.splice(chosenIndex.value,1)
      deleteDialog.value = false
   }
   const confirmAddRecord = async (formEl: FormInstance | undefined) =>{
      if (!formEl) return
      await formEl.validate((valid, fields) => {
         if (valid) {
            if(chosenIndex.value == -1){
               tableData.unshift(addRecord.value)
            }else{
               tableData[chosenIndex.value] = addRecord.value
            }
            dialogAddRecord.value =false
         } else {
            console.log('error submit!', fields)
         }
         const deleteRecord = (index) =>{
            chosenIndex.value = index
            deleteDialog.value = true
         }
         const conFirmDelete = ()=> {
            tableData.splice(chosenIndex.value,1)
            deleteDialog.value = false
         }
         const confirmAddRecord = async (formEl: FormInstance | undefined) =>{
            if (!formEl) return
            await formEl.validate((valid, fields) => {
               if (valid) {
                  if(chosenIndex.value == -1){
                     tableData.unshift(addRecord.value)
                  }else{
                     tableData[chosenIndex.value] = addRecord.value
                  }
                  dialogAddRecord.value =false
               } else {
                  console.log('error submit!', fields)
               }
            })
      })
         }
         const closeAdd =()=>{
            addRecord.value={}
            chosenIndex.value = -1
         }
         const indexClear = ()=>{
            chosenIndex.value = -1
         }
         const editRecord =(index, row)=>{
            dialogAddRecord.value = true
            chosenIndex.value = index
            addRecord.value = JSON.parse(JSON.stringify(row))
         }
         // 折线图
         const renderMenu = async (value: string) => {
            Session.set('projectId',value)
            userInfos.value.projectId = value
            await initBackEndControlRoutes();
         };
         // return {
         //    renderMenu,
         //    multipleTableRef,
         //    tableData,
         //    currentPage,
         //    pageSize,
         //    dialogDetails,
         //    details,
         //    deleteDialog,
         //    dialogAddRecord,
         //    viewRecord,
         //    deleteRecord,
         //    handleSizeChange,
         //    handleCurrentChange,
         //    Plus,
         //    Edit,
         //    Delete,
         //    Search,
         //    Download,
         //    handleSelectionChange,
         //    Refresh,
         //    ...toRefs(state),
         // };
   //    },
   // });
   }
   const closeAdd =()=>{
      addRecord.value={}
      chosenIndex.value = -1
   }
   const indexClear = ()=>{
      chosenIndex.value = -1
   }
   const editRecord =(index, row)=>{
      dialogAddRecord.value = true
      chosenIndex.value = index
      addRecord.value = JSON.parse(JSON.stringify(row))
   }
   // 折线图
   const renderMenu = async (value: string) => {
      Session.set('projectId',value)
      userInfos.value.projectId = value
      await initBackEndControlRoutes();
   };
</script>
<style scoped lang="scss">
   $homeNavLengh: 8;
   .home-container {
      height: 100%;
      height: calc(100vh - 114px);
      box-sizing: border-box;
      overflow: hidden;
      .homeCard{
         width: 100%;
         padding: 20px;
         box-sizing: border-box;
         background: #fff;
         border-radius: 4px;
         .main-card{
            width: 100%;
            height: 100%;
            .cardTop{
               display: flex;
               align-items: center;
               justify-content: space-between;
               margin-bottom: 20px;
               .mainCardBtn{
                  margin: 0;
               }
            }
            .pageBtn{
               height: 60px;
               display: flex;
               align-items: center;
               justify-content: right;
               .demo-pagination-block + .demo-pagination-block {
                  margin-top: 10px;
               }
               .demo-pagination-block .demonstration {
                  margin-bottom: 16px;
               }
            }
         }
         &:last-of-type{
            height: calc(100% - 100px);
         }
      }
      .el-row{
         display: flex;
@@ -338,37 +343,6 @@
               white-space: nowrap;
               margin-right: 20px;
            }
         }
      }
      .mainPages{
         height: 100%;
         display: flex;
         flex-direction: column;
         justify-content: space-between;
      }
      .main-card{
         width: 100%;
         .cardTop{
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 20px;
            .mainCardBtn{
               margin: 0;
            }
         }
      }
      .pageBtn{
         display: flex;
         align-items: center;
         justify-content: right;
         margin-top: 20px;
         .demo-pagination-block + .demo-pagination-block {
            margin-top: 10px;
         }
         .demo-pagination-block .demonstration {
            margin-bottom: 16px;
         }
      }
   }