123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- <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="boxSetting-add" v-hasPermission="'B_exchangeSetting_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
- id="boxSetting-edit"
- type="edit"
- title="编辑"
- class="actionBtn icon-blues"
- @click="handleEdit(record)"
- v-hasPermission="'B_exchangeSetting_edit'"/>
- <a-icon
- id="boxSetting-del"
- type="delete"
- title="删除"
- class="actionBtn icon-red"
- v-if="$hasPermissions('B_exchangeSetting_del') && !record.isEnable"
- @click="delect(record)" />
- <span v-if="!$hasPermissions('B_exchangeSetting_edit') && (!$hasPermissions('B_exchangeSetting_del') && !record.isEnable)">--</span>
- </template>
- </s-table>
- <!-- 新增/编辑 弹窗 -->
- <add-set-modal :visible="openBoxModal" :goldExRuleNo="itemGoldExRuleNo" :id="itemId" @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, // 新增/编辑弹窗
- itemId: '', // 新增/编辑id
- itemGoldExRuleNo: '', // 兑换编码
- // 表头
- columns: [{
- title: '序号',
- dataIndex: 'no',
- width: 80,
- align: 'center'
- },
- {
- title: '创建时间',
- dataIndex: 'createDate',
- width: 200,
- align: 'center'
- },
- {
- title: '兑换规则名称',
- dataIndex: 'name',
- width: 200,
- align: 'center'
- },
- {
- title: '兑换规则说明',
- dataIndex: 'remarks',
- width: 200,
- align: 'center'
- },
- {
- title: '兑换规则(投放重量(g)/可兑换乐豆数(个))',
- children: [{
- title: '废旧衣物',
- dataIndex: 'clothes',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '不兑换') : '不兑换'
- }
- },
- {
- title: '废旧塑料',
- dataIndex: 'plastic',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '不兑换') : '不兑换'
- }
- },
- {
- title: '废旧金属',
- dataIndex: 'metal',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '不兑换') : '不兑换'
- }
- },
- {
- title: '废旧纸张',
- dataIndex: 'paper',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '不兑换') : '不兑换'
- }
- },
- {
- title: '有害垃圾',
- dataIndex: 'harm',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '不兑换') : '不兑换'
- }
- },
- {
- title: '废旧金属/塑料',
- dataIndex: 'metPla',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '不兑换') : '不兑换'
- }
- },
- {
- title: '废旧玻璃',
- dataIndex: 'glass',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '不兑换') : '不兑换'
- }
- },
- {
- title: '可回收物',
- dataIndex: 'recycling',
- width: 100,
- align: 'center',
- customRender: (record, text) => {
- return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '不兑换') : '不兑换'
- }
- }
- ]
- },
- {
- 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.queryParam.name = ''
- })
- },
- methods: {
- // 重置
- handleReset () {
- this.queryParam.name = ''
- this.$refs.table.refresh(true)
- },
- // 新增/编辑 后刷新列表
- refreshTable () {
- if (this.itemId) {
- this.$refs.table.refresh()
- } else {
- this.$refs.table.refresh(true)
- }
- },
- // 新建
- openModal () {
- this.openBoxModal = true
- this.itemId = ''
- this.itemGoldExRuleNo = ''
- },
- // 编辑
- handleEdit (item) {
- this.openBoxModal = true
- this.itemId = item.id
- this.itemGoldExRuleNo = item.goldExRuleNo
- },
- // 删除
- 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>
|