Commit 6faec595 by 林家欣

联调商品分类

parent 6666637e
<template>
<el-dialog
:title="!dataForm.categoryid ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
<el-form-item label="分类名称" prop="category">
<el-input v-model="dataForm.category" placeholder="请输入分类名称"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
categoryid: 0,
category: '',
},
dataRule: {
category: [
{ required: true, message: '分类名称不能为空', trigger: 'blur' }
],
}
}
},
methods: {
init (id) {
this.dataForm.categoryid = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.categoryid) {
this.$http({
url: this.$http.adornUrl(`/office/pcategory/info/${this.dataForm.categoryid}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.category = data.pcategory.category
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/office/pcategory/${!this.dataForm.categoryid ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'categoryid': this.dataForm.categoryid || undefined,
'category': this.dataForm.category,
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
}
}
}
</script>
<template>
<div class="mod-config">
<div class="add-btn">
<el-button
v-if="isAuth('manage:center:save')"
type="primary"
@click="addOrUpdateHandle()"
>
+ 添加分类</el-button
>
</div>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%"
>
<el-table-column
prop="categoryid"
header-align="center"
align="center"
label="编号"
width="100"
>
</el-table-column>
<el-table-column
prop="category"
header-align="center"
align="center"
label="类型"
>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
label="操作"
>
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click="addOrUpdateHandle(scope.row.categoryid)"
>编辑</el-button
>
<el-button
type="text"
size="small"
@click="deleteHandle(scope.row.categoryid)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update
v-if="addOrUpdateVisible"
ref="addOrUpdate"
@refreshDataList="getDataList"
></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from "./pcategory-add-or-update";
export default {
data() {
return {
dataForm: {
key: "",
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false,
};
},
components: {
AddOrUpdate,
},
activated() {
this.getDataList();
},
methods: {
// 获取数据列表
getDataList() {
this.dataListLoading = true;
this.$http({
url: this.$http.adornUrl("/office/pcategory/list"),
method: "get",
params: this.$http.adornParams({
page: this.pageIndex,
limit: this.pageSize,
key: this.dataForm.key,
}),
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataList = data.page.list;
this.totalPage = data.page.totalCount;
} else {
this.dataList = [];
this.totalPage = 0;
}
this.dataListLoading = false;
});
},
// 每页数
sizeChangeHandle(val) {
this.pageSize = val;
this.pageIndex = 1;
this.getDataList();
},
// 当前页
currentChangeHandle(val) {
this.pageIndex = val;
this.getDataList();
},
// 多选
selectionChangeHandle(val) {
this.dataListSelections = val;
},
// 新增 / 修改
addOrUpdateHandle(id) {
this.addOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id);
});
},
// 删除
deleteHandle(id) {
var ids = id
? [id]
: this.dataListSelections.map((item) => {
return item.categoryid;
});
this.$confirm(
`确定对[id=${ids.join(",")}]进行[${id ? "删除" : "批量删除"}]操作?`,
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
).then(() => {
this.$http({
url: this.$http.adornUrl("/office/pcategory/delete"),
method: "post",
data: this.$http.adornData(ids, false),
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.getDataList();
},
});
} else {
this.$message.error(data.msg);
}
});
});
},
},
};
</script>
<template>
<el-dialog
:title="!dataForm.branchCode ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
<el-form-item label="${column.comments}" prop="branchName">
<el-input v-model="dataForm.branchName" placeholder="${column.comments}"></el-input>
</el-form-item>
<el-form-item label="${column.comments}" prop="branchAddress">
<el-input v-model="dataForm.branchAddress" placeholder="${column.comments}"></el-input>
</el-form-item>
<el-form-item label="${column.comments}" prop="branchPostcode">
<el-input v-model="dataForm.branchPostcode" placeholder="${column.comments}"></el-input>
</el-form-item>
<el-form-item label="${column.comments}" prop="branchContact">
<el-input v-model="dataForm.branchContact" placeholder="${column.comments}"></el-input>
</el-form-item>
<el-form-item label="${column.comments}" prop="tel1">
<el-input v-model="dataForm.tel1" placeholder="${column.comments}"></el-input>
</el-form-item>
<el-form-item label="${column.comments}" prop="tel2">
<el-input v-model="dataForm.tel2" placeholder="${column.comments}"></el-input>
</el-form-item>
<el-form-item label="${column.comments}" prop="fax">
<el-input v-model="dataForm.fax" placeholder="${column.comments}"></el-input>
</el-form-item>
<el-form-item label="${column.comments}" prop="rockkey">
<el-input v-model="dataForm.rockkey" placeholder="${column.comments}"></el-input>
</el-form-item>
<el-form-item label="${column.comments}" prop="branchSimname">
<el-input v-model="dataForm.branchSimname" placeholder="${column.comments}"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
branchCode: 0,
branchName: '',
branchAddress: '',
branchPostcode: '',
branchContact: '',
tel1: '',
tel2: '',
fax: '',
rockkey: '',
branchSimname: ''
},
dataRule: {
branchName: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
],
branchAddress: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
],
branchPostcode: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
],
branchContact: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
],
tel1: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
],
tel2: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
],
fax: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
],
rockkey: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
],
branchSimname: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init (id) {
this.dataForm.branchCode = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.branchCode) {
this.$http({
url: this.$http.adornUrl(`/office/branch/info/${this.dataForm.branchCode}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.branchName = data.branch.branchName
this.dataForm.branchAddress = data.branch.branchAddress
this.dataForm.branchPostcode = data.branch.branchPostcode
this.dataForm.branchContact = data.branch.branchContact
this.dataForm.tel1 = data.branch.tel1
this.dataForm.tel2 = data.branch.tel2
this.dataForm.fax = data.branch.fax
this.dataForm.rockkey = data.branch.rockkey
this.dataForm.branchSimname = data.branch.branchSimname
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/manage/branch/${!this.dataForm.branchCode ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'branchCode': this.dataForm.branchCode || undefined,
'branchName': this.dataForm.branchName,
'branchAddress': this.dataForm.branchAddress,
'branchPostcode': this.dataForm.branchPostcode,
'branchContact': this.dataForm.branchContact,
'tel1': this.dataForm.tel1,
'tel2': this.dataForm.tel2,
'fax': this.dataForm.fax,
'rockkey': this.dataForm.rockkey,
'branchSimname': this.dataForm.branchSimname
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
}
}
}
</script>
<template>
<div class="mod-config">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('manage:branch:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="isAuth('manage:branch:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item>
</el-form>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%;">
<el-table-column
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
<el-table-column
prop="branchCode"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
prop="branchName"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
prop="branchAddress"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
prop="branchPostcode"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
prop="branchContact"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
prop="tel1"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
prop="tel2"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
prop="fax"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
prop="rockkey"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
prop="branchSimname"
header-align="center"
align="center"
label="${column.comments}">
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.branchCode)">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.branchCode)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from './branch-add-or-update'
export default {
data () {
return {
dataForm: {
key: ''
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false
}
},
components: {
AddOrUpdate
},
activated () {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/office/branch/list'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.dataForm.key
})
}).then(({data}) => {
if (data && data.code === 0) {
this.dataList = data.page.list
this.totalPage = data.page.totalCount
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
// 多选
selectionChangeHandle (val) {
this.dataListSelections = val
},
// 新增 / 修改
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
// 删除
deleteHandle (id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.branchCode
})
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/office/branch/delete'),
method: 'post',
data: this.$http.adornData(ids, false)
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
})
})
}
}
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment