rules.vue 10.6 KB
<template>
  <d2-container>
    <el-card shadow="never">
      <el-form :inline="true" :model="formInline" class="demo-form-inline" size="small">
        <el-form-item label="设备类型:">
          <el-select v-model="formInline.deviceType" placeholder="请选择">
            <el-option value="" label="全部">全部</el-option>
            <el-option v-for="item in deviceList" :key="item.id" :value="item.id" :label="item.name"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="设备型号:">
          <el-input v-model="formInline.mnumName" placeholder="设备型号" />
        </el-form-item>
        <el-form-item label="设备号开头编码:">
          <el-input v-model="formInline.snHead" placeholder="设备号开头编码" />
        </el-form-item>
        <el-form-item label="项目:">
          <el-select v-model="formInline.subject" placeholder="请选择">
            <el-option value="" label="全部">全部</el-option>
            <el-option v-for="item in projectList" :key="item.id" :value="item.id" :label="item.name"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否投保:">
          <el-select v-model="formInline.issure" placeholder="请选择">
            <el-option value="" label="全部">全部</el-option>
            <el-option value="Y" label="是"></el-option>
            <el-option value="N" label="否"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="入库平台:">
          <el-select v-model="formInline.moduleFlag" placeholder="请选择">
            <el-option value="" label="全部">全部</el-option>
            <el-option v-for="item in modulesList" :key="item.moduleFlag" :value="item.moduleFlag" :label="item.moduleFlagName"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" :loading="tableLoading" plain @click="getList()">搜索</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 按钮操作区域 开始 -->
    <div class="links_group">
      <div class="left">
        <el-button type="success" plain icon="el-icon-plus" size="small" @click="openAddPopup">新增</el-button>
      </div>
      <div class="right">
        <el-button type="primary" plain icon="el-icon-download" size="small" :loading="eloading" @click="downloadExcel">导出</el-button>
      </div>
    </div>
    <!-- 按钮操作区域 开始 -->

    <!-- 表格区域 开始 -->
    <div class="table_box">
      <el-table class="el_table" v-loading="tableLoading" :data="tableData" stripe style="width: 100%" size="small" border>
        <el-table-column prop="deviceTypeName" label="设备类型" />
        <el-table-column prop="mnumName" label="设备型号" />
        <el-table-column prop="snHead" label="设备SN开头编码" />
        <el-table-column prop="subjectName" label="项目" />
        <el-table-column prop="issureName" label="是否投保" />
        <el-table-column prop="dvIccid" label="入库平台">
          <template slot-scope="{row}">
            <div class="flag_list">
              <p v-for="(item,idx) in (row.listVo||[])" :key="idx">{{item.moduleFlagName}}</p>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="" label="操作">
          <template slot-scope="scope">
            <el-link type="danger" @click="openDialog(scope.row)">删除</el-link>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination_list">
        <el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :page-size="pageSize" :page-sizes="pageSizes" @current-change="getList" @size-change="changePageSize" />
      </div>
    </div>
    <!-- 表格区域 end -->

    <!-- 弹框 开始 -->
    <glsx-dialog :show="showDialog" title="确认删除" width="50%" usefooter @closed="closeDialog">
      <div class="remove_box" v-loading="rloading">
        <h2 class="tips">请确认是否删除,删除后,设备不再自动分发到指定的业务系统,请谨慎操作!</h2>
        <div class="row_form">
          <div class="cell">
            <span class="name">设备类型:</span>
            <div class="txt_box">{{ruleInfo.deviceTypeName}}</div>
          </div>
          <div class="cell">
            <span class="name">设备型号:</span>
            <div class="txt_box">{{ruleInfo.mnumName}}</div>
          </div>
          <div class="cell">
            <span class="name">设备号开头编码:</span>
            <div class="txt_box">{{ruleInfo.snHead}}</div>
          </div>
          <div class="cell">
            <span class="name">项目:</span>
            <div class="txt_box">{{ruleInfo.subjectName}}</div>
          </div>
          <div class="cell">
            <span class="name">是否投保:</span>
            <div class="txt_box">{{ruleInfo.issureName}}</div>
          </div>
          <div class="cell">
            <span class="name">入库平台:</span>
            <div class="txt_box">
              <div class="" v-for="(item,index) in (ruleInfo.listVo||[])" :key="index">{{item.moduleFlagName}}</div>
            </div>
          </div>
        </div>
      </div>
      <div slot="footer" class="btn_group">
        <el-button type="danger" plain size="small" :loading="dloading" @click="removeRules">确认删除</el-button>
        <el-button size="small" @click="closeDialog">取消删除</el-button>
      </div>
    </glsx-dialog>
    <!-- 弹框 end -->

    <!-- 新增弹框 开始 -->
    <glsx-dialog :show="addPopup" width="60%" title="新建设备分发规则" @close="closeAddPopup">
      <div>
        <add-rules ref="addRulesComponent" @change="onChange" v-if="addPopup"></add-rules>
      </div>
      <div slot="footer" class="btn_group">
        <el-button type="success" plain size="small" :loading="aloading" @click="saveInfo">提交</el-button>
        <el-button size="small" @click="closeAddPopup">取消</el-button>
      </div>
    </glsx-dialog>
    <!-- 新增弹框 end -->

  </d2-container>
