From 4e77a057819df8bcd8eb4218e6d1fcd8ccc8abf6 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期五, 26 四月 2024 18:21:56 +0800
Subject: [PATCH] 应发工资报表的前端开发

---
 src/views/employeeSalary/machineManage/index.vue |  252 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 245 insertions(+), 7 deletions(-)

diff --git a/src/views/employeeSalary/machineManage/index.vue b/src/views/employeeSalary/machineManage/index.vue
index a3cf584..f3099c5 100644
--- a/src/views/employeeSalary/machineManage/index.vue
+++ b/src/views/employeeSalary/machineManage/index.vue
@@ -1,21 +1,259 @@
 <template>
-  <div class="container"></div>
+  <div class="container">
+    <div class="filter-card">
+      <CommonSearch ref="searchRef" :show-add="false" :amount-view="false" placeholder="璇疯緭鍏ュ叧閿瘝" @searchClick="onFilterSearch">
+        <template slot="leftButton">
+          <el-button size="small" type="primary" @click="addBtnClick" >鏂板</el-button>
+          <!-- <el-button size="small" type="primary" @click="exportClick">瀵煎叆</el-button> -->
+        </template>
+      </CommonSearch>
+    </div>
+    <div class="body-card">
+      <div class="list-view">
+        <TableCommonView
+          :table-list="tableList"
+          @selTableCol="selTableCol"
+          @tableRowClick="tableRowClick"
+        >
+          <template slot="tableButton">
+            <el-table-column label="鎿嶄綔" width="160" fixed='right'>
+              <template slot-scope="scope">
+                <el-button @click.stop="handleClick(scope.row, '淇敼')" type="text" size="small">淇敼</el-button>
+                <el-button @click.stop="delClick(scope.row)" type="text" size="small">鍒犻櫎</el-button>
+                
+              </template>
+            </el-table-column>
+          </template>
+        </TableCommonView>
+      </div>
+      <AddDialog 
+      ref="add"
+        :editRow="editRow"  @refresh="refreshClick"
+      />
+      <div class="btn-pager">
+        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
+      </div>
+    </div>
+  </div>
 </template>
 
 <script>
