rt-sim-training-client/src/views/orderauthor/commodity/index.vue

222 lines
9.1 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList">
</QueryListPage>
</div>
</template>
<script>
import { getCommodityList, delCommodity, setCommodityStatus } from '@/api/management/goods';
import { UrlConfig } from '@/router/index';
import { listPublishMap } from '@/api/jmap/map';
export default {
name: 'Dictionary',
data() {
return {
productTypeList: [],
EffectiveTypeList: [],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '80px',
reset: true,
queryObject: {
name: {
type: 'text',
2019-08-12 18:54:32 +08:00
label: this.$t('orderAuthor.name')
2019-07-26 13:32:43 +08:00
},
productType: {
type: 'select',
2019-08-12 18:54:32 +08:00
label: this.$t('orderAuthor.productType'),
2019-07-26 13:32:43 +08:00
config: {
data: []
}
},
mapId: {
type: 'select',
2019-08-12 18:54:32 +08:00
label: this.$t('orderAuthor.map'),
2019-07-26 13:32:43 +08:00
config: {
data: []
}
},
status: {
type: 'select',
2019-08-12 18:54:32 +08:00
label: this.$t('orderAuthor.state'),
2019-07-26 13:32:43 +08:00
config: {
data: this.$ConstSelect.Status
}
}
}
},
queryList: {
query: getCommodityList,
selectCheckShow: false,
indexShow: true,
columns: [
{
2019-08-12 18:54:32 +08:00
title: this.$t('orderAuthor.commodityName'),
2019-07-26 13:32:43 +08:00
prop: 'name'
},
{
2019-08-12 18:54:32 +08:00
title: this.$t('orderAuthor.productType'),
2019-07-26 13:32:43 +08:00
prop: 'productType',
type: 'tag',
2019-08-08 15:57:36 +08:00
columnValue: (row) => { return this.$convertField(row.productType, this.productTypeList, ['value', 'label']) },
2019-07-26 13:32:43 +08:00
tagType: (row) => { return 'success' }
},
{
2019-08-12 18:54:32 +08:00
title: this.$t('orderAuthor.mapName'),
2019-07-26 13:32:43 +08:00
prop: 'mapName',
},
{
2019-08-12 18:54:32 +08:00
title: this.$t('orderAuthor.productName'),
2019-07-26 13:32:43 +08:00
prop: 'prdName',
},
{
2019-08-12 18:54:32 +08:00
title: this.$t('orderAuthor.courseName'),
2019-07-26 13:32:43 +08:00
prop: 'lessonName',
},
{
2019-08-12 18:54:32 +08:00
title: this.$t('orderAuthor.price'),
2019-07-26 13:32:43 +08:00
prop: 'price'
},
{
2019-08-12 18:54:32 +08:00
title: this.$t('orderAuthor.state'),
2019-07-26 13:32:43 +08:00
prop: 'status',
type: 'tag',
2019-08-08 15:57:36 +08:00
columnValue: (row) => { return this.$convertField(row.status, this.EffectiveTypeList, ['value', 'label']) },
2019-07-26 13:32:43 +08:00
tagType: (row) => {
switch (row.status) {
case '1': return 'success';
default: return 'danger';
}
}
},
{
2019-08-12 18:54:32 +08:00
title: this.$t('orderAuthor.describtion'),
2019-07-26 13:32:43 +08:00
prop: 'remarks'
},
{
2019-08-12 18:54:32 +08:00
title: this.$t('orderAuthor.creationTime'),
2019-07-26 13:32:43 +08:00
prop: 'createTime'
},
{
type: 'button',
2019-08-12 18:54:32 +08:00
title: this.$t('global.operate'),
2019-07-26 13:32:43 +08:00
width: '250',
buttons: [
{
2019-08-12 18:54:32 +08:00
name: this.$t('global.edit'),
2019-07-26 13:32:43 +08:00
type: 'primary',
handleClick: this.handleEdit
},
{
2019-08-12 18:54:32 +08:00
name: this.$t('orderAuthor.setupFailure'),
2019-07-26 13:32:43 +08:00
handleClick: this.handleEfficacy,
type: 'warning',
showControl: (row) => {
return row.status == '1';
}
},
{
2019-08-12 18:54:32 +08:00
name: this.$t('orderAuthor.setupEffective'),
2019-07-26 13:32:43 +08:00
type: 'primary',
handleClick: this.handleEfficacy,
showControl: (row) => {
return row.status == '0';
}
},
{
2019-08-12 18:54:32 +08:00
name: this.$t('global.delete'),
2019-07-26 13:32:43 +08:00
type: 'danger',
handleClick: this.handleDelete,
},
]
}
],
actions: [
2019-08-12 18:54:32 +08:00
{ text: this.$t('global.add'), handler: this.handleAdd },
2019-07-26 13:32:43 +08:00
]
},
currentModel: {}
}
},
mounted() {
this.loadInitData();
},
methods: {
async loadInitData() {
this.$Dictionary.effectiveType().then(list => {
2019-08-08 15:57:36 +08:00
this.$convertList(list, this.EffectiveTypeList, elem => {
2019-07-26 13:32:43 +08:00
return true;
});
});
// 产品类型
this.$Dictionary.productType().then(list => {
list.forEach(elem => {
this.queryForm.queryObject.productType.config.data.push({ value: elem.code, label: elem.name });
});
2019-08-08 15:57:36 +08:00
this.$convertList(list, this.productTypeList, elem => {
2019-07-26 13:32:43 +08:00
return true;
});
});
try {
// 获取地图
let res = await listPublishMap();
res.data.forEach(elem => {
this.queryForm.queryObject.mapId.config.data.push({ value: elem.id, label: elem.name });
});
} catch (error) {
console.error(error, '获取发布地图');
}
},
handleEdit(index, row) {
this.$router.push({ path: `${UrlConfig.orderauthor.commodityDraft}/edit/${row.id}` });
},
handleAdd() {
this.$router.push({ path: `${UrlConfig.orderauthor.commodityDraft}/add/0` });
},
// 设置失效
handleEfficacy(index, row) {
2019-08-12 18:54:32 +08:00
this.$confirm(this.$t('orderAuthor.updateProductTip'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
2019-07-26 13:32:43 +08:00
type: 'warning'
}).then(() => {
setCommodityStatus(row.id).then(res => {
2019-08-12 18:54:32 +08:00
this.$message.success(this.$t('tip.operationSuccessfully'));
2019-07-26 13:32:43 +08:00
this.reloadTable()
}).catch(err => {
2019-08-12 18:54:32 +08:00
this.$messageBox(this.$t('tip.operationFailed'));
2019-07-26 13:32:43 +08:00
this.reloadTable()
})
}).catch(() => { })
},
handleDelete(index, row) {
2019-08-12 18:54:32 +08:00
this.$confirm(this.$t('orderAuthor.deleteProductTip'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
2019-07-26 13:32:43 +08:00
type: 'warning'
}).then(() => {
delCommodity(row.id).then(response => {
2019-08-12 18:54:32 +08:00
this.$message.success(this.$t('tip.successfullyDelete'));
2019-07-26 13:32:43 +08:00
this.reloadTable()
}).catch(error => {
2019-08-12 18:54:32 +08:00
this.reloadTable();
this.$messageBox(this.$t('tip.failDelete'))
2019-07-26 13:32:43 +08:00
})
}).catch(() => { })
},
reloadTable() {
this.queryList.reload()
}
}
}
2019-08-12 18:54:32 +08:00
</script>