<template>
|
<div>
|
<div style="margin-bottom:5px;">
|
<el-button
|
type="primary"
|
@click="addOrUpdateHandle"
|
:disabled="!indexInfo"
|
>
|
新增
|
</el-button>
|
</div>
|
<el-table
|
stripe
|
ref="labelconfigdetaillist"
|
:data="list"
|
height="600"
|
border
|
:row-style="{ height: '26px' }"
|
:cell-style="{ padding: '0' }"
|
v-loading="loading"
|
>
|
<el-table-column label="序号" type="index" />
|
<el-table-column label="是否启用" min-width="6%">
|
<template slot-scope="{ row }">
|
<el-switch v-model="row.isActive" @change="goEdit(row)" />
|
</template>
|
</el-table-column>
|
<el-table-column label="是否配置数据源" min-width="8%">
|
<template slot-scope="{ row }">
|
<el-switch v-model="row.isConfigDataSource" @change="goEdit(row)" />
|
</template>
|
</el-table-column>
|
<!-- <el-table-column label="标签元素描述" prop="itemCode" min-width="10%" /> -->
|
<el-table-column label="标题" prop="caption" min-width="10%" />
|
<el-table-column label="默认值" prop="defaultValue" min-width="10%" />
|
<el-table-column label="查询sql" prop="qrySql" min-width="30%" />
|
<el-table-column label="创建人" prop="createUser" min-width="8%" />
|
<el-table-column label="创建时间" prop="createTime" min-width="10%" />
|
<el-table-column label="更新人" prop="updateUser" min-width="8%" />
|
<el-table-column label="更新时间" prop="updateTime" min-width="10%" />
|
<el-table-column label="操作" min-width="8%">
|
<template slot-scope="{ row }">
|
<el-button
|
class="commonButton"
|
type="text"
|
@click="deleteHandle(row)"
|
>
|
删除
|
</el-button>
|
<el-button
|
class="commonButton"
|
type="text"
|
@click="addOrUpdateHandle(row)"
|
>
|
修改
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<DetailForm
|
v-if="addOrUpdateVisible"
|
ref="addOrUpdate"
|
:indexInfo="indexInfo"
|
@refreshDataList="getData"
|
/>
|
</div>
|
</template>
|
|
<script>
|
import { fetchList, delObj, putObj } from '@/api/print/configDtl'
|
|
import DetailForm from './DetailForm'
|
import { mapGetters } from 'vuex'
|
|
export default {
|
props: {
|
indexInfo: {
|
type: Object,
|
default: null
|
}
|
},
|
data() {
|
return {
|
addOrUpdateVisible: false,
|
loading: false,
|
list: []
|
}
|
},
|
components: {
|
DetailForm
|
},
|
computed: {
|
...mapGetters(['permissions'])
|
},
|
created() {},
|
watch: {
|
indexInfo: {
|
deep: true,
|
handler(newVal) {
|
if (newVal) {
|
this.init()
|
}
|
}
|
}
|
},
|
methods: {
|
init() {
|
this.getData()
|
},
|
doLayout() {
|
this.$nextTick(() => {
|
this.$refs.labelconfigdetaillist.doLayout()
|
})
|
},
|
getData() {
|
this.loading = true
|
fetchList({
|
mid: this.indexInfo.id
|
}).then((res) => {
|
this.list = res.data.data
|
this.loading = false
|
this.doLayout()
|
})
|
},
|
// 新增 / 修改
|
addOrUpdateHandle(row) {
|
this.addOrUpdateVisible = true
|
this.$nextTick(() => {
|
this.$refs.addOrUpdate.init(row == null ? null : row.id)
|
})
|
},
|
// 删除
|
deleteHandle(row) {
|
this.$confirm('是否确认删除标签元素:' + row.itemCode, '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
closeOnClickModal: false,
|
type: 'warning'
|
})
|
.then(function() {
|
return delObj(row.id)
|
})
|
.then((data) => {
|
this.$message.success('删除成功')
|
this.getData()
|
})
|
},
|
goEdit(row) {
|
putObj({
|
...row,
|
mid: this.indexInfo.id
|
}).then((data) => {
|
if (data.data.code !== 0) {
|
row.isActive = !row.isActive
|
}
|
})
|
}
|
}
|
}
|
</script>
|