<template>
  <div class='app-container'>
    <div class='app-container-search main-bgcolor main-radius'>
      <h1 class="">窜货统计</h1>
      <br/>
      <!-- 搜索工作栏 -->
      <StatsForm
          :searchFormParam="{ queryParams, dataSource }"
          :showSearch.sync="showSearch"
          @handleQuery="handleQuery"
          @resetQuery="resetQuery"
      ></StatsForm>
    </div>
<pre><code>&lt;div class='app-container-list main-bgcolor main-radius'&gt;
  &lt;!-- 操作工具栏 --&gt;
  &lt;h1&gt;窜货统计列表&lt;/h1&gt;

  &lt;el-button
      style=&quot;float: right; margin-bottom: 10px&quot;
      type=&quot;primary&quot;
      @click=&quot;handleExport&quot;
      :loading=&quot;exportLoading&quot;
      v-hasPermi=&quot;['identity:diversion-stats:export']&quot;
  &gt;导出
  &lt;/el-button
  &gt;
  &lt;!-- 列表 --&gt;
  &lt;el-table v-loading=&quot;loading&quot; :data=&quot;list&quot;&gt;
    &lt;el-table-column label=&quot;所属商户&quot; align=&quot;center&quot; prop=&quot;belongBusinessName&quot;/&gt;
    &lt;el-table-column label=&quot;商品编号&quot; align=&quot;center&quot; prop=&quot;goodsId&quot;/&gt;
    &lt;el-table-column label=&quot;商品名称:&quot; align=&quot;center&quot; prop=&quot;goodsName&quot;/&gt;
    &lt;el-table-column label=&quot;经销商名称&quot; align=&quot;center&quot; prop=&quot;dealerName&quot;/&gt;
    &lt;el-table-column label=&quot;经销商编码&quot; align=&quot;center&quot; prop=&quot;dealerId&quot;/&gt;
    &lt;el-table-column label=&quot;窜货数&quot; align=&quot;center&quot; prop=&quot;num&quot;/&gt;
    &lt;el-table-column
        label=&quot;操作&quot;
        align=&quot;center&quot;
        class-name=&quot;small-padding fixed-width&quot;
    &gt;
      &lt;template v-slot=&quot;scope&quot;&gt;
        &lt;el-button
            size=&quot;mini&quot;
            type=&quot;text&quot;
            icon=&quot;el-icon-edit&quot;
            @click=&quot;handleUpdate(scope.row)&quot;
            v-hasPermi=&quot;['identity:diversion-stats:update']&quot;
        &gt;修改
        &lt;/el-button
        &gt;
        &lt;el-button
            size=&quot;mini&quot;
            type=&quot;text&quot;
            icon=&quot;el-icon-delete&quot;
            @click=&quot;handleDelete(scope.row)&quot;
            v-hasPermi=&quot;['identity:diversion-stats:delete']&quot;
        &gt;删除
        &lt;/el-button
        &gt;
      &lt;/template&gt;
    &lt;/el-table-column&gt;
    &lt;div slot=&quot;empty&quot;&gt;
      &lt;StatsTable/&gt;
    &lt;/div&gt;
  &lt;/el-table&gt;
  &lt;!-- 分页组件 --&gt;
  &lt;pagination
      v-show=&quot;total &gt; 0&quot;
      :total=&quot;total&quot;
      :page.sync=&quot;queryParams.pageNo&quot;
      :limit.sync=&quot;queryParams.pageSize&quot;
      @pagination=&quot;getList&quot;
  /&gt;
&lt;/div&gt;

&lt;!-- 对话框(添加 / 修改) --&gt;
&lt;el-dialog
    :title=&quot;title&quot;
    :visible.sync=&quot;open&quot;
    width=&quot;500px&quot;
    v-dialogDrag
    append-to-body
&gt;
  &lt;el-form ref=&quot;form&quot; :model=&quot;form&quot; :rules=&quot;rules&quot; label-width=&quot;80px&quot;&gt;
    &lt;el-form-item label=&quot;经销商编码&quot; prop=&quot;dealerId&quot;&gt;
      &lt;el-input v-model=&quot;form.dealerId&quot; placeholder=&quot;请输入经销商编码&quot;/&gt;
    &lt;/el-form-item&gt;
    &lt;el-form-item label=&quot;经销商名称&quot; prop=&quot;dealerName&quot;&gt;
      &lt;el-input v-model=&quot;form.dealerName&quot; placeholder=&quot;请输入经销商名称&quot;/&gt;
    &lt;/el-form-item&gt;
    &lt;el-form-item label=&quot;批次id&quot; prop=&quot;batchId&quot;&gt;
      &lt;el-input v-model=&quot;form.batchId&quot; placeholder=&quot;请输入批次id&quot;/&gt;
    &lt;/el-form-item&gt;
    &lt;el-form-item label=&quot;商品id&quot; prop=&quot;goodsId&quot;&gt;
      &lt;el-input v-model=&quot;form.goodsId&quot; placeholder=&quot;请输入商品id&quot;/&gt;
    &lt;/el-form-item&gt;
    &lt;el-form-item label=&quot;商品名称&quot; prop=&quot;goodsName&quot;&gt;
      &lt;el-input v-model=&quot;form.goodsName&quot; placeholder=&quot;请输入商品名称&quot;/&gt;
    &lt;/el-form-item&gt;
    &lt;el-form-item label=&quot;窜货数&quot; prop=&quot;num&quot;&gt;
      &lt;el-input v-model=&quot;form.num&quot; placeholder=&quot;请输入窜货数&quot;/&gt;
    &lt;/el-form-item&gt;
    &lt;el-form-item label=&quot;所属商户id&quot; prop=&quot;belongBusinessId&quot;&gt;
      &lt;el-input
          v-model=&quot;form.belongBusinessId&quot;
          placeholder=&quot;请输入所属商户id&quot;
      /&gt;
    &lt;/el-form-item&gt;
    &lt;el-form-item label=&quot;所属商户名称&quot; prop=&quot;belongBusinessName&quot;&gt;
      &lt;el-input
          v-model=&quot;form.belongBusinessName&quot;
          placeholder=&quot;请输入所属商户名称&quot;
      /&gt;
    &lt;/el-form-item&gt;
  &lt;/el-form&gt;
  &lt;div slot=&quot;footer&quot; class=&quot;dialog-footer&quot;&gt;
    &lt;el-button type=&quot;primary&quot; @click=&quot;submitForm&quot;&gt;确 定&lt;/el-button&gt;
    &lt;el-button @click=&quot;cancel&quot;&gt;取 消&lt;/el-button&gt;
  &lt;/div&gt;
