<!--
|
- Copyright (c) 2018-2025, ztt All rights reserved.
|
-
|
- Redistribution and use in source and binary forms, with or without
|
- modification, are permitted provided that the following conditions are met:
|
-
|
- Redistributions of source code must retain the above copyright notice,
|
- this list of conditions and the following disclaimer.
|
- Redistributions in binary form must reproduce the above copyright
|
- notice, this list of conditions and the following disclaimer in the
|
- documentation and/or other materials provided with the distribution.
|
- Neither the name of the pig4cloud.com developer nor the names of its
|
- contributors may be used to endorse or promote products derived from
|
- this software without specific prior written permission.
|
- Author: ztt
|
-->
|
|
<template>
|
<div class="app-container calendar-list-container">
|
<basic-container>
|
<avue-crud
|
ref="crud"
|
:option="tableOption"
|
:data="list"
|
:page="page"
|
v-model="form"
|
:table-loading="listLoading"
|
@on-load="getList"
|
@search-change="searchChange"
|
@refresh-change="refreshChange"
|
@size-change="sizeChange"
|
@current-change="currentChange">
|
<template slot="staffName" slot-scope="scope">{{ scope.row.staffName }}</template>
|
<template slot="type" slot-scope="scope">{{ scope.row.type }}</template>
|
<template slot="menuLeft">
|
<el-button
|
v-if="prodManager_btn_add"
|
class="filter-item"
|
type="primary"
|
icon="el-icon-plus"
|
@click="dialogAddVisible=true">添加</el-button>
|
</template>
|
<template slot="menu" slot-scope="scope">
|
<el-button
|
v-if="prodManager_btn_del"
|
type="text"
|
size="small"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row,scope.index)">删除
|
</el-button>
|
</template>
|
</avue-crud>
|
</basic-container>
|
<el-dialog :visible.sync="dialogAddVisible" :close-on-click-modal="false" title="新增配置">
|
<el-form :model="prodForm" :rules="rules" ref="addDialog">
|
<el-form-item prop="staffName" label="用户名称:" label-width="90px">
|
<el-select style="width:100%" v-model="prodForm.staffName">
|
<el-option v-for="(item,index) in staffNamesOptions" :key="index" :value="item.id" :label="item.staffName"/>
|
</el-select>
|
</el-form-item>
|
<el-form-item prop="type" label="类型关键字:" label-width="90px">
|
<el-input style="width:100%" v-model="prodForm.type" placeholder="请输入产品类型关键字"/>
|
</el-form-item>
|
</el-form>
|
<div slot="footer"
|
class="dialog-footer">
|
<el-button type="primary" size="small" @click="createConfirm">确 认</el-button>
|
<el-button type="default" size="small" @click="reset">取消</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { tableOption } from '@/const/crud/admin/productType'
|
import { getList,addObj,delObj,chooseStaff } from '@/api/admin/productType'
|
import { mapGetters } from 'vuex'
|
|
export default {
|
name: 'TableProduct',
|
data() {
|
return {
|
dialogAddVisible: false,
|
prodForm: {
|
staffName: '',
|
type: ''
|
},
|
rules: {
|
staffName:[{ required:true,message:"用户名不能为空", trigger: 'change' }],
|
type:[{required:true,message:"产品类型关键字不能为空", trigger: 'blur'}]
|
},
|
staffNamesOptions: [],
|
tableOption: tableOption,
|
page: {
|
total: 0, // 总页数
|
currentPage: 1, // 当前页数
|
pageSize: 20 // 每页显示多少条
|
},
|
list: [],
|
listLoading: false,
|
form: {},
|
prodManager_btn_add: false,
|
prodManager_btn_del: false,
|
}
|
},
|
created() {
|
this.prodManager_btn_add = this.permissions['sys_prod_add']
|
this.prodManager_btn_del = this.permissions['sys_prod_del']
|
this.getStaffList()
|
},
|
computed: {
|
...mapGetters(['elements', 'permissions'])
|
},
|
methods: {
|
getStaffList(){
|
chooseStaff(Object.assign({})).then(response => {
|
this.staffNamesOptions = response.data.data
|
})
|
},
|
getList(page, params) {
|
this.listLoading = true
|
getList(Object.assign({
|
current: page.currentPage,
|
size: page.pageSize
|
}, params, this.searchForm)).then(response => {
|
this.list = response.data.data
|
this.page.total = response.data.data.total
|
this.listLoading = false
|
}).catch(() => {
|
this.listLoading = false
|
})
|
},
|
refreshChange() {
|
this.getList(this.page)
|
},
|
searchChange(form, done) {
|
this.searchForm = form
|
this.page.currentPage = 1
|
this.getList(this.page, form)
|
done()
|
},
|
sizeChange(pageSize){
|
this.page.pageSize = pageSize
|
},
|
currentChange(current){
|
this.page.currentPage = current
|
},
|
handleCreate() {
|
this.$refs.crud.rowAdd()
|
},
|
createConfirm(){
|
this.$refs['addDialog'].validate(val=>{
|
if(val){
|
addObj({
|
staffId: this.prodForm.staffName,
|
productType: this.prodForm.type
|
}).then(response => {
|
this.dialogAddVisible = false
|
this.$message.success("添加成功")
|
this.refreshChange()
|
}).catch(() => {
|
this.$message.error("添加失败")
|
})
|
}
|
})
|
},
|
reset(){
|
this.dialogAddVisible =false;
|
this.$refs['addDialog'].resetFields()
|
},
|
handleDelete(row, index) {
|
this.$confirm('是否确认删除名称为"' + row.staffName + '"' + '"的数据项?', '警告', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
closeOnClickModal:false,
|
type: 'warning'
|
}).then(function() {
|
return delObj(row.id)
|
}).then(() => {
|
this.getList(this.page)
|
this.$notify.success('删除成功')
|
})
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.el-dialog__wrapper {
|
.el-dialog {
|
width: 61% !important;
|
.dialog-main-tree {
|
max-height: 400px;
|
overflow-y: auto;
|
}
|
}
|
.el-form-item__label {
|
width: 100px !important;
|
padding-right: 20px;
|
}
|
.el-form-item__content {
|
margin-left: 200px !important;
|
}
|
}
|
</style>
|
|