</template>

<script>
import {
  PAGEEXSYSDISPATCHRULE,
  GETLISTSUBJECT,
  GETLISTDEVICETYPE,
  GETLISTMODULES,
  EXPORTEXSYSDISPATCHRULE,
  DELEXSYSDISPATCHRULE,
  GETEXSYSDISPATCHRULE,
} from '@/http/order'
import GlsxDialog from '@/components/dialog/index'
import { deepClone, showToast } from '@/common/util'
import AddRules from './addRules.vue'
export default {
  components: {
    GlsxDialog,
    AddRules,
  },
  data() {
    return {
      formInline: {},
      tableData: [],
      tableLoading: false,
      pageTotal: 0,
      currentPage: 1,
      pageSizes: [10, 20, 30, 40],
      pageSize: 10,
      tdWidth: 170,
      showDialog: false,
      deviceList: [],
      projectList: [],
      modulesList: [],
      eloading: false,
      current: {},
      dloading: false,
      addPopup: false,
      aloading: false,
      ruleInfo: {},
      rloading: false,
    }
  },
  created() {},

  mounted: function () {
    this.getProject()
    this.getDevice()
    this.getModules()
    this.getList()
  },
  methods: {
    /**
     * 查询列表
     */
    getList: function (current) {
      const _this = this
      const oParams = _this.getParams()
      console.log(current)
      oParams.pageNum = current || _this.currentPage
      _this.tableLoading = true
      PAGEEXSYSDISPATCHRULE(oParams).then((res) => {
        console.log(res)
        _this.tableLoading = false
        if (res.returnCode == 0) {
          const { data } = res
          const { total, listVo } = data
          _this.tableData = listVo || []
          _this.pageTotal = total
        }
      })
    },

    /**
     * 获取查询参数
     */
    getParams: function () {
      let oParams = deepClone(this.formInline)
      oParams.pageSize = this.pageSize
      return oParams
    },

    /**
     * 每页展示
     */
    changePageSize: function (e) {
      this.pageSize = e
      this.getList()
    },

    // 打开弹框
    openDialog(row) {
      this.current = row
      this.showDialog = true
      this.getInfo(row)
    },

    /**关闭弹框 */
    closeDialog: function () {
      this.showDialog = false
    },

    // 获取项目列表
    getProject() {
      GETLISTSUBJECT().then((res) => {
        this.projectList = res.data || []
      })
    },

    // 获取设备大类列表
    getDevice() {
      GETLISTDEVICETYPE().then((res) => {
        this.deviceList = res.data || []
      })
    },

    // 获取入库平台
    getModules() {
      GETLISTMODULES().then((res) => {
        this.modulesList = res.data || []
      })
    },

    // 导出excel
    downloadExcel() {
      let _this = this
      let oParams = this.getParams()
      delete oParams.pageSize
      _this.eloading = true
      EXPORTEXSYSDISPATCHRULE(oParams)
        .then((res) => {
          _this.eloading = false
        })
        .catch((error) => {
          _this.eloading = false
        })
    },

    // 删除分发规则
    removeRules() {
      let _this = this
      let oParams = {}
      oParams.ruleCode = _this.current.ruleCode
      console.log(_this.current)
      _this.dloading = true
      DELEXSYSDISPATCHRULE(oParams).then((res) => {
        _this.dloading = false
        if (res.returnCode == 0) {
          showToast({
            message: '删除成功',
            type: 'success',
          })
          _this.getList()
          _this.closeDialog()
        }
      })
    },

    // 保存数据
    saveInfo() {
      this.aloading = true
      this.$refs.addRulesComponent.saveInfo()
    },

    // 打开新增弹框
    openAddPopup() {
      this.addPopup = true
    },

    // 关闭新增弹框
    closeAddPopup() {
      this.addPopup = false
    },

    // 监听组件变化
    onChange(e) {
      this.aloading = false
      if (e) {
        this.addPopup = false
        this.getList()
      }
    },

    // 获取规则详情
    getInfo(row) {
      this.rloading = true
      GETEXSYSDISPATCHRULE({ ruleCode: row.ruleCode }).then((res) => {
        this.rloading = false
        this.ruleInfo = res.data.dto
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.table_box {
  margin: 10px 0;
}

.remove_box {
  width: 80%;
  margin: 0 auto;
  .tips {
    font-size: 14px;
    color: #f00;
    font-weight: normal;
  }
  .row_form {
    display: flex;
    flex-wrap: wrap;
    .cell {
      flex: 0 0 50%;
      display: flex;
      padding: 10px 0;
      .name {
        width: 120px;
        text-align: right;
        flex-shrink: 0;
      }
      .txt_box {
        flex: 0 0 1;
      }
    }
  }
}
.flag_list {
  p {
    margin: 0;
    padding: 0;
  }
}
</style>