src/views/productManage/productRegisterForm/index.vue
@@ -3,31 +3,176 @@
    <div class="filter-card">
      <CommonSearch :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="addBtnClick">新增</el-button>
        </template>
      </CommonSearch>
    </div>
    <div class="body-card">
      <div class="list-view">
        <TableCommonView ref="tableListRef" v-loading="loading" :table-list="tableList" @selTableCol="selTableCol">
          <template slot="tableButton">
            <el-table-column label="操作" width="180">
              <template slot-scope="scope">
                <el-button @click="editClick(scope.row)" type="text" size="small">编辑</el-button>
                <el-button @click="delClick(scope.row)" type="text" size="small">删除</el-button>
              </template>
            </el-table-column>
          </template>
        </TableCommonView>
      </div>
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div>
    </div>
  </div>
</template>
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getYieldRegisterList,deleteYieldRegister } from "@/api/productManage/productRegisterForm.js"
export default {
  name: "productRegisterForm",
  props: {},
  components: {},
  mixins: [],
  mixins: [pageMixin],
  computed: {},
  data() {
    return {}
    return {
      loading: false,
      tableList: {},
      keyword: '',
      tableColumn: [
        { label: "编号", prop: "number", min: 100, default: true },
        { label: "生产时间", prop: "createTime", min: 110, },
        { label: "车组", prop: "groupNumber" },
        { label: "规格", prop: "spec", min: 90 },
        { label: "车间", prop: "workshopName", min: 200 },
        { label: "庄口", prop: "marketName" },
        { label: "回数", prop: "circle",},
        { label: "车组总产量", prop: "total" }
      ],
      showCol: ["编号", "生产时间", "车组", "规格", "车间", "庄口", "回数", "车组总产量"]
    }
  },
  created() {},
  methods: {}
  created() {
    this.setTable()
    this.getData(this.keyword)
  },
  methods: {
    setTable() {
      this.tableList = {
        selectIndex: false,
        tableInfomation: [],
        allcol: [],
        showcol: this.showCol,
        tableColumn: this.setColumnVisible(this.showCol)
      }
      this.tableList.allcol = this.tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
      this.searchOptions = []
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        const label = this.tableList.tableColumn[i].label
        const value = this.tableList.tableColumn[i].prop
        this.searchOptions.push({ value: value, label: label })
      }
    },
    setColumnVisible(showCol) {
      return this.tableColumn.map((ele) => {
        return {
          ...ele,
          isShowColumn: showCol.includes(ele.label)
        }
      })
    },
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setColumnVisible(val)
    },
     // 请求数据
     async getData() {
      this.loading = true
      await getYieldRegisterList({
        keyword: this.keyword,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      })
        .then((res) => {
          console.log(res)
          if (res.code === 200) {
            if (res.data && res.data.length > 0) {
              // const list = res.data.map((item) => {
              //   return {
              //     ...item,
              //     client_name: item.client.name,
              //     contact_name: item.contact.name,
              //     client_status: item.client_status.name,
              //     phone: item.contact.phone,
              //     member_name: item.member.username,
              //     contact_information_name: item.contact_information.name
              //   }
              // })
              this.tableList.tableInfomation =  res.data || []
              this.pagerOptions.totalCount = res.count
            } else {
              this.tableList.tableInfomation = []
            }
          } else {
            this.tableList.tableInfomation = []
          }
          this.loading = false
        })
        .catch((err) => {
          console.log(err)
          this.tableList.tableInfomation = []
          this.loading = false
        })
    },
    // 搜索
    onFilterSearch(searchText) {
      this.keyword = searchText ?? ""
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 新增
    addBtnClick() {
      this.$router.push({ name: "addProductRegisterPage" })
    },
    // 编辑
    editClick(row) {
      this.$router.push({
         name:'addProductRegisterPage',
         query:{
            id:row.ID,
            number:row.number,
          }
        });
    },
    // 删除
    delClick(row) {
      this.$confirm("请确认是否删除,删除操作不可撤销?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          deleteYieldRegister({ number: row.number }).then((response) => {
            if (response.code === 200) {
              this.$message.success("删除成功")
              this.getData()
            } else {
              this.$message.warning("删除失败")
            }
          })
        })
        .catch(() => {})
    },
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.productRegisterForm-container {
  height: 100%;
  .filter-card {
    margin: 20px 30px;
    height: 80px;
@@ -37,5 +182,23 @@
    border-radius: 12px;
    background-color: #fff;
  }
  .body-card {
    margin: 0 30px;
    background-color: #fff;
    padding: 10px 15px;
    height: calc(100% - 160px);
    border-radius: 12px;
  }
    .list-view {
      height: calc(100% - 60px);
      overflow: hidden;
    }
    .btn-pager {
      display: flex;
      margin-top: 10px;
      .page {
        margin-left: auto;
      }
    }
}
</style>