<template>
|
<el-drawer
|
direction="rtl"
|
:visible.sync="visible"
|
@close="handleClose"
|
size="50%">
|
<div class="mod-app-menu" style="padding: 5px;">
|
<el-form :inline="true" :model="dataForm" ref="dataForm" @keyup.enter.native="getDataList()" label-width="10px">
|
<el-form-item prop="itemText">
|
<el-input size="mini" v-model="dataForm.itemText" :placeholder="$t('sysDictItem.itemText')"
|
clearable></el-input>
|
</el-form-item>
|
<el-form-item>
|
<el-button size="mini" @click="getDataList()">{{ $t('query') }}</el-button>
|
</el-form-item>
|
<el-form-item>
|
<el-button size="mini" v-if="$hasPermission('sys:dict:save')" type="primary" @click="openForm()">{{
|
$t('add') }}
|
</el-button>
|
</el-form-item>
|
<el-form-item>
|
<el-button size="mini" type="primary" @click="enableBatch()">{{ $t('enableBatch') }}</el-button>
|
</el-form-item>
|
<el-form-item>
|
<el-button size="mini" type="danger" @click="disableBatch()">{{ $t('disableBatch') }}</el-button>
|
</el-form-item>
|
</el-form>
|
<el-table v-loading="dataListLoading" :data="dataList" row-key="id" border style="width: 100%;"
|
@selection-change="dataListSelectionChangeHandle">
|
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
<el-table-column prop="itemText" :label="$t('prodParamMz.itemText')" header-align="center"
|
align="center" min-width="150"></el-table-column>
|
<el-table-column prop="itemValue" :label="$t('prodParamMz.itemValue')" header-align="center"
|
align="center" min-width="100"></el-table-column>
|
<el-table-column prop="sortOrder" :label="$t('prodParamMc.sortOrder')" header-align="center"
|
align="center" min-width="50"></el-table-column>
|
<el-table-column prop="status" :label="$t('sysDictItem.status')" header-align="center"
|
align="center" min-width="80">
|
<template slot-scope="scope">
|
<el-tag v-if="scope.row.status === 1" size="small">{{ $t('enableStatus1') }}</el-tag>
|
<el-tag v-else size="small" type="danger">{{ $t('enableStatus0') }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="100">
|
<template slot-scope="scope">
|
<el-button v-if="$hasPermission('sys:menu:update')" type="text" size="small" @click="openForm(scope.row.id)">修改</el-button>
|
<el-button v-if="$hasPermission('sys:menu:delete')" type="text" size="small" @click="handleDelete(scope.row.id)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-pagination
|
:current-page="page"
|
:page-sizes="[10, 20, 50, 100]"
|
:page-size="limit"
|
:total="total"
|
layout="total, sizes, prev, pager, next, jumper"
|
@size-change="pageSizeChangeHandle"
|
@current-change="pageCurrentChangeHandle">
|
</el-pagination>
|
<!-- 弹窗, 新增 / 修改 -->
|
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
</div>
|
</el-drawer>
|
</template>
|
<script>
|
import mixinViewModule from '@/mixins/view-module'
|
import AddOrUpdate from './item-add-or-update'
|
import {getDictItem} from "@/utils/dictUtils";
|
|
export default {
|
mixins: [mixinViewModule],
|
data() {
|
return {
|
mixinViewModuleOptions: {
|
createdIsNeed: false,
|
getDataListURL: '/iailab-iems-system/sys/dict-item/page',
|
getDataListIsPage: true,
|
deleteURL: '/iailab-iems-system/sys/dict-item',
|
deleteIsBatch: true
|
},
|
visible: false,
|
dataForm: {
|
dictId: '',
|
dictCode: '',
|
itemText: ''
|
},
|
}
|
},
|
components: {
|
AddOrUpdate
|
},
|
methods: {
|
init(dictId, dictCode) {
|
this.dataForm.dictId = dictId
|
this.dataForm.dictCode = dictCode
|
this.visible = true
|
this.$nextTick(() => {
|
this.getDataList()
|
})
|
},
|
|
getDictItemValue(value) {
|
let data = getDictItem(this.dictCodeMz, value)
|
return data ? data.itemText : '';
|
},
|
|
openForm(id) {
|
this.addOrUpdateVisible = true
|
this.$nextTick(() => {
|
this.$refs.addOrUpdate.init(id, this.dataForm.dictId,this.dataForm.dictCode)
|
})
|
},
|
|
handleClose() {
|
this.$refs['dataForm'].resetFields()
|
this.dataList = []
|
},
|
|
// 批量启用
|
enableBatch (id) {
|
if (!id && this.dataListSelections.length <= 0) {
|
return this.$message({
|
message: this.$t('prompt.deleteBatch'),
|
type: 'warning',
|
duration: 500
|
})
|
}
|
this.$confirm(this.$t('prompt.info', { 'handle': this.$t('enableStatus1') }), this.$t('prompt.title'), {
|
confirmButtonText: this.$t('confirm'),
|
cancelButtonText: this.$t('cancel'),
|
type: 'warning'
|
}).then(() => {
|
this.$http.put('/iailab-iems-system/sys/dict-item/enable', id ? [id] : this.dataListSelections.map(item => item.id)).then(({ data: res }) => {
|
if (res.code !== 0) {
|
return this.$message.error(res.msg)
|
}
|
this.$message({
|
message: this.$t('prompt.success'),
|
type: 'success',
|
duration: 500,
|
onClose: () => {
|
this.getDataList()
|
}
|
})
|
}).catch(() => {})
|
}).catch(() => {})
|
},
|
|
// 批量禁用
|
disableBatch (id) {
|
if (!id && this.dataListSelections.length <= 0) {
|
return this.$message({
|
message: this.$t('prompt.deleteBatch'),
|
type: 'warning',
|
duration: 500
|
})
|
}
|
this.$confirm(this.$t('prompt.info', { 'handle': this.$t('enableStatus0') }), this.$t('prompt.title'), {
|
confirmButtonText: this.$t('confirm'),
|
cancelButtonText: this.$t('cancel'),
|
type: 'warning'
|
}).then(() => {
|
this.$http.put('/iailab-iems-system/sys/dict-item/disable', id ? [id] : this.dataListSelections.map(item => item.id)).then(({ data: res }) => {
|
if (res.code !== 0) {
|
return this.$message.error(res.msg)
|
}
|
this.$message({
|
message: this.$t('prompt.success'),
|
type: 'success',
|
duration: 500,
|
onClose: () => {
|
this.getDataList()
|
}
|
})
|
}).catch(() => {})
|
}).catch(() => {})
|
}
|
}
|
}
|
</script>
|