charles
2024-08-06 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f
src/views/warehouseManage/warehouse/index.vue
@@ -1,40 +1,21 @@
<template>
  <div class="rightContent">
    <div class="top">
      <SearchCommonView
        :add-title="'新建'"
        :placeholder="'请输入仓库'"
        :amount-view="false"
        @addCommonClick="addBtnClick"
        @searchClick="getList"
      />
      <SearchCommonView :add-title="'新建'" :placeholder="'请输入仓库'" :amount-view="false" @addCommonClick="addBtnClick" @searchClick="getList" />
    </div>
    <div class="list-view">
      <div class="table">
        <TableCommonView
          ref="tableListRef"
          :table-list="tableList"
          :show-checkcol="false"
        >
        <template slot="tableButton">
            <el-table-column label="操作" width="120" fixed="right">
        <TableCommonView ref="tableListRef" :table-list="tableList" :show-checkcol="false">
          <template slot="tableButton">
            <el-table-column label="操作" width="120" >
              <template slot-scope="scope">
                <el-button
                  @click="tableRowClick(scope.row,'edit')"
                  type="text"
                  size="small"
                  >编辑</el-button
                >
                <el-button
                  type="text"
                  size="small"
                  @click="tableRowClick(scope.row,'look')"
                  >查看</el-button
                >
                <el-button @click="tableRowClick(scope.row, 'edit')" type="text" size="small">编辑</el-button>
                <el-button type="text" size="small" @click="tableRowClick(scope.row, 'look')">查看</el-button>
                <el-button type="text" size="small" @click.stop="deleteRow(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </template>
      </TableCommonView>
        </TableCommonView>
      </div>
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
@@ -46,123 +27,155 @@
</template>
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getWarehouseList } from "@/api/warehouseManage/warehouse"
import AddDialog from "@/views/warehouseManage/warehouse/AddDialog"
  import pageMixin from '@/components/makepager/pager/mixin/pageMixin'
  import { getWarehouseList, deleteWarehouse } from '@/api/warehouseManage/warehouse'
  import AddDialog from '@/views/warehouseManage/warehouse/AddDialog'
export default {
  name: "WarehouseView",
  props: {},
  components: { AddDialog },
  mixins: [pageMixin],
  computed: {},
  data() {
    return {
      tableList: {},
      keyword:'',
      editConfig: {
        visible: false,
        title: "新建",
        infomation: {}
      }
    }
  },
  created() {
    this.setTable()
    this.getData()
  },
  methods: {
    setTable() {
      this.tableList = {
        tableInfomation: [],
        selectBox: false,
        selectIndex: true,
        showcol: this.showcol,
        allcol: [],
        tableColumn: this.setTableColumn(this.showcol)
      }
      let allcol = []
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        if (!this.tableList.tableColumn[i].default) {
          const label = this.tableList.tableColumn[i].label
          allcol.push(label)
        }
      }
      this.tableList.allcol = allcol
    },
    setTableColumn(showcol) {
      console.log(showcol)
      let tableColumn = [
        {
          label: "仓库",
          prop: "name",
          isShowColumn: true,
          default: true
  export default {
    name: 'WarehouseView',
    props: {},
    components: { AddDialog },
    mixins: [pageMixin],
    computed: {},
    data() {
      return {
        tableList: {},
        keyword: '',
        editConfig: {
          visible: false,
          title: '新建',
          infomation: {},
        },
        {
          label: "库存位置",
          prop: "warehouseLocation",
          isShowColumn: true,
          default: true
        },
        {
          label: "地址",
          prop: "address",
          isShowColumn: true,
          default: true
        }
      ]
      return tableColumn
      }
    },
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setTableColumn(val)
    },
    // 请求数据
    async getData() {
      await getWarehouseList({
        keyword: this.keyword,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      }).then((res) => {
        if (res.code == 200) {
          const list = res.data?res.data:[]
          this.tableList.tableInfomation = list
          this.pagerOptions.totalCount = res.total
        }
      })
    },
    refresh(){
      this.pagerOptions.currPage=1
    created() {
      this.setTable()
      this.getData()
    },
    // 搜索
    getList(val) {
      this.keyword=val;
      this.pagerOptions.currPage=1
      this.getData()
    methods: {
      setTable() {
        this.tableList = {
          tableInfomation: [],
          selectBox: false,
          selectIndex: true,
          showcol: this.showcol,
          allcol: [],
          tableColumn: this.setTableColumn(this.showcol),
        }
        let allcol = []
        for (let i = 0; i < this.tableList.tableColumn.length; i++) {
          if (!this.tableList.tableColumn[i].default) {
            const label = this.tableList.tableColumn[i].label
            allcol.push(label)
          }
        }
        this.tableList.allcol = allcol
      },
      setTableColumn(showcol) {
        console.log(showcol)
        let tableColumn = [
          {
            label: '仓库',
            prop: 'name',
            isShowColumn: true,
            default: true,
          },
          {
            label: '库存位置',
            prop: 'warehouseLocation',
            isShowColumn: true,
            default: true,
          },
          {
            label: '地址',
            prop: 'address',
            isShowColumn: true,
            default: true,
          },
        ]
        return tableColumn
      },
      selTableCol(val) {
        this.showcol = val
        this.tableList.tableColumn = this.setTableColumn(val)
      },
      // 请求数据
      async getData() {
        await getWarehouseList({
          keyword: this.keyword,
          page: this.pagerOptions.currPage,
          pageSize: this.pagerOptions.pageSize,
        }).then((res) => {
          if (res.code == 200) {
            const list = res.data ? res.data : []
            this.tableList.tableInfomation = list
            this.pagerOptions.totalCount = res.total
          }
        })
      },
      refresh() {
        this.pagerOptions.currPage = 1
        this.getData()
      },
      // 搜索
      getList(val) {
        this.keyword = val
        this.pagerOptions.currPage = 1
        this.getData()
      },
      // 行点击
      tableRowClick(row, val) {
        this.editConfig.title = val == 'look' ? '查看' : '编辑'
        this.editConfig.infomation = { ...row }
        this.editConfig.visible = true
      },
      // 新建
      addBtnClick() {
        this.editConfig.infomation = {
          address: '',
          buyToResupply: null,
          code: '',
          name: '',
          inboundTransportation: 1,
          outboundTransportation: 1,
        };
        this.editConfig.visible = true
        this.editConfig.title = '新建'
      },
      //删除
      deleteRow(row) {
        this.$confirm('此操作将永久删除该仓库, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            deleteWarehouse({
              id: row.id,
            }).then((res) => {
              if (res.code == 200) {
                this.$message({
                  type: 'success',
                  message: '删除成功!',
                })
                this.getData()
              }else{
                this.$message.error('删除时出错,请稍后重试或联系管理员...');
              }
            })
          })
          .catch(() => {
            // this.$message({
            //   type: 'info',
            //   message: '已取消删除',
            // })
          })
      },
    },
    // 行点击
    tableRowClick(row,val) {
      this.editConfig.title = val=='look'?'查看':"编辑"
      this.editConfig.infomation = { ...row }
      this.editConfig.visible = true
    },
    // 新建
    addBtnClick() {
      this.editConfig.infomation={
        address:'',
        buyToResupply:null,
        code:'',
        name:'',
        inboundTransportation:1,
        outboundTransportation:1,
      }
      this.editConfig.visible = true
      this.editConfig.title = "新建"
    }
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->