123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <template>
- <a-card :bordered="false" class="network-table-page-search-wrapper">
- <div class="network-searchForm">
- <a-form layout="inline" :form="form" ref="form" v-bind="formItemLayout" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="48">
- <a-col :span="6">
- <a-form-item label="箱体类型名称" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
- <a-input id="boxSetting-name" allowClear :maxLength="30" v-model="queryParam.name" placeholder="请输入箱体类型名称" />
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-button class="handle-btn serach-btn" id="boxSetting-btn-serach" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
- <a-button class="handle-btn" type="" id="boxSetting-btn-reset" @click="handleReset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <div class="table-operator">
- <a-button type="primary" icon="plus" @click="openModal" id="roleList-openModal" v-hasPermission="'B_boxSetting_add'">新增</a-button>
- </div>
- <s-table
- ref="table"
- size="default"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- bordered>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-icon type="edit" title="编辑" class="actionBtn icon-blues" @click="handleEdit(record)" v-hasPermission="'B_boxSetting_edit'" />
- <a-icon type="delete" title="删除" class="actionBtn icon-red" @click="delect(record)" v-if="$hasPermissions('B_boxSetting_del') && !record.isEnable"/>
- <span v-if="!$hasPermissions('B_boxSetting_edit') && (!$hasPermissions('B_boxSetting_del') && !record.isEnable)">--</span>
- </template>
- </s-table>
- <!-- 新增/编辑 弹窗 -->
- <add-box-modal :visible="openBoxModal" :id="itemId" @refresh="refreshTable" @close="openBoxModal = false"></add-box-modal>
- </a-card>
- </template>
- <script>
- import {
- STable,
- VSelect
- } from '@/components'
- import AddBoxModal from './AddBoxModal.vue'
- import {
- getBoxList,
- deleteBoxSetting
- } from '@/api/boxSetting.js'
- export default {
- name: 'Equipment',
- components: {
- STable,
- VSelect,
- AddBoxModal
- },
- data () {
- return {
- form: this.$form.createForm(this),
- formItemLayout: {
- labelCol: {
- span: 7
- },
- wrapperCol: {
- span: 17
- }
- },
- // 查询参数
- queryParam: {
- name: '' // 箱体类型
- },
- openBoxModal: false, // 新增/编辑弹窗
- itemId: '', // 箱体id
- // 表头
- columns: [{
- title: '序号',
- dataIndex: 'no',
- width: 80,
- align: 'center'
- },
- {
- title: '创建时间',
- dataIndex: 'createDate',
- width: 200,
- align: 'center'
- },
- {
- title: '箱体类型名称',
- dataIndex: 'name',
- width: 200,
- align: 'center'
- },
- {
- title: '内置箱体数量(个)',
- dataIndex: 'boxNum',
- width: 200,
- align: 'center'
- },
- {
- title: '内置箱体投放限重(kg)/ 对应资源分类',
- children: [{
- title: '1号箱',
- dataIndex: 'one',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.maxWeight ? (record.maxWeight + '/' + record.rubbishTypeDictValue) : '--') : '--'
- }
- },
- {
- title: '2号箱',
- dataIndex: 'two',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.maxWeight ? (record.maxWeight + '/' + record.rubbishTypeDictValue) : '--') : '--'
- }
- },
- {
- title: '3号箱',
- dataIndex: 'three',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.maxWeight ? (record.maxWeight + '/' + record.rubbishTypeDictValue) : '--') : '--'
- }
- },
- {
- title: '4号箱',
- dataIndex: 'four',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.maxWeight ? (record.maxWeight + '/' + record.rubbishTypeDictValue) : '--') : '--'
- }
- },
- {
- title: '5号箱',
- dataIndex: 'five',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.maxWeight ? (record.maxWeight + '/' + record.rubbishTypeDictValue) : '--') : '--'
- }
- }
- ]
- },
- {
- title: '操作',
- scopedSlots: {
- customRender: 'action'
- },
- width: 240,
- align: 'center'
- }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- return getBoxList(Object.assign(parameter, this.queryParam)).then(res => {
- if (res.status == 200) {
- const no = (res.data.pageNo - 1) * res.data.pageSize
- for (let i = 0; i < res.data.list.length; i++) {
- const _item = res.data.list[i]
- _item.no = no + i + 1
- }
- return res.data
- }
- })
- }
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {
- vm.queryParam.name = ''
- })
- },
- methods: {
- // 重置
- handleReset () {
- console.log('重置', this.queryParam)
- this.form.resetFields()
- this.queryParam.name = ''
- this.$refs.table.refresh(true)
- },
- // 新建
- openModal () {
- this.openBoxModal = true
- this.itemId = ''
- },
- // 编辑
- handleEdit (item) {
- this.openBoxModal = true
- this.itemId = item.id
- },
- // 新增/编辑 后刷新列表
- refreshTable () {
- if (this.itemId) {
- this.$refs.table.refresh()
- } else {
- this.$refs.table.refresh(true)
- }
- },
- // 删除
- delect (row) {
- const _this = this
- this.$confirm({
- title: '警告',
- centered: true,
- content: '删除后无法恢复,确认删除?',
- okText: '确定',
- cancelText: '取消',
- onOk () {
- deleteBoxSetting({
- id: row.id
- }).then(res => {
- console.log(res, 'res1111')
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- }
- })
- }
- })
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .network-table-page-search-wrapper {
- .network-searchForm {
- .ant-form-inline .ant-form-item {
- width: 100%;
- }
- // 搜索框的下间距
- .ant-form-item {
- margin-bottom: 10px;
- }
- .handle-btn {
- margin-top: 4px;
- }
- .serach-btn {
- margin-right: 10px;
- }
- }
- .actionBtn {
- font-size: 20px;
- padding: 0 10px;
- }
- // 合计
- .total {
- margin: 15px 0 25px;
- width: 100%;
- background-color: #e6f7ff;
- border: 1px solid #91d5ff;
- padding: 8px 15px 8px 27px;
- border-radius: 4px;
- .iconImg {
- color: #1890FF;
- margin-right: 10px;
- }
- }
- }
- </style>
|