<template>
|
<div class="rightContent">
|
<div class="top">
|
<SearchCommonView :add-title="'新建'" :placeholder="'请输入产品类型'" :amount-view="false" @addCommonClick="addBtnClick" @searchClick="getList" />
|
</div>
|
<div class="list-view">
|
<div class="table">
|
<TableCommonView ref="tableListRef" :table-list="tableList" :show-checkcol="false">
|
<template slot="tableButton">
|
<el-table-column label="值类型" align="center">
|
<template slot-scope="scope">
|
<span v-if="scope.row.dataType === 1">字符串</span>
|
<span v-else-if="scope.row.dataType === 2">数值</span>
|
<span v-else>下拉框</span>
|
</template>
|
</el-table-column>
|
|
<el-table-column label="使用者" align="center">
|
<template slot-scope="scope">
|
<span v-if="scope.row.entityType === 1">物料</span>
|
</template>
|
</el-table-column>
|
|
<el-table-column label="操作" width="90" align="center">
|
<template slot-scope="scope">
|
<span @click.stop="editRow(scope.row)" class="cursor_pointer">
|
<span style="color: #2a78fb">编辑</span>
|
</span>
|
<span @click.stop="deleteRow(scope.row)" class="cursor_pointer">
|
<span style="color: #2a78fb; padding-left: 15px">删除</span>
|
</span>
|
</template>
|
</el-table-column>
|
</template>
|
</TableCommonView>
|
</div>
|
<div class="btn-pager">
|
<PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
|
</div>
|
</div>
|
|
<!-- 新建 -->
|
<AddPage v-if="modelObj.add" :modelObj="modelObj" @refresh="refresh" />
|
|
<!-- 编辑 -->
|
<UpdatePage v-if="modelObj.update" :modelObj="modelObj" :ruleForm="rowDate" @refresh="refresh" />
|
</div>
|
</template>
|
|
<script>
|
import { getAttribute, deleteAttribut } from '@/api/product/attributeManage'
|
import AddPage from '@/views/productManage/attributeManage/components/AddPage'
|
import UpdatePage from '@/views/productManage/attributeManage/components/UpdatePage'
|
import pageMixin from '@/components/makepager/pager/mixin/pageMixin'
|
|
export default {
|
name: 'attributeManage',
|
mixins: [pageMixin],
|
computed: {},
|
components: {
|
AddPage,
|
UpdatePage,
|
},
|
data() {
|
return {
|
rowDate: {},
|
modelObj: { add: false, update: false },
|
tableList: {},
|
}
|
},
|
created() {
|
this.tableList = {
|
tableInfomation: [],
|
selectBox: false,
|
selectIndex: true,
|
tableColumn: [
|
{
|
label: '属性名称',
|
prop: 'name',
|
isShowColumn: true,
|
default: true,
|
},
|
],
|
}
|
this.getData()
|
},
|
methods: {
|
// 请求数据
|
async getData() {
|
await getAttribute({
|
keyword: this.keyword,
|
page: this.pagerOptions.currPage,
|
pageSize: this.pagerOptions.pageSize,
|
}).then((res) => {
|
if (res.code === 200) {
|
const list = res.data ? res.data : []
|
this.tableList.tableInfomation = list
|
this.pagerOptions.totalCount = res.total
|
}
|
})
|
},
|
refresh() {
|
this.pagerOptions.currPage = 1
|
this.getData()
|
},
|
// 搜索
|
getList(val) {
|
this.keyword = val
|
this.pagerOptions.currPage = 1
|
this.getData()
|
},
|
|
// 新建
|
addBtnClick() {
|
this.modelObj.add = true
|
},
|
//编辑
|
editRow(row) {
|
if (row.dataType == 3) {
|
|
let arr = [];
|
row.selectValues.forEach(function (value, index, array) {
|
arr.push({ "value": value, "key": Date.now()+index})
|
row.selectValues = arr
|
})
|
}
|
|
this.rowDate = { ...row }
|
this.modelObj.update = true
|
},
|
//删除
|
deleteRow(row) {
|
this.$confirm('此操作将永久删除该产品属性, 是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning',
|
})
|
.then(() => {
|
deleteAttribut({
|
id: row.ID,
|
}).then((res) => {
|
if (res.code == 200) {
|
this.$message({
|
type: 'success',
|
message: '删除成功!',
|
})
|
this.getData()
|
} else {
|
this.$message.error('删除时出错,请稍后重试或联系管理员...')
|
}
|
})
|
})
|
.catch(() => {})
|
},
|
},
|
}
|
</script>
|
|
<style>
|
</style>
|