123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <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">新增</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)" />
- <a-icon
- type="delete"
- title="删除"
- class="actionBtn icon-red"
- v-if="!record.isEnable"
- @click="delect(record)" />
- </template>
- </s-table>
- <!-- 新增/编辑 弹窗 -->
- <add-set-modal :visible="openBoxModal" :data="itemData" @refresh="refreshTable" @close="openBoxModal = false"></add-set-modal>
- </a-card>
- </template>
- <script>
- import {
- STable,
- VSelect
- } from '@/components'
- import AddSetModal from './AddSetModal.vue'
- import { getList, deleteExchangeSetting } from '@/api/exchangeSetting.js'
- export default {
- name: 'Equipment',
- components: {
- STable,
- VSelect,
- AddSetModal
- },
- data () {
- return {
- form: this.$form.createForm(this),
- formItemLayout: {
- labelCol: {
- span: 7
- },
- wrapperCol: {
- span: 17
- }
- },
- // 查询参数
- queryParam: {
- name: '' // 箱体类型
- },
- openBoxModal: false, // 新增/编辑弹窗
- boxId: '', // 箱体id
- // 表头
- columns: [{
- title: '序号',
- dataIndex: 'no',
- width: 80,
- align: 'center'
- },
- {
- title: '创建时间',
- dataIndex: 'networkName',
- width: 200,
- align: 'center'
- },
- {
- title: '兑换规则名称',
- dataIndex: 'address',
- width: 200,
- align: 'center'
- },
- {
- title: '兑换规则说明',
- dataIndex: 'equipmentNo',
- width: 200,
- align: 'center'
- },
- {
- title: '兑换规则(投放重量(g)/可兑换乐豆数(个))',
- children: [{
- title: '废旧衣服',
- dataIndex: 'oProportion',
- width: 100,
- align: 'center'
- },
- {
- title: '废旧塑料',
- dataIndex: 'tProportion',
- width: 100,
- align: 'center'
- },
- {
- title: '废旧金属',
- dataIndex: 'tProportion',
- width: 100,
- align: 'center',
- customRender: (record, index) => {
- return record.tProportion || '--'
- }
- },
- {
- title: '废旧纸张',
- dataIndex: 'tProportion',
- width: 100,
- align: 'center',
- customRender: (record, index) => {
- return record.tProportion || '--'
- }
- },
- {
- title: '有害垃圾',
- dataIndex: 'tProportion',
- width: 100,
- align: 'center',
- customRender: (record, index) => {
- return record.tProportion || '--'
- }
- }
- ]
- },
- {
- title: '操作',
- scopedSlots: {
- customRender: 'action'
- },
- width: 240,
- align: 'center'
- }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- return getList(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.handleReset()
- })
- },
- methods: {
- // 重置
- handleReset () {
- console.log('重置', this.queryParam)
- this.form.resetFields()
- this.$refs.table.refresh(true)
- },
- // 新建
- openModal () {
- this.openBoxModal = true
- this.itemData = {}
- },
- // 编辑
- handleEdit (item) {
- this.openBoxModal = true
- },
- // 删除
- delect (row) {
- const _this = this
- this.$confirm({
- title: '警告',
- centered: true,
- content: '删除后无法恢复,确认删除?',
- okText: '确定',
- cancelText: '取消',
- onOk () {
- deleteExchangeSetting({
- 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>
|