+import { getWorkerPositionList, deleteWorkerPositionInfo } from "@/api/employeeSalary/machineManage.js"
+import AddDialog from "@/views/employeeSalary/machineManage/components/addDialog.vue"
+import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
+import Date from "@/api/date";
+const { formatDate2 } = Date;
 export default {
   name: "machineManage",
   props: {},
-  components: {},
-  mixins: [],
+  components: {AddDialog},
+  mixins: [pageMixin],
   computed: {},
   data() {
-    return {}
+    return {
+      tableList: {},
+      showCol: ["鏃ユ湡", "宸ョ", "鍛樺伐缂栫爜", "鍛樺伐濮撳悕", "杞﹂棿", "缁勫埆", "鏈哄彴鍙�", "娣诲姞鏃堕棿", "娣诲姞浜�"],
+      tableColumn: [
+        { label: "鏃ユ湡", prop: "date",min:180},
+        { label: "宸ョ", prop: "workType",min:110 },
+        { label: "鍛樺伐缂栫爜", prop: "workerId",min:110 },
+        { label: "鍛樺伐濮撳悕", prop: "name",min:110 },
+        { label: "杞﹂棿", prop: "workshopName",min:110 },
+        { label: "缁勫埆", prop: "workshopGroup",min:110 },
+        { label: "鏈哄彴鍙�", prop: "workerPosition",min:110 },
+        { label: "娣诲姞鏃堕棿", prop: "created_at",min:120 },
+        { label: "娣诲姞浜�", prop: "creator",min:110 },
+      ],
+      editRow:{},
+      loading: false,
+      getDataParams: {
+        keyWord: '',
+      },
+    }
   },
-  created() {},
-  methods: {}
+  created() {
+    this.setTable()
+    this.getData(this.getDataParams.keyWord)
+  },
+  methods: {
+    setTable() {
+      // top 鏄庣粏鍗曞垪琛�
+      this.tableList = {
+        selectIndex: true,
+        tableInfomation: [],
+        allcol: [],
+        showcol: this.showCol,
+        tableColumn: this.setColumnVisible(this.showCol, this.tableColumn)
+      }
+      this.setTableList(this.tableList)
+    },
+    setColumnVisible(showCol, tableColumn) {
+      return tableColumn.map((ele) => {
+        return {
+          ...ele,
+          isShowColumn: showCol.includes(ele.label)
+        }
+      })
+    },
+    setTableList(tableList) {
+      tableList.allcol = tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
+      this.searchOptions = []
+      for (let i = 0; i < tableList.tableColumn.length; i++) {
+        const label = tableList.tableColumn[i].label
+        const value = tableList.tableColumn[i].prop
+        this.searchOptions.push({ value: value, label: label })
+      }
+    },
+    selTableCol(val) {
+      this.showcol = val
+      this.tableList.tableColumn = this.setColumnVisible(val, this.tableColumn)
+    },
+     // 璇锋眰鏁版嵁
+     async getData() {
+      this.loading = true
+      await getWorkerPositionList({
+        keyword:this.getDataParams.keyWord,
+        page: this.pagerOptions.currPage,
+        pageSize: this.pagerOptions.pageSize
+      })
+        .then((res) => {
+          if (res.code === 200) {
+            if (res.data) {
+              const list = res.data.map(item=>{
+                return {
+                  ...item,
+                  date:item.StartDate?item.StartDate+'/'+item.EndDate:'',
+                  workType:item.worker?item.worker.workType:'',
+                  name:item.worker?item.worker.name:'',
+                  workerPosition:item.startWorkerPosition?item.startWorkerPosition+'-'+item.endWorkerPosition:'',
+                  created_at:item.CreatedAt?formatDate2(item.CreatedAt).split(' ')[0]:''
+                }
+              })
+              this.tableList.tableInfomation = list || []
+              this.pagerOptions.totalCount = res.total
+            } else {
+              this.tableList.tableInfomation = []
+            }
+          } else {
+            this.tableList.tableInfomation = []
+          }
+          this.loading = false
+        })
+        .catch((err) => {
+          console.log(err)
+          this.tableList.tableInfomation = []
+          this.loading = false
+        })
+    },
+    // 鏂板
+    addBtnClick() {
+      this.editRow = { title:'鏂板缓',type:'add' }
+      this.$refs.add.islook = true;
+    },
+    // 鎼滅储
+    onFilterSearch(searchText) {
+      this.getDataParams.keyWord = searchText,
+      this.pagerOptions.currPage = 1
+      this.getData()
+    },
+    // 鍒锋柊
+    refreshClick() {
+      this.getData()
+    },
+    // 鎵撳嵃
+    exportClick() { },
+    // 缂栬緫
+    handleClick(row) {
+      let config=JSON.parse(JSON.stringify(row));
+      this.editRow = { 
+        ...config, 
+        title:'缂栬緫',
+        type:'edit',
+        id:config.ID,
+        date:config.StartDate?[config.StartDate,config.EndDate]:[],
+        workshopObj:{
+          value:config.workshop,
+          label:config.workshopName,
+        },      
+        name:config.worker?config.worker.name:'',
+        workerPosition:{
+          value:config.startWorkerPosition?config.startWorkerPosition+'-'+config.endWorkerPosition:'',
+          label:config.startWorkerPosition?config.startWorkerPosition+'-'+config.endWorkerPosition:'',
+        }, 
+      }
+      this.$refs.add.islook = true;
+    },
+    // 鍒犻櫎
+    delClick(row) {
+      this.$confirm("鏄惁纭鍒犻櫎?", "璀﹀憡", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning"
+      })
+        .then(() => {
+          deleteWorkerPositionInfo({ id: row.ID }).then((response) => {
+            if (response.code === 200) {
+              this.$message.success("鍒犻櫎鎴愬姛")
+              this.getData()
+            }
+          })
+        })
+        .catch(() => {})
+    },
+    // 琛ㄦ牸琛岀偣鍑�
+    tableRowClick(row) {
+      console.log(row, "row")
+    },
+  }
 }
 </script>
 
 <!-- Add "scoped" attribute to limit CSS to this component only -->
-<style lang="scss" scoped></style>
+<style lang="scss" scoped>
+
+.container {
+  height: 100%;
+  .filter-card {
+    margin: 20px 30px;
+    height: 80px;
+    display: flex;
+    align-items: center;
+    padding: 0 20px 0 20px;
+    border-radius: 4px;
+    background-color: #fff;
+  }
+  .body-card {
+    margin: 0 30px;
+    background-color: #fff;
+    padding: 10px 15px;
+    height: calc(100% - 180px);
+    border-radius: 4px;
+    .edit-save {
+      display: flex;
+      align-items: center;
+      margin-bottom: 10px;
+      .edit-save-icon {
+        font-size: 24px;
+        color: #5582f3;
+        cursor: pointer;
+      }
+      .edit-sace-label {
+        margin-left: 10px;
+        font-size: 14px;
+        color: #000000d8;
+      }
+    }
+  }
+}
+.list-view {
+  height: calc(100% - 60px);
+  overflow: hidden;
+}
+.btn-pager {
+  display: flex;
+  margin-top: 10px;
+  .page {
+    margin-left: auto;
+  }
+}
+</style>

--
Gitblit v1.8.0