&lt;/el-dialog&gt;
</code></pre>
  </div>
</template>
<script>
import StatsForm from '@/components/Customer/SearchForm'
import StatsTable from '@/components/EmptyTable'
import {
  createDiversionStats,
  deleteDiversionStats,
  exportDiversionStatsExcel,
  getDiversionStats,
  getDiversionStatsPage,
  updateDiversionStats,
} from '@/api/identity/diversionStats'

export default {
  name: 'DiversionStats',
  components: {
    StatsForm,
    StatsTable,
  },
  data() {
    return {
      //展示层
      foldBoole: false,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 窜货统计列表
      list: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        dealerId: null,
        dealerName: null,
        batchId: null,
        goodsId: null,
        goodsName: null,
        num: null,
        belongBusinessId: null,
        belongBusinessName: null,
        createTime: [],
      },
      //表对象
      dataSource: [
        {
          key: 'goodsId', //商品编码
          itemType: 'input',
          label: '商品编码',
          placeholder: '请输入',
          onEnterKeyUp: this.handleQuery,
        },
        {
          key: 'goodsName', //商品名称
          itemType: 'input',
          label: '商品名称',
          placeholder: '请输入',
          onEnterKeyUp: this.handleQuery,
        },
        {
          key: 'dealerDame', //经销商名称
          itemType: 'input',
          label: '经销商名称',
          placeholder: '请输入',
          onEnterKeyUp: this.handleQuery,
        },
        {
          key: 'dealerId', //经销商编码
          itemType: 'input',
          label: '经销商编码',
          placeholder: '请输入',
          onEnterKeyUp: this.handleQuery,
        },
      ],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        dealerId: [
          {required: true, message: '经销商编码不能为空', trigger: 'blur'},
        ],
        dealerName: [
          {required: true, message: '经销商名称不能为空', trigger: 'blur'},
        ],
        batchId: [
          {required: true, message: '批次id不能为空', trigger: 'blur'},
        ],
        goodsId: [
          {required: true, message: '商品id不能为空', trigger: 'blur'},
        ],
        goodsName: [
          {required: true, message: '商品名称不能为空', trigger: 'blur'},
        ],
        num: [{required: true, message: '窜货数不能为空', trigger: 'blur'}],
        belongBusinessId: [
          {required: true, message: '所属商户id不能为空', trigger: 'blur'},
        ],
        belongBusinessName: [
          {required: true, message: '所属商户名称不能为空', trigger: 'blur'},
        ],
      },
    }
  },
  created() {
    this.getList()
  },
  methods: {
    //展示与收起
    foldfun() {
      this.foldBoole = !this.foldBoole
    },
    /** 查询列表 */
    getList() {
      this.loading = true
      // 执行查询
      getDiversionStatsPage(this.queryParams).then((response) => {
        this.list = response.data.list
        this.total = response.data.total
        this.loading = false
      })
    },
    /** 取消按钮 */
    cancel() {
      this.open = false
      this.reset()
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        dealerId: undefined,
        dealerName: undefined,
        batchId: undefined,
        goodsId: undefined,
        goodsName: undefined,
        num: undefined,
        belongBusinessId: undefined,
        belongBusinessName: undefined,
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1 // 重置页码为1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '添加窜货统计'
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id
      getDiversionStats(id).then((response) => {
        this.form = response.data
        this.open = true
        this.title = '修改窜货统计'
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (!valid) {
          return
        }
        // 修改的提交
        if (this.form.id != null) {
          updateDiversionStats(this.form).then((response) => {
            this.$modal.msgSuccess('修改成功')
            this.open = false
            this.getList()
          })
          return
        }
        // 添加的提交
        createDiversionStats(this.form).then((response) => {
          this.$modal.msgSuccess('新增成功')
          this.open = false
          this.getList()
        })
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id
      this.$modal
          .confirm('是否确认删除窜货统计编号为' + id + '的数据项?')
          .then(function () {
            return deleteDiversionStats(id)
          })
          .then(() => {
            this.getList()
            this.$modal.msgSuccess('删除成功')
          })
          .catch(() => {
          })
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams}
      params.pageNo = undefined
      params.pageSize = undefined
      this.$modal
          .confirm('是否确认导出所有窜货统计数据项?')
          .then(() => {
            this.exportLoading = true
            return exportDiversionStatsExcel(params)
          })
          .then((response) => {
            this.$download.excel(response, '窜货统计.xls')
            this.exportLoading = false
          })
          .catch(() => {
          })
    },
  },
}
</script>
Vue 点击搜索按钮切换分页组件 - 实用教程

原文地址: https://www.cveoy.top/t/topic/mkZS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录